From 89767aedf4ba35fce9c6cdf2af0dd28eaaca42b6 Mon Sep 17 00:00:00 2001 From: Wyatt Childers Date: Wed, 3 Aug 2016 22:09:13 -0400 Subject: [PATCH] Updated for latest Sponge API changes --- .../sk89q/worldedit/sponge/SpongeWorld.java | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java index bbdbb216d..a617cb08f 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java @@ -198,16 +198,13 @@ public abstract class SpongeWorld extends AbstractWorld { return; } - Optional optItem = getWorld().createEntity( + org.spongepowered.api.entity.Entity entity = getWorld().createEntity( EntityTypes.ITEM, new Vector3d(position.getX(), position.getY(), position.getZ()) ); - if (optItem.isPresent()) { - org.spongepowered.api.entity.Entity entity = optItem.get(); - entity.offer(Keys.REPRESENTED_ITEM, SpongeWorldEdit.toSpongeItemStack(item).createSnapshot()); - getWorld().spawnEntity(entity, ENTITY_SPAWN_CAUSE); - } + entity.offer(Keys.REPRESENTED_ITEM, SpongeWorldEdit.toSpongeItemStack(item).createSnapshot()); + getWorld().spawnEntity(entity, ENTITY_SPAWN_CAUSE); } @Override @@ -277,24 +274,21 @@ public abstract class SpongeWorld extends AbstractWorld { EntityType entityType = Sponge.getRegistry().getType(EntityType.class, entity.getTypeId()).get(); Vector3d pos = new Vector3d(location.getX(), location.getY(), location.getZ()); - Optional optNewEnt = world.createEntity(entityType, pos); - if (optNewEnt.isPresent()) { - org.spongepowered.api.entity.Entity newEnt = optNewEnt.get(); - if (entity.hasNbtData()) { - applyEntityData(newEnt, entity); - } + org.spongepowered.api.entity.Entity newEnt = world.createEntity(entityType, pos); + if (entity.hasNbtData()) { + applyEntityData(newEnt, entity); + } - // Overwrite any data set by the NBT application - Vector dir = location.getDirection(); + // Overwrite any data set by the NBT application + Vector dir = location.getDirection(); - newEnt.setLocationAndRotation( - new org.spongepowered.api.world.Location<>(getWorld(), pos), - new Vector3d(dir.getX(), dir.getY(), dir.getZ()) - ); + newEnt.setLocationAndRotation( + new org.spongepowered.api.world.Location<>(getWorld(), pos), + new Vector3d(dir.getX(), dir.getY(), dir.getZ()) + ); - if (world.spawnEntity(newEnt, ENTITY_SPAWN_CAUSE)) { - return new SpongeEntity(newEnt); - } + if (world.spawnEntity(newEnt, ENTITY_SPAWN_CAUSE)) { + return new SpongeEntity(newEnt); } return null;