Skip to content

Commit

Permalink
fix: incompatability with fabric-carpet's scarpet explosion event. (#565
Browse files Browse the repository at this point in the history
)

Use `@WrapOperation` instead of `@Redirect` to avoid the mixin incompatibility
  • Loading branch information
wendavid552 authored Sep 13, 2024
1 parent 83df07e commit f4705b2
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package me.jellysquid.mods.lithium.mixin.world.explosions.cache_exposure;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import me.jellysquid.mods.lithium.common.world.ExplosionCache;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.explosion.Explosion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

/**
* Optimizations for Explosions: Remove duplicate {@link Explosion#getExposure(Vec3d, Entity)} calls.
Expand All @@ -24,8 +25,8 @@ public abstract class ExplosionMixin implements ExplosionCache {
this.cachedEntity = entity;
}

@Redirect(method = "collectBlocksAndDamageEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/explosion/Explosion;getExposure(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/entity/Entity;)F"))
private float returnCachedExposure(Vec3d source, Entity entity) {
return this.cachedEntity == entity ? this.cachedExposure : Explosion.getExposure(source, entity);
@WrapOperation(method = "collectBlocksAndDamageEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/explosion/Explosion;getExposure(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/entity/Entity;)F"))
private float returnCachedExposure(Vec3d source, Entity entity, Operation<Float> original) {
return this.cachedEntity == entity ? this.cachedExposure : original.call(source, entity);
}
}

0 comments on commit f4705b2

Please sign in to comment.