- 122
- 4
- 6
Всем здорова. Не особо понимаю почему не работает код. И как исправить эту проблему, не знаю. Пожалуйста подсобите кто знает.
Java:
@SubscribeEvent
public void onHurt(LivingHurtEvent e) {
DamageSource source = e.getSource();
Entity entity = e.getEntity();
if(entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
EnumHand hand = player.getActiveHand();
ItemStack stack = player.getHeldItem(hand);
if(player.getHeldItem(hand).getItem() == ItemsInit.AXE && player.isHandActive() && stack.getItemUseAction() == EnumAction.BLOCK) {
if(entity instanceof EntityLivingBase) {
EntityLivingBase entityAttacker = (EntityLivingBase) e.getSource().getTrueSource();
EnumHand hand_ = entityAttacker.getActiveHand();
if(entityAttacker.getHeldItem(hand_).getItem() == ItemsInit.SWORD) {
if (!entity.world.isRemote) {
entityAttacker.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 20 * 30, 0, false, false));
player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 20 * 30, 0, false, false));
entityAttacker.knockBack(entityAttacker, 2.5f, -entityAttacker.motionX, -entityAttacker.motionZ);
player.knockBack(player, 2.5f, player.motionX, player.motionZ); //Вот эта часть
if (entity.world instanceof WorldServer)
((WorldServer) entity.world).spawnParticle(EnumParticleTypes.CRIT, player.posX, player.posY + 1 , player.posZ, 30, 0.7, 0.7, 0.7, 0.0001, new int[0]);
entity.motionX = 0;
entity.motionZ = 0;
entity.onGround = false;
}
}
}
}
}
}
Последнее редактирование: