use of com.simibubi.create.content.contraptions.relays.encased.EncasedCogwheelBlock in project Create by Creators-of-Create.
the class CogWheelBlock method use.
@Override
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult ray) {
if (player.isShiftKeyDown() || !player.mayBuild())
return InteractionResult.PASS;
ItemStack heldItem = player.getItemInHand(hand);
EncasedCogwheelBlock[] encasedBlocks = isLarge ? new EncasedCogwheelBlock[] { AllBlocks.ANDESITE_ENCASED_LARGE_COGWHEEL.get(), AllBlocks.BRASS_ENCASED_LARGE_COGWHEEL.get() } : new EncasedCogwheelBlock[] { AllBlocks.ANDESITE_ENCASED_COGWHEEL.get(), AllBlocks.BRASS_ENCASED_COGWHEEL.get() };
for (EncasedCogwheelBlock encasedCog : encasedBlocks) {
if (!encasedCog.getCasing().isIn(heldItem))
continue;
if (world.isClientSide)
return InteractionResult.SUCCESS;
BlockState encasedState = encasedCog.defaultBlockState().setValue(AXIS, state.getValue(AXIS));
for (Direction d : Iterate.directionsInAxis(state.getValue(AXIS))) {
BlockState adjacentState = world.getBlockState(pos.relative(d));
if (!(adjacentState.getBlock() instanceof IRotate))
continue;
IRotate def = (IRotate) adjacentState.getBlock();
if (!def.hasShaftTowards(world, pos.relative(d), adjacentState, d.getOpposite()))
continue;
encasedState = encasedState.cycle(d.getAxisDirection() == AxisDirection.POSITIVE ? EncasedCogwheelBlock.TOP_SHAFT : EncasedCogwheelBlock.BOTTOM_SHAFT);
}
KineticTileEntity.switchToBlockState(world, pos, encasedState);
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
}
use of com.simibubi.create.content.contraptions.relays.encased.EncasedCogwheelBlock in project Create by Creators-of-Create.
the class KineticsScenes method cogwheelsCanBeEncased.
public static void cogwheelsCanBeEncased(SceneBuilder scene, SceneBuildingUtil util) {
scene.title("cogwheel_casing", "Encasing Cogwheels");
scene.configureBasePlate(0, 0, 5);
scene.world.showSection(util.select.layer(0), Direction.UP);
Selection large1 = util.select.position(4, 1, 3);
Selection small1 = util.select.fromTo(3, 1, 2, 3, 2, 2);
Selection small2 = util.select.position(2, 1, 2);
Selection large2 = util.select.fromTo(1, 1, 3, 1, 1, 4);
Selection shaft2 = util.select.position(2, 2, 2);
scene.world.setKineticSpeed(shaft2, 0);
scene.idle(10);
scene.world.showSection(large1, Direction.DOWN);
scene.idle(5);
scene.world.showSection(small1, Direction.DOWN);
scene.world.showSection(small2, Direction.DOWN);
scene.idle(5);
scene.world.showSection(large2, Direction.EAST);
scene.idle(20);
BlockEntry<EncasedCogwheelBlock> andesiteEncased = AllBlocks.ANDESITE_ENCASED_COGWHEEL;
ItemStack andesiteCasingItem = AllBlocks.ANDESITE_CASING.asStack();
scene.overlay.showControls(new InputWindowElement(util.vector.topOf(3, 0, 2), Pointing.UP).rightClick().withItem(andesiteCasingItem), 100);
scene.idle(7);
scene.world.setBlocks(util.select.position(3, 1, 2), andesiteEncased.getDefaultState().setValue(EncasedCogwheelBlock.AXIS, Axis.Y).setValue(EncasedCogwheelBlock.TOP_SHAFT, true), true);
scene.world.setKineticSpeed(util.select.position(3, 1, 2), -32);
scene.idle(15);
scene.overlay.showControls(new InputWindowElement(util.vector.topOf(2, 1, 2), Pointing.DOWN).rightClick().withItem(andesiteCasingItem), 30);
scene.idle(7);
scene.world.setBlocks(small2, andesiteEncased.getDefaultState().setValue(EncasedCogwheelBlock.AXIS, Axis.Y), true);
scene.world.setKineticSpeed(small2, 32);
scene.idle(15);
BlockEntry<EncasedCogwheelBlock> brassEncased = AllBlocks.BRASS_ENCASED_LARGE_COGWHEEL;
ItemStack brassCasingItem = AllBlocks.BRASS_CASING.asStack();
scene.overlay.showControls(new InputWindowElement(util.vector.topOf(1, 0, 3), Pointing.UP).rightClick().withItem(brassCasingItem), 60);
scene.idle(7);
scene.world.setBlocks(util.select.position(1, 1, 3), brassEncased.getDefaultState().setValue(EncasedCogwheelBlock.AXIS, Axis.Y), true);
scene.world.setKineticSpeed(util.select.position(1, 1, 3), -16);
scene.idle(10);
scene.overlay.showText(70).placeNearTarget().attachKeyFrame().text("Brass or Andesite Casing can be used to decorate Cogwheels").pointAt(util.vector.topOf(1, 1, 3));
scene.idle(80);
ElementLink<WorldSectionElement> shaftLink = scene.world.showIndependentSection(shaft2, Direction.DOWN);
scene.idle(15);
scene.overlay.showText(90).placeNearTarget().colored(PonderPalette.RED).attachKeyFrame().text("Components added after encasing will not connect to the shaft outputs").pointAt(util.vector.centerOf(2, 2, 2));
scene.idle(90);
scene.world.moveSection(shaftLink, new Vec3(0, .5f, 0), 10);
scene.idle(10);
scene.addKeyframe();
Vec3 wrenchHere = util.vector.topOf(2, 1, 2).add(.25, 0, -.25);
scene.overlay.showControls(new InputWindowElement(wrenchHere, Pointing.RIGHT).rightClick().withWrench(), 25);
scene.idle(7);
scene.world.cycleBlockProperty(util.grid.at(2, 1, 2), EncasedCogwheelBlock.TOP_SHAFT);
scene.idle(15);
scene.world.moveSection(shaftLink, new Vec3(0, -.5f, 0), 10);
scene.idle(10);
scene.world.setKineticSpeed(shaft2, 32);
scene.effects.rotationDirectionIndicator(util.grid.at(2, 2, 2));
scene.idle(20);
scene.overlay.showText(90).placeNearTarget().colored(PonderPalette.GREEN).text("The Wrench can be used to toggle connections").pointAt(wrenchHere.add(-.5, 0, .5));
scene.idle(40);
scene.overlay.showControls(new InputWindowElement(wrenchHere, Pointing.RIGHT).rightClick().withWrench(), 25);
scene.idle(7);
scene.world.cycleBlockProperty(util.grid.at(2, 1, 2), EncasedCogwheelBlock.TOP_SHAFT);
scene.world.setKineticSpeed(shaft2, 0);
}
Aggregations