diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java index f3814c3e3..6ff654402 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java @@ -58,7 +58,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer { @@ -36,7 +37,8 @@ public class HarvesterRenderer extends SafeTileEntityRenderer ms.translate(0, isBlockItem ? 9 / 16f : 11 / 16f, 0); ms.scale(scale, scale, scale); transform = TransformType.GROUND; - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(AnimationTickHolder.getRenderTime())); + ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(AnimationTickHolder.getRenderTime(te.getWorld()))); } else { float scale = punching ? .75f : isBlockItem ? .75f - 1 / 64f : .5f; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java index 6421411d3..cb469d615 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java @@ -41,7 +41,7 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer { SuperByteBuffer fanInner = AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectionalSouth(te.getBlockState(), direction.getOpposite()); - float time = AnimationTickHolder.getRenderTime(); + float time = AnimationTickHolder.getRenderTime(te.getWorld()); float speed = te.getSpeed() * 5; if (speed > 0) speed = MathHelper.clamp(speed, 80, 64 * 20); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java index 5ad5963e0..41635cb02 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java @@ -46,7 +46,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer { int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos); float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks); float speed = mixer.getRenderedHeadRotationSpeed(partialTicks); - float time = AnimationTickHolder.getRenderTime(); + float time = AnimationTickHolder.getRenderTime(te.getWorld()); float angle = ((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI; SuperByteBuffer poleRender = AllBlockPartials.MECHANICAL_MIXER_POLE.renderOn(blockState); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java index 0010a4755..271992288 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java @@ -72,7 +72,7 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer { } public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) { - float time = AnimationTickHolder.getRenderTime(); + float time = AnimationTickHolder.getRenderTime(te.getWorld()); float offset = getRotationOffsetForPosition(te, pos, axis); return ((time * te.getSpeed() * 3f / 20 + offset) % 360) / 180 * (float) Math.PI; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticle.java index f9b754484..43e871aa2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/RotationIndicatorParticle.java @@ -67,7 +67,7 @@ public class RotationIndicatorParticle extends SimpleAnimatedParticle { } public void move(double x, double y, double z) { - float time = AnimationTickHolder.getTicks(); + float time = AnimationTickHolder.getTicks(world); float angle = (float) ((time * speed) % 360) - (speed / 2 * age * (((float) age) / maxAge)); if (speed < 0 && axis.isVertical()) angle += 180; diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java index 618816da2..72d80ad6b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java @@ -72,8 +72,9 @@ public class BasinRenderer extends SmartTileEntityRenderer { if (fluidLevel > 0) { ms.translate(0, - (MathHelper.sin(AnimationTickHolder.getRenderTime() / 12f + anglePartition * itemCount) + 1.5f) * 1 - / 32f, + (MathHelper.sin( + AnimationTickHolder.getRenderTime(basin.getWorld()) / 12f + anglePartition * itemCount) + 1.5f) + * 1 / 32f, 0); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java index 458035ec9..df11ef484 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java @@ -27,7 +27,7 @@ public class BlazeBurnerRenderer extends SafeTileEntityRenderer { MatrixStack localTransforms = new MatrixStack(); MatrixStacker msr = MatrixStacker.of(localTransforms); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); - float renderTick = AnimationTickHolder.getRenderTime(); + float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()); msr.centre(); msr.rotateY(AngleHelper.horizontalAngle(facing) + (upward ? 180 : 0) + (sideways ? 270 : 0)); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java index 1d4531a36..a1cf575af 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java @@ -32,7 +32,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer { Block block = te.getBlockState().getBlock(); final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState()); final BlockPos pos = te.getPos(); - float time = AnimationTickHolder.getRenderTime(); + float time = AnimationTickHolder.getRenderTime(te.getWorld()); for (Direction direction : Iterate.directions) { Axis axis = direction.getAxis(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java index 601aedc49..45463f007 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java @@ -30,7 +30,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer { final Axis boxAxis = te.getBlockState().get(BlockStateProperties.AXIS); final BlockPos pos = te.getPos(); - float time = AnimationTickHolder.getRenderTime(); + float time = AnimationTickHolder.getRenderTime(te.getWorld()); for (Direction direction : Iterate.directions) { final Axis axis = direction.getAxis(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java index 2675f8550..e4e00e69c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInstance.java @@ -95,7 +95,7 @@ public class ArmInstance extends SingleRotatingInstance implements ITickableInst float headAngle = arm.headAngle.get(pt); if (rave) { - float renderTick = AnimationTickHolder.getRenderTime() + (tile.hashCode() % 64); + float renderTick = AnimationTickHolder.getRenderTime(arm.getWorld()) + (tile.hashCode() % 64); baseAngle = (renderTick * 10) % 360; lowerArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 4) + 1) / 2, -45, 15); upperArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 8) + 1) / 4, -45, 95); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java index 79d3c3765..9f4c6224e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java @@ -69,7 +69,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { float headAngle = arm.headAngle.get(pt); boolean rave = arm.phase == Phase.DANCING; - float renderTick = AnimationTickHolder.getRenderTime() + (te.hashCode() % 64); + float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()) + (te.hashCode() % 64); if (rave) { baseAngle = (renderTick * 10) % 360; lowerArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 4) + 1) / 2, -45, 15); diff --git a/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java b/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java index 17806fb70..577ea8028 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java +++ b/src/main/java/com/simibubi/create/foundation/gui/AllIcons.java @@ -122,7 +122,8 @@ public class AllIcons implements IScreenRenderable { I_MTD_CLOSE = next(), I_MTD_RIGHT = next(), I_MTD_SCAN = next(), - I_MTD_REPLAY = next(); + I_MTD_REPLAY = next(), + I_MTD_USER_MODE = next(); public AllIcons(int x, int y) { iconX = x * 16; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java index 6209624bc..2f1abec45 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderTooltipHandler.java @@ -95,7 +95,8 @@ public class PonderTooltipHandler { } public static void addToTooltip(List toolTip, ItemStack stack) { - float renderPartialTicks = AnimationTickHolder.getPartialTicks(); + float renderPartialTicks = Minecraft.getInstance() + .getRenderPartialTicks(); if (lastHoveredStack != stack) return; ITextComponent component = subject ? Lang.createTranslationTextComponent(SUBJECT) diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java index f9ac2c8a6..c17df5a2e 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderUI.java @@ -38,6 +38,7 @@ import net.minecraft.client.GameSettings; import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.settings.KeyBinding; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; @@ -55,6 +56,9 @@ import net.minecraftforge.registries.ForgeRegistries; public class PonderUI extends AbstractSimiScreen { + public static int ponderTicks; + public static float ponderPartialTicksPaused; + public static final String PONDERING = PonderLocalization.LANG_PREFIX + "pondering"; public static final String IDENTIFY_MODE = PonderLocalization.LANG_PREFIX + "identify_mode"; public static final String IN_CHAPTER = PonderLocalization.LANG_PREFIX + "in_chapter"; @@ -68,6 +72,7 @@ public class PonderUI extends AbstractSimiScreen { ItemStack stack; PonderChapter chapter = null; + private boolean userViewMode; private boolean identifyMode; private ItemStack hoveredTooltipItem; private BlockPos hoveredBlockPos; @@ -79,7 +84,7 @@ public class PonderUI extends AbstractSimiScreen { private int index = 0; private PonderTag referredToByTag; - private PonderButton left, right, scan, chap; + private PonderButton left, right, scan, chap, userMode; public static PonderUI of(ItemStack item) { return new PonderUI(PonderRegistry.compile(item.getItem() @@ -165,10 +170,19 @@ public class PonderUI extends AbstractSimiScreen { if (!identifyMode) scenes.get(index) .deselect(); + else + ponderPartialTicksPaused = minecraft.getRenderPartialTicks(); }).showing(AllIcons.I_MTD_SCAN) .shortcut(bindings.keyBindDrop) .fade(0, -1)); + if (PonderIndex.EDITOR_MODE) { + widgets.add(userMode = new PonderButton(31, bY, () -> { + userViewMode = !userViewMode; + }).showing(AllIcons.I_MTD_USER_MODE) + .fade(0, -1)); + } + bX += 50 + spacing; widgets.add(left = new PonderButton(bX, bY, () -> this.scroll(false)).showing(AllIcons.I_MTD_LEFT) .shortcut(bindings.keyBindLeft) @@ -215,8 +229,10 @@ public class PonderUI extends AbstractSimiScreen { } PonderScene activeScene = scenes.get(index); - if (!identifyMode) + if (!identifyMode) { + ponderTicks++; activeScene.tick(); + } sceneProgress.chase(activeScene.getSceneProgress(), .5f, Chaser.EXP); lazyIndex.tickChaser(); fadeIn.tickChaser(); @@ -295,8 +311,8 @@ public class PonderUI extends AbstractSimiScreen { @Override protected void renderWindow(int mouseX, int mouseY, float partialTicks) { RenderSystem.enableBlend(); - renderVisibleScenes(mouseX, mouseY, identifyMode ? 0 : partialTicks); - renderWidgets(mouseX, mouseY, identifyMode ? 0 : partialTicks); + renderVisibleScenes(mouseX, mouseY, identifyMode ? ponderPartialTicksPaused : partialTicks); + renderWidgets(mouseX, mouseY, identifyMode ? ponderPartialTicksPaused : partialTicks); } protected void renderVisibleScenes(int mouseX, int mouseY, float partialTicks) { @@ -310,7 +326,7 @@ public class PonderUI extends AbstractSimiScreen { SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance(); PonderScene story = scenes.get(i); MatrixStack ms = new MatrixStack(); - double value = lazyIndex.getValue(AnimationTickHolder.getPartialTicks()); + double value = lazyIndex.getValue(AnimationTickHolder.getPartialTicks(story.world)); double diff = i - value; double slide = MathHelper.lerp(diff * diff, 200, 600) * diff; @@ -326,7 +342,7 @@ public class PonderUI extends AbstractSimiScreen { buffer.draw(); // coords for debug - if (PonderIndex.EDITOR_MODE) { + if (PonderIndex.EDITOR_MODE && !userViewMode) { MutableBoundingBox bounds = story.getBounds(); RenderSystem.pushMatrix(); @@ -388,6 +404,10 @@ public class PonderUI extends AbstractSimiScreen { PonderScene activeScene = scenes.get(index); int textColor = 0xeeeeee; + boolean noWidgetsHovered = true; + for (Widget widget : widgets) + noWidgetsHovered &= !widget.isMouseOver(mouseX, mouseY); + { // Chapter title RenderSystem.pushMatrix(); @@ -433,34 +453,43 @@ public class PonderUI extends AbstractSimiScreen { } if (identifyMode) { - RenderSystem.pushMatrix(); - RenderSystem.translated(mouseX, mouseY, 100); - if (hoveredTooltipItem.isEmpty()) { - String tooltip = Lang - .createTranslationTextComponent(IDENTIFY_MODE, - new StringTextComponent(minecraft.gameSettings.keyBindDrop.getKeyBinding() - .getLocalizedName()).applyTextStyle(TextFormatting.WHITE)) - .applyTextStyle(TextFormatting.GRAY) - .getFormattedText(); - renderTooltip(font.listFormattedStringToWidth(tooltip, width / 3), 0, 0); - } else - renderTooltip(hoveredTooltipItem, 0, 0); - if (hoveredBlockPos != null && PonderIndex.EDITOR_MODE) { - RenderSystem.translated(0, -15, 0); - boolean copied = copiedBlockPos != null && hoveredBlockPos.equals(copiedBlockPos); - String coords = new StringTextComponent( - hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ()) - .applyTextStyles(copied ? TextFormatting.GREEN : TextFormatting.GOLD) + if (noWidgetsHovered) { + RenderSystem.pushMatrix(); + RenderSystem.translated(mouseX, mouseY, 100); + if (hoveredTooltipItem.isEmpty()) { + String tooltip = Lang + .createTranslationTextComponent(IDENTIFY_MODE, + new StringTextComponent(minecraft.gameSettings.keyBindDrop.getKeyBinding() + .getLocalizedName()).applyTextStyle(TextFormatting.WHITE)) + .applyTextStyle(TextFormatting.GRAY) .getFormattedText(); - renderTooltip(coords, 0, 0); + renderTooltip(font.listFormattedStringToWidth(tooltip, width / 3), 0, 0); + } else + renderTooltip(hoveredTooltipItem, 0, 0); + if (hoveredBlockPos != null && PonderIndex.EDITOR_MODE && !userViewMode) { + RenderSystem.translated(0, -15, 0); + boolean copied = copiedBlockPos != null && hoveredBlockPos.equals(copiedBlockPos); + String coords = new StringTextComponent( + hoveredBlockPos.getX() + ", " + hoveredBlockPos.getY() + ", " + hoveredBlockPos.getZ()) + .applyTextStyles(copied ? TextFormatting.GREEN : TextFormatting.GOLD) + .getFormattedText(); + renderTooltip(coords, 0, 0); + } + RenderSystem.popMatrix(); } - RenderSystem.popMatrix(); scan.flash(); } else { scan.dim(); } + if (PonderIndex.EDITOR_MODE) { + if (userViewMode) + userMode.flash(); + else + userMode.dim(); + } + { // Scene overlay RenderSystem.pushMatrix(); @@ -777,8 +806,25 @@ public class PonderUI extends AbstractSimiScreen { @Override public void shareContextWith(AbstractSimiScreen other) { - if (other instanceof PonderUI) - ((PonderUI) other).referredToByTag = referredToByTag; + if (other instanceof PonderUI) { + PonderUI ponderUI = (PonderUI) other; + ponderUI.referredToByTag = referredToByTag; + } + } + + public static float getPartialTicks() { + if (Minecraft.getInstance().currentScreen instanceof PonderUI) { + PonderUI ui = (PonderUI) Minecraft.getInstance().currentScreen; + if (ui.identifyMode) + return ponderPartialTicksPaused; + } + return Minecraft.getInstance() + .getRenderPartialTicks(); + } + + @Override + public boolean isPauseScreen() { + return true; } } 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 5bfe87504..a6dbd20a9 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java @@ -525,7 +525,7 @@ public class SceneBuilder { return; behaviour.handleInsertion(stack, insertionSide.getOpposite(), false); }); - flapFunnels(scene.getSceneBuildingUtil().select.position(location.up()), true); + flapFunnel(location.up(), true); } public ElementLink createItemOnBelt(BlockPos beltLocation, Direction insertionSide, @@ -553,9 +553,8 @@ public class SceneBuilder { scene.linkElement(tracker, link); return TransportedResult.doNothing(); }); - }); - flapFunnels(scene.getSceneBuildingUtil().select.position(beltLocation.up()), true); + flapFunnel(beltLocation.up(), true); return link; } @@ -633,11 +632,8 @@ public class SceneBuilder { }, reDrawBlocks)); } - public void flapFunnels(Selection selection, boolean outward) { - addInstruction(new TileEntityDataInstruction(selection, FunnelTileEntity.class, nbt -> { - nbt.putInt("Flap", outward ? -1 : 1); - return nbt; - }, false)); + public void flapFunnel(BlockPos position, boolean outward) { + modifyTileEntity(position, FunnelTileEntity.class, funnel -> funnel.flap(!outward)); } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/FunnelScenes.java b/src/main/java/com/simibubi/create/foundation/ponder/content/FunnelScenes.java index f6fee510c..c8f9c6c44 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/FunnelScenes.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/FunnelScenes.java @@ -52,12 +52,11 @@ public class FunnelScenes { BlockPos entryBeltPos = util.grid.at(3, 1, 2); BlockPos exitBeltPos = util.grid.at(1, 1, 2); ItemStack itemStack = AllBlocks.BRASS_BLOCK.asStack(); - Selection exitFunnel = util.select.position(exitBeltPos.up()); for (int i = 0; i < 8; i++) { scene.idle(8); scene.world.removeItemsFromBelt(exitBeltPos); - scene.world.flapFunnels(exitFunnel, false); + scene.world.flapFunnel(exitBeltPos.up(), false); if (i == 2) scene.rotateCameraY(70); if (i < 6) @@ -94,7 +93,7 @@ public class FunnelScenes { for (int i = 0; i < 3; i++) { scene.idle(8); - scene.world.flapFunnels(outputFunnel, false); + scene.world.flapFunnel(util.grid.at(1, 2, 4), false); scene.world.createItemEntity(sideItemSpawn, util.vector.of(-.05, 0, 0), itemStack); } @@ -198,7 +197,7 @@ public class FunnelScenes { scene.idle(20); - scene.world.flapFunnels(sideFunnelSelection, true); + scene.world.flapFunnel(sideFunnel, true); itemLink = scene.world.createItemEntity(sideCenter.subtract(0, .45, 0), util.vector.of(0, 0, -0.1), itemStack); scene.idle(60); scene.world.hideSection(sideFunnelSelection, Direction.UP); @@ -233,7 +232,7 @@ public class FunnelScenes { scene.idle(35); scene.world.removeItemsFromBelt(beltPos); - scene.world.flapFunnels(beltFunnelSetup, false); + scene.world.flapFunnel(util.grid.at(2, 2, 2), false); if (i == 0) { scene.idle(50); @@ -374,7 +373,7 @@ public class FunnelScenes { scene.idle(10); scene.world.createItemOnBeltLike(andesiteFunnel.down() .north(), Direction.SOUTH, itemStack); - scene.world.flapFunnels(util.select.position(andesiteFunnel), true); + scene.world.flapFunnel(andesiteFunnel, true); scene.idle(60); scene.overlay.showText(60) @@ -384,7 +383,7 @@ public class FunnelScenes { scene.idle(10); scene.world.createItemOnBeltLike(brassFunnel.down() .north(), Direction.SOUTH, ItemHandlerHelper.copyStackWithSize(itemStack, 64)); - scene.world.flapFunnels(util.select.position(brassFunnel), true); + scene.world.flapFunnel(brassFunnel, true); scene.idle(60); AxisAlignedBB filterSlot = new AxisAlignedBB(brassFunnel).grow(-.35, -.35, -.35) @@ -421,7 +420,7 @@ public class FunnelScenes { if (i > 0 && (i < 3 || i % 3 == 0)) { scene.world.removeItemsFromBelt(brassFunnel.down()); - scene.world.flapFunnels(util.select.position(brassFunnel), false); + scene.world.flapFunnel(brassFunnel, false); } scene.world.modifyEntities(ItemEntity.class, e -> { diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java index 364ce0797..15f3e70f8 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderIndexScreen.java @@ -49,43 +49,39 @@ public class PonderIndexScreen extends AbstractSimiScreen { protected void init() { super.init(); - //populate lists + // populate lists widgets.clear(); chapters.clear(); - //chapters.addAll(PonderRegistry.chapters.getAllChapters()); + // chapters.addAll(PonderRegistry.chapters.getAllChapters()); items.clear(); PonderRegistry.all.keySet() - .stream() - .map(key -> { - Item item = ForgeRegistries.ITEMS.getValue(key); - if (item == null) { - Block b = ForgeRegistries.BLOCKS.getValue(key); - if (b != null) - item = b.asItem(); - } - return item; - }) - .filter(Objects::nonNull) - .filter(PonderIndexScreen::exclusions) - .forEach(items::add); + .stream() + .map(key -> { + Item item = ForgeRegistries.ITEMS.getValue(key); + if (item == null) { + Block b = ForgeRegistries.BLOCKS.getValue(key); + if (b != null) + item = b.asItem(); + } + return item; + }) + .filter(Objects::nonNull) + .filter(PonderIndexScreen::exclusions) + .forEach(items::add); boolean hasChapters = !chapters.isEmpty(); - //setup chapters - LayoutHelper layout = LayoutHelper.centeredHorizontal( - chapters.size(), - MathHelper.clamp((int) Math.ceil(chapters.size() / 4f), 1, 4), - 200, - 38, - 16 - ); + // setup chapters + LayoutHelper layout = LayoutHelper.centeredHorizontal(chapters.size(), + MathHelper.clamp((int) Math.ceil(chapters.size() / 4f), 1, 4), 200, 38, 16); chapterArea = layout.getArea(); int chapterCenterX = (int) (width * chapterXmult); int chapterCenterY = (int) (height * chapterYmult); - //todo at some point pagination or horizontal scrolling may be needed for chapters/items + // todo at some point pagination or horizontal scrolling may be needed for + // chapters/items for (PonderChapter chapter : chapters) { ChapterLabel label = new ChapterLabel(chapter, chapterCenterX + layout.getX(), chapterCenterY + layout.getY(), (mouseX, mouseY) -> { @@ -97,44 +93,40 @@ public class PonderIndexScreen extends AbstractSimiScreen { layout.next(); } - //setup items + // setup items if (!hasChapters) { itemYmult = 0.5; } int maxItemRows = hasChapters ? 4 : 7; - layout = LayoutHelper.centeredHorizontal( - items.size(), - MathHelper.clamp((int) Math.ceil(items.size() / 11f), 1, maxItemRows), - 28, - 28, - 8 - ); + layout = LayoutHelper.centeredHorizontal(items.size(), + MathHelper.clamp((int) Math.ceil(items.size() / 11f), 1, maxItemRows), 28, 28, 8); itemArea = layout.getArea(); int itemCenterX = (int) (width * itemXmult); int itemCenterY = (int) (height * itemYmult); for (Item item : items) { - PonderButton button = new PonderButton(itemCenterX + layout.getX() + 4, itemCenterY + layout.getY() + 4, (x, y) -> { - if (!PonderRegistry.all.containsKey(item.getRegistryName())) - return; + PonderButton button = + new PonderButton(itemCenterX + layout.getX() + 4, itemCenterY + layout.getY() + 4, (x, y) -> { + if (!PonderRegistry.all.containsKey(item.getRegistryName())) + return; - centerScalingOn(x, y); - ScreenOpener.transitionTo(PonderUI.of(new ItemStack(item))); - }).showing(new ItemStack(item)); + centerScalingOn(x, y); + ScreenOpener.transitionTo(PonderUI.of(new ItemStack(item))); + }).showing(new ItemStack(item)); button.fade(1); widgets.add(button); layout.next(); } - } private static boolean exclusions(Item item) { if (item instanceof BlockItem) { Block block = ((BlockItem) item).getBlock(); - if (block instanceof ValveHandleBlock && !AllBlocks.COPPER_VALVE_HANDLE.is(item)) return false; + if (block instanceof ValveHandleBlock && !AllBlocks.COPPER_VALVE_HANDLE.is(item)) + return false; } return true; @@ -143,6 +135,7 @@ public class PonderIndexScreen extends AbstractSimiScreen { @Override public void tick() { super.tick(); + PonderUI.ponderTicks++; hoveredItem = ItemStack.EMPTY; MainWindow w = minecraft.getWindow(); @@ -224,4 +217,9 @@ public class PonderIndexScreen extends AbstractSimiScreen { public ItemStack getHoveredTooltipItem() { return hoveredItem; } + + @Override + public boolean isPauseScreen() { + return true; + } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagScreen.java b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagScreen.java index 8c03321c9..a443af1f2 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagScreen.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/content/PonderTagScreen.java @@ -77,13 +77,16 @@ public class PonderTagScreen extends AbstractSimiScreen { int itemCenterY = getItemsY(); for (Item i : items) { + final boolean canClick = PonderRegistry.all.containsKey(i.getRegistryName()); PonderButton button = new PonderButton(itemCenterX + layout.getX() + 4, itemCenterY + layout.getY() + 4, (mouseX, mouseY) -> { - if (!PonderRegistry.all.containsKey(i.getRegistryName())) + if (!canClick) return; centerScalingOn(mouseX, mouseY); ScreenOpener.transitionTo(PonderUI.of(new ItemStack(i), tag)); }).showing(new ItemStack(i)); + if (!canClick) + button.noClickEvent(); button.fade(1); widgets.add(button); @@ -92,18 +95,20 @@ public class PonderTagScreen extends AbstractSimiScreen { if (!tag.getMainItem() .isEmpty()) { + final boolean canClick = PonderRegistry.all.containsKey(tag.getMainItem() + .getItem() + .getRegistryName()); PonderButton button = new PonderButton(itemCenterX - layout.getTotalWidth() / 2 - 42, itemCenterY - 10, (mouseX, mouseY) -> { - if (!PonderRegistry.all.containsKey(tag.getMainItem() - .getItem() - .getRegistryName())) + if (!canClick) return; centerScalingOn(mouseX, mouseY); ScreenOpener.transitionTo(PonderUI.of(tag.getMainItem(), tag)); }).showing(tag.getMainItem()); + if (!canClick) + button.noClickEvent(); button.fade(1); -// button.flash(); widgets.add(button); } @@ -133,6 +138,7 @@ public class PonderTagScreen extends AbstractSimiScreen { @Override public void tick() { super.tick(); + PonderUI.ponderTicks++; hoveredItem = ItemStack.EMPTY; MainWindow w = minecraft.getWindow(); @@ -291,5 +297,10 @@ public class PonderTagScreen extends AbstractSimiScreen { return tag == ((PonderTagScreen) other).tag; return super.isEquivalentTo(other); } + + @Override + public boolean isPauseScreen() { + return true; + } } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java index cd7043524..c2ea78695 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/ParrotElement.java @@ -6,9 +6,9 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.ponder.PonderScene; +import com.simibubi.create.foundation.ponder.PonderUI; import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.utility.AngleHelper; -import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; import net.minecraft.client.MainWindow; @@ -170,7 +170,7 @@ public class ParrotElement extends AnimatedSceneElement { .length(); entity.onGround = false; double phase = Math.min(length * 15, 8); - float f = (float) ((AnimationTickHolder.getTicks() % 100) * phase); + float f = (float) ((PonderUI.ponderTicks % 100) * phase); entity.flapSpeed = MathHelper.sin(f) + 1; if (length == 0) entity.flapSpeed = 0; diff --git a/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java b/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java index e4f24ed6a..f1e05c489 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/elements/WorldSectionElement.java @@ -313,10 +313,9 @@ public class WorldSectionElement extends AnimatedSceneElement { transformMS(ms, pt); RenderSystem.disableTexture(); WorldRenderer.drawBox(ms, buffer.getBuffer(RenderType.getLines()), shape.getBoundingBox() - .offset(selectedBlock), 1, 1, 1, 1); - if (buffer instanceof SuperRenderTypeBuffer) - ((SuperRenderTypeBuffer) buffer).draw(RenderType.getLines()); - RenderSystem.enableTexture(); + .offset(selectedBlock), 1, 1, 1, 0.6f); +// if (buffer instanceof SuperRenderTypeBuffer) +// ((SuperRenderTypeBuffer) buffer).draw(RenderType.getLines()); ms.pop(); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderButton.java b/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderButton.java index c5ff15c2a..defd97deb 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderButton.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderButton.java @@ -7,7 +7,6 @@ import com.simibubi.create.foundation.gui.GuiGameElement; import com.simibubi.create.foundation.gui.IScreenRenderable; import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget; import com.simibubi.create.foundation.ponder.PonderUI; -import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.LerpedFloat; @@ -26,6 +25,7 @@ public class PonderButton extends AbstractSimiWidget { private float fade; private KeyBinding shortcut; private LerpedFloat flash; + private boolean noClickEvent; public static final int SIZE = 20; @@ -54,6 +54,11 @@ public class PonderButton extends AbstractSimiWidget { return this; } + public PonderButton noClickEvent() { + this.noClickEvent = true; + return this; + } + public PonderButton shortcut(KeyBinding key) { this.shortcut = key; return this; @@ -86,7 +91,7 @@ public class PonderButton extends AbstractSimiWidget { if (fade < .1f) return; - isHovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height && fade > .75f; + isHovered = isMouseOver(mouseX, mouseY) && fade > .75f; RenderSystem.pushMatrix(); RenderSystem.disableDepthTest(); @@ -95,11 +100,13 @@ public class PonderButton extends AbstractSimiWidget { float flashValue = flash.getValue(partialTicks); if (flashValue > .1f) - fade *= 3 * flashValue + Math.sin((AnimationTickHolder.getTicks() + partialTicks) / 6); + fade *= 3 * flashValue + Math.sin((PonderUI.ponderTicks + partialTicks) / 6); int backgroundColor = ColorHelper.applyAlpha(0xdd000000, fade); - int borderColorStart = ColorHelper.applyAlpha(isHovered ? 0x70ffffff : 0x40aa9999, fade); - int borderColorEnd = ColorHelper.applyAlpha(isHovered ? 0x30ffffff : 0x20aa9999, fade); + int borderColorStart = + ColorHelper.applyAlpha(noClickEvent ? 0x70984500 : isHovered ? 0x70ffffff : 0x40aa9999, fade); + int borderColorEnd = + ColorHelper.applyAlpha(noClickEvent ? 0x70692400 : isHovered ? 0x30ffffff : 0x20aa9999, fade); PonderUI.renderBox(x, y, width, height, backgroundColor, borderColorStart, borderColorEnd); RenderSystem.translated(0, 0, 800); @@ -153,4 +160,13 @@ public class PonderButton extends AbstractSimiWidget { public ItemStack getItem() { return item; } + + @Override + public boolean isMouseOver(double x, double y) { + double m = 4; + x = Math.floor(x); + y = Math.floor(y); + return active && visible + && !(x < this.x - m || x > this.x + width + m - 1 || y < this.y - m || y > this.y + height + m - 1); + } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java b/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java index b86ac025a..1da015fd6 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AnimationTickHolder.java @@ -1,6 +1,10 @@ package com.simibubi.create.foundation.utility; +import com.simibubi.create.foundation.ponder.PonderUI; +import com.simibubi.create.foundation.ponder.PonderWorld; + import net.minecraft.client.Minecraft; +import net.minecraft.world.IWorld; public class AnimationTickHolder { @@ -15,6 +19,10 @@ public class AnimationTickHolder { ticks = (ticks + 1) % 1_728_000; // wrap around every 24 hours so we maintain enough floating point precision } } + + public static int getTicks() { + return ticks; + } public static float getRenderTime() { return getTicks() + getPartialTicks(); @@ -24,8 +32,16 @@ public class AnimationTickHolder { Minecraft mc = Minecraft.getInstance(); return (mc.isGamePaused() ? mc.renderPartialTicksPaused : mc.getRenderPartialTicks()); } - - public static int getTicks() { - return ticks; + + public static int getTicks(IWorld world) { + return world instanceof PonderWorld ? PonderUI.ponderTicks : getTicks(); + } + + public static float getRenderTime(IWorld world) { + return getTicks(world) + getPartialTicks(world); + } + + public static float getPartialTicks(IWorld world) { + return world instanceof PonderWorld ? PonderUI.getPartialTicks() : getPartialTicks(); } } diff --git a/src/main/resources/assets/create/textures/gui/icons.png b/src/main/resources/assets/create/textures/gui/icons.png index 000090faf..c9d661aee 100644 Binary files a/src/main/resources/assets/create/textures/gui/icons.png and b/src/main/resources/assets/create/textures/gui/icons.png differ