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]);
}
}
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")));
}
}
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;
}
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);
}
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);
}
Aggregations