Jump to content

Recommended Posts

Posted

The registry events are preferred, but I noticed this:

 

https://github.com/Corgam/1.12/blob/master/src/main/java/corgam/slavicraft/items/_Items.java#L30

You use the ModelLoader (the more-correct method) here

https://github.com/Corgam/1.12/blob/master/src/main/java/corgam/slavicraft/blocks/_Blocks.java#L47

But use the ModelMesher (the absolutely-worst method) here.

 

WHY. Why would you mix these two methodologies together?

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.

Posted
1 hour ago, diesieben07 said:

Items must be registered in RegistryEvent.Register<Item>, item models must be registered in ModelRegistryEvent.

And how do I use registry events exactly? I would love to see an example, it would help me a lot.

  • 2 weeks later...
Posted

Ok, I after one week break I tried to get it working, but still there is something wrong and I need help to understand it better.

 

Here are my files: 

 

EventHandler class:

Spoiler

package corgam.slavicraft.base.handler;

import corgam.slavicraft.base.init._Items;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class EventHandler {
    
    @SubscribeEvent
    public static void onModelRegistry(ModelRegistryEvent event)
    {
        _Items.registerRenders();
    }

}
 

 

_Items class (ModItems):

Spoiler

package corgam.slavicraft.base.init;

import corgam.slavicraft.base.lib.LibMisc;
import corgam.slavicraft.items.ItemBlankRune;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.ForgeRegistries;

public class _Items {
    
    public static Item blank_rune;
    
    public static void init()
    {
        blank_rune = new ItemBlankRune("blank_rune");
    }
    
    public static void register()
    {
        registerItem(blank_rune);
    }
    
    public static void registerItem(Item item)
    {
        ForgeRegistries.ITEMS.register(item);
        
    //    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, 
    //    new ModelResourceLocation(LibMisc.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
    }
    
    
    public static void registerRenders()
    {
        registerRender(blank_rune);
    }
    
    private static void registerRender(Item item)
    {
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }
    
}

 ItemBlankRune class (class of the item that I try to get the texture working)(extends SlavicraftItem)

Spoiler

package corgam.slavicraft.items;

public class ItemBlankRune extends SlavicraftItem{
    
    public ItemBlankRune(String name){
        super(name);

        
    }

}
 

SlavicraftItem class

Spoiler

package corgam.slavicraft.items;

import corgam.slavicraft.base.Slavicraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class SlavicraftItem extends Item{

    public SlavicraftItem(String name) {
    
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(Slavicraft.slavicrafttab);

    }
    
}
 

 

Posted
7 minutes ago, Corgam said:

but still there is something wrong and I need help to understand it better.

You missed the @EventBusSubscriber annotation at the top of your Event Handler class. AKA

@EventBusSubscriber
public class EventHandler...

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted (edited)
25 minutes ago, Animefan8888 said:

You missed the @EventBusSubscriber annotation at the top of your Event Handler class. AKA


@EventBusSubscriber
public class EventHandler...

 

I added it, but the texture only works when I reload resource packs (F3 + T) and I don't have a clue why.

(btw, what is the difference between @Mod.EventBusSubscriber and @EventBusSubscriber ? )

Edited by Corgam
Posted
Just now, Corgam said:

I added it, but the texture only works when I reload resource packs (F3 + T) and I don't have a clue why.

(btw, what is the difference between @Mod.EventBusSubscriber and @EventBusSubscriber ? )

Nothing, @Mod.EventBusSubscriber is just the whole name. EventBusSubscriber is within the Mod annotation class. Also you need to register your Items and Blocks in the RegistryEvent.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted (edited)

Here you go: https://github.com/Corgam/Items-problem

I tried to add:

 

@SubscribeEvent
    public void registerItems(RegistryEvent.Register<Item> event) {   
        _Items.register();
    }

 

But the game crashes: (there are also some other mods, but I think they don't interfere at all)

Spoiler

2017-07-18 12:55:30,107 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2017-07-18 12:55:30,109 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
[12:55:30] [main/INFO] [GradleStart]: Extra: []
[12:55:30] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/Thermaltake/.gradle/caches/minecraft/assets, --assetIndex, 1.12, --accessToken{REDACTED}, --version, 1.12, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[12:55:30] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[12:55:30] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[12:55:30] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[12:55:30] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[12:55:30] [main/INFO] [FML]: Forge Mod Loader version 14.21.1.2413 for Minecraft 1.12 loading
[12:55:30] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_131, running on Windows 8:amd64:6.2, installed at C:\Program Files\Java\jre1.8.0_131
[12:55:30] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[12:55:30] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
[12:55:30] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
[12:55:30] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[12:55:30] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[12:55:30] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[12:55:30] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[12:55:30] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[12:55:30] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[12:55:30] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
2017-07-18 12:55:30,619 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2017-07-18 12:55:30,947 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2017-07-18 12:55:30,948 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
[12:55:32] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[12:55:32] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[12:55:32] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[12:55:32] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[12:55:32] [main/INFO] [GradleStart]: Remapping AccessTransformer rules...
[12:55:32] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[12:55:32] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[12:55:32] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[12:55:33] [main/INFO]: Setting user: Player281
[12:55:39] [main/WARN]: Skipping bad option: lastServer:
[12:55:39] [main/INFO]: LWJGL Version: 2.9.4
[12:55:40] [main/INFO] [FML]: -- System Details --
Details:
    Minecraft Version: 1.12
    Operating System: Windows 8 (amd64) version 6.2
    Java Version: 1.8.0_131, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 782984040 bytes (746 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: 
    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 372.54' Renderer: 'GeForce GTX 970/PCIe/SSE2'
[12:55:40] [main/INFO] [FML]: MinecraftForge v14.21.1.2413 Initialized
[12:55:40] [main/INFO] [FML]: Replaced 921 ore ingredients
[12:55:40] [main/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer
[12:55:40] [main/INFO] [FML]: Searching E:\Aaa_mods\Slavicraft forge-2413\run\mods for mods
[12:55:42] [main/INFO] [FML]: Forge Mod Loader has identified 10 mods to load
[12:55:42] [Thread-3/INFO] [FML]: Using sync timing. 200 frames of Display.update took 105054210 nanos
[12:55:42] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, slavicraft, waila, jei, jeresources, mantle, natura] at CLIENT
[12:55:42] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, slavicraft, waila, jei, jeresources, mantle, natura] at SERVER
[12:55:44] [main/INFO] [Pulsar-natura]: Skipping Pulse craftingtweaksIntegration; missing dependency: craftingtweaks
[12:55:44] [main/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Slavicraft, FMLFileResourcePack:Waila, FMLFileResourcePack:Just Enough Items, FMLFileResourcePack:Just Enough Resources, FMLFileResourcePack:Mantle, FMLFileResourcePack:Natura
[12:55:44] [main/INFO] [FML]: Processing ObjectHolder annotations
[12:55:44] [main/INFO] [FML]: Found 1168 ObjectHolder annotations
[12:55:44] [main/INFO] [FML]: Identifying ItemStackHolder annotations
[12:55:44] [main/INFO] [FML]: Found 0 ItemStackHolder annotations
[12:55:44] [main/INFO] [FML]: Configured a dormant chunk cache size of 0
[12:55:44] [Forge Version Check/INFO] [ForgeVersionCheck]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[12:55:44] [main/INFO] [jeresources]: Loading configs..
[12:55:44] [main/INFO] [jeresources]: Updating ModMetaData...
[12:55:44] [main/INFO] [jeresources]: Providing API...
[12:55:45] [Forge Version Check/INFO] [ForgeVersionCheck]: [forge] Found status: AHEAD Target: null
[12:55:45] [main/INFO] [Mantle]: Started loading books...
[12:55:45] [main/INFO] [Mantle]: Book loading completed in 1.05354E-4 seconds.
[12:55:45] [main/INFO] [FML]: Applying holder lookups
[12:55:45] [main/INFO] [FML]: Holder lookups applied
[12:55:45] [main/INFO] [FML]: Applying holder lookups
[12:55:45] [main/INFO] [FML]: Holder lookups applied
[12:55:45] [main/INFO] [FML]: Applying holder lookups
[12:55:45] [main/INFO] [FML]: Holder lookups applied
[12:55:45] [main/ERROR] [FML]: Exception caught during firing event net.minecraftforge.client.event.ModelRegistryEvent@4b4eac80:
java.lang.NullPointerException: null
    at corgam.slavicraft.base.init._Items.registerRender(_Items.java:38) ~[_Items.class:?]
    at corgam.slavicraft.base.init._Items.registerRenders(_Items.java:33) ~[_Items.class:?]
    at corgam.slavicraft.base.handler.EventHandler.onModelRegistry(EventHandler.java:18) ~[EventHandler.class:?]
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_EventHandler_onModelRegistry_ModelRegistryEvent.invoke(.dynamic) ~[?:?]
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:143) ~[EventBus$1.class:?]
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) [EventBus.class:?]
    at net.minecraftforge.fml.client.FMLClientHandler.fireSidedRegistryEvents(FMLClientHandler.java:1083) [FMLClientHandler.class:?]
    at net.minecraftforge.fml.common.FMLCommonHandler.fireSidedRegistryEvents(FMLCommonHandler.java:757) [FMLCommonHandler.class:?]
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:606) [Loader.class:?]
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:266) [FMLClientHandler.class:?]
    at net.minecraft.client.Minecraft.init(Minecraft.java:508) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:416) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:26) [start/:?]
[12:55:45] [main/ERROR] [FML]: Index: 1 Listeners:
[12:55:45] [main/ERROR] [FML]: 0: NORMAL
[12:55:45] [main/ERROR] [FML]: 1: net.minecraftforge.fml.common.eventhandler.EventBus$1@7bcbf479
[12:55:45] [main/ERROR] [FML]: 2: net.minecraftforge.fml.common.eventhandler.EventBus$1@29457ad2
[12:55:45] [main/ERROR] [FML]: 3: net.minecraftforge.fml.common.eventhandler.EventBus$1@5a050bf9
[12:55:45] [main/ERROR] [FML]: 4: net.minecraftforge.fml.common.eventhandler.EventBus$1@7b2637fa
[12:55:45] [main/ERROR] [FML]: 5: net.minecraftforge.fml.common.eventhandler.EventBus$1@5fea6cdb
[12:55:45] [main/ERROR] [FML]: 6: net.minecraftforge.fml.common.eventhandler.EventBus$1@5dfb0e1e
[12:55:45] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:630]: ---- Minecraft Crash Report ----
// Sorry :(

Time: 7/18/17 12:55 PM
Description: Initializing game

java.lang.NullPointerException: Initializing game
    at corgam.slavicraft.base.init._Items.registerRender(_Items.java:38)
    at corgam.slavicraft.base.init._Items.registerRenders(_Items.java:33)
    at corgam.slavicraft.base.handler.EventHandler.onModelRegistry(EventHandler.java:18)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_EventHandler_onModelRegistry_ModelRegistryEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:143)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179)
    at net.minecraftforge.fml.client.FMLClientHandler.fireSidedRegistryEvents(FMLClientHandler.java:1083)
    at net.minecraftforge.fml.common.FMLCommonHandler.fireSidedRegistryEvents(FMLCommonHandler.java:757)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:606)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:266)
    at net.minecraft.client.Minecraft.init(Minecraft.java:508)
    at net.minecraft.client.Minecraft.run(Minecraft.java:416)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:26)


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

-- Head --
Thread: Client thread
Stacktrace:
    at corgam.slavicraft.base.init._Items.registerRender(_Items.java:38)
    at corgam.slavicraft.base.init._Items.registerRenders(_Items.java:33)
    at corgam.slavicraft.base.handler.EventHandler.onModelRegistry(EventHandler.java:18)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_EventHandler_onModelRegistry_ModelRegistryEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:143)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179)
    at net.minecraftforge.fml.client.FMLClientHandler.fireSidedRegistryEvents(FMLClientHandler.java:1083)
    at net.minecraftforge.fml.common.FMLCommonHandler.fireSidedRegistryEvents(FMLCommonHandler.java:757)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:606)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:266)
    at net.minecraft.client.Minecraft.init(Minecraft.java:508)

-- Initialization --
Details:
Stacktrace:
    at net.minecraft.client.Minecraft.run(Minecraft.java:416)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:26)

-- System Details --
Details:
    Minecraft Version: 1.12
    Operating System: Windows 8 (amd64) version 6.2
    Java Version: 1.8.0_131, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 750518024 bytes (715 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP 9.40 Powered by Forge 14.21.1.2413 10 mods loaded, 10 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    UCH    minecraft{1.12} [Minecraft] (minecraft.jar) 
    UCH    mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
    UCH    FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.12-14.21.1.2413.jar) 
    UCH    forge{14.21.1.2413} [Minecraft Forge] (forgeSrc-1.12-14.21.1.2413.jar) 
    UCH    slavicraft{1.0} [Slavicraft] (bin) 
    UCH    waila{1.8.19} [Waila] (Hwyla-1.8.19-B33_1.12.jar) 
    UCH    jei{4.7.1.69} [Just Enough Items] (jei_1.12-4.7.1.69.jar) 
    UCH    jeresources{0.8.1.14} [Just Enough Resources] (JustEnoughResources-1.12-0.8.1.14.jar) 
    UCH    mantle{1.12-1.3.0.12} [Mantle] (Mantle-1.12-1.3.0.12.jar) 
    UCH    natura{1.12-4.3.0.10} [Natura] (Natura-1.12-4.3.0.10.jar) 
    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 372.54' Renderer: 'GeForce GTX 970/PCIe/SSE2'
    Pulsar/natura loaded Pulses: 
        - NaturaCommons (Enabled/Forced)
        - NaturaOverworld (Enabled/Not Forced)
        - NaturaNether (Enabled/Not Forced)
        - NaturaDecorative (Enabled/Not Forced)
        - NaturaTools (Enabled/Not Forced)
        - NaturaEntities (Enabled/Not Forced)
        - NaturaOredict (Enabled/Forced)
        - NaturaWorld (Enabled/Not Forced)

    Launched Version: 1.12
    LWJGL: 2.9.4
    OpenGL: GeForce GTX 970/PCIe/SSE2 GL version 4.5.0 NVIDIA 372.54, NVIDIA Corporation
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 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: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs: 
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    CPU: 8x Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
[12:55:45] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:630]: #@!@# Game crashed! Crash report saved to: #@!@# E:\Aaa_mods\Slavicraft forge-2413\run\.\crash-reports\crash-2017-07-18_12.55.45-client.txt
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
 

 

Edited by Corgam
Posted
2 minutes ago, Corgam said:

@SubscribeEvent
    public void registerItems(RegistryEvent.Register<Item> event) {   
        _Items.register();
    }

This is not the proper way to register them. You must do event.getRegistry().register...

  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
2 minutes ago, Animefan8888 said:

This is not the proper way to register them. You must do event.getRegistry().register...

so is this good?

 

@SubscribeEvent
    public void registerItems(RegistryEvent.Register<Item> event) {
        event.getRegistry().registerAll(***);
    }

And what do I write in *** blank ?

 

Posted (edited)
  1. Register methods must be static.
  2. You put what you register ;). You can create new items right in that event and then take them from @ObjectHolder class later, or do some form of storage (array, separate instances).
  3. To keep code clean, it's better to move your model registries into the model RegisterHandler and completely get rid of _Items class.
Edited by MrBendelScrolls
  • Like 1
Posted (edited)

I managed to get everything working, thanks! :D

(now I only need to write something to it to handle more items)

Are there benefits of using @ObjectHolders or arrays?

Here is code for others with the same problem to look at:

 

RegisterHandler class:

Spoiler

package corgam.slavicraft.base.handler;

import corgam.slavicraft.base.init._Blocks;
import corgam.slavicraft.base.init._Items;
import corgam.slavicraft.items.ItemBlankRune;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@EventBusSubscriber
public class RegisterHandler {
    
    public static Item blank_rune;
    
    public static void init()
    {
        blank_rune = new ItemBlankRune("blank_rune");
    }
    
    @SubscribeEvent
    public static void registerItems(RegistryEvent.Register<Item> event) {
        event.getRegistry().register(blank_rune);
    }
    
    @SubscribeEvent
    public static void onModelRegistry(ModelRegistryEvent event)
    {
        registerRender(blank_rune);
    }
    
    private static void registerRender(Item item)
    {
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }

}
 

 

Edited by Corgam
Posted
14 minutes ago, Corgam said:

Are there benefits of using @ObjectHolders or arrays?

@ObjectHolder as far as I know don't really have advantages or disadvantages in this case. Instead of an array I suggest a ArrayList. That way you have access to List#add. Also you will need to move your ModelRegistryEvent to another class or it will crash the dedicated server as it is a Client side only class. You also will need to put @SideOnly(SIde.CLIENT) at the top of your class.

  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 hour ago, Animefan8888 said:

Also you will need to move your ModelRegistryEvent to another class or it will crash the dedicated server as it is a Client side only class. You also will need to put @SideOnly(SIde.CLIENT) at the top of your class.

Helpful tips, thanks! :) 

Posted (edited)
1 hour ago, Animefan8888 said:

Also you will need to move your ModelRegistryEvent to another class or it will crash the dedicated server as it is a Client side only class. You also will need to put @SideOnly(SIde.CLIENT) at the top of your class.

Isn't forge smart enough to call the method with ModelRegistryEvent on the client only?
I didn't have any problems with this being in the common class.
And, isn't @SideOnly kind of... "forbidden"?

Edited by MrBendelScrolls
  • Like 1
Posted (edited)
5 minutes ago, MrBendelScrolls said:

Isn't forge smart enough to call the method with ModelRegistryEvent on the client only?
I didn't have any problems with this being in the common class.

That has nothing to do with it. 

Pretend you are the JVM. When you load a class you need to check that the class contains valid code. Ie that every referenced class with its already loaded or can be found and loaded if it is needed. 

 

The JVM cannot predict whether or not a given method will execute, so it assumes that all of them will at some point. 

 

The JVM scans through your class, finds a reference to a ModelRegistryEvent, attempts to locate this class, and fails to do so.

Edited by Draco18s
  • Like 2

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.

Posted

The problem is that all the client stuff isn't available on server. Should a server try to run a class that contains client code (even if its not directly executed) it will crash in almost all cases.

 

I would run a setup with two classes, a YourModItems class and a ClientRendererItems class.

YourModItems has a list of all your items and a method to register them that is started by the common proxy. Your ClientItemRenderer has a function that loops through all your items in the YourModItems class and registers the rendering stuff for them.

  • Like 1

Here could be your advertisement!

Posted (edited)
7 minutes ago, MrBendelScrolls said:

Isn't forge smart enough to call the method with ModelRegistryEvent on the client only?
I didn't have any problems with this being in the common class.

Yes, and I misspoke ModelRegistryEvent is not the Client Side only class (at least it is not marked with @SideOnly(Side.CLIENT)), but ModelLoader is. And if you compile a Common or Server class with ModelLoader referenced in it it will crash with a "Class Not Found Exception". Seeing as how the class doesn't exist in the servers files. 

Edited by Animefan8888
  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
6 minutes ago, MrBendelScrolls said:

Isn't forge smart enough to call the method with ModelRegistryEvent on the client only?
I didn't have any problems with this being in the common class.
And, isn't @SideOnly kind of... "forbidden"?

Yes, Forge is - it will only call the method on the client. But like draco said, the JVM isn't clever enough to know the method won't get called, so it crashes as soon as it finds a reference to a nonexistent class.

 

You won't have any problems when you run code like that on the physical client because all the referenced classes are present - it's only the server that will crash.

 

@SideOnly isn't forbidden, it's just that it needs to be used correctly. People get mixed up about the difference between logical and physical sides - @SideOnly applies to physical sides.

  • Like 1
Posted
1 minute ago, MrBendelScrolls said:

However, no matter how hard I tried, I couldn't make it crash a single time

I don't believe the crash will happen in a development environment possibly because the classes marked with @SIdeOnly(Side.CLIENT) still get compiled though that may just be me thinking wildly.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.