Fixed Imprinter dupe bug

This commit is contained in:
Henry Mao 2013-02-10 22:22:48 +08:00
parent 7c230fe52e
commit 3beb8bb780
3 changed files with 66 additions and 3 deletions

View file

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

View file

@ -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;

View file

@ -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);