diff --git a/src/main/java/com/hbm/crafting/ToolRecipes.java b/src/main/java/com/hbm/crafting/ToolRecipes.java index b56361021..84c9df2a6 100644 --- a/src/main/java/com/hbm/crafting/ToolRecipes.java +++ b/src/main/java/com/hbm/crafting/ToolRecipes.java @@ -28,9 +28,9 @@ import net.minecraft.item.ItemStack; * @author hbm */ public class ToolRecipes { - + public static void register() { - + //Regular tools addSword( STEEL.ingot(), ModItems.steel_sword); addPickaxe( STEEL.ingot(), ModItems.steel_pickaxe); @@ -62,7 +62,7 @@ public class ToolRecipes { addAxe( DESH.ingot(), ModItems.desh_axe); addShovel( DESH.ingot(), ModItems.desh_shovel); addHoe( DESH.ingot(), ModItems.desh_hoe); - + CraftingManager.addRecipeAuto(new ItemStack(ModItems.elec_sword, 1), new Object[] { "RPR", "RPR", " B ", 'P', ANY_PLASTIC.ingot(), 'D', DURA.ingot(), 'R', DURA.bolt(), 'M', ModItems.motor, 'B', ModItems.battery_lithium }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.elec_pickaxe, 1), new Object[] { "RDM", " PB", " P ", 'P', ANY_PLASTIC.ingot(), 'D', DURA.ingot(), 'R', DURA.bolt(), 'M', ModItems.motor, 'B', ModItems.battery_lithium }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.elec_axe, 1), new Object[] { " DP", "RRM", " PB", 'P', ANY_PLASTIC.ingot(), 'D', DURA.ingot(), 'R', DURA.bolt(), 'M', ModItems.motor, 'B', ModItems.battery_lithium }); @@ -90,7 +90,7 @@ public class ToolRecipes { CraftingManager.addRecipeAuto(new ItemStack(ModItems.chlorophyte_axe, 1), new Object[] { " SD", "APS", "FA ", 'S', ModItems.blades_steel, 'D', ModItems.powder_chlorophyte, 'A', FIBER.ingot(), 'P', ModItems.bismuth_axe, 'F', DURA.bolt() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.chlorophyte_axe, 1), new Object[] { " SD", "APS", "FA ", 'S', ModItems.blades_steel, 'D', ModItems.powder_chlorophyte, 'A', FIBER.ingot(), 'P', ModItems.volcanic_axe, 'F', DURA.bolt() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.mese_axe, 1), new Object[] { " SD", "APS", "FA ", 'S', ModItems.blades_desh, 'D', ModItems.powder_dineutronium, 'A', ModItems.plate_paa, 'P', ModItems.chlorophyte_axe, 'F', ModItems.shimmer_handle }); - + //Chainsaws CraftingManager.addRecipeAuto(ItemToolAbilityFueled.getEmptyTool(ModItems.chainsaw), new Object[] { "CCH", "BBP", "CCE", 'H', STEEL.shell(), 'B', ModItems.blades_steel, 'P', ModItems.piston_selenium, 'C', ModBlocks.chain, 'E', ModItems.canister_empty }); @@ -150,7 +150,7 @@ public class ToolRecipes { CraftingManager.addRecipeAuto(new ItemStack(ModItems.power_net_tool), new Object[] { "WRW", " I ", " B ", 'W', MINGRADE.wireFine(), 'R', REDSTONE.dust(), 'I', IRON.ingot(), 'B', ModItems.battery_generic }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.analysis_tool), new Object[] { " G", " S ", "S ", 'G', KEY_ANYPANE, 'S', STEEL.ingot() }); - CraftingManager.addRecipeAuto(new ItemStack(ModItems.kit_toolbox_empty), new Object[] { "CCC", "CIC", 'C', CU.plate(), 'I', IRON.ingot() }); + CraftingManager.addRecipeAuto(new ItemStack(ModItems.toolbox), new Object[] { "CCC", "CIC", 'C', CU.plate(), 'I', IRON.ingot() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.screwdriver, 1), new Object[] { " I", " I ", "S ", 'S', STEEL.ingot(), 'I', IRON.ingot() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.screwdriver_desh, 1), new Object[] { " I", " I ", "S ", 'S', ANY_PLASTIC.ingot(), 'I', DESH.ingot() }); @@ -161,24 +161,24 @@ public class ToolRecipes { CraftingManager.addRecipeAuto(ItemBlowtorch.getEmptyTool(ModItems.blowtorch), new Object[] { "CC ", " I ", "CCC", 'C', CU.plate528(), 'I', IRON.ingot() }); CraftingManager.addRecipeAuto(ItemBlowtorch.getEmptyTool(ModItems.acetylene_torch), new Object[] { "SS ", " PS", " T ", 'S', STEEL.plate528(), 'P', ANY_PLASTIC.ingot(), 'T', ModItems.tank_steel }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.boltgun), new Object[] { "DPS", " RD", " D ", 'D', DURA.ingot(), 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'R', RUBBER.ingot(), 'S', STEEL.shell() }); - + //Bobmazon CraftingManager.addShapelessAuto(new ItemStack(ModItems.bobmazon), new Object[] { Items.book, Items.gold_nugget, Items.string, KEY_BLUE }); - + //Carts CraftingManager.addRecipeAuto(ItemModMinecart.createCartItem(EnumCartBase.WOOD, EnumMinecart.EMPTY), new Object[] { "P P", "WPW", 'P',KEY_SLAB, 'W', KEY_PLANKS }); CraftingManager.addRecipeAuto(ItemModMinecart.createCartItem(EnumCartBase.STEEL, EnumMinecart.EMPTY), new Object[] { "P P", "IPI", 'P', STEEL.plate(), 'I', STEEL.ingot() }); CraftingManager.addShapelessAuto(ItemModMinecart.createCartItem(EnumCartBase.PAINTED, EnumMinecart.EMPTY), new Object[] { ItemModMinecart.createCartItem(EnumCartBase.STEEL, EnumMinecart.EMPTY), KEY_RED }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.boat_rubber), new Object[] { "L L", "LLL", 'L', ANY_RUBBER.ingot() }); - + for(EnumCartBase base : EnumCartBase.values()) { - + if(EnumMinecart.DESTROYER.supportsBase(base)) CraftingManager.addRecipeAuto(ItemModMinecart.createCartItem(base, EnumMinecart.DESTROYER), new Object[] { "S S", "BLB", "SCS", 'S', STEEL.ingot(), 'B', ModItems.blades_steel, 'L', Fluids.LAVA.getDict(1000), 'C', ItemModMinecart.createCartItem(base, EnumMinecart.EMPTY) }); if(EnumMinecart.POWDER.supportsBase(base)) CraftingManager.addRecipeAuto(ItemModMinecart.createCartItem(base, EnumMinecart.POWDER), new Object[] { "PPP", "PCP", "PPP", 'P', Items.gunpowder, 'C', ItemModMinecart.createCartItem(base, EnumMinecart.EMPTY) }); if(EnumMinecart.SEMTEX.supportsBase(base)) CraftingManager.addRecipeAuto(ItemModMinecart.createCartItem(base, EnumMinecart.SEMTEX), new Object[] { "S", "C", 'S', ModBlocks.semtex, 'C', ItemModMinecart.createCartItem(base, EnumMinecart.EMPTY) }); } net.minecraft.item.crafting.CraftingManager.getInstance().addRecipe(DictFrame.fromOne(ModItems.cart, EnumMinecart.CRATE), new Object[] { "C", "S", 'C', ModBlocks.crate_steel, 'S', Items.minecart }).func_92100_c(); - + //Configged if(GeneralConfig.enableLBSM && GeneralConfig.enableLBSMSimpleToolRecipes) { addSword( CO.block(), ModItems.cobalt_decorated_sword); @@ -234,11 +234,11 @@ public class ToolRecipes { public static void addHoe(Object ingot, Item hoe) { addTool(ingot, hoe, patternHoe); } - + public static void addTool(Object ingot, Item tool, String[] pattern) { CraftingManager.addRecipeAuto(new ItemStack(tool), new Object[] { pattern, 'X', ingot, '#', KEY_STICK }); } - + public static final String[] patternSword = new String[] {"X", "X", "#"}; public static final String[] patternPick = new String[] {"XXX", " # ", " # "}; public static final String[] patternAxe = new String[] {"XX", "X#", " #"}; diff --git a/src/main/java/com/hbm/crafting/handlers/ToolboxCraftingHandler.java b/src/main/java/com/hbm/crafting/handlers/ToolboxCraftingHandler.java deleted file mode 100644 index 7e27a5cc6..000000000 --- a/src/main/java/com/hbm/crafting/handlers/ToolboxCraftingHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.hbm.crafting.handlers; - -import java.util.ArrayList; -import java.util.List; - -import com.hbm.items.ModItems; -import com.hbm.items.special.ItemKitNBT; - -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.World; - -public class ToolboxCraftingHandler implements IRecipe { - - @Override - public boolean matches(InventoryCrafting inventory, World world) { - - int itemCount = 0; - int kitCount = 0; - - for(int i = 0; i < 9; i++) { - ItemStack stack = inventory.getStackInRowAndColumn(i % 3, i / 3); - - if(stack != null) { - - if(stack.getItem().hasContainerItem(stack) || !stack.getItem().doesContainerItemLeaveCraftingGrid(stack)) - return false; - - itemCount++; - - if(stack.getItem() == ModItems.kit_toolbox_empty) { - kitCount++; - } - } - } - - return itemCount > 1 && kitCount == 1; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting inventory) { - - List stacks = new ArrayList(); - - for(int i = 0; i < 9; i++) { - ItemStack stack = inventory.getStackInRowAndColumn(i % 3, i / 3); - - if(stack != null && stack.getItem() != ModItems.kit_toolbox_empty) { - ItemStack copy = stack.copy(); - copy.stackSize = 1; - stacks.add(copy); - } - } - - return ItemKitNBT.create(stacks.toArray(new ItemStack[0])); - } - - @Override - public int getRecipeSize() { - return 9; - } - - @Override - public ItemStack getRecipeOutput() { - return new ItemStack(ModItems.kit_toolbox); - } -} diff --git a/src/main/java/com/hbm/inventory/container/ContainerToolBox.java b/src/main/java/com/hbm/inventory/container/ContainerToolBox.java new file mode 100644 index 000000000..9e9de5aa9 --- /dev/null +++ b/src/main/java/com/hbm/inventory/container/ContainerToolBox.java @@ -0,0 +1,84 @@ +package com.hbm.inventory.container; + +import com.hbm.util.InventoryUtil; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import static com.hbm.items.tool.ItemToolBox.*; + +public class ContainerToolBox extends Container { + + private InventoryToolBox box; + + public ContainerToolBox(InventoryPlayer invPlayer, InventoryToolBox box) { + this.box = box; + this.box.openInventory(); + + for(int i = 0; i < 3; i++) { + for(int j = 0; j < 8; j++) { + this.addSlotToContainer(new Slot(box, j + i * 8, 17 + j * 18, 18 + i * 18)); + } + } + + for(int i = 0; i < 3; i++) { + for(int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 98 + i * 18)); + } + } + + for(int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 156)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) { + ItemStack var3 = null; + Slot var4 = (Slot) this.inventorySlots.get(par2); + + if(var4 != null && var4.getHasStack()) { + ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + if(par2 <= box.getSizeInventory() - 1) { + if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, box.getSizeInventory(), this.inventorySlots.size(), true)) { + return null; + } + } else if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, 0, box.getSizeInventory(), false)) { + return null; + } + + if(var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + var4.onPickupFromSlot(p_82846_1_, var5); + } + + return var3; + } + + @Override + public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) { + // prevents the player from moving around the currently open box + if(mode == 2 && button == player.inventory.currentItem) return null; + if(index == player.inventory.currentItem + 51) return null; + return super.slotClick(index, button, mode, player); + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return box.isUseableByPlayer(player); + } + + @Override + public void onContainerClosed(EntityPlayer player) { + super.onContainerClosed(player); + this.box.closeInventory(); + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUILeadBox.java b/src/main/java/com/hbm/inventory/gui/GUILeadBox.java index 715b40b01..49802ce65 100644 --- a/src/main/java/com/hbm/inventory/gui/GUILeadBox.java +++ b/src/main/java/com/hbm/inventory/gui/GUILeadBox.java @@ -13,43 +13,43 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; public class GUILeadBox extends GuiContainer { - + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_containment.png"); private final InventoryLeadBox inventory; private ItemStack firstHeld; - + public GUILeadBox(InventoryPlayer invPlayer, InventoryLeadBox box) { super(new ContainerLeadBox(invPlayer, box)); this.inventory = box; - + this.xSize = 176; this.ySize = 186; } @Override public void drawScreen(int x, int y, float interp) { - + if(firstHeld == null) { // *very* unlikely to be incorrect on the first frame after opening, so doing this is good enough firstHeld = this.mc.thePlayer.getHeldItem(); - + // if the open box has changed or disappeared, close the inventory } else if(this.mc.thePlayer.getHeldItem() != firstHeld) { //this.mc.thePlayer.closeScreen(); //return; } - + super.drawScreen(x, y, interp); } - + @Override protected void drawGuiContainerForegroundLayer(int i, int j) { String name = I18n.format(this.inventory.getInventoryName()); - + if(inventory.hasCustomInventoryName()) { - name = inventory.box.getDisplayName(); + name = inventory.target.getDisplayName(); } - + this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIToolBox.java b/src/main/java/com/hbm/inventory/gui/GUIToolBox.java new file mode 100644 index 000000000..1aedd6395 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIToolBox.java @@ -0,0 +1,65 @@ +package com.hbm.inventory.gui; + +import com.hbm.inventory.container.ContainerLeadBox; +import com.hbm.inventory.container.ContainerToolBox; +import com.hbm.items.tool.ItemLeadBox.InventoryLeadBox; +import com.hbm.lib.RefStrings; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import static com.hbm.items.tool.ItemToolBox.*; + +public class GUIToolBox extends GuiContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_toolbox.png"); + private final InventoryToolBox inventory; + private ItemStack firstHeld; + + public GUIToolBox(InventoryPlayer invPlayer, InventoryToolBox box) { + super(new ContainerToolBox(invPlayer, box)); + this.inventory = box; + + this.xSize = 176; + this.ySize = 186; + } + + @Override + public void drawScreen(int x, int y, float interp) { + + if(firstHeld == null) { + // *very* unlikely to be incorrect on the first frame after opening, so doing this is good enough + firstHeld = this.mc.thePlayer.getHeldItem(); + + // if the open box has changed or disappeared, close the inventory + } else if(this.mc.thePlayer.getHeldItem() != firstHeld) { + //this.mc.thePlayer.closeScreen(); + //return; + } + + super.drawScreen(x, y, interp); + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + String name = I18n.format(this.inventory.getInventoryName()); + + if(inventory.hasCustomInventoryName()) { + name = inventory.target.getDisplayName(); + } + + this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 102 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + } +} diff --git a/src/main/java/com/hbm/items/IItemInventory.java b/src/main/java/com/hbm/items/IItemInventory.java new file mode 100644 index 000000000..5efeef53d --- /dev/null +++ b/src/main/java/com/hbm/items/IItemInventory.java @@ -0,0 +1,154 @@ +package com.hbm.items; + +import com.hbm.util.ItemStackUtil; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; + +import java.io.IOException; +import java.util.Random; + +/** + * Base class for items containing an inventory. This can be seen in crates, containment boxes, and the toolbox. + * @author BallOfEnergy/Gammawave + */ +public abstract class IItemInventory implements IInventory { + + public EntityPlayer player; + public ItemStack[] slots; + public ItemStack target; + + public boolean toMarkDirty = false; + + @Override + public void markDirty() { + + if(!toMarkDirty || player.getEntityWorld().isRemote) + return; + + for(int i = 0; i < getSizeInventory(); ++i) { + if(getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { + slots[i] = null; + } + } + + ItemStackUtil.addStacksToNBT(target, slots); // Maintain compatibility with the containment boxes. + + target.setTagCompound(checkNBT(target.getTagCompound())); + + } + + public NBTTagCompound checkNBT(NBTTagCompound nbt) { + if(!nbt.hasNoTags()) { + Random random = new Random(); + + try { + byte[] abyte = CompressedStreamTools.compress(nbt); + + if (abyte.length > 6000) { + player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Warning: Container NBT exceeds 6kB, contents will be ejected!")); + for (int i1 = 0; i1 < this.getSizeInventory(); ++i1) { + ItemStack itemstack = this.getStackInSlot(i1); + + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + float f2 = random.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) { + int j1 = random.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + EntityItem entityitem = new EntityItem(player.worldObj, player.posX + f, player.posY + f1, player.posZ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + + if (itemstack.hasTagCompound()) { + entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (float) random.nextGaussian() * f3 + player.motionX; + entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F + player.motionY; + entityitem.motionZ = (float) random.nextGaussian() * f3 + player.motionZ; + player.worldObj.spawnEntityInWorld(entityitem); + } + } + } + + return new NBTTagCompound(); // Reset. + } + } catch (IOException ignored) {} + } + return nbt; + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + ItemStack stack = getStackInSlot(slot); + if (stack != null) { + if (stack.stackSize > amount) { + stack = stack.splitStack(amount); + } else { + setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + if(stack != null) { + stack.stackSize = Math.min(stack.stackSize, this.getInventoryStackLimit()); + } + + slots[slot] = stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + ItemStack stack = getStackInSlot(slot); + setInventorySlotContents(slot, null); + return stack; + } + + @Override + public ItemStack getStackInSlot(int slot) { + return slots[slot]; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return true; + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + return true; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public void openInventory() { + player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:block.crateOpen", 1.0F, 0.8F); + } + + @Override + public void closeInventory() { + toMarkDirty = true; + markDirty(); + toMarkDirty = false; + player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:block.crateClose", 1.0F, 0.8F); + } +} diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index 517423b5d..129624ec4 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -2133,8 +2133,9 @@ public class ModItems { public static Item hazmat_red_kit; public static Item hazmat_grey_kit; public static Item kit_custom; - public static Item kit_toolbox_empty; - public static Item kit_toolbox; + + public static Item legacy_toolbox; + public static Item toolbox; public static Item loot_10; public static Item loot_15; @@ -4125,8 +4126,8 @@ public class ModItems { hazmat_red_kit = new ItemStarterKit().setUnlocalizedName("hazmat_red_kit").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":hazmat_red_kit"); hazmat_grey_kit = new ItemStarterKit().setUnlocalizedName("hazmat_grey_kit").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":hazmat_grey_kit"); kit_custom = new ItemKitCustom().setUnlocalizedName("kit_custom").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":kit"); - kit_toolbox_empty = new Item().setUnlocalizedName("kit_toolbox_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":kit_toolbox_empty"); - kit_toolbox = new ItemKitNBT().setUnlocalizedName("kit_toolbox").setCreativeTab(MainRegistry.consumableTab).setContainerItem(kit_toolbox_empty).setTextureName(RefStrings.MODID + ":kit_toolbox"); + toolbox = new ItemToolBox().setUnlocalizedName("toolbox").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":kit_toolbox"); + legacy_toolbox = new ItemKitNBT().setUnlocalizedName("toolbox_legacy").setContainerItem(toolbox).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":kit_toolbox"); loot_10 = new ItemLootCrate().setUnlocalizedName("loot_10").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":loot_10"); loot_15 = new ItemLootCrate().setUnlocalizedName("loot_15").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab).setTextureName(RefStrings.MODID + ":loot_15"); @@ -6487,7 +6488,7 @@ public class ModItems { GameRegistry.registerItem(ammo_standard, ammo_standard.getUnlocalizedName()); GameRegistry.registerItem(ammo_secret, ammo_secret.getUnlocalizedName()); - + GameRegistry.registerItem(weapon_mod_test, weapon_mod_test.getUnlocalizedName()); //Ammo @@ -7161,8 +7162,8 @@ public class ModItems { GameRegistry.registerItem(hazmat_grey_kit, hazmat_grey_kit.getUnlocalizedName()); GameRegistry.registerItem(kit_custom, kit_custom.getUnlocalizedName()); GameRegistry.registerItem(euphemium_kit, euphemium_kit.getUnlocalizedName()); - GameRegistry.registerItem(kit_toolbox_empty, kit_toolbox_empty.getUnlocalizedName()); - GameRegistry.registerItem(kit_toolbox, kit_toolbox.getUnlocalizedName()); + GameRegistry.registerItem(legacy_toolbox, legacy_toolbox.getUnlocalizedName()); + GameRegistry.registerItem(toolbox, toolbox.getUnlocalizedName()); GameRegistry.registerItem(letter, letter.getUnlocalizedName()); //Misile Loot Boxes diff --git a/src/main/java/com/hbm/items/block/ItemBlockStorageCrate.java b/src/main/java/com/hbm/items/block/ItemBlockStorageCrate.java index 83d7d64b7..bad911b14 100644 --- a/src/main/java/com/hbm/items/block/ItemBlockStorageCrate.java +++ b/src/main/java/com/hbm/items/block/ItemBlockStorageCrate.java @@ -3,6 +3,7 @@ package com.hbm.items.block; import com.hbm.blocks.ModBlocks; import com.hbm.inventory.container.*; import com.hbm.inventory.gui.*; +import com.hbm.items.IItemInventory; import com.hbm.items.tool.ItemKey; import com.hbm.main.MainRegistry; import com.hbm.tileentity.IGUIProvider; @@ -10,21 +11,14 @@ import com.hbm.tileentity.machine.storage.*; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import javax.annotation.Nonnull; -import java.io.IOException; -import java.util.Random; public class ItemBlockStorageCrate extends ItemBlockBase implements IGUIProvider { @@ -86,18 +80,12 @@ public class ItemBlockStorageCrate extends ItemBlockBase implements IGUIProvider throw new NullPointerException(); } - public static class InventoryCrate implements IInventory { - - public final EntityPlayer player; - public final ItemStack crate; - public ItemStack[] slots; - - private boolean toMarkDirty = false; + public static class InventoryCrate extends IItemInventory { public InventoryCrate(EntityPlayer player, ItemStack crate) { this.player = player; - this.crate = crate; + this.target = crate; slots = new ItemStack[this.getSizeInventory()]; if(crate.stackTagCompound == null) @@ -125,66 +113,23 @@ public class ItemBlockStorageCrate extends ItemBlockBase implements IGUIProvider @Override public int getSizeInventory() { - return findCrateType(crate.getItem()).getSizeInventory(); + return findCrateType(target.getItem()).getSizeInventory(); } @Override public String getInventoryName() { - return findCrateType(crate.getItem()).getInventoryName(); - } - - @Override - public ItemStack getStackInSlot(int slot) { - return slots[slot]; - } - - @Override - public ItemStack decrStackSize(int slot, int amount) { - ItemStack stack = getStackInSlot(slot); - if (stack != null) { - if (stack.stackSize > amount) { - stack = stack.splitStack(amount); - } else { - setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - ItemStack stack = getStackInSlot(slot); - setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack) { - if(stack != null) { - stack.stackSize = Math.min(stack.stackSize, this.getInventoryStackLimit()); - } - - slots[slot] = stack; + return findCrateType(target.getItem()).getInventoryName(); } @Override public boolean hasCustomInventoryName() { - return crate.hasDisplayName(); - } - - @Override - public int getInventoryStackLimit() { - return 64; + return target.hasDisplayName(); } @Override public void markDirty() { // I HATE THIS SO MUCH - if(player.worldObj.isRemote) { // go the fuck away - return; - } - - if(!toMarkDirty) { // ok fuck you too + if(player.getEntityWorld().isRemote || !toMarkDirty) { // go the fuck away return; } @@ -203,88 +148,18 @@ public class ItemBlockStorageCrate extends ItemBlockBase implements IGUIProvider nbt.setTag("slot" + i, slot); } - if(crate.stackTagCompound != null) { // yes it's a bit jank, but it wants to clear otherwise so... - if(crate.stackTagCompound.hasKey("lock")) - nbt.setInteger("lock", crate.stackTagCompound.getInteger("lock")); - if(crate.stackTagCompound.hasKey("lockMod")) - nbt.setDouble("lockMod", crate.stackTagCompound.getDouble("lockMod")); - if(crate.stackTagCompound.hasKey("spiders")) - nbt.setBoolean("spiders", crate.stackTagCompound.getBoolean("spiders")); // fuck you!! + if(target.stackTagCompound != null) { // yes it's a bit jank, but it wants to clear otherwise so... + if(target.stackTagCompound.hasKey("lock")) + nbt.setInteger("lock", target.stackTagCompound.getInteger("lock")); + if(target.stackTagCompound.hasKey("lockMod")) + nbt.setDouble("lockMod", target.stackTagCompound.getDouble("lockMod")); + if(target.stackTagCompound.hasKey("spiders")) + nbt.setBoolean("spiders", target.stackTagCompound.getBoolean("spiders")); // fuck you!! } - if(!nbt.hasNoTags()) { + target.setTagCompound(checkNBT(nbt)); - Random random = new Random(); - - try { - byte[] abyte = CompressedStreamTools.compress(nbt); - - if(abyte.length > 6000) { - player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Warning: Container NBT exceeds 6kB, contents will be ejected!")); - for(int i1 = 0; i1 < invSize; ++i1) { - ItemStack itemstack = this.getStackInSlot(i1); - - if(itemstack != null) { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - float f2 = random.nextFloat() * 0.8F + 0.1F; - - while(itemstack.stackSize > 0) { - int j1 = random.nextInt(21) + 10; - - if(j1 > itemstack.stackSize) { - j1 = itemstack.stackSize; - } - - itemstack.stackSize -= j1; - EntityItem entityitem = new EntityItem(player.worldObj, player.posX + f, player.posY + f1, player.posZ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); - - if(itemstack.hasTagCompound()) { - entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); - } - - float f3 = 0.05F; - entityitem.motionX = (float) random.nextGaussian() * f3 + player.motionX; - entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F + player.motionY; - entityitem.motionZ = (float) random.nextGaussian() * f3 + player.motionZ; - player.worldObj.spawnEntityInWorld(entityitem); - } - } - } - - crate.setTagCompound(null); // Wipe tag compound to clear crate. - player.inventory.setInventorySlotContents(player.inventory.currentItem, crate); - return; - } - } catch(IOException ignored) { } - } - - crate.setTagCompound(nbt); - - player.inventory.setInventorySlotContents(player.inventory.currentItem, crate); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return true; - } - - @Override - public void openInventory() { - player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:block.crateOpen", 1.0F, 0.8F); - } - - @Override - public void closeInventory() { - toMarkDirty = true; - markDirty(); - toMarkDirty = false; - player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:block.crateClose", 1.0F, 0.8F); - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack) { - return true; + player.inventory.setInventorySlotContents(player.inventory.currentItem, target); } } } diff --git a/src/main/java/com/hbm/items/special/ItemKitNBT.java b/src/main/java/com/hbm/items/special/ItemKitNBT.java index f7248759c..571ecf257 100644 --- a/src/main/java/com/hbm/items/special/ItemKitNBT.java +++ b/src/main/java/com/hbm/items/special/ItemKitNBT.java @@ -14,64 +14,64 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class ItemKitNBT extends Item { - + public ItemKitNBT() { this.setMaxStackSize(1); } - + @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - + ItemStack[] stacks = ItemStackUtil.readStacksFromNBT(stack); - + if(stacks != null) { - + for(ItemStack item : stacks) { if(item != null) { player.inventory.addItemStackToInventory(item.copy()); } } } - + ItemStack container = stack.getItem().getContainerItem(stack); - + stack.stackSize--; - + if(container != null) { - + if(stack.stackSize > 0) { player.inventory.addItemStackToInventory(container.copy()); } else { stack = container.copy(); } } - + world.playSoundAtEntity(player, "hbm:item.unpack", 1.0F, 1.0F); - + return stack; } - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { - + ItemStack[] stacks = ItemStackUtil.readStacksFromNBT(stack); - + if(stacks != null) { - + list.add("Contains:"); - + for(ItemStack item : stacks) { list.add("-" + item.getDisplayName() + (item.stackSize > 1 ? (" x" + item.stackSize) : "")); } } } - + public static ItemStack create(ItemStack... contents) { - ItemStack stack = new ItemStack(ModItems.kit_toolbox); + ItemStack stack = new ItemStack(ModItems.legacy_toolbox); stack.stackTagCompound = new NBTTagCompound(); ItemStackUtil.addStacksToNBT(stack, contents); - + return stack; } } diff --git a/src/main/java/com/hbm/items/tool/ItemLeadBox.java b/src/main/java/com/hbm/items/tool/ItemLeadBox.java index bfa427cc7..3959cb7e7 100644 --- a/src/main/java/com/hbm/items/tool/ItemLeadBox.java +++ b/src/main/java/com/hbm/items/tool/ItemLeadBox.java @@ -2,6 +2,7 @@ package com.hbm.items.tool; import com.hbm.inventory.container.ContainerLeadBox; import com.hbm.inventory.gui.GUILeadBox; +import com.hbm.items.IItemInventory; import com.hbm.main.MainRegistry; import com.hbm.tileentity.IGUIProvider; import com.hbm.util.ItemStackUtil; @@ -10,7 +11,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -21,7 +21,7 @@ public class ItemLeadBox extends Item implements IGUIProvider { public ItemLeadBox() { this.setMaxStackSize(1); } - + @Override public int getMaxItemUseDuration(ItemStack stack) { return 1; @@ -29,7 +29,7 @@ public class ItemLeadBox extends Item implements IGUIProvider { @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - + if(!world.isRemote) player.openGui(MainRegistry.instance, 0, world, 0, 0, 0); return stack; } @@ -44,28 +44,27 @@ public class ItemLeadBox extends Item implements IGUIProvider { public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUILeadBox(player.inventory, new InventoryLeadBox(player, player.getHeldItem())); } - - public static class InventoryLeadBox implements IInventory { - - public final EntityPlayer player; - public final ItemStack box; - public ItemStack[] slots; - + + public static class InventoryLeadBox extends IItemInventory { + public InventoryLeadBox(EntityPlayer player, ItemStack box) { this.player = player; - this.box = box; + this.target = box; slots = new ItemStack[this.getSizeInventory()]; - + if(!box.hasTagCompound()) box.setTagCompound(new NBTTagCompound()); - + ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(box, slots.length); - + if(fromNBT != null) { for(int i = 0; i < slots.length; i++) { slots[i] = fromNBT[i]; } } + toMarkDirty = true; + this.markDirty(); + toMarkDirty = false; } @Override @@ -73,43 +72,6 @@ public class ItemLeadBox extends Item implements IGUIProvider { return 20; } - @Override - public ItemStack getStackInSlot(int slot) { - return slots[slot]; - } - - @Override - public ItemStack decrStackSize(int slot, int amount) { - ItemStack stack = getStackInSlot(slot); - if (stack != null) { - if (stack.stackSize > amount) { - stack = stack.splitStack(amount); - markDirty(); - } else { - setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - ItemStack stack = getStackInSlot(slot); - setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack) { - - if(stack != null) { - stack.stackSize = Math.min(stack.stackSize, this.getInventoryStackLimit()); - } - - slots[slot] = stack; - markDirty(); - } - @Override public String getInventoryName() { return "container.leadBox"; @@ -117,44 +79,12 @@ public class ItemLeadBox extends Item implements IGUIProvider { @Override public boolean hasCustomInventoryName() { - return box.hasDisplayName(); + return target.hasDisplayName(); } @Override public int getInventoryStackLimit() { return 1; } - - @Override - public void markDirty() { - - for(int i = 0; i < getSizeInventory(); ++i) { - if(getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { - slots[i] = null; - } - } - - ItemStackUtil.addStacksToNBT(box, slots); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return true; - } - - @Override - public void openInventory() { - player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:block.crateOpen", 1.0F, 0.8F); - } - - @Override - public void closeInventory() { - player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:block.crateClose", 1.0F, 0.8F); - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack) { - return true; - } } } diff --git a/src/main/java/com/hbm/items/tool/ItemToolBox.java b/src/main/java/com/hbm/items/tool/ItemToolBox.java new file mode 100644 index 000000000..a378c6cd8 --- /dev/null +++ b/src/main/java/com/hbm/items/tool/ItemToolBox.java @@ -0,0 +1,227 @@ +package com.hbm.items.tool; + +import com.hbm.inventory.container.ContainerToolBox; +import com.hbm.inventory.gui.GUIToolBox; +import com.hbm.items.IItemInventory; +import com.hbm.items.ModItems; +import com.hbm.lib.RefStrings; +import com.hbm.main.MainRegistry; +import com.hbm.tileentity.IGUIProvider; +import com.hbm.util.ChatBuilder; +import com.hbm.util.ItemStackUtil; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.*; +import net.minecraft.world.World; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class ItemToolBox extends Item implements IGUIProvider { + + @SideOnly(Side.CLIENT) protected IIcon iconOpen; + @SideOnly(Side.CLIENT) protected IIcon iconClosed; + + public ItemToolBox() { + this.setMaxStackSize(1); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + super.registerIcons(iconRegister); + this.iconOpen = iconRegister.registerIcon(RefStrings.MODID + ":kit_toolbox_empty"); + this.iconClosed = iconRegister.registerIcon(RefStrings.MODID + ":kit_toolbox"); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass) { + + if(stack.getTagCompound() != null && stack.getTagCompound().getBoolean("isOpen") && renderPass == 1) return this.iconOpen; + return renderPass == 1 ? this.iconClosed : getIconFromDamageForRenderPass(stack.getItemDamage(), renderPass); + } + + public List getActiveRows(ItemStack box) { + ItemStack[] stacks = ItemStackUtil.readStacksFromNBT(box, 24); + if(stacks == null) + return new ArrayList<>(); + List activeRows = new ArrayList<>(); + for (int row = 0; row < 3; row++) { + for (int slot = 0; slot < 8; slot++) { + if(stacks[row * 8 + slot] != null) { + activeRows.add(row); + break; + } + } + } + return activeRows; + } + + // This function genuinely hurts my soul, but it works... + public void moveRows(ItemStack box, EntityPlayer player) { + + // Move from hotbar into array in preparation for boxing. + ItemStack[] endingHotBar = new ItemStack[9]; + ItemStack[] stacksToTransferToBox = new ItemStack[8]; + + boolean hasToolbox = false; + int extraToolboxes = 0; + for (int i = 0; i < 9; i++) { // Maximum allowed HotBar size is 9. + + ItemStack slot = player.inventory.getStackInSlot(i); + + if(slot != null && slot.getItem() == ModItems.toolbox && i != player.inventory.currentItem) { + + extraToolboxes++; + player.dropPlayerItemWithRandomChoice(slot, true); + player.inventory.setInventorySlotContents(i, null); + + } else if(i == player.inventory.currentItem) { + hasToolbox = true; + endingHotBar[i] = slot; + } else { + stacksToTransferToBox[i - (hasToolbox ? 1 : 0)] = slot; + } + } + + if(extraToolboxes > 0) { + if(extraToolboxes == 1) + player.addChatComponentMessage(new ChatComponentText("You can't toolbox a toolbox... ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); // TODO: tell someone else to do i18n stuff; i don't want to + else + player.addChatComponentMessage(new ChatComponentText("You can't toolbox a toolbox... (x" + extraToolboxes + ")").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); // TODO: this too :ayo: + } + + // Move stacks around inside the box, mostly shifts rows to other rows and shifts the top row to the hotbar. + ItemStack[] stacks = ItemStackUtil.readStacksFromNBT(box, 24); + ItemStack[] endingStacks = new ItemStack[24]; + + if(stacks != null) { + List activeRows = getActiveRows(box); + + int lowestIndex = Integer.MAX_VALUE; + { // Finding the lowest active row to decide what row to move to the hotbar. + for (Integer activeRowIndex : activeRows) { + lowestIndex = Math.min(activeRowIndex, lowestIndex); + } + } + + // This entire section sucks, but honestly it's not actually that bad; it works so.... + for (Integer activeRowIndex : activeRows) { + + int activeIndex = 8 * activeRowIndex; + + if (activeRowIndex == lowestIndex) { // Items to "flow" to the hotbar. + hasToolbox = false; + for (int i = 0; i < 9; i++) { + if(i == player.inventory.currentItem) { + hasToolbox = true; + continue; + } + endingHotBar[i] = stacks[activeIndex + i - (hasToolbox ? 1 : 0)]; + } + continue; + } + + int targetIndex = 8 * (activeRowIndex - 1); + + System.arraycopy(stacks, activeIndex, endingStacks, targetIndex, 8); + } + } + + // Finally, move all temporary arrays into their respective locations. + System.arraycopy(stacksToTransferToBox, 0, endingStacks, 16, 8); + + for (int i = 0; i < endingHotBar.length; i++) { + player.inventory.setInventorySlotContents(i, endingHotBar[i]); + } + + box.setTagCompound(new NBTTagCompound()); + ItemStackUtil.addStacksToNBT(box, endingStacks); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + + if(!world.isRemote) { + if (player.isSneaking()) { + moveRows(stack, player); + player.inventoryContainer.detectAndSendChanges(); + } else { + if(stack.getTagCompound() == null) + stack.setTagCompound(new NBTTagCompound()); + stack.getTagCompound().setBoolean("isOpen", true); + player.openGui(MainRegistry.instance, 0, world, 0, 0, 0); + } + } + return stack; + } + + @Override + public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { + return new ContainerToolBox(player.inventory, new InventoryToolBox(player, player.getHeldItem())); + } + + @Override + @SideOnly(Side.CLIENT) + public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { + return new GUIToolBox(player.inventory, new InventoryToolBox(player, player.getHeldItem())); + } + + public static class InventoryToolBox extends IItemInventory { + + public InventoryToolBox(EntityPlayer player, ItemStack box) { + this.player = player; + this.target = box; + slots = new ItemStack[this.getSizeInventory()]; + + if(!box.hasTagCompound()) + box.setTagCompound(new NBTTagCompound()); + + ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(box, slots.length); + + if(fromNBT != null) { + System.arraycopy(fromNBT, 0, slots, 0, slots.length); + } + toMarkDirty = true; + this.markDirty(); + toMarkDirty = false; + } + + @Override + public int getSizeInventory() { + return 24; + } + + @Override + public String getInventoryName() { + return "container.toolBox"; + } + + @Override + public boolean hasCustomInventoryName() { + return target.hasDisplayName(); + } + + @Override + public void closeInventory() { + this.target.getTagCompound().removeTag("isOpen"); + this.player.inventory.setInventorySlotContents(this.player.inventory.currentItem, this.target); + super.closeInventory(); + } + } +} diff --git a/src/main/java/com/hbm/main/CraftingManager.java b/src/main/java/com/hbm/main/CraftingManager.java index 5605ce908..5494f320b 100644 --- a/src/main/java/com/hbm/main/CraftingManager.java +++ b/src/main/java/com/hbm/main/CraftingManager.java @@ -66,12 +66,10 @@ public class CraftingManager { GameRegistry.addRecipe(new RBMKFuelCraftingHandler()); GameRegistry.addRecipe(new MKUCraftingHandler()); - GameRegistry.addRecipe(new ToolboxCraftingHandler()); GameRegistry.addRecipe(new CargoShellCraftingHandler()); GameRegistry.addRecipe(new ScrapsCraftingHandler()); RecipeSorter.register("hbm:rbmk", RBMKFuelCraftingHandler.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); - RecipeSorter.register("hbm:toolbox", ToolboxCraftingHandler.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); RecipeSorter.register("hbm:cargo", CargoShellCraftingHandler.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); RecipeSorter.register("hbm:scraps", ScrapsCraftingHandler.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); RecipeSorter.register("hbm:mku", MKUCraftingHandler.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped before:minecraft:shapeless"); @@ -791,7 +789,7 @@ public class CraftingManager { addShapelessAuto(new ItemStack(ModItems.plate_cast, 1, Mats.MAT_STEEL.id), new Object[] { ModBlocks.hadron_plating_voltz }); addShapelessAuto(DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), new Object[] { ModBlocks.hadron_analysis }); addShapelessAuto(DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ADVANCED), new Object[] { ModBlocks.hadron_analysis_glass }); - + addRecipeAuto(new ItemStack(ModBlocks.hadron_coil_alloy, 1), new Object[] { "WW", "WW", 'W', ALLOY.wireDense() }); //addRecipeAuto(new ItemStack(ModBlocks.hadron_coil_gold, 1), new Object[] { "WG", "GW", 'W', ALLOY.wireDense(), 'G', GOLD.wireDense() }); //addRecipeAuto(new ItemStack(ModBlocks.hadron_coil_neodymium, 1), new Object[] { "WG", "GW", 'W', ND.wireDense(), 'G', GOLD.wireDense() }); @@ -1171,29 +1169,29 @@ public class CraftingManager { List toDestroy = new ArrayList(); List recipeList = net.minecraft.item.crafting.CraftingManager.getInstance().getRecipeList(); - + synchronized(recipeList) { //this is how threading works. i think. for(Object o : recipeList) { - + if(o instanceof IRecipe) { IRecipe rec = (IRecipe)o; ItemStack stack = rec.getRecipeOutput(); - + for(ItemStack target : targets) { if(stack != null && stack.getItem() == target.getItem() && stack.getItemDamage() == target.getItemDamage()) toDestroy.add(rec); } } } - + if(toDestroy.size() > 0) { recipeList.removeAll(toDestroy); } - + if(Loader.isModLoaded("Mekanism")) { Item disassembler = (Item) Item.itemRegistry.getObject("Mekanism:AtomicDisassembler"); if(disassembler != null) addRecipeAuto(new ItemStack(disassembler, 1), "GAG", "EIE", " I ", 'G', GOLD.plateCast(), 'A', "alloyUltimate", 'E', "battery", 'I', "ingotRefinedObsidian"); } - + if(Loader.isModLoaded("MekanismGenerators")) { Block generator = (Block) Block.blockRegistry.getObject("MekanismGenerators:Generator"); if(generator != null) addRecipeAuto(new ItemStack(generator, 1, 6), " T ", "TAT", "BCB", 'T', TI.plateCast(), 'A', "alloyAdvanced", 'B', "battery", 'C', ANY_PLASTIC.ingot()); diff --git a/src/main/java/com/hbm/main/MainRegistry.java b/src/main/java/com/hbm/main/MainRegistry.java index 903ddb954..dd4323118 100644 --- a/src/main/java/com/hbm/main/MainRegistry.java +++ b/src/main/java/com/hbm/main/MainRegistry.java @@ -172,7 +172,7 @@ public class MainRegistry { public static StatBase statLegendary; public static StatBase statMines; public static StatBase statBullets; - + // Achievements public static Achievement achSacrifice; public static Achievement achImpossible; @@ -863,7 +863,7 @@ public class MainRegistry { FalloutConfigJSON.initialize(); ItemPoolConfigJSON.initialize(); - + ClientConfig.initConfig(); ServerConfig.initConfig(); @@ -1672,6 +1672,9 @@ public class MainRegistry { remapItems.put("hbm:item.briquette_lignite", ModItems.briquette); remapItems.put("hbm:item.antiknock", ModItems.fuel_additive); + remapItems.put("hbm:item.kit_toolbox_empty", ModItems.toolbox); + remapItems.put("hbm:item.kit_toolbox", ModItems.legacy_toolbox); + for(MissingMapping mapping : event.get()) { // ignore all ammo prefixes because those are from the time we threw out all the ammo items diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 90140273e..4c7355630 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -849,6 +849,7 @@ container.soyuzLauncher=Soyuz Launch Platform container.storageDrum=Nuclear Waste Disposal Drum container.teleLinker=TelLink Device container.teleporter=Teleporter +container.toolBox=Toolbox container.trainTram=Electric Flat Bed Tram container.turbinegas=Combined Cycle Gas Turbine container.turretArty=Greg @@ -3387,8 +3388,8 @@ item.key_red.desc.P11=§4e§r item.key_red_cracked.name=Cracked Key item.key_red_cracked.desc=??? item.key_red.key_red_cracked.P11=§4???§r -item.kit_toolbox.name=Toolbox -item.kit_toolbox_empty.name=Empty Toolbox +item.toolbox.name=Toolbox +item.toolbox_legacy.name=Toolbox (LEGACY) item.laser_crystal_bismuth.desc=Bismuth-Samarium-Uranium-Thorium crystal matrix item.laser_crystal_bismuth.name=BiSmUTh Laser Crystal item.laser_crystal_cmb.desc=Antischrabidium Suspended in a CMB-Schrabidate Alloy Lattice diff --git a/src/main/resources/assets/hbm/textures/gui/gui_toolbox.png b/src/main/resources/assets/hbm/textures/gui/gui_toolbox.png new file mode 100644 index 000000000..285c78101 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/gui_toolbox.png differ