aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2024-12-17 12:12:59 +0100
committerNassim Jahnke <[email protected]>2024-12-17 12:12:59 +0100
commitd37b5601d212fbff17342760813ee78e9ee761a9 (patch)
tree0c09650680c890f1c1c2ffe1f47057d346d5931d
parentac69f75d23618d914c0d705b578ac47dbac2bff0 (diff)
downloadPaper-d37b5601d212fbff17342760813ee78e9ee761a9.tar.gz
Paper-d37b5601d212fbff17342760813ee78e9ee761a9.zip
Update redstone optimization and lag compensation patches
-rw-r--r--feature-patches/1068-Fix-entity-tracker-desync-when-new-players-are-added.patch74
-rw-r--r--feature-patches/1069-Lag-compensation-ticks.patch115
-rw-r--r--feature-patches/1073-Eigencraft-redstone-implementation.patch109
-rw-r--r--feature-patches/1074-Add-Alternate-Current-redstone-implementation.patch189
4 files changed, 237 insertions, 250 deletions
diff --git a/feature-patches/1068-Fix-entity-tracker-desync-when-new-players-are-added.patch b/feature-patches/1068-Fix-entity-tracker-desync-when-new-players-are-added.patch
index e80eb74101..d7fc36933f 100644
--- a/feature-patches/1068-Fix-entity-tracker-desync-when-new-players-are-added.patch
+++ b/feature-patches/1068-Fix-entity-tracker-desync-when-new-players-are-added.patch
@@ -28,30 +28,30 @@ which is most likely in an unloaded chunk - which means that the
client will not tick the entity and thus not lerp the entity
from its old position to its new position.
-diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
-+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
-@@ -0,0 +0,0 @@ public class ClientboundAddEntityPacket implements Packet<ClientGamePacketListen
+diff --git a/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java b/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
+index db31989ebe3d7021cfd2311439e9a00f819b0841..1373977b339405ef59bb3ea03d195285c96dd3fe 100644
+--- a/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
++++ b/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java
+@@ -42,9 +42,11 @@ public class ClientboundAddEntityPacket implements Packet<ClientGamePacketListen
this(
entity.getId(),
entity.getUUID(),
-- entityTrackerEntry.getPositionBase().x(),
-- entityTrackerEntry.getPositionBase().y(),
-- entityTrackerEntry.getPositionBase().z(),
+- serverEntity.getPositionBase().x(),
+- serverEntity.getPositionBase().y(),
+- serverEntity.getPositionBase().z(),
+ // Paper start - fix entity tracker desync
+ entity.trackingPosition().x(),
+ entity.trackingPosition().y(),
+ entity.trackingPosition().z(),
+ // Paper end - fix entity tracker desync
- entityTrackerEntry.getLastSentXRot(),
- entityTrackerEntry.getLastSentYRot(),
+ serverEntity.getLastSentXRot(),
+ serverEntity.getLastSentYRot(),
entity.getType(),
-diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/level/ChunkMap.java
-+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
-@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
+diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
+index f8f145cd9614f7e38d6aa72501fe31837340a8bb..fa48e63fea42f387dcd154c08af54cfb0d3b08af 100644
+--- a/net/minecraft/server/level/ChunkMap.java
++++ b/net/minecraft/server/level/ChunkMap.java
+@@ -1419,6 +1419,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.serverEntity.addPairing(player);
}
// Paper end - entity tracking events
@@ -59,11 +59,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
} else if (this.seenBy.remove(player.connection)) {
this.serverEntity.removePairing(player);
-diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/level/ServerEntity.java
-+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
-@@ -0,0 +0,0 @@ public class ServerEntity {
+diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
+index 4c891706c2a3efc8e8c44fc1c031e8a1d21efb60..66f7926a2639ade41cb89419e38e12053314c982 100644
+--- a/net/minecraft/server/level/ServerEntity.java
++++ b/net/minecraft/server/level/ServerEntity.java
+@@ -90,6 +90,13 @@ public class ServerEntity {
this.trackedDataValues = entity.getEntityData().getNonDefaultValues();
}
@@ -75,31 +75,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - fix desync when a player is added to the tracker
+
public void sendChanges() {
- // Paper start - optimise collisions
- if (((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)this.entity).moonrise$isHardColliding()) {
-@@ -0,0 +0,0 @@ public class ServerEntity {
- }
+ List<Entity> passengers = this.entity.getPassengers();
+ if (!passengers.equals(this.lastPassengers)) {
+@@ -125,7 +132,7 @@ public class ServerEntity {
+ this.sendDirtyEntityData();
}
- if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) {
+ if (this.forceStateResync || this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { // Paper - fix desync when a player is added to the tracker
- byte b0 = Mth.packDegrees(this.entity.getYRot());
+ byte b = Mth.packDegrees(this.entity.getYRot());
byte b1 = Mth.packDegrees(this.entity.getXRot());
- boolean flag = Math.abs(b0 - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1;
-@@ -0,0 +0,0 @@ public class ServerEntity {
- long k = this.positionCodec.encodeZ(vec3d);
- boolean flag5 = i < -32768L || i > 32767L || j < -32768L || j > 32767L || k < -32768L || k > 32767L;
-
-- if (!flag5 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) {
-+ if (!this.forceStateResync && !flag5 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) { // Paper - fix desync when a player is added to the tracker
- if ((!flag2 || !flag) && !(this.entity instanceof AbstractArrow)) {
- if (flag2) {
- packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), this.entity.onGround());
-@@ -0,0 +0,0 @@ public class ServerEntity {
+ boolean flag = Math.abs(b - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1;
+@@ -160,7 +167,7 @@ public class ServerEntity {
+ long l1 = this.positionCodec.encodeY(vec3);
+ long l2 = this.positionCodec.encodeZ(vec3);
+ boolean flag5 = l < -32768L || l > 32767L || l1 < -32768L || l1 > 32767L || l2 < -32768L || l2 > 32767L;
+- if (flag5 || this.teleportDelay > 400 || this.wasRiding || this.wasOnGround != this.entity.onGround()) {
++ if (this.forceStateResync || flag5 || this.teleportDelay > 400 || this.wasRiding || this.wasOnGround != this.entity.onGround()) { // Paper - fix desync when a player is added to the tracker
+ this.wasOnGround = this.entity.onGround();
+ this.teleportDelay = 0;
+ packet = ClientboundEntityPositionSyncPacket.of(this.entity);
+@@ -225,6 +232,7 @@ public class ServerEntity {
}
this.entity.hasImpulse = false;
+ this.forceStateResync = false; // Paper - fix desync when a player is added to the tracker
}
- ++this.tickCount;
+ this.tickCount++;
diff --git a/feature-patches/1069-Lag-compensation-ticks.patch b/feature-patches/1069-Lag-compensation-ticks.patch
index a2f30eb99d..1d692f7144 100644
--- a/feature-patches/1069-Lag-compensation-ticks.patch
+++ b/feature-patches/1069-Lag-compensation-ticks.patch
@@ -7,66 +7,65 @@ Areas affected by lag comepnsation:
- Block breaking and destroying
- Eating food items
-diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/MinecraftServer.java
-+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
-@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
-
- public volatile Thread shutdownThread; // Paper
- public volatile boolean abnormalExit = false; // Paper
+diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
+index 646c2f2b617ed706021c83c9fc4492860dfdd4e9..8aa9ae2925ad44d57a27be3e520fcf20e30237d6 100644
+--- a/net/minecraft/server/MinecraftServer.java
++++ b/net/minecraft/server/MinecraftServer.java
+@@ -299,6 +299,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
+ public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
+ public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
+ private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
+ public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
- public static <S extends MinecraftServer> S spin(Function<Thread, S> serverFactory) {
+ public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
-@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
- worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
- worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
- net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers
-+ worldserver.updateLagCompensationTick(); // Paper - lag compensation
-
- gameprofilerfiller.push(() -> {
- String s = String.valueOf(worldserver);
-diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/level/ServerLevel.java
-+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
-@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
- );
+@@ -1564,6 +1565,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
+ for (ServerLevel serverLevel : this.getAllLevels()) {
+ serverLevel.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
+ serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
++ serverLevel.updateLagCompensationTick(); // Paper - lag compensation
+ profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().location());
+ /* Drop global time updates
+ if (this.tickCount % 20 == 0) {
+diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
+index ca9427a7eae9a66f4f1ccedda7b1def7ac2a88da..efc18884358907661d1226409f11d19a394073b3 100644
+--- a/net/minecraft/server/level/ServerLevel.java
++++ b/net/minecraft/server/level/ServerLevel.java
+@@ -2362,4 +2362,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
+ return this.server.getPlayerList().getPlayer(uuid);
}
- // Paper end - chunk tick iteration
+ // Paper end - check global player list where appropriate
++
+ // Paper start - lag compensation
-+ private long lagCompensationTick = net.minecraft.server.MinecraftServer.SERVER_INIT;
++ private long lagCompensationTick = MinecraftServer.SERVER_INIT;
+
+ public long getLagCompensationTick() {
+ return this.lagCompensationTick;
+ }
+
+ public void updateLagCompensationTick() {
-+ this.lagCompensationTick = (System.nanoTime() - net.minecraft.server.MinecraftServer.SERVER_INIT) / (java.util.concurrent.TimeUnit.MILLISECONDS.toNanos(50L));
++ this.lagCompensationTick = (System.nanoTime() - MinecraftServer.SERVER_INIT) / (java.util.concurrent.TimeUnit.MILLISECONDS.toNanos(50L));
+ }
+ // Paper end - lag compensation
-
- // Add env and gen to constructor, IWorldDataServer -> WorldDataServer
- public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
-diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
-+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
-@@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
+ }
+diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java
+index 6176f0738aa1a18df5d7d4d49fd6961e3f2eb736..d6da40d7188a55a9b2eeedb540c8e275359342e4 100644
+--- a/net/minecraft/server/level/ServerPlayerGameMode.java
++++ b/net/minecraft/server/level/ServerPlayerGameMode.java
+@@ -111,7 +111,7 @@ public class ServerPlayerGameMode {
}
public void tick() {
-- this.gameTicks = MinecraftServer.currentTick; // CraftBukkit;
-+ this.gameTicks = (int)this.level.getLagCompensationTick(); // CraftBukkit; // Paper - lag compensation
- BlockState iblockdata;
-
+- this.gameTicks = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit;
++ this.gameTicks = (int) this.level.getLagCompensationTick(); // Paper - lag compensation
if (this.hasDelayedDestroy) {
-diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
-+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
-@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ BlockState blockState = this.level.getBlockStateIfLoaded(this.delayedDestroyPos); // Paper - Don't allow digging into unloaded chunks
+ if (blockState == null || blockState.isAir()) { // Paper - Don't allow digging into unloaded chunks
+diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
+index c83aeaf4e50dd7290c608dfe260a3bd2404b6004..8439e1593c9973243383dc7091c587f7e72eb9e0 100644
+--- a/net/minecraft/world/entity/LivingEntity.java
++++ b/net/minecraft/world/entity/LivingEntity.java
+@@ -3831,6 +3831,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer);
}
// Paper end - Properly cancel usable items
@@ -77,33 +76,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private void updatingUsingItem() {
if (this.isUsingItem()) {
if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
-@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
+@@ -3844,7 +3848,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
- protected void updateUsingItem(ItemStack stack) {
- stack.onUseTick(this.level(), this, this.getUseItemRemainingTicks());
-- if (--this.useItemRemaining == 0 && !this.level().isClientSide && !stack.useOnRelease()) {
+ protected void updateUsingItem(ItemStack usingItem) {
+ usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks());
+- if (--this.useItemRemaining == 0 && !this.level().isClientSide && !usingItem.useOnRelease()) {
+ // Paper start - lag compensate eating
+ // we add 1 to the expected time to avoid lag compensating when we should not
+ final boolean shouldLagCompensate = this.useItem.has(DataComponents.FOOD) && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1L + this.totalEatTimeTicks) * 50L * (1000L * 1000L));
-+ if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !stack.useOnRelease()) {
++ if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !usingItem.useOnRelease()) {
+ this.useItemRemaining = 0;
+ // Paper end - lag compensate eating
this.completeUsingItem();
}
-
-@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
-
- if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
- this.useItem = itemstack;
-- this.useItemRemaining = itemstack.getUseDuration(this);
+ }
+@@ -3878,7 +3887,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ ItemStack itemInHand = this.getItemInHand(hand);
+ if (!itemInHand.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
+ this.useItem = itemInHand;
+- this.useItemRemaining = itemInHand.getUseDuration(this);
+ // Paper start - lag compensate eating
-+ this.useItemRemaining = this.totalEatTimeTicks = itemstack.getUseDuration(this);
++ this.useItemRemaining = this.totalEatTimeTicks = itemInHand.getUseDuration(this);
+ this.eatStartTime = System.nanoTime();
+ // Paper end - lag compensate eating
if (!this.level().isClientSide) {
this.setLivingEntityFlag(1, true);
this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
-@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
+@@ -3902,7 +3914,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
} else if (!this.isUsingItem() && !this.useItem.isEmpty()) {
this.useItem = ItemStack.EMPTY;
@@ -114,8 +113,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - lag compensate eating
}
}
-
-@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ }
+@@ -4026,7 +4041,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
this.useItem = ItemStack.EMPTY;
diff --git a/feature-patches/1073-Eigencraft-redstone-implementation.patch b/feature-patches/1073-Eigencraft-redstone-implementation.patch
index 87c9d93cc3..9b2677a63c 100644
--- a/feature-patches/1073-Eigencraft-redstone-implementation.patch
+++ b/feature-patches/1073-Eigencraft-redstone-implementation.patch
@@ -3,8 +3,6 @@ From: theosib <[email protected]>
Date: Thu, 27 Sep 2018 01:43:35 -0600
Subject: [PATCH] Eigencraft redstone implementation
-Author: theosib <[email protected]>
-
Original license: MIT
This patch implements theosib's redstone algorithms to completely overhaul the way redstone works.
@@ -17,19 +15,15 @@ A lot of this code is self-contained in a helper class.
Aside from making the obvious class/function renames and obfhelpers I didn't need to modify much.
Just added Bukkit's event system and took a few liberties with dead code and comment misspellings.
-== AT ==
-public net.minecraft.world.level.block.RedStoneWireBlock shouldSignal
-public net.minecraft.world.level.block.RedStoneWireBlock canSurvive(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelReader;Lnet/minecraft/core/BlockPos;)Z
-
Co-authored-by: egg82 <[email protected]>
-diff --git a/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java b/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java
+diff --git a/io/papermc/paper/redstone/RedstoneWireTurbo.java b/io/papermc/paper/redstone/RedstoneWireTurbo.java
new file mode 100644
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+index 0000000000000000000000000000000000000000..ff747a1ecdf3c888bca0d69de4f85dcd810b6139
--- /dev/null
-+++ b/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java
-@@ -0,0 +0,0 @@
-+package com.destroystokyo.paper.util;
++++ b/io/papermc/paper/redstone/RedstoneWireTurbo.java
+@@ -0,0 +1,954 @@
++package io.papermc.paper.redstone;
+
+import java.util.List;
+import java.util.Map;
@@ -48,14 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
-+/**
-+ * Used for the faster redstone algorithm.
-+ * Original author: theosib
-+ * Original license: MIT
-+ *
-+ * Ported to Paper and updated to 1.13 by egg82
-+ */
-+public class RedstoneWireTurbo {
++public final class RedstoneWireTurbo {
+ /*
+ * This is Helper class for BlockRedstoneWire. It implements a minimally-invasive
+ * bolt-on accelerator that performs a breadth-first search through redstone wire blocks
@@ -862,7 +849,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */
+ private BlockState calculateCurrentChanges(final Level worldIn, final UpdateNode upd) {
+ BlockState state = upd.currentState;
-+ final int i = state.getValue(RedStoneWireBlock.POWER).intValue();
++ final int i = state.getValue(RedStoneWireBlock.POWER);
+ int j = 0;
+ j = getMaxCurrentStrength(upd, j);
+ int l = 0;
@@ -986,21 +973,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */
+ private static int getMaxCurrentStrength(final UpdateNode upd, final int strength) {
+ if (upd.type != UpdateNode.Type.REDSTONE) return strength;
-+ final int i = upd.currentState.getValue(RedStoneWireBlock.POWER).intValue();
++ final int i = upd.currentState.getValue(RedStoneWireBlock.POWER);
+ return i > strength ? i : strength;
+ }
+}
-diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
-+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
-@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
- return floor.isFaceSturdy(world, pos, Direction.UP) || floor.is(Blocks.HOPPER);
+diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
+index 84e6c986917128d4488afa23d29c689cadb4f55d..f02232ce97779db0d12a5d5da1d767326d78ea4c 100644
+--- a/net/minecraft/world/level/block/RedStoneWireBlock.java
++++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
+@@ -290,6 +290,60 @@ public class RedStoneWireBlock extends Block {
+ return state.isFaceSturdy(level, pos, Direction.UP) || state.is(Blocks.HOPPER);
}
+ // Paper start - Optimize redstone
+ // The bulk of the new functionality is found in RedstoneWireTurbo.java
-+ com.destroystokyo.paper.util.RedstoneWireTurbo turbo = new com.destroystokyo.paper.util.RedstoneWireTurbo(this);
++ io.papermc.paper.redstone.RedstoneWireTurbo turbo = new io.papermc.paper.redstone.RedstoneWireTurbo(this);
+
+ /*
+ * Modified version of pre-existing updateSurroundingRedstone, which is called from
@@ -1052,46 +1039,46 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end
+
- private void updatePowerStrength(Level world, BlockPos pos, BlockState state, @Nullable Orientation orientation, boolean blockAdded) {
- if (useExperimentalEvaluator(world)) {
- new ExperimentalRedstoneWireEvaluator(this).updatePowerStrength(world, pos, state, orientation, blockAdded);
-@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
+ private void updatePowerStrength(Level level, BlockPos pos, BlockState state, @Nullable Orientation orientation, boolean updateShape) {
+ if (useExperimentalEvaluator(level)) {
+ new ExperimentalRedstoneWireEvaluator(this).updatePowerStrength(level, pos, state, orientation, updateShape);
+@@ -318,7 +372,7 @@ public class RedStoneWireBlock extends Block {
@Override
- protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
- if (!oldState.is(state.getBlock()) && !world.isClientSide) {
-- this.updatePowerStrength(world, pos, state, null, true);
-+ this.updateSurroundingRedstone(world, pos, state, null, true); // Paper - Optimize redstone
+ protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
+ if (!oldState.is(state.getBlock()) && !level.isClientSide) {
+- this.updatePowerStrength(level, pos, state, null, true);
++ this.updateSurroundingRedstone(level, pos, state, null, true); // Paper - Optimize redstone
for (Direction direction : Direction.Plane.VERTICAL) {
- world.updateNeighborsAt(pos.relative(direction), this);
-@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
- world.updateNeighborsAt(pos.relative(direction), this);
+ level.updateNeighborsAt(pos.relative(direction), this);
+@@ -337,7 +391,7 @@ public class RedStoneWireBlock extends Block {
+ level.updateNeighborsAt(pos.relative(direction), this);
}
-- this.updatePowerStrength(world, pos, state, null, false);
-+ this.updateSurroundingRedstone(world, pos, state, null, false); // Paper - Optimize redstone
- this.updateNeighborsOfNeighboringWires(world, pos);
+- this.updatePowerStrength(level, pos, state, null, false);
++ this.updateSurroundingRedstone(level, pos, state, null, false); // Paper - Optimize redstone
+ this.updateNeighborsOfNeighboringWires(level, pos);
}
}
-@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
- if (!world.isClientSide) {
- if (sourceBlock != this || !useExperimentalEvaluator(world)) {
- if (state.canSurvive(world, pos)) {
-- this.updatePowerStrength(world, pos, state, wireOrientation, false);
-+ this.updateSurroundingRedstone(world, pos, state, wireOrientation, false); // Paper - Optimize redstone
+@@ -363,7 +417,7 @@ public class RedStoneWireBlock extends Block {
+ if (!level.isClientSide) {
+ if (neighborBlock != this || !useExperimentalEvaluator(level)) {
+ if (state.canSurvive(level, pos)) {
+- this.updatePowerStrength(level, pos, state, orientation, false);
++ this.updateSurroundingRedstone(level, pos, state, orientation, false); // Paper - Optimize redstone
} else {
- dropResources(state, world, pos);
- world.removeBlock(pos, false);
-diff --git a/src/main/java/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java b/src/main/java/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
-+++ b/src/main/java/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
-@@ -0,0 +0,0 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator {
-
+ dropResources(state, level, pos);
+ level.removeBlock(pos, false);
+diff --git a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
+index 380fc51a252022195e178daccd8aa53dd1d71a2e..2d77780b6727f82ffc3cb216ca5f2d6483496cfd 100644
+--- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
++++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
+@@ -44,7 +44,7 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator {
+ }
}
-- private int calculateTargetStrength(Level world, BlockPos pos) {
-+ public int calculateTargetStrength(Level world, BlockPos pos) { // Paper - Optimize redstone
- int i = this.getBlockSignal(world, pos);
-
- return i == 15 ? i : Math.max(i, this.getIncomingWireSignal(world, pos));
+- private int calculateTargetStrength(Level level, BlockPos pos) {
++ public int calculateTargetStrength(Level level, BlockPos pos) { // Paper - Optimize redstone
+ int blockSignal = this.getBlockSignal(level, pos);
+ return blockSignal == 15 ? blockSignal : Math.max(blockSignal, this.getIncomingWireSignal(level, pos));
+ }
diff --git a/feature-patches/1074-Add-Alternate-Current-redstone-implementation.patch b/feature-patches/1074-Add-Alternate-Current-redstone-implementation.patch
index 50c8d18711..30c303e0c2 100644
--- a/feature-patches/1074-Add-Alternate-Current-redstone-implementation.patch
+++ b/feature-patches/1074-Add-Alternate-Current-redstone-implementation.patch
@@ -20,12 +20,12 @@ Alternate Current needs the following modifications:
* RedStoneWireBlock: Replace calls to vanilla's or Eigencraft's methods for handling power changes with calls to
Alternate Current's wire handler.
-diff --git a/src/main/java/alternate/current/wire/LevelHelper.java b/src/main/java/alternate/current/wire/LevelHelper.java
+diff --git a/alternate/current/wire/LevelHelper.java b/alternate/current/wire/LevelHelper.java
new file mode 100644
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+index 0000000000000000000000000000000000000000..eda108e2df9bf7d1ddd89287b8d2c2d7f1637c96
--- /dev/null
-+++ b/src/main/java/alternate/current/wire/LevelHelper.java
-@@ -0,0 +0,0 @@
++++ b/alternate/current/wire/LevelHelper.java
+@@ -0,0 +1,66 @@
+package alternate.current.wire;
+
+import org.bukkit.craftbukkit.block.CraftBlock;
@@ -92,12 +92,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return true;
+ }
+}
-diff --git a/src/main/java/alternate/current/wire/Node.java b/src/main/java/alternate/current/wire/Node.java
+diff --git a/alternate/current/wire/Node.java b/alternate/current/wire/Node.java
new file mode 100644
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+index 0000000000000000000000000000000000000000..8af6c69098e64945361d116b5fd6ac21e97fcd8d
--- /dev/null
-+++ b/src/main/java/alternate/current/wire/Node.java
-@@ -0,0 +0,0 @@
++++ b/alternate/current/wire/Node.java
+@@ -0,0 +1,113 @@
+package alternate.current.wire;
+
+import java.util.Arrays;
@@ -211,12 +211,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ throw new UnsupportedOperationException("Not a WireNode!");
+ }
+}
-diff --git a/src/main/java/alternate/current/wire/PriorityQueue.java b/src/main/java/alternate/current/wire/PriorityQueue.java
+diff --git a/alternate/current/wire/PriorityQueue.java b/alternate/current/wire/PriorityQueue.java
new file mode 100644
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+index 0000000000000000000000000000000000000000..d71b4d0e4c44a2620b41b89475412db53bea20ed
--- /dev/null
-+++ b/src/main/java/alternate/current/wire/PriorityQueue.java
-@@ -0,0 +0,0 @@
++++ b/alternate/current/wire/PriorityQueue.java
+@@ -0,0 +1,211 @@
+package alternate.current.wire;
+
+import java.util.AbstractQueue;
@@ -428,12 +428,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return prev;
+ }
+}
-diff --git a/src/main/java/alternate/current/wire/SimpleQueue.java b/src/main/java/alternate/current/wire/SimpleQueue.java
+diff --git a/alternate/current/wire/SimpleQueue.java b/alternate/current/wire/SimpleQueue.java
new file mode 100644
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+index 0000000000000000000000000000000000000000..2b30074252551e1dc55d5be17d26fb4a2d8eb2e4
--- /dev/null
-+++ b/src/main/java/alternate/current/wire/SimpleQueue.java
-@@ -0,0 +0,0 @@
++++ b/alternate/current/wire/SimpleQueue.java
+@@ -0,0 +1,112 @@
+package alternate.current.wire;
+
+import java.util.AbstractQueue;
@@ -546,12 +546,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ }
+}
-diff --git a/src/main/java/alternate/current/wire/UpdateOrder.java b/src/main/java/alternate/current/wire/UpdateOrder.java
+diff --git a/alternate/current/wire/UpdateOrder.java b/alternate/current/wire/UpdateOrder.java
new file mode 100644
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+index 0000000000000000000000000000000000000000..29338efd16cf62bb49e81cce09fbafd9b4319e7c
--- /dev/null
-+++ b/src/main/java/alternate/current/wire/UpdateOrder.java
-@@ -0,0 +0,0 @@
++++ b/alternate/current/wire/UpdateOrder.java
+@@ -0,0 +1,390 @@
+package alternate.current.wire;
+
+import java.util.Locale;
@@ -942,12 +942,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public abstract void forEachNeighbor(NodeProvider nodes, Node source, int forward, Consumer<Node> action);
+
+}
-diff --git a/src/main/java/alternate/current/wire/WireConnection.java b/src/main/java/alternate/current/wire/WireConnection.java
+diff --git a/alternate/current/wire/WireConnection.java b/alternate/current/wire/WireConnection.java
new file mode 100644
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+index 0000000000000000000000000000000000000000..4fd8cb29024330397cfe4cbc1f237d285bfb7b3e
--- /dev/null
-+++ b/src/main/java/alternate/current/wire/WireConnection.java
-@@ -0,0 +0,0 @@
++++ b/alternate/current/wire/WireConnection.java
+@@ -0,0 +1,30 @@
+package alternate.current.wire;
+
+/**
@@ -978,12 +978,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.accept = accept;
+ }
+}
-diff --git a/src/main/java/alternate/current/wire/WireConnectionManager.java b/src/main/java/alternate/current/wire/WireConnectionManager.java
+diff --git a/alternate/current/wire/WireConnectionManager.java b/alternate/current/wire/WireConnectionManager.java
new file mode 100644
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+index 0000000000000000000000000000000000000000..f03b313e58385d626490a9e64c9616fd08aa951e
--- /dev/null
-+++ b/src/main/java/alternate/current/wire/WireConnectionManager.java
-@@ -0,0 +0,0 @@
++++ b/alternate/current/wire/WireConnectionManager.java
+@@ -0,0 +1,134 @@
+package alternate.current.wire;
+
+import java.util.Arrays;
@@ -1118,12 +1118,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ }
+}
-diff --git a/src/main/java/alternate/current/wire/WireHandler.java b/src/main/java/alternate/current/wire/WireHandler.java
+diff --git a/alternate/current/wire/WireHandler.java b/alternate/current/wire/WireHandler.java
new file mode 100644
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+index 0000000000000000000000000000000000000000..259b301b2c8b64cb7974a235afb260e0e991af54
--- /dev/null
-+++ b/src/main/java/alternate/current/wire/WireHandler.java
-@@ -0,0 +0,0 @@
++++ b/alternate/current/wire/WireHandler.java
+@@ -0,0 +1,1073 @@
+package alternate.current.wire;
+
+import java.util.Iterator;
@@ -2197,12 +2197,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ }
+}
-diff --git a/src/main/java/alternate/current/wire/WireNode.java b/src/main/java/alternate/current/wire/WireNode.java
+diff --git a/alternate/current/wire/WireNode.java b/alternate/current/wire/WireNode.java
new file mode 100644
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9f5689bdb
--- /dev/null
-+++ b/src/main/java/alternate/current/wire/WireNode.java
-@@ -0,0 +0,0 @@
++++ b/alternate/current/wire/WireNode.java
+@@ -0,0 +1,122 @@
+package alternate.current.wire;
+
+import net.minecraft.core.BlockPos;
@@ -2325,11 +2325,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return LevelHelper.setWireState(level, pos, state, added);
+ }
+}
-diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/server/level/ServerLevel.java
-+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
-@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
+diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
+index efc18884358907661d1226409f11d19a394073b3..9cc47bda7197ca3f63b0ede9905c9a13931f84ed 100644
+--- a/net/minecraft/server/level/ServerLevel.java
++++ b/net/minecraft/server/level/ServerLevel.java
+@@ -214,6 +214,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
public final UUID uuid;
public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent
public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent
@@ -2337,7 +2337,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public LevelChunk getChunkIfLoaded(int x, int z) {
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
-@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
+@@ -2213,6 +2214,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
return this.chunkSource.getGenerator().getSeaLevel();
}
@@ -2348,14 +2348,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end - optimize redstone (Alternate Current)
+
- private final class EntityCallbacks implements LevelCallback<Entity> {
-
- EntityCallbacks() {}
-diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/world/level/Level.java
-+++ b/src/main/java/net/minecraft/world/level/Level.java
-@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
+ final class EntityCallbacks implements LevelCallback<Entity> {
+ @Override
+ public void onCreated(Entity entity) {
+diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
+index 872c3b8826f436b15f6ab0a3619692c5202eadc3..cb6ca60af3d3f90501e4693a78466b9f7462362d 100644
+--- a/net/minecraft/world/level/Level.java
++++ b/net/minecraft/world/level/Level.java
+@@ -1401,6 +1401,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public abstract FuelValues fuelValues();
@@ -2371,74 +2371,75 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - optimize redstone (Alternate Current)
+
public static enum ExplosionInteraction implements StringRepresentable {
-
- NONE("none"), BLOCK("block"), MOB("mob"), TNT("tnt"), TRIGGER("trigger"), STANDARD("standard"); // CraftBukkit - Add STANDARD which will always use Explosion.Effect.DESTROY
-diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
-+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
-@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
- return floor.isFaceSturdy(world, pos, Direction.UP) || floor.is(Blocks.HOPPER);
+ NONE("none"),
+ BLOCK("block"),
+diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
+index f02232ce97779db0d12a5d5da1d767326d78ea4c..12c9d60314c99fb65e640d255a2d0c6b7790ad4d 100644
+--- a/net/minecraft/world/level/block/RedStoneWireBlock.java
++++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
+@@ -290,7 +290,7 @@ public class RedStoneWireBlock extends Block {
+ return state.isFaceSturdy(level, pos, Direction.UP) || state.is(Blocks.HOPPER);
}
- // Paper start - Optimize redstone
+ // Paper start - Optimize redstone (Eigencraft)
// The bulk of the new functionality is found in RedstoneWireTurbo.java
- com.destroystokyo.paper.util.RedstoneWireTurbo turbo = new com.destroystokyo.paper.util.RedstoneWireTurbo(this);
+ io.papermc.paper.redstone.RedstoneWireTurbo turbo = new io.papermc.paper.redstone.RedstoneWireTurbo(this);
-@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
+@@ -372,7 +372,13 @@ public class RedStoneWireBlock extends Block {
@Override
- protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
- if (!oldState.is(state.getBlock()) && !world.isClientSide) {
-- this.updateSurroundingRedstone(world, pos, state, null, true); // Paper - Optimize redstone
+ protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
+ if (!oldState.is(state.getBlock()) && !level.isClientSide) {
+- this.updateSurroundingRedstone(level, pos, state, null, true); // Paper - Optimize redstone
+ // Paper start - optimize redstone - replace call to updatePowerStrength
-+ if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
-+ world.getWireHandler().onWireAdded(pos, state); // Alternate Current
++ if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
++ level.getWireHandler().onWireAdded(pos, state); // Alternate Current
+ } else {
-+ this.updateSurroundingRedstone(world, pos, state, null, true); // Vanilla/Eigencraft
++ this.updateSurroundingRedstone(level, pos, state, null, true); // Vanilla/Eigencraft
+ }
-+ // Paper end
++ // Paper end - optimize redstone
for (Direction direction : Direction.Plane.VERTICAL) {
- world.updateNeighborsAt(pos.relative(direction), this);
-@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
- world.updateNeighborsAt(pos.relative(direction), this);
+ level.updateNeighborsAt(pos.relative(direction), this);
+@@ -391,7 +397,13 @@ public class RedStoneWireBlock extends Block {
+ level.updateNeighborsAt(pos.relative(direction), this);
}
-- this.updateSurroundingRedstone(world, pos, state, null, false); // Paper - Optimize redstone
+- this.updateSurroundingRedstone(level, pos, state, null, false); // Paper - Optimize redstone
+ // Paper start - optimize redstone - replace call to updatePowerStrength
-+ if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
-+ world.getWireHandler().onWireRemoved(pos, state); // Alternate Current
++ if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
++ level.getWireHandler().onWireRemoved(pos, state); // Alternate Current
+ } else {
-+ this.updateSurroundingRedstone(world, pos, state, null, false); // Vanilla/Eigencraft
++ this.updateSurroundingRedstone(level, pos, state, null, false); // Vanilla/Eigencraft
+ }
- this.updateNeighborsOfNeighboringWires(world, pos);
++ // Paper end - optimize redstone
+ this.updateNeighborsOfNeighboringWires(level, pos);
}
}
-@@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block {
+@@ -415,9 +427,15 @@ public class RedStoneWireBlock extends Block {
@Override
- protected void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, @Nullable Orientation wireOrientation, boolean notify) {
- if (!world.isClientSide) {
+ protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) {
+ if (!level.isClientSide) {
+ // Paper start - optimize redstone (Alternate Current)
+ // Alternate Current handles breaking of redstone wires in the WireHandler.
-+ if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
-+ world.getWireHandler().onWireUpdated(pos, state, wireOrientation);
++ if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
++ level.getWireHandler().onWireUpdated(pos, state, orientation);
+ } else
-+ // Paper end - optimize redstone (Alternate Current)
- if (sourceBlock != this || !useExperimentalEvaluator(world)) {
- if (state.canSurvive(world, pos)) {
-- this.updateSurroundingRedstone(world, pos, state, wireOrientation, false); // Paper - Optimize redstone
-+ this.updateSurroundingRedstone(world, pos, state, wireOrientation, false); // Paper - Optimize redstone (Eigencraft)
++ // Paper end - optimize redstone (Alternate Current)
+ if (neighborBlock != this || !useExperimentalEvaluator(level)) {
+ if (state.canSurvive(level, pos)) {
+- this.updateSurroundingRedstone(level, pos, state, orientation, false); // Paper - Optimize redstone
++ this.updateSurroundingRedstone(level, pos, state, orientation, false); // Paper - Optimize redstone (Eigencraft)
} else {
- dropResources(state, world, pos);
- world.removeBlock(pos, false);
-diff --git a/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java b/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
-+++ b/src/main/java/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
-@@ -0,0 +0,0 @@ public class ExperimentalRedstoneUtils {
- if (up != null) {
- orientation = orientation.withFront(up);
+ dropResources(state, level, pos);
+ level.removeBlock(pos, false);
+diff --git a/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java b/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
+index 83f5da3e24834882193b9d7e3a788517e4b12b55..db7a7b091d2eb0f5b7efbe0db2b91709dee688e8 100644
+--- a/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
++++ b/net/minecraft/world/level/redstone/ExperimentalRedstoneUtils.java
+@@ -17,6 +17,11 @@ public class ExperimentalRedstoneUtils {
+ if (front != null) {
+ orientation = orientation.withFront(front);
}
+ // Paper start - Optimize redstone (Alternate Current) - use default front instead of random
+ else if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {