Search in sources :

Example 1 with ItemRemoteDetonator

use of icbm.classic.content.items.ItemRemoteDetonator in project ICBM-Classic by BuiltBrokenModding.

the class TileLauncherScreen method onPlayerActivated.

@Override
public boolean onPlayerActivated(EntityPlayer player, int side, Pos hit) {
    if (isServer()) {
        boolean notNull = player.getHeldItem() != null;
        if (notNull && player.getHeldItem().getItem() == Items.redstone) {
            if (canLaunch()) {
                launch();
            } else {
                player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.failedToFire")));
                String translation = LanguageUtility.getLocal("chat.launcher.status");
                translation = translation.replace("%1", getStatus());
                player.addChatComponentMessage(new ChatComponentText(translation));
            }
        } else if (notNull && player.getHeldItem().getItem() instanceof ItemRemoteDetonator) {
            ((ItemRemoteDetonator) player.getHeldItem().getItem()).setBroadCastHz(player.getHeldItem(), getFrequency());
            player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolFrequencySet").replace("%1", "" + getFrequency())));
        } else if (notNull && player.getHeldItem().getItem() instanceof IWorldPosItem) {
            IWorldPosition location = ((IWorldPosItem) player.getHeldItem().getItem()).getLocation(player.getHeldItem());
            if (location != null) {
                if (location.world() == world()) {
                    setTarget(new Pos(location.x(), location.y(), location.z()));
                    player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolTargetSet")));
                } else {
                    player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolWorldNotMatch")));
                }
            } else {
                player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.noTargetInTool")));
            }
        } else {
            player.openGui(ICBMClassic.INSTANCE, 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
        }
    }
    return true;
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) IWorldPosition(com.builtbroken.mc.api.IWorldPosition) IWorldPosItem(com.builtbroken.mc.api.items.tools.IWorldPosItem) ChatComponentText(net.minecraft.util.ChatComponentText) ItemRemoteDetonator(icbm.classic.content.items.ItemRemoteDetonator)

Example 2 with ItemRemoteDetonator

use of icbm.classic.content.items.ItemRemoteDetonator in project ICBM-Classic by BuiltBrokenModding.

the class ItemReg method registerItems.

@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event) {
    // Items
    event.getRegistry().register(new ItemGrenade().setName("grenade").setCreativeTab(ICBMClassic.CREATIVE_TAB));
    event.getRegistry().register(new ItemBombCart().setName("bombcart").setCreativeTab(ICBMClassic.CREATIVE_TAB));
    // TODO fix name _
    event.getRegistry().register(new ItemBase().setName("poisonPowder").setCreativeTab(ICBMClassic.CREATIVE_TAB));
    Item sulfurItem = new ItemBase().setName("sulfurDust").setCreativeTab(ICBMClassic.CREATIVE_TAB);
    // TODO fix name _
    event.getRegistry().register(sulfurItem);
    OreDictionary.registerOre("dustSulfur", sulfurItem);
    Item saltpeterItem = new ItemBase().setName("saltpeter").setCreativeTab(ICBMClassic.CREATIVE_TAB);
    event.getRegistry().register(saltpeterItem);
    OreDictionary.registerOre("dustSaltpeter", saltpeterItem);
    event.getRegistry().register(new ItemAntidote().setName("antidote"));
    event.getRegistry().register(new ItemSignalDisrupter());
    event.getRegistry().register(new ItemTracker());
    event.getRegistry().register(new ItemDefuser());
    event.getRegistry().register(new ItemRadarGun());
    event.getRegistry().register(new ItemRemoteDetonator());
    event.getRegistry().register(new ItemLaserDetonator());
    event.getRegistry().register(new ItemRocketLauncher());
    event.getRegistry().register(new ItemMissile());
    // Block items
    event.getRegistry().register(new ItemBlock(BlockReg.blockGlassPlate).setRegistryName(BlockReg.blockGlassPlate.getRegistryName()));
    event.getRegistry().register(new ItemBlock(BlockReg.blockGlassButton).setRegistryName(BlockReg.blockGlassButton.getRegistryName()));
    event.getRegistry().register(new ItemBlockSubTypes(BlockReg.blockSpikes));
    event.getRegistry().register(new ItemBlockSubTypes(BlockReg.blockConcrete));
    event.getRegistry().register(new ItemBlock(BlockReg.blockReinforcedGlass).setRegistryName(BlockReg.blockReinforcedGlass.getRegistryName()));
    event.getRegistry().register(new ItemBlockExplosive(BlockReg.blockExplosive).setRegistryName(BlockReg.blockExplosive.getRegistryName()));
    event.getRegistry().register(new ItemBlock(BlockReg.blockEmpTower).setRegistryName(BlockReg.blockEmpTower.getRegistryName()));
    event.getRegistry().register(new ItemBlock(BlockReg.blockRadarStation).setRegistryName(BlockReg.blockRadarStation.getRegistryName()));
    event.getRegistry().register(new ItemBlockSubTypes(BlockReg.blockLaunchSupport));
    event.getRegistry().register(new ItemBlockRotatedMultiTile(BlockReg.blockLaunchBase, e -> TileLauncherBase.getLayoutOfMultiBlock(e)));
    event.getRegistry().register(new ItemBlockSubTypes(BlockReg.blockLaunchScreen));
    event.getRegistry().register(new ItemBlock(BlockReg.blockCruiseLauncher).setRegistryName(BlockReg.blockCruiseLauncher.getRegistryName()));
    // Crafting resources
    if (ConfigItems.ENABLE_CRAFTING_ITEMS) {
        if (ConfigItems.ENABLE_INGOTS_ITEMS) {
            event.getRegistry().register(new ItemCrafting("ingot", "steel", "copper"));
            event.getRegistry().register(new ItemCrafting("clump", "steel"));
        }
        if (ConfigItems.ENABLE_PLATES_ITEMS) {
            event.getRegistry().register(new ItemCrafting("plate", "steel", "iron"));
        }
        if (ConfigItems.ENABLE_CIRCUIT_ITEMS) {
            event.getRegistry().register(new ItemCrafting("circuit", "basic", "advanced", "elite"));
        }
        if (ConfigItems.ENABLE_WIRES_ITEMS) {
            event.getRegistry().register(new ItemCrafting("wire", "copper", "gold"));
        }
    }
    // Optional items
    if (ConfigItems.ENABLE_BATTERY) {
        event.getRegistry().register(new ItemBattery());
    }
}
Also used : Item(net.minecraft.item.Item) ItemDefuser(icbm.classic.content.items.ItemDefuser) ItemLaserDetonator(icbm.classic.content.items.ItemLaserDetonator) ItemCrafting(icbm.classic.content.items.ItemCrafting) ItemSignalDisrupter(icbm.classic.content.items.ItemSignalDisrupter) ItemRemoteDetonator(icbm.classic.content.items.ItemRemoteDetonator) OreDictionary(net.minecraftforge.oredict.OreDictionary) ItemBattery(icbm.classic.content.items.ItemBattery) ItemRocketLauncher(icbm.classic.content.items.ItemRocketLauncher) RegistryEvent(net.minecraftforge.event.RegistryEvent) ItemBombCart(icbm.classic.content.items.ItemBombCart) Mod(net.minecraftforge.fml.common.Mod) ICBMClassic(icbm.classic.ICBMClassic) ItemTracker(icbm.classic.content.items.ItemTracker) ICBMConstants(icbm.classic.ICBMConstants) ItemGrenade(icbm.classic.content.items.ItemGrenade) ItemBlockExplosive(icbm.classic.content.blocks.explosive.ItemBlockExplosive) TileLauncherBase(icbm.classic.content.blocks.launcher.base.TileLauncherBase) ItemMissile(icbm.classic.content.items.ItemMissile) ConfigItems(icbm.classic.config.ConfigItems) ObjectHolder(net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder) ItemBlockSubTypes(icbm.classic.prefab.item.ItemBlockSubTypes) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ItemRadarGun(icbm.classic.content.items.ItemRadarGun) ItemBlockRotatedMultiTile(icbm.classic.prefab.item.ItemBlockRotatedMultiTile) ItemBlock(net.minecraft.item.ItemBlock) ItemAntidote(icbm.classic.content.items.ItemAntidote) ItemBase(icbm.classic.prefab.item.ItemBase) ItemCrafting(icbm.classic.content.items.ItemCrafting) ItemBattery(icbm.classic.content.items.ItemBattery) ItemRocketLauncher(icbm.classic.content.items.ItemRocketLauncher) ItemBase(icbm.classic.prefab.item.ItemBase) ItemMissile(icbm.classic.content.items.ItemMissile) ItemBlockSubTypes(icbm.classic.prefab.item.ItemBlockSubTypes) ItemBlockExplosive(icbm.classic.content.blocks.explosive.ItemBlockExplosive) ItemBlock(net.minecraft.item.ItemBlock) ItemDefuser(icbm.classic.content.items.ItemDefuser) ItemRemoteDetonator(icbm.classic.content.items.ItemRemoteDetonator) Item(net.minecraft.item.Item) ItemLaserDetonator(icbm.classic.content.items.ItemLaserDetonator) ItemBlockRotatedMultiTile(icbm.classic.prefab.item.ItemBlockRotatedMultiTile) ItemTracker(icbm.classic.content.items.ItemTracker) ItemGrenade(icbm.classic.content.items.ItemGrenade) ItemSignalDisrupter(icbm.classic.content.items.ItemSignalDisrupter) ItemBombCart(icbm.classic.content.items.ItemBombCart) ItemAntidote(icbm.classic.content.items.ItemAntidote) ItemRadarGun(icbm.classic.content.items.ItemRadarGun) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with ItemRemoteDetonator

use of icbm.classic.content.items.ItemRemoteDetonator in project ICBM-Classic by BuiltBrokenModding.

the class BlockLaunchScreen method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        TileEntity tileEntity = world.getTileEntity(pos);
        if (tileEntity instanceof TileLauncherScreen) {
            TileLauncherScreen screen = (TileLauncherScreen) tileEntity;
            ItemStack stack = player.getHeldItem(hand);
            if (stack.getItem() == Items.REDSTONE) {
                if ((screen._tier == EnumTier.ONE && !ConfigLauncher.LAUNCHER_REDSTONE_TIER1) || (screen._tier == EnumTier.TWO && !ConfigLauncher.LAUNCHER_REDSTONE_TIER2) || (screen._tier == EnumTier.THREE && !ConfigLauncher.LAUNCHER_REDSTONE_TIER3)) {
                    return false;
                }
                if (// canLaunch is called in launch and launch returns false if cannot launch
                !screen.launch()) {
                    player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.failedToFire")));
                    String translation = LanguageUtility.getLocal("chat.launcher.status");
                    translation = translation.replace("%s", screen.getStatus());
                    player.sendMessage(new TextComponentString(translation));
                }
            } else if (stack.getItem() instanceof ItemRemoteDetonator) {
                ((ItemRemoteDetonator) stack.getItem()).setBroadCastHz(stack, screen.getFrequency());
                player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.toolFrequencySet").replace("%s", "" + screen.getFrequency())));
            } else if (stack.getItem() instanceof ItemLaserDetonator) {
                ((ItemLaserDetonator) stack.getItem()).setBroadCastHz(stack, screen.getFrequency());
                player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.toolFrequencySet").replace("%s", "" + screen.getFrequency())));
            } else if (stack.getItem() instanceof IWorldPosItem) {
                IWorldPosition location = ((IWorldPosItem) stack.getItem()).getLocation(stack);
                if (location != null) {
                    if (location.world() == world) {
                        screen.setTarget(new Pos(location.x(), location.y(), location.z()));
                        player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.toolTargetSet")));
                    } else {
                        player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.toolWorldNotMatch")));
                    }
                } else {
                    player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.noTargetInTool")));
                }
            } else if (screen.launcherBase == null || !screen.launcherBase.tryInsertMissile(player, hand, player.getHeldItem(hand))) {
                player.openGui(ICBMClassic.INSTANCE, 0, world, pos.getX(), pos.getY(), pos.getZ());
            }
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ItemLaserDetonator(icbm.classic.content.items.ItemLaserDetonator) Pos(icbm.classic.lib.transform.vector.Pos) BlockPos(net.minecraft.util.math.BlockPos) IWorldPosition(icbm.classic.api.data.IWorldPosition) TextComponentString(net.minecraft.util.text.TextComponentString) ItemStack(net.minecraft.item.ItemStack) IWorldPosItem(icbm.classic.api.items.IWorldPosItem) TextComponentString(net.minecraft.util.text.TextComponentString) ItemRemoteDetonator(icbm.classic.content.items.ItemRemoteDetonator)

Example 4 with ItemRemoteDetonator

use of icbm.classic.content.items.ItemRemoteDetonator in project ICBM-Classic by BuiltBrokenModding.

the class BlockCruiseLauncher method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        TileEntity tileEntity = world.getTileEntity(pos);
        if (tileEntity instanceof TileCruiseLauncher) {
            TileCruiseLauncher launcher = (TileCruiseLauncher) tileEntity;
            ItemStack stack = player.getHeldItem(hand);
            if (stack.getItem() == Items.REDSTONE) {
                if (// canLaunch is called in launch and launch returns false if cannot launch
                !launcher.launch()) {
                    player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.failedToFire")));
                    String translation = LanguageUtility.getLocal("chat.launcher.status");
                    translation = translation.replace("%s", launcher.getStatus());
                    player.sendMessage(new TextComponentString(translation));
                }
            } else if (stack.getItem() instanceof ItemRemoteDetonator) {
                ((ItemRemoteDetonator) stack.getItem()).setBroadCastHz(stack, launcher.getFrequency());
                player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.toolFrequencySet").replace("%s", "" + launcher.getFrequency())));
            } else if (stack.getItem() instanceof ItemLaserDetonator) {
                ((ItemLaserDetonator) stack.getItem()).setBroadCastHz(stack, launcher.getFrequency());
                player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.toolFrequencySet").replace("%s", "" + launcher.getFrequency())));
            } else if (stack.getItem() instanceof IWorldPosItem) {
                IWorldPosition location = ((IWorldPosItem) stack.getItem()).getLocation(stack);
                if (location != null) {
                    if (location.world() == world) {
                        launcher.setTarget(new Pos(location.x(), location.y(), location.z()));
                        player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.toolTargetSet")));
                    } else {
                        player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.toolWorldNotMatch")));
                    }
                } else {
                    player.sendMessage(new TextComponentString(LanguageUtility.getLocal("chat.launcher.noTargetInTool")));
                }
            } else {
                player.openGui(ICBMClassic.INSTANCE, 0, world, pos.getX(), pos.getY(), pos.getZ());
            }
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ItemLaserDetonator(icbm.classic.content.items.ItemLaserDetonator) Pos(icbm.classic.lib.transform.vector.Pos) BlockPos(net.minecraft.util.math.BlockPos) IWorldPosition(icbm.classic.api.data.IWorldPosition) TextComponentString(net.minecraft.util.text.TextComponentString) ItemStack(net.minecraft.item.ItemStack) IWorldPosItem(icbm.classic.api.items.IWorldPosItem) TextComponentString(net.minecraft.util.text.TextComponentString) ItemRemoteDetonator(icbm.classic.content.items.ItemRemoteDetonator)

Aggregations

ItemRemoteDetonator (icbm.classic.content.items.ItemRemoteDetonator)4 ItemLaserDetonator (icbm.classic.content.items.ItemLaserDetonator)3 IWorldPosition (icbm.classic.api.data.IWorldPosition)2 IWorldPosItem (icbm.classic.api.items.IWorldPosItem)2 Pos (icbm.classic.lib.transform.vector.Pos)2 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 IWorldPosition (com.builtbroken.mc.api.IWorldPosition)1 IWorldPosItem (com.builtbroken.mc.api.items.tools.IWorldPosItem)1 Pos (com.builtbroken.mc.imp.transform.vector.Pos)1 ICBMClassic (icbm.classic.ICBMClassic)1 ICBMConstants (icbm.classic.ICBMConstants)1 ConfigItems (icbm.classic.config.ConfigItems)1 ItemBlockExplosive (icbm.classic.content.blocks.explosive.ItemBlockExplosive)1 TileLauncherBase (icbm.classic.content.blocks.launcher.base.TileLauncherBase)1 ItemAntidote (icbm.classic.content.items.ItemAntidote)1 ItemBattery (icbm.classic.content.items.ItemBattery)1 ItemBombCart (icbm.classic.content.items.ItemBombCart)1