Search in sources :

Example 6 with IMachine

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);
    }
}
Also used : IMachine(binnie.core.machines.IMachine) Random(java.util.Random) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

IMachine (binnie.core.machines.IMachine)6 MachineUtil (binnie.core.machines.MachineUtil)3 ItemStack (net.minecraft.item.ItemStack)3 ComponentInventorySlots (binnie.core.machines.inventory.ComponentInventorySlots)2 ComponentInventoryTransfer (binnie.core.machines.inventory.ComponentInventoryTransfer)2 InventorySlot (binnie.core.machines.inventory.InventorySlot)2 SlotValidator (binnie.core.machines.inventory.SlotValidator)2 ComponentPowerReceptor (binnie.core.machines.power.ComponentPowerReceptor)2 ComponentGeneticGUI (binnie.genetics.machine.ComponentGeneticGUI)2 Random (java.util.Random)2 ControlText (binnie.core.gui.controls.ControlText)1 ControlTextEdit (binnie.core.gui.controls.ControlTextEdit)1 ControlButton (binnie.core.gui.controls.button.ControlButton)1 Control (binnie.core.gui.controls.core.Control)1 ControlPage (binnie.core.gui.controls.page.ControlPage)1 ControlPages (binnie.core.gui.controls.page.ControlPages)1 ControlTabBar (binnie.core.gui.controls.tab.ControlTabBar)1 EventMouse (binnie.core.gui.events.EventMouse)1 Point (binnie.core.gui.geometry.Point)1 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)1