Repository: mekanism/mekanism
Issue: [Issue] Tesselating block model

Hi,

Random client crash when i'm in my base, it seems to begin to happen since i've built a boiler.

Crash log : http://pastebin.com/qQqD8yf6


Changed files:
src/main/java/mekanism/generators/common/GeneratorsItems.java, src/main/java/mekanism/common/block/BlockMachine.java, src/main/java/mekanism/generators/common/block/BlockReactor.java, src/main/java/mekanism/common/block/BlockGlowPanel.java, src/main/java/mekanism/common/block/BlockGasTank.java, src/main/java/mekanism/common/block/BlockPlastic.java, src/main/java/mekanism/generators/common/block/BlockGenerator.java, src/main/java/mekanism/common/block/BlockBasic.java, src/main/java/mekanism/common/block/BlockTransmitter.java, src/main/java/mekanism/common/block/BlockEnergyCube.java, src/main/java/mekanism/common/util/MekanismUtils.java

diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java
index 6be823ca10..f420ff9d59 100644
--- a/src/main/java/mekanism/common/block/BlockBasic.java
+++ b/src/main/java/mekanism/common/block/BlockBasic.java
@@ -158,8 +158,8 @@ public abstract class BlockBasic extends Block implements ICTMBlock
 	@Override
 	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
 	{
-		TileEntity tile = worldIn.getTileEntity(pos);
-		
+		TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos);
+
 		if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null)
 		{
 			state = state.withProperty(BlockStateFacing.facingProperty, ((TileEntityBasicBlock)tile).facing);
@@ -344,7 +344,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
 						return false;
 					case 9:
 					case 11:
-						TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)world.getTileEntity(pos);
+						TileEntityDynamicTank tileEntity = (TileEntityDynamicTank) MekanismUtils.getTileEntitySafe(world, pos);
 
 						if(tileEntity != null)
 						{
@@ -372,7 +372,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
 					case 2:
 					case 7:
 					case 8:
-						TileEntityMultiblock tileEntity = (TileEntityMultiblock)world.getTileEntity(pos);
+						TileEntityMultiblock tileEntity = (TileEntityMultiblock) MekanismUtils.getTileEntitySafe(world, pos);
 
 						if(tileEntity != null)
 						{
@@ -716,7 +716,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
 	@Override
 	public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos)
 	{
-		TileEntity tileEntity = world.getTileEntity(pos);
+		TileEntity tileEntity = MekanismUtils.getTileEntitySafe(world, pos);
 		int metadata = state.getBlock().getMetaFromState(state);
 
 		if(tileEntity instanceof IActiveState)
@@ -1044,4 +1044,4 @@ public abstract class BlockBasic extends Block implements ICTMBlock
 	{
 		return BasicBlockType.get(world.getBlockState(pos)).isBeaconBase;
 	}
-}
\\ No newline at end of file
+}
diff --git a/src/main/java/mekanism/common/block/BlockEnergyCube.java b/src/main/java/mekanism/common/block/BlockEnergyCube.java
index b2afc48576..45d337ab6b 100644
--- a/src/main/java/mekanism/common/block/BlockEnergyCube.java
+++ b/src/main/java/mekanism/common/block/BlockEnergyCube.java
@@ -87,7 +87,7 @@ public class BlockEnergyCube extends BlockContainer
 	@Override
 	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
 	{
-		TileEntity tile = worldIn.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos);
 		
 		if(tile instanceof TileEntityEnergyCube)
 		{
diff --git a/src/main/java/mekanism/common/block/BlockGasTank.java b/src/main/java/mekanism/common/block/BlockGasTank.java
index 64297680fa..f30c2c5c93 100644
--- a/src/main/java/mekanism/common/block/BlockGasTank.java
+++ b/src/main/java/mekanism/common/block/BlockGasTank.java
@@ -74,7 +74,7 @@ public class BlockGasTank extends BlockContainer
 	@Override
 	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
 	{
-		TileEntity tile = worldIn.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos);
 		
 		if(tile instanceof TileEntityGasTank)
 		{
diff --git a/src/main/java/mekanism/common/block/BlockGlowPanel.java b/src/main/java/mekanism/common/block/BlockGlowPanel.java
index 0480378b6a..7aeea339d0 100644
--- a/src/main/java/mekanism/common/block/BlockGlowPanel.java
+++ b/src/main/java/mekanism/common/block/BlockGlowPanel.java
@@ -9,6 +9,7 @@ import mekanism.common.block.property.PropertyColor;
 import mekanism.common.block.states.BlockStateFacing;
 import mekanism.common.block.states.BlockStateGlowPanel;
 import mekanism.common.tile.TileEntityGlowPanel;
+import mekanism.common.util.MekanismUtils;
 import mekanism.common.util.MultipartUtils;
 import net.minecraft.block.Block;
 import net.minecraft.block.ITileEntityProvider;
@@ -71,7 +72,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider
 	@Override
 	public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
 	{
-		TileEntityGlowPanel tileEntity = (TileEntityGlowPanel)world.getTileEntity(pos);
+		TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySafe(world, pos);
 		return tileEntity != null ? state.withProperty(BlockStateFacing.facingProperty, tileEntity.side) : state;
 	}
 
@@ -79,8 +80,8 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider
     @Override
     public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) 
 	{
-		TileEntityGlowPanel tileEntity = (TileEntityGlowPanel)world.getTileEntity(pos);
-		
+		TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySafe(world, pos);
+
 		if(tileEntity != null)
 		{
 			state = state.withProperty(BlockStateFacing.facingProperty, tileEntity.side);
@@ -117,7 +118,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider
 	@Override
 	public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor)
 	{
-		TileEntityGlowPanel tileEntity = (TileEntityGlowPanel)world.getTileEntity(pos);
+		TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySafe(world, pos);
 		
 		if(!tileEntity.getWorld().isRemote && !canStay(tileEntity))
 		{			
@@ -137,7 +138,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider
 	@Override
 	public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
 	{
-		TileEntity tile = world.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos);
 		
 		if(tile != null && tile instanceof TileEntityGlowPanel)
 		{
diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java
index 6529f9ed9e..b29cee2430 100644
--- a/src/main/java/mekanism/common/block/BlockMachine.java
+++ b/src/main/java/mekanism/common/block/BlockMachine.java
@@ -206,7 +206,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
 	@Override
 	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
 	{
-		TileEntity tile = worldIn.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos);
 		
 		if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null)
 		{
@@ -383,7 +383,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
 	{
 		if(client.enableAmbientLighting)
 		{
-			TileEntity tileEntity = world.getTileEntity(pos);
+			TileEntity tileEntity = MekanismUtils.getTileEntitySafe(world, pos);
 
 			if(tileEntity instanceof IActiveState)
 			{
@@ -992,7 +992,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
 	public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
 	{
 		MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state));
-		TileEntity tile = world.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos);
 		
 		if(type == null)
 		{
@@ -1025,12 +1025,6 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
     {
         return false;
     }
-	
-	@Override
-	public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
-	{
-		return super.getCollisionBoundingBox(state, world, pos);
-	}
 
 	@Override
 	public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side)
@@ -1111,7 +1105,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
 	@Override
 	public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side)
     {
-		TileEntity tile = world.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos);
 		
 		if(tile instanceof TileEntityLaserAmplifier)
 		{
diff --git a/src/main/java/mekanism/common/block/BlockPlastic.java b/src/main/java/mekanism/common/block/BlockPlastic.java
index 4b10f95f49..43061a2ab5 100644
--- a/src/main/java/mekanism/common/block/BlockPlastic.java
+++ b/src/main/java/mekanism/common/block/BlockPlastic.java
@@ -14,9 +14,7 @@ import net.minecraft.item.EnumDyeColor;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
 import net.minecraft.util.NonNullList;
-import net.minecraft.util.math.AxisAlignedBB;
 import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.Vec3d;
 import net.minecraft.world.IBlockAccess;
 import net.minecraft.world.World;
 import net.minecraftforge.fml.relauncher.Side;
diff --git a/src/main/java/mekanism/common/block/BlockTransmitter.java b/src/main/java/mekanism/common/block/BlockTransmitter.java
index 7b094a3fd5..2600250994 100644
--- a/src/main/java/mekanism/common/block/BlockTransmitter.java
+++ b/src/main/java/mekanism/common/block/BlockTransmitter.java
@@ -95,7 +95,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider
 	@Override
 	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
 	{
-		TileEntity tile = worldIn.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos);
 		
 		if(tile instanceof TileEntitySidedPipe)
 		{
@@ -129,7 +129,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider
     @Override
     public IBlockState getExtendedState(IBlockState state, IBlockAccess w, BlockPos pos) 
 	{
-		TileEntitySidedPipe tile = (TileEntitySidedPipe)w.getTileEntity(pos);
+		TileEntitySidedPipe tile = (TileEntitySidedPipe) MekanismUtils.getTileEntitySafe(w, pos);
 		
 		if(tile != null)
 		{
@@ -147,7 +147,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider
 	@Override
 	public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
 	{
-		TileEntity tile = world.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos);
 		
 		if(tile instanceof TileEntitySidedPipe && ((TileEntitySidedPipe)tile).getTransmitterType().getSize() == Size.SMALL)
 		{
@@ -301,7 +301,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider
 	@Override
 	public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor)
 	{
-		TileEntitySidedPipe tile = (TileEntitySidedPipe)world.getTileEntity(pos);
+		TileEntitySidedPipe tile = (TileEntitySidedPipe) MekanismUtils.getTileEntitySafe(world, pos);
 		EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ());
 		tile.onNeighborTileChange(side);
 	}
diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java
index cdb259d814..c3abcca998 100644
--- a/src/main/java/mekanism/common/util/MekanismUtils.java
+++ b/src/main/java/mekanism/common/util/MekanismUtils.java
@@ -82,9 +82,11 @@ import net.minecraft.util.math.BlockPos;
 import net.minecraft.util.math.RayTraceResult;
 import net.minecraft.util.math.Vec3d;
 import net.minecraft.util.text.TextComponentString;
+import net.minecraft.world.ChunkCache;
 import net.minecraft.world.EnumSkyBlock;
 import net.minecraft.world.IBlockAccess;
 import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
 import net.minecraftforge.fluids.BlockFluidBase;
 import net.minecraftforge.fluids.Fluid;
 import net.minecraftforge.fluids.FluidRegistry;
@@ -1526,4 +1528,9 @@ public final class MekanismUtils
 			return prefix + "/";
 		}
 	}
+
+	public static TileEntity getTileEntitySafe(IBlockAccess worldIn, BlockPos pos)
+	{
+		return worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos);
+	}
 }
diff --git a/src/main/java/mekanism/generators/common/GeneratorsItems.java b/src/main/java/mekanism/generators/common/GeneratorsItems.java
index af3d46d507..70e8fe0f34 100644
--- a/src/main/java/mekanism/generators/common/GeneratorsItems.java
+++ b/src/main/java/mekanism/generators/common/GeneratorsItems.java
@@ -1,6 +1,7 @@
 package mekanism.generators.common;
 
 import mekanism.common.item.ItemMekanism;
+import mekanism.common.util.MekanismUtils;
 import mekanism.generators.common.item.ItemHohlraum;
 import mekanism.generators.common.tile.turbine.TileEntityTurbineRotor;
 import net.minecraft.entity.player.EntityPlayer;
@@ -20,7 +21,7 @@ public class GeneratorsItems
 		@Override
 		public boolean doesSneakBypassUse(ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player)
 		{
-			return world.getTileEntity(pos) instanceof TileEntityTurbineRotor;
+			return MekanismUtils.getTileEntitySafe(world, pos) instanceof TileEntityTurbineRotor;
 		}
 	};
 
diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java
index 03976ab9af..a02c398a5d 100644
--- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java
+++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java
@@ -169,7 +169,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
 	@Override
 	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
 	{
-		TileEntity tile = worldIn.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos);
 		
 		if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null)
 		{
@@ -254,7 +254,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
 	{
 		if(client.enableAmbientLighting)
 		{
-			TileEntity tileEntity = world.getTileEntity(pos);
+			TileEntity tileEntity = MekanismUtils.getTileEntitySafe(world, pos);
 
 			if(tileEntity instanceof IActiveState && !(tileEntity instanceof TileEntitySolarGenerator))
 			{
diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java
index 00d86b3057..dea26a93be 100644
--- a/src/main/java/mekanism/generators/common/block/BlockReactor.java
+++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java
@@ -75,7 +75,7 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti
 	@Override
 	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
 	{
-		TileEntity tile = worldIn.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos);
 		
 		if(tile instanceof TileEntityReactorController)
 		{
@@ -293,7 +293,7 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti
 	@Override
 	public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side)
     {
-		TileEntity tile = world.getTileEntity(pos);
+		TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos);
 		
 		if(tile instanceof TileEntityReactorLogicAdapter)
 		{