@Override @SideOnly(Side.CLIENT) public ModelBiped getArmorModel( EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { ModelBackBokken armorModel = null; if (itemStack != null) { if (itemStack.getItem() instanceof ItemArmourKatana) { int type = ((ItemArmor) itemStack.getItem()).armorType; if (type == 1) { armorModel = new ModelBackBokken(); DataWatcher dw = entityLiving.getDataWatcher(); armorModel.animationID = dw.getWatchableObjectString(20); armorModel.animationlastID = dw.getWatchableObjectString(26); armorModel.animationTick = dw.getWatchableObjectFloat(25); } } } if (entityLiving.getHeldItem() != null) { // armorModel.blade.isHidden = true; // armorModel.blade.isHidden = false; armorModel.handle.isHidden = entityLiving.getHeldItem().getItem() == NarutoItems.Katana; } else { // armorModel.blade.isHidden = false; armorModel.handle.isHidden = false; } if (armorModel != null) { armorModel.bipedBody.showModel = armorSlot == 1; armorModel.isSneak = entityLiving.isSneaking(); armorModel.isRiding = entityLiving.isRiding(); armorModel.isChild = entityLiving.isChild(); armorModel.heldItemRight = entityLiving.getEquipmentInSlot(0) != null ? 1 : 0; armorModel.isSprinting = entityLiving.isSprinting(); if (entityLiving instanceof EntityPlayer) { EntityPlayer entityPlayer = (EntityPlayer) entityLiving; if (itemStack != null && entityPlayer.getItemInUseCount() > 0) { EnumAction enumaction = itemStack.getItemUseAction(); if (enumaction == EnumAction.block) { armorModel.heldItemRight = 3; } else if (enumaction == EnumAction.bow) { armorModel.aimedBow = true; } else if (enumaction == NarutoItems.Throw) { if (FMLClientHandler.instance().getClient().thePlayer == entityPlayer) { armorModel.isClientThrowing = true; } else { armorModel.isThrowing = true; } } } } } return armorModel; }
@SubscribeEvent public void HandleEnchant(LivingAttackEvent fEvent) { if (fEvent.source.damageType != "player" && fEvent.source.damageType != "mob") return; if (!(fEvent.source.getSourceOfDamage() instanceof EntityLivingBase)) return; EntityLivingBase attacker = (EntityLivingBase) fEvent.source.getSourceOfDamage(); if (attacker == null) return; ItemStack dmgSource = ((EntityLivingBase) fEvent.source.getSourceOfDamage()).getHeldItem(); if (dmgSource == null) return; if (EnchantmentHelper.getEnchantmentLevel(effectId, dmgSource) <= 0) return; // We have a cleaving level, let's figure out our damage value. float splashDamage = fEvent.ammount * (EnchantmentHelper.getEnchantmentLevel(effectId, dmgSource) * 0.25F); // Next, find our entities to hit. AxisAlignedBB boundBox = AxisAlignedBB.getBoundingBox( attacker.posX - 5, attacker.posY - 5, attacker.posZ - 5, attacker.posX + 5, attacker.posY + 5, attacker.posZ + 5); @SuppressWarnings("unchecked") ArrayList<Entity> targetEntities = new ArrayList<Entity>( attacker.worldObj.getEntitiesWithinAABBExcludingEntity(fEvent.entity, boundBox)); // Let's remove all the entries that aren't within range of our attacker ListIterator<Entity> itr = targetEntities.listIterator(); while (itr.hasNext()) { Entity target = itr.next(); if (!(target instanceof EntityLivingBase)) continue; if (target == attacker) continue; if (target.getDistanceToEntity(attacker) > 3.5F) continue; Vec3 attackerCheck = Vec3.createVectorHelper( target.posX - attacker.posX, target.posY - attacker.posY, target.posZ - attacker.posZ); double angle = Math.toDegrees(Math.acos(attackerCheck.normalize().dotProduct(attacker.getLookVec()))); if (angle < 60.0D) { // This is within our arc, let's deal our damage. DamageSource source = null; if (attacker instanceof EntityPlayer) source = new EntityDamageSource("player", attacker); if (attacker instanceof EntityMob) source = new EntityDamageSource("mob", attacker); if (source != null) { target.attackEntityFrom(DamageSource.generic, splashDamage); } if (attacker instanceof EntityPlayer) { // Apply knockback int modKnockback = 1; modKnockback += EnchantmentHelper.getKnockbackModifier(attacker, (EntityLivingBase) target); if (attacker.isSprinting()) modKnockback++; if (modKnockback > 0) target.addVelocity( (double) (-MathHelper.sin(attacker.rotationYaw * (float) Math.PI / 180.0F) * (float) modKnockback * 0.5F), 0.1D, (double) (MathHelper.cos(attacker.rotationYaw * (float) Math.PI / 180.0F) * (float) modKnockback * 0.5F)); } } } // Stop the player sprinting attacker.setSprinting(false); }