package com.whammich.sstow.client;

import com.whammich.sstow.iface.IOwnableTile;
import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import tehnut.lib.annot.Handler;

@Handler(client = true)
public class ClientEventHandler {

    @SubscribeEvent
    public void onDebugMenu(RenderGameOverlayEvent.Text event) {
        if (!Minecraft.getMinecraft().gameSettings.showDebugInfo)
            return;

        RayTraceResult rayTrace = Minecraft.getMinecraft().objectMouseOver;
        if (!Minecraft.getMinecraft().thePlayer.isSneaking()) {
            event.getLeft().add(TextFormatting.ITALIC + "Sneak for Ownable information");
            return;
        }

        if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
            TileEntity tileEntity = Minecraft.getMinecraft().theWorld.getTileEntity(rayTrace.getBlockPos());
            if (tileEntity instanceof IOwnableTile) {
                IOwnableTile ownableTile = (IOwnableTile) tileEntity;
                if (ownableTile.getOwnerUUID() != null) {
                    event.getLeft().add("Owner UUID: " + ownableTile.getOwnerUUID());
                    event.getLeft().add("Owner Name: " + Minecraft.getMinecraft().getIntegratedServer().getEntityFromUuid(ownableTile.getOwnerUUID()).getName());
                }
            }
        }
    }
}

@@ -722,16 +722,17 @@
 seOver;%0A
+%0A
         
@@ -739,149 +739,25 @@
 if (
-!Minecraft.getMinecraft().thePlayer.isSneaking()) %7B%0A            event.getLeft().add(TextFormatting.ITALIC + %22Sneak for Ownable information%22);
+rayTrace == null)
 %0A   
@@ -772,26 +772,16 @@
  return;
-%0A        %7D
 %0A%0A      
@@ -942,24 +942,24 @@
 lockPos());%0A
-
             
@@ -996,24 +996,241 @@
 ableTile) %7B%0A
+                if (!Minecraft.getMinecraft().thePlayer.isSneaking()) %7B%0A                    event.getLeft().add(TextFormatting.ITALIC + %22Sneak for Ownable information%22);%0A                    return;%0A                %7D%0A%0A
             

Fix weird debug screen crash