December 19, 20168 yr Author 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
December 19, 20168 yr 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.
December 19, 20168 yr Author It works now, will change the aabb thing. Thanks. Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
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.