From 3beb8bb780f2bbce69b970230041d4a7688d380c Mon Sep 17 00:00:00 2001 From: Henry Mao Date: Sun, 10 Feb 2013 22:22:48 +0800 Subject: [PATCH] Fixed Imprinter dupe bug --- .../assemblyline/common/AssemblyLine.java | 4 +- .../common/block/TileEntityCrate.java | 2 +- .../machine/imprinter/BlockImprinter.java | 63 +++++++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/minecraft/assemblyline/common/AssemblyLine.java b/src/minecraft/assemblyline/common/AssemblyLine.java index 517b464f..9c78accd 100644 --- a/src/minecraft/assemblyline/common/AssemblyLine.java +++ b/src/minecraft/assemblyline/common/AssemblyLine.java @@ -157,14 +157,14 @@ public class AssemblyLine // Imprint GameRegistry.addRecipe(new ShapedOreRecipe(itemImprint, new Object[] { "R", "P", "I", 'P', Item.paper, 'R', Item.redstone, 'I', new ItemStack(Item.dyePowder, 1, 0) })); - // Imprinter (VANILLA COMPATIBLE) + // Imprinter GameRegistry.addRecipe(new ShapedOreRecipe(blockImprinter, new Object[] { "SIS", "SPS", "WCW", 'S', Item.ingotIron, 'C', Block.chest, 'W', Block.workbench, 'P', Block.pistonBase, 'I', new ItemStack(Item.dyePowder, 1, 0) })); // Detector GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, new Object[] { "SES", "SCS", "SPS", 'S', "ingotSteel", 'C', "basicCircuit", 'E', Item.eyeOfEnder })); // Crate - GameRegistry.addRecipe(new ShapedOreRecipe(blockCrate, new Object[] { "TST", "S S", "TST", 'S', "ingotSteel", 'T', Item.stick })); + GameRegistry.addRecipe(new ShapedOreRecipe(blockCrate, new Object[] { "TST", "S S", "TST", 'S', Item.ingotIron, 'T', Block.wood })); // Conveyor Belt GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 10), new Object[] { "III", "WMW", 'I', "ingotSteel", 'W', Block.wood, 'M', "motor" })); diff --git a/src/minecraft/assemblyline/common/block/TileEntityCrate.java b/src/minecraft/assemblyline/common/block/TileEntityCrate.java index e602199f..4d21a3a8 100644 --- a/src/minecraft/assemblyline/common/block/TileEntityCrate.java +++ b/src/minecraft/assemblyline/common/block/TileEntityCrate.java @@ -20,7 +20,7 @@ import cpw.mods.fml.relauncher.Side; public class TileEntityCrate extends TileEntityAdvanced implements IInventory, IPacketReceiver { - public static final int MAX_LIMIT = 2880; + public static final int MAX_LIMIT = 2048; private ItemStack[] containingItems = new ItemStack[1]; public long prevClickTime = -1000; diff --git a/src/minecraft/assemblyline/common/machine/imprinter/BlockImprinter.java b/src/minecraft/assemblyline/common/machine/imprinter/BlockImprinter.java index 13d3bc63..7f13ceba 100644 --- a/src/minecraft/assemblyline/common/machine/imprinter/BlockImprinter.java +++ b/src/minecraft/assemblyline/common/machine/imprinter/BlockImprinter.java @@ -1,7 +1,13 @@ package assemblyline.common.machine.imprinter; +import java.util.Random; + import net.minecraft.block.material.Material; +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.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import universalelectricity.prefab.BlockMachine; @@ -54,6 +60,63 @@ public class BlockImprinter extends BlockMachine } + @Override + public void breakBlock(World par1World, int x, int y, int z, int par5, int par6) + { + TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z); + + if (tileEntity != null) + { + if (tileEntity instanceof TileEntityImprinter) + { + TileEntityImprinter inventory = (TileEntityImprinter) tileEntity; + + for (int i = 0; i < inventory.getSizeInventory(); ++i) + { + ItemStack itemStack = inventory.getStackInSlot(i); + + if (itemStack != null) + { + Random random = new Random(); + float var8 = random.nextFloat() * 0.8F + 0.1F; + float var9 = random.nextFloat() * 0.8F + 0.1F; + float var10 = random.nextFloat() * 0.8F + 0.1F; + + while (itemStack.stackSize > 0) + { + int var11 = random.nextInt(21) + 10; + + if (var11 > itemStack.stackSize) + { + var11 = itemStack.stackSize; + } + + itemStack.stackSize -= var11; + + if (i != inventory.imprinterMatrix.length + TileEntityImprinter.IMPRINTER_MATRIX_START - 1) + { + EntityItem entityItem = new EntityItem(par1World, (x + var8), (y + var9), (z + var10), new ItemStack(itemStack.itemID, var11, itemStack.getItemDamage())); + + if (itemStack.hasTagCompound()) + { + entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); + } + + float var13 = 0.05F; + entityItem.motionX = ((float) random.nextGaussian() * var13); + entityItem.motionY = ((float) random.nextGaussian() * var13 + 0.2F); + entityItem.motionZ = ((float) random.nextGaussian() * var13); + par1World.spawnEntityInWorld(entityItem); + } + } + } + } + } + } + + super.breakBlock(par1World, x, y, z, par5, par6); + } + public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) { TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);