use of buildcraft.api.robots.IRobotOverlayItem in project BuildCraft by BuildCraft.
the class EntityRobot method interact.
@Override
protected boolean interact(EntityPlayer player) {
ItemStack stack = player.getCurrentEquippedItem();
if (stack == null || stack.getItem() == null) {
return false;
}
RobotEvent.Interact robotInteractEvent = new RobotEvent.Interact(this, player, stack);
MinecraftForge.EVENT_BUS.post(robotInteractEvent);
if (robotInteractEvent.isCanceled()) {
return false;
}
if (player.isSneaking() && stack.getItem() instanceof IToolWrench) {
RobotEvent.Dismantle robotDismantleEvent = new RobotEvent.Dismantle(this, player);
MinecraftForge.EVENT_BUS.post(robotDismantleEvent);
if (robotDismantleEvent.isCanceled()) {
return false;
}
onRobotHit(false);
if (worldObj.isRemote) {
((IToolWrench) stack.getItem()).wrenchUsed(player, this);
}
return true;
} else if (wearables.size() < MAX_WEARABLES && stack.getItem().isValidArmor(stack, 0, this)) {
if (!worldObj.isRemote) {
wearables.add(stack.splitStack(1));
syncWearablesToClient();
} else {
player.swingItem();
}
return true;
} else if (wearables.size() < MAX_WEARABLES && stack.getItem() instanceof IRobotOverlayItem && ((IRobotOverlayItem) stack.getItem()).isValidRobotOverlay(stack)) {
if (!worldObj.isRemote) {
wearables.add(stack.splitStack(1));
syncWearablesToClient();
} else {
player.swingItem();
}
return true;
} else if (wearables.size() < MAX_WEARABLES && stack.getItem() instanceof ItemSkull) {
if (!worldObj.isRemote) {
ItemStack skullStack = stack.splitStack(1);
initSkullItem(skullStack);
wearables.add(skullStack);
syncWearablesToClient();
} else {
player.swingItem();
}
return true;
} else {
return super.interact(player);
}
}
Aggregations