diff --git a/build-data/sakura.at b/build-data/sakura.at index 6608c6f..d6f2a0c 100644 --- a/build-data/sakura.at +++ b/build-data/sakura.at @@ -19,7 +19,6 @@ protected-f net.minecraft.world.level.ServerExplosion center public net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket chunkData public net.minecraft.server.level.ServerLevel entityTickList public net.minecraft.world.entity.Entity addMovementThisTick(Lnet/minecraft/world/entity/Entity$Movement;)V -public net.minecraft.world.entity.Entity axisStepOrder(Lnet/minecraft/world/phys/Vec3;)Ljava/lang/Iterable; public net.minecraft.world.entity.Entity stuckSpeedMultiplier public net.minecraft.world.entity.Entity$Movement public net.minecraft.world.level.Level neighborUpdater diff --git a/build.gradle.kts b/build.gradle.kts index 8a800a1..50cbfa7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent plugins { java - id("io.papermc.paperweight.patcher") version "2.0.0-beta.17" + id("io.papermc.paperweight.patcher") version "2.0.0-beta.18" } paperweight { diff --git a/gradle.properties b/gradle.properties index eab7eba..bd0cea8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ group=me.samsuik.sakura -version=1.21.8-R0.1-SNAPSHOT -mcVersion=1.21.8 +version=1.21.9-rc1-R0.1-SNAPSHOT +mcVersion=1.21.9-rc1 -paperRef=29c8822d90899c89d2689338e81a98f690bcba12 +paperRef=e16b369f6e8cbd3c4cc29970b6eb11d2b9da06df org.gradle.jvmargs=-Xmx2G org.gradle.vfs.watch=false diff --git a/sakura-api/build.gradle.kts.patch b/sakura-api/build.gradle.kts.patch index 4cae1f9..d071e1f 100644 --- a/sakura-api/build.gradle.kts.patch +++ b/sakura-api/build.gradle.kts.patch @@ -45,7 +45,7 @@ options.use() options.isDocFilesSubDirs = true options.links( -@@ -199,11 +_,11 @@ +@@ -201,11 +_,11 @@ } // workaround for https://github.com/gradle/gradle/issues/4046 diff --git a/sakura-api/paper-patches/features/0001-Client-Visibility-Settings-API.patch b/sakura-api/paper-patches/features/0001-Client-Visibility-Settings-API.patch index 16aeb6b..58be36b 100644 --- a/sakura-api/paper-patches/features/0001-Client-Visibility-Settings-API.patch +++ b/sakura-api/paper-patches/features/0001-Client-Visibility-Settings-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Client Visibility Settings API diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index 7f48e073173094fdee63efa0eea1cbfc4e06ba7d..8f53905e57e0905c7f75f9a457cdb9c0a7bcfafe 100644 +index bf8a7c425ebc8cf1546b5f891092ec317b298f3c..756336415e4e18b7871556bf1fe4ec7690ea4047 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -70,6 +70,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM +@@ -71,6 +71,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM void setTrackingRangeModifier(final double modifier); // Sakura end - entity tracking range modifier diff --git a/sakura-api/paper-patches/files/src/main/java/org/bukkit/Bukkit.java.patch b/sakura-api/paper-patches/files/src/main/java/org/bukkit/Bukkit.java.patch index 1982130..492e6ae 100644 --- a/sakura-api/paper-patches/files/src/main/java/org/bukkit/Bukkit.java.patch +++ b/sakura-api/paper-patches/files/src/main/java/org/bukkit/Bukkit.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -128,6 +_,20 @@ +@@ -127,6 +_,20 @@ // Paper end } diff --git a/sakura-api/paper-patches/files/src/main/java/org/bukkit/World.java.patch b/sakura-api/paper-patches/files/src/main/java/org/bukkit/World.java.patch index f9f8675..a1eb69d 100644 --- a/sakura-api/paper-patches/files/src/main/java/org/bukkit/World.java.patch +++ b/sakura-api/paper-patches/files/src/main/java/org/bukkit/World.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -4387,6 +_,11 @@ +@@ -4556,6 +_,11 @@ void setSendViewDistance(int viewDistance); // Paper end - view distance api diff --git a/sakura-api/paper-patches/files/src/main/java/org/bukkit/entity/Player.java.patch b/sakura-api/paper-patches/files/src/main/java/org/bukkit/entity/Player.java.patch index 6f4f2fb..1641a99 100644 --- a/sakura-api/paper-patches/files/src/main/java/org/bukkit/entity/Player.java.patch +++ b/sakura-api/paper-patches/files/src/main/java/org/bukkit/entity/Player.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -65,6 +_,12 @@ +@@ -66,6 +_,12 @@ @NullMarked public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer, com.destroystokyo.paper.network.NetworkClient { // Paper diff --git a/sakura-api/src/main/java/me/samsuik/sakura/mechanics/MechanicVersion.java b/sakura-api/src/main/java/me/samsuik/sakura/mechanics/MechanicVersion.java index a01eef1..8efcf18 100644 --- a/sakura-api/src/main/java/me/samsuik/sakura/mechanics/MechanicVersion.java +++ b/sakura-api/src/main/java/me/samsuik/sakura/mechanics/MechanicVersion.java @@ -24,6 +24,7 @@ public final class MechanicVersion { public static final short v1_21_2 = MinecraftVersionEncoding.v1xy(21, 2); public static final short v1_21_5 = MinecraftVersionEncoding.v1xy(21, 5); public static final short v1_21_6 = MinecraftVersionEncoding.v1xy(21, 6); + public static final short v1_21_9 = MinecraftVersionEncoding.v1xy(21, 9); public static String name(final short version) { if (version == LATEST) { diff --git a/sakura-server/build.gradle.kts.patch b/sakura-server/build.gradle.kts.patch index 9ea9fde..ec7d2bb 100644 --- a/sakura-server/build.gradle.kts.patch +++ b/sakura-server/build.gradle.kts.patch @@ -7,7 +7,7 @@ +val serverBrand = rootProject.name dependencies { - mache("io.papermc:mache:1.21.8+build.2") + mache("io.papermc:mache:1.21.9-rc1+build.1") @@ -26,6 +_,17 @@ minecraftVersion = providers.gradleProperty("mcVersion") gitFilePatches = false @@ -24,7 +24,7 @@ + activeFork = fork + spigot { - enabled = true + enabled = false buildDataRef = "436eac9815c211be1a2a6ca0702615f995e81c44" @@ -107,7 +_,20 @@ } @@ -54,7 +54,7 @@ dependencies { - implementation(project(":paper-api")) + implementation(project(":$serverBrand-api")) - implementation("ca.spottedleaf:concurrentutil:0.0.3") + implementation("ca.spottedleaf:concurrentutil:0.0.5") implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21 @@ -207,7 +_,7 @@ diff --git a/sakura-server/minecraft-patches/features/0001-Track-block-changes-and-level-tick-scheduler.patch b/sakura-server/minecraft-patches/features/0001-Track-block-changes-and-level-tick-scheduler.patch index a5cc69b..a2a5c0d 100644 --- a/sakura-server/minecraft-patches/features/0001-Track-block-changes-and-level-tick-scheduler.patch +++ b/sakura-server/minecraft-patches/features/0001-Track-block-changes-and-level-tick-scheduler.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Track block changes and level tick scheduler diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 4dabb2a689d4bceb054e819e2fd53420e95a283d..65bd8e94d7d7b815a2c8fe2a6fd1fa1ad9e60bc6 100644 +index a90e5cb4d989f38f7011a6ddd8c539a67e51494c..b2b8c9a651bab91491b4306dbb9d5a818e06869d 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1750,6 +1750,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop, AutoCl +@@ -829,6 +829,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return chunk != null ? chunk.getNoiseBiome(x, y, z) : this.getUncachedNoiseBiome(x, y, z); } // Paper end - optimise random ticking @@ -32,10 +32,10 @@ index b0b5d32b374a3ff32dc9f6757361ee4ace962a46..44e4c907801b934c188cf67bf3c75023 protected Level( WritableLevelData levelData, diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 75578e6ed7233a03d9b6cd3c6d3997f1c6148392..a39077ba4e1e40462ee9a96ce6f3871a5ecb85c7 100644 +index 4dcec2e8a3120a3dfa078e8cf6857ba99ca01a2d..4a274798077c4ee0a504a784449a1aef1d89d325 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -129,6 +129,21 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -136,6 +136,21 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot return this.getBlockStateFinal(x, y, z); } // Paper end - get block chunk optimisation @@ -57,7 +57,7 @@ index 75578e6ed7233a03d9b6cd3c6d3997f1c6148392..a39077ba4e1e40462ee9a96ce6f3871a public LevelChunk(Level level, ChunkPos pos) { this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); -@@ -166,6 +181,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -173,6 +188,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot this.debug = !empty && this.level.isDebug(); this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE; // Paper end - get block chunk optimisation @@ -65,7 +65,7 @@ index 75578e6ed7233a03d9b6cd3c6d3997f1c6148392..a39077ba4e1e40462ee9a96ce6f3871a } public LevelChunk(ServerLevel level, ProtoChunk chunk, @Nullable LevelChunk.PostLoadProcessor postLoad) { -@@ -414,6 +430,11 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -421,6 +437,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot if (!section.getBlockState(i, i1, i2).is(block)) { return null; } else { @@ -74,6 +74,7 @@ index 75578e6ed7233a03d9b6cd3c6d3997f1c6148392..a39077ba4e1e40462ee9a96ce6f3871a + this.blockChange(pos, state, blockState); + } + // Sakura end - track block changes and tick scheduler - if (!this.level.isClientSide && (flags & 512) == 0 && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. ++ + if (!this.level.isClientSide() && (flags & 512) == 0 && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. state.onPlace(this.level, pos, blockState, flag1); } diff --git a/sakura-server/minecraft-patches/features/0002-Client-Visibility-Settings.patch b/sakura-server/minecraft-patches/features/0002-Client-Visibility-Settings.patch index c681374..e1991ee 100644 --- a/sakura-server/minecraft-patches/features/0002-Client-Visibility-Settings.patch +++ b/sakura-server/minecraft-patches/features/0002-Client-Visibility-Settings.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Client Visibility Settings diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index 9f6d7c5dc0e591488a8a3763d8a1f1b3671d5299..0f5383dcec940db15205afbb65f1f8aa5899edf4 100644 +index 6987eeace609fbfba967922e558e09268e0f6d44..e45e2d6094620d761b624bfaf5dfbbed4d559858 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -31,7 +31,7 @@ public class ClientboundLevelChunkPacketData { @@ -36,7 +36,7 @@ index 9f6d7c5dc0e591488a8a3763d8a1f1b3671d5299..0f5383dcec940db15205afbb65f1f8aa final CompoundTag tag; diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08fa3b5d68 100644 +index 88035581d220dd3653fa2d30102e59e9a9340002..f9dfbf11a39573e839153fd5d72bcf9019540359 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java @@ -173,6 +173,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -47,7 +47,7 @@ index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08 public ChunkMap( ServerLevel level, -@@ -237,6 +238,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -235,6 +236,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider ); this.setServerViewDistance(serverViewDistance); this.worldGenContext = new WorldGenContext(level, generator, structureManager, this.lightEngine, null, this::setChunkUnsaved); // Paper - rewrite chunk system @@ -58,7 +58,7 @@ index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08 } private void setChunkUnsaved(ChunkPos chunkPos) { -@@ -1016,6 +1021,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1024,6 +1029,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider tracker.serverEntity.sendChanges(); } } @@ -67,7 +67,7 @@ index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08 } // Paper end - optimise entity tracker -@@ -1226,6 +1233,32 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1263,6 +1270,32 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return !this.seenBy.isEmpty(); } // Paper end - optimise entity tracker @@ -99,8 +99,8 @@ index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08 + // Sakura end - client visibility settings; entity visibility public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { - this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this::broadcastIgnorePlayers, this.seenBy); // Paper -@@ -1304,6 +1337,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this, this.seenBy); // Paper +@@ -1347,6 +1380,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } flag = flag && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z); // Paper end - Configurable entity tracking range by Y @@ -109,10 +109,10 @@ index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08 if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits flag = false; diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 03a157f6c96b0f39effa24ae278eeac689c83ee8..2a7c057ccfeb5dbe6b14ff660c0bb342571d88e7 100644 +index 1b1e2cb3f97de8bce9a88709e3fe02f7c44c77b6..9a963308d5b1a896b0dfe6a47f7d257a173719c5 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -564,6 +564,22 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -584,6 +584,22 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.playerTickingChunks.remove((LevelChunk)chunkHolder.getCurrentChunk()); } // Paper end - chunk tick iteration @@ -135,7 +135,7 @@ index 03a157f6c96b0f39effa24ae278eeac689c83ee8..2a7c057ccfeb5dbe6b14ff660c0bb342 public ServerLevel( MinecraftServer server, -@@ -675,6 +691,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -692,6 +708,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.chunkDataController = new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.ChunkDataController((ServerLevel)(Object)this, this.chunkTaskScheduler); // Paper end - rewrite chunk system this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit @@ -143,31 +143,33 @@ index 03a157f6c96b0f39effa24ae278eeac689c83ee8..2a7c057ccfeb5dbe6b14ff660c0bb342 } // Paper start -@@ -1898,7 +1915,18 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1931,7 +1948,20 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe for (ServerPlayer serverPlayer : this.players) { if (serverPlayer.distanceToSqr(vec3) < 4096.0) { Optional optional = Optional.ofNullable(serverExplosion.getHitPlayers().get(serverPlayer)); -- serverPlayer.connection.send(new ClientboundExplodePacket(vec3, optional, particleOptions, explosionSound)); +- serverPlayer.connection.send(new ClientboundExplodePacket(vec3, radius, i, optional, particleOptions, explosionSound, blockParticles)); + // Sakura start - client visibility settings; let players toggle explosion particles + ParticleOptions particle = particleOptions; + Vec3 position = vec3; -+ // In 1.22 and later this should be replaced with sending the motion through a PlayerPositionPacket. -+ // The problem here is SetEntityMotion is capped to 3.9 b/pt and the only other alternate mean was -+ // implemented in 1.21.3. I believe it's best to just wait on this issue and deal with this hack. + if (!this.checkExplosionVisibility(vec3, serverPlayer)) { -+ position = new Vec3(0.0, -1024.0, 0.0); -+ particle = net.minecraft.core.particles.ParticleTypes.SMOKE; ++ // todo: send knockback through PlayerPositionPacket ++ if (this.paperConfig().environment.disableExplosionKnockback) { ++ continue; ++ } else { ++ position = new Vec3(0.0, -1024.0, 0.0); ++ particle = net.minecraft.core.particles.ParticleTypes.SMOKE; ++ } + } -+ serverPlayer.connection.send(new ClientboundExplodePacket(position, optional, particle, explosionSound)); ++ serverPlayer.connection.send(new ClientboundExplodePacket(position, radius, i, optional, particle, explosionSound, blockParticles)); + // Sakura end - client visibility settings; let players toggle explosion particles } } diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index b1a0ab0958fffbd24d4e79c6840c5d7539a42142..34730f5750f335d10f04ebb557cca510a6a8adbd 100644 +index 637d60f082ca7aac689f9e7dc940e8c16d414445..24921be00af8df2314e54373c7014b6831940204 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -460,6 +460,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -473,6 +473,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc return this.viewDistanceHolder; } // Paper end - rewrite chunk system @@ -176,10 +178,10 @@ index b1a0ab0958fffbd24d4e79c6840c5d7539a42142..34730f5750f335d10f04ebb557cca510 public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, gameProfile); diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index f02800e4e941b05bde6f0d5fac76e2b6ec5b9832..4a84792f9cf17cf2b50638ce6de05dc6f40b311f 100644 +index c6db2c96db96453daaf49779f588f75f7c3d3d60..fd08d04c13a4064c658e0aad436b48831316129b 100644 --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -57,6 +57,60 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -58,6 +58,60 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack public @Nullable String playerBrand; public final java.util.Set pluginMessagerChannels; // Paper end - retain certain values @@ -240,9 +242,9 @@ index f02800e4e941b05bde6f0d5fac76e2b6ec5b9832..4a84792f9cf17cf2b50638ce6de05dc6 public ServerCommonPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie) { this.server = server; -@@ -317,6 +371,12 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -318,6 +372,12 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } else if (packet instanceof net.minecraft.network.protocol.game.ClientboundSetDefaultSpawnPositionPacket defaultSpawnPositionPacket && this instanceof ServerGamePacketListenerImpl serverGamePacketListener) { - serverGamePacketListener.player.compassTarget = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(defaultSpawnPositionPacket.getPos(), serverGamePacketListener.getCraftPlayer().getWorld()); + serverGamePacketListener.player.compassTarget = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(defaultSpawnPositionPacket.respawnData().pos(), serverGamePacketListener.getPlayer().level()); } + // Sakura start - client visibility settings + final net.minecraft.server.level.ServerPlayer player = this.getPlayer(); @@ -254,10 +256,10 @@ index f02800e4e941b05bde6f0d5fac76e2b6ec5b9832..4a84792f9cf17cf2b50638ce6de05dc6 if (packet.isTerminal()) { this.close(); diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index ca13dd72f173be6714965c506f2d48dcd3c9e569..21134883bea2553a870ef0df32c47430aa056cef 100644 +index 11d55309f3030399386b4deeab58d5f760b3574d..57934cb30c7704f7ff10d25a47df894fabd4687a 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3205,6 +3205,7 @@ public class ServerGamePacketListenerImpl +@@ -3215,6 +3215,7 @@ public class ServerGamePacketListenerImpl event.setCancelled(cancelled); net.minecraft.world.inventory.AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224 @@ -266,10 +268,10 @@ index ca13dd72f173be6714965c506f2d48dcd3c9e569..21134883bea2553a870ef0df32c47430 if (this.player.containerMenu != oldContainer) { this.player.containerMenu.resumeRemoteUpdates(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index b06d701b280d58240503a0c95c2c98fa002faa16..96988c6993360cf90c8872a1371d91e897c56582 100644 +index 40983aa59d0d8ee7e725c3daf2049a8a9d775d70..8d64020b4c4d5f86ab692db05f40e79b9c42ee68 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -533,6 +533,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -535,6 +535,10 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } // Paper end - optimise entity tracker public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api @@ -281,7 +283,7 @@ index b06d701b280d58240503a0c95c2c98fa002faa16..96988c6993360cf90c8872a1371d91e8 public Entity(EntityType entityType, Level level) { this.type = entityType; diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index e035e87278e02c5a234ec9fa79c009706a189561..fff6985d35ff9b37b2829b7d0639a13e150ad697 100644 +index 31e0739bc20096fa368f2b22bb45034a6fe1fe43..c7a930caa2264c9465baf61a0ed8a188119f28c8 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -79,6 +79,7 @@ public class FallingBlockEntity extends Entity { @@ -293,7 +295,7 @@ index e035e87278e02c5a234ec9fa79c009706a189561..fff6985d35ff9b37b2829b7d0639a13e public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) { diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java -index f153f25a4a61a84d842ab33225c4618d464c4116..d9e2a6e02b51cd42f1226a9fb62d0b205e693eba 100644 +index df5b6c6c06fc594c3d51e59bab59a625ac1e4bae..4d0bc49ce0868d7a5a1870be4e19eb08f3f31482 100644 --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java @@ -63,6 +63,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { diff --git a/sakura-server/minecraft-patches/features/0003-Load-Chunks-on-Movement.patch b/sakura-server/minecraft-patches/features/0003-Load-Chunks-on-Movement.patch index fcdd5b7..10fcbce 100644 --- a/sakura-server/minecraft-patches/features/0003-Load-Chunks-on-Movement.patch +++ b/sakura-server/minecraft-patches/features/0003-Load-Chunks-on-Movement.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Load Chunks on Movement diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java -index 01cd38bba2deb6cf65c82b4e4ec352a2998fd339..c9bafad13e831f7254f397629f07d3c92fc2a8bb 100644 +index 2082b7506a403ed6815076cbd0d3b7eecd7225a0..82dac4fbaf3572391dad61356ba5351b725194ff 100644 --- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java @@ -1885,6 +1885,7 @@ public final class CollisionUtil { @@ -50,22 +50,22 @@ index 01cd38bba2deb6cf65c82b4e4ec352a2998fd339..c9bafad13e831f7254f397629f07d3c9 // bound y diff --git a/net/minecraft/server/level/TicketType.java b/net/minecraft/server/level/TicketType.java -index 6a7dae136691fb2476633fa12897424daa6bb5b3..372fceb03ee24f0d9c0dc970824f3b637068385a 100644 +index e3a4b57f374bbe9792d86e60da1a115abcc9cd66..c22a4c45da0a4c3f6c043d40b6a9a9cd50a64667 100644 --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java -@@ -56,6 +56,7 @@ public final class TicketType implements ca.spottedleaf.moonrise.patches.chun - public static final TicketType PLUGIN_TICKET = register("plugin_ticket", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); static { ((TicketType)PLUGIN_TICKET).moonrise$setIdentifierComparator((org.bukkit.plugin.Plugin p1, org.bukkit.plugin.Plugin p2) -> p1.getName().compareTo(p2.getName())); } // Paper // Paper - rewrite chunk system - public static final TicketType FUTURE_AWAIT = register("future_await", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Paper - public static final TicketType CHUNK_LOAD = register("chunk_load", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING); // Paper - moonrise -+ public static final TicketType ENTITY_MOVEMENT = register("entity_movement", 200L, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Sakura - load chunks on movement +@@ -62,6 +62,7 @@ public final class TicketType implements ca.spottedleaf.moonrise.patches.chun + public static final TicketType PLUGIN_TICKET = register("plugin_ticket", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); // Paper + public static final TicketType FUTURE_AWAIT = register("future_await", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); // Paper + public static final TicketType CHUNK_LOAD = register("chunk_load", NO_TIMEOUT, FLAG_LOADING); // Paper - moonrise ++ public static final TicketType ENTITY_MOVEMENT = register("entity_movement", 200L, FLAG_LOADING | FLAG_SIMULATION); // Sakura - load chunks on movement - public static TicketType register(String name, long timeout, boolean persist, TicketType.TicketUse use) { - return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, persist, use)); + private static TicketType register(String name, long timeout, int flags) { + return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, flags)); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 96988c6993360cf90c8872a1371d91e897c56582..77c06f9304a895e70a695be5afbaea7b99eaec25 100644 +index 8d64020b4c4d5f86ab692db05f40e79b9c42ee68..245997396ebb84c69ee056d83b02fcbc06cea4d2 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -537,6 +537,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -539,6 +539,19 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name public boolean isPrimedTNT; public boolean isFallingBlock; // Sakura end - client visibility settings @@ -85,7 +85,7 @@ index 96988c6993360cf90c8872a1371d91e897c56582..77c06f9304a895e70a695be5afbaea7b public Entity(EntityType entityType, Level level) { this.type = entityType; -@@ -1520,7 +1533,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1537,7 +1550,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder( this.level, (Entity)(Object)this, initialCollisionBox, potentialCollisionsVoxel, potentialCollisionsBB, @@ -94,7 +94,7 @@ index 96988c6993360cf90c8872a1371d91e897c56582..77c06f9304a895e70a695be5afbaea7b ); potentialCollisionsBB.addAll(entityAABBs); final Vec3 collided = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currentBox, potentialCollisionsVoxel, potentialCollisionsBB); -@@ -5183,13 +5196,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5248,13 +5261,14 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name @Override public boolean shouldBeSaved() { return (this.removalReason == null || this.removalReason.shouldSave()) @@ -111,7 +111,7 @@ index 96988c6993360cf90c8872a1371d91e897c56582..77c06f9304a895e70a695be5afbaea7b public boolean mayInteract(ServerLevel level, BlockPos pos) { diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index fff6985d35ff9b37b2829b7d0639a13e150ad697..4b9a75c677b8f553a103438c3c7813f46d64d26a 100644 +index c7a930caa2264c9465baf61a0ed8a188119f28c8..44f04d0a6b1a47fa152f955a22cc8b8f1d2b3348 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -80,6 +80,7 @@ public class FallingBlockEntity extends Entity { @@ -123,7 +123,7 @@ index fff6985d35ff9b37b2829b7d0639a13e150ad697..4b9a75c677b8f553a103438c3c7813f4 public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) { diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java -index d9e2a6e02b51cd42f1226a9fb62d0b205e693eba..ea017a4162d54bd7e02b801216d83e51010ef618 100644 +index 4d0bc49ce0868d7a5a1870be4e19eb08f3f31482..2572c0fe5fc6bd2f389569cdaa907a8b5203f5b4 100644 --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java @@ -64,6 +64,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -135,10 +135,10 @@ index d9e2a6e02b51cd42f1226a9fb62d0b205e693eba..ea017a4162d54bd7e02b801216d83e51 public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) { diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java -index 182c14b660f8860bed627eed4e01fd4002153e9a..164e080fbfc4ebff99479497030294e06b658bdc 100644 +index 9889485b15501c1adf1a73bb4603d3477860482d..833048754d7f60ad7f528f38c7d34804e1bf5ee1 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -139,6 +139,15 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -137,6 +137,15 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh private final int minSection; private final int maxSection; // Paper end - get block chunk optimisation diff --git a/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch b/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch index 6906df4..38bac80 100644 --- a/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch +++ b/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch @@ -123,10 +123,10 @@ index f1ab0e66e7d464f7f31a7a360528ed97cdda0aa0..4aed59c3038cb4af7e454a0dd8455488 public DataItem(EntityDataAccessor accessor, T value) { this.accessor = accessor; diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index e96d4dee14c05f2fa329bfb1588ec795d4e3d730..ba9393e474ae213316c693d73ef2641e69eae8cc 100644 +index 638432a2e6506d3db6a25c068a33eeafb13cf0d6..c386288e808e97c938f1909d81ebfa0032dec2a6 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -148,7 +148,7 @@ public class ServerEntity { +@@ -136,7 +136,7 @@ public class ServerEntity { this.sendDirtyEntityData(); } @@ -135,28 +135,28 @@ index e96d4dee14c05f2fa329bfb1588ec795d4e3d730..ba9393e474ae213316c693d73ef2641e byte b = Mth.packDegrees(this.entity.getYRot()); byte b1 = Mth.packDegrees(this.entity.getXRot()); boolean flag = Math.abs(b - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1; -@@ -411,7 +411,15 @@ public class ServerEntity { +@@ -392,7 +392,15 @@ public class ServerEntity { List> list = entityData.packDirty(); if (list != null) { this.trackedDataValues = entityData.getNonDefaultValues(); -- this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), list)); +- this.synchronizer.sendToTrackingPlayersAndSelf(new ClientboundSetEntityDataPacket(this.entity.getId(), list)); + // Slice start - packet obfuscation and reduction + if (!(this.entity instanceof ServerPlayer)) { + list = entityData.packForeignDirty(list); + } + + if (list != null) { -+ this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), list)); ++ this.synchronizer.sendToTrackingPlayersAndSelf(new ClientboundSetEntityDataPacket(this.entity.getId(), list)); + } + // Slice end - packet obfuscation and reduction } if (this.entity instanceof LivingEntity) { diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 77c06f9304a895e70a695be5afbaea7b99eaec25..a13f7613115f08461ed6852fd35bc19f4923063d 100644 +index 245997396ebb84c69ee056d83b02fcbc06cea4d2..eb157e848ea97ea11bbf233d473e6a62a23bf32f 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -3637,7 +3637,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3703,7 +3703,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID); return; } @@ -166,7 +166,7 @@ index 77c06f9304a895e70a695be5afbaea7b99eaec25..a13f7613115f08461ed6852fd35bc19f } diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index 4b9a75c677b8f553a103438c3c7813f46d64d26a..d35183f10362952c0c38061ccdedc1a578c91c2d 100644 +index 44f04d0a6b1a47fa152f955a22cc8b8f1d2b3348..59aa539b7d830de48ff582b0da6fa17796b8c4b8 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -144,7 +144,7 @@ public class FallingBlockEntity extends Entity { @@ -179,7 +179,7 @@ index 4b9a75c677b8f553a103438c3c7813f46d64d26a..d35183f10362952c0c38061ccdedc1a5 public BlockPos getStartPos() { diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java -index ea017a4162d54bd7e02b801216d83e51010ef618..b53baca84c9022a700fbc1150264fc805af6a61e 100644 +index 2572c0fe5fc6bd2f389569cdaa907a8b5203f5b4..6797e16f973b11d168906dfce240c70db25bc6f0 100644 --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java @@ -228,7 +228,11 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -196,10 +196,10 @@ index ea017a4162d54bd7e02b801216d83e51010ef618..b53baca84c9022a700fbc1150264fc80 public int getFuse() { diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index fbb58d0dc50d1e6d90d51379acbf6822674efc46..17723bdf3f3d3c8637dee01f8f4a15b2d741e52d 100644 +index 0a72140f396ab1c03a064020b6e081108a98b06e..92a8bdbf74a35afcd76eabee0869426440a69b7a 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -701,7 +701,7 @@ public abstract class Player extends LivingEntity { +@@ -573,7 +573,7 @@ public abstract class Player extends Avatar implements ContainerUser { public void increaseScore(int score) { int score1 = this.getScore(); diff --git a/sakura-server/minecraft-patches/features/0005-Add-redstone-implementation-api.patch b/sakura-server/minecraft-patches/features/0005-Add-redstone-implementation-api.patch index 66ba2a9..f67026e 100644 --- a/sakura-server/minecraft-patches/features/0005-Add-redstone-implementation-api.patch +++ b/sakura-server/minecraft-patches/features/0005-Add-redstone-implementation-api.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add redstone implementation api diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index ddd70576d1551d77cbefb9d63bbbaf94b569b074..a9db955a90e0b44d3c85e39f2f7ae9ea4f68a316 100644 +index 8268ac128d0a2dfb9eee9a46630862bdd04a747e..7390a21f7c6991d3fb62fda9e88bc9212159177b 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java @@ -275,7 +275,7 @@ public class RedStoneWireBlock extends Block { @@ -19,7 +19,7 @@ index ddd70576d1551d77cbefb9d63bbbaf94b569b074..a9db955a90e0b44d3c85e39f2f7ae9ea // to find the direction of information flow @@ -348,7 +348,7 @@ public class RedStoneWireBlock extends Block { protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { - if (!oldState.is(state.getBlock()) && !level.isClientSide) { + if (!oldState.is(state.getBlock()) && !level.isClientSide()) { // Paper start - optimize redstone - replace call to updatePowerStrength - if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { + if (level.localConfig().at(pos).paperRedstoneImplementation() == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura - redstone implementation api @@ -36,7 +36,7 @@ index ddd70576d1551d77cbefb9d63bbbaf94b569b074..a9db955a90e0b44d3c85e39f2f7ae9ea } else { this.updateSurroundingRedstone(level, pos, state, null, false); // Vanilla/Eigencraft @@ -401,7 +401,7 @@ public class RedStoneWireBlock extends Block { - if (!level.isClientSide) { + if (!level.isClientSide()) { // Paper start - optimize redstone (Alternate Current) // Alternate Current handles breaking of redstone wires in the WireHandler. - if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { diff --git a/sakura-server/minecraft-patches/features/0006-Optimise-paper-explosions.patch b/sakura-server/minecraft-patches/features/0006-Optimise-paper-explosions.patch index d935487..a3f90cc 100644 --- a/sakura-server/minecraft-patches/features/0006-Optimise-paper-explosions.patch +++ b/sakura-server/minecraft-patches/features/0006-Optimise-paper-explosions.patch @@ -40,10 +40,10 @@ index b2bcfb3557a0326fd7ec1059f95d6da4568dfd80..8df264c86ab14f4e7aa9918a3341ef35 if (this.count == 0) { return; diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index f99a254d140f96feab9436b7799eec4804500033..0b3abcd143e7f81d5feaf75f74ce19a6915be7be 100644 +index 6626dd51bba3bbc979f0e641243ce864f88925ca..a3e47902098331ce1dfcbb96909e4a8cd5d7da78 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -86,7 +86,7 @@ public class ServerExplosion implements Explosion { +@@ -88,7 +88,7 @@ public class ServerExplosion implements Explosion { } } @@ -52,7 +52,7 @@ index f99a254d140f96feab9436b7799eec4804500033..0b3abcd143e7f81d5feaf75f74ce19a6 } private static final int CHUNK_CACHE_SHIFT = 2; -@@ -398,6 +398,12 @@ public class ServerExplosion implements Explosion { +@@ -400,6 +400,12 @@ public class ServerExplosion implements Explosion { initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true); } @@ -65,110 +65,10 @@ index f99a254d140f96feab9436b7799eec4804500033..0b3abcd143e7f81d5feaf75f74ce19a6 // only ~1/3rd of the loop iterations in vanilla will result in a ray, as it is iterating the perimeter of // a 16x16x16 cube // we can cache the rays and their normals as well, so that we eliminate the excess iterations / checks and -@@ -476,16 +482,62 @@ public class ServerExplosion implements Explosion { - // Paper end - collision optimisations - } - -+ // Sakura start - optimise paper explosions -+ protected final AABB getExplosionBounds(final float impactRadius) { -+ final int minX = Mth.floor(this.center.x - impactRadius - 1.0); -+ final int maxX = Mth.floor(this.center.x + impactRadius + 1.0); -+ final int minY = Mth.floor(this.center.y - impactRadius - 1.0); -+ final int maxY = Mth.floor(this.center.y + impactRadius + 1.0); -+ final int minZ = Mth.floor(this.center.z - impactRadius - 1.0); -+ final int maxZ = Mth.floor(this.center.z + impactRadius + 1.0); -+ return new AABB(minX, minY, minZ, maxX, maxY, maxZ); -+ } -+ - private void hurtEntities() { -- float f = this.radius * 2.0F; -- int floor = Mth.floor(this.center.x - f - 1.0); -- int floor1 = Mth.floor(this.center.x + f + 1.0); -- int floor2 = Mth.floor(this.center.y - f - 1.0); -- int floor3 = Mth.floor(this.center.y + f + 1.0); -- int floor4 = Mth.floor(this.center.z - f - 1.0); -- int floor5 = Mth.floor(this.center.z + f + 1.0); -- List list = this.level.getEntities(this.excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source -- for (Entity entity : list) { // Paper - used in loop -+ final float impactRadius = this.radius * 2.0F; -+ -+ final int minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(this.level); -+ final int maxSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxSection(this.level); -+ -+ final int minChunkX = Mth.floor(this.center.x - impactRadius) >> 4; -+ final int maxChunkX = Mth.floor(this.center.x + impactRadius) >> 4; -+ final int minChunkY = Mth.clamp(Mth.floor(this.center.y - impactRadius) >> 4, minSection, maxSection); -+ final int maxChunkY = Mth.clamp(Mth.floor(this.center.y + impactRadius) >> 4, minSection, maxSection); -+ final int minChunkZ = Mth.floor(this.center.z - impactRadius) >> 4; -+ final int maxChunkZ = Mth.floor(this.center.z + impactRadius) >> 4; -+ -+ final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup entityLookup = this.level.moonrise$getEntityLookup(); -+ for (int chunkX = minChunkX; chunkX <= maxChunkX; ++chunkX) { -+ for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; ++chunkZ) { -+ final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices chunk = entityLookup.getChunk(chunkX, chunkZ); -+ if (chunk == null) { -+ continue; // empty slice -+ } -+ -+ for (int chunkY = minChunkY; chunkY <= maxChunkY; ++chunkY) { -+ this.impactEntities(impactRadius, chunk.getSectionEntities(chunkY)); -+ } -+ } -+ } -+ } -+ -+ protected final void impactEntities(final float impactRadius, final Entity[] entities) { -+ for (int index = 0; index < entities.length; index++) { -+ final Entity entity = entities[index]; -+ if (entity == null) break; // end of entity slice -+ -+ this.impactEntity(impactRadius, entity); -+ -+ // Entities can be removed from the world mid-explosion. -+ if (entity != entities[index]) { -+ index--; -+ } -+ } -+ } -+ -+ protected final void impactEntity(final float f, final Entity entity) { -+ if (entity.isAlive() && !entity.isSpectator() && (!this.excludeSourceFromDamage || entity != this.source)) { // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source -+ // Sakura end - optimise paper explosions - if (!entity.ignoreExplosion(this)) { - double d = Math.sqrt(entity.distanceToSqr(this.center)) / f; - if (d <= 1.0) { -@@ -510,15 +562,16 @@ public class ServerExplosion implements Explosion { - // - Damaging EnderDragon does nothing - // - EnderDragon hitbox always covers the other parts and is therefore always present - if (entity instanceof EnderDragonPart) { -- continue; -+ return; // Sakura - optimise paper explosions - } - - entity.lastDamageCancelled = false; - - if (entity instanceof EnderDragon) { -+ final AABB bounds = this.getExplosionBounds(f); // Sakura - optimise paper explosions - for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) { - // Calculate damage separately for each EntityComplexPart -- if (list.contains(dragonPart)) { -+ if (dragonPart.getBoundingBox().intersects(bounds)) { // Sakura - optimise paper explosions - dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, dragonPart, f1)); - } - } -@@ -527,7 +580,7 @@ public class ServerExplosion implements Explosion { - } - - if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled -- continue; -+ return; // Sakura - optimise paper explosions - } - // CraftBukkit end - } -@@ -570,7 +623,7 @@ public class ServerExplosion implements Explosion { +@@ -558,7 +564,7 @@ public class ServerExplosion implements Explosion { // CraftBukkit start - Location location = CraftLocation.toBukkit(this.center, this.level.getWorld()); + Location location = CraftLocation.toBukkit(this.center, this.level); - List blockList = new ObjectArrayList<>(); + List blockList = new ObjectArrayList<>(fire ? ObjectArrayList.DEFAULT_INITIAL_CAPACITY : blocks.size()); // Sakura - optimise paper explosions for (int i1 = blocks.size() - 1; i1 >= 0; i1--) { diff --git a/sakura-server/minecraft-patches/features/0007-Store-Entity-Data-State.patch b/sakura-server/minecraft-patches/features/0007-Store-Entity-Data-State.patch index 155c6dd..4f87e90 100644 --- a/sakura-server/minecraft-patches/features/0007-Store-Entity-Data-State.patch +++ b/sakura-server/minecraft-patches/features/0007-Store-Entity-Data-State.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Store Entity Data/State diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index a13f7613115f08461ed6852fd35bc19f4923063d..815f92176821bf4117952450e97bd5b044c78b58 100644 +index eb157e848ea97ea11bbf233d473e6a62a23bf32f..127479da921c2679e19f13e71cc04be8a310b459 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -550,6 +550,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -552,6 +552,21 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return flags; } // Sakura end - load chunks on movement @@ -31,14 +31,14 @@ index a13f7613115f08461ed6852fd35bc19f4923063d..815f92176821bf4117952450e97bd5b0 public Entity(EntityType entityType, Level level) { this.type = entityType; diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 44e4c907801b934c188cf67bf3c75023a52a948f..4ff7fdc9a75e7d31170385016bf8ea75c45719a1 100644 +index 4b2ea3c99bcd5452840b26c2ba607a4f034ba367..5f49990b13ac7fdd4366585d976d50bd3ae183cb 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1498,6 +1498,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1448,6 +1448,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - public void guardEntityTick(Consumer consumerEntity, T entity) { + public void guardEntityTick(Consumer action, T entity) { try { + entity.storeEntityState(); // Sakura - store entity data/state - consumerEntity.accept(entity); + action.accept(entity); } catch (Throwable var6) { // Paper start - Prevent block entity and entity crashes diff --git a/sakura-server/minecraft-patches/features/0008-Merge-Cannon-Entities.patch b/sakura-server/minecraft-patches/features/0008-Merge-Cannon-Entities.patch index a785468..2bf7b13 100644 --- a/sakura-server/minecraft-patches/features/0008-Merge-Cannon-Entities.patch +++ b/sakura-server/minecraft-patches/features/0008-Merge-Cannon-Entities.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Merge Cannon Entities diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 2a7c057ccfeb5dbe6b14ff660c0bb342571d88e7..496e23c110cbb3b60a6565e1903545e09715f79e 100644 +index bc714079924b4a724a6f1aa7ccfa53884a9e4fa9..259faa131f4aec7db565c78c38aa058d20ef3d28 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -692,6 +692,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -709,6 +709,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end - rewrite chunk system this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit this.levelTickScheduler.repeatingTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings @@ -16,7 +16,7 @@ index 2a7c057ccfeb5dbe6b14ff660c0bb342571d88e7..496e23c110cbb3b60a6565e1903545e0 } // Paper start -@@ -806,6 +807,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -827,6 +828,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR @@ -24,7 +24,7 @@ index 2a7c057ccfeb5dbe6b14ff660c0bb342571d88e7..496e23c110cbb3b60a6565e1903545e0 this.entityTickList .forEach( entity -> { -@@ -824,6 +826,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -845,6 +847,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe entity.stopRiding(); } @@ -41,10 +41,10 @@ index 2a7c057ccfeb5dbe6b14ff660c0bb342571d88e7..496e23c110cbb3b60a6565e1903545e0 this.guardEntityTick(this::tickNonPassenger, entity); profilerFiller.pop(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 815f92176821bf4117952450e97bd5b044c78b58..bf46bb5b61f4ec6f23aacec41426d0ffe5a265fb 100644 +index 127479da921c2679e19f13e71cc04be8a310b459..4ce3d09d30996fb2c13afe799bb31d910ce666ba 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -565,6 +565,27 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -567,6 +567,27 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return to.entityState() != null && to.entityState().comparePositionAndMotion(this); } // Sakura end - store entity data/state @@ -72,7 +72,7 @@ index 815f92176821bf4117952450e97bd5b044c78b58..bf46bb5b61f4ec6f23aacec41426d0ff public Entity(EntityType entityType, Level level) { this.type = entityType; -@@ -5176,6 +5197,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5241,6 +5262,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name if (this.removalReason != Entity.RemovalReason.UNLOADED_TO_CHUNK) { this.getPassengers().forEach(Entity::stopRiding); } // Paper - rewrite chunk system this.levelCallback.onRemove(removalReason); this.onRemoval(removalReason); @@ -85,7 +85,7 @@ index 815f92176821bf4117952450e97bd5b044c78b58..bf46bb5b61f4ec6f23aacec41426d0ff if (!(this instanceof ServerPlayer) && removalReason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) { // Players need to be special cased, because they are regularly removed from the world diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index d35183f10362952c0c38061ccdedc1a578c91c2d..8ea534e6f49b787f5445093203f41410668e42bd 100644 +index 59aa539b7d830de48ff582b0da6fa17796b8c4b8..af7dd04ecbf9e8b35357da421fb156aee61261b5 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -53,7 +53,7 @@ import net.minecraft.world.phys.HitResult; @@ -167,9 +167,9 @@ index d35183f10362952c0c38061ccdedc1a578c91c2d..8ea534e6f49b787f5445093203f41410 // CraftBukkit end + if (this.tryToRespawnEntity()) return; // Sakura - merge cannon entities if (this.level().setBlock(blockPos, this.blockState, 3)) { - ((ServerLevel)this.level()) - .getChunkSource() -@@ -346,6 +398,11 @@ public class FallingBlockEntity extends Entity { + serverLevel.getChunkSource() + .chunkMap +@@ -345,6 +397,11 @@ public class FallingBlockEntity extends Entity { output.putBoolean("CancelDrop", this.cancelDrop); if (!this.autoExpire) output.putBoolean("Paper.AutoExpire", false); // Paper - Expand FallingBlock API @@ -181,7 +181,7 @@ index d35183f10362952c0c38061ccdedc1a578c91c2d..8ea534e6f49b787f5445093203f41410 } @Override -@@ -360,6 +417,7 @@ public class FallingBlockEntity extends Entity { +@@ -359,6 +416,7 @@ public class FallingBlockEntity extends Entity { this.blockData = input.read("TileEntityData", CompoundTag.CODEC).map(blockData -> this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock ? null : blockData).map(CompoundTag::copy).orElse(null); // Paper - Filter bad block entity nbt data from falling blocks this.cancelDrop = input.getBooleanOr("CancelDrop", false); this.autoExpire = input.getBooleanOr("Paper.AutoExpire", true); // Paper - Expand FallingBlock API @@ -190,7 +190,7 @@ index d35183f10362952c0c38061ccdedc1a578c91c2d..8ea534e6f49b787f5445093203f41410 public void setHurtsEntities(float fallDamagePerDistance, int fallDamageMax) { diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java -index b53baca84c9022a700fbc1150264fc805af6a61e..95d57f9aea21860ff886a27cc5641d7c96882f34 100644 +index 6797e16f973b11d168906dfce240c70db25bc6f0..8a36e0ce4792e7152905256dde7746fd09d42729 100644 --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java @@ -34,7 +34,7 @@ import org.bukkit.event.entity.EntityRemoveEvent; @@ -256,7 +256,7 @@ index b53baca84c9022a700fbc1150264fc805af6a61e..95d57f9aea21860ff886a27cc5641d7c // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event //this.discard(); + this.tryToRespawnEntity(); // Sakura - merge cannon entities - if (!this.level().isClientSide) { + if (!this.level().isClientSide()) { this.explode(); } @@ -203,6 +241,11 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -280,10 +280,10 @@ index b53baca84c9022a700fbc1150264fc805af6a61e..95d57f9aea21860ff886a27cc5641d7c @Nullable diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 4ff7fdc9a75e7d31170385016bf8ea75c45719a1..7b9e61b2286d18f55a365eebda1fe2128023bec9 100644 +index 5f49990b13ac7fdd4366585d976d50bd3ae183cb..93ff0fdaee21ac493833640b5f620f9bec1a69c8 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -828,6 +828,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -833,6 +833,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public final me.samsuik.sakura.listener.LevelTickScheduler levelTickScheduler = new me.samsuik.sakura.listener.LevelTickScheduler(this); public final me.samsuik.sakura.listener.BlockChangeTracker blockChangeTracker = new me.samsuik.sakura.listener.BlockChangeTracker(this); // Sakura end - track block changes and tick scheduler @@ -292,7 +292,7 @@ index 4ff7fdc9a75e7d31170385016bf8ea75c45719a1..7b9e61b2286d18f55a365eebda1fe212 protected Level( WritableLevelData levelData, diff --git a/net/minecraft/world/level/block/BasePressurePlateBlock.java b/net/minecraft/world/level/block/BasePressurePlateBlock.java -index 42ee3f32fe44c1f0680c994a69201f7bd7792673..79593698d532a41c3f75c00b3452b6f0aa092845 100644 +index fe9b5cf6fb8d8221b98836148e95aa857241181d..f9c1c5a7f0602c225d18005e7161384cc1d3c604 100644 --- a/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java @@ -92,7 +92,7 @@ public abstract class BasePressurePlateBlock extends Block { diff --git a/sakura-server/minecraft-patches/features/0009-Replace-explosion-density-cache.patch b/sakura-server/minecraft-patches/features/0009-Replace-explosion-density-cache.patch index 3bc72c5..d9616eb 100644 --- a/sakura-server/minecraft-patches/features/0009-Replace-explosion-density-cache.patch +++ b/sakura-server/minecraft-patches/features/0009-Replace-explosion-density-cache.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Replace explosion density cache diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 496e23c110cbb3b60a6565e1903545e09715f79e..a73395c1ec0f36019de553c39199957032e316c4 100644 +index 259faa131f4aec7db565c78c38aa058d20ef3d28..efdf41c42320ac9defd5d0eb206df5aaed012363 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -693,6 +693,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -710,6 +710,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit this.levelTickScheduler.repeatingTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings this.levelTickScheduler.repeatingTask(this.mergeHandler::expire, 200); // Sakura - merge cannon entities @@ -17,10 +17,10 @@ index 496e23c110cbb3b60a6565e1903545e09715f79e..a73395c1ec0f36019de553c391999570 // Paper start diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 7b9e61b2286d18f55a365eebda1fe2128023bec9..7a30a227a417ecf9f16ce97d53b238935e652d68 100644 +index 93ff0fdaee21ac493833640b5f620f9bec1a69c8..e807aafed0295d8db7ba0782bb1e462561e9e1ec 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -829,6 +829,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -834,6 +834,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public final me.samsuik.sakura.listener.BlockChangeTracker blockChangeTracker = new me.samsuik.sakura.listener.BlockChangeTracker(this); // Sakura end - track block changes and tick scheduler public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities @@ -29,10 +29,10 @@ index 7b9e61b2286d18f55a365eebda1fe2128023bec9..7a30a227a417ecf9f16ce97d53b23893 protected Level( WritableLevelData levelData, diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index cc6ee993470a274cdad124b4a7befb016d9a2b6e..fde0528e00939972adc2f48b1456002dcd28343b 100644 +index a3e47902098331ce1dfcbb96909e4a8cd5d7da78..39a4f8ffb7c0e61d94c4384c4a3f77550fefe16f 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -294,7 +294,12 @@ public class ServerExplosion implements Explosion { +@@ -296,7 +296,12 @@ public class ServerExplosion implements Explosion { Math.fma(dz, diffZ, offZ) ); @@ -46,7 +46,7 @@ index cc6ee993470a274cdad124b4a7befb016d9a2b6e..fde0528e00939972adc2f48b1456002d ++missedRays; } } -@@ -352,8 +357,16 @@ public class ServerExplosion implements Explosion { +@@ -354,8 +359,16 @@ public class ServerExplosion implements Explosion { double d9 = Mth.lerp(d6, boundingBox.minY, boundingBox.maxY); double d10 = Mth.lerp(d7, boundingBox.minZ, boundingBox.maxZ); Vec3 vec3 = new Vec3(d8 + d3, d9, d10 + d4); @@ -65,7 +65,7 @@ index cc6ee993470a274cdad124b4a7befb016d9a2b6e..fde0528e00939972adc2f48b1456002d i++; } -@@ -656,6 +669,11 @@ public class ServerExplosion implements Explosion { +@@ -597,6 +610,11 @@ public class ServerExplosion implements Explosion { return; } // CraftBukkit end @@ -77,7 +77,7 @@ index cc6ee993470a274cdad124b4a7befb016d9a2b6e..fde0528e00939972adc2f48b1456002d for (BlockPos blockPos : blocks) { // CraftBukkit start - TNTPrimeEvent -@@ -822,14 +840,12 @@ public class ServerExplosion implements Explosion { +@@ -765,14 +783,12 @@ public class ServerExplosion implements Explosion { // Paper start - Optimize explosions protected float getBlockDensity(Vec3 vec3d, Entity entity) { @@ -98,7 +98,7 @@ index cc6ee993470a274cdad124b4a7befb016d9a2b6e..fde0528e00939972adc2f48b1456002d return blockDensity; diff --git a/net/minecraft/world/level/block/BasePressurePlateBlock.java b/net/minecraft/world/level/block/BasePressurePlateBlock.java -index 79593698d532a41c3f75c00b3452b6f0aa092845..2ea14093ba70d6e0e7407c18fb0570f5a15d8c2a 100644 +index f9c1c5a7f0602c225d18005e7161384cc1d3c604..a43dfc0ebd28d42d4334021ac7255e496f78c6b7 100644 --- a/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java @@ -107,6 +107,11 @@ public abstract class BasePressurePlateBlock extends Block { @@ -130,7 +130,7 @@ index 8a3a8b0fdf9545a41501dc992c6982d9c8ce7b66..5e2576a8b90de8a829c6136cc384f3fe notifyNeighbors(block, level, blockPosx, opposite); emitState(level, blockPosx, flag2, flag3, flag, flag1); diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java -index 84f3073444ae9e11e5d11224d6af6474ced925e2..cc0ce70aa363a5ba64c5f7eda579cd00fbb6cd4c 100644 +index f87d0bd3d65155fbc206a0dae8de67a9184436f3..da90795ce9d4589ee9a4b5ab10f3af59c772547b 100644 --- a/net/minecraft/world/phys/AABB.java +++ b/net/minecraft/world/phys/AABB.java @@ -19,6 +19,30 @@ public class AABB { diff --git a/sakura-server/minecraft-patches/features/0010-Optimise-explosions-in-protected-regions.patch b/sakura-server/minecraft-patches/features/0010-Optimise-explosions-in-protected-regions.patch index b3e663c..7939b6d 100644 --- a/sakura-server/minecraft-patches/features/0010-Optimise-explosions-in-protected-regions.patch +++ b/sakura-server/minecraft-patches/features/0010-Optimise-explosions-in-protected-regions.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Optimise explosions in protected regions diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index c3c90cc17c4f1ebcaddffea4087929e3708aa22f..000e1ffcebd6f529133af1edbed6da80b9848e75 100644 +index 39a4f8ffb7c0e61d94c4384c4a3f77550fefe16f..17aaa7cd99f9a0f1d1c31c72bea2973eeb71e600 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -309,6 +309,22 @@ public class ServerExplosion implements Explosion { +@@ -311,6 +311,22 @@ public class ServerExplosion implements Explosion { return (float)missedRays / (float)totalRays; } // Paper end - collisions optimisations @@ -31,7 +31,7 @@ index c3c90cc17c4f1ebcaddffea4087929e3708aa22f..000e1ffcebd6f529133af1edbed6da80 public ServerExplosion( ServerLevel level, -@@ -416,6 +432,11 @@ public class ServerExplosion implements Explosion { +@@ -418,6 +434,11 @@ public class ServerExplosion implements Explosion { return ret; } // Sakura end - optimise paper explosions diff --git a/sakura-server/minecraft-patches/features/0011-Specialised-Explosions.patch b/sakura-server/minecraft-patches/features/0011-Specialised-Explosions.patch index dd86d1b..c5802dc 100644 --- a/sakura-server/minecraft-patches/features/0011-Specialised-Explosions.patch +++ b/sakura-server/minecraft-patches/features/0011-Specialised-Explosions.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Specialised Explosions diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 8c4b4cb9e98b8c0334bb7e247e67206bd57c3de2..573b1695abde0d89d5702a60a84919167ef4baab 100644 +index efdf41c42320ac9defd5d0eb206df5aaed012363..733c5d7419cae21300d40fb13979dd40ecdd6810 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -1914,7 +1914,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1947,7 +1947,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe case STANDARD -> Explosion.BlockInteraction.DESTROY; // CraftBukkit - handle custom explosion type }; Vec3 vec3 = new Vec3(x, y, z); @@ -16,47 +16,55 @@ index 8c4b4cb9e98b8c0334bb7e247e67206bd57c3de2..573b1695abde0d89d5702a60a8491916 + // Sakura start - specialised explosions + final ServerExplosion serverExplosion; + if (source instanceof net.minecraft.world.entity.item.PrimedTnt tnt) { -+ serverExplosion = new me.samsuik.sakura.explosion.TntExplosion(this, tnt, damageSource, damageCalculator, vec3, radius, fire, blockInteraction, self -> { -+ this.notifyPlayersOfExplosion(self, self.center(), smallExplosionParticles, largeExplosionParticles, explosionSound); -+ }); ++ serverExplosion = new me.samsuik.sakura.explosion.TntExplosion(this, tnt, damageSource, damageCalculator, vec3, radius, fire, blockInteraction); + } else { + serverExplosion = new ServerExplosion(this, source, damageSource, damageCalculator, vec3, radius, fire, blockInteraction); + } + // Sakura end - specialised explosions if (configurator != null) configurator.accept(serverExplosion);// Paper - Allow explosions to damage source - serverExplosion.explode(); + int i = serverExplosion.explode(); // CraftBukkit start -@@ -1922,6 +1931,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1955,6 +1962,29 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe return serverExplosion; } // CraftBukkit end + // Sakura start - specialised explosions -+ this.notifyPlayersOfExplosion(serverExplosion, vec3, smallExplosionParticles, largeExplosionParticles, explosionSound); ++ if (serverExplosion instanceof me.samsuik.sakura.explosion.SpecialisedExplosion specialisedExplosion) { ++ me.samsuik.sakura.explosion.ExplosionToSend explosionToSend; ++ while ((explosionToSend = specialisedExplosion.getExplosionsToSend().poll()) != null) { ++ this.notifyPlayersOfExplosion(serverExplosion, explosionToSend.position(), radius, explosionToSend.blocksDestroyed(), smallExplosionParticles, largeExplosionParticles, explosionSound, blockParticles); ++ } ++ } ++ ++ this.notifyPlayersOfExplosion(serverExplosion, vec3, radius, i, smallExplosionParticles, largeExplosionParticles, explosionSound, blockParticles); + return serverExplosion; + } + + private void notifyPlayersOfExplosion( + final ServerExplosion serverExplosion, + final Vec3 vec3, ++ final float radius, ++ final int i, + final ParticleOptions smallExplosionParticles, + final ParticleOptions largeExplosionParticles, -+ final Holder explosionSound ++ final Holder explosionSound, ++ final WeightedList blockParticles + ) { + // Sakura end - specialised explosions ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer serverPlayer : this.players) { -@@ -1942,7 +1964,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1977,7 +2007,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } - return serverExplosion; // CraftBukkit -+ // Sakura - specialised explosions; return moved up into explode0 ++ serverExplosion.getHitPlayers().clear(); // Sakura - specialised explosions } private Explosion.BlockInteraction getDestroyType(GameRules.Key decayGameRule) { diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java -index 95d57f9aea21860ff886a27cc5641d7c96882f34..45a528169a57ecc287ae4f527d1d98b597a48f04 100644 +index 8a36e0ce4792e7152905256dde7746fd09d42729..b349149592b09512b573911e95fd13915ba698cd 100644 --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java @@ -79,20 +79,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -82,10 +90,10 @@ index 95d57f9aea21860ff886a27cc5641d7c96882f34..45a528169a57ecc287ae4f527d1d98b5 // Sakura end - merge cannon entities diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index 000e1ffcebd6f529133af1edbed6da80b9848e75..d2b33fb06ce9a806466208d7afd65fa8d3da0292 100644 +index 17aaa7cd99f9a0f1d1c31c72bea2973eeb71e600..0f95ffa2551289cb74d0210673b942ca90be74d3 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -325,6 +325,38 @@ public class ServerExplosion implements Explosion { +@@ -327,6 +327,38 @@ public class ServerExplosion implements Explosion { return true; } // Sakura end - optimise explosion protected regions @@ -101,16 +109,6 @@ index 000e1ffcebd6f529133af1edbed6da80b9848e75..d2b33fb06ce9a806466208d7afd65fa8 + // Paper end - collision optimisations + } + -+ protected final void markBlocksInCacheAsExplodable(final List explodedPositions) { -+ for (final BlockPos blow : explodedPositions) { -+ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache cache = this.blockCache.get(blow.asLong()); -+ // May be null if the blockCache is cleared then retrieved from the recent block cache -+ if (cache != null) { -+ cache.shouldExplode = null; -+ } -+ } -+ } -+ + protected final void clearBlockCache() { + // Paper start - collision optimisations + this.blockCache = null; @@ -120,26 +118,92 @@ index 000e1ffcebd6f529133af1edbed6da80b9848e75..d2b33fb06ce9a806466208d7afd65fa8 + this.mutablePos = null; + // Paper end - collision optimisations + } ++ ++ protected final void markBlocksInCacheAsExplodable(final List explodedPositions) { ++ for (final BlockPos explodedPos : explodedPositions) { ++ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache cache = this.blockCache.get(explodedPos.asLong()); ++ // May be null if the blockCache is cleared then retrieved from the recent block cache ++ if (cache != null) { ++ cache.shouldExplode = null; ++ } ++ } ++ } + // Sakura end - specialised explosions public ServerExplosion( ServerLevel level, -@@ -641,7 +673,10 @@ public class ServerExplosion implements Explosion { - // CraftBukkit end - entity.push(vec3); - if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback -- this.hitPlayers.put(player, vec3); -+ // Sakura start - specialised explosions; tally player velocity -+ final Vec3 explosionImpact = vec3; -+ this.hitPlayers.compute(player, (p, v) -> v != null ? v.add(explosionImpact) : explosionImpact); -+ // Sakura end - specialised explosions; tally player velocity +@@ -520,14 +552,25 @@ public class ServerExplosion implements Explosion { + + private void hurtEntities() { + float f = this.radius * 2.0F; ++ // Sakura start - specialised explosions ++ for (final Entity entity : this.level.getEntities(null, this.getExplosionBounds(f))) { ++ this.impactEntity(f, entity); ++ } ++ } ++ ++ private AABB getExplosionBounds(final float f) { + int floor = Mth.floor(this.center.x - f - 1.0); + int floor1 = Mth.floor(this.center.x + f + 1.0); + int floor2 = Mth.floor(this.center.y - f - 1.0); + int floor3 = Mth.floor(this.center.y + f + 1.0); + int floor4 = Mth.floor(this.center.z - f - 1.0); + int floor5 = Mth.floor(this.center.z + f + 1.0); +- List list = this.level.getEntities(this.excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source +- for (Entity entity : list) { // Paper - used in loop ++ return new AABB(floor, floor2, floor4, floor1, floor3, floor5); ++ } ++ ++ protected final void impactEntity(final float f, final Entity entity) { ++ if (entity.isAlive() && !entity.isSpectator() && (!this.excludeSourceFromDamage || entity != this.source)) { // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source ++ // Sakura end - specialised explosions + if (!entity.ignoreExplosion(this)) { + double d = Math.sqrt(entity.distanceToSqr(this.center)) / f; + if (!(d > 1.0)) { +@@ -546,15 +589,16 @@ public class ServerExplosion implements Explosion { + // - Damaging EnderDragon does nothing + // - EnderDragon hitbox always covers the other parts and is therefore always present + if (entity instanceof EnderDragonPart) { +- continue; ++ return; // Sakura - specialised explosions } - entity.onExplosionHit(this.source); -@@ -746,14 +781,7 @@ public class ServerExplosion implements Explosion { + entity.lastDamageCancelled = false; + + if (entity instanceof EnderDragon) { ++ final AABB explosionBounds = this.getExplosionBounds(f); // Sakura - specialised explosions + for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) { + // Calculate damage separately for each EntityComplexPart +- if (list.contains(dragonPart)) { ++ if (explosionBounds.intersects(dragonPart.getBoundingBox())) { // Sakura - specialised explosions + dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, dragonPart, f1)); + } + } +@@ -563,7 +607,7 @@ public class ServerExplosion implements Explosion { + } + + if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled +- continue; ++ return; // Sakura - specialised explosions + } + // CraftBukkit end + } +@@ -583,7 +627,10 @@ public class ServerExplosion implements Explosion { + if (entity.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && entity instanceof Projectile projectile) { + projectile.setOwner(this.damageSource.getEntity()); + } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback +- this.hitPlayers.put(player, vec32); ++ // Sakura start - specialised explosions; tally player velocity ++ final Vec3 explosionImpact = vec32; ++ this.hitPlayers.compute(player, (p, v) -> v != null ? v.add(explosionImpact) : explosionImpact); ++ // Sakura end - specialised explosions; tally player velocity + } + + entity.onExplosionHit(this.source); +@@ -687,14 +734,7 @@ public class ServerExplosion implements Explosion { } - public void explode() { + public int explode() { - // Paper start - collision optimisations - this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(); - this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH]; @@ -152,10 +216,10 @@ index 000e1ffcebd6f529133af1edbed6da80b9848e75..d2b33fb06ce9a806466208d7afd65fa8 this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); List list = this.calculateExplodedPositions(); this.hurtEntities(); -@@ -767,13 +795,7 @@ public class ServerExplosion implements Explosion { - if (this.fire) { +@@ -709,13 +749,7 @@ public class ServerExplosion implements Explosion { this.createFire(list); } + - // Paper start - collision optimisations - this.blockCache = null; - this.chunkPosCache = null; @@ -164,6 +228,6 @@ index 000e1ffcebd6f529133af1edbed6da80b9848e75..d2b33fb06ce9a806466208d7afd65fa8 - this.mutablePos = null; - // Paper end - collision optimisations + this.clearBlockCache(); // Sakura - specialised explosions + return list.size(); } - private static void addOrAppendStack(List stackCollectors, ItemStack stack, BlockPos pos) { diff --git a/sakura-server/minecraft-patches/features/0012-Optimise-cannon-entity-movement.patch b/sakura-server/minecraft-patches/features/0012-Optimise-cannon-entity-movement.patch index 77ff666..823151b 100644 --- a/sakura-server/minecraft-patches/features/0012-Optimise-cannon-entity-movement.patch +++ b/sakura-server/minecraft-patches/features/0012-Optimise-cannon-entity-movement.patch @@ -5,24 +5,24 @@ Subject: [PATCH] Optimise cannon entity movement diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index bf46bb5b61f4ec6f23aacec41426d0ffe5a265fb..eaa57560a20841a2b218ff2fd9059f82339a678c 100644 +index 4ce3d09d30996fb2c13afe799bb31d910ce666ba..0c20de0f6af0385a7849cb9b0be86049784d59ae 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -1190,7 +1190,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1200,7 +1200,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name Vec3 vec3 = this.collide(movement); double d = vec3.lengthSqr(); if (d > 1.0E-7 || movement.lengthSqr() - d < 1.0E-7) { - if (this.fallDistance != 0.0 && d >= 1.0) { + if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock) { // Sakura - optimise cannon entity movement + double min = Math.min(vec3.length(), 8.0); + Vec3 vec31 = this.position().add(vec3.normalize().scale(min)); BlockHitResult blockHitResult = this.level() - .clip( - new ClipContext(this.position(), this.position().add(vec3), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this) -@@ -1538,6 +1538,132 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - return distance; +@@ -1555,6 +1555,132 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + return list.isEmpty() ? distance : -Shapes.collide(Direction.Axis.Y, boundingBox, list, -distance); } + // Sakura start - optimise cannon entity movement -+ protected final Vec3 sakura_collide(final Vec3 movement) { ++ protected final Vec3 sakura$collide(final Vec3 movement) { + if (movement.x == 0.0 && movement.y == 0.0 && movement.z == 0.0) { + return movement; + } @@ -151,7 +151,7 @@ index bf46bb5b61f4ec6f23aacec41426d0ffe5a265fb..eaa57560a20841a2b218ff2fd9059f82 protected Vec3 collide(Vec3 movement) { final boolean xZero = movement.x == 0.0; diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index 8ea534e6f49b787f5445093203f41410668e42bd..f7807b56bf935e1686ac893c0752e92e1115ffbe 100644 +index af7dd04ecbf9e8b35357da421fb156aee61261b5..0344ba2a6d063a4ee5d6f9a8985ae8ca8c5816ce 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -124,6 +124,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -161,14 +161,14 @@ index 8ea534e6f49b787f5445093203f41410668e42bd..f7807b56bf935e1686ac893c0752e92e + // Sakura start - optimise cannon entity movement + @Override + protected final Vec3 collide(final Vec3 movement) { -+ return this.sakura_collide(movement); ++ return this.sakura$collide(movement); + } + // Sakura end - optimise cannon entity movement public FallingBlockEntity(EntityType entityType, Level level) { super(entityType, level); diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java -index 45a528169a57ecc287ae4f527d1d98b597a48f04..e476d500df5e197f87863d9fdb61065af68778dd 100644 +index b349149592b09512b573911e95fd13915ba698cd..05003798585d98406cd1affb89403b9f955bacdc 100644 --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java @@ -82,6 +82,12 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -178,7 +178,7 @@ index 45a528169a57ecc287ae4f527d1d98b597a48f04..e476d500df5e197f87863d9fdb61065a + // Sakura start - optimise cannon entity movement + @Override + protected final net.minecraft.world.phys.Vec3 collide(final net.minecraft.world.phys.Vec3 movement) { -+ return this.sakura_collide(movement); ++ return this.sakura$collide(movement); + } + // Sakura end - optimise cannon entity movement diff --git a/sakura-server/minecraft-patches/features/0013-Add-maxSearch-to-getEntities.patch b/sakura-server/minecraft-patches/features/0013-Add-maxSearch-to-getEntities.patch index 43c5651..f2d84aa 100644 --- a/sakura-server/minecraft-patches/features/0013-Add-maxSearch-to-getEntities.patch +++ b/sakura-server/minecraft-patches/features/0013-Add-maxSearch-to-getEntities.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add maxSearch to getEntities diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -index bd2055bc89c5672b514f1f7b1ad320a2fba7cbe2..7678696aa2fa74358a374a501a6b7f76f4805945 100644 +index 8df264c86ab14f4e7aa9918a3341ef35ffaa5290..9d90db0c55df85ac26c91b42fb9e72baad940e8f 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java @@ -336,7 +336,14 @@ public final class ChunkEntitySlices { @@ -83,10 +83,10 @@ index 2d24d03bbdb5ee0d862cbfff2219f58afffafe12..1bf06038d51efcc103fad23670686c30 } } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index c24f09cf9959310353bd0fc5a5ff7498c6ea47a0..ca5e2ec53590b731aedf33dfd69e728992f52b91 100644 +index e807aafed0295d8db7ba0782bb1e462561e9e1ec..af39222e08bc7957ac40ea9fd6aae517e7cee45a 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1772,10 +1772,18 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1728,10 +1728,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl this.getEntities(entityTypeTest, bounds, predicate, output, Integer.MAX_VALUE); } @@ -106,7 +106,7 @@ index c24f09cf9959310353bd0fc5a5ff7498c6ea47a0..ca5e2ec53590b731aedf33dfd69e7289 Profiler.get().incrementCounter("getEntities"); if (entityTypeTest instanceof net.minecraft.world.entity.EntityType byType) { -@@ -1792,7 +1800,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1748,7 +1756,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl if (entityTypeTest == null) { if (maxCount != Integer.MAX_VALUE) { diff --git a/sakura-server/minecraft-patches/features/0014-Use-maxEntityCollision-limit-for-entity-retrieval.patch b/sakura-server/minecraft-patches/features/0014-Use-maxEntityCollision-limit-for-entity-retrieval.patch index f43f0b1..a991552 100644 --- a/sakura-server/minecraft-patches/features/0014-Use-maxEntityCollision-limit-for-entity-retrieval.patch +++ b/sakura-server/minecraft-patches/features/0014-Use-maxEntityCollision-limit-for-entity-retrieval.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Use maxEntityCollision limit for entity retrieval diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 6a28431c6a586adb6cd3e6d38e419fbaf8cafff7..5d4e0efabd61e848db8e0e309cdfd7adaa38b0ce 100644 +index 987e73ec724a435231bccc449ce77ad021aa0903..849b012b87d25bdc4bcbe7edf5a5a6be2de1d35d 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3752,7 +3752,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3784,7 +3784,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin return; } // Paper end - don't run getEntities if we're not going to use its result diff --git a/sakura-server/minecraft-patches/features/0015-Explosion-Durable-Blocks.patch b/sakura-server/minecraft-patches/features/0015-Explosion-Durable-Blocks.patch index ee4fcce..92bf17b 100644 --- a/sakura-server/minecraft-patches/features/0015-Explosion-Durable-Blocks.patch +++ b/sakura-server/minecraft-patches/features/0015-Explosion-Durable-Blocks.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Explosion Durable Blocks diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index 6db566adf2d0df1d26221eda04aa01738df6d3d2..23c135a6355e920535734e946e5bd4d06f7f33b7 100644 +index dceb2b683064bbf4286c3fe71e0fd0c5a644cb07..40b76310d311a8d4cbe028d575f9220f55e70da2 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -38,8 +38,30 @@ public class BlockItem extends Item { +@@ -37,8 +37,30 @@ public class BlockItem extends Item { this.block = block; } @@ -40,10 +40,10 @@ index 6db566adf2d0df1d26221eda04aa01738df6d3d2..23c135a6355e920535734e946e5bd4d0 return !interactionResult.consumesAction() && context.getItemInHand().has(DataComponents.CONSUMABLE) ? super.use(context.getLevel(), context.getPlayer(), context.getHand()) diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index a99273ac64a223cc0a728137abca9331e79a546b..f41caed876beff43778e6138ac444f6e2608883d 100644 +index af39222e08bc7957ac40ea9fd6aae517e7cee45a..1da42c11174bb7eae9a827a17a57d5e7f1d80f09 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -830,6 +830,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -835,6 +835,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // Sakura end - track block changes and tick scheduler 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 @@ -52,10 +52,10 @@ index a99273ac64a223cc0a728137abca9331e79a546b..f41caed876beff43778e6138ac444f6e protected Level( WritableLevelData levelData, diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index 88192b561c2a071f583d16d1de926917108a8f45..d12473581f5285aff5867e8bebfe34ccbdb1285f 100644 +index 0f95ffa2551289cb74d0210673b942ca90be74d3..976ebf4c62d1cc96f2e147c2240a5886d6b022ed 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -131,7 +131,7 @@ public class ServerExplosion implements Explosion { +@@ -133,7 +133,7 @@ public class ServerExplosion implements Explosion { BlockState blockState = ((ca.spottedleaf.moonrise.patches.getblock.GetBlockChunk)chunk).moonrise$getBlock(x, y, z); FluidState fluidState = blockState.getFluidState(); @@ -64,8 +64,8 @@ index 88192b561c2a071f583d16d1de926917108a8f45..d12473581f5285aff5867e8bebfe34cc ret = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache( key, pos, blockState, fluidState, -@@ -357,6 +357,20 @@ public class ServerExplosion implements Explosion { - // Paper end - collision optimisations +@@ -359,6 +359,20 @@ public class ServerExplosion implements Explosion { + } } // Sakura end - specialised explosions + // Sakura start - explosion durable blocks @@ -85,7 +85,7 @@ index 88192b561c2a071f583d16d1de926917108a8f45..d12473581f5285aff5867e8bebfe34cc public ServerExplosion( ServerLevel level, -@@ -744,6 +758,14 @@ public class ServerExplosion implements Explosion { +@@ -697,6 +711,14 @@ public class ServerExplosion implements Explosion { } } // CraftBukkit end diff --git a/sakura-server/minecraft-patches/features/0016-Destroy-Waterlogged-Blocks.patch b/sakura-server/minecraft-patches/features/0016-Destroy-Waterlogged-Blocks.patch index 7a05a5f..d59f133 100644 --- a/sakura-server/minecraft-patches/features/0016-Destroy-Waterlogged-Blocks.patch +++ b/sakura-server/minecraft-patches/features/0016-Destroy-Waterlogged-Blocks.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Destroy Waterlogged Blocks diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index f8933e198a250f2184fb64bb987575b441ae8a32..f79e8f48a1f9a6964e1449c099df39076615dd88 100644 +index 976ebf4c62d1cc96f2e147c2240a5886d6b022ed..16575c1222b28f7809db39d320848153e3b97044 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -366,6 +366,11 @@ public class ServerExplosion implements Explosion { +@@ -368,6 +368,11 @@ public class ServerExplosion implements Explosion { if (material != null && material.replaceBlastResistance() && pos.getY() > this.level.getMinY()) { return Optional.of(material.resistance()); } diff --git a/sakura-server/minecraft-patches/features/0017-Configure-cannon-physics.patch b/sakura-server/minecraft-patches/features/0017-Configure-cannon-physics.patch index fb57b87..9145c58 100644 --- a/sakura-server/minecraft-patches/features/0017-Configure-cannon-physics.patch +++ b/sakura-server/minecraft-patches/features/0017-Configure-cannon-physics.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configure cannon physics diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java -index 5cc6fe6984d59a94c037b2c327a5d72b5a2a740d..82689f3a737a80c1c3fd5c46aa271e70fc7b8866 100644 +index 82dac4fbaf3572391dad61356ba5351b725194ff..0f0f1cb55bc167071e84ec998469001374995e8f 100644 --- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java @@ -1774,6 +1774,13 @@ public final class CollisionUtil { @@ -64,10 +64,10 @@ index 5cc6fe6984d59a94c037b2c327a5d72b5a2a740d..82689f3a737a80c1c3fd5c46aa271e70 if (xSmaller && z != 0.0) { z = performAABBCollisionsZ(axisalignedbb, z, aabbs); diff --git a/net/minecraft/core/dispenser/DispenseItemBehavior.java b/net/minecraft/core/dispenser/DispenseItemBehavior.java -index ca02c4c71a0a5a1a0ae8bbb40f0b1b7eac64e6fd..476b1330455cb30a582147bcf95d4f199ade3c6f 100644 +index 703a75c7c6cd05a95afb630973250898dbc7223d..1531f0c275814e1346fef34dc06ea97643de382c 100644 --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -462,6 +462,14 @@ public interface DispenseItemBehavior { +@@ -471,6 +471,14 @@ public interface DispenseItemBehavior { } } @@ -83,18 +83,10 @@ index ca02c4c71a0a5a1a0ae8bbb40f0b1b7eac64e6fd..476b1330455cb30a582147bcf95d4f19 // CraftBukkit end serverLevel.addFreshEntity(primedTnt); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb913990a820838 100644 +index 0c20de0f6af0385a7849cb9b0be86049784d59ae..87948a1f3ff9b9e5ac2de8e4eb033e31a6818a2e 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -2,7 +2,6 @@ package net.minecraft.world.entity; - - import com.google.common.collect.ImmutableList; - import com.google.common.collect.Lists; --import com.google.common.collect.Sets; - import com.google.common.collect.ImmutableList.Builder; - import com.mojang.logging.LogUtils; - import com.mojang.serialization.Codec; -@@ -586,6 +585,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -588,6 +588,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } } // Sakura end - merge cannon entities @@ -108,7 +100,7 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399 public Entity(EntityType entityType, Level level) { this.type = entityType; -@@ -1110,7 +1116,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1116,7 +1123,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } protected void checkSupportingBlock(boolean onGround, @Nullable Vec3 movement) { @@ -117,9 +109,9 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399 AABB boundingBox = this.getBoundingBox(); AABB aabb = new AABB(boundingBox.minX, boundingBox.minY - 1.0E-6, boundingBox.minZ, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ); Optional optional = this.level.findSupportingBlock(this, aabb); -@@ -1160,7 +1166,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - if (this.noPhysics) { - this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); +@@ -1170,7 +1177,10 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + this.verticalCollisionBelow = false; + this.minorHorizontalCollision = false; } else { - if (type == MoverType.PISTON) { + // Sakura start - configure server mechanics @@ -127,41 +119,50 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399 + if (type == MoverType.PISTON && mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_11)) { + // Sakura end - configure server mechanics // Paper start - EAR 2 - this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); - this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); -@@ -1189,8 +1198,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + this.activatedTick = Math.max(this.activatedTick, net.minecraft.server.MinecraftServer.currentTick + 20); + this.activatedImmunityTick = Math.max(this.activatedImmunityTick, net.minecraft.server.MinecraftServer.currentTick + 20); +@@ -1199,10 +1209,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name movement = this.maybeBackOffFromEdge(movement, type); Vec3 vec3 = this.collide(movement); double d = vec3.lengthSqr(); - if (d > 1.0E-7 || movement.lengthSqr() - d < 1.0E-7) { - if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock) { // Sakura - optimise cannon entity movement +- double min = Math.min(vec3.length(), 8.0); +- Vec3 vec31 = this.position().add(vec3.normalize().scale(min)); + // Sakura start - configure server mechanics + if (me.samsuik.sakura.mechanics.EntityBehaviour.canMoveEntity(d, movement, mechanicsTarget)) { + if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock && mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_18_2)) { // Sakura - optimise cannon entity movement ++ final Vec3 vec31; ++ if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9)) { ++ double min = Math.min(Math.sqrt(d), 8.0); ++ vec31 = this.position().add(vec3.normalize().scale(min)); ++ } else { ++ vec31 = this.position().add(vec3); ++ } + // Sakura end - configure server mechanics BlockHitResult blockHitResult = this.level() - .clip( - new ClipContext(this.position(), this.position().add(vec3), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this) -@@ -1201,9 +1212,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + .clip(new ClipContext(this.position(), vec31, ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this)); + if (blockHitResult.getType() != HitResult.Type.MISS) { +@@ -1211,9 +1228,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } - Vec3 vec31 = this.position(); -- Vec3 vec32 = vec31.add(vec3); -- this.addMovementThisTick(new Entity.Movement(vec31, vec32, true)); -- this.setPos(vec32); + Vec3 vec32 = this.position(); +- Vec3 vec33 = vec32.add(vec3); +- this.addMovementThisTick(new Entity.Movement(vec32, vec33, movement)); +- this.setPos(vec33); + // Sakura start - configure server mechanics + if (mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_6)) { -+ me.samsuik.sakura.mechanics.EntityBehaviour.changeEntityPosition(this, vec31, vec3, mechanicsTarget); ++ me.samsuik.sakura.mechanics.EntityBehaviour.changeEntityPosition(this, vec32, vec3, mechanicsTarget); + } else { -+ Vec3 vec32 = vec31.add(vec3); -+ this.addMovementThisTick(new Entity.Movement(vec31, vec32, true)); -+ this.setPos(vec32); ++ Vec3 vec33 = vec32.add(vec3); ++ this.addMovementThisTick(new Entity.Movement(vec32, vec33, movement)); ++ this.setPos(vec33); + } + // Sakura end - configure server mechanics } profilerFiller.pop(); -@@ -1234,6 +1251,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1244,6 +1267,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } else { if (this.horizontalCollision) { Vec3 deltaMovement = this.getDeltaMovement(); @@ -173,7 +174,7 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399 this.setDeltaMovement(flag ? 0.0 : deltaMovement.x, deltaMovement.y, flag1 ? 0.0 : deltaMovement.z); } -@@ -1568,7 +1590,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1585,7 +1613,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } this.collectCollisions(bb, voxelList, bbList, ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER); @@ -182,7 +183,7 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399 } private Vec3 collideAxisScan(final Vec3 movement, AABB currBoundingBox, final List voxelList, final List bbList) { -@@ -1576,7 +1598,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1593,7 +1621,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name double y = movement.y; double z = movement.z; @@ -191,7 +192,7 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399 if (y != 0.0) { y = this.scanY(currBoundingBox, y, voxelList, bbList); -@@ -1698,7 +1720,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1715,7 +1743,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), null // Sakura - load chunks on movement ); potentialCollisionsBB.addAll(entityAABBs); @@ -200,11 +201,54 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399 final boolean collidedX = collided.x != movement.x; final boolean collidedY = collided.y != movement.y; -@@ -1843,11 +1865,22 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1838,25 +1866,37 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + private void checkInsideBlocks(List movements, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector) { + if (this.isAffectedByBlocks()) { + LongSet set = this.visitedBlocks; ++ final me.samsuik.sakura.mechanics.MinecraftMechanicsTarget mechanicsTarget = this.mechanicsTarget; // Sakura - configure server mechanics + + for (Entity.Movement movement : movements) { + Vec3 vec3 = movement.from; + Vec3 vec31 = movement.to().subtract(movement.from()); + int i = 16; +- if (movement.axisDependentOriginalMovement().isPresent() && vec31.lengthSqr() > 0.0) { +- for (Direction.Axis axis : Direction.axisStepOrder(movement.axisDependentOriginalMovement().get())) { ++ // Sakura start - configure server mechanics ++ final Optional axisDependentMovement = movement.axisDependentOriginalMovement(); ++ if (axisDependentMovement.isPresent() && vec31.lengthSqr() > 0.0 && mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_5)) { ++ final Vec3 stepOrderVec = mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9) ++ ? axisDependentMovement.get() ++ : vec31; ++ ++ // The axis order here may differ from the order during movement in versions below 1.21.9 ++ for (Direction.Axis axis : Direction.axisStepOrder(stepOrderVec)) { + double d = vec31.get(axis); + if (d != 0.0) { + Vec3 vec32 = vec3.relative(axis.getPositive(), d); +- i -= this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, i); ++ final int stepsTaken = this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, i); ++ if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9)) { ++ i -= stepsTaken; ++ } + vec3 = vec32; + } + } +- } else { ++ } else if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { + i -= this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set, 16); + } + +- if (i <= 0) { ++ if (i <= 0 || mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { ++ // Sakura end - configure server mechanics + this.checkInsideBlocks(movement.to(), movement.to(), stepBasedCollector, set, 1); + } + } +@@ -1866,7 +1906,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } - private void checkInsideBlocks(Vec3 vec3, Vec3 vec31, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet set) { -- AABB aabb = this.makeBoundingBox(vec31).deflate(1.0E-5F); + private int checkInsideBlocks(Vec3 from, Vec3 to, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet visited, int maxSteps) { +- AABB aabb = this.makeBoundingBox(to).deflate(1.0E-5F); + // Sakura start - configure server mechanics + final double margin; + if (this.mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { @@ -214,22 +258,25 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399 + } else { + margin = 0.001; + } -+ AABB aabb = this.makeBoundingBox(vec31).deflate(margin); ++ AABB aabb = this.makeBoundingBox(to).deflate(margin); + // Sakura end - configure server mechanics - BlockGetter.forEachBlockIntersectedBetween( - vec3, - vec31, + boolean flag = this.level instanceof ServerLevel serverLevel + && serverLevel.getServer().debugSubscribers().hasAnySubscriberFor(DebugSubscriptions.ENTITY_BLOCK_INTERSECTIONS); + AtomicInteger atomicInteger = new AtomicInteger(); +@@ -1874,6 +1924,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + from, + to, aabb, + this.mechanicsTarget, // Sakura - configure server mechanics (pos, index) -> { if (!this.isAlive()) { return false; diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index f7807b56bf935e1686ac893c0752e92e1115ffbe..297310605e3ed4dbd3db40ff3cddb8eee6f3f508 100644 +index 0344ba2a6d063a4ee5d6f9a8985ae8ca8c5816ce..02dc6c5965354047fc05ad3d3293c7f6277f50cd 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -130,6 +130,25 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti - return this.sakura_collide(movement); + return this.sakura$collide(movement); } // Sakura end - optimise cannon entity movement + // Sakura start - configure server mechanics @@ -333,7 +380,7 @@ index f7807b56bf935e1686ac893c0752e92e1115ffbe..297310605e3ed4dbd3db40ff3cddb8ee if (!this.cancelDrop) { boolean canBeReplaced = blockState.canBeReplaced( new DirectionalPlaceContext(this.level(), blockPos, Direction.DOWN, ItemStack.EMPTY, Direction.UP) -@@ -350,7 +395,14 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti +@@ -349,7 +394,14 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti } } @@ -350,11 +397,11 @@ index f7807b56bf935e1686ac893c0752e92e1115ffbe..297310605e3ed4dbd3db40ff3cddb8ee } diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java -index e476d500df5e197f87863d9fdb61065af68778dd..135e1174115a7ed90245be47bd998833ddbe7d68 100644 +index 05003798585d98406cd1affb89403b9f955bacdc..cb2241e99f4b3bee099ff1eea566beb9bd80c57d 100644 --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java @@ -88,6 +88,23 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak - return this.sakura_collide(movement); + return this.sakura$collide(movement); } // Sakura end - optimise cannon entity movement + // Sakura start - configure server mechanics @@ -458,10 +505,19 @@ index e476d500df5e197f87863d9fdb61065af68778dd..135e1174115a7ed90245be47bd998833 // Paper end - Option to prevent TNT from moving in water } diff --git a/net/minecraft/world/level/BlockGetter.java b/net/minecraft/world/level/BlockGetter.java -index 2146efa860d8323a88f3ad365c0cdb66de42154a..b6ddb1ad889a115daeba64321d38b236033f62ff 100644 +index 41c036324499d4e408030d1e19f78468b6b3d8a6..ba2e7efe147b26bea5d73eac1f4b2fe6ee4bd5c2 100644 --- a/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java -@@ -213,8 +213,20 @@ public interface BlockGetter extends LevelHeightAccessor { +@@ -8,6 +8,8 @@ import java.util.function.Function; + import java.util.function.Supplier; + import java.util.stream.Stream; + import javax.annotation.Nullable; ++ ++import me.samsuik.sakura.mechanics.MechanicVersion; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; + import net.minecraft.core.Vec3i; +@@ -212,8 +214,23 @@ public interface BlockGetter extends LevelHeightAccessor { } static boolean forEachBlockIntersectedBetween(Vec3 from, Vec3 to, AABB boundingBox, BlockGetter.BlockStepVisitor visitor) { @@ -477,17 +533,20 @@ index 2146efa860d8323a88f3ad365c0cdb66de42154a..b6ddb1ad889a115daeba64321d38b236 + final BlockGetter.BlockStepVisitor visitor + ) { Vec3 vec3 = to.subtract(from); -- if (vec3.lengthSqr() < Mth.square(0.99999F)) { -+ if (vec3.lengthSqr() < Mth.square(0.99999F) || mechanicsTarget != null && mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { +- if (vec3.lengthSqr() < Mth.square(1.0E-5F)) { ++ final double margin = mechanicsTarget != null && mechanicsTarget.atLeast(MechanicVersion.v1_21_9) ++ ? 1.0E-5F ++ : 0.99999F; ++ if (vec3.lengthSqr() < Mth.square(margin) || mechanicsTarget != null && mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { + // Sakura end - configure server mechanics for (BlockPos blockPos : BlockPos.betweenClosed(boundingBox)) { if (!visitor.visit(blockPos, 0)) { return false; diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index e6ca200bf17e097f65204d7cead78306573e4782..41a9da18ec229f9e489de2ac3af9d9e5f9b58963 100644 +index 16575c1222b28f7809db39d320848153e3b97044..a24e728476a64e49f2e5139fc103e19d5650d6e1 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -376,6 +376,17 @@ public class ServerExplosion implements Explosion { +@@ -378,6 +378,17 @@ public class ServerExplosion implements Explosion { return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState); } // Sakura end - explosion durable blocks @@ -505,7 +564,7 @@ index e6ca200bf17e097f65204d7cead78306573e4782..41a9da18ec229f9e489de2ac3af9d9e5 public ServerExplosion( ServerLevel level, -@@ -400,6 +411,7 @@ public class ServerExplosion implements Explosion { +@@ -402,6 +413,7 @@ public class ServerExplosion implements Explosion { this.yield = Double.isFinite(this.yield) ? this.yield : 0; // Paper - Don't allow infinite default yields // Paper end - add yield this.consistentExplosionRadius = level.localConfig().at(this.center).consistentExplosionRadius; // Sakura - consistent explosion radius @@ -513,7 +572,7 @@ index e6ca200bf17e097f65204d7cead78306573e4782..41a9da18ec229f9e489de2ac3af9d9e5 } private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { -@@ -429,8 +441,15 @@ public class ServerExplosion implements Explosion { +@@ -431,8 +443,15 @@ public class ServerExplosion implements Explosion { final float density = entity.level().densityCache.getKnownDensity(vec3); if (density != me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { hitResult = density != 0.0f ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK; @@ -530,7 +589,7 @@ index e6ca200bf17e097f65204d7cead78306573e4782..41a9da18ec229f9e489de2ac3af9d9e5 } if (hitResult == HitResult.Type.MISS) { // Sakura end - replace density cache -@@ -528,6 +547,15 @@ public class ServerExplosion implements Explosion { +@@ -530,6 +549,15 @@ public class ServerExplosion implements Explosion { } if (cachedBlock.outOfWorld) { @@ -546,20 +605,36 @@ index e6ca200bf17e097f65204d7cead78306573e4782..41a9da18ec229f9e489de2ac3af9d9e5 break; } final BlockState iblockdata = cachedBlock.blockState; -@@ -630,6 +658,12 @@ public class ServerExplosion implements Explosion { - double d2 = (entity instanceof PrimedTnt ? entity.getY() : entity.getEyeY()) - this.center.y; - double d3 = entity.getZ() - this.center.z; - double squareRoot = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3); +@@ -594,7 +622,27 @@ public class ServerExplosion implements Explosion { + double d = Math.sqrt(entity.distanceToSqr(this.center)) / f; + if (!(d > 1.0)) { + Vec3 vec3 = entity instanceof PrimedTnt ? entity.position() : entity.getEyePosition(); +- Vec3 vec31 = vec3.subtract(this.center).normalize(); + // Sakura start - configure server mechanics ++ final double dirX = vec3.x - this.center.x; ++ final double dirY = vec3.y - this.center.y; ++ final double dirZ = vec3.z - this.center.z; ++ double magnitude = Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ); ++ + if (this.mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_17)) { + d = (float) d; -+ squareRoot = (float) squareRoot; ++ magnitude = (float) magnitude; ++ } ++ ++ final Vec3 vec31; ++ if (magnitude < 1.0e-5f && this.mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9)) { ++ vec31 = Vec3.ZERO; ++ } else { ++ final double normalisedX = dirX / magnitude; ++ final double normalisedY = dirY / magnitude; ++ final double normalisedZ = dirZ / magnitude; ++ vec31 = new Vec3(normalisedX, normalisedY, normalisedZ); + } + // Sakura end - configure server mechanics - if (squareRoot != 0.0) { - d1 /= squareRoot; - d2 /= squareRoot; -@@ -913,7 +947,7 @@ public class ServerExplosion implements Explosion { + boolean shouldDamageEntity = this.damageCalculator.shouldDamageEntity(this, entity); + float knockbackMultiplier = this.damageCalculator.getKnockbackMultiplier(entity); + float f1 = !shouldDamageEntity && knockbackMultiplier == 0.0F ? 0.0F : this.getBlockDensity(this.center, entity); // Paper - Optimize explosions +@@ -868,7 +916,7 @@ public class ServerExplosion implements Explosion { // Sakura start - replace density cache float blockDensity = this.level.densityCache.getBlockDensity(vec3d, entity); if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { @@ -596,7 +671,7 @@ index 4fa238d1cd6b19f16c0d0a8a9a913e9e42debbed..96a02601636cdf7cf6e360fc933e5764 protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (isFree(level.getBlockState(pos.below())) && pos.getY() >= level.getMinY()) { diff --git a/net/minecraft/world/level/block/FenceGateBlock.java b/net/minecraft/world/level/block/FenceGateBlock.java -index a5e686b90e532e3b656fca411936499c2b2020c7..4e689171f7c3344442d7827e6d2aa1dea46a61a2 100644 +index 0c6ae65fc58d63a0b80f3bc1ffa0c9a1bb33de83..f291dc3b3f3e3b8da221f42580ed26c4b8f569a7 100644 --- a/net/minecraft/world/level/block/FenceGateBlock.java +++ b/net/minecraft/world/level/block/FenceGateBlock.java @@ -210,8 +210,15 @@ public class FenceGateBlock extends HorizontalDirectionalBlock { @@ -618,7 +693,7 @@ index a5e686b90e532e3b656fca411936499c2b2020c7..4e689171f7c3344442d7827e6d2aa1de level.playSound( null, diff --git a/net/minecraft/world/level/block/HoneyBlock.java b/net/minecraft/world/level/block/HoneyBlock.java -index a98c308c5febd458d6489174b94898cd4b9bae69..3b0afe1fdfa6f992903acf8fc56a4031d08083a1 100644 +index c15cd4d68e3168d63dba10122a74abe9a884f80d..6da4f87a7ce49f3ad86ca456a9aba66e2a5d1439 100644 --- a/net/minecraft/world/level/block/HoneyBlock.java +++ b/net/minecraft/world/level/block/HoneyBlock.java @@ -71,11 +71,19 @@ public class HoneyBlock extends HalfTransparentBlock { @@ -703,10 +778,10 @@ index f9c305de60a323b450a26c9d7de50a824492cf5a..c4987294763a82f5f065f726d48fa61d } diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java -index 4dbbfa34c085fd9777de5b4a6bf48dedfe8603b8..1bf1f20235ee2d1395c94648c3d5deedf3b31bab 100644 +index 0b1ec05fcd799536c8d7393bb42dc4b2f46ca48b..5968a30d21367b882501bbb70029b9e0069cca9f 100644 --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java -@@ -195,7 +195,14 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -199,7 +199,14 @@ public class LiquidBlock extends Block implements BucketPickup { } // Sakura end - configure fluid ticking outside the world border if (level.getFluidState(blockPos).is(FluidTags.WATER)) { @@ -723,7 +798,7 @@ index 4dbbfa34c085fd9777de5b4a6bf48dedfe8603b8..1bf1f20235ee2d1395c94648c3d5deed if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, block.defaultBlockState(), 3)) { this.fizz(level, pos); diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index a9db955a90e0b44d3c85e39f2f7ae9ea4f68a316..9dbd97607866f8bd356044318ab670bcc794074f 100644 +index 7390a21f7c6991d3fb62fda9e88bc9212159177b..497cc0156cbd87e591f1f50090fc5fe055b71916 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java @@ -542,7 +542,7 @@ public class RedStoneWireBlock extends Block { @@ -768,7 +843,7 @@ index 3b3047aa1198754e64913634f76fdc015c1fe07d..4e88020dc0036145281f86b7f5eaf462 } diff --git a/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/net/minecraft/world/level/block/piston/MovingPistonBlock.java -index 05bbc2e59384702439548a988e128a85f1adbe82..2f7d86b4d50ce4a3da6c1c4d2006c173bde66d86 100644 +index 16f14dffcbca21e0c6d369d557ab6c036523b8bd..f459cee5a4d0eafccc525c246964acc9272429f5 100644 --- a/net/minecraft/world/level/block/piston/MovingPistonBlock.java +++ b/net/minecraft/world/level/block/piston/MovingPistonBlock.java @@ -100,6 +100,16 @@ public class MovingPistonBlock extends BaseEntityBlock { @@ -789,7 +864,7 @@ index 05bbc2e59384702439548a988e128a85f1adbe82..2f7d86b4d50ce4a3da6c1c4d2006c173 } diff --git a/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/net/minecraft/world/level/block/piston/PistonBaseBlock.java -index c372c9f828f52af0d31cc9d20c00359fdb2a610a..c890eb98a3f480e3f269ff56a81f280e7b7c100c 100644 +index 384eb75c644489fecd78fff904612ebe1e3e1706..87bc3222c33a00a46c5fdff792ca11f8248a61cd 100644 --- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java @@ -122,6 +122,11 @@ public class PistonBaseBlock extends DirectionalBlock { @@ -805,7 +880,7 @@ index c372c9f828f52af0d31cc9d20c00359fdb2a610a..c890eb98a3f480e3f269ff56a81f280e } } diff --git a/net/minecraft/world/level/block/piston/PistonHeadBlock.java b/net/minecraft/world/level/block/piston/PistonHeadBlock.java -index 6c789e56f21f01252c21786cfeb48d88485b5636..b325c24be64a3484d1084abc515599e77b535bed 100644 +index 72e39ceeca8d684569c4250263b41034362f8abd..0f723f8eb814931f949b1a467b79266e9a6e7f9e 100644 --- a/net/minecraft/world/level/block/piston/PistonHeadBlock.java +++ b/net/minecraft/world/level/block/piston/PistonHeadBlock.java @@ -3,6 +3,8 @@ package net.minecraft.world.level.block.piston; @@ -841,7 +916,7 @@ index 6c789e56f21f01252c21786cfeb48d88485b5636..b325c24be64a3484d1084abc515599e7 } diff --git a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index b5a17b441f046a8f2efd1b776a4620b55d99a854..dd20beab7f2ae2c804e00f822dfd6cc01aa635e1 100644 +index 4c4dbd7ade2b8836064242bb43eeb871cac023ce..c1afb74f19ad627b02bed2e3ffec67b877625c9f 100644 --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java @@ -64,6 +64,163 @@ public class PistonMovingBlockEntity extends BlockEntity { @@ -1041,7 +1116,7 @@ index b5a17b441f046a8f2efd1b776a4620b55d99a854..dd20beab7f2ae2c804e00f822dfd6cc0 blockEntity.lastTicked = level.getGameTime(); blockEntity.progressO = blockEntity.progress; if (blockEntity.progressO >= 1.0F) { - if (level.isClientSide && blockEntity.deathTicks < 5) { + if (level.isClientSide() && blockEntity.deathTicks < 5) { blockEntity.deathTicks++; } else { + // Sakura start - configure server mechanics @@ -1081,10 +1156,10 @@ index b5a17b441f046a8f2efd1b776a4620b55d99a854..dd20beab7f2ae2c804e00f822dfd6cc0 } diff --git a/net/minecraft/world/level/material/LavaFluid.java b/net/minecraft/world/level/material/LavaFluid.java -index 86401ba95530d10ee505d124dcbaaad6e0b800e9..1166ecc7e938341a65cbabb592fc998593afe835 100644 +index c8e427907c17ae6ac6c4dbe6abe74955c8030ead..f7209a487a48e434fde91daa39466de16ead03f2 100644 --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -184,6 +184,11 @@ public abstract class LavaFluid extends FlowingFluid { +@@ -185,6 +185,11 @@ public abstract class LavaFluid extends FlowingFluid { @Override public boolean canBeReplacedWith(FluidState fluidState, BlockGetter blockReader, BlockPos pos, Fluid fluid, Direction direction) { diff --git a/sakura-server/minecraft-patches/features/0018-Allow-explosions-to-destroy-lava.patch b/sakura-server/minecraft-patches/features/0018-Allow-explosions-to-destroy-lava.patch index a28be8f..6c4894b 100644 --- a/sakura-server/minecraft-patches/features/0018-Allow-explosions-to-destroy-lava.patch +++ b/sakura-server/minecraft-patches/features/0018-Allow-explosions-to-destroy-lava.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Allow explosions to destroy lava diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index e79de0fc3102c107d2c49e1b084b65d5c667e6e3..3e4e09b886dea6642dbe86c52c5a475baad11734 100644 +index a24e728476a64e49f2e5139fc103e19d5650d6e1..8317c1d8ede33a1de115c5597a439f30284c8b86 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -371,6 +371,11 @@ public class ServerExplosion implements Explosion { +@@ -373,6 +373,11 @@ public class ServerExplosion implements Explosion { return Optional.of(ZERO_RESISTANCE); } // Sakura end - destroy water logged blocks @@ -21,10 +21,10 @@ index e79de0fc3102c107d2c49e1b084b65d5c667e6e3..3e4e09b886dea6642dbe86c52c5a475b return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState); diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index 834e27ef2f7b342b074ff9e1e390e02f3ca1c399..fed11ed5ab97826915710b66395d1bdc926935b0 100644 +index dff1c4fa389d5168bd9ec1aff4c7e4bc63c4110e..7ee94845b69139f7c419b9d6ee24ba1db0e69975 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -201,7 +201,7 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -200,7 +200,7 @@ public abstract class BlockBehaviour implements FeatureElement { state.getDrops(builder).forEach(stack -> dropConsumer.accept(stack, pos)); } diff --git a/sakura-server/minecraft-patches/features/0019-Collide-with-non-solid-blocks.patch b/sakura-server/minecraft-patches/features/0019-Collide-with-non-solid-blocks.patch index dd97276..fa0712d 100644 --- a/sakura-server/minecraft-patches/features/0019-Collide-with-non-solid-blocks.patch +++ b/sakura-server/minecraft-patches/features/0019-Collide-with-non-solid-blocks.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Collide with non-solid blocks diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java -index 96009170f6ec0febc577867be3ee77433471c919..17940de16399033575c2c8031cdf1092f7b39ea2 100644 +index 0f0f1cb55bc167071e84ec998469001374995e8f..54d561e1b4069df7115457accb0763fa7586dddc 100644 --- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java @@ -1905,6 +1905,7 @@ public final class CollisionUtil { @@ -46,10 +46,10 @@ index 96009170f6ec0febc577867be3ee77433471c919..17940de16399033575c2c8031cdf1092 blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape); } diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 098b5a8cfe1ce37f5c1ed51c2bb913990a820838..2107fb073fc6bee12a80652c08cdc82e2fe495f8 100644 +index 87948a1f3ff9b9e5ac2de8e4eb033e31a6818a2e..6d1edbfd851737d19ce0a3ffa4914c6beecaa440 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -546,6 +546,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -549,6 +549,14 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name flags |= ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_ADD_TICKET; } diff --git a/sakura-server/minecraft-patches/features/0020-Reduce-entity-tracker-player-updates.patch b/sakura-server/minecraft-patches/features/0020-Reduce-entity-tracker-player-updates.patch index 3303e0e..7e1a3ab 100644 --- a/sakura-server/minecraft-patches/features/0020-Reduce-entity-tracker-player-updates.patch +++ b/sakura-server/minecraft-patches/features/0020-Reduce-entity-tracker-player-updates.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Reduce entity tracker player updates diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index e164d7fbda422dbcffd753c3373b1c08fa3b5d68..98512bdd9cae7f4070587386382c0615074b122d 100644 +index f9dfbf11a39573e839153fd5d72bcf9019540359..747885dd0e8aaefecf600ebef33bb2e136f65290 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -1015,7 +1015,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1023,7 +1023,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (tracker == null) { continue; } @@ -21,7 +21,7 @@ index e164d7fbda422dbcffd753c3373b1c08fa3b5d68..98512bdd9cae7f4070587386382c0615 if (((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity)tracker).moonrise$hasPlayers() || ((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)entity).moonrise$getChunkStatus().isOrAfter(FullChunkStatus.ENTITY_TICKING)) { tracker.serverEntity.sendChanges(); -@@ -1259,12 +1263,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1296,12 +1300,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return state != me.samsuik.sakura.player.visibility.VisibilityState.OFF; } // Sakura end - client visibility settings; entity visibility @@ -41,7 +41,7 @@ index e164d7fbda422dbcffd753c3373b1c08fa3b5d68..98512bdd9cae7f4070587386382c0615 + // Sakura start - reduce entity tracker player updates public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { - this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this::broadcastIgnorePlayers, this.seenBy); // Paper + this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this, this.seenBy); // Paper this.entity = entity; this.range = range; this.lastSectionPos = SectionPos.of(entity); diff --git a/sakura-server/minecraft-patches/features/0021-Legacy-lava-block-formation.patch b/sakura-server/minecraft-patches/features/0021-Legacy-lava-block-formation.patch index 49def34..ca2ac2a 100644 --- a/sakura-server/minecraft-patches/features/0021-Legacy-lava-block-formation.patch +++ b/sakura-server/minecraft-patches/features/0021-Legacy-lava-block-formation.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Legacy lava block formation diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java -index 1bf1f20235ee2d1395c94648c3d5deedf3b31bab..7346bde5612d2d521390102fe8d7c82904b8df06 100644 +index 5968a30d21367b882501bbb70029b9e0069cca9f..6fee4284d61afa39685bbcd2c6e72a41c5b1cc50 100644 --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java -@@ -198,7 +198,14 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -202,7 +202,14 @@ public class LiquidBlock extends Block implements BucketPickup { // Sakura start - configure server mechanics final FluidState fluidState = state.getFluidState(); final Block block = fluidState.isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; @@ -25,10 +25,10 @@ index 1bf1f20235ee2d1395c94648c3d5deedf3b31bab..7346bde5612d2d521390102fe8d7c829 return true; } diff --git a/net/minecraft/world/level/material/LavaFluid.java b/net/minecraft/world/level/material/LavaFluid.java -index 1166ecc7e938341a65cbabb592fc998593afe835..a0666fc38f4df2293b3888224c0b85652af803bf 100644 +index f7209a487a48e434fde91daa39466de16ead03f2..5edf09ff8aca309882b635706354be1dcec12764 100644 --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -184,9 +184,16 @@ public abstract class LavaFluid extends FlowingFluid { +@@ -185,9 +185,16 @@ public abstract class LavaFluid extends FlowingFluid { @Override public boolean canBeReplacedWith(FluidState fluidState, BlockGetter blockReader, BlockPos pos, Fluid fluid, Direction direction) { diff --git a/sakura-server/minecraft-patches/features/0022-Add-entity-travel-distance-limits.patch b/sakura-server/minecraft-patches/features/0022-Add-entity-travel-distance-limits.patch index 3c5aa85..43178ca 100644 --- a/sakura-server/minecraft-patches/features/0022-Add-entity-travel-distance-limits.patch +++ b/sakura-server/minecraft-patches/features/0022-Add-entity-travel-distance-limits.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add entity travel distance limits diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 573b1695abde0d89d5702a60a84919167ef4baab..29e1683741241f4f1e578041371a116170f2d1d2 100644 +index 733c5d7419cae21300d40fb13979dd40ecdd6810..aca28d1e2530d239b0e2b55f75c6d0e398841ea1 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -1304,6 +1304,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1336,6 +1336,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe final boolean isActive = io.papermc.paper.entity.activation.ActivationRange.checkIfActive(entity); // Paper - EAR 2 if (isActive) { // Paper - EAR 2 entity.tick(); @@ -21,10 +21,10 @@ index 573b1695abde0d89d5702a60a84919167ef4baab..29e1683741241f4f1e578041371a1161 } else {entity.inactiveTick();} // Paper - EAR 2 profilerFiller.pop(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 528d45eb5ff968ef14c3ff74a0c3bdb58ab21b86..b39b2cd2f4b85535bea19752ca1ecd334531b86c 100644 +index 6d1edbfd851737d19ce0a3ffa4914c6beecaa440..4ceffc9f043ef3c3063e8dc2b4cda753ad4d8059 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -600,6 +600,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -603,6 +603,18 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return this.mechanicsTarget; } // Sakura end - configure server mechanics @@ -43,7 +43,7 @@ index 528d45eb5ff968ef14c3ff74a0c3bdb58ab21b86..b39b2cd2f4b85535bea19752ca1ecd33 public Entity(EntityType entityType, Level level) { this.type = entityType; -@@ -629,6 +641,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -632,6 +644,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); this.despawnTime = level == null || type == EntityType.PLAYER ? -1 : level.paperConfig().entities.spawning.despawnTime.getOrDefault(type, io.papermc.paper.configuration.type.number.IntOr.Disabled.DISABLED).or(-1); // Paper - entity despawn time limit diff --git a/sakura-server/minecraft-patches/features/0023-Protect-scaffolding-from-creepers.patch b/sakura-server/minecraft-patches/features/0023-Protect-scaffolding-from-creepers.patch index 2bc6368..f0cbc19 100644 --- a/sakura-server/minecraft-patches/features/0023-Protect-scaffolding-from-creepers.patch +++ b/sakura-server/minecraft-patches/features/0023-Protect-scaffolding-from-creepers.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Protect scaffolding from creepers diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index 3e4e09b886dea6642dbe86c52c5a475baad11734..4b937ba2568a08d45541199964b3b46638f76785 100644 +index 8317c1d8ede33a1de115c5597a439f30284c8b86..a185d44ef797663d5007c9084117ca6933ba46be 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -376,6 +376,11 @@ public class ServerExplosion implements Explosion { +@@ -378,6 +378,11 @@ public class ServerExplosion implements Explosion { return Optional.of(ZERO_RESISTANCE); } // Sakura end - allow explosions to destroy lava diff --git a/sakura-server/minecraft-patches/features/0024-Configurable-left-shooting-and-adjusting-limits.patch b/sakura-server/minecraft-patches/features/0024-Configurable-left-shooting-and-adjusting-limits.patch index 4193464..cd58587 100644 --- a/sakura-server/minecraft-patches/features/0024-Configurable-left-shooting-and-adjusting-limits.patch +++ b/sakura-server/minecraft-patches/features/0024-Configurable-left-shooting-and-adjusting-limits.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Configurable left shooting and adjusting limits diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index b39b2cd2f4b85535bea19752ca1ecd334531b86c..0810ca0de7035bc913c63f8c26ccd247d27957be 100644 +index 4ceffc9f043ef3c3063e8dc2b4cda753ad4d8059..5a8fdf9af5b64d2e365151c178b2fbe4468f9a2a 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -612,6 +612,47 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -615,6 +615,47 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return Math.max(x, z) >= this.travelDistanceLimit; } // Sakura end - entity travel distance limits @@ -56,7 +56,7 @@ index b39b2cd2f4b85535bea19752ca1ecd334531b86c..0810ca0de7035bc913c63f8c26ccd247 public Entity(EntityType entityType, Level level) { this.type = entityType; -@@ -1629,6 +1670,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1652,6 +1693,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } if (xSmaller && z != 0.0) { @@ -64,7 +64,7 @@ index b39b2cd2f4b85535bea19752ca1ecd334531b86c..0810ca0de7035bc913c63f8c26ccd247 z = this.scanZ(currBoundingBox, z, voxelList, bbList); if (z != 0.0) { currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetZ(currBoundingBox, z); -@@ -1636,6 +1678,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1659,6 +1701,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } if (x != 0.0) { @@ -77,7 +77,7 @@ index b39b2cd2f4b85535bea19752ca1ecd334531b86c..0810ca0de7035bc913c63f8c26ccd247 if (x != 0.0) { currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetX(currBoundingBox, x); diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index 297310605e3ed4dbd3db40ff3cddb8eee6f3f508..f21b9e47fc35e00b9d4d8664e4bf1b9a188878a4 100644 +index 02dc6c5965354047fc05ad3d3293c7f6277f50cd..1dc2976daac6e0621a3cf573d7e1e673ba5934a3 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -269,6 +269,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti diff --git a/sakura-server/minecraft-patches/features/0025-Optimise-hopper-ticking.patch b/sakura-server/minecraft-patches/features/0025-Optimise-hopper-ticking.patch index 601f0cd..48ca14b 100644 --- a/sakura-server/minecraft-patches/features/0025-Optimise-hopper-ticking.patch +++ b/sakura-server/minecraft-patches/features/0025-Optimise-hopper-ticking.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Optimise hopper ticking diff --git a/net/minecraft/world/CompoundContainer.java b/net/minecraft/world/CompoundContainer.java -index 0e9beb7f74e527a95bff064631e6d591f5775ce5..2408e385989f19ae9591495bd9ee5af411a1e412 100644 +index 8eb989a811924fb6d2bc5150d7279d9d59bc3400..759ba8cc85101e8f22e8cb58cf74fe91d4226e54 100644 --- a/net/minecraft/world/CompoundContainer.java +++ b/net/minecraft/world/CompoundContainer.java -@@ -53,6 +53,15 @@ public class CompoundContainer implements Container { +@@ -54,6 +54,15 @@ public class CompoundContainer implements Container { return this.container1.getLocation(); // TODO: right? } // CraftBukkit end @@ -25,10 +25,10 @@ index 0e9beb7f74e527a95bff064631e6d591f5775ce5..2408e385989f19ae9591495bd9ee5af4 public CompoundContainer(Container container1, Container container2) { this.container1 = container1; diff --git a/net/minecraft/world/Container.java b/net/minecraft/world/Container.java -index b382665cc125b8b5c0938e5e55984e4bf91d37ff..7a62a5c61474b5b0ffc581c55d35d3327c7831b6 100644 +index 8e6f097b4d17aaaf8eccc16e11ce2bd01ad63322..4baa578a2d277676647ca60487a104f8a09ad5c9 100644 --- a/net/minecraft/world/Container.java +++ b/net/minecraft/world/Container.java -@@ -14,6 +14,12 @@ import net.minecraft.world.level.block.entity.BlockEntity; +@@ -16,6 +16,12 @@ import net.minecraft.world.level.block.entity.BlockEntity; public interface Container extends Clearable, Iterable { float DEFAULT_DISTANCE_BUFFER = 4.0F; @@ -42,10 +42,10 @@ index b382665cc125b8b5c0938e5e55984e4bf91d37ff..7a62a5c61474b5b0ffc581c55d35d332 boolean isEmpty(); diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index d4b2f81aebc888e6fe041537b71ac52d8dc8b4e7..92b3a69b2f87f44cb0c797d5986d501a649f4fe4 100644 +index 1da42c11174bb7eae9a827a17a57d5e7f1d80f09..7aa5ffc32835fab4a91db464d9112785475a67e9 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1483,7 +1483,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -1434,7 +1434,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // Spigot end if (tickingBlockEntity.isRemoved()) { toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll @@ -55,7 +55,7 @@ index d4b2f81aebc888e6fe041537b71ac52d8dc8b4e7..92b3a69b2f87f44cb0c797d5986d501a // Paper start - rewrite chunk system if ((++tickedEntities & 7) == 0) { diff --git a/net/minecraft/world/level/block/HopperBlock.java b/net/minecraft/world/level/block/HopperBlock.java -index 46a27f60ba407dacdac190b5e292ab3f1db5a078..ec05bb86803d878867b46e437cc73a39f155b9fc 100644 +index c6bec5967f7792ad3b65c0c69fdafd36194d8823..ad097818384adab7fe4d9e83e2295d20f531a5e3 100644 --- a/net/minecraft/world/level/block/HopperBlock.java +++ b/net/minecraft/world/level/block/HopperBlock.java @@ -121,6 +121,12 @@ public class HopperBlock extends BaseEntityBlock { @@ -72,10 +72,10 @@ index 46a27f60ba407dacdac190b5e292ab3f1db5a078..ec05bb86803d878867b46e437cc73a39 } } diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java -index 5986825d6a381eeb445dd424dd127864aa703163..72ed4c5b9f07be9d7149cd7f99622ec4be6d5902 100644 +index 39691f6ff8dc08c7d4ebff0612cb9777d809c6ed..037534185be3afd434f0a19f4a4e6de43e947ca0 100644 --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -50,6 +50,60 @@ public abstract class BlockEntity { +@@ -52,6 +52,60 @@ public abstract class BlockEntity implements DebugValueSource { private BlockState blockState; private DataComponentMap components = DataComponentMap.EMPTY; @@ -136,7 +136,7 @@ index 5986825d6a381eeb445dd424dd127864aa703163..72ed4c5b9f07be9d7149cd7f99622ec4 public BlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { this.type = type; this.worldPosition = pos.immutable(); -@@ -229,11 +283,22 @@ public abstract class BlockEntity { +@@ -231,11 +285,22 @@ public abstract class BlockEntity implements DebugValueSource { public void setChanged() { if (this.level != null) { if (ignoreBlockEntityUpdates) return; // Paper - Perf: Optimize Hoppers @@ -160,7 +160,7 @@ index 5986825d6a381eeb445dd424dd127864aa703163..72ed4c5b9f07be9d7149cd7f99622ec4 level.blockEntityChanged(pos); if (!state.isAir()) { level.updateNeighbourForOutputSignal(pos, state.getBlock()); -@@ -263,6 +328,7 @@ public abstract class BlockEntity { +@@ -265,6 +330,7 @@ public abstract class BlockEntity implements DebugValueSource { public void setRemoved() { this.remove = true; @@ -169,7 +169,7 @@ index 5986825d6a381eeb445dd424dd127864aa703163..72ed4c5b9f07be9d7149cd7f99622ec4 public void clearRemoved() { diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 01ed25d1f895d94485b5fecd98476534cbb26930..6ccd350a5cbe87e5cf9e66c230aced17e7ccd163 100644 +index 28348e3881c3c8591053a01b193fb2a956f79726..c12dd06bf9e4cd2f9dc3ace5e1089283fce385fe 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -28,7 +28,7 @@ import net.minecraft.world.level.storage.ValueInput; @@ -181,7 +181,7 @@ index 01ed25d1f895d94485b5fecd98476534cbb26930..6ccd350a5cbe87e5cf9e66c230aced17 public static final int MOVE_ITEM_SPEED = 8; public static final int HOPPER_CONTAINER_SIZE = 5; private static final int[][] CACHED_SLOTS = new int[54][]; -@@ -71,6 +71,58 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -72,6 +72,58 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen this.maxStack = size; } // CraftBukkit end @@ -240,7 +240,7 @@ index 01ed25d1f895d94485b5fecd98476534cbb26930..6ccd350a5cbe87e5cf9e66c230aced17 public HopperBlockEntity(BlockPos pos, BlockState blockState) { super(BlockEntityType.HOPPER, pos, blockState); -@@ -200,6 +252,12 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -201,6 +253,12 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen setChanged(level, pos, state); return true; } @@ -253,7 +253,7 @@ index 01ed25d1f895d94485b5fecd98476534cbb26930..6ccd350a5cbe87e5cf9e66c230aced17 } return false; -@@ -417,7 +475,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -418,7 +476,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen // Paper end - Perf: Optimize Hoppers private static boolean ejectItems(Level level, BlockPos pos, HopperBlockEntity blockEntity) { @@ -262,7 +262,7 @@ index 01ed25d1f895d94485b5fecd98476534cbb26930..6ccd350a5cbe87e5cf9e66c230aced17 if (attachedContainer == null) { return false; } else { -@@ -530,7 +588,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -531,7 +589,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen public static boolean suckInItems(Level level, Hopper hopper) { BlockPos blockPos = BlockPos.containing(hopper.getLevelX(), hopper.getLevelY() + 1.0, hopper.getLevelZ()); BlockState blockState = level.getBlockState(blockPos); @@ -287,10 +287,10 @@ index 28e3b73507b988f7234cbf29c4024c88180d0aef..a0d247aa883553708c4b921582324255 + // Sakura end - optimise hopper ticking } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index a39077ba4e1e40462ee9a96ce6f3871a5ecb85c7..6edccc2452c30a56ad393ba72ba2de487078f316 100644 +index 4a274798077c4ee0a504a784449a1aef1d89d325..4e84ead78c91b3453f2549b010de4aa8691967ba 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -987,6 +987,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -1022,6 +1022,13 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot return BlockEntityType.getKey(this.blockEntity.getType()).toString(); } @@ -304,7 +304,7 @@ index a39077ba4e1e40462ee9a96ce6f3871a5ecb85c7..6edccc2452c30a56ad393ba72ba2de48 @Override public String toString() { return "Level ticker for " + this.getType() + "@" + this.getPos(); -@@ -1035,6 +1042,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -1070,6 +1077,13 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot return this.ticker.getType(); } diff --git a/sakura-server/minecraft-patches/features/0026-Optimise-check-inside-blocks-and-traverse-blocks.patch b/sakura-server/minecraft-patches/features/0026-Optimise-check-inside-blocks-and-traverse-blocks.patch index 8144a6f..6cdef2a 100644 --- a/sakura-server/minecraft-patches/features/0026-Optimise-check-inside-blocks-and-traverse-blocks.patch +++ b/sakura-server/minecraft-patches/features/0026-Optimise-check-inside-blocks-and-traverse-blocks.patch @@ -5,55 +5,63 @@ Subject: [PATCH] Optimise check inside blocks and traverse blocks diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 0810ca0de7035bc913c63f8c26ccd247d27957be..5c772c05908f59b0f3d8636492685c3b853bcb47 100644 +index 5a8fdf9af5b64d2e365151c178b2fbe4468f9a2a..bc6e2cd985f28a79c843efe93e8b847a3adb7756 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -1910,6 +1910,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - private void checkInsideBlocks(List movements, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector) { +@@ -1935,6 +1935,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name if (this.isAffectedByBlocks()) { LongSet set = this.visitedBlocks; + final me.samsuik.sakura.mechanics.MinecraftMechanicsTarget mechanicsTarget = this.mechanicsTarget; // Sakura - configure server mechanics + final net.minecraft.world.level.chunk.ChunkAccess[] chunkCache = new net.minecraft.world.level.chunk.ChunkAccess[4]; // Sakura - optimise check inside blocks for (Entity.Movement movement : movements) { Vec3 vec3 = movement.from; -@@ -1919,12 +1920,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1952,7 +1953,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name double d = vec31.get(axis); if (d != 0.0) { Vec3 vec32 = vec3.relative(axis.getPositive(), d); -- this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set); -+ this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, chunkCache); // Sakura - optimise check inside blocks - vec3 = vec32; +- final int stepsTaken = this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, i); ++ final int stepsTaken = this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, i, chunkCache); // Sakura - optimise check inside blocks + if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9)) { + i -= stepsTaken; + } +@@ -1960,12 +1961,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } } - } else { -- this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set); -+ this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set, chunkCache); // Sakura - optimise check inside blocks + } else if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { +- i -= this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set, 16); ++ i -= this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set, 16, chunkCache); // Sakura - optimise check inside blocks + } + + if (i <= 0 || mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { + // Sakura end - configure server mechanics +- this.checkInsideBlocks(movement.to(), movement.to(), stepBasedCollector, set, 1); ++ this.checkInsideBlocks(movement.to(), movement.to(), stepBasedCollector, set, 1, chunkCache); // Sakura - optimise check inside blocks } } -@@ -1932,8 +1933,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1973,7 +1974,16 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } } -- private void checkInsideBlocks(Vec3 vec3, Vec3 vec31, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet set) { -- // Sakura start - configure server mechanics +- private int checkInsideBlocks(Vec3 from, Vec3 to, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet visited, int maxSteps) { + // Sakura start - optimise check inside blocks -+ private void checkInsideBlocks( -+ final Vec3 vec3, -+ final Vec3 vec31, ++ private int checkInsideBlocks( ++ final Vec3 from, ++ final Vec3 to, + final InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, -+ final LongSet set, ++ final LongSet visited, ++ final int maxSteps, + final net.minecraft.world.level.chunk.ChunkAccess[] chunkCache + ) { + // Sakura end - optimise check inside blocks -+ // Sakura start - configure cannon physics + // Sakura start - configure server mechanics final double margin; if (this.mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { - margin = 1.0e-5f; -@@ -1953,7 +1962,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - if (!this.isAlive()) { +@@ -2000,7 +2010,20 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return false; } else { + atomicInteger.set(index); - BlockState blockState = this.level().getBlockState(pos); + // Sakura start - optimise check inside blocks + final int chunkX = pos.getX() >> 4; @@ -70,22 +78,22 @@ index 0810ca0de7035bc913c63f8c26ccd247d27957be..5c772c05908f59b0f3d8636492685c3b + final BlockState blockState = chunk.getBlockState(pos); + // Sakura end - optimise check inside blocks if (blockState.isAir()) { - this.debugBlockIntersection(pos, false, false); - return true; + if (flag) { + this.debugBlockIntersection((ServerLevel)this.level(), pos.immutable(), false, false); diff --git a/net/minecraft/world/level/BlockGetter.java b/net/minecraft/world/level/BlockGetter.java -index b6ddb1ad889a115daeba64321d38b236033f62ff..0d8dda4e914e7570d08f595fd20e5f45e366cd0d 100644 +index ba2e7efe147b26bea5d73eac1f4b2fe6ee4bd5c2..b9ed6671edc98fe7a4bb30fdd25a6629e852da4f 100644 --- a/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java -@@ -227,7 +227,7 @@ public interface BlockGetter extends LevelHeightAccessor { - Vec3 vec3 = to.subtract(from); - if (vec3.lengthSqr() < Mth.square(0.99999F) || mechanicsTarget != null && mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { +@@ -231,7 +231,7 @@ public interface BlockGetter extends LevelHeightAccessor { + : 0.99999F; + if (vec3.lengthSqr() < Mth.square(margin) || mechanicsTarget != null && mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { // Sakura end - configure server mechanics - for (BlockPos blockPos : BlockPos.betweenClosed(boundingBox)) { + for (final BlockPos blockPos : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks if (!visitor.visit(blockPos, 0)) { return false; } -@@ -235,6 +235,20 @@ public interface BlockGetter extends LevelHeightAccessor { +@@ -239,9 +239,22 @@ public interface BlockGetter extends LevelHeightAccessor { return true; } else { @@ -94,9 +102,8 @@ index b6ddb1ad889a115daeba64321d38b236033f62ff..0d8dda4e914e7570d08f595fd20e5f45 + final boolean yZero = vec3.y() == 0.0; + final boolean zZero = vec3.z() == 0.0; + if (xZero && yZero || yZero && zZero || xZero && zZero) { -+ int blockIndex = 0; + for (final BlockPos blockPos : me.samsuik.sakura.utils.BlockPosIterator.traverseArea(vec3, boundingBox)) { -+ if (!visitor.visit(blockPos, blockIndex++)) { ++ if (!visitor.visit(blockPos, 0)) { + return false; + } + } @@ -104,14 +111,18 @@ index b6ddb1ad889a115daeba64321d38b236033f62ff..0d8dda4e914e7570d08f595fd20e5f45 + } + // Sakura end - optimise check inside blocks LongSet set = new LongOpenHashSet(); - Vec3 minPosition = boundingBox.getMinPosition(); - Vec3 vec31 = minPosition.subtract(vec3); -@@ -242,7 +256,7 @@ public interface BlockGetter extends LevelHeightAccessor { + +- for (BlockPos blockPos1 : BlockPos.betweenCornersInDirection(boundingBox.move(vec3.scale(-1.0)), vec3)) { ++ for (final BlockPos blockPos1 : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox.move(vec3.scale(-1.0)))) { // Sakura - optimise check inside blocks + if (!visitor.visit(blockPos1, 0)) { + return false; + } +@@ -253,7 +266,7 @@ public interface BlockGetter extends LevelHeightAccessor { if (i < 0) { return false; } else { -- for (BlockPos blockPos1 : BlockPos.betweenClosed(boundingBox)) { -+ for (final BlockPos blockPos1 : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks - if (!set.contains(blockPos1.asLong()) && !visitor.visit(blockPos1, i + 1)) { +- for (BlockPos blockPos2 : BlockPos.betweenCornersInDirection(boundingBox, vec3)) { ++ for (final BlockPos blockPos2 : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks + if (set.add(blockPos2.asLong()) && !visitor.visit(blockPos2, i + 1)) { return false; } diff --git a/sakura-server/minecraft-patches/features/0028-Cache-vanilla-and-eigencraft-redstone-wires.patch b/sakura-server/minecraft-patches/features/0028-Cache-vanilla-and-eigencraft-redstone-wires.patch index 486360a..155f941 100644 --- a/sakura-server/minecraft-patches/features/0028-Cache-vanilla-and-eigencraft-redstone-wires.patch +++ b/sakura-server/minecraft-patches/features/0028-Cache-vanilla-and-eigencraft-redstone-wires.patch @@ -33,10 +33,10 @@ index ff747a1ecdf3c888bca0d69de4f85dcd810b6139..d90f6aa4557b5863eba6a206226f763c } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 8a046ad7590bd358d416f4aa21a3c173d0931d2a..cdcc64da3481ea8ab4bc680fef775bc193e65c41 100644 +index aca28d1e2530d239b0e2b55f75c6d0e398841ea1..ed50677f6b0445ac1c7246697c5f8d949bb59437 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -694,6 +694,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -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 @@ -45,10 +45,10 @@ index 8a046ad7590bd358d416f4aa21a3c173d0931d2a..cdcc64da3481ea8ab4bc680fef775bc1 // Paper start diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 38baa1b6c846fd1f8cdbe9faf5e38300dade87e9..307542eff210e8824f651ca42e15b00c22df98fc 100644 +index 7aa5ffc32835fab4a91db464d9112785475a67e9..6804055e9344eb2ea0b2dd6318231963376791c2 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -831,6 +831,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -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 @@ -57,7 +57,7 @@ index 38baa1b6c846fd1f8cdbe9faf5e38300dade87e9..307542eff210e8824f651ca42e15b00c protected Level( WritableLevelData levelData, diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index 9dbd97607866f8bd356044318ab670bcc794074f..cc0abc586908631747ceb1c920e7c3cb3f7828dd 100644 +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 { @@ -85,8 +85,8 @@ index 9dbd97607866f8bd356044318ab670bcc794074f..cc0abc586908631747ceb1c920e7c3cb @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 +- 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 @@ -108,10 +108,10 @@ index 9dbd97607866f8bd356044318ab670bcc794074f..cc0abc586908631747ceb1c920e7c3cb : powerValue; } diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index fed11ed5ab97826915710b66395d1bdc926935b0..d6131c5ec6a4229291f7cecb9cec9251d54244ed 100644 +index 7ee94845b69139f7c419b9d6ee24ba1db0e69975..d90389c515255df8273a69c652ba524135928482 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -521,6 +521,13 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -524,6 +524,13 @@ public abstract class BlockBehaviour implements FeatureElement { return this.constantCollisionShape; } // Paper end - optimise collisions @@ -125,7 +125,7 @@ index fed11ed5ab97826915710b66395d1bdc926935b0..d6131c5ec6a4229291f7cecb9cec9251 protected BlockStateBase(Block owner, Reference2ObjectArrayMap, Comparable> values, MapCodec propertiesCodec) { super(owner, values, propertiesCodec); -@@ -635,6 +642,7 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -638,6 +645,7 @@ public abstract class BlockBehaviour implements FeatureElement { } } // Paper end - optimise collisions @@ -134,10 +134,10 @@ index fed11ed5ab97826915710b66395d1bdc926935b0..d6131c5ec6a4229291f7cecb9cec9251 public Block getBlock() { diff --git a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java -index 028eae2f9a459b60e92f3344091083aa93b54485..9fbf679b54088f89ac4ba727ccb645d645f01bd7 100644 +index 879be2d05ef0fcfb8fab0c9f4e5bf66d7fce730b..c995827a4adad2279e98ede5e977aa2775349eec 100644 --- a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java +++ b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java -@@ -26,6 +26,13 @@ public class CollectingNeighborUpdater implements NeighborUpdater { +@@ -29,6 +29,13 @@ public class CollectingNeighborUpdater implements NeighborUpdater { this.maxChainedNeighborUpdates = maxChainedNeighborUpdates; } @@ -148,10 +148,10 @@ index 028eae2f9a459b60e92f3344091083aa93b54485..9fbf679b54088f89ac4ba727ccb645d6 + } + // Sakura end - cache vanilla and eigencraft wires + - @Override - public void shapeUpdate(Direction direction, BlockState state, BlockPos pos, BlockPos neighborPos, int flags, int recursionLevel) { - this.addAndRun(pos, new CollectingNeighborUpdater.ShapeUpdate(direction, state, pos.immutable(), neighborPos.immutable(), flags, recursionLevel)); -@@ -83,6 +90,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater { + public void setDebugListener(@Nullable Consumer debugListener) { + this.debugListener = debugListener; + } +@@ -93,6 +100,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater { } } } finally { diff --git a/sakura-server/minecraft-patches/features/0029-Configure-breaking-blocks-outside-the-world-border.patch b/sakura-server/minecraft-patches/features/0029-Configure-breaking-blocks-outside-the-world-border.patch index 8e9dda6..95e063e 100644 --- a/sakura-server/minecraft-patches/features/0029-Configure-breaking-blocks-outside-the-world-border.patch +++ b/sakura-server/minecraft-patches/features/0029-Configure-breaking-blocks-outside-the-world-border.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Configure breaking blocks outside the world border diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index 963bcb84fc48ae81e07a7a19074af17d302ac890..73c8f19826ca39ba344c9590d4420e0a25103d4d 100644 +index a185d44ef797663d5007c9084117ca6933ba46be..a252e8565b4b8e7f80477611b91f995706008753 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -517,6 +517,11 @@ public class ServerExplosion implements Explosion { +@@ -519,6 +519,11 @@ public class ServerExplosion implements Explosion { return ret; } // Sakura end - optimise protected explosions diff --git a/sakura-server/minecraft-patches/features/0030-Optimise-block-counting-for-cannon-entities.patch b/sakura-server/minecraft-patches/features/0030-Optimise-block-counting-for-cannon-entities.patch index 0566630..fa5126a 100644 --- a/sakura-server/minecraft-patches/features/0030-Optimise-block-counting-for-cannon-entities.patch +++ b/sakura-server/minecraft-patches/features/0030-Optimise-block-counting-for-cannon-entities.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Optimise block counting for cannon entities diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java -index 17940de16399033575c2c8031cdf1092f7b39ea2..884ea2f49afc43c09af9c0b42d34f417bd14ec9e 100644 +index 54d561e1b4069df7115457accb0763fa7586dddc..29f66ef8355a95b2869988187bf74536343f2ec8 100644 --- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java @@ -1941,6 +1941,7 @@ public final class CollisionUtil { @@ -42,10 +42,10 @@ index 17940de16399033575c2c8031cdf1092f7b39ea2..884ea2f49afc43c09af9c0b42d34f417 for (int currY = minYIterate; currY <= maxYIterate; ++currY) { final int blockY = currY | (currChunkY << 4); diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 307542eff210e8824f651ca42e15b00c22df98fc..c3cc64d75338e5fd58db074284cb10b5f778f007 100644 +index 6804055e9344eb2ea0b2dd6318231963376791c2..3a3d22835df907a85c38cd178c1db9d96554b8e0 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -616,6 +616,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -621,6 +621,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl BlockPos selected = null; double selectedDistance = Double.MAX_VALUE; final Vec3 entityPos = entity.position(); @@ -53,7 +53,7 @@ index 307542eff210e8824f651ca42e15b00c22df98fc..c3cc64d75338e5fd58db074284cb10b5 // special cases: if (minBlockY > maxBlockY) { -@@ -658,15 +659,19 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl +@@ -663,15 +664,19 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl final boolean hasSpecial = ((ca.spottedleaf.moonrise.patches.block_counting.BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks(); final int sectionAdjust = !hasSpecial ? 1 : 0; @@ -79,10 +79,10 @@ index 307542eff210e8824f651ca42e15b00c22df98fc..c3cc64d75338e5fd58db074284cb10b5 for (int currY = minYIterate; currY <= maxYIterate; ++currY) { final int blockY = currY | (currChunkY << 4); diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java -index 598e22c085e55be7a35ca6d73b8bc9f465bb6e33..ea193b58a9e49a1c33f0191285a58086be9e0dfa 100644 +index 029d224557613b46f015785a5bbffe49a6f39ec6..a13771119488202fa0ad27121616f82553be968c 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -47,6 +47,13 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ +@@ -43,6 +43,13 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ return this.tickingBlocks; } // Paper end - block counting @@ -96,13 +96,13 @@ index 598e22c085e55be7a35ca6d73b8bc9f465bb6e33..ea193b58a9e49a1c33f0191285a58086 private LevelChunkSection(LevelChunkSection section) { this.nonEmptyBlockCount = section.nonEmptyBlockCount; -@@ -117,6 +124,18 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ +@@ -113,6 +120,18 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ } } + // Sakura start - optimise block counting for cannon entities -+ final boolean isMovingPistonOld = oldState.is(Blocks.MOVING_PISTON); -+ final boolean isMovingPistonNew = newState.is(Blocks.MOVING_PISTON); ++ final boolean isMovingPistonOld = oldState.is(net.minecraft.world.level.block.Blocks.MOVING_PISTON); ++ final boolean isMovingPistonNew = newState.is(net.minecraft.world.level.block.Blocks.MOVING_PISTON); + if (isMovingPistonOld != isMovingPistonNew) { + if (isMovingPistonOld) { + --this.movingPistonBlocks; @@ -115,7 +115,7 @@ index 598e22c085e55be7a35ca6d73b8bc9f465bb6e33..ea193b58a9e49a1c33f0191285a58086 final boolean oldTicking = oldState.isRandomlyTicking(); final boolean newTicking = newState.isRandomlyTicking(); if (oldTicking != newTicking) { -@@ -192,6 +211,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ +@@ -188,6 +207,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ this.tickingBlockCount = (short)0; this.tickingFluidCount = (short)0; this.specialCollidingBlocks = (short)0; @@ -123,12 +123,12 @@ index 598e22c085e55be7a35ca6d73b8bc9f465bb6e33..ea193b58a9e49a1c33f0191285a58086 this.tickingBlocks.clear(); if (this.maybeHas((final BlockState state) -> !state.isAir())) { -@@ -220,6 +240,12 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ +@@ -216,6 +236,12 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ continue; } + // Sakura start - optimise block counting for cannon entities -+ if (state.is(Blocks.MOVING_PISTON)) { ++ if (state.is(net.minecraft.world.level.block.Blocks.MOVING_PISTON)) { + this.movingPistonBlocks += (short) paletteCount; + } + // Sakura end - optimise block counting for cannon entities diff --git a/sakura-server/minecraft-patches/features/0031-Protect-blocks-above-a-configured-Y-level-from-explo.patch b/sakura-server/minecraft-patches/features/0031-Protect-blocks-above-a-configured-Y-level-from-explo.patch index 5b5311f..ab10209 100644 --- a/sakura-server/minecraft-patches/features/0031-Protect-blocks-above-a-configured-Y-level-from-explo.patch +++ b/sakura-server/minecraft-patches/features/0031-Protect-blocks-above-a-configured-Y-level-from-explo.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Protect blocks above a configured Y-level from explosions diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index 3b2498ab4f3da5aea22931532901a540ffb03e73..b5c50214830bd04d916850de6920a651b94e8463 100644 +index a252e8565b4b8e7f80477611b91f995706008753..5d3cfeb3256d1173e1d16f05c501d99503bb6bde 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -381,6 +381,11 @@ public class ServerExplosion implements Explosion { +@@ -383,6 +383,11 @@ public class ServerExplosion implements Explosion { return Optional.of(net.minecraft.world.level.block.Blocks.BARRIER.getExplosionResistance()); } // Sakura end - protect scaffolding from creepers diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch index 0429ff5..1f9c01c 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -300,6 +_,7 @@ +@@ -307,6 +_,7 @@ public volatile boolean abnormalExit; // Paper - Improved watchdog support public volatile Thread shutdownThread; // Paper - Improved watchdog support public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files @@ -8,7 +8,7 @@ public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked private final Set pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation -@@ -319,6 +_,17 @@ +@@ -326,6 +_,17 @@ thread.start(); return minecraftServer; } @@ -26,10 +26,10 @@ // Paper start - rewrite chunk system private volatile Throwable chunkSystemCrash; -@@ -471,6 +_,10 @@ +@@ -476,6 +_,10 @@ Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this)); // CraftBukkit end - this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files + this.paperConfigurations = services.paper().configurations(); // Paper - add paper configuration files + // Sakura start - sakura configuration files + final java.nio.file.Path sakuraConfigDirPath = ((java.io.File) options.valueOf("sakura-settings-directory")).toPath(); + this.sakuraConfigurations = me.samsuik.sakura.configuration.SakuraConfigurations.setup(sakuraConfigDirPath); @@ -37,7 +37,7 @@ } private void readScoreboard(DimensionDataStorage dataStorage) { -@@ -1223,6 +_,7 @@ +@@ -1155,6 +_,7 @@ if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) { final long diff = currentTime - tickSection; final java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP); @@ -45,7 +45,7 @@ tps1.add(currentTps, diff); tps5.add(currentTps, diff); tps15.add(currentTps, diff); -@@ -1260,6 +_,7 @@ +@@ -1192,6 +_,7 @@ // Paper end - rewrite chunk system this.tickFrame.end(); profilerFiller.popPush("nextTickWait"); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch index 0d91e60..9497ba6 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -184,6 +_,11 @@ +@@ -277,6 +_,11 @@ this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now @@ -10,5 +10,5 @@ + me.samsuik.sakura.command.SakuraCommands.registerCommands(this); + // Sakura end - sakura configuration files - this.setPvpAllowed(properties.pvp); - this.setFlightAllowed(properties.allowFlight); + // this.worldData.setGameType(properties.gameMode.get()); // CraftBukkit - moved to world loading + LOGGER.info("Default game type: {}", properties.gameMode.get()); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ChunkMap.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ChunkMap.java.patch index 64d3660..11682d9 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ChunkMap.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ChunkMap.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java @@ -134,7 +_,7 @@ - public final AtomicInteger tickingGenerated = new AtomicInteger(); // Paper - public + public final ChunkMap.DistanceManager distanceManager; private final String storageName; private final PlayerMap playerMap = new PlayerMap(); - public final Int2ObjectMap entityMap = new Int2ObjectOpenHashMap<>(); @@ -9,7 +9,7 @@ private final Long2ByteMap chunkTypeCache = new Long2ByteOpenHashMap(); // Paper - rewrite chunk system public int serverViewDistance; -@@ -1287,7 +_,10 @@ +@@ -1330,7 +_,10 @@ double vec3_dz = player.getZ() - this.entity.getZ(); // Paper end - remove allocation of Vec3D here int playerViewDistance = ChunkMap.this.getPlayerViewDistance(player); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ServerLevel.java.patch index 295e625..63b5850 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -583,7 +_,7 @@ +@@ -602,7 +_,7 @@ org.bukkit.generator.BiomeProvider biomeProvider // CraftBukkit ) { // CraftBukkit start -- super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor -+ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), () -> server.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), server.registryAccess())), dispatcher); // Sakura - sakura configuration files // Paper - create paper world configs; Async-Anti-Xray: Pass executor - this.pvpMode = server.isPvpAllowed(); - this.levelStorageAccess = levelStorageAccess; +- super(levelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(storageSource.levelDirectory.path(), levelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), levelData.getGameRules())), dispatcher); // Paper - create paper world configsAsync-Anti-Xray: Pass executor ++ super(levelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(storageSource.levelDirectory.path(), levelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), levelData.getGameRules())), () -> server.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(storageSource.levelDirectory.path(), levelData.getLevelName(), dimension.location(), server.registryAccess())), dispatcher); // Sakura - sakura configuration files // Paper - create paper world configs; Async-Anti-Xray: Pass executor + this.levelStorageAccess = storageSource; this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile()); + this.levelLoadListener = new net.minecraft.server.level.progress.LoggingLevelLoadListener(false, this); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index 4ac84de..5c23a7d 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -296,7 +_,7 @@ +@@ -307,7 +_,7 @@ // Paper start - Sync offhand slot in menus @Override public void sendOffHandSlotChange() { @@ -9,7 +9,7 @@ } // Paper end - Sync offhand slot in menus -@@ -429,6 +_,7 @@ +@@ -442,6 +_,7 @@ public boolean isRealPlayer; // Paper public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/Entity.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/Entity.java.patch index 32cfb70..4af8b6d 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -532,6 +_,7 @@ +@@ -534,6 +_,7 @@ } } // Paper end - optimise entity tracker @@ -8,7 +8,7 @@ public Entity(EntityType entityType, Level level) { this.type = entityType; -@@ -4227,7 +_,7 @@ +@@ -4301,7 +_,7 @@ } public boolean isPushedByFluid() { diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 1d45ff1..9c7082a 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -287,6 +_,43 @@ +@@ -288,6 +_,43 @@ public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API public int shieldBlockingDelay = this.level().paperConfig().misc.shieldBlockingDelay; // Paper - Make shield blocking delay configurable // CraftBukkit end @@ -44,7 +44,7 @@ protected LivingEntity(EntityType entityType, Level level) { super(entityType, level); -@@ -1513,7 +_,7 @@ +@@ -1521,7 +_,7 @@ } // Paper end - Check distance in entity interactions @@ -53,7 +53,7 @@ if (!flag) { this.indicateDamage(d, d1); } -@@ -1615,6 +_,11 @@ +@@ -1623,6 +_,11 @@ if (itemBlockingWith == null) { return false; } else { @@ -65,7 +65,7 @@ BlocksAttacks blocksAttacks = itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS); if (blocksAttacks != null && !blocksAttacks.bypassedBy().map(damageSource::is).orElse(false)) { if (damageSource.getDirectEntity() instanceof AbstractArrow abstractArrow && abstractArrow.getPierceLevel() > 0) { -@@ -1641,6 +_,12 @@ +@@ -1649,6 +_,12 @@ acos = (float) Math.PI; } @@ -78,7 +78,7 @@ BlocksAttacks blocksAttacks = this.getItemBlockingWith().get(DataComponents.BLOCKS_ATTACKS); return blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); } -@@ -1708,7 +_,7 @@ +@@ -1716,7 +_,7 @@ } protected void blockedByItem(LivingEntity entity) { @@ -87,7 +87,7 @@ } private boolean checkTotemDeathProtection(DamageSource damageSource) { -@@ -1865,6 +_,12 @@ +@@ -1873,6 +_,12 @@ // Paper start if (this.dead) { // Paper @@ -100,7 +100,7 @@ this.level().broadcastEntityEvent(this, (byte)3); this.setPose(Pose.DYING); -@@ -2038,7 +_,7 @@ +@@ -2070,7 +_,7 @@ } public void knockback(double strength, double x, double z, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events @@ -109,7 +109,7 @@ if (true || !(strength <= 0.0)) { // CraftBukkit - Call event even when force is 0 // this.hasImpulse = true; // CraftBukkit - Move down Vec3 deltaMovement = this.getDeltaMovement(); -@@ -2049,10 +_,18 @@ +@@ -2081,10 +_,18 @@ } Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); @@ -129,7 +129,7 @@ deltaMovement.z / 2.0 - vec3.z ); Vec3 diff = finalVelocity.subtract(deltaMovement); -@@ -2197,8 +_,14 @@ +@@ -2229,8 +_,14 @@ } } @@ -145,7 +145,7 @@ return 0; } else { double d = this.calculateFallPower(fallDistance); -@@ -2256,9 +_,21 @@ +@@ -2288,9 +_,21 @@ protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { // this.hurtArmor(damageSource, damageAmount); // CraftBukkit - actuallyHurt(DamageSource, float, EntityDamageEvent) for damage handling @@ -167,7 +167,7 @@ } return damageAmount; -@@ -2438,6 +_,12 @@ +@@ -2470,6 +_,12 @@ armorDamage += (float) event.getDamage(DamageModifier.BLOCKING); armorDamage += (float) event.getDamage(DamageModifier.FREEZING); armorDamage += (float) event.getDamage(DamageModifier.HARD_HAT); @@ -180,7 +180,7 @@ this.hurtArmor(damageSource, armorDamage); } -@@ -3384,6 +_,11 @@ +@@ -3416,6 +_,11 @@ if (this.level() instanceof ServerLevel serverLevel) { EnchantmentHelper.runLocationChangedEffects(serverLevel, itemBySlot, this, equipmentSlot1); } @@ -192,7 +192,7 @@ } } -@@ -3584,7 +_,7 @@ +@@ -3616,7 +_,7 @@ } } // Paper end - Add EntityMoveEvent @@ -201,7 +201,7 @@ this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } } -@@ -4173,6 +_,13 @@ +@@ -4200,6 +_,13 @@ if (!this.isUsingItem()) { return null; } else { diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/Mob.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/Mob.java.patch index ed30dc0..e6a718e 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -746,7 +_,7 @@ +@@ -757,7 +_,7 @@ protected final void serverAiStep() { this.noActionTime++; // Paper start - Allow nerfed mobs to jump and float diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index b1ec7dd..a33d8b9 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -67,7 +67,7 @@ if (this.blockState.hasProperty(BlockStateProperties.WATERLOGGED) && this.level().getFluidState(blockPos).getType() == Fluids.WATER) { this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, true); -@@ -247,6 +_,10 @@ +@@ -246,6 +_,10 @@ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause this.callOnBrokenAfterFall(block, blockPos); this.spawnAtLocation(serverLevel, block); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch index 2ae6d9f..47fa3b0 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -368,6 +_,13 @@ +@@ -359,6 +_,13 @@ @Override public boolean ignoreExplosion(Explosion explosion) { diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch index de963dd..6555dec 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch @@ -3,7 +3,7 @@ @@ -75,7 +_,28 @@ this.yo = y; this.zo = z; - this.owner = owner != null ? new EntityReference<>(owner) : null; + this.owner = EntityReference.of(owner); - } + // Sakura start - configure cannon mechanics + switch (level.sakuraConfig().cannons.mechanics.tntSpread) { diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch index 62e2374..71e200e 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Creeper.java +++ b/net/minecraft/world/entity/monster/Creeper.java -@@ -247,7 +_,12 @@ +@@ -250,7 +_,12 @@ if (!event.isCancelled()) { // CraftBukkit end this.dead = true; diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch index 6b3f380..e4ecfce 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -219,6 +_,7 @@ +@@ -180,6 +_,7 @@ private int currentImpulseContextResetGraceTime = 0; public boolean affectsSpawning = true; // Paper - Affects Spawning API public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage @@ -8,17 +8,27 @@ // CraftBukkit start public boolean fauxSleeping; -@@ -229,6 +_,18 @@ +@@ -190,6 +_,28 @@ return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity(); } // CraftBukkit end ++ // Sakura start - player poses shrink collision box ++ @Override ++ public net.minecraft.world.entity.EntityDimensions getDefaultDimensions(final Pose pose) { ++ final net.minecraft.world.entity.EntityDimensions dimensions = super.getDefaultDimensions(pose); ++ if (!this.level().sakuraConfig().players.posesShrinkCollisionBox && dimensions.height() != Avatar.STANDING_DIMENSIONS.height()) { ++ return STANDING_DIMENSIONS; ++ } ++ return dimensions; ++ } ++ // Sakura end - player poses shrink collision box + // Sakura start - prevent players glitching through blocks + public final boolean isInsideAnyCollision() { + return this.insideAnyCollisionAt(this.level(), this.position()); + } + + public final boolean insideAnyCollisionAt(final Level level, final Vec3 position) { -+ final EntityDimensions entityDimensions = this.getDimensions(Pose.STANDING); ++ final net.minecraft.world.entity.EntityDimensions entityDimensions = this.getDimensions(Pose.STANDING); + final AABB entityBB = entityDimensions.makeBoundingBox(position); + return !level.noCollision(this, entityBB.deflate(1.0e-7)) + || !level.getWorldBorder().isWithinBounds(entityBB); @@ -27,7 +37,7 @@ public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -866,6 +_,10 @@ +@@ -718,6 +_,10 @@ public boolean isInvulnerableTo(ServerLevel level, DamageSource damageSource) { if (super.isInvulnerableTo(level, damageSource)) { return true; @@ -38,7 +48,7 @@ } else if (damageSource.is(DamageTypeTags.IS_DROWNING)) { return !level.getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE); } else if (damageSource.is(DamageTypeTags.IS_FALL)) { -@@ -1182,13 +_,19 @@ +@@ -1030,13 +_,19 @@ if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable. { // Paper end - PlayerAttackEntityEvent @@ -59,17 +69,17 @@ // this.resetAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt if (target.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && target instanceof Projectile projectile) { -@@ -1206,7 +_,7 @@ +@@ -1054,7 +_,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = attackStrengthScale > 0.9F; boolean flag1; - if (this.isSprinting() && flag) { + if (this.isSprinting() && (!this.level().sakuraConfig().players.knockback.sprinting.requireFullAttack || flag)) { // Sakura - configure entity knockback - this.sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility + sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility flag1 = true; } else { -@@ -1222,7 +_,7 @@ - && !this.hasEffect(MobEffects.BLINDNESS) +@@ -1070,7 +_,7 @@ + && !this.isMobilityRestricted() && !this.isPassenger() && target instanceof LivingEntity - && !this.isSprinting(); @@ -77,7 +87,7 @@ flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits if (flag2) { damageSource = damageSource.critical(); // Paper - critical damage API -@@ -1249,7 +_,21 @@ +@@ -1097,7 +_,21 @@ if (flag4) { float f4 = this.getKnockback(target, damageSource) + (flag1 ? 1.0F : 0.0F); if (f4 > 0.0F) { @@ -100,7 +110,7 @@ livingEntity1.knockback( f4 * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) , this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // Paper - knockback events -@@ -1271,7 +_,7 @@ +@@ -1119,7 +_,7 @@ // Paper end - Configurable sprint interruption on attack } @@ -109,7 +119,7 @@ float f5 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * f; for (LivingEntity livingEntity2 : this.level() -@@ -1287,7 +_,7 @@ +@@ -1135,7 +_,7 @@ if (this.level() instanceof ServerLevel serverLevel && livingEntity2.hurtServer(serverLevel, damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), f6) && !livingEntity2.lastDamageCancelled) { // Paper end - Only apply knockback if the event is not cancelled livingEntity2.knockback( @@ -118,7 +128,7 @@ , this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK // Paper - knockback events ); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity2, damageSource); -@@ -1375,7 +_,7 @@ +@@ -1223,7 +_,7 @@ if (target instanceof LivingEntity) { float f7 = f3 - ((LivingEntity)target).getHealth(); this.awardStat(Stats.DAMAGE_DEALT, Math.round(f7 * 10.0F)); @@ -127,7 +137,7 @@ int i = (int)(f7 * 0.5); ((ServerLevel)this.level()) .sendParticles(ParticleTypes.DAMAGE_INDICATOR, target.getX(), target.getY(0.5), target.getZ(), i, 0.1, 0.0, 0.1, 0.2); -@@ -1764,6 +_,11 @@ +@@ -1616,6 +_,11 @@ // Paper start - send while respecting visibility private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) { @@ -139,18 +149,3 @@ fromEntity.level().playSound(fromEntity, x, y, z, soundEffect, soundCategory, volume, pitch); // This will not send the effect to the entity itself if (fromEntity instanceof ServerPlayer serverPlayer) { serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundSoundPacket(net.minecraft.core.registries.BuiltInRegistries.SOUND_EVENT.wrapAsHolder(soundEffect), soundCategory, x, y, z, volume, pitch, fromEntity.random.nextLong())); -@@ -2118,7 +_,13 @@ - - @Override - public EntityDimensions getDefaultDimensions(Pose pose) { -- return POSES.getOrDefault(pose, STANDING_DIMENSIONS); -+ // Sakura start - player poses shrink collision box -+ final EntityDimensions dimensions = POSES.getOrDefault(pose, STANDING_DIMENSIONS); -+ if (!this.level().sakuraConfig().players.posesShrinkCollisionBox && dimensions.height() == STANDING_DIMENSIONS.height()) { -+ return STANDING_DIMENSIONS; -+ } -+ return dimensions; -+ // Sakura end - player poses shrink collision box - } - - @Override diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch index 1b13b17..79341d1 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/AbstractThrownPotion.java +++ b/net/minecraft/world/entity/projectile/AbstractThrownPotion.java -@@ -39,6 +_,26 @@ +@@ -39,6 +_,25 @@ super(entityType, x, y, z, level, item); } @@ -18,9 +18,8 @@ + } + + @Override -+ protected boolean checkLeftOwner() { // may be overridden by plugins -+ return this.level().sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && this.tickCount >= 5 -+ || super.checkLeftOwner(); ++ protected final boolean breakInsideOwner() { ++ return this.level().sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && this.tickCount >= 5; + } + // Sakura end - configure potion mechanics + diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch index bd71468..04336d6 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -298,6 +_,12 @@ - if (!this.level().isClientSide) { +@@ -302,6 +_,12 @@ + if (!this.level().isClientSide()) { this.setHookedEntity(result.getEntity()); } + // Sakura start - configure entity knockback @@ -13,7 +13,7 @@ } @Override -@@ -599,7 +_,7 @@ +@@ -603,7 +_,7 @@ public void pullEntity(Entity entity) { Entity owner = this.getOwner(); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch new file mode 100644 index 0000000..759e513 --- /dev/null +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -0,0 +1,24 @@ +--- a/net/minecraft/world/entity/projectile/Projectile.java ++++ b/net/minecraft/world/entity/projectile/Projectile.java +@@ -51,6 +_,12 @@ + super(entityType, level); + } + ++ // Sakura start - configure potion mechanics ++ protected boolean breakInsideOwner() { ++ return false; ++ } ++ // Sakura end - configure potion mechanics ++ + protected void setOwner(@Nullable EntityReference owner) { + this.owner = owner; + this.refreshProjectileSource(false); // Paper +@@ -401,7 +_,7 @@ + } + } + // Paper end - Cancel hit for vanished entities +- return owner == null || this.leftOwner || !owner.isPassengerOfSameVehicle(target); ++ return owner == null || this.leftOwner || this.breakInsideOwner() || !owner.isPassengerOfSameVehicle(target); // Sakura - configure potion mechanics + } + } + diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch index d1d991f..ccb0b6d 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -16,7 +16,7 @@ @Override public Item getDefaultItem() { return Items.ENDER_PEARL; -@@ -118,6 +_,15 @@ +@@ -103,6 +_,15 @@ if (owner != null && isAllowedToTeleportOwner(owner, serverLevel)) { Vec3 vec3 = this.oldPosition(); if (owner instanceof ServerPlayer serverPlayer) { diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/BoatItem.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/BoatItem.java.patch index 9db2940..463f434 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/BoatItem.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/BoatItem.java.patch @@ -8,4 +8,4 @@ + if (!level.noCollision(boat, boat.getBoundingBox()) || !level.getWorldBorder().isWithinBounds(boat.getBoundingBox())) { // Sakura - fix placing boats outside the world border return InteractionResult.FAIL; } else { - if (!level.isClientSide) { + if (!level.isClientSide()) { diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/BucketItem.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/BucketItem.java.patch index e3b100e..6bc1219 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/BucketItem.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/BucketItem.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/item/BucketItem.java @@ -147,7 +_,7 @@ // CraftBukkit end - if (!flag) { + if (!flag2) { return hitResult != null && this.emptyContents(entity, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null, direction, clicked, itemstack, hand); // CraftBukkit - } else if (level.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { + } else if (!level.sakuraConfig().environment.allowWaterInTheNether && level.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { // Sakura - allow water in the nether diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/Item.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/Item.java.patch index 4846ef5..5060c89 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/Item.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/Item.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/Item.java +++ b/net/minecraft/world/item/Item.java -@@ -131,6 +_,11 @@ +@@ -134,6 +_,11 @@ } } diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/ItemStack.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/ItemStack.java.patch index 0e32341..8cc4377 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -822,6 +_,15 @@ +@@ -823,6 +_,15 @@ } } diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/Items.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/Items.java.patch index ebc7a2f..0291fbc 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/Items.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/Items.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/Items.java +++ b/net/minecraft/world/item/Items.java -@@ -1158,32 +_,32 @@ +@@ -1207,7 +_,7 @@ public static final Item GOLD_INGOT = registerItem("gold_ingot", new Item.Properties().trimMaterial(TrimMaterials.GOLD)); public static final Item NETHERITE_INGOT = registerItem("netherite_ingot", new Item.Properties().fireResistant().trimMaterial(TrimMaterials.NETHERITE)); public static final Item NETHERITE_SCRAP = registerItem("netherite_scrap", new Item.Properties().fireResistant()); @@ -9,7 +9,10 @@ public static final Item WOODEN_SHOVEL = registerItem("wooden_shovel", properties -> new ShovelItem(ToolMaterial.WOOD, 1.5F, -3.0F, properties)); public static final Item WOODEN_PICKAXE = registerItem("wooden_pickaxe", new Item.Properties().pickaxe(ToolMaterial.WOOD, 1.0F, -2.8F)); public static final Item WOODEN_AXE = registerItem("wooden_axe", properties -> new AxeItem(ToolMaterial.WOOD, 6.0F, -3.2F, properties)); - public static final Item WOODEN_HOE = registerItem("wooden_hoe", properties -> new HoeItem(ToolMaterial.WOOD, 0.0F, -3.0F, properties)); +@@ -1217,27 +_,27 @@ + public static final Item COPPER_PICKAXE = registerItem("copper_pickaxe", new Item.Properties().pickaxe(ToolMaterial.COPPER, 1.0F, -2.8F)); + public static final Item COPPER_AXE = registerItem("copper_axe", properties -> new AxeItem(ToolMaterial.COPPER, 7.0F, -3.2F, properties)); + public static final Item COPPER_HOE = registerItem("copper_hoe", properties -> new HoeItem(ToolMaterial.COPPER, -1.0F, -2.0F, properties)); - public static final Item STONE_SWORD = registerItem("stone_sword", new Item.Properties().sword(ToolMaterial.STONE, 3.0F, -2.4F)); + public static final Item STONE_SWORD = registerItem("stone_sword", me.samsuik.sakura.player.item.BlockableSwordItem::new, new Item.Properties().sword(ToolMaterial.STONE, 3.0F, -2.4F)); // Sakura - allow blocking with swords public static final Item STONE_SHOVEL = registerItem("stone_shovel", properties -> new ShovelItem(ToolMaterial.STONE, 1.5F, -3.0F, properties)); @@ -39,7 +42,7 @@ public static final Item NETHERITE_SHOVEL = registerItem( "netherite_shovel", properties -> new ShovelItem(ToolMaterial.NETHERITE, 1.5F, -3.0F, properties), new Item.Properties().fireResistant() ); -@@ -1261,6 +_,7 @@ +@@ -1321,6 +_,7 @@ public static final Item GOLDEN_APPLE = registerItem("golden_apple", new Item.Properties().food(Foods.GOLDEN_APPLE, Consumables.GOLDEN_APPLE)); public static final Item ENCHANTED_GOLDEN_APPLE = registerItem( "enchanted_golden_apple", @@ -47,7 +50,7 @@ new Item.Properties() .rarity(Rarity.RARE) .food(Foods.ENCHANTED_GOLDEN_APPLE, Consumables.ENCHANTED_GOLDEN_APPLE) -@@ -1362,12 +_,12 @@ +@@ -1422,12 +_,12 @@ (block, properties) -> new HangingSignItem(block, Blocks.WARPED_WALL_HANGING_SIGN, properties), new Item.Properties().stacksTo(16) ); @@ -63,7 +66,7 @@ ); public static final Item POWDER_SNOW_BUCKET = registerItem( "powder_snow_bucket", -@@ -1378,6 +_,7 @@ +@@ -1438,6 +_,7 @@ public static final Item LEATHER = registerItem("leather"); public static final Item MILK_BUCKET = registerItem( "milk_bucket", diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch index 7f7cc1d..a7a0115 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch @@ -1,50 +1,23 @@ --- a/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java -@@ -13,6 +_,7 @@ - import net.minecraft.core.registries.Registries; - import net.minecraft.server.level.ServerLevel; +@@ -14,6 +_,7 @@ + import net.minecraft.server.level.ServerPlayer; import net.minecraft.stats.Stats; + import net.minecraft.world.Difficulty; +import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.AgeableMob; -@@ -71,16 +_,21 @@ - } - - EntityType type = this.getType(level.registryAccess(), itemInHand); -+ // Sakura start - prevent placing spawn eggs inside blocks -+ if (level.sakuraConfig().players.preventPlacingSpawnEggsInsideBlocks && !level.noCollision(type.getSpawnAABB(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5))) { -+ return InteractionResult.PASS; -+ } -+ // Sakura end - prevent placing spawn eggs inside blocks +@@ -98,6 +_,12 @@ + } else if (!type.isAllowedInPeaceful(stack.get(DataComponents.ENTITY_DATA).getUnsafe()) && level.getDifficulty() == Difficulty.PEACEFUL) { // Paper - check peaceful override + return InteractionResult.FAIL; + } else { ++ // Sakura start - prevent placing spawn eggs inside blocks ++ if (level.sakuraConfig().players.preventPlacingSpawnEggsInsideBlocks && !level.noCollision(type.getSpawnAABB(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5))) { ++ return InteractionResult.PASS; ++ } ++ // Sakura end - prevent placing spawn eggs inside blocks + - if (type.spawn( -- (ServerLevel)level, -- itemInHand, -- context.getPlayer(), -- blockPos, -- EntitySpawnReason.SPAWN_ITEM_USE, -- true, -- !Objects.equals(clickedPos, blockPos) && clickedFace == Direction.UP -- ) -- != null) { -+ (ServerLevel)level, -+ itemInHand, -+ context.getPlayer(), -+ blockPos, -+ EntitySpawnReason.SPAWN_ITEM_USE, -+ true, -+ !Objects.equals(clickedPos, blockPos) && clickedFace == Direction.UP -+ ) != null) { - itemInHand.shrink(1); - level.gameEvent(context.getPlayer(), GameEvent.ENTITY_PLACE, clickedPos); - } -@@ -103,7 +_,7 @@ - } else if (level.mayInteract(player, blockPos) && player.mayUseItemAt(blockPos, playerPovHitResult.getDirection(), itemInHand)) { - EntityType type = this.getType(serverLevel.registryAccess(), itemInHand); - Entity entity = type.spawn(serverLevel, itemInHand, player, blockPos, EntitySpawnReason.SPAWN_ITEM_USE, false, false); -- if (entity == null) { -+ if (entity == null || level.sakuraConfig().players.preventPlacingSpawnEggsInsideBlocks && !level.noCollision(null, entity.getBoundingBox())) { // Sakura - prevent placing spawn eggs inside blocks - return InteractionResult.PASS; - } else { - itemInHand.consume(1, player); + if (type.spawn((ServerLevel)level, stack, source, pos, EntitySpawnReason.SPAWN_ITEM_USE, shouldOffsetY, shouldOffsetYMore) != null) { + stack.consume(1, source); + level.gameEvent(source, GameEvent.ENTITY_PLACE, pos); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/BaseSpawner.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/BaseSpawner.java.patch index b298871..7806f80 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/BaseSpawner.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/BaseSpawner.java.patch @@ -22,7 +22,7 @@ tickDelay = serverLevel.paperConfig().tickRates.mobSpawner; if (tickDelay == -1) { return; } // If disabled // Paper end - Configurable mob spawner tick rate -- if (this.isNearPlayer(serverLevel, pos)) { +- if (this.isNearPlayer(serverLevel, pos) && serverLevel.getServer().isSpawnerBlockEnabled()) { + if (!serverLevel.sakuraConfig().environment.mobSpawner.requireNearbyPlayer || this.isNearPlayer(serverLevel, pos)) { // Sakura - configure mob spawner behaviour if (this.spawnDelay < -tickDelay) { // Paper - Configurable mob spawner tick rate this.delay(serverLevel, pos); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch index 4e35835..b456303 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -109,7 +_,7 @@ +@@ -114,7 +_,7 @@ public final List blockEntityTickers = Lists.newArrayList(); - public final NeighborUpdater neighborUpdater; + public final CollectingNeighborUpdater neighborUpdater; private final List pendingBlockEntityTickers = Lists.newArrayList(); - private boolean tickingBlockEntities; + public boolean tickingBlockEntities; public final Thread thread; private final boolean isDebug; private int skyDarken; -@@ -159,6 +_,18 @@ +@@ -164,6 +_,18 @@ return this.paperConfig; } // Paper end - add paper world config @@ -28,7 +28,7 @@ public static @Nullable BlockPos lastPhysicsProblem; // Spigot private int tileTickPosition; -@@ -827,6 +_,7 @@ +@@ -832,6 +_,7 @@ org.bukkit.World.Environment environment, // Paper java.util.function.Function paperWorldConfigCreator, // Paper - create paper world config @@ -36,7 +36,7 @@ java.util.concurrent.Executor executor // Paper - Anti-Xray ) { // Paper start - getblock optimisations - cache world height/sections -@@ -840,6 +_,7 @@ +@@ -845,6 +_,7 @@ // Paper end - getblock optimisations - cache world height/sections this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/ServerExplosion.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/ServerExplosion.java.patch index eca08ac..af6055f 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/ServerExplosion.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/ServerExplosion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -60,6 +_,7 @@ +@@ -62,6 +_,7 @@ public float yield; // CraftBukkit end public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source @@ -8,7 +8,7 @@ // Paper start - collisions optimisations private static final double[] CACHED_RAYS; static { -@@ -326,6 +_,7 @@ +@@ -328,6 +_,7 @@ this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; this.yield = Double.isFinite(this.yield) ? this.yield : 0; // Paper - Don't allow infinite default yields // Paper end - add yield @@ -16,7 +16,7 @@ } private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { -@@ -414,8 +_,7 @@ +@@ -416,8 +_,7 @@ final double incZ = CACHED_RAYS[ray + 2]; ray += 3; @@ -26,7 +26,7 @@ do { final int blockX = Mth.floor(currX); -@@ -622,7 +_,20 @@ +@@ -610,7 +_,20 @@ .onExplosionHit(this.level, blockPos, this, (itemStack, blockPos1) -> addOrAppendStack(list, itemStack, blockPos1)); } diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch index 00120b6..eb6d393 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java -@@ -140,7 +_,7 @@ +@@ -144,7 +_,7 @@ } // Paper start - Configurable speed for water flowing over lava public int getFlowSpeed(Level level, BlockPos pos) { @@ -9,7 +9,7 @@ if ( isLava(level, pos.north(1)) || isLava(level, pos.south(1)) || -@@ -150,7 +_,7 @@ +@@ -154,7 +_,7 @@ return level.paperConfig().environment.waterOverLavaFlowSpeed; } } @@ -18,7 +18,7 @@ } private static boolean isLava(Level level, BlockPos pos) { final FluidState fluidState = level.getFluidIfLoaded(pos); -@@ -189,6 +_,11 @@ +@@ -193,6 +_,11 @@ for (Direction direction : POSSIBLE_FLOW_DIRECTIONS) { BlockPos blockPos = pos.relative(direction.getOpposite()); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch index 3b95e97..0d1505f 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/DispenserBlockEntity.java +++ b/net/minecraft/world/level/block/entity/DispenserBlockEntity.java -@@ -70,8 +_,11 @@ +@@ -71,8 +_,11 @@ int i = -1; int i1 = 1; diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch index 515439f..1755b2a 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -310,12 +_,18 @@ +@@ -306,12 +_,18 @@ public void fillBiomesFromNoise(BiomeResolver biomeResolver, Climate.Sampler climateSampler, int x, int y, int z) { PalettedContainer> palettedContainer = this.biomes.recreate(); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch index f8a6a8f..7cfdb21 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -152,12 +_,12 @@ +@@ -153,12 +_,12 @@ } protected void spread(ServerLevel level, BlockPos pos, BlockState blockState, FluidState fluidState) { @@ -15,7 +15,7 @@ Fluid type = newLiquid.getType(); if (fluidState1.canBeReplacedWith(level, blockPos, type, Direction.DOWN) && canHoldSpecificFluid(level, blockPos, blockState1, type)) { // CraftBukkit start -@@ -199,6 +_,11 @@ +@@ -200,6 +_,11 @@ BlockPos blockPos = pos.relative(direction); final BlockState blockStateIfLoaded = level.getBlockStateIfLoaded(blockPos); // Paper - Prevent chunk loading from fluid flowing if (blockStateIfLoaded == null) continue; // Paper - Prevent chunk loading from fluid flowing @@ -27,7 +27,7 @@ // CraftBukkit start org.bukkit.block.Block source = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); org.bukkit.event.block.BlockFromToEvent event = new org.bukkit.event.block.BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)); -@@ -213,17 +_,83 @@ +@@ -214,17 +_,83 @@ } } @@ -113,7 +113,7 @@ if (fluidState.isSource()) { i1++; } -@@ -236,19 +_,11 @@ +@@ -237,19 +_,11 @@ BlockState blockState1 = level.getBlockState(mutableBlockPos.setWithOffset(pos, Direction.DOWN)); FluidState fluidState1 = blockState1.getFluidState(); if (blockState1.isSolid() || this.isSourceBlockOfThisType(fluidState1)) { @@ -135,7 +135,7 @@ } // Paper start - fluid method optimisations -@@ -414,7 +_,7 @@ +@@ -417,7 +_,7 @@ if (blockState == null) continue; // Paper - Prevent chunk loading from fluid flowing FluidState fluidState = blockState.getFluidState(); if (this.canMaybePassThrough(level, pos, state, direction, blockPos, blockState, fluidState)) { @@ -144,7 +144,7 @@ if (canHoldSpecificFluid(level, blockPos, blockState, newLiquid.getType())) { if (spreadContext == null) { spreadContext = new FlowingFluid.SpreadContext(level, pos); -@@ -465,6 +_,11 @@ +@@ -468,6 +_,11 @@ } private static boolean canHoldSpecificFluid(BlockGetter level, BlockPos pos, BlockState state, Fluid fluid) { @@ -156,7 +156,7 @@ return !(state.getBlock() instanceof LiquidBlockContainer liquidBlockContainer) || liquidBlockContainer.canPlaceLiquid(null, level, pos, state, fluid); } -@@ -477,7 +_,7 @@ +@@ -480,7 +_,7 @@ @Override public void tick(ServerLevel level, BlockPos pos, BlockState blockState, FluidState fluidState) { if (!fluidState.isSource()) { diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch index 1404c0a..3be2c04 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -189,12 +_,20 @@ +@@ -190,12 +_,20 @@ @Override public int getTickDelay(LevelReader level) { diff --git a/sakura-server/paper-patches/features/0001-Client-Visibility-Settings.patch b/sakura-server/paper-patches/features/0001-Client-Visibility-Settings.patch index 0c01669..6decfb4 100644 --- a/sakura-server/paper-patches/features/0001-Client-Visibility-Settings.patch +++ b/sakura-server/paper-patches/features/0001-Client-Visibility-Settings.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Client Visibility Settings diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 5e6fed659a9c10697e8a029e484fdb25594bfb51..3f437cbafc601af4f37ed875cf2159c87d6c7c67 100644 +index b140ed057d6a0abe51cc2853b46abd61dc11ba9f..dd8d6eed46846364ca8e98efd6f4cfa49e0f4af1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -2328,6 +2328,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa +@@ -2272,6 +2272,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa handle.expToDrop = data.getIntOr("expToDrop", 0); handle.keepLevel = data.getBooleanOr("keepLevel", false); }); @@ -20,7 +20,7 @@ index 5e6fed659a9c10697e8a029e484fdb25594bfb51..3f437cbafc601af4f37ed875cf2159c8 } public void setExtraData(ValueOutput output) { -@@ -2349,6 +2354,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa +@@ -2293,6 +2298,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa paper.putLong("LastLogin", handle.loginTime); paper.putLong("LastSeen", System.currentTimeMillis()); // Paper end @@ -31,7 +31,7 @@ index 5e6fed659a9c10697e8a029e484fdb25594bfb51..3f437cbafc601af4f37ed875cf2159c8 } @Override -@@ -3022,6 +3031,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa +@@ -2871,6 +2880,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa return this.getHandle().allowsListing(); } diff --git a/sakura-server/paper-patches/files/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java.patch b/sakura-server/paper-patches/files/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java.patch index 3bba499..f7df3c0 100644 --- a/sakura-server/paper-patches/files/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java.patch +++ b/sakura-server/paper-patches/files/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -179,7 +_,7 @@ +@@ -178,7 +_,7 @@ .defaultOptions(PaperConfigurations::defaultOptions); } @@ -9,7 +9,7 @@ return options.serializers(builder -> builder .register(MapSerializer.TYPE, new MapSerializer(false)) .register(new EnumValueSerializer()) -@@ -341,7 +_,7 @@ +@@ -340,7 +_,7 @@ } } @@ -18,7 +18,7 @@ return List.of( MergeMap.DEFINITION ); -@@ -483,7 +_,7 @@ +@@ -482,7 +_,7 @@ } // Symlinks are not correctly checked in createDirectories diff --git a/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftServer.java.patch b/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftServer.java.patch index f955d6b..c04d860 100644 --- a/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftServer.java.patch +++ b/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftServer.java.patch @@ -1,14 +1,14 @@ --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1048,6 +_,7 @@ +@@ -992,6 +_,7 @@ org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot this.console.paperConfigurations.reloadConfigs(this.console); + this.console.sakuraConfigurations.reloadConfigs(this.console); // Sakura - sakura configuration files; missing comment above :< for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty - world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) -@@ -1079,6 +_,7 @@ + world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && world.getGameRules().getBoolean(GameRules.RULE_SPAWN_MONSTERS)); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) +@@ -1023,6 +_,7 @@ this.reloadData(); org.spigotmc.SpigotConfig.registerCommands(); // Spigot io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper diff --git a/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftWorld.java.patch b/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftWorld.java.patch index c5c2f88..6130572 100644 --- a/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftWorld.java.patch +++ b/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftWorld.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -294,6 +_,12 @@ +@@ -295,6 +_,12 @@ ).isValid(); } // Paper end diff --git a/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java.patch b/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java.patch index b995de8..2479cfb 100644 --- a/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java.patch +++ b/sakura-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -237,6 +_,18 @@ +@@ -244,6 +_,18 @@ this.firstPlayed = System.currentTimeMillis(); } diff --git a/sakura-server/src/main/java/me/samsuik/sakura/explosion/ExplosionToSend.java b/sakura-server/src/main/java/me/samsuik/sakura/explosion/ExplosionToSend.java new file mode 100644 index 0000000..ad47f19 --- /dev/null +++ b/sakura-server/src/main/java/me/samsuik/sakura/explosion/ExplosionToSend.java @@ -0,0 +1,6 @@ +package me.samsuik.sakura.explosion; + +import net.minecraft.world.phys.Vec3; + +public record ExplosionToSend(Vec3 position, int blocksDestroyed) { +} diff --git a/sakura-server/src/main/java/me/samsuik/sakura/explosion/SpecialisedExplosion.java b/sakura-server/src/main/java/me/samsuik/sakura/explosion/SpecialisedExplosion.java index 4a7d72b..9ad741f 100644 --- a/sakura-server/src/main/java/me/samsuik/sakura/explosion/SpecialisedExplosion.java +++ b/sakura-server/src/main/java/me/samsuik/sakura/explosion/SpecialisedExplosion.java @@ -3,7 +3,7 @@ package me.samsuik.sakura.explosion; import ca.spottedleaf.moonrise.common.util.WorldUtil; import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices; import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import it.unimi.dsi.fastutil.objects.*; import me.samsuik.sakura.mechanics.MechanicVersion; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; @@ -12,23 +12,25 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.ExplosionDamageCalculator; import net.minecraft.world.level.ServerExplosion; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; import org.jspecify.annotations.NullMarked; -import java.util.Arrays; -import java.util.List; +import java.util.*; import java.util.function.Consumer; @NullMarked public abstract class SpecialisedExplosion extends ServerExplosion { - private static final double ENTITY_DISPATCH_DISTANCE = Math.pow(32.0, 2.0); + private static final double ENTITY_DISPATCH_DISTANCE_SQR = 32.0 * 32.0; protected final T cause; // preferred over source - private Vec3 impactPosition; - protected final BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); - private final Consumer> applyEffects; + private Vec3 dispatchPosition; + private final List bufferedExplosions = new ObjectArrayList<>(); + private AABB bounds; + private final Set gameEvents = new ObjectOpenHashSet<>(); + private final Deque explosionsToSend = new ArrayDeque<>(); public SpecialisedExplosion( final ServerLevel level, @@ -38,50 +40,80 @@ public abstract class SpecialisedExplosion extends ServerExplo final Vec3 center, final float power, final boolean createFire, - final BlockInteraction destructionType, - final Consumer> applyEffects + final BlockInteraction destructionType ) { super(level, entity, damageSource, behavior, center, power, createFire, destructionType); this.cause = entity; - this.impactPosition = center; - this.applyEffects = applyEffects; + this.dispatchPosition = center; + this.bounds = new AABB(center, center); + } + + public final Queue getExplosionsToSend() { + return this.explosionsToSend; } protected double getExplosionOffset() { - return (double) this.cause.getBbHeight() * 0.0625D; + return 0.0; } - protected abstract void beginExplosion(); + protected abstract int handleExplosion(); @Override - public final void explode() { + public final int explode() { this.createBlockCache(); - this.beginExplosion(); // search for blocks, impact entities, finalise if necessary + final int blocksDestroyed = this.handleExplosion(); this.clearBlockCache(); + return blocksDestroyed; } - protected final boolean requiresImpactEntities(final List blocks, final Vec3 center) { - if (this.impactPosition.distanceToSqr(center) > ENTITY_DISPATCH_DISTANCE) { - this.impactPosition = center; + protected final List collectBlocksAndImpactEntities(final boolean interactWithBlocks, final boolean dispatch) { + if (interactWithBlocks && this.gameEvents.add(BlockPos.containing(this.center))) { + this.level().gameEvent(this.source, GameEvent.EXPLODE, this.center); + } + + // Collect all the blocks to explode + final List blocksToExplode = interactWithBlocks + ? this.calculateExplodedPositions() + : List.of(); + + // Buffer explosions to reduce the amount of calculations and improve locality + final Vec3 center = this.center; + this.bounds = this.bounds.expand(center); + this.bufferedExplosions.add(center); + + // Dispatch the buffered explosions + if (dispatch || this.needToDispatchEntities(blocksToExplode, center)) { + this.locateAndImpactEntitiesInBounds(this.bounds, this.bufferedExplosions); + this.bounds = new AABB(center, center); + this.bufferedExplosions.clear(); + } + + return blocksToExplode; + } + + protected final boolean needToDispatchEntities(final List blocksToBlow, final Vec3 center) { + if (this.dispatchPosition.distanceToSqr(center) > ENTITY_DISPATCH_DISTANCE_SQR) { + this.dispatchPosition = center; + this.gameEvents.clear(); return true; } - return !blocks.isEmpty(); + return !blocksToBlow.isEmpty(); } - protected final boolean finalizeExplosionAndParticles(final List blocks) { + protected final int finalizeExplosionAndParticles(final List blocksToBlow, final boolean lastCycle) { this.wasCanceled = false; - final List explodedPositions = new ObjectArrayList<>(blocks); + final List explodedPositions = new ObjectArrayList<>(blocksToBlow); this.interactWithBlocks(explodedPositions); - if (!this.wasCanceled) { - this.applyEffects.accept(this); - this.getHitPlayers().clear(); + if (!this.wasCanceled && !lastCycle) { + // Packets are sent after the explosion + this.explosionsToSend.add(new ExplosionToSend(this.center, explodedPositions.size())); } - return !explodedPositions.isEmpty() && !this.wasCanceled; + return this.wasCanceled ? 0 : explodedPositions.size(); } - protected void postExplosion(final List foundBlocks, final boolean destroyedBlocks) { + protected void nextExplosion(final List foundBlocks, final boolean destroyedBlocks) { // Reuse the block cache between explosions. This can help a lot when searching for blocks and raytracing. // This is disabled by default as it's incompatible with plugins that modify blocks in the explosion event. if (this.level().sakuraConfig().cannons.explosion.reuseBlockCacheAcrossExplosions && !foundBlocks.isEmpty() && !destroyedBlocks) { @@ -188,7 +220,7 @@ public abstract class SpecialisedExplosion extends ServerExplo distance = (float) distance; } - if (distance != 0.0D) { + if (distance >= 1.0e-5 || distance != 0.0 && this.mechanicsTarget.before(MechanicVersion.v1_21_9)) { x /= distance; y /= distance; z /= distance; diff --git a/sakura-server/src/main/java/me/samsuik/sakura/explosion/TntExplosion.java b/sakura-server/src/main/java/me/samsuik/sakura/explosion/TntExplosion.java index 2efb18c..9b7d429 100644 --- a/sakura-server/src/main/java/me/samsuik/sakura/explosion/TntExplosion.java +++ b/sakura-server/src/main/java/me/samsuik/sakura/explosion/TntExplosion.java @@ -1,7 +1,6 @@ package me.samsuik.sakura.explosion; import ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; import me.samsuik.sakura.entity.EntityState; import me.samsuik.sakura.entity.merge.MergeLevel; import me.samsuik.sakura.entity.merge.MergeableEntity; @@ -13,13 +12,11 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.PrimedTnt; import net.minecraft.world.level.ExplosionDamageCalculator; -import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; import org.jspecify.annotations.NullMarked; import java.util.List; -import java.util.function.Consumer; @NullMarked public final class TntExplosion extends SpecialisedExplosion { @@ -27,8 +24,6 @@ public final class TntExplosion extends SpecialisedExplosion { private static final int FOUND_ALL_BLOCKS = ALL_DIRECTIONS + 12; private final Vec3 originalPosition; - private final List explosions = new ObjectArrayList<>(); - private AABB bounds; private int swinging = 0; private boolean moved = false; @@ -40,19 +35,17 @@ public final class TntExplosion extends SpecialisedExplosion { final Vec3 center, final float power, final boolean createFire, - final BlockInteraction destructionType, - final Consumer> applyEffects + final BlockInteraction destructionType ) { - super(level, tnt, damageSource, behavior, center, power, createFire, destructionType, applyEffects); + super(level, tnt, damageSource, behavior, center, power, createFire, destructionType); this.originalPosition = center; - this.bounds = new AABB(center, center); } @Override protected double getExplosionOffset() { return this.mechanicsTarget.before(MechanicVersion.v1_10) ? (double) 0.49f - : super.getExplosionOffset(); + : (double) this.cause.getBbHeight() * 0.0625D; } private void mergeEntitiesBeforeExploding() { @@ -89,41 +82,28 @@ public final class TntExplosion extends SpecialisedExplosion { } @Override - protected void beginExplosion() { + protected int handleExplosion() { + int blocksDestroyed = 0; for (int remaining = this.mergeAndGetExplosionPotential() - 1; remaining >= 0; --remaining) { final boolean lastCycle = remaining == 0; - final List toBlow = this.midExplosion(lastCycle); // search for blocks and impact entities - final boolean destroyedBlocks = this.finalizeExplosionAndParticles(toBlow); // call events, break blocks and send particles + final List blocksToBlow = this.collectBlocksAndImpactEntities(this.swinging < FOUND_ALL_BLOCKS, lastCycle); + blocksDestroyed = this.finalizeExplosionAndParticles(blocksToBlow, lastCycle); if (!lastCycle) { + // The source velocity has to be calculated before nextExplosion as it clears the blockCache final EntityState entityState = this.nextSourceVelocity(); - this.postExplosion(toBlow, destroyedBlocks); + final boolean destroyedBlocks = blocksDestroyed > 0; + this.nextExplosion(blocksToBlow, destroyedBlocks); this.updateExplosionPosition(entityState, destroyedBlocks); } } - } - private List midExplosion(final boolean lastCycle) { - final List explodedPositions = this.swinging < FOUND_ALL_BLOCKS - ? this.calculateExplodedPositions() - : List.of(); - - final Vec3 center = this.center; - this.bounds = this.bounds.expand(center); - this.explosions.add(center); - - if (lastCycle || this.requiresImpactEntities(explodedPositions, center)) { - this.locateAndImpactEntitiesInBounds(this.bounds, this.explosions); - this.bounds = new AABB(center, center); - this.explosions.clear(); - } - - return explodedPositions; + return blocksDestroyed; } @Override - protected void postExplosion(final List foundBlocks, final boolean destroyedBlocks) { - super.postExplosion(foundBlocks, destroyedBlocks); + protected void nextExplosion(final List foundBlocks, final boolean destroyedBlocks) { + super.nextExplosion(foundBlocks, destroyedBlocks); if (this.swinging >= ALL_DIRECTIONS) { // Increment "swinging" if no blocks have been found, and it has swung in every direction. // This is used to skip expensive exploded block calculations. diff --git a/sakura-server/src/main/java/me/samsuik/sakura/mechanics/EntityBehaviour.java b/sakura-server/src/main/java/me/samsuik/sakura/mechanics/EntityBehaviour.java index 0330969..8bfb3da 100644 --- a/sakura-server/src/main/java/me/samsuik/sakura/mechanics/EntityBehaviour.java +++ b/sakura-server/src/main/java/me/samsuik/sakura/mechanics/EntityBehaviour.java @@ -23,7 +23,7 @@ public final class EntityBehaviour { final Vec3 newEntityPosition; if (mechanicsTarget.is(MechanicVersion.v1_21_5)) { newEntityPosition = manglePosition(position, relativeMovement); - entity.addMovementThisTick(new Entity.Movement(position, newPosition, true)); + entity.addMovementThisTick(new Entity.Movement(position, newPosition, relativeMovement)); } else { newEntityPosition = newPosition; } @@ -33,7 +33,7 @@ public final class EntityBehaviour { private static Vec3 manglePosition(final Vec3 position, final Vec3 relativeMovement) { Vec3 newPosition = position; - for (final Direction.Axis axis : Entity.axisStepOrder(relativeMovement)) { + for (final Direction.Axis axis : Direction.axisStepOrder(relativeMovement)) { final double movement = relativeMovement.get(axis); if (movement != 0.0) { newPosition = newPosition.relative(axis.getPositive(), movement); diff --git a/sakura-server/src/main/java/me/samsuik/sakura/player/combat/LegacyDamageMapping.java b/sakura-server/src/main/java/me/samsuik/sakura/player/combat/LegacyDamageMapping.java index 7de243b..8deb6e8 100644 --- a/sakura-server/src/main/java/me/samsuik/sakura/player/combat/LegacyDamageMapping.java +++ b/sakura-server/src/main/java/me/samsuik/sakura/player/combat/LegacyDamageMapping.java @@ -36,6 +36,7 @@ public final class LegacyDamageMapping { LEGACY_ITEM_DAMAGE_MAP.put(Items.WOODEN_AXE, 3.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.GOLDEN_AXE, 3.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.STONE_AXE, 4.0); + LEGACY_ITEM_DAMAGE_MAP.put(Items.COPPER_AXE, 4.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.IRON_AXE, 5.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.DIAMOND_AXE, 6.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.NETHERITE_AXE, 7.0); diff --git a/sakura-server/src/main/java/me/samsuik/sakura/player/item/DataComponentHelper.java b/sakura-server/src/main/java/me/samsuik/sakura/player/item/DataComponentHelper.java index 3317262..52cf6ba 100644 --- a/sakura-server/src/main/java/me/samsuik/sakura/player/item/DataComponentHelper.java +++ b/sakura-server/src/main/java/me/samsuik/sakura/player/item/DataComponentHelper.java @@ -11,7 +11,13 @@ import org.jspecify.annotations.NullMarked; public final class DataComponentHelper { public static int bucketMaxStackSize() { final GlobalConfiguration config = GlobalConfiguration.get(); - return config == null || !config.players.bucketStackSize.isDefined() ? -1 : config.players.bucketStackSize.intValue(); + return config != null && config.players.bucketStackSize.isDefined() + ? config.players.bucketStackSize.intValue() + : -1; + } + + public static DataComponentMap updateBucketMaxStackSize(final DataComponentMap components) { + return copyComponentsAndModifyMaxStackSize(components, bucketMaxStackSize()); } @SuppressWarnings("OptionalAssignedToNull") @@ -20,7 +26,7 @@ public final class DataComponentHelper { } public static DataComponentMap copyComponentsAndModifyMaxStackSize(final DataComponentMap componentMap, final int maxItemSize) { - if (maxItemSize > 0 && maxItemSize <= 99) { + if (maxItemSize > 1 && maxItemSize <= 99) { return DataComponentMap.builder() .addAll(componentMap) .set(DataComponents.MAX_STACK_SIZE, maxItemSize) diff --git a/sakura-server/src/main/java/me/samsuik/sakura/player/item/MilkBucketItem.java b/sakura-server/src/main/java/me/samsuik/sakura/player/item/MilkBucketItem.java index f968345..f781268 100644 --- a/sakura-server/src/main/java/me/samsuik/sakura/player/item/MilkBucketItem.java +++ b/sakura-server/src/main/java/me/samsuik/sakura/player/item/MilkBucketItem.java @@ -1,9 +1,10 @@ package me.samsuik.sakura.player.item; import me.samsuik.sakura.configuration.GlobalConfiguration; +import net.minecraft.core.component.DataComponentMap; import net.minecraft.core.component.DataComponents; +import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; import org.jspecify.annotations.NullMarked; @NullMarked @@ -13,10 +14,17 @@ public final class MilkBucketItem extends Item { } @Override - public void verifyComponentsAfterLoad(final ItemStack stack) { - final int maxStackSize = DataComponentHelper.bucketMaxStackSize(); - if (maxStackSize > 0 && maxStackSize < 100 && stackableMilkBuckets()) { - stack.set(DataComponents.MAX_STACK_SIZE, maxStackSize); + public DataComponentMap components() { + final DataComponentMap components = super.components(); + return stackableMilkBuckets() + ? DataComponentHelper.updateBucketMaxStackSize(components) + : components; + } + + @Override + public void modifyComponentsSentToClient(final PatchedDataComponentMap components) { + if (stackableMilkBuckets()) { + components.set(DataComponents.MAX_STACK_SIZE, DataComponentHelper.bucketMaxStackSize()); } } diff --git a/sakura-server/src/main/java/me/samsuik/sakura/player/item/StackableBucketItem.java b/sakura-server/src/main/java/me/samsuik/sakura/player/item/StackableBucketItem.java index c26ff1d..ffc407a 100644 --- a/sakura-server/src/main/java/me/samsuik/sakura/player/item/StackableBucketItem.java +++ b/sakura-server/src/main/java/me/samsuik/sakura/player/item/StackableBucketItem.java @@ -1,8 +1,9 @@ package me.samsuik.sakura.player.item; +import net.minecraft.core.component.DataComponentMap; import net.minecraft.core.component.DataComponents; +import net.minecraft.core.component.PatchedDataComponentMap; import net.minecraft.world.item.BucketItem; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.material.Fluid; import org.jspecify.annotations.NullMarked; @@ -13,11 +14,15 @@ public final class StackableBucketItem extends BucketItem { } @Override - public void verifyComponentsAfterLoad(final ItemStack stack) { - // It's also possible to override the components method and modify the stack size through the DataComponentHelper + public DataComponentMap components() { + return DataComponentHelper.updateBucketMaxStackSize(super.components()); + } + + @Override + public void modifyComponentsSentToClient(final PatchedDataComponentMap components) { final int maxStackSize = DataComponentHelper.bucketMaxStackSize(); - if (maxStackSize > 0 && maxStackSize < 100) { - stack.set(DataComponents.MAX_STACK_SIZE, maxStackSize); + if (maxStackSize > 1 && maxStackSize <= 99) { + components.set(DataComponents.MAX_STACK_SIZE, maxStackSize); } } } diff --git a/scripts/apatch.sh b/scripts/apatch.sh index f56771d..9156cb7 100755 --- a/scripts/apatch.sh +++ b/scripts/apatch.sh @@ -40,7 +40,7 @@ fi for i in $(find . -name \*.rej); do base=$(echo "$i" | sed 's/.rej//g') if [ -f "$i" ]; then - sed -e 's/^diff a\/\(.*\) b\/\(.*\)[[:space:]].*rejected.*$/--- \1\n+++ \2/' -i $i && wiggle -v -l --replace "$base" "$i" + sed -e 's/^diff a\/\(.*\) b\/\(.*\)[[:space:]].*rejected.*$/--- \1\n+++ \2/' -i '' $i && wiggle -v -l --replace "$base" "$i" rm "$base.porig" "$i" else echo "No such file: $base" diff --git a/scripts/upstream.sh b/scripts/upstream.sh index 8981a0f..9defa08 100755 --- a/scripts/upstream.sh +++ b/scripts/upstream.sh @@ -15,7 +15,7 @@ fi echo "Updating paper: $oldHash -> $newHash" -sed -i "s/$oldHash/$newHash/g" gradle.properties +sed -i '' "s/$oldHash/$newHash/g" gradle.properties git add gradle.properties ./gradlew cleanCache