From 761ae74f8784538b5e1700df955adc9718d8924e Mon Sep 17 00:00:00 2001 From: tterrag1098 Date: Thu, 15 Jan 2015 14:55:08 -0500 Subject: [PATCH] Fix #148 AutoChisel not dropping inventory correctly --- .../chisel/block/BlockAutoChisel.java | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/cricketcraft/chisel/block/BlockAutoChisel.java b/src/main/java/com/cricketcraft/chisel/block/BlockAutoChisel.java index 7127ed37..6ade4931 100644 --- a/src/main/java/com/cricketcraft/chisel/block/BlockAutoChisel.java +++ b/src/main/java/com/cricketcraft/chisel/block/BlockAutoChisel.java @@ -1,14 +1,10 @@ package com.cricketcraft.chisel.block; -import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -47,7 +43,7 @@ public class BlockAutoChisel extends BlockContainer { if (tile != null && tile instanceof TileEntityAutoChisel && !player.isSneaking()) { player.openGui(Chisel.instance, 1, world, x, y, z); } - + return true; } @@ -58,7 +54,6 @@ public class BlockAutoChisel extends BlockContainer { } private void dropItems(World world, int x, int y, int z) { - Random random = new Random(); TileEntity tileEntity = world.getTileEntity(x, y, z); if (!(tileEntity instanceof TileEntityAutoChisel)) { @@ -69,23 +64,8 @@ public class BlockAutoChisel extends BlockContainer { for (int c = 0; c < inventory.getSizeInventory(); c++) { ItemStack stack = inventory.getStackInSlot(c); - - if (stack != null && stack.stackSize > 0) { - float rx = random.nextFloat() * 0.8F + 0.1F; - float ry = random.nextFloat() * 0.8F + 0.1F; - float rz = random.nextFloat() * 0.8F + 0.1F; - EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz, stack); - - if (stack.hasTagCompound()) { - entityItem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); - } - - float factor = 0.05F; - entityItem.motionX = random.nextGaussian() * factor; - entityItem.motionY = random.nextGaussian() * factor + 0.2F; - entityItem.motionZ = random.nextGaussian() * factor; - world.spawnEntityInWorld(entityItem); - stack.stackSize = 0; + if (stack != null) { + dropBlockAsItem(world, x, y, z, stack); } } }