mirror of
https://github.com/Samsuik/Sakura.git
synced 2026-01-04 15:31:43 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@7e70636 Initial 1.21.9 update (squashed) PaperMC/Paper@0a28816 Add Server#getRespawnWorld and Server#setRespawnWorld(World) PaperMC/Paper@b67fa6d move todos txt content into tracking issue PaperMC/Paper@68f26a1 Drop no-longer-needed packet diffs PaperMC/Paper@f9434d2 Use pitch when setting spawn position with Location PaperMC/Paper@810b3c6 Deprecate the Conversation API (for removal), Metadata API, and PlayerSpawnLocationEvent (for removal) PaperMC/Paper@1870261 Update Moonrise to 1.21.9-pre1 PaperMC/Paper@1141058 Shift feature patch #s for Moonrise being first PaperMC/Paper@510aa9b Update 'Optimize Network Manager and add advanced packet support' PaperMC/Paper@89cc24a Update 'Allow Saving of Oversized Chunks' PaperMC/Paper@bcd75d8 Update EAR 2.0 patch and enable oldPaperCommit for better 3-way merges PaperMC/Paper@6b44820 Update 'Use Velocity compression and cipher natives' PaperMC/Paper@87f3e2f Update 'Optimize GoalSelector Goal.Flag Set operations' PaperMC/Paper@5323486 Update 'Optimize Voxel Shape Merging' PaperMC/Paper@5aac8b4 Update 'Handle Oversized block entities in chunks' PaperMC/Paper@f0b3d62 Update 'optimize dirt and snow spreading' and drop 'Optimise getChunkAt calls for loaded chunks' patch to code replaced by Moonrise PaperMC/Paper@92f822d Update 'Optimize Bit Operations by inlining', 'Remove streams from hot code' PaperMC/Paper@98e745a Update 'Optimize Pathfinder - Remove Streams / Optimized collections' PaperMC/Paper@49e49d0 Update 'Fix entity tracker desync when new players are added to the tracker' PaperMC/Paper@87e0525 Update alternate redstone impls PaperMC/Paper@35e973d Update 'Improve exact choice recipe ingredients', 'Only write chunk data to disk if it serializes without throwing' PaperMC/Paper@181f9bb Update 'Entity load/save limit per chunk', 'Attempt to recalculate regionfile header if it is corrupt' PaperMC/Paper@b31ca18 Update 'Incremental chunk and player saving', 'Optimise general POI access' PaperMC/Paper@9b69cc5 Add some more Mannequin API PaperMC/Paper@8bb12cb Fix compile PaperMC/Paper@e3aca92 Replace ConcurrentUtil's Validate with Objects PaperMC/Paper@9a626dd Rewrite ticket counter system PaperMC/Paper@65250cb Drop "Optimize Collision to not load chunks" PaperMC/Paper@55d56d9 Apply "Flush regionfiles on save configuration option" PaperMC/Paper@920e8d3 Apply "Optimise collision checking in player move packet handling" PaperMC/Paper@ec492d3 Apply "Improve keepalive ping system" PaperMC/Paper@8f65947 Apply "Optimise EntityScheduler ticking" PaperMC/Paper@086b4fd Apply "Optional per player mob spawns" PaperMC/Paper@2f4211e Apply "Improve cancelling PreCreatureSpawnEvent with per player mob spawns" PaperMC/Paper@b6d9557 Apply "Optimize Hoppers" PaperMC/Paper@388e693 update generator PaperMC/Paper@a3c89a8 add javadocs for new api PaperMC/Paper@fcc763a Call BlockRedstoneEvent for the shelf PaperMC/Paper@03eb18b replace requireNonNull by checkArgument and deprecate MCUtil#toLocation PaperMC/Paper@6b7bf01 bump built-in datapack version PaperMC/Paper@2779a53 deprecate #lanterns material tag in favour of vanilla tag PaperMC/Paper@6f9957e Mannequin#createDefaultProfile -> Mannequin#defaultProfile PaperMC/Paper@24874e5 Also rename Mannequin profile getter/setters for consistency PaperMC/Paper@bc2ae10 Fix default respawn dimension being null for new worlds PaperMC/Paper@eb42158 Use 0.0.4 release of ConcurrentUtil PaperMC/Paper@bb01745 1.21.9-pre2 PaperMC/Paper@0249204 1.21.9-pre2 feature patches PaperMC/Paper@9360ba4 Identifying comments for MinecraftServer PaperMC/Paper@5d3aa53 Some diff improvements in prepare spawn task PaperMC/Paper@22ad451 Move some stuff to ATs PaperMC/Paper@0ea15c9 Drop no longer applicable ATs PaperMC/Paper@cf78f2a bump api-version/datapack format and add a copper torch tag PaperMC/Paper@60cb0df generate ClientOption enums and mark CraftBlockData impl as null marked PaperMC/Paper@4025289 Add pre2 to api version PaperMC/Paper@f2cb073 Set build channel to alpha PaperMC/Paper@90b29c4 Port most of the anti-xray patch PaperMC/Paper@4a8e88d Disable oldPaperCommit to fix CI build PaperMC/Paper@121ac2e Port the last Anti-XRay hunk PaperMC/Paper@f43641f Use ConcurrentUtil 0.0.5 PaperMC/Paper@1f79388 fix end portal teleportation PaperMC/Paper@2efb400 [ci skip] Adjust spawn location event docs PaperMC/Paper@cb9fc05 simplify overloads PaperMC/Paper@25ecc59 Enable Anti-Xray PaperMC/Paper@4d7185f Add AsyncPlayerSpawnLocationEvent#isNewPlayer (#13081) PaperMC/Paper@dc474a8 Fixup vanilla code for Anti-Xray changes PaperMC/Paper@0e23b02 Add back null check for chunkPacketBlockController PaperMC/Paper@e6f1483 Update to 1.21.9-pre3 PaperMC/Paper@44259ea Add ResolvableProfile.SkinPatch (#13091) PaperMC/Paper@634f51e Update to 1.21.9-pre4 PaperMC/Paper@fada3a7 Update DataConverter to 1.21.9-pre4 PaperMC/Paper@037179f Update Starlight stored version PaperMC/Paper@6b0b29a Update publishing endpoint PaperMC/Paper@f6fabc5 Call EntityChangeBlockEvent for copper golem statue changes (#13090) PaperMC/Paper@1d6ee7d Update adventure PaperMC/Paper@404e49f Update to 1.21.9-rc1 PaperMC/Paper@4055274 Fix empty SkinPatch initialization and swapped dynamic/static heuristic in ResolvableProfile build method PaperMC/Paper@51fe7aa Fixed modern forwarding support (#13098) PaperMC/Paper@5613a35 fix PlayerGameModeChangeEvent#cancelMessage PaperMC/Paper@673abf4 use PlayerShieldDisableEvent#getCooldown PaperMC/Paper@3a0dc7f Fix a couple PlayerProfile mutability issues PaperMC/Paper@e97fb40 Remove parallel generation config option PaperMC/Paper@c3a60b8 Use ThreadLocal for Starlight and ticket level propagator cache PaperMC/Paper@e16b369 Resize propagator queues less aggressively
206 lines
12 KiB
Diff
206 lines
12 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Sun, 16 Feb 2025 23:27:59 +0000
|
|
Subject: [PATCH] Cache vanilla and eigencraft redstone wires
|
|
|
|
|
|
diff --git a/io/papermc/paper/redstone/RedstoneWireTurbo.java b/io/papermc/paper/redstone/RedstoneWireTurbo.java
|
|
index ff747a1ecdf3c888bca0d69de4f85dcd810b6139..d90f6aa4557b5863eba6a206226f763c1e89dc31 100644
|
|
--- a/io/papermc/paper/redstone/RedstoneWireTurbo.java
|
|
+++ b/io/papermc/paper/redstone/RedstoneWireTurbo.java
|
|
@@ -658,6 +658,7 @@ public final class RedstoneWireTurbo {
|
|
// while these updates are dispatched to non-wires only, so we can
|
|
// pass null.
|
|
worldIn.getBlockState(upd.self).handleNeighborChanged(worldIn, upd.self, wire, null, false);
|
|
+ worldIn.redstoneWireCache.trackNeighbor(upd.self); // Sakura - cache vanilla and eigencraft wires
|
|
}
|
|
}
|
|
|
|
@@ -801,6 +802,7 @@ public final class RedstoneWireTurbo {
|
|
// Perform the walk over all directly reachable redstone wire blocks, propagating wire value
|
|
// updates in a breadth first order out from the initial update received for the block at 'pos'.
|
|
breadthFirstWalk(worldIn);
|
|
+ worldIn.redstoneWireCache.stopTracking(); // Sakura - cache vanilla and eigencraft wires
|
|
|
|
// With the whole search completed, clear the list of all known blocks.
|
|
// We do not want to keep around state information that may be changed by other code.
|
|
@@ -909,6 +911,7 @@ public final class RedstoneWireTurbo {
|
|
// bypass the new neighbor update stack.
|
|
if (worldIn.setBlock(upd.self, state, Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_CLIENTS))
|
|
updateNeighborShapes(worldIn, upd.self, state);
|
|
+ worldIn.redstoneWireCache.trackWirePower(upd.self, j, i); // Sakura - cache vanilla and eigencraft wires
|
|
}
|
|
}
|
|
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index aca28d1e2530d239b0e2b55f75c6d0e398841ea1..ed50677f6b0445ac1c7246697c5f8d949bb59437 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -711,6 +711,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
this.levelTickScheduler.repeatingTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings
|
|
this.levelTickScheduler.repeatingTask(this.mergeHandler::expire, 200); // Sakura - merge cannon entities
|
|
this.levelTickScheduler.repeatingTask(this.densityCache::expire, 0); // Sakura - explosion density cache
|
|
+ this.levelTickScheduler.repeatingTask(this.redstoneWireCache::expire, 300); // Sakura - cache vanilla and eigencraft wires
|
|
}
|
|
|
|
// Paper start
|
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
|
index 7aa5ffc32835fab4a91db464d9112785475a67e9..6804055e9344eb2ea0b2dd6318231963376791c2 100644
|
|
--- a/net/minecraft/world/level/Level.java
|
|
+++ b/net/minecraft/world/level/Level.java
|
|
@@ -836,6 +836,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
|
|
public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(this); // Sakura - optimise explosion density cache
|
|
public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager(); // Sakura - explosion durable blocks
|
|
+ public final me.samsuik.sakura.redstone.RedstoneWireCache redstoneWireCache = new me.samsuik.sakura.redstone.RedstoneWireCache(this); // Sakura - cache vanilla and eigencraft wires
|
|
|
|
protected Level(
|
|
WritableLevelData levelData,
|
|
diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
|
|
index 497cc0156cbd87e591f1f50090fc5fe055b71916..b124e28cefac098d42fef55b699f4db398dfa1ba 100644
|
|
--- a/net/minecraft/world/level/block/RedStoneWireBlock.java
|
|
+++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
|
|
@@ -306,6 +306,12 @@ public class RedStoneWireBlock extends Block {
|
|
|
|
newPower = event.getNewCurrent();
|
|
|
|
+ // Sakura start - cache vanilla and eigencraft wires
|
|
+ if (level.redstoneWireCache.applyFromCache(pos, null, newPower, oldPower)) {
|
|
+ return state;
|
|
+ }
|
|
+ // Sakura end - cache vanilla and eigencraft wires
|
|
+
|
|
if (level.getBlockState(pos) == state) {
|
|
state = state.setValue(POWER, newPower);
|
|
// [Space Walker] suppress shape updates and emit those manually to
|
|
@@ -313,6 +319,7 @@ public class RedStoneWireBlock extends Block {
|
|
if (level.setBlock(pos, state, Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_CLIENTS)) {
|
|
turbo.updateNeighborShapes(level, pos, state);
|
|
}
|
|
+ level.redstoneWireCache.trackWirePower(pos, newPower, oldPower); // Sakura - cache vanilla and eigencraft wires
|
|
}
|
|
}
|
|
return state;
|
|
@@ -398,7 +405,7 @@ public class RedStoneWireBlock extends Block {
|
|
|
|
@Override
|
|
protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) {
|
|
- if (!level.isClientSide()) {
|
|
+ if (!level.isClientSide() && !level.redstoneWireCache.isApplyingCache()) { // Sakura - cache vanilla and eigencraft wires; ignore redstone updates when applying from cache
|
|
// Paper start - optimize redstone (Alternate Current)
|
|
// Alternate Current handles breaking of redstone wires in the WireHandler.
|
|
if (level.localConfig().at(pos).paperRedstoneImplementation() == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura - redstone implementation api
|
|
@@ -432,8 +439,14 @@ public class RedStoneWireBlock extends Block {
|
|
if (powerValue == 0) {
|
|
return 0;
|
|
} else {
|
|
- return side != Direction.UP
|
|
- && !this.getConnectionState(blockAccess, blockState, pos).getValue(PROPERTY_BY_DIRECTION.get(side.getOpposite())).isConnected()
|
|
+ // Sakura start - cache vanilla and eigencraft wires
|
|
+ if (side == Direction.UP) {
|
|
+ return powerValue;
|
|
+ }
|
|
+ final boolean updating = blockAccess instanceof Level level && level.redstoneWireCache.isUpdatingRedstoneWire(pos);
|
|
+ final BlockState state = updating ? blockState : this.getConnectionState(blockAccess, blockState, pos);
|
|
+ return !state.getValue(PROPERTY_BY_DIRECTION.get(side.getOpposite())).isConnected()
|
|
+ // Sakura end - cache vanilla and eigencraft wires
|
|
? 0
|
|
: powerValue;
|
|
}
|
|
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
index 7ee94845b69139f7c419b9d6ee24ba1db0e69975..d90389c515255df8273a69c652ba524135928482 100644
|
|
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
@@ -524,6 +524,13 @@ public abstract class BlockBehaviour implements FeatureElement {
|
|
return this.constantCollisionShape;
|
|
}
|
|
// Paper end - optimise collisions
|
|
+ // Sakura start - cache vanilla and eigencraft wires
|
|
+ private boolean specialBlock;
|
|
+
|
|
+ public final boolean isSpecialBlock() {
|
|
+ return this.specialBlock;
|
|
+ }
|
|
+ // Sakura end - cache vanilla and eigencraft wires
|
|
|
|
protected BlockStateBase(Block owner, Reference2ObjectArrayMap<Property<?>, Comparable<?>> values, MapCodec<BlockState> propertiesCodec) {
|
|
super(owner, values, propertiesCodec);
|
|
@@ -638,6 +645,7 @@ public abstract class BlockBehaviour implements FeatureElement {
|
|
}
|
|
}
|
|
// Paper end - optimise collisions
|
|
+ this.specialBlock = !Block.class.equals(this.owner.getClass()); // Sakura - cache vanilla and eigencraft wires
|
|
}
|
|
|
|
public Block getBlock() {
|
|
diff --git a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
|
index 879be2d05ef0fcfb8fab0c9f4e5bf66d7fce730b..c995827a4adad2279e98ede5e977aa2775349eec 100644
|
|
--- a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
|
+++ b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
|
@@ -29,6 +29,13 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
|
|
this.maxChainedNeighborUpdates = maxChainedNeighborUpdates;
|
|
}
|
|
|
|
+ // Sakura start - cache vanilla and eigencraft wires
|
|
+ @Override
|
|
+ public final int getUpdateDepth() {
|
|
+ return this.count;
|
|
+ }
|
|
+ // Sakura end - cache vanilla and eigencraft wires
|
|
+
|
|
public void setDebugListener(@Nullable Consumer<BlockPos> debugListener) {
|
|
this.debugListener = debugListener;
|
|
}
|
|
@@ -93,6 +100,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
|
|
}
|
|
}
|
|
} finally {
|
|
+ this.level.redstoneWireCache.stopTracking(); // Sakura - cache vanilla and eigencraft wires
|
|
this.stack.clear();
|
|
this.addedThisLayer.clear();
|
|
this.count = 0;
|
|
diff --git a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
|
|
index abcc144a086a45bf4cfa4d1a33e2ae10952e0da2..b76f54d9573b9f3ddd77915e9209ee8d9b497192 100644
|
|
--- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
|
|
+++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java
|
|
@@ -27,7 +27,14 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator {
|
|
}
|
|
if (oldPower != i) {
|
|
// CraftBukkit end
|
|
+ // Sakura start - cache vanilla and eigencraft wires
|
|
+ final me.samsuik.sakura.redstone.RedstoneWireCache wireCache = level.redstoneWireCache;
|
|
+ if (wireCache.applyFromCache(pos, orientation, i, oldPower)) {
|
|
+ return;
|
|
+ }
|
|
if (level.getBlockState(pos) == state) {
|
|
+ wireCache.trackWirePower(pos, i, oldPower);
|
|
+ // Sakura end - cache vanilla and eigencraft wires
|
|
level.setBlock(pos, state.setValue(RedStoneWireBlock.POWER, i), 2);
|
|
}
|
|
|
|
@@ -39,6 +46,7 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator {
|
|
}
|
|
|
|
for (BlockPos blockPos : set) {
|
|
+ wireCache.trackNeighborsAt(blockPos); // Sakura - cache vanilla and eigencraft wires
|
|
level.updateNeighborsAt(blockPos, this.wireBlock);
|
|
}
|
|
}
|
|
diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
index 332b33a004ab11150cca0cc2cefc26d0286648f5..3691a8b2306ad4fb555ea3b4cefb8e1ea0c14b6b 100644
|
|
--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
|
|
@@ -17,6 +17,12 @@ import net.minecraft.world.level.block.state.BlockState;
|
|
public interface NeighborUpdater {
|
|
Direction[] UPDATE_ORDER = new Direction[]{Direction.WEST, Direction.EAST, Direction.DOWN, Direction.UP, Direction.NORTH, Direction.SOUTH};
|
|
|
|
+ // Sakura start - cache vanilla and eigencraft wires
|
|
+ default int getUpdateDepth() {
|
|
+ return 0;
|
|
+ }
|
|
+ // Sakura end - cache vanilla and eigencraft wires
|
|
+
|
|
void shapeUpdate(Direction direction, BlockState state, BlockPos pos, BlockPos neighborPos, int flags, int recursionLevel);
|
|
|
|
void neighborChanged(BlockPos pos, Block neighborBlock, @Nullable Orientation orientation);
|