diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 3a6e79685..948fd7ec2 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -587,6 +587,7 @@ public class ModBlocks { public static Block crate_desh; public static Block crate_tungsten; public static Block safe; + public static Block mass_storage; public static Block nuke_gadget; public static final int guiID_nuke_gadget = 3; @@ -2107,8 +2108,9 @@ public class ModBlocks { crate_iron = new BlockStorageCrate(Material.iron).setBlockName("crate_iron").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); crate_steel = new BlockStorageCrate(Material.iron).setBlockName("crate_steel").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); crate_desh = new BlockStorageCrate(Material.iron).setBlockName("crate_desh").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); - crate_tungsten = new BlockStorageCrate(Material.iron).setBlockName("crate_tungsten").setStepSound(Block.soundTypeMetal).setHardness(7.5F).setResistance(60.0F).setCreativeTab(MainRegistry.machineTab); + crate_tungsten = new BlockStorageCrate(Material.iron).setBlockName("crate_tungsten").setStepSound(Block.soundTypeMetal).setHardness(7.5F).setResistance(300.0F).setCreativeTab(MainRegistry.machineTab); safe = new BlockStorageCrate(Material.iron).setBlockName("safe").setStepSound(Block.soundTypeMetal).setHardness(7.5F).setResistance(10000.0F).setCreativeTab(MainRegistry.machineTab); + mass_storage = new BlockMassStorage().setBlockName("mass_storage").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); boxcar = new DecoBlock(Material.iron).setBlockName("boxcar").setStepSound(Block.soundTypeMetal).setHardness(10.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":boxcar"); boat = new DecoBlock(Material.iron).setBlockName("boat").setStepSound(Block.soundTypeMetal).setHardness(10.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":boat"); @@ -2904,6 +2906,7 @@ public class ModBlocks { GameRegistry.registerBlock(crate_desh, crate_desh.getUnlocalizedName()); GameRegistry.registerBlock(crate_tungsten, crate_tungsten.getUnlocalizedName()); GameRegistry.registerBlock(safe, safe.getUnlocalizedName()); + GameRegistry.registerBlock(mass_storage, mass_storage.getUnlocalizedName()); //Junk GameRegistry.registerBlock(boxcar, boxcar.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/blocks/generic/BlockStorageCrate.java b/src/main/java/com/hbm/blocks/generic/BlockStorageCrate.java index b313837c7..306698713 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockStorageCrate.java +++ b/src/main/java/com/hbm/blocks/generic/BlockStorageCrate.java @@ -66,6 +66,10 @@ public class BlockStorageCrate extends BlockContainer { this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":safe_front"); this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":safe_side"); } + if(this == ModBlocks.mass_storage) { + this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top"); + this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side"); + } } @Override diff --git a/src/main/java/com/hbm/blocks/machine/BlockMassStorage.java b/src/main/java/com/hbm/blocks/machine/BlockMassStorage.java new file mode 100644 index 000000000..6e26763b8 --- /dev/null +++ b/src/main/java/com/hbm/blocks/machine/BlockMassStorage.java @@ -0,0 +1,69 @@ +package com.hbm.blocks.machine; + +import com.hbm.blocks.ModBlocks; +import com.hbm.items.ModItems; +import com.hbm.items.tool.ItemLock; +import com.hbm.lib.RefStrings; +import com.hbm.main.MainRegistry; +import com.hbm.tileentity.machine.storage.TileEntityMassStorage; + +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockMassStorage extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon iconTop; + + public BlockMassStorage() { + super(Material.iron); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top"); + this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metadata) { + + if(this == ModBlocks.safe) + return metadata == 0 && side == 3 ? this.iconTop : (side == metadata ? this.iconTop : this.blockIcon); + + return side == 1 ? this.iconTop : (side == 0 ? this.iconTop : this.blockIcon); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityMassStorage(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + if(world.isRemote) { + return true; + } else if(player.getHeldItem() != null && (player.getHeldItem().getItem() instanceof ItemLock || player.getHeldItem().getItem() == ModItems.key_kit)) { + return false; + + } else if(!player.isSneaking()) { + TileEntity entity = world.getTileEntity(x, y, z); + if(entity instanceof TileEntityMassStorage && ((TileEntityMassStorage) entity).canAccess(player)) { + FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); + } + return true; + } else { + return false; + } + } +} diff --git a/src/main/java/com/hbm/entity/cart/EntityMinecartDestroyer.java b/src/main/java/com/hbm/entity/cart/EntityMinecartDestroyer.java index 49b43e6ff..7c3aa7d1c 100644 --- a/src/main/java/com/hbm/entity/cart/EntityMinecartDestroyer.java +++ b/src/main/java/com/hbm/entity/cart/EntityMinecartDestroyer.java @@ -20,13 +20,12 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; import net.minecraft.world.World; public class EntityMinecartDestroyer extends EntityMinecartContainerBase { - public EntityMinecartDestroyer(World p_i1712_1_) { - super(p_i1712_1_); + public EntityMinecartDestroyer(World world) { + super(world); } public EntityMinecartDestroyer(World world, double x, double y, double z, EnumCartBase type) { diff --git a/src/main/java/com/hbm/handler/GUIHandler.java b/src/main/java/com/hbm/handler/GUIHandler.java index ede516501..af9f7ba34 100644 --- a/src/main/java/com/hbm/handler/GUIHandler.java +++ b/src/main/java/com/hbm/handler/GUIHandler.java @@ -33,7 +33,7 @@ public class GUIHandler implements IGuiHandler { if(entity instanceof TileEntityCrateSteel) { return new ContainerCrateSteel(player.inventory, (TileEntityCrateSteel) entity); } if(entity instanceof TileEntityCrateDesh) { return new ContainerCrateDesh(player.inventory, (TileEntityCrateDesh) entity); } if(entity instanceof TileEntityCrateTungsten) { return new ContainerCrateTungsten(player.inventory, (TileEntityCrateTungsten) entity); } - if(entity instanceof TileEntitySafe) { return new ContainerSafe(player.inventory, (TileEntitySafe) entity); } + if(entity instanceof TileEntityMassStorage) { return new ContainerMassStorage(player.inventory, (TileEntityMassStorage) entity); } if(entity instanceof TileEntityMachineLiquefactor) { return new ContainerLiquefactor(player.inventory, (TileEntityMachineLiquefactor) entity); } if(entity instanceof TileEntityMachineSolidifier) { return new ContainerSolidifier(player.inventory, (TileEntityMachineSolidifier) entity); } @@ -857,6 +857,7 @@ public class GUIHandler implements IGuiHandler { if(entity instanceof TileEntityCrateDesh) { return new GUICrateDesh(player.inventory, (TileEntityCrateDesh) entity); } if(entity instanceof TileEntityCrateTungsten) { return new GUICrateTungsten(player.inventory, (TileEntityCrateTungsten) entity); } if(entity instanceof TileEntitySafe) { return new GUISafe(player.inventory, (TileEntitySafe) entity); } + if(entity instanceof TileEntityMassStorage) { return new GUIMassStorage(player.inventory, (TileEntityMassStorage) entity); } if(entity instanceof TileEntityMachineLiquefactor) { return new GUILiquefactor(player.inventory, (TileEntityMachineLiquefactor) entity); } if(entity instanceof TileEntityMachineSolidifier) { return new GUISolidifier(player.inventory, (TileEntityMachineSolidifier) entity); } diff --git a/src/main/java/com/hbm/inventory/container/ContainerMassStorage.java b/src/main/java/com/hbm/inventory/container/ContainerMassStorage.java new file mode 100644 index 000000000..820008c64 --- /dev/null +++ b/src/main/java/com/hbm/inventory/container/ContainerMassStorage.java @@ -0,0 +1,105 @@ +package com.hbm.inventory.container; + +import com.hbm.inventory.SlotMachineOutput; +import com.hbm.inventory.SlotPattern; +import com.hbm.tileentity.machine.storage.TileEntityMassStorage; + +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 ContainerMassStorage extends Container { + + private TileEntityMassStorage storage; + + public ContainerMassStorage(InventoryPlayer invPlayer, TileEntityMassStorage te) { + this.storage = te; + + this.addSlotToContainer(new Slot(storage, 0, 61, 17)); + this.addSlotToContainer(new SlotPattern(storage, 1, 61, 53)); + this.addSlotToContainer(new SlotMachineOutput(storage, 2, 61, 89)); + + 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, 139 + i * 18)); + } + } + + for(int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 197)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, 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 == 0 || par2 == 2) { + if(!this.mergeItemStack(var5, storage.getSizeInventory(), this.inventorySlots.size(), true)) { + return null; + } + } else if(!this.mergeItemStack(var5, 0, 1, false)) { + return null; + } + + if(var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + var4.onPickupFromSlot(player, var5); + } + + return var3; + } + + @Override + public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) { + + //L/R: 0 + //M3: 3 + //SHIFT: 1 + //DRAG: 5 + //System.out.println("Mode " + mode); + //System.out.println("Slot " + index); + + if(index != 1) { + 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(); + + //Don't allow for a type change when the thing isn't empty + if(storage.getStockpile() > 0) + return ret; + + slot.putStack(held != null ? held.copy() : null); + + if(slot.getHasStack()) { + slot.getStack().stackSize = 1; + } + + slot.onSlotChanged(); + + return ret; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return storage.isUseableByPlayer(player); + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUICrateDesh.java b/src/main/java/com/hbm/inventory/gui/GUICrateDesh.java index 61cb62526..d75a8ee62 100644 --- a/src/main/java/com/hbm/inventory/gui/GUICrateDesh.java +++ b/src/main/java/com/hbm/inventory/gui/GUICrateDesh.java @@ -30,7 +30,7 @@ public class GUICrateDesh extends GuiContainer { String name = this.crate.hasCustomInventoryName() ? this.crate.getInventoryName() : I18n.format(this.crate.getInventoryName()); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); - this.fontRendererObj.drawString(I18n.format("container.inventory"), 40, this.ySize - 96 + 3, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 44, this.ySize - 96 + 3, 4210752); } @Override diff --git a/src/main/java/com/hbm/inventory/gui/GUIMassStorage.java b/src/main/java/com/hbm/inventory/gui/GUIMassStorage.java new file mode 100644 index 000000000..b2e7255f0 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIMassStorage.java @@ -0,0 +1,84 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.container.ContainerMassStorage; +import com.hbm.lib.RefStrings; +import com.hbm.packet.NBTControlPacket; +import com.hbm.packet.PacketDispatcher; +import com.hbm.tileentity.machine.storage.TileEntityMassStorage; + +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.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; + +public class GUIMassStorage extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_mass_storage.png"); + private TileEntityMassStorage storage; + + public GUIMassStorage(InventoryPlayer invPlayer, TileEntityMassStorage tile) { + super(new ContainerMassStorage(invPlayer, tile)); + storage = tile; + + this.xSize = 176; + this.ySize = 221; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + super.drawScreen(mouseX, mouseY, f); + + String percent = (((int) (storage.getStockpile() * 1000D / (double) storage.getCapacity())) / 10D) + "%"; + this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 96, guiTop + 16, 18, 90, mouseX, mouseY, new String[] { storage.getStockpile() + " / " + storage.getCapacity(), percent }); + + this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 62, guiTop + 72, 14, 14, mouseX, mouseY, new String[] { "Click: Provide one", "Shift-click: Provide stack" }); + this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 80, guiTop + 72, 14, 14, mouseX, mouseY, new String[] { "Toggle output" }); + } + + @Override + protected void mouseClicked(int x, int y, int i) { + super.mouseClicked(x, y, i); + + if(guiLeft + 62 <= x && guiLeft + 62 + 14 > x && guiTop + 72 < y && guiTop + 72 + 14 >= y) { + + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + NBTTagCompound data = new NBTTagCompound(); + data.setBoolean("provide", Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)); + PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, storage.xCoord, storage.yCoord, storage.zCoord)); + } + + if(guiLeft + 80 <= x && guiLeft + 80 + 14 > x && guiTop + 72 < y && guiTop + 72 + 14 >= y) { + + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + NBTTagCompound data = new NBTTagCompound(); + data.setBoolean("toggle", false); + PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, storage.xCoord, storage.yCoord, storage.zCoord)); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + String name = this.storage.hasCustomInventoryName() ? this.storage.getInventoryName() : I18n.format(this.storage.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); + + int gauge = storage.getStockpile() * 88 / storage.getCapacity(); + drawTexturedModalRect(guiLeft + 97, guiTop + 105 - gauge, 176, 88 - gauge, 16, gauge); + + if(storage.output) + drawTexturedModalRect(guiLeft + 80, guiTop + 72, 192, 0, 14, 14); + } +} diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 3ada8dd13..b3150ec36 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -1631,16 +1631,19 @@ public class ClientProxy extends ServerProxy { int gW = (int)(width / 0.25F); int gH = (int)(height / 0.25F); + int count = (int) (gW * 1.5 * gH); + + if(data.hasKey("cDiv")) + count = (int) Math.ceil(count / (double)data.getInteger("cDiv")); + boolean blowMeIntoTheGodDamnStratosphere = rand.nextInt(15) == 0; double mult = 1D; if(blowMeIntoTheGodDamnStratosphere) mult *= 10; - for(int i = -(gW / 2); i <= gW; i++) { - for(int j = 0; j <= gH; j++) { - Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleGiblet(man, world, x, y, z, rand.nextGaussian() * 0.25 * mult, rand.nextDouble() * mult, rand.nextGaussian() * 0.25 * mult)); - } + for(int i = 0; i < count; i++) { + Minecraft.getMinecraft().effectRenderer.addEffect(new ParticleGiblet(man, world, x, y, z, rand.nextGaussian() * 0.25 * mult, rand.nextDouble() * mult, rand.nextGaussian() * 0.25 * mult)); } } diff --git a/src/main/java/com/hbm/main/CraftingManager.java b/src/main/java/com/hbm/main/CraftingManager.java index 69f4a68b8..f16fc2630 100644 --- a/src/main/java/com/hbm/main/CraftingManager.java +++ b/src/main/java/com/hbm/main/CraftingManager.java @@ -266,6 +266,7 @@ public class CraftingManager { addRecipeAuto(new ItemStack(ModBlocks.machine_converter_rf_he, 1), new Object[] { "SSS", "BRC", "SSS", 'S', BE.ingot(), 'C', ModItems.coil_copper, 'R', ModItems.coil_copper_torus, 'B', REDSTONE.block() }); addRecipeAuto(new ItemStack(ModBlocks.crate_iron, 1), new Object[] { "PPP", "I I", "III", 'P', IRON.plate(), 'I', IRON.ingot() }); addRecipeAuto(new ItemStack(ModBlocks.crate_steel, 1), new Object[] { "PPP", "I I", "III", 'P', STEEL.plate(), 'I', STEEL.ingot() }); + addRecipeAuto(new ItemStack(ModBlocks.crate_desh, 1), new Object[] { " D ", "DSD", " D ", 'D', ModItems.plate_desh, 'S', ModBlocks.crate_steel }); addRecipeAuto(new ItemStack(ModBlocks.crate_tungsten, 1), new Object[] { "BPB", "PCP", "BPB", 'B', W.block(), 'P', ModItems.board_copper, 'C', ModBlocks.crate_steel }); addRecipeAuto(new ItemStack(ModBlocks.safe, 1), new Object[] { "LAL", "ACA", "LAL", 'L', PB.plate(), 'A', ALLOY.plate(), 'C', ModBlocks.crate_steel }); addRecipeAuto(new ItemStack(ModBlocks.machine_waste_drum, 1), new Object[] { "LRL", "BRB", "LRL", 'L', PB.ingot(), 'B', Blocks.iron_bars, 'R', ModItems.rod_quad_empty }); diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index 91855540a..6a539da64 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -8,9 +8,7 @@ import com.hbm.blocks.generic.BlockLoot.TileEntityLoot; import com.hbm.blocks.generic.BlockMotherOfAllOres.TileEntityRandomOre; import com.hbm.blocks.network.CableDiode.TileEntityDiode; import com.hbm.interfaces.IFluidAcceptor; -import com.hbm.interfaces.IFluidContainer; import com.hbm.interfaces.IFluidSource; -import com.hbm.main.MainRegistry; import com.hbm.tileentity.bomb.*; import com.hbm.tileentity.conductor.*; import com.hbm.tileentity.deco.*; @@ -96,6 +94,8 @@ public class TileMappings { put(TileEntityMachineTurbofan.class, "tileentity_machine_turbofan"); put(TileEntityCrateIron.class, "tileentity_crate_iron"); put(TileEntityCrateSteel.class, "tileentity_crate_steel"); + put(TileEntityCrateDesh.class, "tileentity_crate_desh"); + put(TileEntityMassStorage.class, "tileentity_mass_storage"); put(TileEntityMachinePress.class, "tileentity_press"); put(TileEntityAMSBase.class, "tileentity_ams_base"); put(TileEntityAMSEmitter.class, "tileentity_ams_emitter"); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssembler.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssembler.java index ba77308a0..ced4e8098 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssembler.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssembler.java @@ -6,6 +6,7 @@ import java.util.Random; import com.hbm.blocks.ModBlocks; import com.hbm.inventory.RecipesCommon.AStack; +import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.recipes.AssemblerRecipes; import com.hbm.inventory.UpgradeManager; import com.hbm.items.ModItems; @@ -208,12 +209,18 @@ public class TileEntityMachineAssembler extends TileEntityMachineBase implements break; } + int rec = -1; + if(AssemblerRecipes.getOutputFromTempate(slots[4]) != null) { + ComparableStack comp = ItemAssemblyTemplate.readType(slots[4]); + rec = AssemblerRecipes.recipeList.indexOf(comp); + } + NBTTagCompound data = new NBTTagCompound(); data.setLong("power", power); data.setInteger("progress", progress); data.setInteger("maxProgress", maxProgress); data.setBoolean("isProgressing", isProgressing); - data.setInteger("recipe", slots[4] != null ? AssemblerRecipes.recipeList.indexOf(AssemblerRecipes.getOutputFromTempate(slots[4])) : -1); + data.setInteger("recipe", rec); this.networkPack(data, 150); } else { diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbofan.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbofan.java index feadfe218..a7751b620 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbofan.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbofan.java @@ -14,6 +14,7 @@ import com.hbm.inventory.fluid.Fluids; import com.hbm.items.ModItems; import com.hbm.lib.ModDamageSource; import com.hbm.packet.AuxElectricityPacket; +import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.LoopedSoundPacket; import com.hbm.packet.PacketDispatcher; import com.hbm.packet.TETurbofanPacket; @@ -24,6 +25,7 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -322,6 +324,16 @@ public class TileEntityMachineTurbofan extends TileEntityLoadedBase implements I for(Entity e : list) { e.attackEntityFrom(ModDamageSource.turbofan, 1000); + + if(!e.isEntityAlive() && e instanceof EntityLivingBase) { + NBTTagCompound vdat = new NBTTagCompound(); + vdat.setString("type", "giblets"); + vdat.setInteger("ent", e.getEntityId()); + vdat.setInteger("cDiv", 5); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(vdat, e.posX, e.posY + e.height * 0.5, e.posZ), new TargetPoint(e.dimension, e.posX, e.posY + e.height * 0.5, e.posZ, 150)); + + worldObj.playSoundEffect(e.posX, e.posY, e.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F); + } } } if(meta == 3) { @@ -374,6 +386,16 @@ public class TileEntityMachineTurbofan extends TileEntityLoadedBase implements I for(Entity e : list) { e.attackEntityFrom(ModDamageSource.turbofan, 1000); + + if(!e.isEntityAlive() && e instanceof EntityLivingBase) { + NBTTagCompound vdat = new NBTTagCompound(); + vdat.setString("type", "giblets"); + vdat.setInteger("ent", e.getEntityId()); + vdat.setInteger("cDiv", 5); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(vdat, e.posX, e.posY + e.height * 0.5, e.posZ), new TargetPoint(e.dimension, e.posX, e.posY + e.height * 0.5, e.posZ, 150)); + + worldObj.playSoundEffect(e.posX, e.posY, e.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F); + } } } if(meta == 4) { @@ -426,6 +448,16 @@ public class TileEntityMachineTurbofan extends TileEntityLoadedBase implements I for(Entity e : list) { e.attackEntityFrom(ModDamageSource.turbofan, 1000); + + if(!e.isEntityAlive() && e instanceof EntityLivingBase) { + NBTTagCompound vdat = new NBTTagCompound(); + vdat.setString("type", "giblets"); + vdat.setInteger("ent", e.getEntityId()); + vdat.setInteger("cDiv", 5); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(vdat, e.posX, e.posY + e.height * 0.5, e.posZ), new TargetPoint(e.dimension, e.posX, e.posY + e.height * 0.5, e.posZ, 150)); + + worldObj.playSoundEffect(e.posX, e.posY, e.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F); + } } } if(meta == 5) { @@ -478,6 +510,16 @@ public class TileEntityMachineTurbofan extends TileEntityLoadedBase implements I for(Entity e : list) { e.attackEntityFrom(ModDamageSource.turbofan, 1000); + + if(!e.isEntityAlive() && e instanceof EntityLivingBase) { + NBTTagCompound vdat = new NBTTagCompound(); + vdat.setString("type", "giblets"); + vdat.setInteger("ent", e.getEntityId()); + vdat.setInteger("cDiv", 5); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(vdat, e.posX, e.posY + e.height * 0.5, e.posZ), new TargetPoint(e.dimension, e.posX, e.posY + e.height * 0.5, e.posZ, 150)); + + worldObj.playSoundEffect(e.posX, e.posY, e.posZ, "mob.zombie.woodbreak", 2.0F, 0.95F + worldObj.rand.nextFloat() * 0.2F); + } } } } diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityCrateBase.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityCrateBase.java index 14568a358..1f477ecee 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityCrateBase.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityCrateBase.java @@ -13,10 +13,6 @@ public abstract class TileEntityCrateBase extends TileEntityLockableBase impleme protected ItemStack slots[]; public String customName; - public TileEntityCrateBase() { - slots = new ItemStack[0]; - } - public TileEntityCrateBase(int count) { slots = new ItemStack[count]; } diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFluidTank.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFluidTank.java index ab683fc23..a59f7cbab 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFluidTank.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineFluidTank.java @@ -3,7 +3,6 @@ package com.hbm.tileentity.machine.storage; import java.util.ArrayList; import java.util.List; -import com.hbm.blocks.ModBlocks; import com.hbm.interfaces.IFluidAcceptor; import com.hbm.interfaces.IFluidContainer; import com.hbm.interfaces.IFluidSource; diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachinePuF6Tank.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachinePuF6Tank.java index 49996bdbb..1dfe5dc04 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachinePuF6Tank.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachinePuF6Tank.java @@ -1,8 +1,5 @@ package com.hbm.tileentity.machine.storage; -import java.util.ArrayList; -import java.util.List; - import com.hbm.interfaces.IFluidContainer; import com.hbm.inventory.FluidTank; import com.hbm.inventory.fluid.FluidType; diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineUF6Tank.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineUF6Tank.java index 115bc7ec9..9a1d5db6e 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineUF6Tank.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMachineUF6Tank.java @@ -1,8 +1,5 @@ package com.hbm.tileentity.machine.storage; -import java.util.ArrayList; -import java.util.List; - import com.hbm.interfaces.IFluidContainer; import com.hbm.inventory.FluidTank; import com.hbm.inventory.fluid.FluidType; diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java new file mode 100644 index 000000000..06f18b433 --- /dev/null +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java @@ -0,0 +1,141 @@ +package com.hbm.tileentity.machine.storage; + +import com.hbm.interfaces.IControlReceiver; +import com.hbm.items.ModItems; +import com.hbm.tileentity.INBTPacketReceiver; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.Vec3; + +public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPacketReceiver, IControlReceiver { + + private int stack = 0; + public boolean output = false; + + public TileEntityMassStorage() { + super(3); + } + + @Override + public String getInventoryName() { + return "container.massStorage"; + } + + @Override + public void updateEntity() { + + if(!worldObj.isRemote) { + + if(slots[0] != null && slots[0].getItem() == ModItems.fluid_barrel_infinite) { + this.stack = this.getCapacity(); + } + + if(this.getType() == null) + this.stack = 0; + + if(getType() != null && getStockpile() < getCapacity() && slots[0] != null && slots[0].isItemEqual(getType()) && ItemStack.areItemStackTagsEqual(slots[0], getType())) { + + int remaining = getCapacity() - getStockpile(); + int toRemove = Math.min(remaining, slots[0].stackSize); + this.decrStackSize(0, toRemove); + this.stack += toRemove; + this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this); + } + + if(output) { + + if(slots[2] != null && !(slots[2].isItemEqual(getType()) && ItemStack.areItemStackTagsEqual(slots[2], getType()))) { + return; + } + + int amount = Math.min(getStockpile(), getType().getMaxStackSize()); + + if(slots[2] == null) { + slots[2] = slots[1].copy(); + slots[2].stackSize = amount; + this.stack -= amount; + } else { + amount = Math.min(amount, slots[2].getMaxStackSize() - slots[2].stackSize); + slots[2].stackSize += amount; + this.stack -= amount; + } + } + + NBTTagCompound data = new NBTTagCompound(); + data.setInteger("stack", getStockpile()); + data.setBoolean("output", output); + INBTPacketReceiver.networkPack(this, data, 15); + } + } + + @Override + public void networkUnpack(NBTTagCompound nbt) { + this.stack = nbt.getInteger("stack"); + this.output = nbt.getBoolean("output"); + } + + public int getCapacity() { + return 10_000; + } + + public ItemStack getType() { + return slots[1] == null ? null : slots[1].copy(); + } + + public int getStockpile() { + return stack; + } + + @Override + public boolean hasPermission(EntityPlayer player) { + return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 20; + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.stack = nbt.getInteger("stack"); + this.output = nbt.getBoolean("output"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setInteger("stack", stack); + nbt.setBoolean("output", output); + } + + @Override + public void receiveControl(NBTTagCompound data) { + if(data.hasKey("provide") && slots[1] != null) { + + if(this.getStockpile() == 0) { + return; + } + + int amount = data.getBoolean("provide") ? slots[1].getMaxStackSize() : 1; + amount = Math.min(amount, getStockpile()); + + if(slots[2] != null && !(slots[2].isItemEqual(getType()) && ItemStack.areItemStackTagsEqual(slots[2], getType()))) { + return; + } + + if(slots[2] == null) { + slots[2] = slots[1].copy(); + slots[2].stackSize = amount; + this.stack -= amount; + } else { + amount = Math.min(amount, slots[2].getMaxStackSize() - slots[2].stackSize); + slots[2].stackSize += amount; + this.stack -= amount; + } + } + + if(data.hasKey("toggle")) { + this.output = !output; + } + } +} diff --git a/src/main/resources/assets/hbm/textures/blocks/mass_storage_side.png b/src/main/resources/assets/hbm/textures/blocks/mass_storage_side.png new file mode 100644 index 000000000..a90990955 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/mass_storage_side.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/mass_storage_top.png b/src/main/resources/assets/hbm/textures/blocks/mass_storage_top.png new file mode 100644 index 000000000..bb27102bb Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/mass_storage_top.png differ diff --git a/src/main/resources/assets/hbm/textures/gui/storage/gui_mass_storage_double.png b/src/main/resources/assets/hbm/textures/gui/storage/gui_mass_storage_double.png new file mode 100644 index 000000000..65d532788 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/storage/gui_mass_storage_double.png differ diff --git a/src/main/resources/assets/hbm/textures/gui/storage/gui_mass_storage_triple.png b/src/main/resources/assets/hbm/textures/gui/storage/gui_mass_storage_triple.png new file mode 100644 index 000000000..aa9a3cc40 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/storage/gui_mass_storage_triple.png differ