@Override public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { if (stack.getItemDamage() != 20) return; if (!(entity instanceof EntityPlayer) || (entity instanceof FakePlayer)) return; if (itemSlot < ((EntityPlayer)entity).inventory.getHotbarSize()) { List<EntityLiving> entities = entity.worldObj.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(entity.getPosition().add(-range, -range, -range), entity.getPosition().add(range, range, range))); for (EntityLiving ent : entities) { List<EntityAITaskEntry> entries = new ArrayList(ent.tasks.taskEntries); entries.addAll(new ArrayList(ent.targetTasks.taskEntries)); for (EntityAITaskEntry entry : entries) { if (entry.action instanceof EntityAIAttackRangedBow) { makeSkellyShootSlower((EntityAIAttackRangedBow)entry.action); } } if (ent instanceof EntityCreeper) ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper)ent, 60, this.FUSETIME); } } }
@SubscribeEvent public void onSkeletonUpdate(LivingEvent.LivingUpdateEvent event) { if (!(event.getEntityLiving() instanceof EntitySkeleton)) { return; } EntitySkeleton skeleton = (EntitySkeleton) event.getEntityLiving(); EntityAITasks tasks = skeleton.tasks; boolean containsOld = false; Iterator<EntityAITasks.EntityAITaskEntry> itr = tasks.taskEntries.iterator(); while (itr.hasNext()) { EntityAITasks.EntityAITaskEntry entry = itr.next(); if (entry.action instanceof EntityAIAttackRangedBow) { itr.remove(); } if (entry.action instanceof EntityAIAttackRanged) { containsOld = true; } } if (!containsOld) { tasks.addTask(4, new EntityAIAttackRanged(skeleton, 1.0D, 20, 15.0F)); } }
private void makeSkellyShootSlower(EntityAIAttackRangedBow aiEntry) { int timeShoot = ReflectionHelper.getPrivateValue(EntityAIAttackRangedBow.class, aiEntry, this.FIELD_G); if (timeShoot == 40) ReflectionHelper.setPrivateValue(EntityAIAttackRangedBow.class, aiEntry, 100, this.FIELD_G); }