1
我正在制作一款增加装甲的mod,让你立于不败之地。到目前为止,我有这样的代码:取消伤害动画
@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'工作吗? (该事件发生在实体受到攻击时)。如果没有,另一种方法是以某种方式直接取消动画 - 动画在“EntityLivingBase.handleStatusUpdate”中触发(参见[wiki.vg关于实体的文章](http://wiki.vg/Entities#Living)) - I不知道伪装是否有钩,但这是潜在的领先。 – Pokechu22