diff --git a/patches/api/0010-Add-redstone-implementation-API.patch b/patches/api/0010-Add-redstone-implementation-API.patch index 79bc52e..a56fbaa 100644 --- a/patches/api/0010-Add-redstone-implementation-API.patch +++ b/patches/api/0010-Add-redstone-implementation-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add redstone implementation API diff --git a/src/main/java/me/samsuik/sakura/local/LocalValueKey.java b/src/main/java/me/samsuik/sakura/local/LocalValueKey.java -index 3beb5830d623e72a3f4dec63aedc8b69a6396bf0..1a725c1f349b9b8f86c118e579004d7974f016fd 100644 +index 4735e5d8dcea4835061b5cada9d601794efdf390..4d8c83f48d8ef739a00ea1b8a17ac8cdf10ac396 100644 --- a/src/main/java/me/samsuik/sakura/local/LocalValueKey.java +++ b/src/main/java/me/samsuik/sakura/local/LocalValueKey.java @@ -1,6 +1,7 @@ @@ -16,13 +16,17 @@ index 3beb5830d623e72a3f4dec63aedc8b69a6396bf0..1a725c1f349b9b8f86c118e579004d79 import org.bukkit.Material; import org.bukkit.NamespacedKey; -@@ -20,6 +21,10 @@ public record LocalValueKey(NamespacedKey key, Supplier defaultSupplier) { +@@ -20,6 +21,14 @@ public record LocalValueKey(NamespacedKey key, Supplier defaultSupplier) { new NamespacedKey("sakura", "durable-materials"), HashMap::new ); + public static final LocalValueKey REDSTONE_IMPLEMENTATION = new LocalValueKey<>( + new NamespacedKey("sakura", "redstone-implementation"), () -> RedstoneImplementation.VANILLA + ); ++ ++ public static final LocalValueKey CONSISTENT_EXPLOSION_RADIUS = new LocalValueKey<>( ++ new NamespacedKey("saskua", "consistent-radius"), () -> false ++ ); + @Override public boolean equals(Object o) { diff --git a/patches/server/0004-Local-Config-and-Value-Storage-API.patch b/patches/server/0004-Local-Config-and-Value-Storage-API.patch index 3b657b8..4669cb9 100644 --- a/patches/server/0004-Local-Config-and-Value-Storage-API.patch +++ b/patches/server/0004-Local-Config-and-Value-Storage-API.patch @@ -155,10 +155,10 @@ index 0000000000000000000000000000000000000000..a3a09b8d58589883c7c465597bc64502 +} diff --git a/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..f0037f98e93fd1f0dea9c224ba402ebcacf9b21f +index 0000000000000000000000000000000000000000..dd61d4e8811ffb1e8a842df1db6ac6ce5a8258c6 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java -@@ -0,0 +1,59 @@ +@@ -0,0 +1,68 @@ +package me.samsuik.sakura.local.config; + +import io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation; @@ -180,6 +180,7 @@ index 0000000000000000000000000000000000000000..f0037f98e93fd1f0dea9c224ba402ebc + public Map durableMaterials; + public PhysicsVersion physicsVersion; + public RedstoneImplementation redstoneImplementation; ++ public boolean consistentRadius; + + LocalValueConfig(Expiry expiry) { + this.expiry = expiry; @@ -194,6 +195,9 @@ index 0000000000000000000000000000000000000000..f0037f98e93fd1f0dea9c224ba402ebc + + // redstone implementation + this.redstoneImplementation = level.paperConfig().misc.redstoneImplementation; ++ ++ // consistent explosion radius ++ this.consistentRadius = level.sakuraConfig().cannons.explosion.consistentRadius; + } + + void load(LocalValueStorage storage) { @@ -211,6 +215,11 @@ index 0000000000000000000000000000000000000000..f0037f98e93fd1f0dea9c224ba402ebc + if (storage.exists(LocalValueKey.REDSTONE_IMPLEMENTATION)) { + this.redstoneImplementation = RedstoneImplementation.values()[storage.value(LocalValueKey.REDSTONE_IMPLEMENTATION).ordinal()]; + } ++ ++ // consistent explosion radius ++ if (storage.exists(LocalValueKey.CONSISTENT_EXPLOSION_RADIUS)) { ++ this.consistentRadius = storage.value(LocalValueKey.CONSISTENT_EXPLOSION_RADIUS); ++ } + } + + Expiry expiry() { diff --git a/patches/server/0038-Consistent-Explosion-Radius.patch b/patches/server/0038-Consistent-Explosion-Radius.patch index a8c58ec..433ed5f 100644 --- a/patches/server/0038-Consistent-Explosion-Radius.patch +++ b/patches/server/0038-Consistent-Explosion-Radius.patch @@ -5,15 +5,31 @@ Subject: [PATCH] Consistent Explosion Radius diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index c2edd4021fe2bdf96f58f6d402b767f911801cf6..134aff1eccae14a1ebf654222d7016ebf0f07a8f 100644 +index 9d9fe71897839d5ee7f3ec7467616021a8791a29..f7e01cb367b5b75f1f267d727b539066845d6e14 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -585,7 +585,7 @@ public class Explosion { +@@ -75,6 +75,7 @@ public class Explosion { + public boolean wasCanceled = false; + public float yield; + // CraftBukkit end ++ private final boolean consistentRadius; // Sakura - consistent explosion radius + + public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) { + return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source)); +@@ -112,6 +113,7 @@ public class Explosion { + this.largeExplosionParticles = emitterParticle; + this.explosionSound = soundEvent; + this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit ++ this.consistentRadius = world.localConfig().config(BlockPos.containing(x, y, z)).consistentRadius; // Sakura - consistent explosion radius + } + + // Sakura start - optimise paper explosions +@@ -585,7 +587,7 @@ public class Explosion { double d2 = CACHED_RAYS[ray + 2]; ray += 3; // Paper end - optimise explosions - float f = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F); -+ float f = this.radius * (0.7F + (this.level.sakuraConfig().cannons.explosion.consistentRadius ? 0.7F : this.level.random.nextFloat()) * 0.6F); // Sakura - consistent explosion radius ++ float f = this.radius * (0.7F + (this.consistentRadius ? 0.7F : this.level.random.nextFloat()) * 0.6F); // Sakura - consistent explosion radius double d4 = this.x; double d5 = this.y; double d6 = this.z; diff --git a/patches/server/0041-Configure-cannon-physics-by-version.patch b/patches/server/0041-Configure-cannon-physics-by-version.patch index 0422e96..33050bc 100644 --- a/patches/server/0041-Configure-cannon-physics-by-version.patch +++ b/patches/server/0041-Configure-cannon-physics-by-version.patch @@ -255,7 +255,7 @@ index b9d91310268088b43c432e7fb4d669cc9ddae527..f6a4c34a47d4ca46681d694798f61959 if (this.level().hasChunksAt(blockposition, blockposition1)) { BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -index d22c1357006d2785ff2a0e9465a214cf5a262cb1..b0a6d829a9790744a030cd4b230b71a752e546d0 100644 +index 779a6686d491a8c4c95d5b8087fc55ee2f184f38..c01ed76846ad9ab893b0a7cdeadc077ccd829f1a 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -90,6 +90,8 @@ public class FallingBlockEntity extends Entity { @@ -391,7 +391,7 @@ index d22c1357006d2785ff2a0e9465a214cf5a262cb1..b0a6d829a9790744a030cd4b230b71a7 } diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 30443bc74abbe0a557b5d9d9bae0eb48ef1dd7d3..f775f881b6d89670b3e3900f3023918d6ababe01 100644 +index df2a37e57012333a618937e61cb5a99c3ef4a0f9..62d40333c42f673479db5e6312343161aacf7078 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java @@ -58,6 +58,13 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -481,26 +481,26 @@ index 30443bc74abbe0a557b5d9d9bae0eb48ef1dd7d3..f775f881b6d89670b3e3900f3023918d // Paper end - Option to prevent TNT from moving in water } diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 3b5c6aa1e211bf8f16f0b8d11c4169b2978f52dc..383639ee1e25c36f656bf3b3908b1dac11319695 100644 +index f7e01cb367b5b75f1f267d727b539066845d6e14..c5db31bd92a441eccd0f4c5ea1b8c7f17a00de65 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -75,6 +75,7 @@ public class Explosion { - public boolean wasCanceled = false; +@@ -76,6 +76,7 @@ public class Explosion { public float yield; // CraftBukkit end + private final boolean consistentRadius; // Sakura - consistent explosion radius + protected final me.samsuik.sakura.physics.PhysicsVersion physics; // Sakura - physics version api public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) { return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source)); -@@ -112,6 +113,7 @@ public class Explosion { - this.largeExplosionParticles = emitterParticle; +@@ -114,6 +115,7 @@ public class Explosion { this.explosionSound = soundEvent; this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit + this.consistentRadius = world.localConfig().config(BlockPos.containing(x, y, z)).consistentRadius; // Sakura - consistent explosion radius + this.physics = entity != null ? entity.physics() : world.localConfig().config(BlockPos.containing(x, y, z)).physicsVersion; // Sakura - physics version api } // Sakura start - optimise paper explosions -@@ -504,8 +506,12 @@ public class Explosion { +@@ -506,8 +508,12 @@ public class Explosion { final float density = entity.level().densityCache.getKnownDensity(vec3d1); 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; @@ -514,7 +514,7 @@ index 3b5c6aa1e211bf8f16f0b8d11c4169b2978f52dc..383639ee1e25c36f656bf3b3908b1dac } if (hitResult == HitResult.Type.MISS) { // Sakura end - replace density cache -@@ -610,6 +616,14 @@ public class Explosion { +@@ -612,6 +618,14 @@ public class Explosion { } if (cachedBlock.outOfWorld) { @@ -529,7 +529,7 @@ index 3b5c6aa1e211bf8f16f0b8d11c4169b2978f52dc..383639ee1e25c36f656bf3b3908b1dac break; } -@@ -715,9 +729,15 @@ public class Explosion { +@@ -717,9 +731,15 @@ public class Explosion { if (d7 <= 1.0D) { double d8 = entity.getX() - this.x; @@ -546,7 +546,7 @@ index 3b5c6aa1e211bf8f16f0b8d11c4169b2978f52dc..383639ee1e25c36f656bf3b3908b1dac if (d11 != 0.0D) { d8 /= d11; -@@ -1056,7 +1076,7 @@ public class Explosion { +@@ -1058,7 +1078,7 @@ public class Explosion { // Sakura start - replace density cache float blockDensity = this.level.densityCache.getDensity(vec3d, entity); if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { @@ -555,7 +555,7 @@ index 3b5c6aa1e211bf8f16f0b8d11c4169b2978f52dc..383639ee1e25c36f656bf3b3908b1dac this.level.densityCache.putDensity(vec3d, entity, blockDensity); // Sakura end - replace density cache } -@@ -1064,6 +1084,17 @@ public class Explosion { +@@ -1066,6 +1086,17 @@ public class Explosion { return blockDensity; } diff --git a/patches/server/0045-Allow-explosions-to-destroy-lava.patch b/patches/server/0045-Allow-explosions-to-destroy-lava.patch index 0ab7986..ef8b19f 100644 --- a/patches/server/0045-Allow-explosions-to-destroy-lava.patch +++ b/patches/server/0045-Allow-explosions-to-destroy-lava.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Allow explosions to destroy lava diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 1315eaed58de523ee5e3289494f8d240d2ebe224..d16c58568d3fe343c5c50af0bbb7e1574676caac 100644 +index c5db31bd92a441eccd0f4c5ea1b8c7f17a00de65..fd53dff917b65b94eceb5796fc80b1a490454cc2 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -287,7 +287,7 @@ public class Explosion { +@@ -289,7 +289,7 @@ public class Explosion { if (material != null && material.resistance() >= 0.0f && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) { return Optional.of(material.resistance()); // Sakura start - destroy water logged blocks diff --git a/patches/server/0057-Add-explosions-dropping-items-config.patch b/patches/server/0057-Add-explosions-dropping-items-config.patch index ff56f7d..a62a863 100644 --- a/patches/server/0057-Add-explosions-dropping-items-config.patch +++ b/patches/server/0057-Add-explosions-dropping-items-config.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add explosions dropping items config diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index d16c58568d3fe343c5c50af0bbb7e1574676caac..1cef34d0cc8747d136ba7050bfe5a9197426d802 100644 +index fd53dff917b65b94eceb5796fc80b1a490454cc2..a5ea2a84098e5cef7c82bfb437b6e630727a25c4 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -949,6 +949,11 @@ public class Explosion { +@@ -951,6 +951,11 @@ public class Explosion { this.level.densityCache.clear(-1); } // Sakura end - explosion density cache