From be2aa6f947f8bcfd01626daca75df5b4fbedd0e6 Mon Sep 17 00:00:00 2001 From: Samsuik <40902469+Samsuik@users.noreply.github.com> Date: Thu, 23 Nov 2023 15:52:05 +0000 Subject: [PATCH] Fix tnt not being affected properly --- .../0004-Sakura-Configuration-Files.patch | 49 +------------------ ...-Configure-cannon-physics-by-version.patch | 32 ++++++------ 2 files changed, 19 insertions(+), 62 deletions(-) diff --git a/patches/server/0004-Sakura-Configuration-Files.patch b/patches/server/0004-Sakura-Configuration-Files.patch index 949a031..d61e71d 100644 --- a/patches/server/0004-Sakura-Configuration-Files.patch +++ b/patches/server/0004-Sakura-Configuration-Files.patch @@ -371,10 +371,10 @@ index 0000000000000000000000000000000000000000..911c81920bda503577ed63c9ea4505cc +} diff --git a/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..41d471089530d12119a93d76ff1a2fb40a06cdb6 +index 0000000000000000000000000000000000000000..5fc23a0b579d7cbe03baf5324bef887ad3dcaa25 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java -@@ -0,0 +1,233 @@ +@@ -0,0 +1,231 @@ +package me.samsuik.sakura.configuration; + +import com.google.common.collect.Table; @@ -400,7 +400,6 @@ index 0000000000000000000000000000000000000000..41d471089530d12119a93d76ff1a2fb4 +import it.unimi.dsi.fastutil.objects.Reference2LongMap; +import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; +import me.samsuik.sakura.configuration.mapping.InnerClassFieldDiscoverer; -+import me.samsuik.sakura.configuration.serializer.PhysicsVersionSerializer; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; @@ -539,7 +538,6 @@ index 0000000000000000000000000000000000000000..41d471089530d12119a93d76ff1a2fb4 + .register(Duration.SERIALIZER) + .register(DurationOrDisabled.SERIALIZER) + .register(NbtPathSerializer.SERIALIZER) -+ .register(new PhysicsVersionSerializer()) + .register(new RegistryValueSerializer<>(new TypeToken>() {}, access, Registries.ENTITY_TYPE, true)) + .register(new RegistryValueSerializer<>(Item.class, access, Registries.ITEM, true)) + .register(new RegistryValueSerializer<>(Block.class, access, Registries.BLOCK, true)) @@ -817,49 +815,6 @@ index 0000000000000000000000000000000000000000..96080117b5ac9dea6b9eeb7489dc0c87 + return new InnerClassFieldDiscoverer(Collections.emptyMap()); + } +} -diff --git a/src/main/java/me/samsuik/sakura/configuration/serializer/PhysicsVersionSerializer.java b/src/main/java/me/samsuik/sakura/configuration/serializer/PhysicsVersionSerializer.java -new file mode 100644 -index 0000000000000000000000000000000000000000..1368db166f5720f52ebab7a180ee7a04b7e761fa ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/configuration/serializer/PhysicsVersionSerializer.java -@@ -0,0 +1,37 @@ -+package me.samsuik.sakura.configuration.serializer; -+ -+import me.samsuik.sakura.physics.PhysicsVersion; -+import org.spongepowered.configurate.serialize.ScalarSerializer; -+import org.spongepowered.configurate.serialize.SerializationException; -+ -+import java.lang.reflect.Type; -+import java.util.Locale; -+import java.util.function.Predicate; -+ -+public final class PhysicsVersionSerializer extends ScalarSerializer { -+ -+ public PhysicsVersionSerializer() { -+ super(PhysicsVersion.class); -+ } -+ -+ @Override -+ public PhysicsVersion deserialize(Type type, Object obj) throws SerializationException { -+ if (obj instanceof String string) { -+ PhysicsVersion version = PhysicsVersion.of(string); -+ -+ if (version == null) { -+ throw new SerializationException("%s (%s) unsupported version".formatted(obj, type)); -+ } -+ -+ return version; -+ } else { -+ throw new SerializationException("%s (%s) is not a string".formatted(obj, type)); -+ } -+ } -+ -+ @Override -+ protected Object serialize(PhysicsVersion item, Predicate> typeSupported) { -+ return item.getFriendlyName().toLowerCase(Locale.ROOT); -+ } -+ -+} diff --git a/src/main/java/me/samsuik/sakura/explosion/durable/DurableMaterial.java b/src/main/java/me/samsuik/sakura/explosion/durable/DurableMaterial.java new file mode 100644 index 0000000000000000000000000000000000000000..4024f9738e039ffffd560a07a2210f758879d3c0 diff --git a/patches/server/0040-Configure-cannon-physics-by-version.patch b/patches/server/0040-Configure-cannon-physics-by-version.patch index e9ae4ba..bbc149d 100644 --- a/patches/server/0040-Configure-cannon-physics-by-version.patch +++ b/patches/server/0040-Configure-cannon-physics-by-version.patch @@ -217,7 +217,7 @@ index 50259042ebafe520342bdb1a4b7e6b9138b8acbd..adf8be12b754c3d9b16ef4a7c675dd2c 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 bf52aafe542ca735181e461d1f9cbc39b8d88220..add0f223ca64daaf1c117a5d6885b9268f62e08a 100644 +index bf52aafe542ca735181e461d1f9cbc39b8d88220..80168d32a95bd960e781751fcf05ff591276e991 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -89,6 +89,8 @@ public class FallingBlockEntity extends Entity { @@ -242,10 +242,14 @@ index bf52aafe542ca735181e461d1f9cbc39b8d88220..add0f223ca64daaf1c117a5d6885b926 world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit return entityfallingblock; } -@@ -191,6 +197,36 @@ public class FallingBlockEntity extends Entity { - return heightParity ? getY() : super.getEyeY(); - } - // Sakura end +@@ -188,7 +194,37 @@ public class FallingBlockEntity extends Entity { + // Sakura start + @Override + public final double getEyeY() { +- return heightParity ? getY() : super.getEyeY(); ++ return heightParity ? this.getY() : super.getEyeY(); ++ } ++ // Sakura end + // Sakura start - physics version api + @Override + public double distanceToSqr(Vec3 vector) { @@ -274,11 +278,9 @@ index bf52aafe542ca735181e461d1f9cbc39b8d88220..add0f223ca64daaf1c117a5d6885b926 + // Why was this special cased for sand in the first place? + private static boolean isInAir(BlockState state) { + return state.is(Blocks.FIRE) || state.is(Blocks.AIR) || !state.getFluidState().isEmpty() || state.is(Blocks.WATER) || state.is(Blocks.LAVA); -+ } -+ // Sakura end + } + // Sakura end - @Override - public void tick() { @@ -204,9 +240,16 @@ public class FallingBlockEntity extends Entity { } else { Block block = this.blockState.getBlock(); @@ -346,7 +348,7 @@ index bf52aafe542ca735181e461d1f9cbc39b8d88220..add0f223ca64daaf1c117a5d6885b926 } 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 f25b15949f100b01e44a23832bc900d84f6cf1f1..139df4488e00fc71db6a54c4fabca775034ba8d0 100644 +index f25b15949f100b01e44a23832bc900d84f6cf1f1..e58ba1a6f0d17a75fa50dc01ff11cc72872f8714 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java @@ -52,6 +52,13 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -370,7 +372,7 @@ index f25b15949f100b01e44a23832bc900d84f6cf1f1..139df4488e00fc71db6a54c4fabca775 + // Sakura start - physics version api + @Override + public double getEyeY() { -+ return this.physics.isLegacy() ? super.getEyeY() : 0.0; ++ return this.physics.isLegacy() ? super.getEyeY() : this.getY(); + } + + @Override @@ -413,7 +415,7 @@ index f25b15949f100b01e44a23832bc900d84f6cf1f1..139df4488e00fc71db6a54c4fabca775 this.setFuse(i); - if (i <= 0) { -+ if ((this.physics.before(1_9_0) ? i < 0 : i <= 0)) { // Sakura - physics version api ++ if (this.physics.before(1_9_0) ? (i < 0) : (i <= 0)) { // Sakura - physics version api // 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.respawn(); // Sakura @@ -439,7 +441,7 @@ index f25b15949f100b01e44a23832bc900d84f6cf1f1..139df4488e00fc71db6a54c4fabca775 // Paper end } diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 6f1f5a03441e156b9c2cfa2c25db0aef6a7db66c..b0c90958d747e5b97acd9101764065f19f8ee793 100644 +index 3dc6bd54890bc1fa0f2a3e76f9620a2bff3c1aef..22a06d109c647629e9eeb6847cc8dadfd4d72652 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java @@ -69,6 +69,7 @@ public class Explosion { @@ -466,7 +468,7 @@ index 6f1f5a03441e156b9c2cfa2c25db0aef6a7db66c..b0c90958d747e5b97acd9101764065f1 if (data != null && data.isExpandable() && data.has(vec3d1)) { - i += (int) data.density(); - } else if (entity.level().clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() == HitResult.Type.MISS) { -+ hitResult = data.density() == 1.0 ? net.minecraft.world.phys.HitResult.Type.BLOCK : net.minecraft.world.phys.HitResult.Type.MISS; ++ hitResult = data.density() == 1.0 ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK; + } else { + if (this.physics.afterOrEqual(1_14_0)) { + hitResult = entity.level().rayTrace(vec3d1, source); @@ -515,7 +517,7 @@ index 6f1f5a03441e156b9c2cfa2c25db0aef6a7db66c..b0c90958d747e5b97acd9101764065f1 - float blockDensity = this.getSeenFraction(vec3d, entity, data, blockCache, blockPos); // Paper - optimise explosions; + // Sakura start - physics version api + final float blockDensity; -+ if (this.physics.before(1_16_0)) { ++ if (this.physics.afterOrEqual(1_16_0)) { + blockDensity = this.getSeenFraction(vec3d, entity, data, blockCache, blockPos); // Paper - optimise explosions; + } else { + blockDensity = this.getSeenPercent(vec3d, entity, data);