Jump to content

Recommended Posts

Posted (edited)

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: 
        javafml@36.1
        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 by DracoDoes
Posted
  On 5/20/2021 at 4:08 PM, DracoDoes said:

Block class :: I'm trying to simplify the Block as much as I can.

Expand  

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.

Posted

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

Posted

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.gradleFetching info...

Posted
  On 5/20/2021 at 7:35 PM, DracoDoes said:

I tried to use DeferredRegister to register blocks

Expand  

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.

Posted

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/:?]

 

Expand  

https://github.com/MacDax/McraftForge

 

Thanks

Sonal

Posted

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • After some time minecraft crashes with an error. Here is the log https://drive.google.com/file/d/1o-2R6KZaC8sxjtLaw5qj0A-GkG_SuoB5/view?usp=sharing
    • The specific issue is that items in my inventory wont stack properly. For instance, if I punch a tree down to collect wood, the first block I collected goes to my hand. So when I punch the second block of wood to collect it, it drops, but instead of stacking with the piece of wood already in my hand, it goes to the second slot in my hotbar instead. Another example is that I'll get some dirt, and then when I'm placing it down later I'll accidentally place a block where I don't want it. When I harvest it again, it doesn't go back to the stack that it came from on my hotbar, where it should have gone, but rather into my inventory. That means that if my inventory is full, then the dirt wont be picked up even though there should be space available in the stack I'm holding. The forge version I'm using is 40.3.0, for java 1.18.2. I'll leave the mods I'm using here, and I'd appreciate it if anybody can point me in the right direction in regards to figuring out how to fix this. I forgot to mention that I think it only happens on my server but I&#39;m not entirely sure. PLEASE HELP ME! LIST OF THE MODS. aaa_particles Adorn AdvancementPlaques AI-Improvements AkashicTome alexsdelight alexsmobs AmbientSounds amwplushies Animalistic another_furniture AppleSkin Aquaculture aquamirae architectury artifacts Atlas-Lib AutoLeveling AutoRegLib auudio balm betterfpsdist biggerstacks biomancy BiomesOPlenty blockui blueprint Bookshelf born_in_chaos Botania braincell BrassAmberBattleTowers brutalbosses camera CasinoCraft cfm (MrCrayfish’s Furniture Mod) chat_heads citadel cloth-config Clumps CMDCam CNB cobweb collective comforts convenientcurioscontainer cookingforblockheads coroutil CosmeticArmorReworked CozyHome CrabbersDelight crashexploitfixer crashutilities Create CreativeCore creeperoverhaul cristellib crittersandcompanions Croptopia CroptopiaAdditions CullLessLeaves curios curiouslanterns curiouslights Curses' Naturals CustomNPCs CyclopsCore dannys_expansion decocraft Decoration Mod DecorationDelightRefurbished Decorative Blocks Disenchanting DistantHorizons doubledoors DramaticDoors drippyloadingscreen durabilitytooltip dynamic-fps dynamiclights DynamicTrees DynamicTreesBOP DynamicTreesPlus Easy Dungeons EasyAnvils EasyMagic easy_npc eatinganimation ecologics effective_fg elevatorid embeddium emotecraft enchantlimiter EnchantmentDescriptions EnderMail engineersdecor entityculling entity_model_features entity_texture_features epicfight EvilCraft exlinefurniture expandability explosiveenhancement factory-blocks fairylights fancymenu FancyVideo FarmersDelight fast-ip-ping FastSuite ferritecore finsandtails FixMySpawnR Forge Middle Ages fossil FpsReducer2 furnish GamingDeco geckolib goblintraders goldenfood goodall H.e.b habitat harvest-with-ease hexerei hole_filler huge-structure-blocks HunterIllager iammusicplayer Iceberg illuminations immersive_paintings incubation infinitybuttons inventoryhud InventoryProfilesNext invocore ItemBorders itemzoom Jade jei (Just Enough Items) JetAndEliasArmors journeymap JRFTL justzoom kiwiboi Kobolds konkrete kotlinforforge lazydfu LegendaryTooltips libIPN lightspeed lmft lodestone LongNbtKiller LuckPerms Lucky77 MagmaMonsters malum ManyIdeasCore ManyIdeasDoors marbledsarsenal marg mcw-furniture mcw-lights mcw-paths mcw-stairs mcw-trapdoors mcw-windows meetyourfight melody memoryleakfix Mimic minecraft-comes-alive MineTraps minibosses MmmMmmMmmMmm MOAdecor (ART, BATH, COOKERY, GARDEN, HOLIDAYS, LIGHTS, SCIENCE) MobCatcher modonomicon mods_optimizer morehitboxes mowziesmobs MutantMonsters mysticalworld naturalist NaturesAura neapolitan NekosEnchantedBooks neoncraft2 nerb nifty NightConfigFixes nightlights nocube's_villagers_sell_animals NoSeeNoTick notenoughanimations obscure_api oculus oresabovediamonds otyacraftengine Paraglider Patchouli physics-mod Pillagers Gun PizzaCraft placeableitems Placebo player-animation-lib pneumaticcraft-repressurized polymorph PrettyPipes Prism projectbrazier Psychadelic-Chemistry PuzzlesLib realmrpg_imps_and_demons RecipesLibrary reeves-furniture RegionsUnexplored restrictedportals revive-me Scary_Mobs_And_Bosses selene shetiphiancore ShoulderSurfing smoothboot
    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
  • Topics

×
×
  • Create New...

Important Information

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