Posted May 20, 20214 yr I'm trying to add a simple block for the first time in MineCraft Forge. I get following error: Stacktrace: at com.mcexamples.examplemod.BlockSimple.<init>(BlockSimple.java:22) ~[mcexamples:1.0] {re:classloading} -- MOD mcexamples -- Details: Mod File: mcexamples-1.0.jar Failure message: CrazyBoys Mod (mcexamples) encountered an error during the load_registries event phase java.lang.NoSuchFieldError: field_151573_f Mod Version: 1.0 Mod Issue URL: NOT PROVIDED Exception message: java.lang.NoSuchFieldError: field_151573_f Stacktrace: at com.mcexamples.examplemod.BlockSimple.<init>(BlockSimple.java:22) ~[main/:?] {re:classloading} at com.mcexamples.examplemod.StartupCommon.registerBlocks(StartupCommon.java:34) ~[main/:?] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_1_StartupCommon_registerBlocks_Register.invoke(.dynamic) ~[?:?] {} -- System Details -- Details: Minecraft Version: 1.16.5 Minecraft Version ID: 1.16.5 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_291, Oracle Corporation FML: 36.1 Forge: net.minecraftforge:36.1.0 FML Language Providers: [email protected] minecraft@1 Block class :: I'm trying to simplify the Block as much as I can. public class BlockSimple extends Block { private static final String REGISTRY_NAME = "block_simple_registry_name.json"; public BlockSimple() { super(AbstractBlock.Properties.of(Material.METAL)); //.sound(SoundType.METAL) //.strength(2.0f)); //.lightLevel(state -> state.getValue(BlockStateProperties.POWERED) ? 14 : 0) //); } @Nullable @Override public BlockState getStateForPlacement(BlockItemUseContext context) { return defaultBlockState().setValue(BlockStateProperties.FACING, context.getNearestLookingDirection().getOpposite()); } //in other class calling this Block as follows:: @SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { System.out.println("in register block of sc : " + event.getName() + " reg name : " + event.getRegistry().getRegistryName()); blockSimple1 = (BlockSimple) new BlockSimple().setRegistryName("mcexamples", "block_simple_registry_name"); //this line gives above error System.out.println("block registered :" + blockSimple1); event.getRegistry().register(blockSimple1); Edited May 20, 20214 yr by DracoDoes
May 20, 20214 yr 54 minutes ago, DracoDoes said: Block class :: I'm trying to simplify the Block as much as I can. Don't simplify. Provide an exact paste of the entire class. Simplification means you're filtering out code you think might not be relevant but might be actually causing the error. It's preferable if you can provide a repo to your codebase instead of just snippets though because the above error suggests that you're trying to refer to an unmapped field.
May 20, 20214 yr Please, for the love of god, don't just paste your code as plain text, it's painfull to try and read it. The forums has a tool that you can use to post code, it will even do syntax highliting, you just click on the angle brackets that show up on the top of the textarea you use to make the post (near the smiley) Same goes for error logs, post them in something like gist or pastebin, or use the code thing, makes it waaay easier to read Don't register your blocks through Registry Events, the preferred way is to use DeferredRegisters, you can find more info on it in the docs It seems that you are trying to set some block state in getStateForPlacement, however your blocks has no block states, you need to set the defaultState in the constructor, and then override fillStateContainer, to "register" your states If fixing the blockstate, and using DeferredRegisters doesn't solve your issue, post your build.gradle file
May 20, 20214 yr Author thanks for reply. I tried to use DeferredRegister to register blocks. Now, I get this error: https://github.com/MacDax/McraftForge Details: Mod File: mcexamples-1.0.jar Failure message: CrazyBoys Mod (mcexamples) encountered an error during the error event phase java.lang.NullPointerException: Registry Object not present: mcexamples:silver_block Mod Version: 1.0 Mod Issue URL: NOT PROVIDED Exception message: java.lang.NullPointerException: Registry Object not present: mcexamples:silver_block build.gradle build.gradle
May 20, 20214 yr 14 minutes ago, DracoDoes said: I tried to use DeferredRegister to register blocks This is still a registry event. You should also make your items use a deferred register. By the way, what is this, why is it here, and why does it have a .json? https://github.com/MacDax/McraftForge/blob/master/src/main/java/com/mcexamples/examplemod/BlockSimple.java#L22 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.
May 21, 20214 yr Author Still getting the same error. Added items and block and used DeferredRegistry to register the same. Commented out method with "subscribeEvent" annotation in "main" type class. But still the same error: Quote [21May2021 11:03:03.823] [Render thread/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/LOADING]: Caught exception during event RegistryEvent.Register<minecraft:block> dispatch for modid mcexamples java.lang.NoSuchFieldError: field_151573_f at com.mcexamples.lists.BlockList.lambda$static$0(BlockList.java:19) ~[main/:?] at net.minecraftforge.registries.DeferredRegister.lambda$register$0(DeferredRegister.java:124) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] at net.minecraftforge.registries.DeferredRegister.addEntries(DeferredRegister.java:200) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] at net.minecraftforge.registries.DeferredRegister.access$000(DeferredRegister.java:61) ~[forge-1.16.5-36.1.0_mapped_official_1.16.5-recomp.jar:?] [21May2021 11:03:03.977] [Render thread/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/LOADING]: Caught exception during event RegistryEvent.Register<minecraft:item> dispatch for modid mcexamples java.lang.NoSuchFieldError: field_78037_j at com.mcexamples.lists.ItemList.lambda$static$0(ItemList.java:19) ~[main/:?] https://github.com/MacDax/McraftForge Thanks Sonal
May 21, 20214 yr Just FYI: This: https://github.com/MacDax/McraftForge/blob/master/src/main/java/com/mcexamples/examplemod/ExampleMod.java#L46 This: https://github.com/MacDax/McraftForge/blob/master/src/main/java/com/mcexamples/examplemod/ExampleMod.java#L65 And this: https://github.com/MacDax/McraftForge/blob/master/src/main/java/com/mcexamples/examplemod/ExampleMod.java#L82 All do the same thing: register this class's annotated or otherwise indicated methods with a given event bus (of which there are two: line 46 and 65 are registering things with the mod bus, 82 is registering with the Forge bus; on top of that line 71 stores one of those busses (the mod bus) to a local variable despite having already said "fuck local variables" earlier on line 65 and again on 72). Not to mention that half of the registered event methods do fucking nothing, like these: https://github.com/MacDax/McraftForge/blob/master/src/main/java/com/mcexamples/examplemod/ExampleMod.java#L106-L111 https://github.com/MacDax/McraftForge/blob/master/src/main/java/com/mcexamples/examplemod/ExampleMod.java#L125-L143 Additionally, client code will crash the dedicated server: https://github.com/MacDax/McraftForge/blob/master/src/main/java/com/mcexamples/examplemod/ExampleMod.java#L113-L123 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.
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.