fixed robot re-initialization problems, #1873
This commit is contained in:
parent
1d642f052c
commit
defa5cab45
2 changed files with 20 additions and 9 deletions
|
@ -84,16 +84,14 @@ public class EntityRobot extends EntityRobotBase implements
|
||||||
board = (RedstoneBoardRobot) RedstoneBoardRegistry.instance.getRedstoneBoard(boardNBT).create(boardNBT, this);
|
board = (RedstoneBoardRobot) RedstoneBoardRegistry.instance.getRedstoneBoard(boardNBT).create(boardNBT, this);
|
||||||
dataWatcher.updateObject(16, board.getNBTHandler().getID());
|
dataWatcher.updateObject(16, board.getNBTHandler().getID());
|
||||||
|
|
||||||
if (world.isRemote) {
|
if (!world.isRemote) {
|
||||||
RPCHandler.rpcServer(this, "requestInitialization", itemInUse);
|
|
||||||
} else {
|
|
||||||
mainAI = new AIRobotMain(this);
|
mainAI = new AIRobotMain(this);
|
||||||
mainAI.start();
|
mainAI.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityRobot(World par1World) {
|
public EntityRobot(World world) {
|
||||||
super(par1World);
|
super(world);
|
||||||
|
|
||||||
motionX = 0;
|
motionX = 0;
|
||||||
motionY = 0;
|
motionY = 0;
|
||||||
|
@ -153,7 +151,9 @@ public class EntityRobot extends EntityRobotBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init() {
|
protected void init() {
|
||||||
|
if (worldObj.isRemote) {
|
||||||
|
RPCHandler.rpcServer(this, "requestInitialization");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLaserDestination (float x, float y, float z) {
|
public void setLaserDestination (float x, float y, float z) {
|
||||||
|
@ -459,7 +459,13 @@ public class EntityRobot extends EntityRobotBase implements
|
||||||
|
|
||||||
@RPC(RPCSide.SERVER)
|
@RPC(RPCSide.SERVER)
|
||||||
public void requestInitialization(RPCMessageInfo info) {
|
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
|
@Override
|
||||||
|
@ -539,4 +545,9 @@ public class EntityRobot extends EntityRobotBase implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canDespawn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,6 @@ public class AIRobotCutWood extends AIRobot {
|
||||||
woodToChop.y, woodToChop.z, -1);
|
woodToChop.y, woodToChop.z, -1);
|
||||||
blockDamage = 0;
|
blockDamage = 0;
|
||||||
BlockUtil.breakBlock((WorldServer) robot.worldObj, woodToChop.x, woodToChop.y, woodToChop.z, 6000);
|
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,
|
robot.getItemInUse().getItem().onBlockDestroyed(robot.getItemInUse(), robot.worldObj, block, woodToChop.x,
|
||||||
woodToChop.y, woodToChop.z, robot);
|
woodToChop.y, woodToChop.z, robot);
|
||||||
|
|
||||||
|
@ -94,6 +92,8 @@ public class AIRobotCutWood extends AIRobot {
|
||||||
@Override
|
@Override
|
||||||
public void end() {
|
public void end() {
|
||||||
robot.setItemActive(false);
|
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) {
|
private float getBreakSpeed(EntityRobotBase robot, ItemStack usingItem, Block block, int meta) {
|
||||||
|
|
Loading…
Reference in a new issue