@Override public void executeActivateBehavior(TileEntityTrophy tile, EntityPlayer player) { if (tile.worldObj.isRemote) { return; } double midX = tile.xCoord + 0.5; double midZ = tile.zCoord + 0.5; EntityArrow entityarrow = new EntityArrow(tile.worldObj, midX, tile.yCoord + 1, midZ); entityarrow.setDamage(0.1); entityarrow.setThrowableHeading( tile.worldObj.rand.nextInt(10) - 5, 40, tile.worldObj.rand.nextInt(10) - 5, 1.0f, 6.0f); player.playSound("random.bow", 1.0F, 1.0F / (tile.worldObj.rand.nextFloat() * 0.4F + 0.8F)); tile.worldObj.spawnEntityInWorld(entityarrow); }
/** * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define * their attack. */ protected void attackEntity(Entity entity, float f) { if ((entity instanceof EntityPlayer) || (entity instanceof CREEPSEntityHunchback) || (entity instanceof CREEPSEntityHunchbackSkeleton)) { this.setAttackTarget(null); return; } if (f < 10F) { double d = entity.posX - posX; double d1 = entity.posZ - posZ; EntityArrow entityarrow = new EntityArrow(worldObj, this, 1.0F); entityarrow.posY += 1.3999999761581421D; double d2 = entity.posY - 0.20000000298023224D - entityarrow.posY; float f1 = MathHelper.sqrt_double(d * d + d1 * d1) * 0.2F; worldObj.playSoundAtEntity(this, "random.bow", 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 0.8F)); worldObj.spawnEntityInWorld(entityarrow); entityarrow.setThrowableHeading(d, d2 + (double) f1, d1, 0.6F, 12F); rotationYaw = (float) ((Math.atan2(d1, d) * 180D) / Math.PI) - 90F; hasAttacked = true; } }