Added incomplete entity support to all Extents.

The Bukkit implementation supports the new entity API, but it has
not yet been tested. The Forge implementation does not support the
entity API yet.

At the moment, an UnsupportedOperationException is thrown for
Entity.getState() in some implementations, but use of an exception
should probably not be allowed.

BaseEntity is now an interface. It should not be possible to create
instances of BaseEntity because it may be implementation-specific.
This commit is contained in:
sk89q
2014-04-27 23:34:39 -07:00
parent a5c3238876
commit c4c19017bb
17 changed files with 336 additions and 79 deletions

View File

@ -24,6 +24,7 @@ import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.internal.cui.CUIEvent;
@ -51,6 +52,11 @@ public class ForgePlayer extends LocalPlayer {
return this.player.username;
}
@Override
public BaseEntity getState() {
throw new UnsupportedOperationException("Cannot create a state from this object");
}
@Override
public Location getLocation() {
Vector position = new Vector(this.player.posX, this.player.posY, this.player.posZ);

View File

@ -26,6 +26,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.blocks.LazyBlock;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.mapping.NullResolver;
@ -54,6 +55,7 @@ import net.minecraft.world.gen.ChunkProviderServer;
import javax.annotation.Nullable;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
@ -501,6 +503,17 @@ public class ForgeWorld extends AbstractWorld {
return null;
}
@Override
public List<com.sk89q.worldedit.entity.Entity> getEntities() {
return Collections.emptyList();
}
@Nullable
@Override
public com.sk89q.worldedit.entity.Entity createEntity(Location location, BaseEntity entity) {
return null;
}
/**
* Thrown when the reference to the world is lost.
*/