Jump to content

Recommended Posts

Posted

I added a couple of new blocks, but though they render when placed, they are purple-black when in inventory or on the ground.

Here is my blockstates json

{
"forge_marker": 1,
"defaults": {
	"textures": {
		"all": "dchem:blocks/moltenStone"
	}
},
"variants": {
	"normal": {
		"model": "cube_all"
	},
	"inventory": {
		"model": "cube_all"
	}
}
}

And the json in model

{
    "parent": "block/cube_all",
    "textures": {
        "all": "dchem:blocks/moltenStone"
    }
}

Posted

Path? Like in filepath?

\src\main\resources\assets\dchem\blockstates

 

And in code I have this:

moltenStone = register(new dchemBlocks(Material.rock, "moltenStone").setCreativeTab(CreativeTabs.tabMaterials));

Posted

Add this to your code to apply the texture:

Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new net.minecraft.client.resources.model.ModelResourceLocation(References.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));

 

hope it works

Posted

Add this to your code to apply the texture:

Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new net.minecraft.client.resources.model.ModelResourceLocation(References.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));

 

hope it works

To quote Choonster:

Don't use unlocalised names for registry names. The whole point of the registry name methods being added in 1.8.9 was to stop people from doing that.

 

Set your registry names in your

Item

constructors. If the

Item

class is used by multiple instances, take the registry name as a constructor argument. If the

Item

class in only used by one instance, you can hardcode the registry name in the constructor.

 

If your registry and unlocalised names are the same, I recommend setting the registry name (

setRegistryName("myItem")

) and then setting the unlocalised name to the full registry name (

setUnlocalizedName(getRegistryName())

). This will result in your item's full unlocalised name being

item.modid:myItem.name

, which includes your mod ID to avoid conflicts with other mods.

 

I personally use an interface containing a method called setItemName (or setBlockName for blocks) that looks like this:

//items
default void setItemName(Item item, String itemName) {
item.setRegistryName(Reference.MOD_ID, itemName);
item.setUnlocalizedName(item.getRegistryName().toString());
}

//blocks
default void setBlockName(Block block, String blockName) {
block.setRegistryName(Reference.MOD_ID, blockName);
block.setUnlocalizedName(block.getRegistryName().toString());
}

And all my item/block classes implement the interface and use the method in their constructor like so:

public BlockExample(String name) {
super(Material.ROCK);
this.setBlockName(this, name);
}

//or

public ItemExample(String name) {
super();
this.setItemName(this, name);
}

 

And also, you should be using ModelLoader.setCustomModelResourceLocation() instead of Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(). See this helpful document on the model-loading process as of 1.9, also by Choonster: https://gist.github.com/Choonster/1ee75eecb82c001ec10eca75be924bce

Colore - The mod that adds monochrome blocks in every color of the rainbow!

http://www.minecraftforge.net/forum/index.php?topic=35149

 

If you're looking to learn how to make mods for 1.9.4, I wrote a helpful article with links to a lot of useful resources for learning Minecraft 1.9.4 modding!

 

http://supergeniuszeb.com/mods/a-helpful-list-of-minecraft-1-9-4-modding-resources/

Posted

@SuperGeniusZeb: The first parameter to those methods is not needed if it's always

this

anyways. Or otherwise make the methods static.

The methods are defined once in the interfaces called IItemName & IBlockName and aren't actually defined in any of the classes that implement it, hence the "default" modifier and the need to use "this" as a parameter (so the method knows what class it is registering). I probably should have made that clear in my first post. Is that a good way to do it, or should the interfaces just have blank methods (like most of the Forge interfaces) and leave it to the implementing classes to define what the method does? Because by doing it this way, I can easily change what the method does without having to go into every item/block class and change each implementation individually.

Colore - The mod that adds monochrome blocks in every color of the rainbow!

http://www.minecraftforge.net/forum/index.php?topic=35149

 

If you're looking to learn how to make mods for 1.9.4, I wrote a helpful article with links to a lot of useful resources for learning Minecraft 1.9.4 modding!

 

http://supergeniuszeb.com/mods/a-helpful-list-of-minecraft-1-9-4-modding-resources/

Posted

I know what default methods are. You can use

this

inside them like in any other non-static method.

I know you can use "this" in default methods, but since the methods are defined in separate classes from the ones they are used in (IItemName.java & IBlockName.java), using something like "this.setRegistryName()" in the method won't work because it will try to call IItemName.setRegistryName() or IBlockName.setRegistryName(), which obviously don't exist. here's my interface classes:

 

IBlockName.java

package com.supergeniuszeb.colore.common.blocks;

import com.supergeniuszeb.colore.Reference;

import net.minecraft.block.Block;

public interface IBlockName {
//A utility method for setting both the registryName & unlocalizedName of blocks.
default void setBlockName(Block block, String blockName) {
	block.setRegistryName(Reference.MOD_ID, blockName);
	block.setUnlocalizedName(block.getRegistryName().toString());
}
}

 

IItemName.java

package com.supergeniuszeb.colore.common.items;

import com.supergeniuszeb.colore.Reference;

import net.minecraft.item.Item;

public interface IItemName {
//A utility method for setting both the registryName & unlocalizedName of items.
default void setItemName(Item item, String itemName) {
	item.setRegistryName(Reference.MOD_ID, itemName);
	item.setUnlocalizedName(item.getRegistryName().toString());
}
}

 

Am I missing something or have I just not explained things properly?

Colore - The mod that adds monochrome blocks in every color of the rainbow!

http://www.minecraftforge.net/forum/index.php?topic=35149

 

If you're looking to learn how to make mods for 1.9.4, I wrote a helpful article with links to a lot of useful resources for learning Minecraft 1.9.4 modding!

 

http://supergeniuszeb.com/mods/a-helpful-list-of-minecraft-1-9-4-modding-resources/

Posted

Either make the methods static them (having them instance methods makes no sense) or make one interface that extends

IForgeRegistryEntry

. Since Block and Item already implement that, the implementor of your interface does not have to do anything.

Ah, ok, that makes sense. I've now made the methods static. I would have merged the 2 interfaces into one that extends IForgeRegistryEntry, but it became impossible (as far as I know, correct me if I'm wrong) to call setUnlocalizedName() since that isn't one of IForgeRegistryEntry's methods. Thanks for the advice! :D

Colore - The mod that adds monochrome blocks in every color of the rainbow!

http://www.minecraftforge.net/forum/index.php?topic=35149

 

If you're looking to learn how to make mods for 1.9.4, I wrote a helpful article with links to a lot of useful resources for learning Minecraft 1.9.4 modding!

 

http://supergeniuszeb.com/mods/a-helpful-list-of-minecraft-1-9-4-modding-resources/

Posted

Either make the methods static them (having them instance methods makes no sense) or make one interface that extends

IForgeRegistryEntry

. Since Block and Item already implement that, the implementor of your interface does not have to do anything.

Ah, ok, that makes sense. I've now made the methods static. I would have merged the 2 interfaces into one that extends IForgeRegistryEntry, but it became impossible (as far as I know, correct me if I'm wrong) to call setUnlocalizedName() since that isn't one of IForgeRegistryEntry's methods. Thanks for the advice! :D

Colore - The mod that adds monochrome blocks in every color of the rainbow!

http://www.minecraftforge.net/forum/index.php?topic=35149

 

If you're looking to learn how to make mods for 1.9.4, I wrote a helpful article with links to a lot of useful resources for learning Minecraft 1.9.4 modding!

 

http://supergeniuszeb.com/mods/a-helpful-list-of-minecraft-1-9-4-modding-resources/

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.