Flawn_ Posted February 5, 2017 Posted February 5, 2017 Hello everyone, I want to render the Inventory Player to the main Menu but it makes problems. Description: Initializing game java.lang.NullPointerException: Initializing game at net.minecraft.client.gui.inventory.GuiInventory.drawEntityOnScreen(GuiInventory.java:103) at net.minecraft.client.gui.GuiMainMenu.initGui(GuiMainMenu.java:213) at net.minecraft.client.gui.GuiScreen.setWorldAndResolution(GuiScreen.java:556) at net.minecraft.client.Minecraft.displayGuiScreen(Minecraft.java:1011) at net.minecraft.client.Minecraft.startGame(Minecraft.java:575) at net.minecraft.client.Minecraft.run(Minecraft.java:402) at net.minecraft.client.main.Main.main(Main.java:114) at Start.main(Start.java:11) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.client.gui.inventory.GuiInventory.drawEntityOnScreen(GuiInventory.java:103) at net.minecraft.client.gui.GuiMainMenu.initGui(GuiMainMenu.java:213) at net.minecraft.client.gui.GuiScreen.setWorldAndResolution(GuiScreen.java:556) at net.minecraft.client.Minecraft.displayGuiScreen(Minecraft.java:1011) at net.minecraft.client.Minecraft.startGame(Minecraft.java:575) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:402) at net.minecraft.client.main.Main.main(Main.java:114) at Start.main(Start.java:11) -- System Details -- Details: Minecraft Version: 1.8 Operating System: Mac OS X (x86_64) version 10.12.1 Java Version: 1.8.0_91, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 870970032 bytes (830 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 Launched Version: mcp LWJGL: 2.9.1 OpenGL: Intel(R) Iris(TM) Graphics 6100 GL version 2.1 INTEL-10.20.23, Intel Inc. GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because ARB_framebuffer_object is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: No Is Modded: Definitely; Client brand changed to 'Cose' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) #@!@# Game crashed! Crash report saved to: #@!@# /Users/nevinpeters/Documents/Cose/jars/./crash-reports/crash-2017-02-05_14.09.16-client.txt AL lib: (EE) alc_cleanup: 1 device not closed It makes Problems here: public static void drawEntityOnScreen(int x, int y, int scale, float mouseX, float mouseY, EntityLivingBase entity) { GlStateManager.enableColorMaterial(); GlStateManager.pushMatrix(); GlStateManager.translate((float)x, (float)y, 50.0F); GlStateManager.scale((float)(-scale), (float)scale, (float)scale); GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); //here float var6 = entity.renderYawOffset; float var7 = entity.rotationYaw; float var8 = entity.rotationPitch; float var9 = entity.prevRotationYawHead; float var10 = entity.rotationYawHead; GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(-((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); entity.renderYawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F; entity.rotationYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F; entity.rotationPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F; entity.rotationYawHead = entity.rotationYaw; entity.prevRotationYawHead = entity.rotationYaw; GlStateManager.translate(0.0F, 0.0F, 0.0F); RenderManager var11 = Minecraft.getMinecraft().getRenderManager(); var11.func_178631_a(180.0F); var11.func_178633_a(false); var11.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); var11.func_178633_a(true); entity.renderYawOffset = var6; entity.rotationYaw = var7; entity.rotationPitch = var8; entity.prevRotationYawHead = var9; entity.rotationYawHead = var10; GlStateManager.popMatrix(); RenderHelper.disableStandardItemLighting(); GlStateManager.disableRescaleNormal(); GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.func_179090_x(); GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); } Quote
Flawn_ Posted February 5, 2017 Author Posted February 5, 2017 In GuiMainScreen i gave it so: EntityLivingBase elb = mc.thePlayer; [...] GuiInventory.drawEntityOnScreen(ex, ey, 30, (float)(ex) - GuiInventory.oldMouseX, (float)(ey) - GuiInventory.oldMouseY, elb); Quote
Kokkie Posted February 5, 2017 Posted February 5, 2017 That is null until you join a world... I think But what is mc? Quote Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
Flawn_ Posted February 5, 2017 Author Posted February 5, 2017 mc is Minecraft(). Isnt there a possibility that i can render it ? Has somebody a workaround? Quote
Kokkie Posted February 5, 2017 Posted February 5, 2017 I guess Minecraft.getMinecraft()? Also, can you show your full code instead of little pieces? Quote Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
Flawn_ Posted February 5, 2017 Author Posted February 5, 2017 Here is the Part where it is called (GuiMainMenu) public void initGui() { int sx = (int) (width * 0.025); int sy = (int) ( height * 0.25); int ex = width / 2 - 150; EntityLivingBase elb = mc.thePlayer; EntityPlayerSP player = new EntityPlayerSP(); int ey = height / 2 - 150; int swidth = 80 * (int) (width / 427.0); int sheight = 150 * (int) (height / 150.0); updateList = new GuiScrollList(sx, sy, swidth, sheight, 1073741823, "Updates", InfoUpdates.lines, true); GuiInventory.drawEntityOnScreen(ex, ey, 30, (float)(ex) - GuiInventory.oldMouseX, (float)(ey) - GuiInventory.oldMouseY, player); [...] } Quote
Flawn_ Posted February 5, 2017 Author Posted February 5, 2017 (edited) How do you make that? I would make to it also a Skin Edited February 5, 2017 by Flawn_ Quote
Kokkie Posted February 5, 2017 Posted February 5, 2017 5 minutes ago, diesieben07 said: You will need to create a fake player to render, if you are not in the world yet there is no player. Jay, I said something right Quote Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
Flawn_ Posted February 5, 2017 Author Posted February 5, 2017 4 hours ago, diesieben07 said: You will need to create a fake player to render, if you are not in the world yet there is no player. But how? Pls say it Quote
Draco18s Posted February 5, 2017 Posted February 5, 2017 How do you know what inventory to render? Each save has a different player profile, with a different inventory... Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Flawn_ Posted February 5, 2017 Author Posted February 5, 2017 No i ment the Player left above the inv. Quote
Swedz Posted February 7, 2017 Posted February 7, 2017 On 2/6/2017 at 10:07 AM, TheSunCat said: That makes more sense... Look at how it's done in the Inventory Gui. That could give you a hint. I have never personally done this myself, as I am not skilled in rendering (I have had a LOT of trouble with simple directional blocks... :P), but I believe that the Inventory Gui has the code for rendering the player. Just use that with a fake player. Basically, FakePlayer fakePlayer = new FakePlayer(argumentsHere); FakePlayer requires a world argument, and if it's null, it will output an NPE. Quote
Flawn_ Posted February 7, 2017 Author Posted February 7, 2017 Yes, but even when i render it in the world it gives me a black screen if i have something in the hand .-. Quote
Recommended Posts
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.