Search in sources :

Example 11 with FilteringBehaviour

use of com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour in project Create by Creators-of-Create.

the class ContentObserverBlock method onFunnelTransfer.

public void onFunnelTransfer(Level world, BlockPos funnelPos, ItemStack transferred) {
    for (Direction direction : Iterate.horizontalDirections) {
        BlockPos detectorPos = funnelPos.relative(direction);
        BlockState detectorState = world.getBlockState(detectorPos);
        if (!AllBlocks.CONTENT_OBSERVER.has(detectorState))
            continue;
        if (detectorState.getValue(FACING) != direction.getOpposite())
            continue;
        withTileEntityDo(world, detectorPos, te -> {
            FilteringBehaviour filteringBehaviour = TileEntityBehaviour.get(te, FilteringBehaviour.TYPE);
            if (filteringBehaviour == null)
                return;
            if (!filteringBehaviour.test(transferred))
                return;
            te.activate(4);
        });
    }
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) FilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour) BlockPos(net.minecraft.core.BlockPos) Direction(net.minecraft.core.Direction)

Example 12 with FilteringBehaviour

use of com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour in project Create by Creators-of-Create.

the class ContentObserverTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    filtering = new FilteringBehaviour(this, new FilteredDetectorFilterSlot()).moveText(new Vec3(0, 5, 0));
    behaviours.add(filtering);
    InterfaceProvider towardBlockFacing = InterfaceProvider.towardBlockFacing();
    behaviours.add(observedInventory = new InvManipulationBehaviour(this, towardBlockFacing).bypassSidedness());
    behaviours.add(observedTank = new TankManipulationBehaviour(this, towardBlockFacing).bypassSidedness());
}
Also used : FilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour) Vec3(net.minecraft.world.phys.Vec3) InvManipulationBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour) InterfaceProvider(com.simibubi.create.foundation.tileEntity.behaviour.inventory.CapManipulationBehaviourBase.InterfaceProvider) TankManipulationBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.inventory.TankManipulationBehaviour)

Example 13 with FilteringBehaviour

use of com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour in project Create by Creators-of-Create.

the class AbstractFunnelBlock method tryInsert.

public static ItemStack tryInsert(Level worldIn, BlockPos pos, ItemStack toInsert, boolean simulate) {
    FilteringBehaviour filter = TileEntityBehaviour.get(worldIn, pos, FilteringBehaviour.TYPE);
    InvManipulationBehaviour inserter = TileEntityBehaviour.get(worldIn, pos, InvManipulationBehaviour.TYPE);
    if (inserter == null)
        return toInsert;
    if (filter != null && !filter.test(toInsert))
        return toInsert;
    if (simulate)
        inserter.simulate();
    ItemStack insert = inserter.insert(toInsert);
    if (!simulate && insert.getCount() != toInsert.getCount()) {
        BlockEntity tileEntity = worldIn.getBlockEntity(pos);
        if (tileEntity instanceof FunnelTileEntity) {
            FunnelTileEntity funnelTileEntity = (FunnelTileEntity) tileEntity;
            funnelTileEntity.onTransfer(toInsert);
            if (funnelTileEntity.hasFlap())
                funnelTileEntity.flap(true);
        }
    }
    return insert;
}
Also used : FilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour) InvManipulationBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour) ItemStack(net.minecraft.world.item.ItemStack) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 14 with FilteringBehaviour

use of com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour in project Create by Creators-of-Create.

the class SmartChuteTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    behaviours.add(filtering = new FilteringBehaviour(this, new SmartChuteFilterSlotPositioning()).showCountWhen(this::isExtracting));
    super.addBehaviours(behaviours);
}
Also used : FilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour)

Example 15 with FilteringBehaviour

use of com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour in project Create by Creators-of-Create.

the class TankManipulationBehaviour method getFilterTest.

protected Predicate<FluidStack> getFilterTest(Predicate<FluidStack> customFilter) {
    Predicate<FluidStack> test = customFilter;
    FilteringBehaviour filter = tileEntity.getBehaviour(FilteringBehaviour.TYPE);
    if (filter != null)
        test = customFilter.and(filter::test);
    return test;
}
Also used : FilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour) FluidStack(net.minecraftforge.fluids.FluidStack)

Aggregations

FilteringBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour)15 ItemStack (net.minecraft.world.item.ItemStack)7 InvManipulationBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour)6 BlockState (net.minecraft.world.level.block.state.BlockState)6 BlockPos (net.minecraft.core.BlockPos)5 Direction (net.minecraft.core.Direction)5 Vec3 (net.minecraft.world.phys.Vec3)5 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)4 TileEntityBehaviour (com.simibubi.create.foundation.tileEntity.TileEntityBehaviour)3 List (java.util.List)3 CompoundTag (net.minecraft.nbt.CompoundTag)3 BlockEntityType (net.minecraft.world.level.block.entity.BlockEntityType)3 FluidStack (net.minecraftforge.fluids.FluidStack)3 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)3 AllBlocks (com.simibubi.create.AllBlocks)2 SmartTileEntity (com.simibubi.create.foundation.tileEntity.SmartTileEntity)2 DirectBeltInputBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour)2 InterfaceProvider (com.simibubi.create.foundation.tileEntity.behaviour.inventory.CapManipulationBehaviourBase.InterfaceProvider)2 TankManipulationBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.inventory.TankManipulationBehaviour)2 VecHelper (com.simibubi.create.foundation.utility.VecHelper)2