mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-28 11:19:08 +00:00
drop old redstone cache implementation
This commit is contained in:
@@ -1,427 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
||||
Date: Thu, 16 Nov 2023 13:38:06 +0000
|
||||
Subject: [PATCH] Cache Vanillia and Eigen Redstone
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java b/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java
|
||||
index 9f17170179cc99d84ad25a1e838aff3d8cc66f93..a1fb1e286d66dde55682d899ded0e5d24715b642 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java
|
||||
@@ -662,6 +662,7 @@ public class RedstoneWireTurbo {
|
||||
// restores old behavior, at the cost of bypassing the
|
||||
// max-chained-neighbor-updates server property.
|
||||
worldIn.getBlockState(upd.self).handleNeighborChanged(worldIn, upd.self, wire, upd.parent, false);
|
||||
+ worldIn.redstoneTracker.trackUpdate(upd.self, upd.currentState, upd.parent); // Sakura
|
||||
}
|
||||
}
|
||||
|
||||
@@ -777,6 +778,17 @@ public class RedstoneWireTurbo {
|
||||
// already on-going graph walk being performed by breadthFirstWalk.
|
||||
return scheduleReentrantNeighborChanged(worldIn, pos, newState, source);
|
||||
}
|
||||
+
|
||||
+ // Sakura start
|
||||
+ int oldPower = state.getValue(RedStoneWireBlock.POWER);
|
||||
+ int newPower = newState.getValue(RedStoneWireBlock.POWER);
|
||||
+ if (worldIn.redstoneTracker.applyFromCache(pos, oldPower, newPower)) {
|
||||
+ return newState;
|
||||
+ } else {
|
||||
+ worldIn.redstoneTracker.beginTracking(pos, oldPower, newPower);
|
||||
+ }
|
||||
+ // Sakura end
|
||||
+
|
||||
// If there are no on-going walks through redstone wire, then start a new walk.
|
||||
|
||||
// If the source of the block update to the redstone wire at 'pos' is known, we can use
|
||||
@@ -806,6 +818,8 @@ public class RedstoneWireTurbo {
|
||||
// updates in a breadth first order out from the initial update received for the block at 'pos'.
|
||||
breadthFirstWalk(worldIn);
|
||||
|
||||
+ worldIn.redstoneTracker.endTracking(); // Sakura - we're done with the breadth walk
|
||||
+
|
||||
// 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.
|
||||
// In theory, we could cache the neighbor block positions, but that is a separate
|
||||
@@ -913,6 +927,7 @@ public 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.redstoneTracker.trackState(upd.self, state); // Sakura
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/me/samsuik/sakura/redstone/RedstoneTracker.java b/src/main/java/me/samsuik/sakura/redstone/RedstoneTracker.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2e322ac7c8751ab4586fcce7974c26dacad18e4a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/redstone/RedstoneTracker.java
|
||||
@@ -0,0 +1,285 @@
|
||||
+package me.samsuik.sakura.redstone;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.HashCommon;
|
||||
+import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
||||
+import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
+import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
|
||||
+import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
+import me.samsuik.sakura.utils.objects.Expiry;
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.core.Direction;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.level.block.*;
|
||||
+import net.minecraft.world.level.block.state.BlockState;
|
||||
+import net.minecraft.world.level.redstone.InstantNeighborUpdater;
|
||||
+import net.minecraft.world.level.redstone.NeighborUpdater;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+import java.util.function.Predicate;
|
||||
+
|
||||
+public final class RedstoneTracker {
|
||||
+
|
||||
+ private static final int DEPTH_LIMIT = 512;
|
||||
+
|
||||
+ // this is a fucking horrible hack, you could make a method in block
|
||||
+ // then override it but that is far more work than I am willing right now.
|
||||
+ private static final Predicate<Block> TECHNICAL_BLOCK = (block) -> {
|
||||
+ return block instanceof BaseEntityBlock
|
||||
+ || block instanceof DirectionalBlock
|
||||
+ || block instanceof HorizontalDirectionalBlock
|
||||
+ || block instanceof GameMasterBlock
|
||||
+ || block instanceof BaseRailBlock // rails themselves don't require it but it's variants do
|
||||
+ || block instanceof NoteBlock
|
||||
+ || block instanceof DoorBlock
|
||||
+ || block instanceof RedstoneLampBlock
|
||||
+ || block instanceof RedstoneTorchBlock
|
||||
+ || block instanceof RedStoneWireBlock; // required to update any nearby redstone that isn't the line currently being tested
|
||||
+ };
|
||||
+
|
||||
+ private final Level level;
|
||||
+ private final InstantNeighborUpdater updater;
|
||||
+ private final Long2ObjectOpenHashMap<RedstoneCache> wireCaches = new Long2ObjectOpenHashMap<>();
|
||||
+ // important locations, wires and adjacent
|
||||
+ private final Long2ObjectMap<List<RedstoneCache>> adjacent = new Long2ObjectOpenHashMap<>();
|
||||
+ // last block of physics
|
||||
+ private final Long2ObjectMap<List<RedstoneCache>> updates = new Long2ObjectOpenHashMap<>();
|
||||
+
|
||||
+ private ConnectedWires tracking;
|
||||
+ private int depth = 0;
|
||||
+
|
||||
+ public RedstoneTracker(Level level) {
|
||||
+ this.level = level;
|
||||
+ this.updater = new InstantNeighborUpdater(level);
|
||||
+ }
|
||||
+
|
||||
+ private static long cacheKey(BlockPos position, int previous, int next) {
|
||||
+ int powerState = 1 + previous + (next * 31); // previous and next only go up to 15
|
||||
+ long powerHash = HashCommon.murmurHash3((long) powerState); // long for a better hash
|
||||
+ return position.asLong() ^ powerHash;
|
||||
+ }
|
||||
+
|
||||
+ private boolean stillValid(BlockPos position, BlockState previous, BlockState next) {
|
||||
+ return previous.getBlock() == next.getBlock() || previous.isSignalSource() == next.isSignalSource()
|
||||
+ && previous.isRedstoneConductor(this.level, position) == next.isRedstoneConductor(this.level, position);
|
||||
+ }
|
||||
+
|
||||
+ public void updateNeighbors(BlockPos position, Block self) {
|
||||
+ this.updater.updateNeighborsAtExceptFromFacing(position, self, null);
|
||||
+ }
|
||||
+
|
||||
+ public boolean applyFromCache(BlockPos position, int previous, int next) {
|
||||
+ if (this.level.localConfig().config(position).redstoneCache && this.depth == 0) {
|
||||
+ long key = cacheKey(position, previous, next);
|
||||
+ RedstoneCache cache = this.wireCaches.get(key);
|
||||
+
|
||||
+ if (cache != null && !cache.expiry().isExpired(MinecraftServer.currentTick)) {
|
||||
+ cache.apply(this.level);
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ public void invalidate(BlockPos position, BlockState previous, BlockState next) {
|
||||
+ if (!this.stillValid(position, previous, next)) {
|
||||
+ long packed = position.asLong();
|
||||
+ this.invalidate(this.adjacent.get(packed));
|
||||
+
|
||||
+ if (TECHNICAL_BLOCK.test(next.getBlock())) {
|
||||
+ this.invalidate(this.updates.get(packed));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void invalidate(List<RedstoneCache> caches) {
|
||||
+ if (caches != null) {
|
||||
+ caches.forEach(cache -> cache.expiry().refresh(-200));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void trackState(BlockPos position, BlockState state) {
|
||||
+ if (this.tracking != null) {
|
||||
+ this.tracking.wireUpdate(position, state);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void trackUpdates(BlockPos position, Block block) {
|
||||
+ if (this.tracking != null) {
|
||||
+ this.tracking.updateNeighbors(position, block);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void trackUpdate(BlockPos position, BlockState state, BlockPos parent) {
|
||||
+ if (this.tracking != null) {
|
||||
+ this.tracking.updates().put(position.asLong(), new UpdateState(state.getBlock(), parent));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public boolean isTracked(BlockPos position) {
|
||||
+ List<RedstoneCache> wires = this.adjacent.get(position.asLong());
|
||||
+ return wires != null && wires.stream().anyMatch(cache -> !cache.expiry().isExpired(MinecraftServer.currentTick));
|
||||
+ }
|
||||
+
|
||||
+ public boolean isTracking() {
|
||||
+ return this.tracking != null && this.depth != 0 && this.depth < DEPTH_LIMIT;
|
||||
+ }
|
||||
+
|
||||
+ public void beginTracking(BlockPos position, int previous, int next) {
|
||||
+ if (this.level.localConfig().config(position).redstoneCache && ++this.depth == 1) {
|
||||
+ long key = cacheKey(position, previous, next);
|
||||
+
|
||||
+ if (this.wireCaches.containsKey(key)) {
|
||||
+ return; // cache already exists
|
||||
+ }
|
||||
+
|
||||
+ this.tracking = new ConnectedWires(
|
||||
+ position, key,
|
||||
+ new Object2ObjectOpenHashMap<>(),
|
||||
+ new Long2ObjectLinkedOpenHashMap<>()
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void endTracking() {
|
||||
+ if (this.depth > 0 && --this.depth == 0 && this.tracking != null) {
|
||||
+ this.createRedstoneCache();
|
||||
+ this.tracking = null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void createRedstoneCache() {
|
||||
+ ConnectedWires connected = this.tracking;
|
||||
+ List<RedstoneUpdate> updates = new ArrayList<>(connected.updates().size() / 2);
|
||||
+
|
||||
+ Long2ObjectMaps.fastForEach(connected.updates(), entry -> {
|
||||
+ BlockPos position = BlockPos.of(entry.getLongKey());
|
||||
+ UpdateState update = entry.getValue();
|
||||
+
|
||||
+ // do not update wires that are connected
|
||||
+ if (connected.wires().containsKey(position)) return;
|
||||
+
|
||||
+ // filter out blocks that do not need updates
|
||||
+ BlockState state = this.level.getBlockState(position);
|
||||
+ if (TECHNICAL_BLOCK.test(state.getBlock())) {
|
||||
+ updates.add(new RedstoneUpdate(position, state, update));
|
||||
+ }
|
||||
+ });
|
||||
+
|
||||
+ List<RedstoneWire> wires = new ArrayList<>(connected.wires().size());
|
||||
+
|
||||
+ connected.wires().forEach((pos, state) -> {
|
||||
+ // is it even worth taking the hit here
|
||||
+ boolean shapeUpdate = updates.stream()
|
||||
+ .filter(update -> update.state().is(Blocks.OBSERVER))
|
||||
+ .anyMatch(update -> pos.distManhattan(update.position()) == 1);
|
||||
+
|
||||
+ wires.add(new RedstoneWire(pos, state, shapeUpdate));
|
||||
+ });
|
||||
+
|
||||
+ RedstoneCache redstoneCache = new RedstoneCache(
|
||||
+ wires, updates, connected,
|
||||
+ new Expiry(MinecraftServer.currentTick, 200)
|
||||
+ );
|
||||
+
|
||||
+ // put the newly created redstone cache into use
|
||||
+ this.wireCaches.put(connected.key(), redstoneCache);
|
||||
+
|
||||
+ // used for cache invalidation
|
||||
+ connected.updates().keySet().forEach(update -> {
|
||||
+ BlockPos position = BlockPos.of(update);
|
||||
+
|
||||
+ if (wires.stream().anyMatch(wire -> wire.position().distManhattan(position) == 1)) {
|
||||
+ this.adjacent.computeIfAbsent(update, key -> new ArrayList<>(1))
|
||||
+ .add(redstoneCache);
|
||||
+ } else {
|
||||
+ this.updates.computeIfAbsent(update, key -> new ArrayList<>(1))
|
||||
+ .add(redstoneCache);
|
||||
+ }
|
||||
+ });
|
||||
+
|
||||
+ wires.forEach(wire -> {
|
||||
+ this.adjacent.computeIfAbsent(wire.position().asLong(), key -> new ArrayList<>(1))
|
||||
+ .add(redstoneCache);
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ public void expire(int tick) {
|
||||
+ if (tick % 100 != 0) return;
|
||||
+
|
||||
+ this.wireCaches.values().removeIf(cache -> {
|
||||
+ if (cache.expiry().isExpired(tick)) {
|
||||
+ removeExpiredCache(cache);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ private void removeExpiredCache(RedstoneCache cache) {
|
||||
+ cache.connected().updates().keySet().forEach(update -> {
|
||||
+ this.removeFromCaches(update, cache);
|
||||
+ });
|
||||
+
|
||||
+ cache.connected().wires().keySet().forEach(wire -> {
|
||||
+ this.removeFromCaches(wire.asLong(), cache);
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ private void removeFromCaches(long packed, RedstoneCache cache) {
|
||||
+ this.removeCache(this.adjacent, packed, cache);
|
||||
+ this.removeCache(this.updates, packed, cache);
|
||||
+ }
|
||||
+
|
||||
+ private void removeCache(Long2ObjectMap<List<RedstoneCache>> locationMap, long packed, RedstoneCache cache) {
|
||||
+ List<RedstoneCache> caches = locationMap.get(packed);
|
||||
+
|
||||
+ // in case something goes wrong
|
||||
+ if (caches == null) return;
|
||||
+
|
||||
+ caches.remove(cache);
|
||||
+
|
||||
+ if (caches.isEmpty()) {
|
||||
+ locationMap.remove(packed);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private record UpdateState(Block block, BlockPos position) {}
|
||||
+ private record RedstoneWire(BlockPos position, BlockState state, boolean shapeUpdate) {}
|
||||
+ private record RedstoneUpdate(BlockPos position, BlockState state, UpdateState parent) {}
|
||||
+
|
||||
+ private record RedstoneCache(List<RedstoneWire> wires, List<RedstoneUpdate> updates, ConnectedWires connected, Expiry expiry) {
|
||||
+ public void apply(Level level) {
|
||||
+ // Apply cached wire changes
|
||||
+ wires.forEach(wire -> level.setBlock(wire.position(), wire.state(), wire.shapeUpdate() ? 2 : 18));
|
||||
+
|
||||
+ // Now update the neighbors. We have to do this after applying wire changes
|
||||
+ // in case the block we're affecting here, checks the surrounding power level.
|
||||
+ updates.forEach(update -> {
|
||||
+ level.neighborChanged(update.position(), update.parent().block(), update.parent().position());
|
||||
+ });
|
||||
+
|
||||
+ // Refresh so the cache won't expire
|
||||
+ expiry.refresh(MinecraftServer.currentTick);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private record ConnectedWires(BlockPos source, long key, Object2ObjectMap<BlockPos, BlockState> wires, Long2ObjectMap<UpdateState> updates) {
|
||||
+ public void updateNeighbors(BlockPos position, Block block) {
|
||||
+ for (Direction direction : NeighborUpdater.UPDATE_ORDER) {
|
||||
+ BlockPos neighbor = position.relative(direction);
|
||||
+ this.updates.put(neighbor.asLong(), new UpdateState(block, position));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void wireUpdate(BlockPos position, BlockState state) {
|
||||
+ this.wires.put(position, state);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 88aa465a4bc6ae79dbad8dc8ecc21345f70abf0b..d82d64c98fc7624dfcc86fcbf49cde108bb34ede 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -698,6 +698,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(); // Sakura - 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.RedstoneTracker redstoneTracker = new me.samsuik.sakura.redstone.RedstoneTracker(this); // Sakura - cache vanilla and eigen redstone
|
||||
|
||||
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura - sakura configuration files// Paper - create paper world config & Anti-Xray
|
||||
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
||||
@@ -1077,6 +1078,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
} else {
|
||||
BlockState iblockdata2 = this.getBlockState(pos);
|
||||
|
||||
+ this.redstoneTracker.invalidate(pos, iblockdata1, state); // Sakura
|
||||
/*
|
||||
if (iblockdata2 == iblockdata) {
|
||||
if (iblockdata1 != iblockdata2) {
|
||||
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 c131734cad123a35456d18f8a161f77a4ac9ac99..88ddd1747d9786210e8faf412b3b0363df4bab43 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||
@@ -381,7 +381,15 @@ public class RedStoneWireBlock extends Block {
|
||||
}
|
||||
if (oldPower != i) {
|
||||
// CraftBukkit end
|
||||
+ // Sakura start
|
||||
+ if (world.redstoneTracker.applyFromCache(pos, oldPower, i)) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ world.redstoneTracker.beginTracking(pos, oldPower, i);
|
||||
if (world.getBlockState(pos) == state) {
|
||||
+ world.redstoneTracker.trackState(pos, state.setValue(RedStoneWireBlock.POWER, i));
|
||||
+ // Sakura end
|
||||
world.setBlock(pos, (BlockState) state.setValue(RedStoneWireBlock.POWER, i), 2);
|
||||
}
|
||||
|
||||
@@ -402,8 +410,17 @@ public class RedStoneWireBlock extends Block {
|
||||
while (iterator.hasNext()) {
|
||||
BlockPos blockposition1 = (BlockPos) iterator.next();
|
||||
|
||||
- world.updateNeighborsAt(blockposition1, this);
|
||||
+ // Sakura start
|
||||
+ world.redstoneTracker.trackUpdates(blockposition1, this);
|
||||
+ if (world.redstoneTracker.isTracking()) {
|
||||
+ world.redstoneTracker.updateNeighbors(blockposition1, this);
|
||||
+ } else {
|
||||
+ world.updateNeighborsAt(blockposition1, this);
|
||||
+ }
|
||||
+ // Sakura end
|
||||
}
|
||||
+
|
||||
+ world.redstoneTracker.endTracking(); // Sakura
|
||||
}
|
||||
|
||||
}
|
||||
@@ -559,7 +576,22 @@ public class RedStoneWireBlock extends Block {
|
||||
if (this.shouldSignal && direction != Direction.DOWN) {
|
||||
int i = (Integer) state.getValue(RedStoneWireBlock.POWER);
|
||||
|
||||
- return i == 0 ? 0 : (direction != Direction.UP && !((RedstoneSide) this.getConnectionState(world, state, pos).getValue((Property) RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(direction.getOpposite()))).isConnected() ? 0 : i);
|
||||
+ // Sakura start - use redstone cache to avoid recalculating wires
|
||||
+ if (i == 0) {
|
||||
+ return 0;
|
||||
+ } else if (direction == Direction.UP) {
|
||||
+ return i;
|
||||
+ } else {
|
||||
+ final BlockState wireState;
|
||||
+ if (world instanceof Level level && level.redstoneTracker.isTracked(pos)) {
|
||||
+ wireState = state; // cached wire
|
||||
+ } else {
|
||||
+ wireState = this.getConnectionState(world, state, pos);
|
||||
+ }
|
||||
+ return !((RedstoneSide) wireState.getValue((Property) RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(direction.getOpposite()))).isConnected() ? 0 : i;
|
||||
+ }
|
||||
+ //return i == 0 ? 0 : (direction != Direction.UP && !((RedstoneSide) this.getConnectionState(world, state, pos).getValue((Property) RedStoneWireBlock.PROPERTY_BY_DIRECTION.get(direction.getOpposite()))).isConnected() ? 0 : i);
|
||||
+ // Sakura end - use redstone cache to avoid recalculating wires
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Consistent Explosion Radius
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index b32f377079a7c97840079b0a6b541be936c822dd..fa142719b1c4f6434466141128c475ef945edbb7 100644
|
||||
index e941719d74f46b0bcf6e74c704d1a87f6cb37e4e..6852abf596187b328a1e67bd915c5870a1a60688 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -77,6 +77,7 @@ public class Explosion {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Remove spigot max tnt per tick
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
index 64ebae26c3c58c94b9907a5819cdc09f4f748cf1..56ad11f51e3ec395a88fa6d961cf8e99bde6b69f 100644
|
||||
index 89d297bbec6034630fe0dbb84c079023611194a3..4d0cfa1f96a04713cb1d51c7aaaf91374a0d6c17 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
@@ -142,7 +142,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Option to configure entity water sensitivity
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 64b55ad9544867ad0423aec368ff878d3ab8168f..0fed8714e1d01c6f584d6de00fba3635740298f6 100644
|
||||
index 25cc69a62f7c45dc1398820bfeb68f590bd7643b..64fafabf949fefcf24091c3bc6c1d7517e9cfa9b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3578,7 +3578,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -569,7 +569,7 @@ index 6852abf596187b328a1e67bd915c5870a1a60688..d0ba33c84cb2c1d01a368f5ec8a047da
|
||||
private final Level world;
|
||||
private final double posX, posY, posZ;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 20d6044e32cc56089a175675ff74dca02d68e75a..bd72b02c20fb56c2351f865dfff2573545ac313a 100644
|
||||
index 2cf25b6e51f1c430f80f1defe365b0373227bed2..d0424bb26fd16ac14a606512ebee5f5385f4773d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -695,6 +695,170 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -862,10 +862,10 @@ index 84623c632d8c2f0fa7ec939c711316d757117d23..afd6549f110ce32a1ad382b17f202ab5
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, pos, block.defaultBlockState())) {
|
||||
this.fizz(world, pos);
|
||||
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 88ddd1747d9786210e8faf412b3b0363df4bab43..b6c3aa283b8c6dcd5af4f770301a5481af82f945 100644
|
||||
index c131734cad123a35456d18f8a161f77a4ac9ac99..1f81bfd23abdb764fc2a86a9f73cfdc15bdf6b63 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||
@@ -699,6 +699,10 @@ public class RedStoneWireBlock extends Block {
|
||||
@@ -667,6 +667,10 @@ public class RedStoneWireBlock extends Block {
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) {
|
||||
if (!player.getAbilities().mayBuild) {
|
||||
return InteractionResult.PASS;
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Allow explosions to destroy lava
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index cfeacded13f5ebbc3ef66163387c7a40622d7b74..f39507dd7e0890446c9c16e6ae45d96302577253 100644
|
||||
index d0ba33c84cb2c1d01a368f5ec8a047da5cf81863..958cb715479d527a0833d1abee0852b2cc65b0ff 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -175,6 +175,11 @@ public class Explosion {
|
||||
@@ -48,7 +48,7 @@ index aa23d2665d5804e31b7c1b7021377010e74e4718..a93dc86f8c75e7021f42025d8f80c846
|
||||
blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 13f0184f5cf5687b3641d3e94625c0599ed2afb1..6d3e350635f978cadb56961121638e124a00a059 100644
|
||||
index 33cb52d93806a291403c496ce7f4a8964be3b28f..b30371a91a42fea32e26266b0bea96b09bd785b0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -564,6 +564,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Add redstone implementation API
|
||||
|
||||
|
||||
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 b6c3aa283b8c6dcd5af4f770301a5481af82f945..43a579795c19d4edd06ec6f301d6c107beaca96f 100644
|
||||
index 1f81bfd23abdb764fc2a86a9f73cfdc15bdf6b63..0bf0ce52424b8806d82d515d61189bb0e8f243b0 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
|
||||
@@ -268,7 +268,7 @@ public class RedStoneWireBlock extends Block {
|
||||
@@ -44,7 +44,7 @@ index b6c3aa283b8c6dcd5af4f770301a5481af82f945..43a579795c19d4edd06ec6f301d6c107
|
||||
// The old code would decrement the wire value only by 1 at a time.
|
||||
if (l > j) {
|
||||
j = l - 1;
|
||||
@@ -478,7 +478,7 @@ public class RedStoneWireBlock extends Block {
|
||||
@@ -461,7 +461,7 @@ public class RedStoneWireBlock extends Block {
|
||||
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
||||
if (!oldState.is(state.getBlock()) && !world.isClientSide) {
|
||||
// Paper start - optimize redstone - replace call to updatePowerStrength
|
||||
@@ -53,7 +53,7 @@ index b6c3aa283b8c6dcd5af4f770301a5481af82f945..43a579795c19d4edd06ec6f301d6c107
|
||||
world.getWireHandler().onWireAdded(pos); // Alternate Current
|
||||
} else {
|
||||
this.updateSurroundingRedstone(world, pos, state, null); // vanilla/Eigencraft
|
||||
@@ -511,7 +511,7 @@ public class RedStoneWireBlock extends Block {
|
||||
@@ -494,7 +494,7 @@ public class RedStoneWireBlock extends Block {
|
||||
}
|
||||
|
||||
// Paper start - optimize redstone - replace call to updatePowerStrength
|
||||
@@ -62,7 +62,7 @@ index b6c3aa283b8c6dcd5af4f770301a5481af82f945..43a579795c19d4edd06ec6f301d6c107
|
||||
world.getWireHandler().onWireRemoved(pos, state); // Alternate Current
|
||||
} else {
|
||||
this.updateSurroundingRedstone(world, pos, state, null); // vanilla/Eigencraft
|
||||
@@ -552,7 +552,7 @@ public class RedStoneWireBlock extends Block {
|
||||
@@ -535,7 +535,7 @@ public class RedStoneWireBlock extends Block {
|
||||
if (!world.isClientSide) {
|
||||
// Paper start - optimize redstone (Alternate Current)
|
||||
// Alternate Current handles breaking of redstone wires in the WireHandler.
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Add instant mob death animation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 0fed8714e1d01c6f584d6de00fba3635740298f6..7acb574bf1ca8de1ecd023e96ef9c0013118091d 100644
|
||||
index 64fafabf949fefcf24091c3bc6c1d7517e9cfa9b..ee262cd83534f4bc691d3a6e3c0bc5f8c211d22c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1815,6 +1815,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Configure potion speed and breaking inside entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
index 5f7d152f41eb85f17bcded4bc8099b998e5a338b..81e2161c90001ea941611f1691160df089c1cf97 100644
|
||||
index 10ade433c083851d9ea4797c6ec618db122229f9..25c9df0e27fb30f1dd89d257fe162727c595c10a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
@@ -156,7 +156,7 @@ public abstract class Projectile extends Entity implements TraceableEntity {
|
||||
@@ -101,7 +101,7 @@ index 0000000000000000000000000000000000000000..9c58f13396609ddd2bf7a909f2f20bd6
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 35b75be4ace452e684439ef2f0a6fa6d83f8f6cc..34721b0555f3977f85d72d9e704bbe49654ee19d 100644
|
||||
index ee262cd83534f4bc691d3a6e3c0bc5f8c211d22c..72ee41d96643072a3a9a562c31840f3d3ec80827 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -299,6 +299,43 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Allow disabling sweep attacks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index d4485ecff16969e57241d3841efbe1745c0814aa..a5417a76897395129baaf0eea8ed0a0cd60d9335 100644
|
||||
index 5d16462e1fab47f0587449d0f6e94886831d6ff3..ed2162313e9d92c03aaa7f46435ae8fd475433d3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -1386,7 +1386,7 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Change shields to reduce damage
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 34721b0555f3977f85d72d9e704bbe49654ee19d..5da12031d773ec9325bf7c592a1c3c854281da72 100644
|
||||
index 72ee41d96643072a3a9a562c31840f3d3ec80827..79b8087a2446d2ff933c1c0efd977c5da7c65f63 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2341,7 +2341,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Old enchanted golden apples
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 5da12031d773ec9325bf7c592a1c3c854281da72..4562a9c7327c6981e36cbeda88b53b44f1bbf20b 100644
|
||||
index 79b8087a2446d2ff933c1c0efd977c5da7c65f63..082304d1eb773798754d86afdf452746e67aaf19 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -4538,6 +4538,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Old combat sounds and particle effects
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index a5417a76897395129baaf0eea8ed0a0cd60d9335..2c88d4956894e19e773f569679396d5c6058781b 100644
|
||||
index ed2162313e9d92c03aaa7f46435ae8fd475433d3..fb3555f132a213dedf94616c8eef50b0cbd767e5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -1496,7 +1496,7 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Protect scaffolding from creepers
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index 98df890c88c6635566b5702080753f5cb0c20598..d7278a4f2a186532a9b4a57af8dad47b86660068 100644
|
||||
index 9dc47e2a61196cff74726972afe392ac1983ec84..8091187e9d09b16e466f09935861a32309f399b5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -180,6 +180,11 @@ public class Explosion {
|
||||
@@ -42,10 +42,10 @@ index 5db5ba026462ca642dcee718af732f80fadabef5..51e26395b53628b34b1f7f68935a9ba4
|
||||
|
||||
boolean isEmpty();
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 062bc318e9c4e3b9a6429ce0eaaa29081cd1d227..11e89d518d45b42bb39689e6ac1635b54ec8e41f 100644
|
||||
index d0424bb26fd16ac14a606512ebee5f5385f4773d..e97c5c64f915d22f39fd88e41ce80a17392a5159 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -1579,7 +1579,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -1577,7 +1577,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
tilesThisCycle--;
|
||||
toRemove.add(tickingblockentity); // Paper - Fix MC-117075; use removeAll
|
||||
// Spigot end
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Add max armour durability damage
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 4562a9c7327c6981e36cbeda88b53b44f1bbf20b..222558ec09ed64574fcbcbd40537981cd2e6403d 100644
|
||||
index 082304d1eb773798754d86afdf452746e67aaf19..e7a0acfc2af709bc2083432992d6ee20b225be87 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2437,6 +2437,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
Reference in New Issue
Block a user