From cb063d161c8aa4eca680d231a3e73b093aaa77f7 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 9 Mar 2021 21:17:02 +0100 Subject: [PATCH] Pondering about Windmills --- .../components/actors/HarvesterRenderer.java | 34 +-- .../actors/HarvesterTileEntity.java | 11 +- .../foundation/ponder/SceneBuilder.java | 9 + .../ponder/content/BearingScenes.java | 198 ++++++++++++++++++ .../ponder/content/PonderIndex.java | 6 + .../ponder/windmill_bearing/source.nbt | Bin 0 -> 820 bytes .../ponder/windmill_bearing/structure.nbt | Bin 0 -> 1120 bytes 7 files changed, 242 insertions(+), 16 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/ponder/content/BearingScenes.java create mode 100644 src/main/resources/ponder/windmill_bearing/source.nbt create mode 100644 src/main/resources/ponder/windmill_bearing/structure.nbt diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java index d3455237d..7a39b6233 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java @@ -35,7 +35,8 @@ public class HarvesterRenderer extends SafeTileEntityRenderer type) { super(type); } - + @Override public boolean hasFastRenderer() { return true; - } + } + + // For simulations such as Ponder + float manuallyAnimatedSpeed; + + public void setAnimatedSpeed(float speed) { + manuallyAnimatedSpeed = speed; + } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java index 7dc616f67..17ea8d9a0 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java @@ -596,6 +596,15 @@ public class SceneBuilder { modifyTileNBT(selection, teType, consumer, false); } + public void modifyTileEntity(BlockPos position, Class teType, + Consumer consumer) { + addInstruction(scene -> { + TileEntity tileEntity = scene.world.getTileEntity(position); + if (teType.isInstance(tileEntity)) + consumer.accept(teType.cast(tileEntity)); + }); + } + public void modifyTileNBT(Selection selection, Class teType, Consumer consumer, boolean reDrawBlocks) { addInstruction(new TileEntityDataInstruction(selection, teType, nbt -> { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/BearingScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/BearingScenes.java new file mode 100644 index 000000000..6358cf7ab --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/BearingScenes.java @@ -0,0 +1,198 @@ +package com.simibubi.create.foundation.ponder.content; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.content.contraptions.components.actors.HarvesterTileEntity; +import com.simibubi.create.content.contraptions.components.structureMovement.bearing.SailBlock; +import com.simibubi.create.foundation.ponder.ElementLink; +import com.simibubi.create.foundation.ponder.SceneBuilder; +import com.simibubi.create.foundation.ponder.SceneBuildingUtil; +import com.simibubi.create.foundation.ponder.Selection; +import com.simibubi.create.foundation.ponder.elements.InputWindowElement; +import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; +import com.simibubi.create.foundation.utility.Iterate; +import com.simibubi.create.foundation.utility.Pointing; + +import net.minecraft.util.Direction; +import net.minecraft.util.Direction.Axis; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +public class BearingScenes { + + public static void windmillsAsSource(SceneBuilder scene, SceneBuildingUtil util) { + scene.title("windmill_source", "Generating Rotational Force using Windmill Bearings"); + scene.world.showSection(util.select.fromTo(1, 0, 1, 5, 0, 5), Direction.UP); + scene.world.setBlock(util.grid.at(2, -1, 0), AllBlocks.SAIL.getDefaultState() + .with(SailBlock.FACING, Direction.NORTH), false); + scene.idle(5); + Selection kinetics = util.select.fromTo(3, 1, 1, 4, 1, 4); + Selection largeCog = util.select.position(3, 2, 2); + BlockPos windmill = util.grid.at(3, 2, 1); + scene.world.showSection(kinetics.add(largeCog), Direction.DOWN); + scene.idle(10); + + scene.world.showSection(util.select.position(windmill), Direction.DOWN); + scene.idle(10); + + BlockPos anchorPos = windmill.north(); + scene.overlay.showSelectionWithText(util.select.position(anchorPos), 60) + .colored(PonderPalette.GREEN) + .pointAt(util.vector.blockSurface(windmill, Direction.WEST)) + .placeNearTarget() + .text("Windmill Bearings attach to the block in front of them"); + scene.idle(50); + + ElementLink structure = + scene.world.showIndependentSection(util.select.position(anchorPos), Direction.SOUTH); + scene.idle(10); + for (Direction d : Iterate.directions) + if (d.getAxis() != Axis.Z) + scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.offset(d, 1), anchorPos.offset(d, 2)), + d.getOpposite(), structure); + scene.idle(10); + + scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.up() + .east(), + anchorPos.up(3) + .east()), + Direction.WEST, structure); + scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.down() + .west(), + anchorPos.down(3) + .west()), + Direction.EAST, structure); + scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.east() + .down(), + anchorPos.east(3) + .down()), + Direction.UP, structure); + scene.world.showSectionAndMerge(util.select.fromTo(anchorPos.west() + .up(), + anchorPos.west(3) + .up()), + Direction.DOWN, structure); + + scene.idle(5); + for (Direction d : Iterate.directions) + if (d.getAxis() != Axis.Z) + scene.effects.superGlue(anchorPos.offset(d, 1), d.getOpposite(), false); + scene.idle(10); + + scene.overlay.showText(60) + .pointAt(util.vector.blockSurface(anchorPos, Direction.NORTH)) + .placeNearTarget() + .text("If enough Sail-like blocks are attached to the block, it can act as a Windmill"); + scene.idle(70); + + scene.rotateCameraY(-90); + scene.idle(20); + + scene.overlay.showControls(new InputWindowElement(util.vector.topOf(windmill), Pointing.DOWN).rightClick(), 60); + scene.idle(7); + scene.world.rotateBearing(windmill, 360, 200); + scene.world.rotateSection(structure, 0, 0, 360, 200); + scene.world.setKineticSpeed(largeCog, 4); + scene.world.setKineticSpeed(kinetics, -8); + scene.effects.rotationDirectionIndicator(windmill.south()); + BlockPos gaugePos = util.grid.at(4, 1, 4); + scene.effects.indicateSuccess(gaugePos); + scene.idle(10); + + scene.overlay.showText(60) + .pointAt(util.vector.topOf(windmill)) + .placeNearTarget() + .text("Once Activated, the Windmill Bearing will start providing Rotational Force"); + scene.idle(70); + + scene.overlay.showText(60) + .pointAt(util.vector.blockSurface(gaugePos, Direction.WEST)) + .colored(PonderPalette.SLOW) + .placeNearTarget() + .text("The Amount of Sail Blocks determine its Rotation Speed"); + scene.idle(90); + + Vec3d surface = util.vector.blockSurface(windmill, Direction.WEST); + AxisAlignedBB point = new AxisAlignedBB(surface, surface); + AxisAlignedBB expanded = point.grow(1 / 16f, 1 / 4f, 1 / 4f); + + scene.overlay.showControls(new InputWindowElement(surface, Pointing.DOWN).scroll() + .withWrench(), 60); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.WHITE, point, point, 1); + scene.idle(1); + scene.overlay.chaseBoundingBoxOutline(PonderPalette.WHITE, point, expanded, 50); + scene.overlay.showText(60) + .pointAt(surface) + .placeNearTarget() + .text("Use a Wrench to configure its rotation direction"); + scene.idle(35); + + scene.world.rotateBearing(windmill, -90 - 45, 75); + scene.world.rotateSection(structure, 0, 0, -90 - 45, 75); + scene.world.modifyKineticSpeed(largeCog, f -> -f); + scene.world.modifyKineticSpeed(kinetics, f -> -f); + scene.effects.rotationDirectionIndicator(windmill.south()); + scene.idle(69); + + scene.overlay.showControls(new InputWindowElement(util.vector.topOf(windmill), Pointing.DOWN).rightClick(), 60); + scene.idle(7); + scene.world.rotateBearing(windmill, -45, 0); + scene.world.rotateSection(structure, 0, 0, -45, 0); + scene.world.setKineticSpeed(largeCog, 0); + scene.world.setKineticSpeed(kinetics, 0); + scene.idle(10); + scene.overlay.showText(60) + .pointAt(util.vector.topOf(windmill)) + .placeNearTarget() + .text("Right-click the Bearing anytime to stop and edit the Structure again"); + + } + + public static void windmillsAnyStructure(SceneBuilder scene, SceneBuildingUtil util) { + scene.title("windmill_structure", "Windmill Contraptions"); + scene.world.showSection(util.select.layer(0), Direction.UP); + scene.idle(5); + + BlockPos bearingPos = util.grid.at(3, 1, 3); + scene.world.showSection(util.select.position(bearingPos), Direction.DOWN); + scene.idle(10); + ElementLink contraption = + scene.world.showIndependentSection(util.select.position(bearingPos.up()), Direction.DOWN); + scene.idle(10); + scene.world.showSectionAndMerge(util.select.fromTo(3, 2, 2, 3, 3, 1), Direction.SOUTH, contraption); + scene.world.showSectionAndMerge(util.select.fromTo(3, 2, 4, 3, 3, 5), Direction.NORTH, contraption); + scene.idle(5); + scene.world.showSectionAndMerge(util.select.position(3, 1, 5), Direction.NORTH, contraption); + scene.world.showSectionAndMerge(util.select.position(3, 4, 2), Direction.DOWN, contraption); + scene.idle(5); + scene.world.showSectionAndMerge(util.select.position(2, 1, 5), Direction.EAST, contraption); + scene.world.showSectionAndMerge(util.select.position(3, 3, 3), Direction.DOWN, contraption); + scene.idle(5); + scene.effects.superGlue(bearingPos.up(), Direction.SOUTH, true); + scene.effects.superGlue(bearingPos.up(), Direction.NORTH, true); + scene.idle(5); + scene.effects.superGlue(util.grid.at(3, 1, 5), Direction.UP, true); + scene.idle(5); + scene.effects.superGlue(util.grid.at(3, 3, 3), Direction.DOWN, true); + scene.idle(10); + + scene.overlay.showOutline(PonderPalette.BLUE, bearingPos, util.select.fromTo(3, 2, 1, 3, 3, 2), 80); + scene.overlay.showSelectionWithText(util.select.fromTo(3, 2, 4, 3, 3, 5), 80) + .colored(PonderPalette.BLUE) + .text("Any Structure can count as a valid Windmill, as long as it contains at least 8 sail-like Blocks."); + + scene.idle(90); + scene.overlay.showControls( + new InputWindowElement(util.vector.blockSurface(bearingPos, Direction.WEST), Pointing.LEFT).rightClick(), + 40); + scene.idle(7); + scene.world.rotateBearing(bearingPos, -720, 400); + scene.world.rotateSection(contraption, 0, -720, 0, 400); + scene.world.modifyTileEntity(util.grid.at(2, 1, 5), HarvesterTileEntity.class, + hte -> hte.setAnimatedSpeed(-150)); + scene.markAsFinished(); + scene.idle(400); + scene.world.modifyTileEntity(util.grid.at(2, 1, 5), HarvesterTileEntity.class, hte -> hte.setAnimatedSpeed(0)); + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java index 40cad7990..63438e8ec 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndex.java @@ -77,6 +77,12 @@ public class PonderIndex { .addStoryBoard("funnels/transposer", FunnelScenes::transposer); PonderRegistry.addStoryBoard(AllBlocks.ANDESITE_FUNNEL, "funnels/brass", FunnelScenes::brass); + // Windmill Bearing + PonderRegistry.forComponents(AllBlocks.WINDMILL_BEARING) + .addStoryBoard("windmill_bearing/source", BearingScenes::windmillsAsSource, PonderTag.KINETIC_SOURCES) + .addStoryBoard("windmill_bearing/structure", BearingScenes::windmillsAnyStructure, + PonderTag.MOVEMENT_ANCHOR); + // Gantries PonderRegistry.addStoryBoard(AllBlocks.GANTRY_SHAFT, "gantry/intro", GantryScenes::introForShaft, PonderTag.KINETIC_APPLIANCES, PonderTag.MOVEMENT_ANCHOR); diff --git a/src/main/resources/ponder/windmill_bearing/source.nbt b/src/main/resources/ponder/windmill_bearing/source.nbt new file mode 100644 index 0000000000000000000000000000000000000000..7426cb759b0f4772e35b997be901d16eb98e21e7 GIT binary patch literal 820 zcmV-41Izp$iwFP!000000L50{Z__Xkb`qz*wy}Zu`I=``A?*e24GqK#8i5JKhMhr3t)4$*)L z!wjPumDdpUCR`?$dIW!thbYLUu8qpuN7X~94KZ|O(ZqOYd3gb?c%`> zJfQ;HfnS4z&mzYO#$6JMe@KJhf)*kZ0_W=WRUL zfhTm}sWpcVc@7=&yp0Dt@Pt;L5eme_geW}EDV>(*#eZhBO*g&&7frKa`;KnFY1dT&C;Qm$$1$#te-UDWHeImCatrBCd{c>(%G0h9hE1b!AU&l70$Oq`CG>r+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