Fix #148 AutoChisel not dropping inventory correctly

This commit is contained in:
tterrag1098 committed 2015-01-15 14:55:08 -05:00
1 parent 4a8af575fb
commit c5170a9167
1 file changed
+3 -23
@@ -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);
}
}
}