I have a problem.I'm trying to update my Arrow Golems mod and the mob works perfectly except for 1 problem.The game crashes when it tries to attack a mob.
I know it's when it tries to attack because it happens whenever I spawn a monster it attacks by it.
I tried making a new ArrowAttack AI with ArrowGolem after the name, but that didn't work, because there's still the crash error.I thought it would work because I thought it may be because the skeleton uses it to shoot arrows and so will the Arrow Golem, and so the new AI would only be used by the Arrow Golem, but that didn't work.
Any help would be appreciated.
This is the crash error:
---- Minecraft Crash Report ----
// Hey, that tickles! Hehehe!
Time: 10/31/12 8:30 PM
Description: Exception in server tick loop
java.lang.NullPointerException
at net.minecraft.src.DataWatcher.getWatchableObjectByte(DataWatcher.java:65)
at net.minecraft.src.EntityArrowGolem.func_82202_m(EntityArrowGolem.java:121)
at net.minecraft.src.EntityArrowGolem.func_82196_d(EntityArrowGolem.java:140)
at net.minecraft.src.EntityAIArrowAttackArrowGolem.updateTask(EntityAIArrowAttackArrowGolem.java:109)
at net.minecraft.src.EntityAITasks.onUpdateTasks(EntityAITasks.java:97)
at net.minecraft.src.EntityLiving.updateAITasks(EntityLiving.java:1884)
at net.minecraft.src.EntityLiving.onLivingUpdate(EntityLiving.java:1611)
at net.minecraft.src.EntityArrowGolem.onLivingUpdate(EntityArrowGolem.java:38)
at net.minecraft.src.EntityLiving.onUpdate(EntityLiving.java:734)
at net.minecraft.src.World.updateEntityWithOptionalForce(World.java:2020)
at net.minecraft.src.WorldServer.updateEntityWithOptionalForce(WorldServer.java:546)
at net.minecraft.src.World.updateEntity(World.java:1991)
at net.minecraft.src.World.updateEntities(World.java:1876)
at net.minecraft.src.WorldServer.updateEntities(WorldServer.java:440)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:648)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:586)
at net.minecraft.src.IntegratedServer.tick(IntegratedServer.java:124)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496)
at net.minecraft.src.ThreadMinecraftServer.run(ThreadMinecraftServer.java:17)
Relevant Details:
- Minecraft Version: 1.4.2
- Operating System: Windows 7 (x86) version 6.1
- Java Version: 1.7.0_04, Oracle Corporation
- Java VM Version: Java HotSpotâ„¢ Client VM (mixed mode), Oracle Corporation
- Memory: 948965392 bytes (905 MB) / 1067057152 bytes (1017 MB) up to 1067057152 bytes (1017 MB)
- JVM Flags: 3 total; -Xincgc -Xms1024M -Xmx1024M
- AABB Pool Size: 13623 (762888 bytes; 0 MB) allocated, 3929 (220024 bytes; 0 MB) used
- ModLoader: Mods loaded: 2
ModLoader 1.4.2
mod_EntityArrowGolem 1.4.2
- Is Modded: Very likely
- Profiler Position: N/A (disabled)
- Vec3 Pool Size: 778 (43568 bytes; 0 MB) allocated, 778 (43568 bytes; 0 MB) used
- Player Count: 1 / 8; [EntityPlayerMP['Player653'/297, l='Test', x=57.50, y=72.00, z=247.50]]
- World Test Entities: 0 total; []
- World Test Players: 0 total; []
- World Test Chunk Stats: ServerChunkCache: 0 Drop: 0
- Type: Integrated Server
And yes, that's the only problem I'm having.I tried searching Google for any help but couldn't find the answer.
Anyone?
Oh, and here's my Entity's code file.Not showing the mod_class since it's how the usual mob's mod_ file is with ModLoader.
package net.minecraft.src;
public class EntityArrowGolem extends EntityGolem implements IRangedAttackMob
{
public EntityArrowGolem(World par1World)
{
super(par1World);
this.texture = "/mob/ArrowGolem.png";
this.setSize(0.4F, 1.8F);
this.getNavigator().setAvoidsWater(false);
this.tasks.addTask(1, new EntityAIArrowAttackArrowGolem(this, 0.25F, 60, 10.0F));
this.tasks.addTask(2, new EntityAIWander(this, 0.2F));
this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(4, new EntityAILookIdle(this));
this.tasks.addTask(5, new EntityAISwimming(this));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 16.0F, 0, true, false, IMob.field_82192_a));
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
public int getMaxHealth()
{
return 32;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
if (this.isWet())
{
this.worldObj.playSoundAtEntity(this, "none", 1.0F, 1.0F);
}
int var1 = MathHelper.floor_double(this.posX);
int var2 = MathHelper.floor_double(this.posZ);
if (this.worldObj.getBiomeGenForCoords(var1, var2).getFloatTemperature() > 9.0F)
{
this.attackEntityFrom(DamageSource.inWall, 1);
}
for (var1 = 0; var1 < 4; ++var1)
{
var2 = MathHelper.floor_double(this.posX + (double)((float)(var1 % 2 * 2 - 1) * 0.25F));
int var3 = MathHelper.floor_double(this.posY);
int var4 = MathHelper.floor_double(this.posZ + (double)((float)(var1 / 2 % 2 * 2 - 1) * 0.25F));
if (this.worldObj.getBlockId(var2, var3, var4) == 0 && this.worldObj.getBiomeGenForCoords(var2, var4).getFloatTemperature() < 0.8F && Block.redstoneWire.canPlaceBlockAt(this.worldObj, var2, var3, var4))
{
this.worldObj.setBlockWithNotify(var2, var3, var4, Block.redstoneWire.blockID);
}
}
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.irongolem.death";
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.worldObj.playSoundAtEntity(this, "step.stone", 1.0F, 1.0F);
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return Item.arrow.shiftedIndex;
}
/**
* Drop 0-2 items of this living's type
*/
protected void dropFewItems(boolean par1, int par2)
{
int var3 = this.rand.nextInt(16);
for (int var4 = 0; var4 < var3; ++var4)
{
this.dropItem(Item.arrow.shiftedIndex, 3);
}
}
public int func_82202_m()
{
return this.dataWatcher.getWatchableObjectByte(13);
}
public void func_82196_d(EntityLiving par1EntityLiving)
{
EntityArrow var2 = new EntityArrow(this.worldObj, this, par1EntityLiving, 1.6F, 12.0F);
int var3 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
int var4 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
if (var3 > 0)
{
var2.setDamage(var2.getDamage() + (double)var3 * 0.5D + 0.5D);
}
if (var4 > 0)
{
var2.setKnockbackStrength(var4);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.func_82202_m() == 1)
{
var2.setFire(100);
}
this.worldObj.playSoundAtEntity(this, "random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.worldObj.spawnEntityInWorld(var2);
}
}
I know it's when it tries to attack because it happens whenever I spawn a monster it attacks by it.
I tried making a new ArrowAttack AI with ArrowGolem after the name, but that didn't work, because there's still the crash error.I thought it would work because I thought it may be because the skeleton uses it to shoot arrows and so will the Arrow Golem, and so the new AI would only be used by the Arrow Golem, but that didn't work.
Any help would be appreciated.
This is the crash error:
// Hey, that tickles! Hehehe!
Time: 10/31/12 8:30 PM
Description: Exception in server tick loop
java.lang.NullPointerException
at net.minecraft.src.DataWatcher.getWatchableObjectByte(DataWatcher.java:65)
at net.minecraft.src.EntityArrowGolem.func_82202_m(EntityArrowGolem.java:121)
at net.minecraft.src.EntityArrowGolem.func_82196_d(EntityArrowGolem.java:140)
at net.minecraft.src.EntityAIArrowAttackArrowGolem.updateTask(EntityAIArrowAttackArrowGolem.java:109)
at net.minecraft.src.EntityAITasks.onUpdateTasks(EntityAITasks.java:97)
at net.minecraft.src.EntityLiving.updateAITasks(EntityLiving.java:1884)
at net.minecraft.src.EntityLiving.onLivingUpdate(EntityLiving.java:1611)
at net.minecraft.src.EntityArrowGolem.onLivingUpdate(EntityArrowGolem.java:38)
at net.minecraft.src.EntityLiving.onUpdate(EntityLiving.java:734)
at net.minecraft.src.World.updateEntityWithOptionalForce(World.java:2020)
at net.minecraft.src.WorldServer.updateEntityWithOptionalForce(WorldServer.java:546)
at net.minecraft.src.World.updateEntity(World.java:1991)
at net.minecraft.src.World.updateEntities(World.java:1876)
at net.minecraft.src.WorldServer.updateEntities(WorldServer.java:440)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:648)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:586)
at net.minecraft.src.IntegratedServer.tick(IntegratedServer.java:124)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496)
at net.minecraft.src.ThreadMinecraftServer.run(ThreadMinecraftServer.java:17)
Relevant Details:
- Minecraft Version: 1.4.2
- Operating System: Windows 7 (x86) version 6.1
- Java Version: 1.7.0_04, Oracle Corporation
- Java VM Version: Java HotSpotâ„¢ Client VM (mixed mode), Oracle Corporation
- Memory: 948965392 bytes (905 MB) / 1067057152 bytes (1017 MB) up to 1067057152 bytes (1017 MB)
- JVM Flags: 3 total; -Xincgc -Xms1024M -Xmx1024M
- AABB Pool Size: 13623 (762888 bytes; 0 MB) allocated, 3929 (220024 bytes; 0 MB) used
- ModLoader: Mods loaded: 2
ModLoader 1.4.2
mod_EntityArrowGolem 1.4.2
- Is Modded: Very likely
- Profiler Position: N/A (disabled)
- Vec3 Pool Size: 778 (43568 bytes; 0 MB) allocated, 778 (43568 bytes; 0 MB) used
- Player Count: 1 / 8; [EntityPlayerMP['Player653'/297, l='Test', x=57.50, y=72.00, z=247.50]]
- World Test Entities: 0 total; []
- World Test Players: 0 total; []
- World Test Chunk Stats: ServerChunkCache: 0 Drop: 0
- Type: Integrated Server
Oh, and here's my Entity's code file.Not showing the mod_class since it's how the usual mob's mod_ file is with ModLoader.
public class EntityArrowGolem extends EntityGolem implements IRangedAttackMob
{
public EntityArrowGolem(World par1World)
{
super(par1World);
this.texture = "/mob/ArrowGolem.png";
this.setSize(0.4F, 1.8F);
this.getNavigator().setAvoidsWater(false);
this.tasks.addTask(1, new EntityAIArrowAttackArrowGolem(this, 0.25F, 60, 10.0F));
this.tasks.addTask(2, new EntityAIWander(this, 0.2F));
this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(4, new EntityAILookIdle(this));
this.tasks.addTask(5, new EntityAISwimming(this));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 16.0F, 0, true, false, IMob.field_82192_a));
}
/**
* Returns true if the newer Entity AI code should be run
*/
public boolean isAIEnabled()
{
return true;
}
public int getMaxHealth()
{
return 32;
}
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
super.onLivingUpdate();
if (this.isWet())
{
this.worldObj.playSoundAtEntity(this, "none", 1.0F, 1.0F);
}
int var1 = MathHelper.floor_double(this.posX);
int var2 = MathHelper.floor_double(this.posZ);
if (this.worldObj.getBiomeGenForCoords(var1, var2).getFloatTemperature() > 9.0F)
{
this.attackEntityFrom(DamageSource.inWall, 1);
}
for (var1 = 0; var1 < 4; ++var1)
{
var2 = MathHelper.floor_double(this.posX + (double)((float)(var1 % 2 * 2 - 1) * 0.25F));
int var3 = MathHelper.floor_double(this.posY);
int var4 = MathHelper.floor_double(this.posZ + (double)((float)(var1 / 2 % 2 * 2 - 1) * 0.25F));
if (this.worldObj.getBlockId(var2, var3, var4) == 0 && this.worldObj.getBiomeGenForCoords(var2, var4).getFloatTemperature() < 0.8F && Block.redstoneWire.canPlaceBlockAt(this.worldObj, var2, var3, var4))
{
this.worldObj.setBlockWithNotify(var2, var3, var4, Block.redstoneWire.blockID);
}
}
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "none";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.irongolem.death";
}
/**
* Plays step sound at given x, y, z for the entity
*/
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.worldObj.playSoundAtEntity(this, "step.stone", 1.0F, 1.0F);
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected int getDropItemId()
{
return Item.arrow.shiftedIndex;
}
/**
* Drop 0-2 items of this living's type
*/
protected void dropFewItems(boolean par1, int par2)
{
int var3 = this.rand.nextInt(16);
for (int var4 = 0; var4 < var3; ++var4)
{
this.dropItem(Item.arrow.shiftedIndex, 3);
}
}
public int func_82202_m()
{
return this.dataWatcher.getWatchableObjectByte(13);
}
public void func_82196_d(EntityLiving par1EntityLiving)
{
EntityArrow var2 = new EntityArrow(this.worldObj, this, par1EntityLiving, 1.6F, 12.0F);
int var3 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
int var4 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
if (var3 > 0)
{
var2.setDamage(var2.getDamage() + (double)var3 * 0.5D + 0.5D);
}
if (var4 > 0)
{
var2.setKnockbackStrength(var4);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.func_82202_m() == 1)
{
var2.setFire(100);
}
this.worldObj.playSoundAtEntity(this, "random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.worldObj.spawnEntityInWorld(var2);
}
}
I guess a moderator can remove this now.