-
-
Save codestripper/05b5b35f93a1522cdd6eb30043a9201c to your computer and use it in GitHub Desktop.
Mixin Issue with getting damage source player.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.minecraft.entity.Entity; | |
import net.minecraft.entity.EntityLivingBase; | |
import net.minecraft.entity.player.EntityPlayer; | |
import net.minecraft.util.DamageSource; | |
import net.minecraft.world.World; | |
import org.apache.logging.log4j.Logger; | |
import org.spongepowered.asm.mixin.Final; | |
import org.spongepowered.asm.mixin.Mixin; | |
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.callback.CallbackInfoReturnable; | |
@Mixin(EntityLivingBase.class) | |
public abstract class MixinEntityLivingBase extends Entity { | |
@Final | |
@Shadow | |
private static Logger LOGGER; | |
public MixinEntityLivingBase(World worldIn) { | |
super(worldIn); | |
} | |
@Inject(method = "attackEntityFrom", at = @At(value = "HEAD")) | |
private void onAttackEntityFrom(DamageSource source, float damageAmount, CallbackInfoReturnable<Boolean> cir) { | |
Entity entity = source.getTrueSource(); | |
if (entity instanceof EntityPlayer) { | |
EntityPlayer player = (EntityPlayer) entity; | |
LOGGER.info(player.getLastAttackedEntityTime()); | |
LOGGER.info(player.getCooledAttackStrength(0)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment