Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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)

 

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.

  • Author

Thanks now it works. I dont even want to ask who made that method.

Eclipse suggested to use that empty, I should check it befor I wrote that topic.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.