Search in sources :

Example 1 with TileEntityFilteredHopper

use of betterwithmods.common.blocks.mechanical.tile.TileEntityFilteredHopper in project BetterWithAddons by DaedalusGame.

the class TileEntityAncestrySand method fillBottles.

public void fillBottles() {
    IBlockState hopper = world.getBlockState(pos.down());
    if (spirits <= InteractionEriottoMod.SPIRIT_PER_BOTTLE)
        return;
    if (hopper.getBlock() != BWMBlocks.SINGLE_MACHINES || hopper.getValue(BlockMechMachines.TYPE) != BlockMechMachines.EnumType.HOPPER)
        return;
    boolean isOn = false;
    IBlockState state = world.getBlockState(pos);
    isOn = calculateInput() > 0;
    if (isOn) {
        TileEntity te = world.getTileEntity(pos.down());
        if (te instanceof TileEntityFilteredHopper) {
            TileEntityFilteredHopper tileHopper = (TileEntityFilteredHopper) te;
            IItemHandler handler = tileHopper.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
            ItemStack stack = new ItemStack(ModItems.ancestryBottle);
            ItemStack consumed = new ItemStack(Items.GLASS_BOTTLE);
            if (tileHopper.getFilterStack().getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND) && InvUtils.canInsert(handler, stack, 1) && InvUtils.getFirstOccupiedStackOfItem(handler, consumed) >= 0) {
                InvUtils.consumeItemsInInventory(handler, consumed, 1, false);
                InvUtils.insert(handler, stack, false);
                consumeSpirits(InteractionEriottoMod.SPIRIT_PER_BOTTLE);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) IItemHandler(net.minecraftforge.items.IItemHandler) ItemStack(net.minecraft.item.ItemStack) TileEntityFilteredHopper(betterwithmods.common.blocks.mechanical.tile.TileEntityFilteredHopper)

Example 2 with TileEntityFilteredHopper

use of betterwithmods.common.blocks.mechanical.tile.TileEntityFilteredHopper in project BetterWithAddons by DaedalusGame.

the class HopperCratingRecipe method craft.

@Override
public void craft(EntityItem inputStack, World world, BlockPos pos) {
    TileEntityFilteredHopper tile = (TileEntityFilteredHopper) world.getTileEntity(pos);
    SimpleStackHandler inventory = tile.inventory;
    if (!InvUtils.consumeItemsInInventory(inventory, input, 7, false)) {
        return;
    }
    InvUtils.ejectStackWithOffset(world, pos.down(1), this.output.copy());
    this.onCraft(world, pos, inputStack);
}
Also used : TileEntityFilteredHopper(betterwithmods.common.blocks.mechanical.tile.TileEntityFilteredHopper) SimpleStackHandler(betterwithmods.common.blocks.tile.SimpleStackHandler)

Example 3 with TileEntityFilteredHopper

use of betterwithmods.common.blocks.mechanical.tile.TileEntityFilteredHopper in project BetterWithAddons by DaedalusGame.

the class HopperCratingRecipe method canCraft.

@Override
public boolean canCraft(World world, BlockPos pos) {
    IBlockState crateState = world.getBlockState(pos.down());
    TileEntityFilteredHopper tile = (TileEntityFilteredHopper) world.getTileEntity(pos);
    SimpleStackHandler inventory = tile.inventory;
    if (!isCrate(crateState)) {
        return false;
    }
    return true;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TileEntityFilteredHopper(betterwithmods.common.blocks.mechanical.tile.TileEntityFilteredHopper) SimpleStackHandler(betterwithmods.common.blocks.tile.SimpleStackHandler)

Aggregations

TileEntityFilteredHopper (betterwithmods.common.blocks.mechanical.tile.TileEntityFilteredHopper)3 SimpleStackHandler (betterwithmods.common.blocks.tile.SimpleStackHandler)2 IBlockState (net.minecraft.block.state.IBlockState)2 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 IItemHandler (net.minecraftforge.items.IItemHandler)1