From d693e19340ad0fb24e3e4ae73ffd29ca78c8ed95 Mon Sep 17 00:00:00 2001 From: 2No2Name <2No2Name@web.de> Date: Sun, 23 Jun 2024 16:07:58 +0200 Subject: [PATCH 1/2] fix incompatibility with lithium explosion exposure optimization --- .../carpet/mixins/Explosion_scarpetEventMixin.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java b/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java index 12e9bf2b6..de6798008 100644 --- a/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java @@ -1,5 +1,6 @@ package carpet.mixins; +import com.llamalad7.mixinextras.sugar.Local; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.core.Holder; import net.minecraft.core.particles.ParticleOptions; @@ -9,7 +10,6 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.ArrayList; @@ -22,7 +22,6 @@ import net.minecraft.world.level.Explosion; import net.minecraft.world.level.ExplosionDamageCalculator; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; import static carpet.script.CarpetEventServer.Event.EXPLOSION_OUTCOME; @@ -41,8 +40,6 @@ public abstract class Explosion_scarpetEventMixin @Shadow /*@Nullable*/ public abstract /*@Nullable*/ LivingEntity getIndirectSourceEntity(); - @Shadow public static float getSeenPercent(Vec3 source, Entity entity) {return 0.0f;} - private List affectedEntities; @Inject(method = "(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/Holder;)V", @@ -55,17 +52,16 @@ private void onExplosionCreated(Level world, Entity entity, DamageSource damageS } } - @Redirect(method = "explode", at=@At( + @Inject(method = "explode", at=@At( value = "INVOKE", target = "Lnet/minecraft/world/level/Explosion;getSeenPercent(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/Entity;)F") ) - private float onExplosion(Vec3 source, Entity entity) + private void onExplosion(CallbackInfo ci, @Local Entity entity) { if (affectedEntities != null) { affectedEntities.add(entity); } - return getSeenPercent(source, entity); } @Inject(method = "finalizeExplosion", at = @At("HEAD")) From 5b35a0046ba19f9defc7c0ba3874a1d937a833c6 Mon Sep 17 00:00:00 2001 From: 2No2Name <50278648+2No2Name@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:20:57 +0000 Subject: [PATCH 2/2] Use ModifyArg instead of Inject with Local capture Apply code review by supersaiyansubtlety Co-authored-by: Will --- .../java/carpet/mixins/Explosion_scarpetEventMixin.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java b/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java index de6798008..3be79304e 100644 --- a/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java +++ b/src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java @@ -1,6 +1,6 @@ package carpet.mixins; -import com.llamalad7.mixinextras.sugar.Local; +import org.spongepowered.asm.mixin.injection.ModifyArg; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.core.Holder; import net.minecraft.core.particles.ParticleOptions; @@ -52,16 +52,17 @@ private void onExplosionCreated(Level world, Entity entity, DamageSource damageS } } - @Inject(method = "explode", at=@At( + @ModifyArg(method = "explode", at=@At( value = "INVOKE", target = "Lnet/minecraft/world/level/Explosion;getSeenPercent(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/Entity;)F") ) - private void onExplosion(CallbackInfo ci, @Local Entity entity) + private Entity onExplosion(Entity entity) { if (affectedEntities != null) { affectedEntities.add(entity); } + return entity; } @Inject(method = "finalizeExplosion", at = @At("HEAD"))