From 7e5375d4767755eecafb18ad47ad7c0dbf98cfff Mon Sep 17 00:00:00 2001 From: Auri Date: Thu, 6 Jun 2019 15:55:19 +0300 Subject: [PATCH 1/5] initial pass at rsturbo --- .../fakes/RedstoneWireBlockInterface.java | 11 ++ ...WireTurbo.javax => RedstoneWireTurbo.java} | 45 +++-- .../carpet/mixins/RedstoneWireBlockMixin.java | 187 ++++++++++++++++++ src/main/resources/carpet.mixins.json | 1 + 4 files changed, 229 insertions(+), 15 deletions(-) create mode 100644 src/main/java/carpet/fakes/RedstoneWireBlockInterface.java rename src/main/java/carpet/helpers/{RedstoneWireTurbo.javax => RedstoneWireTurbo.java} (96%) create mode 100644 src/main/java/carpet/mixins/RedstoneWireBlockMixin.java diff --git a/src/main/java/carpet/fakes/RedstoneWireBlockInterface.java b/src/main/java/carpet/fakes/RedstoneWireBlockInterface.java new file mode 100644 index 00000000..35889a52 --- /dev/null +++ b/src/main/java/carpet/fakes/RedstoneWireBlockInterface.java @@ -0,0 +1,11 @@ +package carpet.fakes; + +import net.minecraft.block.BlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public interface RedstoneWireBlockInterface { + BlockState updateLogicPublic(World world_1, BlockPos blockPos_1, BlockState blockState_1); + void setWiresGivePower(boolean wiresGivePower); + boolean getWiresGivePower(); +} diff --git a/src/main/java/carpet/helpers/RedstoneWireTurbo.javax b/src/main/java/carpet/helpers/RedstoneWireTurbo.java similarity index 96% rename from src/main/java/carpet/helpers/RedstoneWireTurbo.javax rename to src/main/java/carpet/helpers/RedstoneWireTurbo.java index 02b39435..361b43ba 100644 --- a/src/main/java/carpet/helpers/RedstoneWireTurbo.javax +++ b/src/main/java/carpet/helpers/RedstoneWireTurbo.java @@ -7,11 +7,17 @@ import java.util.Map; import java.util.HashMap; import java.util.concurrent.ThreadLocalRandom; +import carpet.fakes.RedstoneWireBlockInterface; import net.minecraft.block.Block; import net.minecraft.block.RedstoneWireBlock; import net.minecraft.block.BlockState; +import net.minecraft.entity.ItemEntity; +import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.loot.context.LootContext; +import net.minecraft.world.loot.context.LootContextParameter; +import net.minecraft.world.loot.context.LootContextParameters; public class RedstoneWireTurbo { @@ -319,10 +325,19 @@ public class RedstoneWireTurbo // others are processed internally by the breadth first search // algorithm. To preserve this game behavior, this check must // be replicated here. - if (!oldState.isValidPosition(worldIn, pos)) { + if (!oldState.canPlaceAt(worldIn, pos)) { // Pop off the redstone dust - oldState.dropBlockAsItem(worldIn, pos, 0); - worldIn.removeBlock(pos); + // aurieh: there must be a better way to do this + LootContext.Builder ctx = new LootContext + .Builder(worldIn.getServer().getWorld(worldIn.dimension.getType())) + .put(LootContextParameters.POSITION, pos) + .put(LootContextParameters.TOOL, ItemStack.EMPTY); + List stacks = oldState.getDroppedStacks(ctx); + for (ItemStack stack : stacks) { + ItemEntity itemEntity = new ItemEntity(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); + worldIn.spawnEntity(itemEntity); + } + worldIn.clearBlockState(pos, false); // Mark this position as not being redstone wire upd1.type = UpdateNode.Type.OTHER; @@ -436,7 +451,7 @@ public class RedstoneWireTurbo // UpdateNode object. BlockState newState; if (old_current_change) { - newState = wire.func_212568_b(worldIn, pos, oldState); + newState = ((RedstoneWireBlockInterface)wire).updateLogicPublic(worldIn, pos, oldState); } else { // Looking up block state is slow. This accelerator includes a version of // calculateCurrentChanges that uses cahed wire values for a @@ -661,7 +676,7 @@ public class RedstoneWireTurbo // already keeping track of all of the neighbor positions // that need to be updated. All on its own, handling neighbors // this way reduces block updates by 1/3 (24 instead of 36). - worldIn.neighborChanged(upd.self, wire, upd.parent); + worldIn.updateNeighbor(upd.self, wire, upd.parent); } } @@ -765,7 +780,7 @@ public class RedstoneWireTurbo // Check this block's neighbors and see if its power level needs to change // Use the calculateCurrentChanges method in RedstoneWireBlock since we have no // cached block states at this point. - final BlockState newState = wire.func_212568_b(worldIn, pos, state); + final BlockState newState = ((RedstoneWireBlockInterface)wire).updateLogicPublic(worldIn, pos, state); // If no change, exit if (newState == state) { @@ -835,17 +850,17 @@ public class RedstoneWireTurbo BlockState state = upd.currentState; final int i = state.get(RedstoneWireBlock.POWER); int j = 0; - j = this.getMaxCurrentStrength(upd, j); + j = getMaxCurrentStrength(upd, j); int l = 0; - wire.setCanProvidePower(false); + ((RedstoneWireBlockInterface)wire).setWiresGivePower(false); // Unfortunately, World.isBlockIndirectlyGettingPowered is complicated, // and I'm not ready to try to replicate even more functionality from // elsewhere in Minecraft into this accelerator. So sadly, we must // suffer the performance hit of this very expensive call. If there // is consistency to what this call returns, we may be able to cache it. - final int k = worldIn.getRedstonePowerFromNeighbors(upd.self); - wire.setCanProvidePower(true); + final int k = worldIn.getReceivedRedstonePower(upd.self); + ((RedstoneWireBlockInterface)wire).setWiresGivePower(true); // The variable 'k' holds the maximum redstone power value of any adjacent blocks. // If 'k' has the highest level of all neighbors, then the power level of this @@ -863,7 +878,7 @@ public class RedstoneWireTurbo // position directly above the node being calculated is always // at index 1. UpdateNode center_up = upd.neighbor_nodes[1]; - boolean center_up_is_cube = center_up.currentState.isNormalCube(); + boolean center_up_is_cube = center_up.currentState.isSimpleFullBlock(worldIn, center_up.self); for (int m=0; m<4; m++) { // Get the neighbor array index of each of the four cardinal @@ -873,18 +888,18 @@ public class RedstoneWireTurbo // Get the max redstone power level of each of the cardinal // neighbors UpdateNode neighbor = upd.neighbor_nodes[n]; - l = this.getMaxCurrentStrength(neighbor, l); + l = getMaxCurrentStrength(neighbor, l); // Also check the positions above and below the cardinal // neighbors - boolean neighbor_is_cube = neighbor.currentState.isNormalCube(); + boolean neighbor_is_cube = neighbor.currentState.isSimpleFullBlock(worldIn, neighbor.self); if (!neighbor_is_cube) { UpdateNode neighbor_down = upd.neighbor_nodes[rs_neighbors_dn[m]]; - l = this.getMaxCurrentStrength(neighbor_down, l); + l = getMaxCurrentStrength(neighbor_down, l); } else if (!center_up_is_cube) { UpdateNode neighbor_up = upd.neighbor_nodes[rs_neighbors_up[m]]; - l = this.getMaxCurrentStrength(neighbor_up, l); + l = getMaxCurrentStrength(neighbor_up, l); } } } diff --git a/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java b/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java new file mode 100644 index 00000000..a956d6bf --- /dev/null +++ b/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java @@ -0,0 +1,187 @@ +package carpet.mixins; + +import carpet.CarpetSettings; +import carpet.fakes.RedstoneWireBlockInterface; +import carpet.helpers.RedstoneWireTurbo; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.RedstoneWireBlock; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Iterator; +import java.util.Set; + +import static net.minecraft.block.RedstoneWireBlock.POWER; + +@Mixin(RedstoneWireBlock.class) +public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterface { + // = + + @Shadow + private boolean wiresGivePower; + + @Shadow + @Final + private Set affectedNeighbors; + + @Shadow + private int increasePower(int int_1, BlockState blockState_1) { return 0; }; + + @Shadow + private BlockState update(World world_1, BlockPos blockPos_1, BlockState blockState_1) { return null; }; + + // = + + @Override + public BlockState updateLogicPublic(World world_1, BlockPos blockPos_1, BlockState blockState_1) { + return updateLogic(world_1, blockPos_1, blockState_1); + } + + @Override + @Accessor("wiresGivePower") + public abstract void setWiresGivePower(boolean wiresGivePower); + + @Override + @Accessor("wiresGivePower") + public abstract boolean getWiresGivePower(); + + // = + + private RedstoneWireTurbo wireTurbo = null; + + @Inject(method = "", at = @At("RETURN")) + private void onRedstoneWireBlockCTOR(Block.Settings settings, CallbackInfo ci) { + //noinspection ConstantConditions + wireTurbo = new RedstoneWireTurbo((RedstoneWireBlock) (Object) this); + } + + // = + + public BlockState fastUpdate(World world, BlockPos pos, BlockState state, BlockPos source) { + // [CM] fastRedstoneDust -- update based on carpet rule + if (CarpetSettings.b_fastRedstoneDust) { + wireTurbo.updateSurroundingRedstone(world, pos, state, source); + } + return update(world, pos, state); + } + + @Overwrite + private BlockState updateLogic(World world_1, BlockPos blockPos_1, BlockState blockState_1) { + BlockState blockState_2 = blockState_1; + int int_1 = (Integer)blockState_1.get(POWER); // i + int int_4 = increasePower(0, blockState_2); // j + this.wiresGivePower = false; + int int_2 = world_1.getReceivedRedstonePower(blockPos_1); // k + this.wiresGivePower = true; + int int_3 = 0; // l + + // [CM] fastRedstoneDust -- if statement around unnecessary check + if (!CarpetSettings.b_fastRedstoneDust) { + if (int_2 > 0 && int_2 > int_4 - 1) { + int_4 = int_2; + } + } + + if (!CarpetSettings.b_fastRedstoneDust || int_2 < 15) { + Iterator var8 = Direction.Type.HORIZONTAL.iterator(); + + label43: + while(true) { + while(true) { + if (!var8.hasNext()) { + break label43; + } + + Direction direction_1 = (Direction)var8.next(); + BlockPos blockPos_2 = blockPos_1.offset(direction_1); + BlockState blockState_3 = world_1.getBlockState(blockPos_2); + int_3 = this.increasePower(int_3, blockState_3); + BlockPos blockPos_3 = blockPos_1.up(); + if (blockState_3.isSimpleFullBlock(world_1, blockPos_2) && !world_1.getBlockState(blockPos_3).isSimpleFullBlock(world_1, blockPos_3)) { + int_3 = this.increasePower(int_3, world_1.getBlockState(blockPos_2.up())); + } else if (!blockState_3.isSimpleFullBlock(world_1, blockPos_2)) { + int_3 = this.increasePower(int_3, world_1.getBlockState(blockPos_2.down())); + } + } + } + } + + // [CM] fastRedstoneDust -- if statement around unnecessary check + if (!CarpetSettings.b_fastRedstoneDust) { + if (int_3 > int_4) { + int_4 = int_3 - 1; + } else if (int_4 > 0) { + --int_4; + } else { + int_4 = 0; + } + + if (int_2 > int_4 - 1) { + int_4 = int_2; + } + } else { + int_4 = int_3 - 1; + if (int_2 > int_4) int_4 = int_2; + } + + if (int_1 != int_4) { + blockState_1 = (BlockState)blockState_1.with(POWER, int_4); + if (world_1.getBlockState(blockPos_1) == blockState_2) { + world_1.setBlockState(blockPos_1, blockState_1, 2); + } + + if (!CarpetSettings.b_fastRedstoneDust) { + this.affectedNeighbors.add(blockPos_1); + Direction[] var14 = Direction.values(); + int var15 = var14.length; + + for (int var16 = 0; var16 < var15; ++var16) { + Direction direction_2 = var14[var16]; + this.affectedNeighbors.add(blockPos_1.offset(direction_2)); + } + } + } + + return blockState_1; + } + + // = + + private static final String updateTarget = "Lnet/minecraft/block/RedstoneWireBlock;update(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockState;"; + + @Redirect(method = "onBlockAdded", at = @At(value = "INVOKE", target = updateTarget)) + private BlockState redirectOnBlockAddedUpdate(RedstoneWireBlock self, World world_1, BlockPos blockPos_1, BlockState blockState_1) { + return fastUpdate(world_1, blockPos_1, blockState_1, null); + } + + @Redirect(method = "onBlockRemoved", at = @At(value = "INVOKE", target = updateTarget)) + private BlockState redirectOnBlockRemovedUpdate(RedstoneWireBlock self, World world_1, BlockPos blockPos_1, BlockState blockState_1) { + return fastUpdate(world_1, blockPos_1, blockState_1, null); + } + + @Redirect(method = "neighborUpdate", at = @At(value = "INVOKE", target = updateTarget)) + private BlockState redirectNeighborUpdateUpdate( + RedstoneWireBlock self, + World world_1, + BlockPos blockPos_1, + BlockState blockState_1, + BlockState blockState_2, + World world_2, + BlockPos blockPos_2, + Block block_1, + BlockPos blockPos_3, + boolean boolean_1) { + return fastUpdate(world_1, blockPos_1, blockState_1, blockPos_3); + } +} diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index 79c9ad10..b0c1df44 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -31,6 +31,7 @@ "PlayerActionC2SPacketMixin", "ServerPlayerEntityMixin", "PlayerManagerMixin", + "RedstoneWireBlockMixin", "CarpetBlockMixin", "SummonCommandMixin", "PistonHandler_pushLimitMixin", From ff94807a4a3e62d1465c8d92061da056926fa353 Mon Sep 17 00:00:00 2001 From: gnembon Date: Tue, 25 Jun 2019 16:21:50 -0300 Subject: [PATCH 2/5] compiles --- .../carpet/mixins/RedstoneWireBlockMixin.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java b/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java index a956d6bf..ffedc33f 100644 --- a/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java +++ b/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import carpet.CarpetSettings; +import carpet.settings.CarpetSettings; import carpet.fakes.RedstoneWireBlockInterface; import carpet.helpers.RedstoneWireTurbo; import net.minecraft.block.Block; @@ -70,12 +70,15 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa public BlockState fastUpdate(World world, BlockPos pos, BlockState state, BlockPos source) { // [CM] fastRedstoneDust -- update based on carpet rule - if (CarpetSettings.b_fastRedstoneDust) { + if (CarpetSettings.fastRedstoneDust) { wireTurbo.updateSurroundingRedstone(world, pos, state, source); } return update(world, pos, state); } + /** + * @author soykaf + */ @Overwrite private BlockState updateLogic(World world_1, BlockPos blockPos_1, BlockState blockState_1) { BlockState blockState_2 = blockState_1; @@ -87,13 +90,13 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa int int_3 = 0; // l // [CM] fastRedstoneDust -- if statement around unnecessary check - if (!CarpetSettings.b_fastRedstoneDust) { + if (!CarpetSettings.fastRedstoneDust) { if (int_2 > 0 && int_2 > int_4 - 1) { int_4 = int_2; } } - if (!CarpetSettings.b_fastRedstoneDust || int_2 < 15) { + if (!CarpetSettings.fastRedstoneDust || int_2 < 15) { Iterator var8 = Direction.Type.HORIZONTAL.iterator(); label43: @@ -118,7 +121,7 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa } // [CM] fastRedstoneDust -- if statement around unnecessary check - if (!CarpetSettings.b_fastRedstoneDust) { + if (!CarpetSettings.fastRedstoneDust) { if (int_3 > int_4) { int_4 = int_3 - 1; } else if (int_4 > 0) { @@ -141,7 +144,7 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa world_1.setBlockState(blockPos_1, blockState_1, 2); } - if (!CarpetSettings.b_fastRedstoneDust) { + if (!CarpetSettings.fastRedstoneDust) { this.affectedNeighbors.add(blockPos_1); Direction[] var14 = Direction.values(); int var15 = var14.length; @@ -158,19 +161,18 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa // = - private static final String updateTarget = "Lnet/minecraft/block/RedstoneWireBlock;update(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockState;"; - @Redirect(method = "onBlockAdded", at = @At(value = "INVOKE", target = updateTarget)) + @Redirect(method = "onBlockAdded", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;update(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockState;")) private BlockState redirectOnBlockAddedUpdate(RedstoneWireBlock self, World world_1, BlockPos blockPos_1, BlockState blockState_1) { return fastUpdate(world_1, blockPos_1, blockState_1, null); } - @Redirect(method = "onBlockRemoved", at = @At(value = "INVOKE", target = updateTarget)) + @Redirect(method = "onBlockRemoved", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;update(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockState;")) private BlockState redirectOnBlockRemovedUpdate(RedstoneWireBlock self, World world_1, BlockPos blockPos_1, BlockState blockState_1) { return fastUpdate(world_1, blockPos_1, blockState_1, null); } - @Redirect(method = "neighborUpdate", at = @At(value = "INVOKE", target = updateTarget)) + @Redirect(method = "neighborUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;update(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockState;")) private BlockState redirectNeighborUpdateUpdate( RedstoneWireBlock self, World world_1, From cba23ff310550e3cf1249278e527d69679b43936 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 3 Jul 2019 12:34:36 -0300 Subject: [PATCH 3/5] fixes --- src/main/java/carpet/helpers/RedstoneWireTurbo.java | 12 +----------- .../java/carpet/mixins/RedstoneWireBlockMixin.java | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/main/java/carpet/helpers/RedstoneWireTurbo.java b/src/main/java/carpet/helpers/RedstoneWireTurbo.java index 361b43ba..1bda7fc0 100644 --- a/src/main/java/carpet/helpers/RedstoneWireTurbo.java +++ b/src/main/java/carpet/helpers/RedstoneWireTurbo.java @@ -327,17 +327,7 @@ public class RedstoneWireTurbo // be replicated here. if (!oldState.canPlaceAt(worldIn, pos)) { // Pop off the redstone dust - // aurieh: there must be a better way to do this - LootContext.Builder ctx = new LootContext - .Builder(worldIn.getServer().getWorld(worldIn.dimension.getType())) - .put(LootContextParameters.POSITION, pos) - .put(LootContextParameters.TOOL, ItemStack.EMPTY); - List stacks = oldState.getDroppedStacks(ctx); - for (ItemStack stack : stacks) { - ItemEntity itemEntity = new ItemEntity(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); - worldIn.spawnEntity(itemEntity); - } - worldIn.clearBlockState(pos, false); + Block.dropStacks(oldState, worldIn, pos); // Mark this position as not being redstone wire upd1.type = UpdateNode.Type.OTHER; diff --git a/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java b/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java index ffedc33f..1b92df8e 100644 --- a/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java +++ b/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java @@ -71,7 +71,7 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa public BlockState fastUpdate(World world, BlockPos pos, BlockState state, BlockPos source) { // [CM] fastRedstoneDust -- update based on carpet rule if (CarpetSettings.fastRedstoneDust) { - wireTurbo.updateSurroundingRedstone(world, pos, state, source); + return wireTurbo.updateSurroundingRedstone(world, pos, state, source); } return update(world, pos, state); } From 16443a2cd6552e73d6cdab47d9d6cfa658e09d39 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 3 Jul 2019 12:56:20 -0300 Subject: [PATCH 4/5] re-added 1.14 optimizations and removed WIP status --- .../carpet/mixins/RedstoneWireBlockMixin.java | 27 ++----------------- .../java/carpet/settings/CarpetSettings.java | 3 +-- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java b/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java index 1b92df8e..f197cef7 100644 --- a/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java +++ b/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java @@ -83,19 +83,10 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa private BlockState updateLogic(World world_1, BlockPos blockPos_1, BlockState blockState_1) { BlockState blockState_2 = blockState_1; int int_1 = (Integer)blockState_1.get(POWER); // i - int int_4 = increasePower(0, blockState_2); // j this.wiresGivePower = false; int int_2 = world_1.getReceivedRedstonePower(blockPos_1); // k this.wiresGivePower = true; int int_3 = 0; // l - - // [CM] fastRedstoneDust -- if statement around unnecessary check - if (!CarpetSettings.fastRedstoneDust) { - if (int_2 > 0 && int_2 > int_4 - 1) { - int_4 = int_2; - } - } - if (!CarpetSettings.fastRedstoneDust || int_2 < 15) { Iterator var8 = Direction.Type.HORIZONTAL.iterator(); @@ -120,23 +111,9 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa } } - // [CM] fastRedstoneDust -- if statement around unnecessary check - if (!CarpetSettings.fastRedstoneDust) { - if (int_3 > int_4) { - int_4 = int_3 - 1; - } else if (int_4 > 0) { - --int_4; - } else { - int_4 = 0; - } + int int_4 = int_3 - 1; + if (int_2 > int_4) int_4 = int_2; - if (int_2 > int_4 - 1) { - int_4 = int_2; - } - } else { - int_4 = int_3 - 1; - if (int_2 > int_4) int_4 = int_2; - } if (int_1 != int_4) { blockState_1 = (BlockState)blockState_1.with(POWER, int_4); diff --git a/src/main/java/carpet/settings/CarpetSettings.java b/src/main/java/carpet/settings/CarpetSettings.java index f99044b1..42b8b2e6 100644 --- a/src/main/java/carpet/settings/CarpetSettings.java +++ b/src/main/java/carpet/settings/CarpetSettings.java @@ -92,8 +92,7 @@ public class CarpetSettings @Rule( desc = "Lag optimizations for redstone dust", extra = "by Theosib", - category = {EXPERIMENTAL, OPTIMIZATION}, - validate = Validator.WIP.class + category = {EXPERIMENTAL, OPTIMIZATION} ) public static boolean fastRedstoneDust = false; From ff59587599f5b081c10ba8678ca632fa52a17f54 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 3 Jul 2019 13:00:25 -0300 Subject: [PATCH 5/5] fix --- src/main/java/carpet/helpers/RedstoneWireTurbo.java | 1 + src/main/java/carpet/mixins/RedstoneWireBlockMixin.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/carpet/helpers/RedstoneWireTurbo.java b/src/main/java/carpet/helpers/RedstoneWireTurbo.java index 1bda7fc0..49a81f8a 100644 --- a/src/main/java/carpet/helpers/RedstoneWireTurbo.java +++ b/src/main/java/carpet/helpers/RedstoneWireTurbo.java @@ -328,6 +328,7 @@ public class RedstoneWireTurbo if (!oldState.canPlaceAt(worldIn, pos)) { // Pop off the redstone dust Block.dropStacks(oldState, worldIn, pos); + worldIn.clearBlockState(pos, false); // Mark this position as not being redstone wire upd1.type = UpdateNode.Type.OTHER; diff --git a/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java b/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java index f197cef7..354985b3 100644 --- a/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java +++ b/src/main/java/carpet/mixins/RedstoneWireBlockMixin.java @@ -77,7 +77,7 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa } /** - * @author soykaf + * @author theosib, soykaf, gnembon */ @Overwrite private BlockState updateLogic(World world_1, BlockPos blockPos_1, BlockState blockState_1) {