From 45d30b82deecb4e1e21cf3bf517c9280309c56b4 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 27 Nov 2016 12:29:29 +0100 Subject: [PATCH] Check if the block is loaded when spawning a firework Supposedly closes #416 --- .../actuallyadditions/mod/tile/TileEntityFireworkBox.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java index 6b929d627..d726d0a8d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java @@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.energy.IEnergyStorage; @@ -40,8 +41,11 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp double newX = x+MathHelper.nextDouble(this.world.rand, 0, range*2)-range; double newZ = z+MathHelper.nextDouble(this.world.rand, 0, range*2)-range; - EntityFireworkRocket rocket = new EntityFireworkRocket(world, newX, y+0.5, newZ, firework); - world.spawnEntity(rocket); + + if(world.isBlockLoaded(new BlockPos(newX, y, newZ))){ + EntityFireworkRocket rocket = new EntityFireworkRocket(world, newX, y+0.5, newZ, firework); + world.spawnEntity(rocket); + } } }