Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.9.4] Registering Blocks - Back to square one


TheA13X
 Share

Recommended Posts

Look, I'm sorry. Guess I'll open an issue for EVERY major MC Version...

 

I have a 1.8(.9) Mod and want to update it to 1.9(.4).

Choonster's TestMod3 is a pretty good reference , but it doesn't work for me.

Tell me what I've done wrong once again, please.

That's what I did:

 

  • registering block and blockitem (on preinit)
private static void registerLeavesBlock(Block block, String name)
    {
        block.setRegistryName(name); //<-sets Registry name HERE to make it more dynamic
        //GameRegistry.register(block,block.getRegistryName()); //<- is not needed I guess? I get something like a double registration error when using it
        GameRegistry.register(new ModLeavesItem(block),block.getRegistryName());//Uses a custom item class for some custumized behaviours. Yes it does extend ItemBlock
        Blocks.FIRE.setFireInfo(block, DEFAULT_LEAVES_FIRE_ENCOURAGEMENT, DEFAULT_LEAVES_FLAMMABILITY);
    }
  • register block variants (using the Client Proxy and executed on init)
public void registerBlockModels()
    {
        for (DefinesLeaves define : subBlocks())//contains the block instance and some additional information
        {
            ModelResourceLocation typeLocation = new ModelResourceLocation(getRegistryName(),"variant="+define.leavesSubBlockVariant().name().toLowerCase());
            ModLeavesItem blockItem = new ModLeavesItem(define.leavesBlock());
            ModelLoader.setCustomModelResourceLocation(blockItem,define.leavesSubBlockVariant().ordinal(),typeLocation);
            //ModelResourceLocation typeItemLocation = new ModelResourceLocation(getRegistryName().toString().substring(0,getRegistryName().toString().length()-1)+"_"+define.leavesSubBlockVariant().name().toLowerCase(),"inventory"); //
            //ModelBakery.registerItemVariants(blockItem,typeItemLocation); 
            //isn't needed as well, I guess, as setCustomModelResourceLocation already registeres the model into the bakery. I tried to use it anyway though, since my item model is saved in a file with the pattern "<block>_<variant>.json" while the blockstate is not.
        }
    }

 

  • My assets layout:
|-assets
 |-modid
  |-blockstates
   |-leaves0
   |-leaves1
   |-...
  |-models
   |-block
    |-leaves_type1
    |-leaves_type2
    |-leaves_type3
    |-...
   |-item
    |-leaves_type1
    |-leaves_type2
    |-leaves_type3
    |-item
    |-...
  • By the way, the localizing is broken too. I have a custom LangMap to fix that, but it shouldn't be broken in the first place. I assume it has to do with the same problem.

 

Thanks and stuff.

Edited by TheA13X

Sincerely,

A13XIS

Link to comment
Share on other sites

GameRegistry.register(block); //still needed

GameRegistry.register(new ModLeavesItem(block).setRegistryName(block.getRegistryName())); //non-deprecated version

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.

Link to comment
Share on other sites

Do you have a crash? Or does it just not exist?

Also, you should give the block an actual registry name (eg. "mod_leaves" with quotations)  instead of just "name".

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

You're creating a new ModLeavesItem instance for the ModelLoader.setCustomModelResourceLocation call, don't do this. You need to use the ItemBlock you already registered. You can use Item.getItemFromBlock to get the Item form of a Block.

 

Do you want your items to use the models defined by your blockstates variant or do you want them to use individual item models? If it's the former, use a ModelResourceLocation with the registry name as the domain and path and the variant name as the variant. If it's the latter, use a ModelResourceLocation with the item model's name as the domain and path and any variant name (it won't be used).

 

I don't know why localisation wouldn't be working. Post the relevant code, and the contents and path of your lang file.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Thank you for the help.

I changed my code to:

That's what I did:

 

  • registering block and blockitem (on preinit)
private static void registerLeavesBlock(Block block, String name)
{
	block.setRegistryName(name);//value: UnlocalizedName<number>
	GameRegistry.register(block);
	GameRegistry.register(new ModLeavesItem(block).setRegistryName(block.getRegistryName()));
	Blocks.FIRE.setFireInfo(block, DEFAULT_LEAVES_FIRE_ENCOURAGEMENT, DEFAULT_LEAVES_FLAMMABILITY);
}
  • register block variants (using the Client Proxy and executed on init)
public void registerBlockModels()
{
	for (DefinesLeaves define : subBlocks())
	{
		ModelResourceLocation typeLocation = new ModelResourceLocation(getRegistryName(),"check_decay=true,decayable=true,variant="+define.leavesSubBlockVariant().name().toLowerCase());
      	        //added all properties to the variant string. This is, how the key in the blockstate file looks like
		//ModelResourceLocation typeItemLocation = new ModelResourceLocation(getRegistryName().toString().substring(0,getRegistryName().toString().length()-1)+"_"+define.leavesSubBlockVariant().name().toLowerCase(),"inventory");
		Item blockItem = Item.getItemFromBlock(define.leavesBlock());
		ModelLoader.setCustomModelResourceLocation(blockItem,define.leavesSubBlockVariant().ordinal(),typeLocation);
	}
}

 

Unfortunately it still doesn't work as you can see in the attached images

 

Regarding translation:

  • The Constructor
//-------------------Superclass--------------------//
protected LeavesBlock(Collection<? extends DefinesLeaves> subBlocks)
    {
        super(Material.LEAVES);
        checkArgument(!subBlocks.isEmpty());
        checkArgument(subBlocks.size() <= CAPACITY);
        this.subBlocks = ImmutableList.copyOf(subBlocks);
        this.setTickRandomly(true);
        this.setHardness(0.2F);
        this.setLightOpacity(1);
        this.setSoundType(SoundType.PLANT);
        setUnlocalizedName("leaves");
    }
//------------------Subclass----------------------//
public ModLeavesBlock(Iterable<? extends DefinesLeaves> subBlocks)
    {
        super(ImmutableList.copyOf(subBlocks));
        setCreativeTab(TheMod.INSTANCE.creativeTab());
        this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, ModLogBlock.EnumType.ACEMUS).withProperty(CHECK_DECAY, Boolean.TRUE).withProperty(DECAYABLE, Boolean.TRUE));
    }
  • The custom getUnlocalizedName() function:
//-------------Block Class--------------------//
public final String getUnlocalizedName()
    {
        return String.format("tile.%s%s", domainPrefix(), getUnwrappedUnlocalizedName(super.getUnlocalizedName()));//domainPrefix() = "dendrology:", super.getUnlocalizedName() = "tile.leaves"
        //getUnwrappedUnlocalizedName(...) gets only the last part of the Unlocalized name path 
    }
//-------------Item Class-------------------//
@Override
public String getUnlocalizedName(ItemStack stack)
    {
        return super.getUnlocalizedName() + "." + ((LeavesBlock)block).getWoodType(stack.getMetadata()).name().toLowerCase();
    }

The langfile is located in /assets/lang and looks like this:

##############################
# Dendrology
#
# English - UNITED STATES (US) (en_US) localization
# Author: Scott Killen
#

#Blocks

### Logs
tile.dendrology:log.acemus.name=Acemus Wood
tile.dendrology:log.cedrum.name=Cedrum Wood
tile.dendrology:log.cerasu.name=Cerasu Wood
tile.dendrology:log.delnas.name=Delnas Wood
tile.dendrology:log.ewcaly.name=Ewcaly Wood
tile.dendrology:log.hekur.name=Hekur Wood
tile.dendrology:log.kiparis.name=Kiparis Wood
tile.dendrology:log.kulist.name=Kulist Wood
tile.dendrology:log.lata.name=Lata Wood
tile.dendrology:log.nucis.name=Nucis Wood
tile.dendrology:log.porffor.name=Porffor Wood
tile.dendrology:log.salyx.name=Salyx Wood
tile.dendrology:log.tuopa.name=Tuopa Wood

### Leaves
tile.dendrology:leaves.acemus.name=Acemus Leaves
tile.dendrology:leaves.cedrum.name=Cedrum Leaves
tile.dendrology:leaves.cerasu.name=Cerasu Leaves
tile.dendrology:leaves.delnas.name=Delnas Leaves
tile.dendrology:leaves.ewcaly.name=Ewcaly Leaves
tile.dendrology:leaves.hekur.name=Hekur Leaves
tile.dendrology:leaves.kiparis.name=Kiparis Leaves
tile.dendrology:leaves.kulist.name=Kulist Leaves
tile.dendrology:leaves.lata.name=Lata Leaves
tile.dendrology:leaves.nucis.name=Nucis Leaves
tile.dendrology:leaves.porffor.name=Porffor Leaves
tile.dendrology:leaves.salyx.name=Salyx Leaves
tile.dendrology:leaves.tuopa.name=Tuopa Leaves

#...

# Creatibe Tabs
itemGroup.dendrology=Ancient Trees
#...

# Config file comments
#...

# Items
item.dendrology:parcel.name=Ancient Parcel
dendrology:parcel.tooltip=What have the Ancients hidden within?

# Parcel contents
#...

 

2017-02-12_11.19.23.png

2017-02-12_11.21.22.png

2017-02-12_11.29.46.png

Sincerely,

A13XIS

Link to comment
Share on other sites

ModelLoader methods must be called in preInit, they won't do anything if called in init or later.

 

It looks like your assets aren't being loaded. Where is your assets folder located? It should be in src/main/resources.

 

If it's still not working, post the FML log (logs/fml-client-latest.log in the game directory) using Gist/Pastebin.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

All right. I finally managed to look in the console output and I found THIS

[16:10:53] [Client thread/ERROR] [FML]: Exception loading model for variant dendrology:leaves3#check_decay=true,decayable=false,variant=cedrum for blockstate "dendrology:leaves3[check_decay=true,decayable=false,variant=cedrum]"
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model dendrology:leaves3#check_decay=true,decayable=false,variant=cedrum with loader VariantLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:134) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:222) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:145) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:210) ~[ModelLoader.class:?]
	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:127) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.Minecraft.startGame(Minecraft.java:538) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:384) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_111]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_111]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_111]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_111]
	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_111]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_111]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_111]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_111]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:78) ~[ModelBlockDefinition.class:?]
	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1164) ~[ModelLoader$VariantLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:130) ~[ModelLoaderRegistry.class:?]
	... 21 more
[16:10:53] [Client thread/ERROR] [FML]: Exception loading blockstate for the variant dendrology:leaves3#check_decay=true,decayable=false,variant=cedrum: 
java.lang.Exception: Could not load model definition for variant dendrology:leaves3
	at net.minecraftforge.client.model.ModelLoader.getModelBlockDefinition(ModelLoader.java:255) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:121) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:210) ~[ModelLoader.class:?]
	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:127) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.Minecraft.startGame(Minecraft.java:538) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:384) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_111]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_111]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_111]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_111]
	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_111]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_111]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_111]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_111]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.RuntimeException: Encountered an exception when loading model definition of model dendrology:blockstates/leaves3.json
	at net.minecraft.client.renderer.block.model.ModelBakery.loadMultipartMBD(ModelBakery.java:205) ~[ModelBakery.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.getModelBlockDefinition(ModelBakery.java:185) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.getModelBlockDefinition(ModelLoader.java:251) ~[ModelLoader.class:?]
	... 20 more
Caused by: java.io.FileNotFoundException: dendrology:blockstates/leaves3.json
	at net.minecraft.client.resources.SimpleReloadableResourceManager.getAllResources(SimpleReloadableResourceManager.java:83) ~[SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadMultipartMBD(ModelBakery.java:198) ~[ModelBakery.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.getModelBlockDefinition(ModelBakery.java:185) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.getModelBlockDefinition(ModelLoader.java:251) ~[ModelLoader.class:?]
	... 20 more

Notice the line "Caused by: java.io.FileNotFoundException: dendrology:blockstates/leaves3.json"

This is true, since the path is "dendrology/blockstates/leaves3.json" 

...huh?

Sincerely,

A13XIS

Link to comment
Share on other sites

21 minutes ago, TheA13X said:

All right. I finally managed to look in the console output and I found THIS

Notice the line "Caused by: java.io.FileNotFoundException: dendrology:blockstates/leaves3.json"

This is true, since the path is "dendrology/blockstates/leaves3.json" 

...huh?

 

dendrology:blockstates/leaves3.json is a ResourceLocation, it corresponds to assets/dendrology/blockstates/leaves3.json on disk.

 

As I suspected from your previous post, none of your assets are being loaded. Is your assets folder in the correct location? Are your assets being copied to your IDE's build output directory? Are they included in the compiled JAR if you run the build Gradle task?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

1 hour ago, Choonster said:

dendrology:blockstates/leaves3.json is a ResourceLocation, it corresponds to assets/dendrology/blockstates/leaves3.json on disk.

Are you sure? It's a FileNotFoundException which usually contains the path used for an I/O operation which is usually the real path.

Anyways. The assets folder is in src/main/resources like it should. It's also included in to the root folder of the mod's jar file. I've run the mod only over the IDE though and while the assets folder does exists in build/resources/main the IDE's output folder is build/classes/main. But it should work anyway right? I mean the assets is copied to the build folder.  

Also I have a custom LanguageMapper who reads the lang files on pre-init and if the assets were missing, minecraft would crash here.

if(test.getLocation().toString().startsWith("jar:"))
  fallback = Optional.of(new LangMap(TheMod.class.getResourceAsStream("/assets/dendrology/lang/en_US.lang")));
else{
  String pathToCode = "../build/resources/main";
  File test2 = new File(pathToCode);
  fallback = Optional.of(new LangMap(new FileInputStream(pathToCode+"/assets/dendrology/lang/en_US.lang")));
}

 

Edited by TheA13X

Sincerely,

A13XIS

Link to comment
Share on other sites

43 minutes ago, TheA13X said:

Are you sure? It's a FileNotFoundException which usually contains the path used for an I/O operation which is usually the real path.

 

Yes. If you look at the method that the exception is thrown from (SimpleReloadableResourceManager#getAllResources), you'll see that it throws a FileNotFoundException with the ResourceLocation as the message if none of the loaded resource packs contain the ResourceLocation's domain.

 

 

Quote

Anyways. The assets folder is in src/main/resources like it should. It's also included in to the root folder of the mod's jar file. I've run the mod only over the IDE though and while the assets folder does exists in build/resources/main the IDE's output folder is build/classes/main. But it should work anyway right? I mean the assets is copied to the build folder.  

Also I have a custom LanguageMapper who reads the lang files on pre-init and if the assets were missing, minecraft would crash here.


if(test.getLocation().toString().startsWith("jar:"))
  fallback = Optional.of(new LangMap(TheMod.class.getResourceAsStream("/assets/dendrology/lang/en_US.lang")));
else{
  String pathToCode = "../build/resources/main";
  File test2 = new File(pathToCode);
  fallback = Optional.of(new LangMap(new FileInputStream(pathToCode+"/assets/dendrology/lang/en_US.lang")));
}

 

 

build is Gradle's output directory, not the IDE's output directory (if you're using IntelliJ IDEA or Eclipse). classes is IntelliJ IDEA's output directory and bin is Eclipse's output directory.

 

I'm not sure why it's not working. Please post your code as a Git repository so I can debug it myself.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

1 hour ago, Choonster said:

build is Gradle's output directory, not the IDE's output directory

IntelliJ's output directory is project/build/classes


I have a git repository for the mod

LOOK

 

Wait. it hasn't updated to 1.9...

Now it has. (1.9 branch)

 

You'll also need it's dependency.

Found here (1.9 branch)

Edited by TheA13X

Sincerely,

A13XIS

Link to comment
Share on other sites

The 1.9 and master branches of dendrology-legacy-mod are still targeting 1.8.9.

 

dendrology-legacy-mod depends on the KoreSample project, but you don't have a settings.gradle file to include the project and the repository doesn't contain the project. If you're going to depend on the KoreSample project, add the KoreSample repository as a Git submodule and include it with a settings.gradle file.

 

Why did you create your own repositories from scratch instead of forking the original ones?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

9 hours ago, Choonster said:

 

The 1.9 and master branches of dendrology-legacy-mod are still targeting 1.8.9.

 

Oh yeah. Didn't notice, sorry.

I fixed it now (for 1.9)

 

9 hours ago, Choonster said:

dendrology-legacy-mod depends on the KoreSample project, but you don't have a settings.gradle file to include the project

Not in the git repository. I have a multi-project-workspace in IntelliJ, so the settings file is in the superdirectory.

I'll add the KoreSample repository as a submodule after I figured out how, but you'll have to create the settings.gradle yourself.

 

9 hours ago, Choonster said:

 

Why did you create your own repositories from scratch instead of forking the original ones?

I just didn't know it's possible back then.

Edited by TheA13X

Sincerely,

A13XIS

Link to comment
Share on other sites

You didn't update build.gradle, but I'll try to work around this.

 

I highly recommend using a proper Git client (e.g. the CLI, IDEA or GitKraken) instead of manually uploading files on the GitHub website. This will make it much easier to commit exactly the right changes and prevent you from creating commits with no changes.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

3 minutes ago, Choonster said:

 

I highly recommend using a proper Git client (e.g. the CLI, IDEA or GitKraken) instead of manually uploading files on the GitHub website. This will make it much easier to commit exactly the right changes and prevent you from creating commits with no changes.

I know. That's what I normally do, I just had to do it this way, because the client told me that "everything is up to date"

Sincerely,

A13XIS

Link to comment
Share on other sites

ModSaplingBlock and ModSapling2Block both reference ProvidesPotionEffect, which doesn't appear to exist anymore. The methods that do this aren't called from anywhere.

 

The game crashes with a NullPointerException thrown from inc.a13xis.legacy.dendrology.TheMod#fallBackExsists because the fallback field is null. The mod isn't running from a JAR and ../build/resources/main doesn't exist because Gradle hasn't built the mod and IDEA doesn't output to that directory, so fallback is never assigned a non-null value. You should use Optional.absent() as the initial value of the field.

 

Your fallback LangMap completely ignores the client's locale and always translates to en_US. I suggest deleting it completely and fixing any issues you have with the vanilla translation system.

 

After fixing that, all models and localisations were working apart from three issues:

  • Errors were being logged for the missing models of the double slab Items. There's no need to register Item forms of your double slab Blocks.
  • Every stairs Item except stairs0 was being rendered as the missing model, depsite not logging any errors. The issue was caused by using the variant enum's ordinal as the metadata argument of ModelLoader.setCustomModelResourceLocation; stairs Items are always metadata 0.
  • Stairs Items were displaying as 2D textures in the inventory. This was fixed by removing the unnecessary display block from the item models.

 

You can't reference client-only classes (e.g. net.minecraft.client.resources.I18n, ModelLoader or ModelResourceLocation) from common code (e.g. your @Mod class), otherwise you'll crash the dedicated server. You can only do this in client-only classes referenced from your client proxy or in client-only methods.

 

SaplingParcel isn't going to work on the dedicated server because you've implemented the item spawning in your client proxy, which is only loaded on the physical client. Items must be spawned on the logical server, but there's no way to send an ItemStack display name in a chat message from the server to the client unless you translate on the server and ignore the client's locale. To solve this, you need to send a custom packet containing the ItemStack from the server to the client and then display the chat message in the packet's handler. I have an example of this for 1.11.2 here.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Oops. I'm sorry for making you so much work. At least the outdated build.gradle and the obsolete ProvidesPotionEffect implementation could be avoided if I had a Git client I can handle.

Thank you for the tips though. My code is pretty chaotic regarding the location of proxied functions, but I works. I never had a crash because of some non-server code.

 

4 hours ago, Choonster said:

SaplingParcel isn't going to work on the dedicated server because you've implemented the item spawning in your client proxy, which is only loaded on the physical client.

Well that's interesting. I'll keep it in mind. See, I implemented the Item spawning on both the common and the client proxy. The common one just returns the Item, the client side adds a translation first. Maybe it isn't ought to be used this way, but it seemed to work.

Sincerely,

A13XIS

Link to comment
Share on other sites

This is a good way to register your blocks.

 

EDIT: Exept youre in 1.9.4, so I guess it woudn't work for you. You should update.

Edited by Leomelonseeds

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

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

 Share



×
×
  • Create New...

Important Information

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