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);
}
}
}
}
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);
}
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;
}
Aggregations