fixed robot re-initialization problems, #1873

This commit is contained in:
SpaceToad 2014-06-11 22:51:41 +02:00
parent 1d642f052c
commit defa5cab45
2 changed files with 20 additions and 9 deletions

View file

@ -84,16 +84,14 @@ public class EntityRobot extends EntityRobotBase implements
board = (RedstoneBoardRobot) RedstoneBoardRegistry.instance.getRedstoneBoard(boardNBT).create(boardNBT, this);
dataWatcher.updateObject(16, board.getNBTHandler().getID());
if (world.isRemote) {
RPCHandler.rpcServer(this, "requestInitialization", itemInUse);
} else {
if (!world.isRemote) {
mainAI = new AIRobotMain(this);
mainAI.start();
}
}
public EntityRobot(World par1World) {
super(par1World);
public EntityRobot(World world) {
super(world);
motionX = 0;
motionY = 0;
@ -153,7 +151,9 @@ public class EntityRobot extends EntityRobotBase implements
}
protected void init() {
if (worldObj.isRemote) {
RPCHandler.rpcServer(this, "requestInitialization");
}
}
public void setLaserDestination (float x, float y, float z) {
@ -459,7 +459,13 @@ public class EntityRobot extends EntityRobotBase implements
@RPC(RPCSide.SERVER)
public void requestInitialization(RPCMessageInfo info) {
RPCHandler.rpcPlayer(info.sender, this, "clientSetItemInUse", itemInUse);
RPCHandler.rpcPlayer(info.sender, this, "rpcInitialize", itemInUse, itemActive);
}
@RPC(RPCSide.CLIENT)
private void rpcInitialize(ItemStack stack, boolean active) {
itemInUse = stack;
itemActive = active;
}
@Override
@ -539,4 +545,9 @@ public class EntityRobot extends EntityRobotBase implements
}
}
@Override
protected boolean canDespawn() {
return false;
}
}

View file

@ -75,8 +75,6 @@ public class AIRobotCutWood extends AIRobot {
woodToChop.y, woodToChop.z, -1);
blockDamage = 0;
BlockUtil.breakBlock((WorldServer) robot.worldObj, woodToChop.x, woodToChop.y, woodToChop.z, 6000);
// robot.worldObj.setBlockToAir(woodToChop.x, woodToChop.y,
// woodToChop.z);
robot.getItemInUse().getItem().onBlockDestroyed(robot.getItemInUse(), robot.worldObj, block, woodToChop.x,
woodToChop.y, woodToChop.z, robot);
@ -94,6 +92,8 @@ public class AIRobotCutWood extends AIRobot {
@Override
public void end() {
robot.setItemActive(false);
robot.worldObj.destroyBlockInWorldPartially(robot.getEntityId(), woodToChop.x,
woodToChop.y, woodToChop.z, -1);
}
private float getBreakSpeed(EntityRobotBase robot, ItemStack usingItem, Block block, int meta) {