From 2fc4588c880144e2f969243835e85e8bb0558a95 Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Sun, 21 Mar 2021 22:27:02 +0800 Subject: [PATCH] dynamically_information_update only recalc every 1 gt --- .../pistorder/impl/PistorderDisplay.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/fallenbreath/pistorder/impl/PistorderDisplay.java b/src/main/java/me/fallenbreath/pistorder/impl/PistorderDisplay.java index 55dd8ba..2ff466c 100644 --- a/src/main/java/me/fallenbreath/pistorder/impl/PistorderDisplay.java +++ b/src/main/java/me/fallenbreath/pistorder/impl/PistorderDisplay.java @@ -50,6 +50,9 @@ public class PistorderDisplay private DisplayMode displayMode; + // used for dynamically_information_update + private long lastUpdateTime = -1; + public PistorderDisplay(World world, BlockPos pos, BlockState blockState, Direction direction, PistonActionType actionType) { this.world = world; @@ -82,6 +85,9 @@ private void disable() this.displayMode = DisplayMode.DISABLED; } + /** + * Will trigger a refresh + */ private void setDisplayMode(DisplayMode mode) { this.displayMode = mode; @@ -112,6 +118,9 @@ private void refreshInformation() } } + /** + * Might make the piston blink for a while if the action type is retract + */ private void analyze(World world, BlockPos pos, Direction pistonFacing, PistonActionType PistonActionType) { BlockState[] states = new BlockState[2]; @@ -132,6 +141,12 @@ private void analyze(World world, BlockPos pos, Direction pistonFacing, PistonAc pistonHandler.calculatePush(); } + if (PistonActionType.isRetract()) + { + world.setBlockState(pos, states[0], 18); + world.setBlockState(pos.offset(pistonFacing), states[1], 18); + } + this.brokenBlocks = pistonHandler.getBrokenBlocks(); this.movedBlocks = pistonHandler.getMovedBlocks(); // reverse the list for correct order @@ -139,12 +154,6 @@ private void analyze(World world, BlockPos pos, Direction pistonFacing, PistonAc Collections.reverse(this.movedBlocks); PushLimitManager.getInstance().restorePushLimit(); - - if (PistonActionType.isRetract()) - { - world.setBlockState(pos, states[0], 18); - world.setBlockState(pos.offset(pistonFacing), states[1], 18); - } } private boolean tryIndirectMode() @@ -270,7 +279,11 @@ void render(float tickDelta) if (PistorderConfigure.DYNAMICALLY_INFORMATION_UPDATE) { - this.refreshInformation(); + if (this.world.getTime() != this.lastUpdateTime) + { + this.refreshInformation(); + this.lastUpdateTime = this.world.getTime(); + } } String actionKey = this.actionType.isPush() ? "pistorder.push" : "pistorder.retract";