Fixed a bug with the game sometimes crashing when looking at a block with the manual in hand

This should actually fix it.
This commit is contained in:
Ellpeck 2016-07-08 19:08:54 +02:00
parent 41a78d0399
commit a315acc50d
2 changed files with 3 additions and 7 deletions

View file

@ -136,9 +136,7 @@ public class ClientEvents{
if(stack != null){ if(stack != null){
if(stack.getItem() instanceof IHudDisplay){ if(stack.getItem() instanceof IHudDisplay){
profiler.startSection("ItemHudDisplay"); profiler.startSection("ItemHudDisplay");
if(minecraft.theWorld != null){ ((IHudDisplay)stack.getItem()).displayHud(minecraft, player, stack, posHit, profiler, event.getResolution());
((IHudDisplay)stack.getItem()).displayHud(minecraft, player, stack, posHit, profiler, event.getResolution());
}
profiler.endSection(); profiler.endSection();
} }
} }
@ -149,9 +147,7 @@ public class ClientEvents{
if(blockHit instanceof IHudDisplay){ if(blockHit instanceof IHudDisplay){
profiler.startSection("BlockHudDisplay"); profiler.startSection("BlockHudDisplay");
if(minecraft.theWorld != null){ ((IHudDisplay)blockHit).displayHud(minecraft, player, stack, posHit, profiler, event.getResolution());
((IHudDisplay)blockHit).displayHud(minecraft, player, stack, posHit, profiler, event.getResolution());
}
profiler.endSection(); profiler.endSection();
} }

View file

@ -98,7 +98,7 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{
@Override @Override
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, Profiler profiler, ScaledResolution resolution){ public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, Profiler profiler, ScaledResolution resolution){
if(posHit != null){ if(posHit != null && posHit.getBlockPos() != null){
IBlockState state = minecraft.theWorld.getBlockState(posHit.getBlockPos()); IBlockState state = minecraft.theWorld.getBlockState(posHit.getBlockPos());
Block block = state.getBlock(); Block block = state.getBlock();
if(block != null && !block.isAir(minecraft.theWorld.getBlockState(posHit.getBlockPos()), minecraft.theWorld, posHit.getBlockPos())){ if(block != null && !block.isAir(minecraft.theWorld.getBlockState(posHit.getBlockPos()), minecraft.theWorld, posHit.getBlockPos())){