我正在制作一个可以增加护甲的模组,让你立于不败之地。到目前为止我有这段代码:
@SubscribeEvent
public void onPlayerHurt(LivingHurtEvent event) {
if(event.getEntity() != null && event.getEntity() instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer) event.getEntity();
for(ItemStack stack : player.getArmorInventoryList()) {
if(stack != null && stack.getItem() instanceof ItemUltimusArmor){
event.setCanceled(true);
}
}
}
}
这确实消除了我使用盔甲时的伤害,但我仍然得到噪音和动画。当穿着这件盔甲时,我希望能够没有那些东西。有什么办法可以做到这一点吗?
最佳答案
我明白了。我使用 LivingAttackEvent
来监听事件,实际上使用了与 LivingHurtEvent
相同的代码,并且它起作用了。感谢 Pokechu22 的建议!
关于java - 取消伤害动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40809090/