Move handling of hanging entities into ExtentEntityCopy.

This commit is contained in:
sk89q
2014-07-15 12:09:11 -07:00
parent cf6fa98525
commit 1f709b9cc3
4 changed files with 75 additions and 32 deletions

View File

@ -55,28 +55,9 @@ class ForgeEntity implements Entity {
@Override
public Location getLocation() {
Vector position;
float pitch;
float yaw;
if (entity instanceof EntityHanging) {
EntityHanging hanging = (EntityHanging) entity;
position = new Vector(hanging.xPosition, hanging.yPosition, hanging.zPosition);
Direction direction = MCDirections.fromHanging(hanging.hangingDirection);
if (direction != null) {
yaw = direction.toVector().toYaw();
pitch = direction.toVector().toPitch();
} else {
yaw = (float) Math.toRadians(entity.rotationYaw);
pitch = (float) Math.toRadians(entity.rotationPitch);
}
} else {
position = new Vector(entity.posX, entity.posY, entity.posZ);
yaw = (float) Math.toRadians(entity.rotationYaw);
pitch = (float) Math.toRadians(entity.rotationPitch);
}
Vector position = new Vector(entity.posX, entity.posY, entity.posZ);
float yaw = (float) Math.toRadians(entity.rotationYaw);
float pitch = (float) Math.toRadians(entity.rotationPitch);
return new Location(ForgeAdapter.adapt(entity.worldObj), position, yaw, pitch);
}

View File

@ -551,16 +551,6 @@ public class ForgeWorld extends AbstractWorld {
createdEntity.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), (float) Math.toDegrees(location.getYaw()), (float) Math.toDegrees(location.getPitch()));
// Special handling for hanging entities
if (createdEntity instanceof EntityHanging) {
EntityHanging hanging = (EntityHanging) createdEntity;
hanging.xPosition = location.getBlockX();
hanging.yPosition = location.getBlockY();
hanging.zPosition = location.getBlockZ();
Direction direction = Direction.findClosest(location.getDirection(), Flag.CARDINAL);
hanging.setDirection(MCDirections.toHanging(direction));
}
world.spawnEntityInWorld(createdEntity);
return new ForgeEntity(createdEntity);
} else {