diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 3d48508ec..0e0a4ec5d 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -775,6 +775,7 @@ public class ModBlocks { public static Block conveyor_lift; public static Block crane_extractor; public static Block crane_inserter; + public static Block crane_grabber; public static Block crane_router; public static Block crane_boxer; public static Block crane_unboxer; @@ -1900,10 +1901,11 @@ public class ModBlocks { conveyor_lift = new BlockConveyorLift().setBlockName("conveyor_lift").setHardness(2.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor"); crane_extractor = new CraneExtractor().setBlockName("crane_extractor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); crane_inserter = new CraneInserter().setBlockName("crane_inserter").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); + crane_grabber = new CraneGrabber().setBlockName("crane_grabber").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); crane_router = new CraneRouter().setBlockName("crane_router").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); crane_boxer = new CraneBoxer().setBlockName("crane_boxer").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); crane_unboxer = new CraneUnboxer().setBlockName("crane_unboxer").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); - crane_splitter = new CraneSplitter().setBlockName("crane_splitter").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); + crane_splitter = new CraneSplitter().setBlockName("crane_splitter").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":crane_side"); fan = new MachineFan().setBlockName("fan").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); chain = new BlockChain(Material.iron).setBlockName("dungeon_chain").setHardness(0.25F).setResistance(2.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":chain"); @@ -3095,6 +3097,7 @@ public class ModBlocks { GameRegistry.registerBlock(crane_extractor, crane_extractor.getUnlocalizedName()); GameRegistry.registerBlock(crane_inserter, crane_inserter.getUnlocalizedName()); + GameRegistry.registerBlock(crane_grabber, crane_grabber.getUnlocalizedName()); GameRegistry.registerBlock(crane_router, crane_router.getUnlocalizedName()); GameRegistry.registerBlock(crane_boxer, crane_boxer.getUnlocalizedName()); GameRegistry.registerBlock(crane_unboxer, crane_unboxer.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/blocks/network/CraneGrabber.java b/src/main/java/com/hbm/blocks/network/CraneGrabber.java new file mode 100644 index 000000000..71372467b --- /dev/null +++ b/src/main/java/com/hbm/blocks/network/CraneGrabber.java @@ -0,0 +1,56 @@ +package com.hbm.blocks.network; + +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.network.TileEntityCraneGrabber; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class CraneGrabber extends BlockCraneBase { + + public CraneGrabber() { + super(Material.iron); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityCraneGrabber(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + super.registerBlockIcons(iconRegister); + this.iconDirectional = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_top"); + this.iconDirectionalUp = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_up"); + this.iconDirectionalDown = iconRegister.registerIcon(RefStrings.MODID + ":crane_grabber_side_down"); + this.iconOut = iconRegister.registerIcon(RefStrings.MODID + ":crane_pull"); + this.iconSideOut = iconRegister.registerIcon(RefStrings.MODID + ":crane_side_pull"); + } + + @Override + public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side) { + int meta = world.getBlockMetadata(x, y, z); + + if(meta > 1 && side == 1) { + if(meta == 2) return 3; + if(meta == 3) return 0; + if(meta == 4) return 1; + if(meta == 5) return 2; + } + + return 0; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + this.dropContents(world, x, y, z, block, meta, 0, 11); + super.breakBlock(world, x, y, z, block, meta); + } +} diff --git a/src/main/java/com/hbm/blocks/network/CraneSplitter.java b/src/main/java/com/hbm/blocks/network/CraneSplitter.java index e0abc2450..98b519420 100644 --- a/src/main/java/com/hbm/blocks/network/CraneSplitter.java +++ b/src/main/java/com/hbm/blocks/network/CraneSplitter.java @@ -28,7 +28,10 @@ public class CraneSplitter extends BlockDummyable implements IConveyorBelt, IEnt @SideOnly(Side.CLIENT) public IIcon iconTopRight; @SideOnly(Side.CLIENT) public IIcon iconFrontLeft; @SideOnly(Side.CLIENT) public IIcon iconFrontRight; - @SideOnly(Side.CLIENT) public IIcon iconBottom; + @SideOnly(Side.CLIENT) public IIcon iconBackLeft; + @SideOnly(Side.CLIENT) public IIcon iconBackRight; + @SideOnly(Side.CLIENT) public IIcon iconLeft; + @SideOnly(Side.CLIENT) public IIcon iconRight; @SideOnly(Side.CLIENT) public IIcon iconBelt; @SideOnly(Side.CLIENT) public IIcon iconInner; @@ -55,7 +58,16 @@ public class CraneSplitter extends BlockDummyable implements IConveyorBelt, IEnt @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { super.registerBlockIcons(iconRegister); + this.iconTopLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_splitter_top_left"); + this.iconTopRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_splitter_top_right"); + this.iconFrontLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_splitter_front_left"); + this.iconFrontRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_splitter_front_right"); + this.iconBackLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_splitter_back_left"); + this.iconBackRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_splitter_back_right"); + this.iconLeft = iconRegister.registerIcon(RefStrings.MODID + ":crane_splitter_left"); + this.iconRight = iconRegister.registerIcon(RefStrings.MODID + ":crane_splitter_right"); this.iconBelt = iconRegister.registerIcon(RefStrings.MODID + ":crane_splitter_belt"); + this.iconInner = iconRegister.registerIcon(RefStrings.MODID + ":crane_splitter_inner"); } public static int renderID = RenderingRegistry.getNextAvailableRenderId(); diff --git a/src/main/java/com/hbm/inventory/container/ContainerCraneExtractor.java b/src/main/java/com/hbm/inventory/container/ContainerCraneExtractor.java index a0de53617..afab4ad24 100644 --- a/src/main/java/com/hbm/inventory/container/ContainerCraneExtractor.java +++ b/src/main/java/com/hbm/inventory/container/ContainerCraneExtractor.java @@ -14,26 +14,26 @@ public class ContainerCraneExtractor extends Container { protected TileEntityCraneExtractor extractor; - public ContainerCraneExtractor(InventoryPlayer invPlayer, TileEntityCraneExtractor inserter) { - this.extractor = inserter; + public ContainerCraneExtractor(InventoryPlayer invPlayer, TileEntityCraneExtractor extractor) { + this.extractor = extractor; //filter for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { - this.addSlotToContainer(new Slot(inserter, j + i * 3, 71 + j * 18, 17 + i * 18)); + this.addSlotToContainer(new Slot(extractor, j + i * 3, 71 + j * 18, 17 + i * 18)); } } //buffer for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { - this.addSlotToContainer(new Slot(inserter, 9 + j + i * 3, 8 + j * 18, 17 + i * 18)); + this.addSlotToContainer(new Slot(extractor, 9 + j + i * 3, 8 + j * 18, 17 + i * 18)); } } //upgrades - this.addSlotToContainer(new SlotUpgrade(inserter, 18, 152, 23)); - this.addSlotToContainer(new SlotUpgrade(inserter, 19, 152, 47)); + this.addSlotToContainer(new SlotUpgrade(extractor, 18, 152, 23)); + this.addSlotToContainer(new SlotUpgrade(extractor, 19, 152, 47)); for(int i = 0; i < 3; i++) { for(int j = 0; j < 9; j++) { @@ -102,8 +102,6 @@ public class ContainerCraneExtractor extends Container { //M3: 3 //SHIFT: 1 //DRAG: 5 - //System.out.println("Mode " + mode); - //System.out.println("Slot " + index); if(index < 0 || index > 8) { return super.slotClick(index, button, mode, player); diff --git a/src/main/java/com/hbm/inventory/container/ContainerCraneGrabber.java b/src/main/java/com/hbm/inventory/container/ContainerCraneGrabber.java new file mode 100644 index 000000000..32c91fd68 --- /dev/null +++ b/src/main/java/com/hbm/inventory/container/ContainerCraneGrabber.java @@ -0,0 +1,126 @@ +package com.hbm.inventory.container; + +import com.hbm.inventory.SlotUpgrade; +import com.hbm.items.ModItems; +import com.hbm.tileentity.network.TileEntityCraneGrabber; + +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; + +public class ContainerCraneGrabber extends Container { + + protected TileEntityCraneGrabber grabber; + + public ContainerCraneGrabber(InventoryPlayer invPlayer, TileEntityCraneGrabber grabber) { + this.grabber = grabber; + + //filter + for(int i = 0; i < 3; i++) { + for(int j = 0; j < 3; j++) { + this.addSlotToContainer(new Slot(grabber, j + i * 3, 40 + j * 18, 17 + i * 18)); + } + } + + //upgrades + this.addSlotToContainer(new SlotUpgrade(grabber, 9, 121, 23)); + this.addSlotToContainer(new SlotUpgrade(grabber, 10, 121, 47)); + + 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, 103 + i * 18)); + } + } + + for(int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 161)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { + ItemStack var3 = null; + Slot var4 = (Slot) this.inventorySlots.get(slot); + + if(var4 != null && var4.getHasStack()) { + ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + if(slot < 9) { //filters + return null; + } + + if(slot <= grabber.getSizeInventory() - 1) { + if(!this.mergeItemStack(var5, grabber.getSizeInventory(), this.inventorySlots.size(), true)) { + return null; + } + } else { + + if(var3.getItem() == ModItems.upgrade_stack) { + if(!this.mergeItemStack(var5, 9, 10, false)) + return null; + } else if(var3.getItem() == ModItems.upgrade_ejector) { + if(!this.mergeItemStack(var5, 10, 11, false)) + return null; + } + + return null; + } + + if(var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + var4.onPickupFromSlot(player, var5); + } + + return var3; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return grabber.isUseableByPlayer(player); + } + + @Override + public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) { + + //L/R: 0 + //M3: 3 + //SHIFT: 1 + //DRAG: 5 + + if(index < 0 || index > 8) { + return super.slotClick(index, button, mode, player); + } + + Slot slot = this.getSlot(index); + + ItemStack ret = null; + ItemStack held = player.inventory.getItemStack(); + + if(slot.getHasStack()) + ret = slot.getStack().copy(); + + if(button == 1 && mode == 0 && slot.getHasStack()) { + grabber.nextMode(index); + return ret; + + } else { + slot.putStack(held != null ? held.copy() : null); + + if(slot.getHasStack()) { + slot.getStack().stackSize = 1; + } + + slot.onSlotChanged(); + grabber.matcher.initPatternStandard(grabber.getWorldObj(), slot.getStack(), index); + + return ret; + } + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUICraneExtractor.java b/src/main/java/com/hbm/inventory/gui/GUICraneExtractor.java index ea927d377..e6937c829 100644 --- a/src/main/java/com/hbm/inventory/gui/GUICraneExtractor.java +++ b/src/main/java/com/hbm/inventory/gui/GUICraneExtractor.java @@ -22,11 +22,11 @@ import net.minecraft.util.ResourceLocation; public class GUICraneExtractor extends GuiInfoContainer { private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_crane_ejector.png"); - private TileEntityCraneExtractor inserter; + private TileEntityCraneExtractor ejector; public GUICraneExtractor(InventoryPlayer invPlayer, TileEntityCraneExtractor tedf) { super(new ContainerCraneExtractor(invPlayer, tedf)); - inserter = tedf; + ejector = tedf; this.xSize = 176; this.ySize = 185; @@ -40,14 +40,14 @@ public class GUICraneExtractor extends GuiInfoContainer { for(int i = 0; i < 9; ++i) { Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i); - if(this.isMouseOverSlot(slot, x, y) && inserter.matcher.modes[i] != null) { + if(this.isMouseOverSlot(slot, x, y) && ejector.matcher.modes[i] != null) { String label = EnumChatFormatting.YELLOW + ""; - switch(inserter.matcher.modes[i]) { + switch(ejector.matcher.modes[i]) { case "exact": label += "Item and meta match"; break; case "wildcard": label += "Item matches"; break; - default: label += "Ore dict key matches: " + inserter.matcher.modes[i]; break; + default: label += "Ore dict key matches: " + ejector.matcher.modes[i]; break; } this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30); @@ -65,13 +65,13 @@ public class GUICraneExtractor extends GuiInfoContainer { mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); NBTTagCompound data = new NBTTagCompound(); data.setBoolean("whitelist", true); - PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, inserter.xCoord, inserter.yCoord, inserter.zCoord)); + PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, ejector.xCoord, ejector.yCoord, ejector.zCoord)); } } @Override protected void drawGuiContainerForegroundLayer(int i, int j) { - String name = this.inserter.hasCustomInventoryName() ? this.inserter.getInventoryName() : I18n.format(this.inserter.getInventoryName()); + String name = this.ejector.hasCustomInventoryName() ? this.ejector.getInventoryName() : I18n.format(this.ejector.getInventoryName()); 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); } @@ -82,7 +82,7 @@ public class GUICraneExtractor extends GuiInfoContainer { Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - if(inserter.isWhitelist) { + if(ejector.isWhitelist) { drawTexturedModalRect(guiLeft + 139, guiTop + 33, 176, 0, 3, 6); } else { drawTexturedModalRect(guiLeft + 139, guiTop + 47, 176, 0, 3, 6); diff --git a/src/main/java/com/hbm/inventory/gui/GUICraneGrabber.java b/src/main/java/com/hbm/inventory/gui/GUICraneGrabber.java new file mode 100644 index 000000000..ef1465205 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUICraneGrabber.java @@ -0,0 +1,91 @@ +package com.hbm.inventory.gui; + +import java.util.Arrays; + +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.container.ContainerCraneGrabber; +import com.hbm.lib.RefStrings; +import com.hbm.packet.NBTControlPacket; +import com.hbm.packet.PacketDispatcher; +import com.hbm.tileentity.network.TileEntityCraneGrabber; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; + +public class GUICraneGrabber extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_crane_grabber.png"); + private TileEntityCraneGrabber grabber; + + public GUICraneGrabber(InventoryPlayer invPlayer, TileEntityCraneGrabber tedf) { + super(new ContainerCraneGrabber(invPlayer, tedf)); + grabber = tedf; + + this.xSize = 176; + this.ySize = 185; + } + + @Override + public void drawScreen(int x, int y, float interp) { + super.drawScreen(x, y, interp); + + if(this.mc.thePlayer.inventory.getItemStack() == null) { + for(int i = 0; i < 9; ++i) { + Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i); + + if(this.isMouseOverSlot(slot, x, y) && grabber.matcher.modes[i] != null) { + + String label = EnumChatFormatting.YELLOW + ""; + + switch(grabber.matcher.modes[i]) { + case "exact": label += "Item and meta match"; break; + case "wildcard": label += "Item matches"; break; + default: label += "Ore dict key matches: " + grabber.matcher.modes[i]; break; + } + + this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30); + } + } + } + } + + @Override + protected void mouseClicked(int x, int y, int i) { + super.mouseClicked(x, y, i); + + if(guiLeft + 97 <= x && guiLeft + 97 + 14 > x && guiTop + 30 < y && guiTop + 30 + 26 >= y) { + + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + NBTTagCompound data = new NBTTagCompound(); + data.setBoolean("whitelist", true); + PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, grabber.xCoord, grabber.yCoord, grabber.zCoord)); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + String name = this.grabber.hasCustomInventoryName() ? this.grabber.getInventoryName() : I18n.format(this.grabber.getInventoryName()); + 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); + } + + @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); + + if(grabber.isWhitelist) { + drawTexturedModalRect(guiLeft + 108, guiTop + 33, 176, 0, 3, 6); + } else { + drawTexturedModalRect(guiLeft + 108, guiTop + 47, 176, 0, 3, 6); + } + } +} diff --git a/src/main/java/com/hbm/main/CraftingManager.java b/src/main/java/com/hbm/main/CraftingManager.java index b01dd9c46..f0b062205 100644 --- a/src/main/java/com/hbm/main/CraftingManager.java +++ b/src/main/java/com/hbm/main/CraftingManager.java @@ -935,11 +935,13 @@ public class CraftingManager { int amount = (int) craneCasing[i * 2 + 1]; addRecipeAuto(new ItemStack(ModBlocks.crane_inserter, amount), new Object[] { "CCC", "C C", "CBC", 'C', casing, 'B', ModBlocks.conveyor }); addRecipeAuto(new ItemStack(ModBlocks.crane_extractor, amount), new Object[] { "CCC", "CPC", "CBC", 'C', casing, 'B', ModBlocks.conveyor, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC) }); + addRecipeAuto(new ItemStack(ModBlocks.crane_grabber, amount), new Object[] { "C C", "P P", "CBC", 'C', casing, 'B', ModBlocks.conveyor, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC) }); } addRecipeAuto(new ItemStack(ModBlocks.crane_boxer), new Object[] { "WWW", "WPW", "CCC", 'W', KEY_PLANKS, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'C', ModBlocks.conveyor }); addRecipeAuto(new ItemStack(ModBlocks.crane_unboxer), new Object[] { "WWW", "WPW", "CCC", 'W', KEY_STICK, 'P', Items.shears, 'C', ModBlocks.conveyor }); addRecipeAuto(new ItemStack(ModBlocks.crane_router), new Object[] { "PIP", "ICI", "PIP", 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'I', ModItems.plate_polymer, 'C', ModItems.circuit_copper }); + addRecipeAuto(new ItemStack(ModBlocks.crane_splitter), new Object[] { "III", "PCP", "III", 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'I', STEEL.ingot(), 'C', ModItems.circuit_aluminium }); addShapelessAuto(DictFrame.fromOne(ModItems.parts_legendary, EnumLegendaryType.TIER1), new Object[] { ModItems.ingot_chainsteel, ASBESTOS.ingot(), ModItems.gem_alexandrite }); addShapelessAuto(DictFrame.fromOne(ModItems.parts_legendary, EnumLegendaryType.TIER1, 3), new Object[] { DictFrame.fromOne(ModItems.parts_legendary, EnumLegendaryType.TIER2) }); diff --git a/src/main/java/com/hbm/render/block/RenderSplitter.java b/src/main/java/com/hbm/render/block/RenderSplitter.java index 3b85f3e18..0d2f1b91a 100644 --- a/src/main/java/com/hbm/render/block/RenderSplitter.java +++ b/src/main/java/com/hbm/render/block/RenderSplitter.java @@ -2,7 +2,6 @@ package com.hbm.render.block; import org.lwjgl.opengl.GL11; -import com.hbm.blocks.ModBlocks; import com.hbm.blocks.network.CraneSplitter; import com.hbm.main.ResourceManager; import com.hbm.render.util.ObjUtil; @@ -11,7 +10,6 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.client.model.obj.WavefrontObject; @@ -28,11 +26,11 @@ public class RenderSplitter implements ISimpleBlockRenderingHandler { GL11.glRotated(-90, 0, 1, 0); GL11.glTranslatef(0F, -0.5F, 0.5F); tessellator.startDrawingQuads(); - ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.splitter, ModBlocks.block_steel.getIcon(0, 0), tessellator, 0, false); + drawSplitter(tessellator, block, true, 0, false); tessellator.draw(); GL11.glTranslatef(0F, 0F, -1F); tessellator.startDrawingQuads(); - ObjUtil.renderWithIcon((WavefrontObject) ResourceManager.splitter, ModBlocks.block_steel.getIcon(0, 0), tessellator, 0, false); + drawSplitter(tessellator, block, false, 0, false); tessellator.draw(); GL11.glPopMatrix(); @@ -54,26 +52,26 @@ public class RenderSplitter implements ISimpleBlockRenderingHandler { if(meta == 14 || meta == 3) rotation = 180F / 180F * (float)Math.PI; boolean isLeft = meta >= 12; - - CraneSplitter splitter = (CraneSplitter) block; - IIcon conveyor = splitter.iconBelt; - - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Top", ModBlocks.block_steel.getIcon(0, 0), tessellator, rotation, true); - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Bottom", ModBlocks.block_steel.getIcon(0, 0), tessellator, rotation, true); - if(isLeft) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Left", ModBlocks.block_steel.getIcon(0, 0), tessellator, rotation, true); - if(!isLeft) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Right", ModBlocks.block_steel.getIcon(0, 0), tessellator, rotation, true); - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Back", ModBlocks.block_steel.getIcon(0, 0), tessellator, rotation, true); - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Front", ModBlocks.block_steel.getIcon(0, 0), tessellator, rotation, true); - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Inner", ModBlocks.block_steel.getIcon(0, 0), tessellator, rotation, true); - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "InnerLeft", ModBlocks.block_steel.getIcon(0, 0), tessellator, rotation, true); - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "InnerRight", ModBlocks.block_steel.getIcon(0, 0), tessellator, rotation, true); - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "InnerTop", ModBlocks.block_steel.getIcon(0, 0), tessellator, rotation, true); - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "InnerBottom", conveyor, tessellator, rotation, true); - + drawSplitter(tessellator, block, isLeft, rotation, true); tessellator.addTranslation(-x - 0.5F, -y, -z - 0.5F); return true; } + + private static void drawSplitter(Tessellator tessellator, Block block, boolean isLeft, float rotation, boolean shadeNormals) { + CraneSplitter splitter = (CraneSplitter) block; + ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Top", isLeft ? splitter.iconTopLeft : splitter.iconTopRight, tessellator, rotation, shadeNormals); + ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Bottom", isLeft ? splitter.iconFrontRight : splitter.iconFrontLeft , tessellator, rotation, shadeNormals); + if(isLeft) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Left", splitter.iconLeft, tessellator, rotation, shadeNormals); + if(!isLeft) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Right", splitter.iconRight, tessellator, rotation, shadeNormals); + ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Back", isLeft ? splitter.iconBackLeft : splitter.iconBackRight, tessellator, rotation, shadeNormals); + ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Front", isLeft ? splitter.iconFrontLeft : splitter.iconFrontRight, tessellator, rotation, shadeNormals); + ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "Inner", splitter.iconInner, tessellator, rotation, shadeNormals); + ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "InnerLeft", splitter.iconInner, tessellator, rotation, shadeNormals); + ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "InnerRight", splitter.iconInner, tessellator, rotation, shadeNormals); + ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "InnerTop", splitter.iconInner, tessellator, rotation, shadeNormals); + ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.splitter, "InnerBottom", splitter.iconBelt, tessellator, rotation, shadeNormals); + } @Override public boolean shouldRender3DInInventory(int modelId) { diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index b4e7437c3..6692e9749 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -347,6 +347,7 @@ public class TileMappings { put(TileEntityCraneInserter.class, "tileentity_inserter"); put(TileEntityCraneExtractor.class, "tileentity_extractor"); + put(TileEntityCraneGrabber.class, "tileentity_grabber"); put(TileEntityCraneBoxer.class, "tileentity_boxer"); put(TileEntityCraneUnboxer.class, "tileentity_unboxer"); put(TileEntityCraneRouter.class, "tileentity_router"); diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java b/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java new file mode 100644 index 000000000..84331f475 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/network/TileEntityCraneGrabber.java @@ -0,0 +1,174 @@ +package com.hbm.tileentity.network; + +import java.util.List; + +import com.hbm.blocks.network.CraneInserter; +import com.hbm.entity.item.EntityMovingItem; +import com.hbm.interfaces.IControlReceiver; +import com.hbm.inventory.container.ContainerCraneGrabber; +import com.hbm.inventory.gui.GUICraneGrabber; +import com.hbm.items.ModItems; +import com.hbm.module.ModulePatternMatcher; +import com.hbm.tileentity.IGUIProvider; +import com.hbm.tileentity.TileEntityMachineBase; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityCraneGrabber extends TileEntityMachineBase implements IGUIProvider, IControlReceiver { + + public boolean isWhitelist = false; + public ModulePatternMatcher matcher; + + public TileEntityCraneGrabber() { + super(11); + this.matcher = new ModulePatternMatcher(9); + } + + public void nextMode(int i) { + this.matcher.nextMode(worldObj, slots[i], i); + } + + @Override + public String getName() { + return "container.craneGrabber"; + } + + @Override + public void updateEntity() { + + if(!worldObj.isRemote) { + + int delay = 20; + + if(slots[10] != null && slots[10].getItem() == ModItems.upgrade_ejector) { + switch(slots[10].getItemDamage()) { + case 0: delay = 10; break; + case 1: delay = 5; break; + case 2: delay = 2; break; + } + } + + if(worldObj.getTotalWorldTime() % delay == 0 && !this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) { + int amount = 1; + + if(slots[9] != null && slots[9].getItem() == ModItems.upgrade_stack) { + switch(slots[9].getItemDamage()) { + case 0: amount = 4; break; + case 1: amount = 16; break; + case 2: amount = 64; break; + } + } + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); + TileEntity te = worldObj.getTileEntity(xCoord - dir.offsetX, yCoord - dir.offsetY, zCoord - dir.offsetZ); + + int[] access = null; + ISidedInventory sided = null; + + if(te instanceof ISidedInventory) { + sided = (ISidedInventory) te; + access = CraneInserter.masquerade(sided, dir.ordinal()); + } + + List items = worldObj.getEntitiesWithinAABB(EntityMovingItem.class, AxisAlignedBB.getBoundingBox(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, xCoord + dir.offsetX + 1, yCoord + dir.offsetY + 1, zCoord + dir.offsetZ + 1)); + + for(EntityMovingItem item : items) { + ItemStack stack = item.getItemStack(); + boolean match = this.matchesFilter(stack); + if(this.isWhitelist && !match || !this.isWhitelist && match) continue; + + ItemStack copy = stack.copy(); + int toAdd = Math.min(stack.stackSize, amount); + copy.stackSize = toAdd; + ItemStack ret = CraneInserter.addToInventory((IInventory) te, access, copy.copy(), dir.ordinal()); + int didAdd = toAdd - (ret != null ? ret.stackSize : 0); + stack.stackSize -= didAdd; + + if(stack.stackSize <= 0) { + item.setDead(); + } + + amount -= didAdd; + if(amount <= 0) { + break; + } + } + } + + + NBTTagCompound data = new NBTTagCompound(); + data.setBoolean("isWhitelist", isWhitelist); + this.matcher.writeToNBT(data); + this.networkPack(data, 15); + } + } + + public void networkUnpack(NBTTagCompound nbt) { + this.isWhitelist = nbt.getBoolean("isWhitelist"); + this.matcher.modes = new String[this.matcher.modes.length]; + this.matcher.readFromNBT(nbt); + } + + public boolean matchesFilter(ItemStack stack) { + + for(int i = 0; i < 9; i++) { + ItemStack filter = slots[i]; + + if(filter != null && this.matcher.isValidForFilter(filter, i, stack)) { + return true; + } + } + + return false; + } + + @Override + public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { + return new ContainerCraneGrabber(player.inventory, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { + return new GUICraneGrabber(player.inventory, this); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.isWhitelist = nbt.getBoolean("isWhitelist"); + this.matcher.readFromNBT(nbt); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setBoolean("isWhitelist", this.isWhitelist); + this.matcher.writeToNBT(nbt); + } + + @Override + public boolean hasPermission(EntityPlayer player) { + return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 20; + } + + @Override + public void receiveControl(NBTTagCompound data) { + if(data.hasKey("whitelist")) { + this.isWhitelist = !this.isWhitelist; + } + } +} diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index bc6b2877e..ff143a96f 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -281,6 +281,7 @@ container.chemplant=Chemiewerk container.compactLauncher=Kompakt-Startrampe container.craneBoxer=Förderband-Verpacker container.craneExtractor=Förderband-Auswerfer +container.craneGrabber=Förderband-Greifer container.craneInserter=Förderband-Einsetzer container.craneRouter=Förderband-Sortierer container.craneUnboxer=Förderband-Entpacker @@ -3577,10 +3578,12 @@ tile.conveyor.name=Förderband tile.conveyor_chute.name=Förderschütte tile.conveyor_double.name=Zweispuriges Förderband tile.conveyor_lift.name=Kettenaufzug +tile.conveyor_splitter.name=Förderband-Teiler tile.conveyor_triple.name=Dreispuriges Förderband tile.corium_block.name=Corium tile.crane_boxer.name=Förderband-Verpacker tile.crane_extractor.name=Förderband-Auswerfer +tile.crane_grabber.name=Förderband-Greifer tile.crane_inserter.name=Förderband-Einsetzer tile.crane_router.name=Förderband-Sortierer tile.crane_unboxer.name=Förderband-Entpacker diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 47acb3efb..5cf9d45ce 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -572,6 +572,7 @@ container.chemplant=Chemical Plant container.compactLauncher=Compact Launch Pad container.craneBoxer=Conveyor Boxer container.craneExtractor=Conveyor Ejector +container.craneGrabber=Conveyor Grabber container.craneInserter=Conveyor Inserter container.craneRouter=Conveyor Router container.craneUnboxer=Conveyor Unboxer @@ -4386,10 +4387,12 @@ tile.conveyor.name=Conveyor Belt tile.conveyor_chute.name=Conveyor Chute tile.conveyor_double.name=Double-Lane Conveyor Belt tile.conveyor_lift.name=Conveyor Chain Lift +tile.conveyor_splitter.name=Conveyor Splitter tile.conveyor_triple.name=Triple-Lane Conveyor Belt tile.corium_block.name=Corium tile.crane_boxer.name=Conveyor Boxer tile.crane_extractor.name=Conveyor Ejector +tile.crane_grabber.name=Conveyor Grabber tile.crane_inserter.name=Conveyor Inserter tile.crane_router.name=Conveyor Sorter tile.crane_unboxer.name=Conveyor Unboxer diff --git a/src/main/resources/assets/hbm/textures/blocks/coolant_duct.png b/src/main/resources/assets/hbm/textures/blocks/coolant_duct.png deleted file mode 100644 index d7ba4a2de..000000000 Binary files a/src/main/resources/assets/hbm/textures/blocks/coolant_duct.png and /dev/null differ diff --git a/src/main/resources/assets/hbm/textures/blocks/coolant_duct_icon.png b/src/main/resources/assets/hbm/textures/blocks/coolant_duct_icon.png deleted file mode 100644 index bbade3f2b..000000000 Binary files a/src/main/resources/assets/hbm/textures/blocks/coolant_duct_icon.png and /dev/null differ diff --git a/src/main/resources/assets/hbm/textures/blocks/coolant_duct_solid.png b/src/main/resources/assets/hbm/textures/blocks/coolant_duct_solid.png deleted file mode 100644 index a08eca758..000000000 Binary files a/src/main/resources/assets/hbm/textures/blocks/coolant_duct_solid.png and /dev/null differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_grabber_side_down.png b/src/main/resources/assets/hbm/textures/blocks/crane_grabber_side_down.png new file mode 100644 index 000000000..6266209fd Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_grabber_side_down.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_grabber_side_up.png b/src/main/resources/assets/hbm/textures/blocks/crane_grabber_side_up.png new file mode 100644 index 000000000..7b615b1cb Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_grabber_side_up.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_grabber_top.png b/src/main/resources/assets/hbm/textures/blocks/crane_grabber_top.png new file mode 100644 index 000000000..5d66fffd1 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_grabber_top.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_pull.png b/src/main/resources/assets/hbm/textures/blocks/crane_pull.png new file mode 100644 index 000000000..a99dd262e Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_pull.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_side_pull.png b/src/main/resources/assets/hbm/textures/blocks/crane_side_pull.png new file mode 100644 index 000000000..ff732c720 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_side_pull.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_splitter_back_left.png b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_back_left.png new file mode 100644 index 000000000..800df3c44 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_back_left.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_splitter_back_right.png b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_back_right.png new file mode 100644 index 000000000..919ca6bf0 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_back_right.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_splitter_front_left.png b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_front_left.png new file mode 100644 index 000000000..724fa7a62 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_front_left.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_splitter_front_right.png b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_front_right.png new file mode 100644 index 000000000..b2701442e Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_front_right.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_splitter_inner.png b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_inner.png new file mode 100644 index 000000000..95506ddf8 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_inner.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_splitter_left.png b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_left.png new file mode 100644 index 000000000..aab446258 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_left.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_splitter_right.png b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_right.png new file mode 100644 index 000000000..8c4dabdd8 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_right.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_splitter_top_left.png b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_top_left.png new file mode 100644 index 000000000..5d477e495 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_top_left.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/crane_splitter_top_right.png b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_top_right.png new file mode 100644 index 000000000..cadc1bb9a Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/crane_splitter_top_right.png differ diff --git a/src/main/resources/assets/hbm/textures/gui/storage/gui_crane_grabber.png b/src/main/resources/assets/hbm/textures/gui/storage/gui_crane_grabber.png new file mode 100644 index 000000000..fda167041 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/storage/gui_crane_grabber.png differ