Jump to content

Recommended Posts

Posted

Hey,

a code for picking up items from ground which I had in 1.7 now doesnt work.

I tried to find simillar code somewhere in zombie or villager class but I didnt menage.

Game crashes after mob spawn, removing that code makes no crashes.

 

Here is my 1.8 code.

        if (!this.worldObj.isRemote && !this.dead && this.canPickUpItems() == true)
        {
            List list = this.worldObj.getEntitiesWithinAABB(EntityItem.class, this.getBoundingBox().expand(1.0D, 0.0D, 1.0D));
            Iterator iterator = list.iterator();

            while (iterator.hasNext())
            {
                EntityItem entityitem = (EntityItem)iterator.next();

                if (!entityitem.isDead && entityitem.getEntityItem() != null)
                {
                    ItemStack itemstack = entityitem.getEntityItem();
                    this.inventory.addItemStackToInventory(itemstack);
                    if(this.inventory.addItemStackToInventory(itemstack) != false) 
                    {
                    	this.onItemPickup(entityitem, 1);
                    	entityitem.setDead();   
                    }
                }
            }
        }   

 

And here is error log

java.lang.NullPointerException: Ticking entity
at BetterWorld.mobs.EntityBetterVillager.onLivingUpdate(EntityBetterVillager.java:166)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1827)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:273)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2024)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:758)
at net.minecraft.world.World.updateEntity(World.java:1990)
at net.minecraft.world.World.updateEntities(World.java:1816)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:587)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:774)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540)
at java.lang.Thread.run(Unknown Source)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at BetterWorld.mobs.EntityBetterVillager.onLivingUpdate(EntityBetterVillager.java:166)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1827)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:273)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2024)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:758)
at net.minecraft.world.World.updateEntity(World.java:1990)

 

Posted

Well first in the Entity code

    public AxisAlignedBB getBoundingBox()
    {
        return null;
    }

 

I don't understand why, but getBoundingBox always returns null, so when you do this.getBoundingBox you're going to get null unless you override the method.

 

    public AxisAlignedBB getEntityBoundingBox()
    {
        return this.boundingBox;
    }

 

Actually returns something.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.