Changed Location to use Extents rather than worlds and overhauled the new Entity code a bit.

This commit is contained in:
sk89q
2014-06-29 15:36:41 -07:00
parent c9612c05a7
commit eee2c5d9f4
24 changed files with 312 additions and 158 deletions

View File

@ -96,7 +96,7 @@ final class BukkitAdapter {
final double length = Math.sqrt(eyeX * eyeX + eyeZ * eyeZ);
final float pitch = (float) Math.toDegrees(Math.atan2(-direction.getY(), length));
return new org.bukkit.Location(
adapt(location.getWorld()),
adapt((World) location.getExtent()),
position.getX(), position.getY(), position.getZ(),
yaw, pitch);
}

View File

@ -1,44 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.entity.AbstractBaseEntity;
import com.sk89q.worldedit.entity.BaseEntity;
import org.bukkit.entity.EntityType;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* An implementation of a {@link BaseEntity} for Bukkit.
*/
public class BukkitBaseEntity extends AbstractBaseEntity {
private final EntityType type;
public BukkitBaseEntity(EntityType type) {
checkNotNull(type);
this.type = type;
}
public EntityType getBukkitType() {
return type;
}
}

View File

@ -19,8 +19,6 @@
package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.PlayerNeededException;
import com.sk89q.worldedit.WorldEditPermissionException;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.cui.CUIEvent;

View File

@ -22,8 +22,8 @@ package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.metadata.Tameable;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import static com.google.common.base.Preconditions.checkNotNull;
@ -63,7 +63,7 @@ class BukkitEntity implements Entity {
}
@Override
public World getWorld() {
public Extent getExtent() {
return BukkitAdapter.adapt(getEntity().getWorld());
}
@ -74,7 +74,12 @@ class BukkitEntity implements Entity {
@Override
public BaseEntity getState() {
return new BukkitBaseEntity(getEntity().getType());
throw new UnsupportedOperationException("Not implemented yet");
}
@Override
public boolean remove() {
return false;
}
}

View File

@ -184,13 +184,7 @@ public class BukkitWorld extends LocalWorld {
@Nullable
@Override
public com.sk89q.worldedit.entity.Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
if (entity instanceof BukkitBaseEntity) {
BukkitBaseEntity bukkitBaseEntity = (BukkitBaseEntity) entity;
Entity nativeEntity = getWorld().spawnEntity(BukkitAdapter.adapt(location), bukkitBaseEntity.getBukkitType());
return BukkitAdapter.adapt(nativeEntity);
} else {
return null;
}
throw new UnsupportedOperationException("Not implemented yet");
}
private class NmsBlockClassLoader extends ClassLoader {