Search in sources :

Example 1 with IExplosive

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

the class GuiMRATDeactivate 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 2 with IExplosive

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

the class GuiSCManual method updateRecipeAndIcons.

private void updateRecipeAndIcons() {
    if (currentPage < 0) {
        recipe = null;
        hoverCheckers.clear();
        return;
    }
    hoverCheckers.clear();
    if (SecurityCraft.instance.manualPages.get(currentPage).hasCustomRecipe())
        recipe = SecurityCraft.instance.manualPages.get(currentPage).getRecipe();
    else
        for (Object object : CraftingManager.getInstance().getRecipeList()) {
            if (object instanceof ShapedRecipes) {
                ShapedRecipes recipe = (ShapedRecipes) object;
                if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
                    this.recipe = recipe.recipeItems;
                    break;
                }
            } else if (object instanceof ShapelessRecipes) {
                ShapelessRecipes recipe = (ShapelessRecipes) object;
                if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
                    this.recipe = toItemStackArray(recipe.recipeItems);
                    break;
                }
            }
            recipe = null;
        }
    if (recipe != null) {
        outer: for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if ((i * 3) + j == recipe.length)
                    break outer;
                if (recipe[(i * 3) + j] != null)
                    hoverCheckers.add(new CustomHoverChecker(144 + (i * 20), 144 + (i * 20) + 16, (k + 100) + (j * 20), (k + 100) + (j * 20) + 16, 20, recipe[(i * 3) + j].getDisplayName()));
            }
        }
    } else if (SecurityCraft.instance.manualPages.get(currentPage).isRecipeDisabled())
        hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.disabled")));
    else if (SecurityCraft.instance.manualPages.get(currentPage).getHelpInfo().equals("help.reinforced.info"))
        hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.recipe.reinforced")));
    else {
        String name = SecurityCraft.instance.manualPages.get(currentPage).getItem().getUnlocalizedName().substring(5);
        hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.recipe." + name)));
    }
    Item item = SecurityCraft.instance.manualPages.get(currentPage).getItem();
    TileEntity te = ((item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof ITileEntityProvider) ? ((ITileEntityProvider) ((ItemBlock) item).getBlock()).createNewTileEntity(Minecraft.getMinecraft().theWorld, 0) : null);
    Block itemBlock = ((item instanceof ItemBlock) ? ((ItemBlock) item).getBlock() : null);
    if (te != null) {
        if (te instanceof IOwnable)
            hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 29, (k + 29) + 16, 20, StatCollector.translateToLocal("gui.scManual.ownableBlock")));
        if (te instanceof IPasswordProtected)
            hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 55, (k + 55) + 16, 20, StatCollector.translateToLocal("gui.scManual.passwordProtectedBlock")));
        if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView())
            hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 81, (k + 81) + 16, 20, StatCollector.translateToLocal("gui.scManual.viewActivatedBlock")));
        if (itemBlock instanceof IExplosive)
            hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 107, (k + 107) + 16, 20, StatCollector.translateToLocal("gui.scManual.explosiveBlock")));
        if (te instanceof CustomizableSCTE)
            hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 213, (k + 213) + 16, 20, StatCollector.translateToLocal("gui.scManual.customizableBlock")));
    }
}
Also used : ShapedRecipes(net.minecraft.item.crafting.ShapedRecipes) IPasswordProtected(net.geforcemods.securitycraft.api.IPasswordProtected) CustomHoverChecker(net.geforcemods.securitycraft.gui.components.CustomHoverChecker) TileEntitySCTE(net.geforcemods.securitycraft.api.TileEntitySCTE) ItemBlock(net.minecraft.item.ItemBlock) TileEntity(net.minecraft.tileentity.TileEntity) Item(net.minecraft.item.Item) ITileEntityProvider(net.minecraft.block.ITileEntityProvider) CustomizableSCTE(net.geforcemods.securitycraft.api.CustomizableSCTE) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) IOwnable(net.geforcemods.securitycraft.api.IOwnable) IExplosive(net.geforcemods.securitycraft.api.IExplosive) ShapelessRecipes(net.minecraft.item.crafting.ShapelessRecipes)

Example 3 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, BlockPos pos, EnumFacing par5EnumFacing, float hitX, float hitY, float hitZ) {
    if (!par3World.isRemote) {
        if (BlockUtils.getBlock(par3World, pos) instanceof IExplosive) {
            if (!isMineAdded(par1ItemStack, par3World, pos)) {
                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(pos) instanceof IOwnable && !((IOwnable) par3World.getTileEntity(pos)).getOwner().isOwner(par2EntityPlayer)) {
                    PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.remoteAccessMine.name"), StatCollector.translateToLocal("messages.mrat.cantBind"), EnumChatFormatting.RED);
                    return false;
                }
                if (par1ItemStack.getTagCompound() == null) {
                    par1ItemStack.setTagCompound(new NBTTagCompound());
                }
                par1ItemStack.getTagCompound().setIntArray(("mine" + availSlot), new int[] { BlockUtils.fromPos(pos)[0], BlockUtils.fromPos(pos)[1], BlockUtils.fromPos(pos)[2] });
                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(pos)), EnumChatFormatting.GREEN);
            } else {
                this.removeTagFromItemAndUpdate(par1ItemStack, pos, par2EntityPlayer);
                PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("item.remoteAccessMine.name"), StatCollector.translateToLocal("messages.mrat.unbound").replace("#", Utils.getFormattedCoordinates(pos)), 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 4 with IExplosive

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

the class GuiMRATActivate 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], "activate"));
    }
    this.updateButton(guibutton);
}
Also used : IExplosive(net.geforcemods.securitycraft.api.IExplosive) PacketSetExplosiveState(net.geforcemods.securitycraft.network.packets.PacketSetExplosiveState)

Example 5 with IExplosive

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

the class GuiMRATDetonate method actionPerformed.

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

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