use of com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour in project createaddition by mrh0.
the class TeslaCoilTileEntity method addBehaviours.
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
super.addBehaviours(behaviours);
processingBehaviour = new BeltProcessingBehaviour(this).whenItemEnters((s, i) -> TeslaCoilBeltCallbacks.onItemReceived(s, i, this)).whileItemHeld((s, i) -> TeslaCoilBeltCallbacks.whenItemHeld(s, i, this));
behaviours.add(processingBehaviour);
}
use of com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour in project Create by Creators-of-Create.
the class SpoutTileEntity method addBehaviours.
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
tank = SmartFluidTankBehaviour.single(this, 1000);
behaviours.add(tank);
beltProcessing = new BeltProcessingBehaviour(this).whenItemEnters(this::onItemReceived).whileItemHeld(this::whenItemHeld);
behaviours.add(beltProcessing);
}
use of com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour in project Create by Creators-of-Create.
the class DepotBehaviour method tick.
@Override
public void tick() {
super.tick();
Level world = tileEntity.getLevel();
for (Iterator<TransportedItemStack> iterator = incoming.iterator(); iterator.hasNext(); ) {
TransportedItemStack ts = iterator.next();
if (!tick(ts))
continue;
if (world.isClientSide && !tileEntity.isVirtual())
continue;
if (heldItem == null) {
heldItem = ts;
} else {
if (!ItemHelper.canItemStackAmountsStack(heldItem.stack, ts.stack)) {
Vec3 vec = VecHelper.getCenterOf(tileEntity.getBlockPos());
Containers.dropItemStack(tileEntity.getLevel(), vec.x, vec.y + .5f, vec.z, ts.stack);
} else {
heldItem.stack.grow(ts.stack.getCount());
}
}
iterator.remove();
tileEntity.notifyUpdate();
}
if (heldItem == null)
return;
if (!tick(heldItem))
return;
BlockPos pos = tileEntity.getBlockPos();
if (world.isClientSide)
return;
if (handleBeltFunnelOutput())
return;
BeltProcessingBehaviour processingBehaviour = TileEntityBehaviour.get(world, pos.above(2), BeltProcessingBehaviour.TYPE);
if (processingBehaviour == null)
return;
if (!heldItem.locked && BeltProcessingBehaviour.isBlocked(world, pos))
return;
ItemStack previousItem = heldItem.stack;
boolean wasLocked = heldItem.locked;
ProcessingResult result = wasLocked ? processingBehaviour.handleHeldItem(heldItem, transportedHandler) : processingBehaviour.handleReceivedItem(heldItem, transportedHandler);
if (result == ProcessingResult.REMOVE) {
heldItem = null;
tileEntity.sendData();
return;
}
heldItem.locked = result == ProcessingResult.HOLD;
if (heldItem.locked != wasLocked || !previousItem.equals(heldItem.stack, false))
tileEntity.sendData();
}
use of com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour in project Create by Creators-of-Create.
the class BeltInventory method handleBeltProcessingAndCheckIfRemoved.
protected boolean handleBeltProcessingAndCheckIfRemoved(TransportedItemStack currentItem, float nextOffset, boolean noMovement) {
int currentSegment = (int) currentItem.beltPosition;
// Continue processing if held
if (currentItem.locked) {
BeltProcessingBehaviour processingBehaviour = getBeltProcessingAtSegment(currentSegment);
TransportedItemStackHandlerBehaviour stackHandlerBehaviour = getTransportedItemStackHandlerAtSegment(currentSegment);
if (stackHandlerBehaviour == null)
return false;
if (processingBehaviour == null) {
currentItem.locked = false;
belt.sendData();
return false;
}
ProcessingResult result = processingBehaviour.handleHeldItem(currentItem, stackHandlerBehaviour);
if (result == ProcessingResult.REMOVE)
return true;
if (result == ProcessingResult.HOLD)
return false;
currentItem.locked = false;
belt.sendData();
return false;
}
if (noMovement)
return false;
// See if any new belt processing catches the item
if (currentItem.beltPosition > .5f || beltMovementPositive) {
int firstUpcomingSegment = (int) (currentItem.beltPosition + (beltMovementPositive ? .5f : -.5f));
int step = beltMovementPositive ? 1 : -1;
for (int segment = firstUpcomingSegment; beltMovementPositive ? segment + .5f <= nextOffset : segment + .5f >= nextOffset; segment += step) {
BeltProcessingBehaviour processingBehaviour = getBeltProcessingAtSegment(segment);
TransportedItemStackHandlerBehaviour stackHandlerBehaviour = getTransportedItemStackHandlerAtSegment(segment);
if (processingBehaviour == null)
continue;
if (stackHandlerBehaviour == null)
continue;
if (BeltProcessingBehaviour.isBlocked(belt.getLevel(), BeltHelper.getPositionForOffset(belt, segment)))
continue;
ProcessingResult result = processingBehaviour.handleReceivedItem(currentItem, stackHandlerBehaviour);
if (result == ProcessingResult.REMOVE)
return true;
if (result == ProcessingResult.HOLD) {
currentItem.beltPosition = segment + .5f + (beltMovementPositive ? 1 / 512f : -1 / 512f);
currentItem.locked = true;
belt.sendData();
return false;
}
}
}
return false;
}
use of com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour in project Create by Creators-of-Create.
the class DeployerTileEntity method addBehaviours.
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
super.addBehaviours(behaviours);
filtering = new FilteringBehaviour(this, new DeployerFilterSlot());
behaviours.add(filtering);
processingBehaviour = new BeltProcessingBehaviour(this).whenItemEnters((s, i) -> BeltDeployerCallbacks.onItemReceived(s, i, this)).whileItemHeld((s, i) -> BeltDeployerCallbacks.whenItemHeld(s, i, this));
behaviours.add(processingBehaviour);
}
Aggregations