use of icbm.classic.api.tile.multiblock.IMultiTileHost in project ICBM-Classic by BuiltBrokenModding.
the class ItemRadarGun method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (world.isRemote) {
return EnumActionResult.SUCCESS;
}
Location location = new Location(world, pos);
TileEntity tile = location.getTileEntity();
if (tile instanceof IMultiTile) {
IMultiTileHost host = ((IMultiTile) tile).getHost();
if (host instanceof TileEntity) {
tile = (TileEntity) host;
}
}
if (player.isSneaking()) {
stack.setTagCompound(null);
stack.setItemDamage(0);
LanguageUtility.addChatToPlayer(player, "gps.cleared.name");
player.inventoryContainer.detectAndSendChanges();
return EnumActionResult.SUCCESS;
} else {
Location storedLocation = getLocation(stack);
if (ICBMClassicHelpers.isLauncher(tile, facing)) {
if (storedLocation == null) {
LanguageUtility.addChatToPlayer(player, "gps.error.pos.invalid.null.name");
return EnumActionResult.SUCCESS;
} else if (!storedLocation.isAboveBedrock()) {
LanguageUtility.addChatToPlayer(player, "gps.error.pos.invalid.name");
return EnumActionResult.SUCCESS;
} else if (storedLocation.world != world) {
LanguageUtility.addChatToPlayer(player, "gps.error.pos.invalid.world.name");
return EnumActionResult.SUCCESS;
} else {
final IMissileLauncher launcher = ICBMClassicHelpers.getLauncher(tile, facing);
if (launcher != null) {
launcher.setTarget(storedLocation.x(), storedLocation.y(), storedLocation.z());
LanguageUtility.addChatToPlayer(player, "gps.data.transferred.name");
return EnumActionResult.SUCCESS;
}
}
} else if (// otherwise, save the currently clicked block as a location if the trace event has not been canceled
trace(pos, player))
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
use of icbm.classic.api.tile.multiblock.IMultiTileHost in project ICBM-Classic by BuiltBrokenModding.
the class BlockICBM method breakBlock.
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof IInventoryProvider && ((IInventoryProvider) tile).getInventory() != null) {
InventoryHelper.dropInventoryItems(world, pos, ((IInventoryProvider) tile).getInventory());
}
if (tile instanceof IMultiTileHost) {
// At this point the structure should already be dead if broken by a player
MultiBlockHelper.destroyMultiBlockStructure((IMultiTileHost) tile, false, true, false);
}
super.breakBlock(world, pos, state);
}
Aggregations