use of com.simibubi.create.content.logistics.block.belts.tunnel.BrassTunnelTileEntity in project Create by Creators-of-Create.
the class TunnelScenes method brassModes.
public static void brassModes(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("brass_tunnel_modes", "Distribution Modes of the Brass Tunnel");
scene.configureBasePlate(0, 1, 5);
BlockState barrier = Blocks.BARRIER.defaultBlockState();
scene.world.setBlock(util.grid.at(1, 1, 0), barrier, false);
scene.world.showSection(util.select.layer(0), Direction.UP);
scene.idle(5);
scene.world.showSection(util.select.fromTo(1, 1, 1, 5, 1, 5).add(util.select.fromTo(3, 2, 5, 1, 2, 5)), Direction.DOWN);
scene.idle(10);
for (int i = 0; i < 3; i++) {
scene.world.showSection(util.select.position(3 - i, 2, 3), Direction.DOWN);
scene.idle(4);
}
Vec3 tunnelTop = util.vector.topOf(util.grid.at(2, 2, 3));
scene.overlay.showControls(new InputWindowElement(tunnelTop, Pointing.DOWN).scroll().withWrench(), 80);
scene.idle(7);
scene.overlay.showCenteredScrollInput(util.grid.at(2, 2, 3), Direction.UP, 120);
scene.overlay.showText(120).attachKeyFrame().pointAt(tunnelTop).placeNearTarget().text("Using a Wrench, the distribution behaviour of Brass Tunnels can be configured");
scene.idle(130);
Class<BrassTunnelTileEntity> tunnelClass = BrassTunnelTileEntity.class;
ElementLink<WorldSectionElement> blockage = scene.world.showIndependentSection(util.select.position(4, 1, 0), Direction.UP);
scene.world.moveSection(blockage, util.vector.of(-3, 0, 0), 0);
Vec3 modeVec = util.vector.of(4, 2.5, 3);
scene.overlay.showControls(new InputWindowElement(modeVec, Pointing.RIGHT).showing(AllIcons.I_TUNNEL_SPLIT), 140);
ElementLink<WorldSectionElement> blockage2 = null;
for (int i = 0; i < 32; i++) {
if (i < 30)
scene.world.createItemOnBelt(util.grid.at(1, 1, 5), Direction.EAST, new ItemStack(Items.SNOWBALL, 12));
scene.idle(i > 8 ? 30 : 40);
if (i == 0) {
scene.overlay.showText(80).attachKeyFrame().pointAt(tunnelTop).placeNearTarget().text("'Split' will attempt to distribute the stack evenly between available outputs");
}
if (i == 2) {
scene.overlay.showText(60).text("If an output is unable to take more items, it will be skipped").pointAt(util.vector.blockSurface(util.grid.at(1, 1, 2), Direction.UP)).placeNearTarget().colored(PonderPalette.GREEN);
}
if (i == 4) {
scene.overlay.showControls(new InputWindowElement(modeVec, Pointing.RIGHT).showing(AllIcons.I_TUNNEL_FORCED_SPLIT), 140);
scene.world.modifyTileEntity(util.grid.at(1, 2, 3), tunnelClass, te -> te.getBehaviour(ScrollOptionBehaviour.TYPE).setValue(BrassTunnelTileEntity.SelectionMode.FORCED_SPLIT.ordinal()));
}
if (i == 5) {
scene.overlay.showText(80).attachKeyFrame().text("'Forced Split' will never skip outputs, and instead wait until they are free").pointAt(util.vector.blockSurface(util.grid.at(1, 1, 2), Direction.UP)).placeNearTarget().colored(PonderPalette.RED);
scene.idle(60);
scene.world.moveSection(blockage, util.vector.of(-1, 0, 0), 10);
scene.world.setBlock(util.grid.at(1, 1, 0), Blocks.AIR.defaultBlockState(), false);
scene.world.multiplyKineticSpeed(util.select.everywhere(), 1.5f);
}
if (i == 7) {
scene.world.modifyTileEntity(util.grid.at(1, 2, 3), tunnelClass, te -> te.getBehaviour(ScrollOptionBehaviour.TYPE).setValue(BrassTunnelTileEntity.SelectionMode.ROUND_ROBIN.ordinal()));
scene.overlay.showControls(new InputWindowElement(modeVec, Pointing.RIGHT).showing(AllIcons.I_TUNNEL_ROUND_ROBIN), 140);
scene.overlay.showText(80).attachKeyFrame().pointAt(tunnelTop).placeNearTarget().text("'Round Robin' keeps stacks whole, and cycles through outputs iteratively");
}
if (i == 7) {
scene.world.moveSection(blockage, util.vector.of(1, 0, 0), 10);
scene.world.setBlock(util.grid.at(1, 1, 0), barrier, false);
}
if (i == 13) {
scene.overlay.showText(60).text("Once Again, if an output is unable to take more items, it will be skipped").placeNearTarget().pointAt(util.vector.blockSurface(util.grid.at(1, 1, 2), Direction.UP)).colored(PonderPalette.GREEN);
}
if (i == 15) {
scene.overlay.showControls(new InputWindowElement(modeVec, Pointing.RIGHT).showing(AllIcons.I_TUNNEL_FORCED_ROUND_ROBIN), 140);
scene.world.modifyTileEntity(util.grid.at(1, 2, 3), tunnelClass, te -> te.getBehaviour(ScrollOptionBehaviour.TYPE).setValue(BrassTunnelTileEntity.SelectionMode.FORCED_ROUND_ROBIN.ordinal()));
}
if (i == 16) {
scene.overlay.showText(50).attachKeyFrame().placeNearTarget().text("'Forced Round Robin' never skips outputs").pointAt(util.vector.blockSurface(util.grid.at(1, 1, 2), Direction.UP)).colored(PonderPalette.RED);
scene.idle(30);
scene.world.moveSection(blockage, util.vector.of(-1, 0, 0), 10);
scene.world.setBlock(util.grid.at(1, 1, 0), Blocks.AIR.defaultBlockState(), false);
}
if (i == 19) {
scene.overlay.showControls(new InputWindowElement(modeVec, Pointing.RIGHT).showing(AllIcons.I_TUNNEL_PREFER_NEAREST), 140);
scene.world.modifyTileEntity(util.grid.at(1, 2, 3), tunnelClass, te -> te.getBehaviour(ScrollOptionBehaviour.TYPE).setValue(BrassTunnelTileEntity.SelectionMode.PREFER_NEAREST.ordinal()));
scene.world.moveSection(blockage, util.vector.of(1, 0, 0), 10);
scene.world.setBlock(util.grid.at(1, 1, 0), barrier, false);
scene.overlay.showText(70).attachKeyFrame().text("'Prefer Nearest' prioritizes the outputs closest to the items' input location").pointAt(util.vector.blockSurface(util.grid.at(1, 1, 2), Direction.UP)).placeNearTarget().colored(PonderPalette.GREEN);
}
if (i == 21) {
scene.world.setBlock(util.grid.at(2, 1, 0), Blocks.BARRIER.defaultBlockState(), false);
blockage2 = scene.world.showIndependentSection(util.select.position(4, 1, 0), Direction.UP);
scene.world.moveSection(blockage2, util.vector.of(-2, 0, 0), 0);
}
if (i == 25) {
scene.world.hideIndependentSection(blockage, Direction.DOWN);
scene.world.setBlock(util.grid.at(1, 1, 0), Blocks.AIR.defaultBlockState(), false);
scene.world.hideIndependentSection(blockage2, Direction.DOWN);
scene.world.setBlock(util.grid.at(2, 1, 0), Blocks.AIR.defaultBlockState(), false);
}
if (i == 26) {
scene.overlay.showControls(new InputWindowElement(modeVec, Pointing.RIGHT).showing(AllIcons.I_TUNNEL_RANDOMIZE), 140);
scene.world.modifyTileEntity(util.grid.at(1, 2, 3), tunnelClass, te -> te.getBehaviour(ScrollOptionBehaviour.TYPE).setValue(BrassTunnelTileEntity.SelectionMode.RANDOMIZE.ordinal()));
}
if (i == 27) {
scene.overlay.showText(70).attachKeyFrame().text("'Randomize' will distribute whole stacks to randomly picked outputs").pointAt(tunnelTop).placeNearTarget();
}
}
scene.world.hideSection(util.select.fromTo(3, 2, 5, 1, 2, 5), Direction.UP);
scene.idle(10);
scene.overlay.showControls(new InputWindowElement(modeVec, Pointing.RIGHT).showing(AllIcons.I_TUNNEL_SYNCHRONIZE), 140);
scene.world.modifyTileEntity(util.grid.at(1, 2, 3), tunnelClass, te -> te.getBehaviour(ScrollOptionBehaviour.TYPE).setValue(BrassTunnelTileEntity.SelectionMode.SYNCHRONIZE.ordinal()));
scene.idle(30);
scene.overlay.showText(70).attachKeyFrame().text("'Synchronize Inputs' is a unique setting for Brass Tunnels").pointAt(tunnelTop).placeNearTarget();
ItemStack item1 = new ItemStack(Items.CARROT);
ItemStack item2 = new ItemStack(Items.HONEY_BOTTLE);
ItemStack item3 = AllItems.POLISHED_ROSE_QUARTZ.asStack();
scene.world.createItemOnBelt(util.grid.at(3, 1, 4), Direction.UP, item1);
scene.world.createItemOnBelt(util.grid.at(2, 1, 4), Direction.UP, item2);
scene.world.createItemOnBelt(util.grid.at(3, 1, 5), Direction.SOUTH, item1);
scene.world.createItemOnBelt(util.grid.at(2, 1, 5), Direction.SOUTH, item2);
scene.idle(80);
scene.world.createItemOnBelt(util.grid.at(2, 1, 5), Direction.SOUTH, item2);
scene.rotateCameraY(-90);
scene.idle(20);
scene.world.multiplyKineticSpeed(util.select.everywhere(), .5f);
scene.overlay.showText(70).text("Items are only allowed past if every tunnel in the group has one waiting").pointAt(util.vector.blockSurface(util.grid.at(2, 1, 4), Direction.UP)).placeNearTarget().colored(PonderPalette.OUTPUT);
scene.idle(60);
scene.world.createItemOnBelt(util.grid.at(1, 1, 5), Direction.SOUTH, item3);
scene.idle(90);
scene.rotateCameraY(90);
scene.overlay.showText(100).text("This ensures that all affected belts supply items at the same rate").pointAt(util.vector.blockSurface(util.grid.at(1, 2, 3), Direction.WEST)).placeNearTarget().colored(PonderPalette.GREEN);
}
use of com.simibubi.create.content.logistics.block.belts.tunnel.BrassTunnelTileEntity in project Create by Creators-of-Create.
the class TunnelScenes method brass.
public static void brass(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("brass_tunnel", "Using Brass Tunnels");
scene.configureBasePlate(1, 0, 5);
scene.world.cycleBlockProperty(util.grid.at(3, 1, 2), BeltBlock.CASING);
scene.world.showSection(util.select.layer(0), Direction.UP);
scene.idle(5);
scene.world.showSection(util.select.fromTo(5, 1, 5, 5, 1, 3), Direction.DOWN);
scene.idle(5);
scene.world.showSection(util.select.fromTo(5, 1, 2, 1, 1, 2), Direction.SOUTH);
scene.idle(10);
Vector<ElementLink<WorldSectionElement>> tunnels = new Vector<>(3);
for (int i = 0; i < 3; i++) {
tunnels.add(scene.world.showIndependentSection(util.select.position(2 + i, 2, 4), Direction.DOWN));
scene.world.moveSection(tunnels.get(i), util.vector.of(0, 0, -2), 0);
scene.idle(4);
}
for (int i = 0; i < 3; i++) {
scene.world.cycleBlockProperty(util.grid.at(2 + i, 1, 2), BeltBlock.CASING);
scene.world.modifyTileNBT(util.select.position(2 + i, 1, 2), BeltTileEntity.class, nbt -> NBTHelper.writeEnum(nbt, "Casing", BeltTileEntity.CasingType.BRASS), true);
scene.idle(4);
}
scene.overlay.showText(60).attachKeyFrame().pointAt(util.vector.topOf(util.grid.at(2, 2, 2))).placeNearTarget().text("Brass Tunnels can be used to cover up your belts");
scene.idle(70);
for (int i = 0; i < 3; i++) {
scene.world.cycleBlockProperty(util.grid.at(2 + i, 1, 2), BeltBlock.CASING);
scene.world.hideIndependentSection(tunnels.get(i), Direction.UP);
scene.idle(4);
}
scene.idle(10);
scene.world.showSection(util.select.fromTo(3, 1, 0, 1, 1, 1), Direction.SOUTH);
scene.idle(10);
scene.world.showSection(util.select.position(3, 2, 2), Direction.DOWN);
scene.idle(10);
scene.world.cycleBlockProperty(util.grid.at(3, 1, 2), BeltBlock.CASING);
scene.idle(10);
BlockPos tunnelPos = util.grid.at(3, 2, 2);
for (Direction d : Iterate.horizontalDirections) {
if (d == Direction.SOUTH)
continue;
Vec3 filter = getTunnelFilterVec(tunnelPos, d);
scene.overlay.showFilterSlotInput(filter, 40);
scene.idle(3);
}
scene.overlay.showText(60).attachKeyFrame().pointAt(getTunnelFilterVec(tunnelPos, Direction.WEST)).placeNearTarget().text("Brass Tunnels have filter slots on each open side");
scene.idle(70);
scene.rotateCameraY(70);
scene.idle(20);
Vec3 tunnelFilterVec = getTunnelFilterVec(tunnelPos, Direction.EAST);
scene.overlay.showFilterSlotInput(tunnelFilterVec, 40);
scene.overlay.showText(60).attachKeyFrame().pointAt(tunnelFilterVec).placeNearTarget().text("Filters on inbound connections simply block non-matching items");
ItemStack copper = new ItemStack(Items.COPPER_INGOT);
Class<BrassTunnelTileEntity> tunnelClass = BrassTunnelTileEntity.class;
scene.world.modifyTileEntity(tunnelPos, tunnelClass, te -> te.getBehaviour(SidedFilteringBehaviour.TYPE).setFilter(Direction.EAST, copper));
scene.overlay.showControls(new InputWindowElement(tunnelFilterVec, Pointing.DOWN).withItem(copper), 30);
ItemStack zinc = AllItems.ZINC_INGOT.asStack();
scene.world.createItemOnBelt(util.grid.at(5, 1, 2), Direction.EAST, zinc);
scene.idle(70);
scene.world.multiplyKineticSpeed(util.select.everywhere(), -2);
scene.idle(20);
scene.rotateCameraY(-70);
scene.world.multiplyKineticSpeed(util.select.everywhere(), -.5f);
scene.idle(20);
scene.world.modifyTileEntity(tunnelPos, tunnelClass, te -> te.getBehaviour(SidedFilteringBehaviour.TYPE).setFilter(Direction.EAST, ItemStack.EMPTY));
tunnelFilterVec = getTunnelFilterVec(tunnelPos, Direction.NORTH);
scene.overlay.showFilterSlotInput(tunnelFilterVec, 40);
tunnelFilterVec = getTunnelFilterVec(tunnelPos, Direction.WEST);
scene.overlay.showFilterSlotInput(tunnelFilterVec, 40);
scene.overlay.showText(60).attachKeyFrame().pointAt(tunnelFilterVec).placeNearTarget().text("Filters on outbound connections can be used to sort items by type");
scene.idle(70);
scene.overlay.showControls(new InputWindowElement(tunnelFilterVec, Pointing.LEFT).withItem(copper), 30);
scene.world.modifyTileEntity(tunnelPos, tunnelClass, te -> te.getBehaviour(SidedFilteringBehaviour.TYPE).setFilter(Direction.WEST, copper));
scene.idle(4);
tunnelFilterVec = getTunnelFilterVec(tunnelPos, Direction.NORTH);
scene.overlay.showControls(new InputWindowElement(tunnelFilterVec, Pointing.RIGHT).withItem(zinc), 30);
scene.world.modifyTileEntity(tunnelPos, tunnelClass, te -> te.getBehaviour(SidedFilteringBehaviour.TYPE).setFilter(Direction.NORTH, zinc));
scene.world.multiplyKineticSpeed(util.select.everywhere(), 1.5f);
for (int i = 0; i < 6; i++) {
scene.world.createItemOnBelt(util.grid.at(5, 1, 2), Direction.EAST, i % 2 == 0 ? zinc : copper);
scene.idle(12);
}
scene.idle(30);
scene.world.modifyTileEntity(tunnelPos, tunnelClass, te -> te.getBehaviour(SidedFilteringBehaviour.TYPE).setFilter(Direction.NORTH, ItemStack.EMPTY));
scene.world.modifyTileEntity(tunnelPos, tunnelClass, te -> te.getBehaviour(SidedFilteringBehaviour.TYPE).setFilter(Direction.WEST, ItemStack.EMPTY));
scene.idle(10);
Vec3 tunnelTop = util.vector.topOf(tunnelPos);
scene.overlay.showControls(new InputWindowElement(tunnelTop, Pointing.DOWN).scroll().withWrench(), 80);
scene.idle(7);
scene.overlay.showCenteredScrollInput(tunnelPos, Direction.UP, 120);
scene.overlay.showText(120).attachKeyFrame().pointAt(tunnelTop).placeNearTarget().text("Whenever a passing item has multiple valid exits, the distribution mode will decide how to handle it");
for (int i = 0; i < 3; i++) {
scene.idle(40);
scene.world.createItemOnBelt(util.grid.at(5, 1, 2), Direction.EAST, AllItems.BRASS_INGOT.asStack(63));
}
scene.idle(30);
scene.world.hideSection(util.select.position(3, 2, 2), Direction.UP);
scene.idle(5);
scene.world.hideSection(util.select.fromTo(5, 1, 2, 1, 1, 0), Direction.UP);
scene.idle(15);
ElementLink<WorldSectionElement> newBelt = scene.world.showIndependentSection(util.select.fromTo(3, 3, 2, 0, 3, 4).add(util.select.fromTo(5, 3, 3, 4, 3, 3)), Direction.DOWN);
scene.world.moveSection(newBelt, util.vector.of(0, -2, -1), 0);
scene.idle(15);
for (int i = 0; i < 3; i++) {
scene.idle(4);
scene.world.showSectionAndMerge(util.select.position(3, 4, 2 + i), Direction.DOWN, newBelt);
}
scene.overlay.showSelectionWithText(util.select.fromTo(3, 1, 1, 3, 2, 3), 80).attachKeyFrame().placeNearTarget().text("Brass Tunnels on parallel belts will form a group");
scene.idle(90);
ItemStack item1 = new ItemStack(Items.CARROT);
ItemStack item2 = new ItemStack(Items.HONEY_BOTTLE);
ItemStack item3 = new ItemStack(Items.SWEET_BERRIES);
tunnelFilterVec = getTunnelFilterVec(tunnelPos, Direction.WEST);
BlockPos newTunnelPos = tunnelPos.above(2).south();
scene.overlay.showControls(new InputWindowElement(tunnelFilterVec.add(0, 0, -1), Pointing.RIGHT).withItem(item1), 20);
scene.world.modifyTileEntity(newTunnelPos.north(), tunnelClass, te -> te.getBehaviour(SidedFilteringBehaviour.TYPE).setFilter(Direction.WEST, item1));
scene.idle(4);
scene.overlay.showControls(new InputWindowElement(tunnelFilterVec, Pointing.DOWN).withItem(item2), 20);
scene.world.modifyTileEntity(newTunnelPos, tunnelClass, te -> te.getBehaviour(SidedFilteringBehaviour.TYPE).setFilter(Direction.WEST, item2));
scene.idle(4);
scene.overlay.showControls(new InputWindowElement(tunnelFilterVec.add(0, 0, 1), Pointing.LEFT).withItem(item3), 20);
scene.world.modifyTileEntity(newTunnelPos.south(), tunnelClass, te -> te.getBehaviour(SidedFilteringBehaviour.TYPE).setFilter(Direction.WEST, item3));
scene.idle(30);
scene.overlay.showText(80).pointAt(tunnelTop).placeNearTarget().text("Incoming Items will now be distributed across all connected exits");
scene.idle(90);
BlockPos beltPos = util.grid.at(5, 3, 3);
Vec3 m = util.vector.of(0, 0.1, 0);
Vec3 spawn = util.vector.centerOf(util.grid.at(5, 3, 2));
scene.world.createItemEntity(spawn, m, item1);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.UP, item1);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.createItemEntity(spawn, m, item2);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.UP, item2);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.createItemEntity(spawn, m, item3);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.UP, item3);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.idle(50);
scene.world.showSectionAndMerge(util.select.position(3, 5, 2), Direction.DOWN, newBelt);
scene.overlay.showText(80).pointAt(util.vector.blockSurface(tunnelPos.above().north(), Direction.WEST)).placeNearTarget().text("For this, items can also be inserted into the Tunnel block directly");
scene.idle(20);
beltPos = util.grid.at(3, 3, 3);
spawn = util.vector.centerOf(util.grid.at(3, 5, 1));
scene.world.createItemEntity(spawn, m, item1);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.EAST, item1);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.createItemEntity(spawn, m, item2);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.EAST, item2);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.world.createItemEntity(spawn, m, item3);
scene.idle(12);
scene.world.createItemOnBelt(beltPos, Direction.EAST, item3);
scene.world.modifyEntities(ItemEntity.class, Entity::discard);
scene.idle(30);
}
use of com.simibubi.create.content.logistics.block.belts.tunnel.BrassTunnelTileEntity in project Create by Creators-of-Create.
the class BeltTunnelInteractionHandler method flapTunnelsAndCheckIfStuck.
public static boolean flapTunnelsAndCheckIfStuck(BeltInventory beltInventory, TransportedItemStack current, float nextOffset) {
int currentSegment = (int) current.beltPosition;
int upcomingSegment = (int) nextOffset;
Direction movementFacing = beltInventory.belt.getMovementFacing();
if (!beltInventory.beltMovementPositive && nextOffset == 0)
upcomingSegment = -1;
if (currentSegment == upcomingSegment)
return false;
if (stuckAtTunnel(beltInventory, upcomingSegment, current.stack, movementFacing)) {
current.beltPosition = currentSegment + (beltInventory.beltMovementPositive ? .99f : .01f);
return true;
}
Level world = beltInventory.belt.getLevel();
boolean onServer = !world.isClientSide || beltInventory.belt.isVirtual();
boolean removed = false;
BeltTunnelTileEntity nextTunnel = getTunnelOnSegment(beltInventory, upcomingSegment);
if (nextTunnel instanceof BrassTunnelTileEntity) {
BrassTunnelTileEntity brassTunnel = (BrassTunnelTileEntity) nextTunnel;
if (brassTunnel.hasDistributionBehaviour()) {
if (!brassTunnel.canTakeItems())
return true;
if (onServer) {
brassTunnel.setStackToDistribute(current.stack);
current.stack = ItemStack.EMPTY;
beltInventory.belt.sendData();
beltInventory.belt.setChanged();
}
removed = true;
}
} else if (nextTunnel != null) {
BlockState blockState = nextTunnel.getBlockState();
if (current.stack.getCount() > 1 && AllBlocks.ANDESITE_TUNNEL.has(blockState) && BeltTunnelBlock.isJunction(blockState) && movementFacing.getAxis() == blockState.getValue(BeltTunnelBlock.HORIZONTAL_AXIS)) {
for (Direction d : Iterate.horizontalDirections) {
if (d.getAxis() == blockState.getValue(BeltTunnelBlock.HORIZONTAL_AXIS))
continue;
if (!nextTunnel.flaps.containsKey(d))
continue;
BlockPos outpos = nextTunnel.getBlockPos().below().relative(d);
if (!world.isLoaded(outpos))
return true;
DirectBeltInputBehaviour behaviour = TileEntityBehaviour.get(world, outpos, DirectBeltInputBehaviour.TYPE);
if (behaviour == null)
continue;
if (!behaviour.canInsertFromSide(d))
continue;
ItemStack toinsert = ItemHandlerHelper.copyStackWithSize(current.stack, 1);
if (!behaviour.handleInsertion(toinsert, d, false).isEmpty())
return true;
if (onServer)
flapTunnel(beltInventory, upcomingSegment, d, false);
current.stack.shrink(1);
beltInventory.belt.sendData();
if (current.stack.getCount() <= 1)
break;
}
}
}
if (onServer) {
flapTunnel(beltInventory, currentSegment, movementFacing, false);
flapTunnel(beltInventory, upcomingSegment, movementFacing.getOpposite(), true);
}
if (removed)
return true;
return false;
}
use of com.simibubi.create.content.logistics.block.belts.tunnel.BrassTunnelTileEntity in project Create by Creators-of-Create.
the class BeltTileEntity method tryInsertingFromSide.
private ItemStack tryInsertingFromSide(TransportedItemStack transportedStack, Direction side, boolean simulate) {
BeltTileEntity nextBeltController = getControllerTE();
ItemStack inserted = transportedStack.stack;
ItemStack empty = ItemStack.EMPTY;
if (nextBeltController == null)
return inserted;
BeltInventory nextInventory = nextBeltController.getInventory();
if (nextInventory == null)
return inserted;
BlockEntity teAbove = level.getBlockEntity(worldPosition.above());
if (teAbove instanceof BrassTunnelTileEntity) {
BrassTunnelTileEntity tunnelTE = (BrassTunnelTileEntity) teAbove;
if (tunnelTE.hasDistributionBehaviour()) {
if (!tunnelTE.getStackToDistribute().isEmpty())
return inserted;
if (!tunnelTE.testFlapFilter(side.getOpposite(), inserted))
return inserted;
if (!simulate) {
BeltTunnelInteractionHandler.flapTunnel(nextInventory, index, side.getOpposite(), true);
tunnelTE.setStackToDistribute(inserted);
}
return empty;
}
}
if (getSpeed() == 0)
return inserted;
if (getMovementFacing() == side.getOpposite())
return inserted;
if (!nextInventory.canInsertAtFromSide(index, side))
return inserted;
if (simulate)
return empty;
transportedStack = transportedStack.copy();
transportedStack.beltPosition = index + .5f - Math.signum(getDirectionAwareBeltMovementSpeed()) / 16f;
Direction movementFacing = getMovementFacing();
if (!side.getAxis().isVertical()) {
if (movementFacing != side) {
transportedStack.sideOffset = side.getAxisDirection().getStep() * .35f;
if (side.getAxis() == Axis.X)
transportedStack.sideOffset *= -1;
} else
transportedStack.beltPosition = getDirectionAwareBeltMovementSpeed() > 0 ? index : index + 1;
}
transportedStack.prevSideOffset = transportedStack.sideOffset;
transportedStack.insertedAt = index;
transportedStack.insertedFrom = side;
transportedStack.prevBeltPosition = transportedStack.beltPosition;
BeltTunnelInteractionHandler.flapTunnel(nextInventory, index, side.getOpposite(), true);
nextInventory.addItem(transportedStack);
nextBeltController.setChanged();
nextBeltController.sendData();
return empty;
}
use of com.simibubi.create.content.logistics.block.belts.tunnel.BrassTunnelTileEntity in project Create by Creators-of-Create.
the class BeltTunnelInteractionHandler method stuckAtTunnel.
public static boolean stuckAtTunnel(BeltInventory beltInventory, int offset, ItemStack stack, Direction movementDirection) {
BeltTileEntity belt = beltInventory.belt;
BlockPos pos = BeltHelper.getPositionForOffset(belt, offset).above();
if (!(belt.getLevel().getBlockState(pos).getBlock() instanceof BrassTunnelBlock))
return false;
BlockEntity te = belt.getLevel().getBlockEntity(pos);
if (te == null || !(te instanceof BrassTunnelTileEntity))
return false;
BrassTunnelTileEntity tunnel = (BrassTunnelTileEntity) te;
return !tunnel.canInsert(movementDirection.getOpposite(), stack);
}
Aggregations