Краш при рендере obj предмета.

Версия Minecraft
1.12.2
32
1
7
ClientProxy
Java:
package vados.mod.proxy;


import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import vados.mod.models.obj.TileEntityCustomRenderer;
import vados.mod.util.handllers.RegistryHandler;

public class ClientProxy extends CommonProxy
{   
    
    
    @Override
        public void preInit(FMLPreInitializationEvent event)
        {
            super.preInit(event);
            RegistryHandler.ObjItem.setTileEntityItemStackRenderer(TileEntityCustomRenderer.instance);
        }

        @Override
        public void init(FMLInitializationEvent event)
        {
            super.init(event);
        }

        @Override
        public void postInit(FMLPostInitializationEvent event)
        {
            super.postInit(event);
        }
        

}
TileEntityCustomRenderer
Java:
package vados.mod.models.obj;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

public class TileEntityCustomRenderer extends TileEntityItemStackRenderer
{
    
public static TileEntityCustomRenderer instance;
private final ObjectObj drawobj = new ObjectObj(new ResourceLocation("modid:models/obj/super_puper_obj.obj"));
ResourceLocation SUPER_PUPER_OBJ_TEXTURE = new ResourceLocation("modid:items/super_puper_texture.png");

TileEntityCustomRenderer() {}

@Override
public void renderByItem(ItemStack itemStack, float partialTicks) {
    Minecraft.getMinecraft().renderEngine.bindTexture(SUPER_PUPER_OBJ_TEXTURE);
    drawobj.draw();
    }

    static {
        instance = new TileEntityCustomRenderer();
    }
}
 
Краш-лог
---- Minecraft Crash Report ----
// Who set us up the TNT?

Time: 8/2/20 8:57 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from vados (vados)
Caused by: java.lang.ExceptionInInitializerError
at vados.mod.proxy.ClientProxy.preInit(ClientProxy.java:17)
at vados.mod.Main.preInit(Main.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:639)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
at com.google.common.eventbus.EventBus.post(EventBus.java:217)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
at com.google.common.eventbus.EventBus.post(EventBus.java:217)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:629)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
at net.minecraft.client.Minecraft.init(Minecraft.java:467)
at net.minecraft.client.Minecraft.run(Minecraft.java:378)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.legacydev.Main.start(Main.java:86)
at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)
Caused by: java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:78)
at java.io.InputStreamReader.<init>(InputStreamReader.java:72)
at vados.mod.models.obj.ObjectObj.<init>(ObjectObj.java:33)
at vados.mod.models.obj.TileEntityCustomRenderer.<init>(TileEntityCustomRenderer.java:12)
at vados.mod.models.obj.TileEntityCustomRenderer.<clinit>(TileEntityCustomRenderer.java:24)
... 49 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
Minecraft Version: 1.12.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_231, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 116552152 bytes (111 MB) / 460849152 bytes (439 MB) up to 1897922560 bytes (1810 MB)
JVM Flags: 0 total;
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP 9.42 Powered by Forge 14.23.5.2854 5 mods loaded, 5 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

| State | ID | Version | Source | Signature |
|:----- |:--------- |:------------ |:------------------------------------------------------------------ |:--------- |
| LCH | minecraft | 1.12.2 | minecraft.jar | None |
| LCH | mcp | 9.42 | minecraft.jar | None |
| LCH | FML | 8.0.99.99 | forge-1.12.2-14.23.5.2854_mapped_snapshot_20171003-1.12-recomp.jar | None |
| LCH | forge | 14.23.5.2854 | forge-1.12.2-14.23.5.2854_mapped_snapshot_20171003-1.12-recomp.jar | None |
| LCE | vados | 1.0 | main | None |

Loaded coremods (and transformers):
GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.6.13587 Compatibility Profile Context 20.4.2 26.20.15029.27017' Renderer: 'Radeon RX 560 Series'
Краш-лог:
---- Minecraft Crash Report ----
// Who set us up the TNT?

Time: 8/2/20 8:57 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from vados (vados)
Caused by: java.lang.ExceptionInInitializerError
	at vados.mod.proxy.ClientProxy.preInit(ClientProxy.java:17)
	at vados.mod.Main.preInit(Main.java:26)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:639)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:629)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
	at net.minecraft.client.Minecraft.init(Minecraft.java:467)
	at net.minecraft.client.Minecraft.run(Minecraft.java:378)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraftforge.legacydev.Main.start(Main.java:86)
	at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29)
Caused by: java.lang.NullPointerException
	at java.io.Reader.<init>(Reader.java:78)
	at java.io.InputStreamReader.<init>(InputStreamReader.java:72)
	at vados.mod.models.obj.ObjectObj.<init>(ObjectObj.java:33)
	at vados.mod.models.obj.TileEntityCustomRenderer.<init>(TileEntityCustomRenderer.java:12)
	at vados.mod.models.obj.TileEntityCustomRenderer.<clinit>(TileEntityCustomRenderer.java:24)
	... 49 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_231, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 116552152 bytes (111 MB) / 460849152 bytes (439 MB) up to 1897922560 bytes (1810 MB)
	JVM Flags: 0 total; 
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.42 Powered by Forge 14.23.5.2854 5 mods loaded, 5 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

	| State | ID        | Version      | Source                                                             | Signature |
	|:----- |:--------- |:------------ |:------------------------------------------------------------------ |:--------- |
	| LCH   | minecraft | 1.12.2       | minecraft.jar                                                      | None      |
	| LCH   | mcp       | 9.42         | minecraft.jar                                                      | None      |
	| LCH   | FML       | 8.0.99.99    | forge-1.12.2-14.23.5.2854_mapped_snapshot_20171003-1.12-recomp.jar | None      |
	| LCH   | forge     | 14.23.5.2854 | forge-1.12.2-14.23.5.2854_mapped_snapshot_20171003-1.12-recomp.jar | None      |
	| LCE   | vados     | 1.0          | main                                                               | None      |

	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.6.13587 Compatibility Profile Context 20.4.2 26.20.15029.27017' Renderer: 'Radeon RX 560 Series'
7,099
324
1,509
Чо за класс такой - ObjectObj?
 
32
1
7
Строка же написана в ошибке, у тебя или в main
Main:
package vados.mod;

import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import vados.mod.proxy.CommonProxy;
import vados.mod.util.Reference;

@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION)
public class Main
{
    
        @Instance
        public static Main instance;
        
        @SidedProxy(clientSide = Reference.CLIENT, serverSide = Reference.COMMON)
        public static CommonProxy proxy;
        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event)
        {
            proxy.preInit(event);   
        }

        @EventHandler
        public void init(FMLInitializationEvent event)
        {
            proxy.init(event);
        }
        
        @EventHandler
        public void postInit(FMLPostInitializationEvent event)
        {
            proxy.postInit(event);
        }
    }

если строки соответствуют
Краш Лог не тот скинул, там указывает ошибку на 18 строку, а т.е на RegistryHandler.ObjItem.setTileEntityItemStackRenderer(TileEntityCustomRenderer.instance);


Чо за класс такой - ObjectObj?
Это загрузчик тут у одного человека я видел тему и он скинул свой загрузчик написанный, решил его и использовать

ObjectObj:
package vados.mod.models.obj;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector3f;

import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;

public class ObjectObj {

    Model ObjModel = new Model();

    ResourceLocation model;
    public ObjectObj(ResourceLocation model) {
        this.model = model;

        InputStream in = null;
        {
            try {
                in = Minecraft.getMinecraft().getResourceManager().getResource(model).getInputStream();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        String line;

        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        {
            try {
//Сам парсер
                while((line = reader.readLine())!= null)
                {
                    if(line.startsWith("v ")) {
                        float x = Float.valueOf(line.split(" ")[1]);
                        float y = Float.valueOf(line.split(" ")[2]);
                        float z = Float.valueOf(line.split(" ")[3]);
                        ObjModel.vertices.add(new Vector3f(x,y,z));
                    }

                    else if (line.startsWith("vn ")) {
                        float x = Float.valueOf(line.split(" ")[1]);
                        float y = Float.valueOf(line.split(" ")[2]);
                        float z = Float.valueOf(line.split(" ")[3]);
                        ObjModel.normals.add(new Vector3f(x,y,z));
                    }

                    //Тут парсер с текстурой
                    else if (line.startsWith("vt ")) {
                        float x = Float.valueOf(line.split(" ")[1]);
                        float y = Float.valueOf(line.split(" ")[2]);
                        ObjModel.uv.add(new Vector3f(x,y,0));
                    }

                    else if(line.startsWith("f ")) {
                        Vector3f vertexIndices = new Vector3f(
                                Float.valueOf(line.split(" ")[1].split("/")[0]),
                                Float.valueOf(line.split(" ")[2].split("/")[0]),
                                Float.valueOf(line.split(" ")[3].split("/")[0]));

                        Vector3f normalIndices = new Vector3f(
                                Float.valueOf(line.split(" ")[1].split("/")[2]),
                                Float.valueOf(line.split(" ")[2].split("/")[2]),
                                Float.valueOf(line.split(" ")[3].split("/")[2]));

                        Vector3f uvIndices = new Vector3f(
                                Float.valueOf(line.split(" ")[1].split("/")[1]),
                                Float.valueOf(line.split(" ")[2].split("/")[1]),
                                Float.valueOf(line.split(" ")[3].split("/")[1]));

                        ObjModel.faces.add(new Face(vertexIndices,uvIndices,normalIndices));
                    }

                }

            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }





    public void draw() {
    GL11.glBegin(GL11.GL_TRIANGLES);


    for(Face face : ObjModel.faces) {
        Vector3f n1 = ObjModel.normals.get((int) face.normal.x - 1);
        GL11.glNormal3f(n1.x,n1.y,n1.z);
        Vector3f uv1 = ObjModel.uv.get((int) face.uv.x - 1);
        GL11.glTexCoord2f(uv1.x, uv1.y);
        Vector3f v1 = ObjModel.vertices.get((int) face.vertex.x - 1);
        GL11.glVertex3f(v1.x,v1.y,v1.z);



        Vector3f n2 = ObjModel.normals.get((int) face.normal.y - 1);
        GL11.glNormal3f(n2.x,n2.y,n2.z);
        Vector3f uv2 = ObjModel.uv.get((int) face.uv.y - 1);
        GL11.glTexCoord2f(uv2.x, uv2.y);
        Vector3f v2 = ObjModel.vertices.get((int) face.vertex.y - 1);
        GL11.glVertex3f(v2.x,v2.y,v2.z);



        Vector3f n3 = ObjModel.normals.get((int) face.normal.z - 1);
        GL11.glNormal3f(n3.x,n3.y,n3.z);
        Vector3f uv3 = ObjModel.uv.get((int) face.uv.z - 1);
        GL11.glTexCoord2f(uv3.x, uv3.y);
        Vector3f v3 = ObjModel.vertices.get((int) face.vertex.z - 1);
        GL11.glVertex3f(v3.x,v3.y,v3.z);

    }

        GL11.glEnd();


    }


}
 
137
7
37
Я специально поискал эту тему, и вот что я обнаружил: ты походу тупо скопипастил и не посмотрел вообще на код.


Java:
private final ObjectObj drawobj = new ObjectObj(new ResourceLocation("modid:models/obj/super_puper_obj.obj"));
ResourceLocation SUPER_PUPER_OBJ_TEXTURE = new ResourceLocation("modid:items/super_puper_texture.png");

В той теме абсолютно такой же путь к файлам, не удивительно почему тебе выкидывает NPE и указывает на строчку с drawobj.
Возможно, я не прав, но, вместо modid: пишешь то значение, которое ты указал в аннотации @mod в параметре modid, т.е если оно "test"

то пишешь "test:folder/to/your/model" впараметре ResourceLocation'a
Файловая иерархия должна быть такой:


YourResFolder/assets/modid/models/obj/super_puper_obj.obj

или же тот, который ты укажешь. Возможно ты даже модель не загрузил
 
32
1
7
В той теме абсолютно такой же путь к файлам, не удивительно почему тебе выкидывает NPE и указывает на строчку с drawobj.
Как и думал проблема была не в этом, всё такая же ошибка. Модель и текстуры у меня загружены по таким же путям
 
Сверху