Now when ever I shot the explosive bow it crashes.
Here is the crash report:
---- Minecraft Crash Report ----
// This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]
Time: 1/17/15 6:18 PM
Description: Unexpected error
java.lang.NullPointerException: Unexpected error
at com.mineturnedmod.mineturned.EntityExplosiveArrow.setStatsByEffect(EntityExplosiveArrow.java:311)
at com.mineturnedmod.mineturned.EntityExplosiveArrow.<init>(EntityExplosiveArrow.java:77)
at com.mineturnedmod.mineturned.GreenBow2Class.onPlayerStoppedUsing(GreenBow2Class.java:67)
at net.minecraft.item.ItemStack.onPlayerStoppedUsing(ItemStack.java:498)
at net.minecraft.entity.player.EntityPlayer.stopUsingItem(EntityPlayer.java:232)
at net.minecraft.client.multiplayer.PlayerControllerMP.onStoppedUsingItem(PlayerControllerMP.java:518)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1999)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1029)
at net.minecraft.client.Minecraft.run(Minecraft.java:951)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at GradleStart.bounce(GradleStart.java:107)
at GradleStart.startClient(GradleStart.java:100)
at GradleStart.main(GradleStart.java:55)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Stacktrace:
at com.mineturnedmod.mineturned.EntityExplosiveArrow.setStatsByEffect(EntityExplosiveArrow.java:311)
at com.mineturnedmod.mineturned.EntityExplosiveArrow.<init>(EntityExplosiveArrow.java:77)
at com.mineturnedmod.mineturned.GreenBow2Class.onPlayerStoppedUsing(GreenBow2Class.java:67)
at net.minecraft.item.ItemStack.onPlayerStoppedUsing(ItemStack.java:498)
at net.minecraft.entity.player.EntityPlayer.stopUsingItem(EntityPlayer.java:232)
at net.minecraft.client.multiplayer.PlayerControllerMP.onStoppedUsingItem(PlayerControllerMP.java:518)
-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player725'/737, l='MpServer', x=183.23, y=73.62, z=303.72]]
Chunk stats: MultiplayerChunkCache: 625, 625
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options:
Level spawn location: World: (112,64,256), Chunk: (at 0,4,0 in 7,16; contains blocks 112,0,256 to 127,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 192082 game time, 136483 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 80 total; [EntitySheep['Sheep'/550, l='MpServer', x=184.94, y=66.00, z=361.59], EntityBat['Bat'/4129, l='MpServer', x=165.69, y=49.32, z=291.50], EntitySlime['Slime'/549, l='MpServer', x=181.78, y=12.87, z=263.22], EntityBat['Bat'/2987, l='MpServer', x=211.53, y=43.83, z=306.17], EntitySkeleton['Skeleton'/4079, l='MpServer', x=155.09, y=17.00, z=321.50], EntitySkeleton['Skeleton'/4078, l='MpServer', x=148.78, y=17.00, z=320.53], EntityZombie['Zombie'/5485, l='MpServer', x=167.50, y=44.00, z=373.50], EntitySkeleton['Skeleton'/4080, l='MpServer', x=149.66, y=17.00, z=319.91], EntitySkeleton['Skeleton'/5483, l='MpServer', x=241.50, y=19.00, z=331.50], EntityCreeper['Creeper'/1115, l='MpServer', x=235.56, y=73.00, z=261.97], EntityZombie['Zombie'/1650, l='MpServer', x=137.03, y=69.00, z=290.50], EntityClientPlayerMP['Player725'/737, l='MpServer', x=183.23, y=73.62, z=303.72], EntityCreeper['Creeper'/3820, l='MpServer', x=141.44, y=79.00, z=342.34], EntitySpider['Spider'/1600, l='MpServer', x=121.78, y=87.00, z=336.03], EntityZombie['Zombie'/525, l='MpServer', x=176.34, y=65.00, z=263.84], EntityBat['Bat'/526, l='MpServer', x=180.47, y=43.10, z=292.75], EntityZombie['Zombie'/4046, l='MpServer', x=141.50, y=82.00, z=347.50], EntityBat['Bat'/2470, l='MpServer', x=245.27, y=11.82, z=337.29], EntityZombie['Zombie'/4049, l='MpServer', x=118.47, y=84.00, z=320.91], EntitySkeleton['Skeleton'/4057, l='MpServer', x=132.50, y=16.00, z=290.50], EntityCreeper['Creeper'/3789, l='MpServer', x=167.50, y=21.00, z=260.50], EntityBat['Bat'/4126, l='MpServer', x=127.28, y=23.10, z=293.66], EntitySkeleton['Skeleton'/3791, l='MpServer', x=188.50, y=19.00, z=331.50], EntitySkeleton['Skeleton'/4675, l='MpServer', x=193.50, y=37.00, z=232.50], EntitySkeleton['Skeleton'/4674, l='MpServer', x=195.44, y=37.00, z=228.47], EntityCreeper['Creeper'/4677, l='MpServer', x=197.50, y=37.00, z=224.50], EntitySheep['Sheep'/614, l='MpServer', x=237.50, y=72.00, z=380.50], EntitySkeleton['Skeleton'/5166, l='MpServer', x=152.50, y=63.00, z=277.50], EntityCreeper['Creeper'/4676, l='MpServer', x=190.00, y=34.00, z=235.47], EntityCreeper['Creeper'/612, l='MpServer', x=228.50, y=28.00, z=278.50], EntityCreeper['Creeper'/4678, l='MpServer', x=195.50, y=37.00, z=226.50], EntitySheep['Sheep'/613, l='MpServer', x=236.50, y=72.00, z=378.50], EntityZombie['Zombie'/3464, l='MpServer', x=106.94, y=13.00, z=262.66], EntityZombie['Zombie'/4687, l='MpServer', x=107.50, y=70.00, z=312.50], EntityCreeper['Creeper'/1842, l='MpServer', x=155.50, y=19.00, z=312.50], EntitySkeleton['Skeleton'/3473, l='MpServer', x=177.50, y=41.00, z=314.50], EntityZombie['Zombie'/4933, l='MpServer', x=127.50, y=70.00, z=308.50], EntityZombie['Zombie'/4932, l='MpServer', x=128.50, y=70.00, z=307.50], EntityZombie['Zombie'/4938, l='MpServer', x=159.50, y=72.00, z=224.50], EntitySkeleton['Skeleton'/5175, l='MpServer', x=232.50, y=89.00, z=315.50], EntityBat['Bat'/3061, l='MpServer', x=147.75, y=40.10, z=357.75], EntitySkeleton['Skeleton'/5402, l='MpServer', x=144.50, y=42.00, z=377.50], EntitySpider['Spider'/1819, l='MpServer', x=190.81, y=74.00, z=303.75], EntitySkeleton['Skeleton'/587, l='MpServer', x=219.34, y=64.00, z=236.59], EntitySheep['Sheep'/589, l='MpServer', x=209.03, y=67.00, z=375.78], EntityCreeper['Creeper'/5138, l='MpServer', x=243.88, y=70.00, z=237.28], EntityBat['Bat'/4737, l='MpServer', x=140.94, y=39.79, z=345.38], EntityBat['Bat'/4739, l='MpServer', x=143.80, y=39.85, z=347.40], EntityBat['Bat'/4767, l='MpServer', x=158.78, y=21.86, z=278.04], EntityBat['Bat'/4753, l='MpServer', x=128.64, y=16.05, z=289.63], EntityBat['Bat'/4752, l='MpServer', x=132.45, y=22.01, z=292.35], EntitySpider['Spider'/5329, l='MpServer', x=217.72, y=81.00, z=273.57], EntitySheep['Sheep'/665, l='MpServer', x=263.13, y=69.00, z=246.94], EntitySpider['Spider'/5341, l='MpServer', x=205.50, y=78.00, z=263.50], EntitySkeleton['Skeleton'/1278, l='MpServer', x=141.50, y=75.00, z=283.50], EntitySkeleton['Skeleton'/1518, l='MpServer', x=236.56, y=72.00, z=266.09], EntityZombie['Zombie'/3099, l='MpServer', x=157.50, y=68.00, z=368.50], EntityPig['Pig'/476, l='MpServer', x=142.56, y=86.00, z=346.13], EntityBat['Bat'/472, l='MpServer', x=135.50, y=22.10, z=300.50], EntityBat['Bat'/473, l='MpServer', x=140.50, y=22.00, z=308.25], EntityXPOrb['Experience Orb'/469, l='MpServer', x=128.34, y=64.25, z=246.25], EntityZombie['Zombie'/4584, l='MpServer', x=252.41, y=84.00, z=337.00], EntitySkeleton['Skeleton'/3084, l='MpServer', x=256.50, y=77.00, z=354.50], EntityZombie['Zombie'/1172, l='MpServer', x=217.50, y=79.00, z=279.50], EntityWitch['Witch'/4341, l='MpServer', x=254.53, y=81.00, z=338.97], EntityCreeper['Creeper'/1960, l='MpServer', x=141.38, y=72.00, z=302.00], EntityItem['item.item.porkchopRaw'/449, l='MpServer', x=125.84, y=65.13, z=247.41], EntitySpider['Spider'/4336, l='MpServer', x=159.50, y=67.00, z=284.88], EntityCreeper['Creeper'/1943, l='MpServer', x=186.94, y=34.00, z=282.47], EntityCreeper['Creeper'/4571, l='MpServer', x=247.84, y=70.00, z=238.78], EntitySpider['Spider'/1666, l='MpServer', x=183.59, y=79.00, z=279.97], EntityPig['Pig'/501, l='MpServer', x=147.50, y=80.00, z=324.69], EntityPig['Pig'/502, l='MpServer', x=156.56, y=71.00, z=345.78], EntityBat['Bat'/4295, l='MpServer', x=166.25, y=17.07, z=251.47], EntitySkeleton['Skeleton'/1467, l='MpServer', x=175.50, y=26.00, z=236.50], EntityCreeper['Creeper'/499, l='MpServer', x=152.00, y=70.00, z=299.50], EntitySpider['Spider'/2898, l='MpServer', x=222.38, y=78.00, z=259.81], EntitySkeleton['Skeleton'/2422, l='MpServer', x=194.50, y=52.00, z=237.50], EntitySquid['Squid'/494, l='MpServer', x=143.44, y=51.34, z=258.94], EntityZombie['Zombie'/3108, l='MpServer', x=188.69, y=72.00, z=339.69]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2556)
at net.minecraft.client.Minecraft.run(Minecraft.java:980)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at GradleStart.bounce(GradleStart.java:107)
at GradleStart.startClient(GradleStart.java:100)
at GradleStart.main(GradleStart.java:55)
-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_67, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 557647408 bytes (531 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
FML: MCP v9.05 FML v7.10.18.1180 Minecraft Forge 10.13.0.1180 4 mods loaded, 4 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available
FML{7.10.18.1180} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.0.1180.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available
Forge{10.13.0.1180} [Minecraft Forge] (forgeSrc-1.7.10-10.13.0.1180.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available
realisticcrafting{1.0} [More Crafting] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available->Available->Available->Available
Launched Version: 1.7.10
LWJGL: 2.9.1
OpenGL: AMD Radeon HD 5700 Series GL version 4.2.12422 Compatibility Profile Context 13.152.0.0, ATI Technologies Inc.
GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Anisotropic Filtering: Off (1)
Here is the greenbow2 class:
public class GreenBow2Class extends Item
{
public static final String[] bowPullIconNameArray = new String[] {"bow_pulling_0", "bow_pulling_1", "bow_pulling_2"};
@SideOnly(Side.CLIENT)
private IIcon[] iconArray;
private static final String __OBFID = "CL_00001777";
public GreenBow2Class()
{
this.maxStackSize = 1;
this.setMaxDamage(384);
this.setCreativeTab(CreativeTabs.tabCombat);
}
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_)
{
int j = this.getMaxItemUseDuration(p_77615_1_) - p_77615_4_;
ArrowLooseEvent event = new ArrowLooseEvent(p_77615_3_, p_77615_1_, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return;
}
j = event.charge;
boolean flag = p_77615_3_.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0;
if (flag || p_77615_3_.inventory.hasItem(Items.arrow))
{
float f = (float)j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if ((double)f < 0.1D)
{
return;
}
if (f > 1.0F)
{
f = 1.0F;
}
EntityExplosiveArrow EntityExplosiveArrow = new EntityExplosiveArrow(p_77615_2_, p_77615_3_, p_77615_3_, f, f, null);
if (f == 1.0F)
{
}
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, p_77615_1_);
if (k > 0)
{
}
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, p_77615_1_);
if (l > 0)
{
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, p_77615_1_) > 0)
{
EntityExplosiveArrow.setFire(100);
}
p_77615_1_.damageItem(1, p_77615_3_);
p_77615_2_.playSoundAtEntity(p_77615_3_, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
if (flag)
{
}
else
{
p_77615_3_.inventory.consumeInventoryItem(Items.arrow);
}
if (!p_77615_2_.isRemote)
{
p_77615_2_.spawnEntityInWorld(EntityExplosiveArrow);
}
}
}
public ItemStack onEaten(ItemStack p_77654_1_, World p_77654_2_, EntityPlayer p_77654_3_)
{
return p_77654_1_;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack p_77626_1_)
{
return 82000;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack p_77661_1_)
{
return EnumAction.bow;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
{
ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return event.result;
}
if (p_77659_3_.capabilities.isCreativeMode || p_77659_3_.inventory.hasItem(Items.arrow))
{
p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_));
}
return p_77659_1_;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
if (usingItem == null) { return itemIcon; }
int ticksInUse = stack.getMaxItemUseDuration() - useRemaining;
if (ticksInUse > 1) {
return iconArray[2];
} else if (ticksInUse > 13) {
return iconArray[1];
} else if (ticksInUse > 0) {
return iconArray[0];
} else {
return itemIcon;
}
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister){
iconArray = new IIcon[4];
iconArray[0] = iconRegister.registerIcon("morecraftingmod:bow_standby");
iconArray[1] = iconRegister.registerIcon("morecraftingmod:bow_pulling_0");
iconArray[2] = iconRegister.registerIcon("morecraftingmod:bow_pulling_1");
iconArray[3] = iconRegister.registerIcon("morecraftingmod:bow_pulling_2");
this.itemIcon = iconRegister.registerIcon("morecraftingmod:bow_standby");
}
/**
* used to cycle through icons based on their used duration, i.e. for the bow
*/
@SideOnly(Side.CLIENT)
public IIcon getItemIconForUseDuration(int p_94599_1_)
{
return this.iconArray[p_94599_1_];
}
}
Here is the explosive arrow class:
package com.mineturnedmod.mineturned;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.DataWatcher;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.potion.Potion;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
public class EntityExplosiveArrow extends EntityArrow {
private int xTile = -1;
private int yTile = -1;
private int zTile = -1;
private Block inTile = null;
private int inData = 0;
private boolean inGround = false;
private int ticksInGround = 0;
private int ticksInAir = 0;
private float knockbackStrength = 0;
public ArrowEffect effect = ArrowEffect.DEFAULT;
public EntityExplosiveArrow(World world) {
super(world);
}
public EntityExplosiveArrow(World world, double x, double y, double z) {
super(world, x, y, z);
}
public EntityExplosiveArrow(World world, double x, double y, double z, double damage) {
super(world, x, y, z);
setDamage(damage);
}
public EntityExplosiveArrow(World world, EntityLivingBase shooter, EntityLivingBase target, float power, float variance) {
super(world, shooter, target, power, variance);
}
public EntityExplosiveArrow(World world, EntityLivingBase shooter, EntityLivingBase target, float power, float variance, double damage) {
super(world, shooter, target, power, variance);
setDamage(damage);
}
public EntityExplosiveArrow(World world, EntityLivingBase shooter, float power) {
super(world, shooter, power);
}
public EntityExplosiveArrow(World world, EntityLivingBase shooter, float power, double damage) {
super(world, shooter, power);
setDamage(damage);
}
public EntityExplosiveArrow(World world, EntityLivingBase shooter, EntityLivingBase target, float power, float variance, ArrowEffect fx) {
super(world, shooter, target, power, variance);
this.effect = fx;
setStatsByEffect();
}
public EntityExplosiveArrow(World world, EntityLivingBase shooter, EntityLivingBase target, float power, float variance, double damage, ArrowEffect fx) {
super(world, shooter, target, power, variance);
setDamage(damage);
this.effect = fx;
setStatsByEffect();
}
public EntityExplosiveArrow(World world, EntityLivingBase shooter, float power, ArrowEffect fx) {
super(world, shooter, power);
this.effect = fx;
setStatsByEffect();
}
public EntityExplosiveArrow(World world, EntityLivingBase shooter, float power, double damage, ArrowEffect fx) {
super(world, shooter, power);
setDamage(damage);
this.effect = fx;
setStatsByEffect();
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(17, "");
}
public void onUpdate()
{
onEntityUpdate();
if ((this.prevRotationPitch == 0.0F) && (this.prevRotationYaw == 0.0F)) {
float var1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.prevRotationYaw = (this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / 3.141592653589793D));
this.prevRotationPitch = (this.rotationPitch = (float)(Math.atan2(this.motionY, var1) * 180.0D / 3.141592653589793D));
}
Block block = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
if (block != Blocks.air) {
block.setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile);
AxisAlignedBB var2 = block.getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile);
if ((var2 != null) && (var2.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))))
this.inGround = true;
}
if (this.arrowShake > 0)
this.arrowShake -= 1;
if (this.inGround) {
Block blockInside = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
int metaInside = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
if ((blockInside == this.inTile) && (metaInside == this.inData)) {
this.ticksInGround++;
if (this.ticksInGround >= 1200)
setDead();
}
else {
this.inGround = false;
this.motionX *= this.rand.nextFloat() * 0.2F;
this.motionY *= this.rand.nextFloat() * 0.2F;
this.motionZ *= this.rand.nextFloat() * 0.2F;
this.ticksInGround = 0;
this.ticksInAir = 0;
}
}
else {
this.ticksInAir += 1;
Vec3 posVector = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 newPosVector = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition moPos = this.worldObj.func_147447_a(posVector, newPosVector, false, true, false);
posVector = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
newPosVector = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (moPos != null)
newPosVector = Vec3.createVectorHelper(moPos.hitVec.xCoord, moPos.hitVec.yCoord, moPos.hitVec.zCoord);
Entity entity = null;
List entityList = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double var7 = 0.0D;
for (int var9 = 0; var9 < entityList.size(); var9++) {
Entity var10 = (Entity)entityList.get(var9);
if ((var10.canBeCollidedWith()) && ((var10 != this.shootingEntity) || (this.ticksInAir >= 5))) {
float var11 = 0.3F;
AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11);
MovingObjectPosition var13 = var12.calculateIntercept(posVector, newPosVector);
if (var13 != null) {
double var14 = posVector.distanceTo(var13.hitVec);
if ((var14 < var7) || (var7 == 0.0D)) {
entity = var10;
var7 = var14;
}
}
}
}
if (entity != null) {
moPos = new MovingObjectPosition(entity);
}
if (moPos != null) {
if (moPos.entityHit != null) {
float var20 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
int var23 = MathHelper.ceiling_double_int(var20 * getDamage() * 1.5);
if (getIsCritical())
var23 += this.rand.nextInt(var23 / 2 + 2);
DamageSource var21 = null;
if (this.shootingEntity == null)
var21 = DamageSource.causeArrowDamage(this, this);
else
var21 = DamageSource.causeArrowDamage(this, this.shootingEntity);
if ((isBurning()) && (!(moPos.entityHit instanceof EntityEnderman)))
moPos.entityHit.setFire(5);
if((shouldDamage(moPos.entityHit))) {
moPos.entityHit.hurtResistantTime = 0;
if ((moPos.entityHit.attackEntityFrom(var21, var23))) {
hitEffect(moPos.entityHit);
if ((moPos.entityHit instanceof EntityLivingBase)) {
EntityLivingBase entityLivingBase = (EntityLivingBase)moPos.entityHit;
if (!this.worldObj.isRemote)
entityLivingBase.setArrowCountInEntity(entityLivingBase.getArrowCountInEntity() + 1);
if (this.knockbackStrength > 0) {
float var26 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (var26 > 0.0F) {
moPos.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6D / var26, 0.1D, this.motionZ * this.knockbackStrength * 0.6D / var26);
}
}
if (this.shootingEntity != null) {
EnchantmentHelper.func_151384_a(entityLivingBase, this.shootingEntity);
EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entityLivingBase);
}
if ((this.shootingEntity != null) && (moPos.entityHit != this.shootingEntity) && ((moPos.entityHit instanceof EntityPlayer)) && ((this.shootingEntity instanceof EntityPlayerMP)))
((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
}
playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
if (!(moPos.entityHit instanceof EntityEnderman))
setDead();
}
}
else {
this.motionX *= -0.1D;
this.motionY *= -0.1D;
this.motionZ *= -0.1D;
this.rotationYaw += 180.0F;
this.prevRotationYaw += 180.0F;
this.ticksInAir = 0;
}
}
else {
this.xTile = moPos.blockX;
this.yTile = moPos.blockY;
this.zTile = moPos.blockZ;
this.inTile = this.worldObj.getBlock(this.xTile, this.yTile, this.zTile);
this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
missEffect(this.xTile, this.yTile, this.zTile);
this.motionX = ((float)(moPos.hitVec.xCoord - this.posX));
this.motionY = ((float)(moPos.hitVec.yCoord - this.posY));
this.motionZ = ((float)(moPos.hitVec.zCoord - this.posZ));
float var20 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / var20 * 0.05D;
this.posY -= this.motionY / var20 * 0.05D;
this.posZ -= this.motionZ / var20 * 0.05D;
playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
this.inGround = true;
this.arrowShake = 7;
setIsCritical(false);
if (this.inTile != Blocks.air)
this.inTile.onEntityCollidedWithBlock(this.worldObj, this.xTile, this.yTile, this.zTile, this);
}
}
if (getIsCritical()) {
for (int var9 = 0; var9 < 4; var9++)
this.worldObj.spawnParticle("crit", this.posX + this.motionX * var9 / 4.0D, this.posY + this.motionY * var9 / 4.0D, this.posZ + this.motionZ * var9 / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ);
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
float var20 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = ((float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / 3.141592653589793D));
for (this.rotationPitch = ((float)(Math.atan2(this.motionY, var20) * 180.0D / 3.141592653589793D)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F);
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
this.prevRotationPitch += 360.0F;
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
this.prevRotationYaw -= 360.0F;
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
this.prevRotationYaw += 360.0F;
this.rotationPitch = (this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F);
this.rotationYaw = (this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F);
float var22 = 0.99F;
float var11 = 0.05F;
if (isInWater()) {
for (int var25 = 0; var25 < 4; var25++) {
float var26 = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * var26, this.posY - this.motionY * var26, this.posZ - this.motionZ * var26, this.motionX, this.motionY, this.motionZ);
}
var22 = 0.8F;
}
this.motionX *= var22;
this.motionY *= var22;
this.motionZ *= var22;
this.motionY -= var11;
setPosition(this.posX, this.posY, this.posZ);
func_145775_I/*doBlockCollisions*/();
}
}
public boolean shouldDamage(Entity entity)
{
return (entity != this.shootingEntity);
}
public void writeEntityToNBT(NBTTagCompound tag)
{
super.writeEntityToNBT(tag);
tag.setShort("xTile", (short)this.xTile);
tag.setShort("yTile", (short)this.yTile);
tag.setShort("zTile", (short)this.zTile);
tag.setByte("inTile", (byte)Block.getIdFromBlock(this.inTile));
tag.setByte("inData", (byte)this.inData);
tag.setByte("inGround", (byte)(this.inGround ? 1 : 0));
tag.setByte("effect", this.effect.ID);
}
public void readEntityFromNBT(NBTTagCompound tag)
{
super.readEntityFromNBT(tag);
this.xTile = tag.getShort("xTile");
this.yTile = tag.getShort("yTile");
this.zTile = tag.getShort("zTile");
this.inTile = Block.getBlockById(tag.getByte("inTile") & 0xFF);
this.inData = (tag.getByte("inData") & 0xFF);
this.inGround = (tag.getByte("inGround") == 1);
this.effect = ArrowEffect.get(tag.getByte("effect"));
}
public void setKnockbackStrength(float strength)
{
this.knockbackStrength = strength;
}
public void setStatsByEffect() {
switch (this.effect.ID) {
case 0:
setKnockbackStrength(1);
break;
case 1:
setKnockbackStrength(0);
break;
}
}
public void hitEffect(Entity entityHit) {
switch (this.effect.ID) {
case 1:
Explosion explosion = new Explosion(this.worldObj, this, this.posX, this.posY, this.posZ, 2F);
explosion.doExplosionA();
explosion.doExplosionB(true);
break;
}
}
public void missEffect(int x, int y, int z) {
switch (this.effect.ID) {
case 1:
Explosion explosion = new Explosion(this.worldObj, this, this.posX, this.posY, this.posZ, 2F);
explosion.doExplosionA();
explosion.doExplosionB(true);
setDead();
break;
}
}
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1)))
{
flag = false;
}
if (flag)
{
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
par1EntityPlayer.onItemPickup(this, 1);
this.setDead();
}
}
}
}