Jump to content

[1.11] Getting Parameter From Recipe Exception.


Recommended Posts

Posted

Thanks.. However now if the entity isnt there it seems to crash, even though I try to put countless null checks.. here is the error:

Time: 12/18/16 10:46 PM
Description: Ticking block entity

java.lang.NullPointerException: Ticking block entity
at com.lambda.plentifulmisc.tile.magic.TileEntitySacrificeStand.updateEntity(TileEntitySacrificeStand.java:93)
at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:184)
at net.minecraft.world.World.updateEntities(World.java:1968)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:646)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547)
at java.lang.Thread.run(Thread.java:745)


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

-- Head --
Thread: Client thread
Stacktrace:
at com.lambda.plentifulmisc.tile.magic.TileEntitySacrificeStand.updateEntity(TileEntitySacrificeStand.java:93)
at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:184)

 

@

                                    if (StandRecipeHandler.sacrifice.isInstance(entityLivingBases.get(i))) {

 

Here is the entire updated te..

  if (recipe.isSacrifice) {
                        List<EntityLivingBase> entityLivingBases = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(this.getPos().getX() - 3, this.getPos().getY() - 3, this.getPos().getY() - 3, this.getPos().getX() + 3, this.getPos().getY() + 3, this.getPos().getZ() + 3));
                        for (int i = 0; i < entityLivingBases.size(); i++) {
                            if (entityLivingBases.get(i) != null) {
                                if (modifierStands != null) {
                                    if (StandRecipeHandler.sacrifice.isInstance(entityLivingBases.get(i))) {
                                        this.recipeForRenderIndex = PlentifulMiscAPI.STAND_RECIPES.indexOf(recipe);
                                        this.processTime++;
                                        boolean done = this.processTime >= recipe.time;

                                        EntityLivingBase entityNear = entityLivingBases.get(i);

                                        //So it cannot be killed / moved during the sacrifice.
                                        entityNear.setHealth(9999f);

                                        for (TileEntityDisplayStand stand : modifierStands) {

                                            if (done) {
                                                stand.slots.decrStackSize(0, 1);
                                            }
                                        }

                                        if (this.processTime % 5 == 0 && this.worldObj instanceof WorldServer) {
                                            boolean almostDone = this.processTime + 40 >= recipe.time;
                                            if (!almostDone) {
                                                ((WorldServer) this.worldObj).spawnParticle(EnumParticleTypes.PORTAL, false, this.pos.getX() + .5, this.pos.getY() + 1, this.pos.getZ() + .5, 10, 0, 0, 0, 0.5D);
                                            }
                                        }

                                        ((WorldServer) this.worldObj).spawnParticle(EnumParticleTypes.CRIT_MAGIC, false, entityNear.posX, entityNear.posY, entityNear.posZ, 10, 0, 0, 0, 10D);


                                        if (lineMode) {
                                            this.drawDamageLaser(this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f});
                                            this.drawDamageLaser(this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f});
                                            this.drawDamageLaser(this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() + 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f});
                                            this.drawDamageLaser(this.pos.getX() - 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, this.pos.getX() + 6.5, this.pos.getY() + .75, this.pos.getZ() - 6.5, new float[]{0f / 255f, 50f / 255f, 255f / 255f});
                                        }

                                        if (done) {
                                            ((WorldServer) this.worldObj).spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, false, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 100, 0, 0, 0, 0.25D);

                                            //ensure the sacrifice dies.
                                            entityNear.setHealth(0.1f);

                                            entityNear.attackEntityFrom(DamageSource.lightningBolt, 10f);
                                            this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, entityNear.getPosition().getX(), entityNear.getPosition().getY(), entityNear.getPosition().getZ(), false));
                                            this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.pos.getX(), this.pos.getY(), this.pos.getZ(), false));

                                            this.slots.setStackInSlot(0, recipe.output.copy());
                                            this.markDirty();

                                            this.processTime = 0;
                                            this.recipeForRenderIndex = -1;
                                        }

                                        break;
                                    } else {
                                        this.processTime = 0;
                                        this.recipeForRenderIndex = -1;
                                    }
                                }
                            }
                        }
                    }

 

Thanks..

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

What is recipe.isSacrifice and what if recipe.sacrifice is null? And instead of getting and checking instances, why not just do

World.getEntitiesWithinAABB(recipe.sacrifice, aabb); 
//aabb should just be a variable instead of a new one everytime. Which you would initialize in the onLoad (I believe that is the name)method.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.