From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Sat, 17 Feb 2024 17:57:08 -0500 Subject: [PATCH] Rail Optimization: optimized PoweredRailBlock logic Original project: https://github.com/FxMorin/RailOptimization Full Rewrite of the powered rail iteration logic that makes powered/activator rails turning on/off up to 4x faster. This rewrite brings a massive performance boost while keeping the vanilla order. This is achieved by running all the powered rail logic from a single rail instead of each block iterating separately. Which was not only very expensive but also completely unnecessary and with a lot of massive overhead diff --git a/net/minecraft/world/level/block/PoweredRailBlock.java b/net/minecraft/world/level/block/PoweredRailBlock.java index e6674c37e09fe0ad2e971bd957666929492ba57e..653551f87f7c6dc20189ead09dcc81661afca2d8 100644 --- a/net/minecraft/world/level/block/PoweredRailBlock.java +++ b/net/minecraft/world/level/block/PoweredRailBlock.java @@ -128,6 +128,12 @@ public class PoweredRailBlock extends BaseRailBlock { @Override protected void updateState(BlockState state, Level level, BlockPos pos, Block block) { + // Leaf start - Rail Optimization + if (org.dreeam.leaf.config.modules.opt.OptimizedPoweredRails.enabled) { + org.dreeam.leaf.world.block.OptimizedPoweredRails.updateState(this, state, level, pos); + return; + } + // Leaf end - Rail Optimization boolean poweredValue = state.getValue(POWERED); boolean flag = level.hasNeighborSignal(pos) || this.findPoweredRailSignal(level, pos, state, true, 0)