use of binnie.core.machines.IMachine in project Binnie by ForestryMC.
the class ComponentInventorySlots method onDestruction.
@Override
public void onDestruction() {
IMachine machine = getMachine();
World world = machine.getWorld();
Random rand = world.rand;
BlockPos pos = machine.getTileEntity().getPos();
for (InventorySlot slot : this.inventory.values()) {
ItemStack stack = slot.getItemStack();
if (slot.isRecipe() || stack.isEmpty()) {
continue;
}
final float xOffset = rand.nextFloat() * 0.8f + 0.1f;
final float yOffset = rand.nextFloat() * 0.8f + 0.1f;
final float zOffset = rand.nextFloat() * 0.8f + 0.1f;
final EntityItem entityItem = new EntityItem(world, pos.getX() + xOffset, pos.getY() + yOffset, pos.getZ() + zOffset, stack.copy());
entityItem.motionX = (float) rand.nextGaussian() * ACCEL;
entityItem.motionY = (float) rand.nextGaussian() * ACCEL + 0.2f;
entityItem.motionZ = (float) rand.nextGaussian() * ACCEL;
world.spawnEntity(entityItem);
}
}
Aggregations