Workaround for shadowed fields from supermixins do not remap. ()

This commit is contained in:
i509VCB 2021-01-01 08:48:35 -06:00 committed by GitHub
parent cbe9176f9d
commit 49c073f9a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,6 +33,8 @@ import net.fabricmc.fabric.api.entity.event.v1.ServerEntityCombatEvents;
abstract class LivingEntityMixin extends EntityMixin {
@Inject(method = "onDeath", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;onKilledOther(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/LivingEntity;)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
private void onEntityKilledOther(DamageSource source, CallbackInfo ci, Entity attacker) {
ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.invoker().afterKilledOtherEntity(((ServerWorld) this.world), attacker, (LivingEntity) (Object) this);
// FIXME: Cannot use shadowed fields from supermixins - needs a fix so people can use fabric api in a dev environment even though this is fine in this repo and prod.
// A temporary fix is to just cast the mixin to LivingEntity and access the world field with a few ugly casts.
ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.invoker().afterKilledOtherEntity((ServerWorld) ((LivingEntity) (Object) this).world, attacker, (LivingEntity) (Object) this);
}
}