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

(SOLVED) [1.11] Changing Texture/Model file on right click?


Rohzek
 Share

Recommended Posts

Is there an easy way to change the texture of an item in say, an overridden onItemRightClick, by changing which layer, or which model file is being loaded?

It depends is it limited? Or can it be anything?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

It depends is it limited? Or can it be anything?

 

Just the easiest way. Preferably if it doesn't involve just removing the item, and adding in another one.

Modifing the metadata of the stack, and assigning the different metadata a different model when registered using ModelLoader.setCustomModelResourceLocation(...)

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Modifing the metadata of the stack, and assigning the different metadata a different model when registered using ModelLoader.setCustomModelResourceLocation(...)

 

Hmm. That sounded easy until I managed to confuse myself. I was originally using

 

 

public static void registerRenders() 
{
registerRender(testItem);
}

public static void registerRender(Item item)
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}

 

 

and it could find my original json file just fine, and it showed in game. I tried changing that to take a string to seperate them, making it:

 

 

 

public static void registerRenders() 
{
registerRender(testItem, 0, "Stage0");
registerRender(testItem, 1, "Stage1");
registerRender(testItem, 2, "Stage2");
}

public static void registerRender(Item item, int meta, String addon)
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, new ModelResourceLocation(item.getRegistryName()+addon, "inventory"));
}

 

 

And that didn't complain about not being able to find my new json files, but it was broken texture in game.

 

After switching that to

 

ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName() + addon, "inventory"));

Now it also can't find my json files.

 

After remembering to register my event, same problem as above. It doesn't complain that it can't find the json files... ...it just doesn't load the textures in game.

Developing the Spiral Power Mod .

こんにちは!お元気ですか?

Link to comment
Share on other sites

You shouldn't be using the ModelMesher anyway, that method has been outdated for a while.

 

Make sure you're calling ModelLoader.setCustomModelResourceLocation during the ModelRegistryEvent (preferred 1.11 way, although I think during PreInit still works).

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

I seem to be failing to properly register my ModelRegistryEvent, as it seems it doesn't complain because that method never runs?

 

I've tried registering it with the forge event bus in both my Main, and ClientProxy and neither works...

 

...This is probably all wrong?

 

MinecraftForge.EVENT_BUS.register(new LoadModelEvent());

 

LoadModelEvent:

...

@SubscribeEvent
public void onModelRegistry(ModelRegistryEvent event)
{
     testItems.registerRenders();
}

 

TestItems:

...

public static void registerRenders() 
{
registerRender(testItem, 0, "Stage0");
registerRender(testItem, 1, "Stage1");
registerRender(testItem, 2, "Stage2");
}

public static void registerRender(Item item, int meta, String addon)
{	
ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName() + addon, "inventory"));

LogHelper.debug("I should be loading the json file for: " + item.getRegistryName() + addon + " and setting metadata: " + meta);
}

Developing the Spiral Power Mod .

こんにちは!お元気ですか?

Link to comment
Share on other sites

ModelRegistryEvent

is fired before preInit, so it needs to be handled by a static

@SubscribeEvent

method in a class annotated with

@Mod.EventBusSubscriber

.

 

You should also be registering all of your

IForgeRegistryEntry

implementations (e.g.

Item

,

Block

,

SoundEvent

) in response to

RegistryEvent.Register<T>

, where

T

is the registry's type.

 

You can read more about events here.

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

MinecraftForge.EVENT_BUS.register(new LoadModelEvent());

 

When are you calling this?

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

When are you calling this?

 

I was calling it during the preinit of my main class

public static void PreInit(FMLPreInitializationEvent PreEvent)
{
     MinecraftForge.EVENT_BUS.register(new LoadModelEvent());
}

 

I also tried (after reading through Choonster's link) making it static, and making that

 

public static void PreInit(FMLPreInitializationEvent PreEvent)
{
     MinecraftForge.EVENT_BUS.register(LoadModelEvent.class);
}

 

Which also didn't work. I then tried removing that, and using:

 

@Mod.EventBusSubscriber
public class LoadModelEvent 
{
     ...
}

 

Which runs, and gets a nullpointerexception because the items aren't loaded yet...

Attempting to load the items by registering them in the event too instead of normal fixes that, but then they get initialized as being from

minecraft instead of being from my MODID

 

Exception loading model for variant minecraft:testitemstage0#inventory for item "minecraft:testitem", normal location exception: 

 

Sorry, I am 100% thoroughly lost and confused.

Developing the Spiral Power Mod .

こんにちは!お元気ですか?

Link to comment
Share on other sites

Events that extend

FMLEvent

(e.g.

FMLPreInitializationEvent

) still need to be handled by instance

@Mod.EventHandler

methods in your

@Mod

class.

 

You should instantiate your

Item

s in a static initialiser and register them in response to

RegistryEvent.Register<Item>

. The same applies to all other

IForgeRegistryEntry

implementations.

 

You can see how I do this here and in the other classes in the

init

package.

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

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I don't much about this, but I do know you can't use the fog for this. The fog is designed to limit the player's view distance, e.g. if they are in lava or water, but mainly so the game doesn't have to draw all the way to "infinity". This means all the fog rendering code is based on the distance to camera. It's an illusion, it's not based on something physically in the world at some position.   Spit balling: I would guess you want something more like how clouds are drawn? But again these are partially an illusion. They are procedurally generated rather than being physically in the world, but they are kind of drawn at a location. You can use forge's RenderLevelLastEvent to draw over the world. Look at LevelRenderer.renderClouds() for how clouds are drawn.  
    • Problem with Electrodynamics. Talk to the mod author.
    • here is my github if you want to check what I did https://github.com/Socrateee/Mist
    • Hi, i'm trying to create a sort of  toxic "mist" in minecraft wich will be cleared by a machine. To create my mist I modified minecraft RenderSystem using the setShaderFogStart and End and setShaderFogColor methods and the EntityViewRenderEvent from forge to update it. The final idea is to make the block create  a protective sphere where there is no toxic mist. What I've done from now is to apply the toxic fog effect to the player when he leaves a sphere i defined (center : 10 100 10 in the World, radius = 10 blocks ). Here is how it looks : https://imgur.com/WdAhF3D (inside the sphere) https://imgur.com/PcluWul (outside the sphere)   The reason why i'm posting here is because I have a problem that I can't solve : as you can see in the picture 1, when inside the fog clear zone the player can see clearly through the sphere's border wich makes no sens as the outsides of the sphere is supposed to be toxic. What I would like to do is to make the outside of the sphere look the same as when we are outside of it (I hope what I say makes sense, English is not my native language ), how can I achieve that ? Maybe modifing the fog center effect to be centered on the sphere center (10 100 10 ) instead of the player itself ? Is it possible ? Do you think about an another way accomplishing what i descibed ?  I really hope what I said made sense and that I made a correct description of what i want to accomplish Have a nice day !    
  • Topics

×
×
  • Create New...

Important Information

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