Search in sources :

Example 6 with IExplosive

use of net.geforcemods.securitycraft.api.IExplosive in project SecurityCraft by Geforce132.

the class GuiMRATDeactivate method actionPerformed.

@Override
protected void actionPerformed(GuiButton guibutton) {
    int[] coords = this.item.getTagCompound().getIntArray("mine" + (guibutton.id + 1));
    if (BlockUtils.getBlock(mc.theWorld, coords[0], coords[1], coords[2]) instanceof IExplosive) {
        mod_SecurityCraft.network.sendToServer(new PacketSetExplosiveState(coords[0], coords[1], coords[2], "defuse"));
    }
    this.updateButton(guibutton);
}
Also used : IExplosive(net.geforcemods.securitycraft.api.IExplosive) PacketSetExplosiveState(net.geforcemods.securitycraft.network.packets.PacketSetExplosiveState)

Example 7 with IExplosive

use of net.geforcemods.securitycraft.api.IExplosive in project SecurityCraft by Geforce132.

the class ItemMineRemoteAccessTool method onItemUse.

@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        if (BlockUtils.getBlock(worldIn, pos) instanceof IExplosive) {
            if (!isMineAdded(stack, worldIn, pos)) {
                int availSlot = this.getNextAvaliableSlot(stack);
                if (availSlot == 0) {
                    PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.remoteAccessMine.name"), I18n.translateToLocal("messages.mrat.noSlots"), TextFormatting.RED);
                    return EnumActionResult.FAIL;
                }
                if (worldIn.getTileEntity(pos) instanceof IOwnable && !((IOwnable) worldIn.getTileEntity(pos)).getOwner().isOwner(playerIn)) {
                    PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.remoteAccessMine.name"), I18n.translateToLocal("messages.mrat.cantBind"), TextFormatting.RED);
                    return EnumActionResult.FAIL;
                }
                if (stack.getTagCompound() == null) {
                    stack.setTagCompound(new NBTTagCompound());
                }
                stack.getTagCompound().setIntArray(("mine" + availSlot), new int[] { BlockUtils.fromPos(pos)[0], BlockUtils.fromPos(pos)[1], BlockUtils.fromPos(pos)[2] });
                mod_SecurityCraft.network.sendTo(new PacketCUpdateNBTTag(stack), (EntityPlayerMP) playerIn);
                PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.remoteAccessMine.name"), I18n.translateToLocal("messages.mrat.bound").replace("#", Utils.getFormattedCoordinates(pos)), TextFormatting.GREEN);
            } else {
                this.removeTagFromItemAndUpdate(stack, pos, playerIn);
                PlayerUtils.sendMessageToPlayer(playerIn, I18n.translateToLocal("item.remoteAccessMine.name"), I18n.translateToLocal("messages.mrat.unbound").replace("#", Utils.getFormattedCoordinates(pos)), TextFormatting.RED);
            }
        } else {
            playerIn.openGui(mod_SecurityCraft.instance, GuiHandler.MRAT_MENU_ID, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);
        }
    }
    return EnumActionResult.SUCCESS;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IOwnable(net.geforcemods.securitycraft.api.IOwnable) IExplosive(net.geforcemods.securitycraft.api.IExplosive) PacketCUpdateNBTTag(net.geforcemods.securitycraft.network.packets.PacketCUpdateNBTTag)

Example 8 with IExplosive

use of net.geforcemods.securitycraft.api.IExplosive in project SecurityCraft by Geforce132.

the class ItemMineRemoteAccessTool method onItemUse.

public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
    if (!par3World.isRemote) {
        if (par3World.getBlock(par4, par5, par6) instanceof IExplosive) {
            if (!isMineAdded(par1ItemStack, par3World, par4, par5, par6)) {
                int availSlot = this.getNextAvaliableSlot(par1ItemStack);
                if (availSlot == 0) {
                    PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.remoteAccessMine.name"), StatCollector.translateToLocal("messages.mrat.noSlots"), EnumChatFormatting.RED);
                    return false;
                }
                if (par3World.getTileEntity(par4, par5, par6) instanceof IOwnable && !((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner().isOwner(par2EntityPlayer)) {
                    PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.remoteAccessMine.name"), StatCollector.translateToLocal("messages.mrat.cantBind"), EnumChatFormatting.RED);
                    return false;
                }
                if (par1ItemStack.stackTagCompound == null) {
                    par1ItemStack.stackTagCompound = new NBTTagCompound();
                }
                par1ItemStack.stackTagCompound.setIntArray(("mine" + availSlot), new int[] { par4, par5, par6 });
                mod_SecurityCraft.network.sendTo(new PacketCUpdateNBTTag(par1ItemStack), (EntityPlayerMP) par2EntityPlayer);
                PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.remoteAccessMine.name"), StatCollector.translateToLocal("messages.mrat.bound").replace("#", Utils.getFormattedCoordinates(par4, par5, par6)), EnumChatFormatting.GREEN);
            } else {
                this.removeTagFromItemAndUpdate(par1ItemStack, par4, par5, par6, par2EntityPlayer);
                PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.remoteAccessMine.name"), StatCollector.translateToLocal("messages.mrat.unbound").replace("#", Utils.getFormattedCoordinates(par4, par5, par6)), EnumChatFormatting.RED);
            }
        } else {
            par2EntityPlayer.openGui(mod_SecurityCraft.instance, GuiHandler.MRAT_MENU_ID, par3World, (int) par2EntityPlayer.posX, (int) par2EntityPlayer.posY, (int) par2EntityPlayer.posZ);
        }
    }
    return true;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IOwnable(net.geforcemods.securitycraft.api.IOwnable) IExplosive(net.geforcemods.securitycraft.api.IExplosive) PacketCUpdateNBTTag(net.geforcemods.securitycraft.network.packets.PacketCUpdateNBTTag)

Example 9 with IExplosive

use of net.geforcemods.securitycraft.api.IExplosive in project SecurityCraft by Geforce132.

the class GuiMRATActivate method initGui.

@Override
public void initGui() {
    super.initGui();
    for (int i = 1; i < 7; i++) {
        buttons[i - 1] = new GuiButton(i - 1, width / 2 - 49 - 25, height / 2 - 7 - 60 + ((i - 1) * 25), 149, 20, StatCollector.translateToLocal("gui.mrat.notBound"));
        buttons[i - 1].enabled = false;
        if (item.getItem() != null && item.getItem() == SCContent.remoteAccessMine && item.getTagCompound() != null && item.getTagCompound().getIntArray("mine" + i) != null && item.getTagCompound().getIntArray("mine" + i).length > 0) {
            int[] coords = item.getTagCompound().getIntArray("mine" + i);
            if (coords[0] == 0 && coords[1] == 0 && coords[2] == 0) {
                buttonList.add(buttons[i - 1]);
                continue;
            }
            buttons[i - 1].displayString = StatCollector.translateToLocal("gui.mrat.mineLocations").replace("#location", Utils.getFormattedCoordinates(new BlockPos(coords[0], coords[1], coords[2])));
            buttons[i - 1].enabled = (BlockUtils.getBlock(mc.theWorld, coords[0], coords[1], coords[2]) instanceof IExplosive && ((IExplosive) BlockUtils.getBlock(mc.theWorld, coords[0], coords[1], coords[2])).isDefusable() && !((IExplosive) BlockUtils.getBlock(mc.theWorld, coords[0], coords[1], coords[2])).isActive(mc.theWorld, BlockUtils.toPos(coords[0], coords[1], coords[2]))) ? true : false;
            buttons[i - 1].id = i - 1;
        }
        buttonList.add(buttons[i - 1]);
    }
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) BlockPos(net.minecraft.util.BlockPos) IExplosive(net.geforcemods.securitycraft.api.IExplosive)

Example 10 with IExplosive

use of net.geforcemods.securitycraft.api.IExplosive in project SecurityCraft by Geforce132.

the class GuiMRATDetonate method initGui.

@Override
public void initGui() {
    super.initGui();
    for (int i = 1; i < 7; i++) {
        buttons[i - 1] = new GuiButton(i - 1, width / 2 - 49 - 25, height / 2 - 7 - 60 + ((i - 1) * 25), 149, 20, StatCollector.translateToLocal("gui.mrat.notBound"));
        buttons[i - 1].enabled = false;
        if (item.getItem() != null && item.getItem() == SCContent.remoteAccessMine && item.getTagCompound() != null && item.getTagCompound().getIntArray("mine" + i) != null && item.getTagCompound().getIntArray("mine" + i).length > 0) {
            int[] coords = item.getTagCompound().getIntArray("mine" + i);
            if (coords[0] == 0 && coords[1] == 0 && coords[2] == 0) {
                buttonList.add(buttons[i - 1]);
                continue;
            }
            buttons[i - 1].displayString = StatCollector.translateToLocal("gui.mrat.mineLocations").replace("#location", Utils.getFormattedCoordinates(new BlockPos(coords[0], coords[1], coords[2])));
            buttons[i - 1].enabled = (BlockUtils.getBlock(mc.theWorld, coords[0], coords[1], coords[2]) instanceof IExplosive && (!((IExplosive) BlockUtils.getBlock(mc.theWorld, coords[0], coords[1], coords[2])).isDefusable() || ((IExplosive) BlockUtils.getBlock(mc.theWorld, coords[0], coords[1], coords[2])).isActive(mc.theWorld, BlockUtils.toPos(coords[0], coords[1], coords[2])))) ? true : false;
            buttons[i - 1].id = i - 1;
        }
        buttonList.add(buttons[i - 1]);
    }
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) BlockPos(net.minecraft.util.BlockPos) IExplosive(net.geforcemods.securitycraft.api.IExplosive)

Aggregations

IExplosive (net.geforcemods.securitycraft.api.IExplosive)11 IOwnable (net.geforcemods.securitycraft.api.IOwnable)5 PacketCUpdateNBTTag (net.geforcemods.securitycraft.network.packets.PacketCUpdateNBTTag)3 PacketSetExplosiveState (net.geforcemods.securitycraft.network.packets.PacketSetExplosiveState)3 GuiButton (net.minecraft.client.gui.GuiButton)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 BlockPos (net.minecraft.util.BlockPos)3 CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)2 IPasswordProtected (net.geforcemods.securitycraft.api.IPasswordProtected)2 TileEntitySCTE (net.geforcemods.securitycraft.api.TileEntitySCTE)2 CustomHoverChecker (net.geforcemods.securitycraft.gui.components.CustomHoverChecker)2 Block (net.minecraft.block.Block)2 ITileEntityProvider (net.minecraft.block.ITileEntityProvider)2 Item (net.minecraft.item.Item)2 ItemBlock (net.minecraft.item.ItemBlock)2 TileEntity (net.minecraft.tileentity.TileEntity)2 ShapedRecipes (net.minecraft.item.crafting.ShapedRecipes)1 ShapelessRecipes (net.minecraft.item.crafting.ShapelessRecipes)1