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