Jump to content

[1.8.9] Rebuild of 1.8 mod causes mod blocks to do all kinds of crazy.


Recommended Posts

Posted

Any pointers deeply appreciated; I have no clue and am truly stumped.

 

Background: I just started migrating 1.8 mods to 1.8.9 (build 11.15.1.1722). Did a rebuild and fixed compiler issues. NO other changes. Opened an existing 1.8 world for a smoke test. Here are the issues I'm getting (I see no one else referring to these kinds of errors so I'm assuming it's something with my mods):

  • Some blocks (simple blocks, no entities, renderers, etc.) are just GONE (no errors, warnings, etc.) The blocks just aren't where they were in the 1.8 version.
  • Lots of errors from Forge looking for blockstates files for ITEMS (it's like the game as substituted items names(?) for existing blocks). Of course there are no blockstates for these things as they're not blocks. Again no big errors or warnings except for these.
  • Some blocks have been swapped for other blocks, sometimes a vanilla block (eg ice blocks shown in pics below) is where a custom mod block was before!

I see this behavior with development IDE saves (Eclipse) as well as standalone games. Old saves and brand new 1.8 saves (just created in 1.8 and re-opened in 1.8.9).

 

Example (snip) FileNotFoundException for items being looked up with blockstates:

java.lang.Exception: Could not load model definition for variant vanillafoodpantry:breads#inventory
at net.minecraftforge.client.model.ModelLoader.func_177586_a(ModelLoader.java:215) ~[ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader.loadItems(ModelLoader.java:252) ~[ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader.func_177570_a(ModelLoader.java:116) ~[ModelLoader.class:?]
at net.minecraft.client.resources.model.ModelManager.func_110549_a(ModelManager.java:28) [bou.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.func_110542_a(SimpleReloadableResourceManager.java:120) [bnn.class:?]
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:478) [ave.class:?]
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:329) [ave.class:?]
at net.minecraft.client.main.Main.main(SourceFile:124) [Main.class:?]
[sNIP...]
Caused by: java.lang.RuntimeException: Encountered an exception when loading model definition of model vanillafoodpantry:blockstates/breads.json
at net.minecraft.client.resources.model.ModelBakery.func_177586_a(ModelBakery.java:165) ~[bot.class:?]
at net.minecraftforge.client.model.ModelLoader.func_177586_a(ModelLoader.java:211) ~[ModelLoader.class:?]
... 21 more
Caused by: java.io.FileNotFoundException: vanillafoodpantry:blockstates/breads.json
at net.minecraft.client.resources.FallbackResourceManager.func_135056_b(FallbackResourceManager.java:93) ~[bnb.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.func_135056_b(SimpleReloadableResourceManager.java:78) ~[bnn.class:?]
at net.minecraft.client.resources.model.ModelBakery.func_177586_a(ModelBakery.java:143) ~[bot.class:?]
at net.minecraftforge.client.model.ModelLoader.func_177586_a(ModelLoader.java:211) ~[ModelLoader.class:?]
... 21 more

 

Example pics of weirdness

Yeah...those ice blocks shouldn't be there...

width=641 height=421http://jwaresoftware.org/files/mcmods/bugs/1.8.9/Vanilla_Blocks_Switched_For_Mod_Blocks.png[/img]

All kinds of confusion in this one...

width=392 height=450http://jwaresoftware.org/files/mcmods/bugs/1.8.9/MyFav_CustomHoppers_Switched_For_OtherMod_Blocks.png[/img]

Posted

It would help to have some code to look at. I can however answer the thing about blockstates, even though they're items, if a model file fails to be found, it searches for a blockstate model it could possibly use. Simply making an item model for "breads" will clear up the block state error.

Posted

To expand -- it's complaining about various items blockstates but all those item models are present (there isn't a single black-n-purple box shown and all items look correct once the game comes up). The usual model file missing errors aren't the ones generated. This seems to be the only symptom of some bigger issue...Are blockstate files required for items now? Or is there a format change or something I've missed?

 

What code would you like to see? There isn't a specific thing that seems to be a problem which is the problem. Forge seems quite silent but there is this weird issue. The library does not complain about missing blocks or bad tile entities or anything. Just loads of model files not found and all of those are present. Everything looks OK on creative tabs and new blocks when placed are also OK. It's just existing blocks in old saves (build 1.8 11.14.3.1450) that are being screwed up.

 

I will post after turning on all of Forge's debugging outside of IDE environment.

Posted

I posted an almost identical thread back in the fall. What I discovered was that nobody else ever even tried to migrate an existing world with modded blocks in it.

 

You may upgrade your mods and create a new world. You might even get away with upgrading mods, installing them only on clients, and then logging into an existing 1.8 world server. However, a modded world created in one MC version of Forge and subsequently opened in another will always be vulnerable to gross memory-structure errors (such as block shuffling). I gave up.

 

The good news: I discovered that if I reverted to a Minecraft 1.8 version of Forge, I could reopen my world, and the riot of random blocks seemed to have gone back to normal (I didn't notice any permanent corruption).

 

Sorry I couldn't offer a migration solution, but maybe I saved you some wasted effort in a lost cause.

 

My recommendations are:

 

1) To continue playing your existing 1.8 world, upgrade Forge to the latest build for pure 1.8 and park it there permanently.

 

2) To upgrade mods, jump up to 1.9.4 and then create a new world. Don't bother creating a new world for an intermediate release.

 

BTW, If you know your Linux, you can setup multiple server worlds, each running a different build of Forge out of a different subdirectory. They can run simultaneously; just give each its own port number and remember to forward all those ports to the host machine.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Just a follow-up (for anyone looking for this in future). I created a very simple 1.8 test-mod that defines a simple item and a simple multi-variant item. Saved a world with the items in frames. Rebuilt said mod for 1.8.9 and loaded 1.8 world. Also broken, but at least there is some code to go with the issue now.

 

All code, asset files, and some screenshots located here: http://jwaresoftware.org/files/mcmods/bugs/1.8.9/TestMod_MC1.8_to_MC1.8.9/.

 

Main code body (as above link may disappear someday):

/** -------- TestMod.java (ClientOnly) -------- **/
/** COMMENTED LINES ARE THE 1.8 LINES replaced **/
package testmod;

//import  net.minecraft.client.Minecraft;
//import  net.minecraft.client.renderer.ItemModelMesher;
//import  net.minecraft.client.resources.model.ModelBakery;
import  net.minecraft.client.resources.model.ModelResourceLocation;
import  net.minecraftforge.client.model.ModelLoader;
import  net.minecraftforge.fml.common.Mod;
import  net.minecraftforge.fml.common.Mod.EventHandler;
import  net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import  net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import  net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid = "testmod", name = "Test Mod", version="1.8")
public class TestMod
{
    @Mod.Instance(value="testmod")
    public static TestMod instance;

    public static ItemSimple itemSimple;
    public static ItemVariant itemVariant;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event) // seed: -8913466909937400889
    {
        itemSimple = (ItemSimple)(new ItemSimple().setUnlocalizedName("tm_simple_item"));
        GameRegistry.registerItem(itemSimple,"tm_simple_item");

        itemVariant = (ItemVariant)(new ItemVariant().setUnlocalizedName("tm_variant_item"));
        GameRegistry.registerItem(itemVariant,"tm_variant_item");
    }

    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
        ModelResourceLocation model;
        //ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();

        model = new ModelResourceLocation("testmod:tm_simple_item","inventory");
        //mesher.register(itemSimple,0,model);
        ModelLoader.setCustomModelResourceLocation(itemSimple,0,model);

        //String[] itemids = new String[]{"testmod:tm_variant_item_0","testmod:tm_variant_item_1"};
        //ModelBakery.addVariantName(itemVariant, itemids);

        model = new ModelResourceLocation("testmod:tm_variant_item_0","inventory");
        //mesher.register(itemVariant,0,model);
        ModelLoader.setCustomModelResourceLocation(itemVariant,0,model);

        model = new ModelResourceLocation("testmod:tm_variant_item_1","inventory");
        //mesher.register(itemVariant,1,model);
        ModelLoader.setCustomModelResourceLocation(itemVariant,1,model);
    }
}

/** --------- ItemSimple.java ---------- **/
package testmod;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class ItemSimple extends Item
{
    public ItemSimple()
    {
        setCreativeTab(CreativeTabs.tabDecorations);
    }
}


/** ----------- ItemVariant.java --------- **/
package testmod;

import  java.util.List;

import  net.minecraft.creativetab.CreativeTabs;
import  net.minecraft.item.Item;
import  net.minecraft.item.ItemStack;
import  net.minecraftforge.fml.relauncher.Side;
import  net.minecraftforge.fml.relauncher.SideOnly;

public class ItemVariant extends Item
{
    public ItemVariant()
    {
        setMaxDamage(0);
        setHasSubtypes(true);
        setCreativeTab(CreativeTabs.tabDecorations);
    }

    public int getMetadata(int damage)
    {
        return damage;
    }

    @SideOnly(Side.CLIENT)
    public void getSubItems(Item item, CreativeTabs tab, List subItems)
    {
        ItemStack stack;
        stack = new ItemStack(item,1,0);
        subItems.add(stack);
        stack = new ItemStack(item,1,1);
        subItems.add(stack);
    }

    public String getUnlocalizedName(ItemStack stack)
    {
      int metadata = stack.getMetadata();
      return super.getUnlocalizedName() + "_"+ metadata;
    }
}

 

Pictures of issues even for this simple mod

(1.8 -- Baseline [yellow=simple, green/blue=variant])

width=623 height=413http://jwaresoftware.org/files/mcmods/bugs/1.8.9/TestMod_MC1.8_to_MC1.8.9/screenshots/MC1.8%20-%20The%20Items.png[/img]

 

(1.8.9 -- Same thing; not so good)  :-[

width=640 height=433http://jwaresoftware.org/files/mcmods/bugs/1.8.9/TestMod_MC1.8_to_MC1.8.9/screenshots/MC1.8.9%20-%20The%20Items.png[/img]

 

I didn't bother adding a Simple Block as there seemed no point based on previous commenter's advice.

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

    • I know that this may be a basic question, but I am very new to modding. I am trying to have it so that I can create modified Vanilla loot tables that use a custom enchantment as a condition (i.e. enchantment present = item). However, I am having trouble trying to implement this; the LootItemRandomChanceWithEnchantedBonusCondition constructor needs a Holder<Enchantment> and I am unable to use the getOrThrow() method on the custom enchantment declared in my mod's enchantments class. Here is what I have so far in the GLM:   protected void start(HolderLookup.Provider registries) { HolderLookup.RegistryLookup<Enchantment> registrylookup = registries.lookupOrThrow(Registries.ENCHANTMENT); LootItemRandomChanceWithEnchantedBonusCondition lootItemRandomChanceWithEnchantedBonusCondition = new LootItemRandomChanceWithEnchantedBonusCondition(0.0f, LevelBasedValue.perLevel(0.07f), registrylookup.getOrThrow(*enchantment here*)); this.add("nebu_from_deepslate", new AddItemModifier(new LootItemCondition[]{ LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.DEEPSLATE).build(), LootItemRandomChanceCondition.randomChance(0.25f).build(), lootItemRandomChanceWithEnchantedBonusCondition }, OrichalcumItems.NEBU.get())); }   Inserting Enchantments.[vanilla enchantment here] actually works but trying to declare an enchantment from my custom enchantments class as [mod enchantment class].[custom enchantment] does not work even though they are both a ResourceKey and are registered in Registries.ENCHANTMENT. Basically, how would I go about making it so that a custom enchantment declared as a ResourceKey<Enchantment> of value ResourceKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath([modid], [name])), declared in a seperate enchantments class, can be used in the LootItemRandomChanceWithEnchantedBonusCondition constructor as a Holder? I can't use getOrThrow() because there is no level or block entity/entity in the start() method and it is running as datagen. It's driving me nuts.
    • Hi here is an update. I was able to fix the code so my mod does not crash Minecraft. Please understand that I am new to modding but I honestly am having a hard time understanding how anyone can get this to work without having extensive programming and debugging experience as well as searching across the Internet, multiple gen AI bots (claude, grok, openai), and examining source code hidden in the gradle directory and in various github repositories. I guess I am wrong because clearly there are thousands of mods so maybe I am just a newbie. Ok, rant over, here is a step by step summary so others can save the 3 days it took me to figure this out.   1. First, I am using forge 54.1.0 and Minecraft 1.21.4 2. I am creating a mod to add a shotgun to Minecraft 3. After creating the mod and compiling it, I installed the .jar file to the proper directory in Minecraft and used 1.21.4-forge-54.1.0 4. The mod immediately crashed with the error: Caused by: java.lang.NullPointerException: Item id not set 5. Using the stack trace, I determined that the Exception was being thrown from the net.minecraft.world.item.Item.Properties class 6. It seems that there are no javadocs for this class, so I used IntelliJ which was able to provide a decompiled version of the class, which I then examined to see the source of the error. Side question: Are there javadocs? 7. This method, specifically, was the culprit: protected String effectiveDescriptionId() {      return this.descriptionId.get(Objects.requireNonNull(this.id, "Item id not set"));  } 8. Now my quest was to determine how to set this.id. Looking at the same source file, I determined there was another method:  public Item.Properties setId(ResourceKey<Item> pId) {             this.id = pId;             return this;   } 9. So now, I need to figure out how to call setId(). This required working backwards a bit. Starting from the constructor, I stubbed out the variable p which is of type Item.Properties public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); Rather than putting this all on one line, I split it up for readability like this: private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); Here is was the missing function, setId(), which takes a type of ResourceKey<Item>. My next problem is that due to the apparent lack of documentation (I tried searching the docs on this site) I could not determine the full import path to ResourceKey. I did some random searching on the Internet and stumbled across a Github repository which gave two clues: import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; Then I created the rk variable like this: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); And now putting it all together in order: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); This compiled and the mod no longer crashes. I still have more to do on it, but hopefully this will save someone hours. I welcome any feedback and if I missed some obvious modding resource or tutorial that has this information. If not, I might suggest we add it somewhere for people trying to write a mod that doesn't crash. Thank you !!!  
    • I will keep adding to this thread with more information in case anyone can help, or at the very least I can keep my troubleshooting organized. I decided to downgrade to 54.1.0 in the hopes that this would fix the issue but it didn't. At least now I am on a "recommended" version. The crash report did confirm my earlier post that the Exception is coming from effectiveDescriptionId(). I'll continue to see if I can find a way to set the ID manually.   Caused by: java.lang.NullPointerException: Item id not set         at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]         at TRANSFORMER/[email protected]/net.minecraft.world.item.Item$Properties.effectiveDescriptionId(Item.java:465) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/[email protected]/net.minecraft.world.item.Item.<init>(Item.java:111) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/[email protected]/com.example.shotgunmod.ShotgunItem.<init>(ShotgunItem.java:19) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/[email protected]/com.example.shotgunmod.ModItems.lambda$static$0(ModItems.java:15) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/[email protected]/net.minecraftforge.registries.DeferredRegister$EventDispatcher.lambda$handleEvent      
    • It just randomly stop working after a rebooted my dedicated server PLEASE HELP!   com.google.gson   Failed to start the minecraft server com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive; at path $  
  • Topics

×
×
  • Create New...

Important Information

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