Jump to content

[1.12.2] Dynamic Textures on Item JSON Model


Spyeedy

Recommended Posts

So a portion of my item model has 3 cards, they can be stacked starting from the bottom. I want to be able to interchangeably apply any card texture on any of the 3 cards (provided there is a card below to place on top).

So I guess it's like a box of cards, the cards can be shuffled however they want. I guess that's what I want, my cards to be moved to any position in the stack in the model.

 

I'm not too sure where I should start, or if this is even possible.

 

Additional Note: I'm using MeshDefinitions for this model for a boolean state of closing/opening, well, i suppose that won't make any difference here, but, just an extra note.

Edited by Spyeedy

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

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

10 hours ago, Draco18s said:

From my understanding of ItemMeshDefinition, it replaces the model entirely, but that's not what I want to do here, I want to apply any texture I want to a portion of my item model.

 

And I think I didn't specify as to what kind of model it is, it's a JSON model, modelled in 3D.

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

hmm, what if I were to use a custom Baked Model or something that allows me to change the texture location, of any of the values applied to the card part, defined in textures of the JSON model?

Is that possible? If so, I would have to add all the card textures to the texture atlas right?

Edited by Spyeedy

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

Take a look at this thread: 

 

I made a Gun Mod with attachments. Instead of creating all combinations each, I created the single layers and then just dynamically combined them for rendering. I am basically sharing all code here. It might help you, feel free to copy parts it.

 

EDIT: What you could do is have 1 model for each card, and 3 models for the transforms where they can be, then combine them

1. Make a card model of the middle card

2. Copy the model, move it up/down and export again for the top/bottom card

- Now you have 3 json models, all have the same data, except that their transforms are different

3. Copy the first model again for each card and apply texture

- Now you also have a model for each card

4. In the rendering code, always load the model with the card texture (of step 3), but load the transform of one of the initial 3 models to get it into the right position. Do that for all 3 cards.

 

Now only does that solve your problem, but it also lets you change everything via resource pack only.

Edited by CAS_ual_TY
Link to comment
Share on other sites

1 hour ago, CAS_ual_TY said:

I made a Gun Mod with attachments. Instead of creating all combinations each, I created the single layers and then just dynamically combined them for rendering.

From the looks of it, your gun mod uses items' whose models are 3D-ed from 2D textures, like most vanilla items doesn't it?

But for my item, I created a 3D model, with a part of my model having a slot to put in 3 cards. Given that I could render extra quads onto the model, I'm not too sure where I could tell these quads to move to the exact position within the slot?

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

2 hours ago, Afroman said:

Why not make various models with diferent textures, i mean it is how vanilla does it.

Forget it. Now I get what you want. Not much fun in doing 54^3 models Hahaha

I plan to add more cards, hence why I created this thread for the purpose of changing the card's textures dynamically to prevent writing so maaaany variants for all the combinations of cards.

Edited by Spyeedy

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

Here is how I would do it:

 

- I would open the model (eg https://blockbench.net/) and add the middle card onto it. Just as a blanc quad or thin cube. Now I would move it to the other 2 slots and write down how I had to move it for that.

- Next, I would remove everything except for the card itself, and export it. Now move the card to another slot (as written down), export. Now move it to the final slot, export.

- Now I would take the initial card-only model again, and create copies of it with the actual textures on it. To clarify: You now have your main item model, 3 blanc card models, which all fit into a slot of your main item model, and then X models of the first card but textured.

- Now whenever you render your item model, you also render one of the textured cards, with the transform of the correct blanc card applied for the slot.

 

This would still require you to create 1 model per card, but no combinations needed.

 

Or you quickly write a Programm which does all the combinations for you from a small premade template.

Link to comment
Share on other sites

6 minutes ago, CAS_ual_TY said:

- Now I would take the initial card-only model again, and create copies of it with the actual textures on it. To clarify: You now have your main item model, 3 blanc card models, which all fit into a slot of your main item model, and then X models of the first card but textured.

- Now whenever you render your item model, you also render one of the textured cards, with the transform of the correct blanc card applied for the slot.

 

This would still require you to create 1 model per card, but no combinations needed.

 

Or you quickly write a Programm which does all the combinations for you from a small premade template.

I see, so with the cards textures, create a card model that fits into the 1st slot, then whenever a card is slotted, take the model of that card and apply the transformations where needed?

 

But before we get into all of that, how will I combine the models?

Edited by Spyeedy

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

3 minutes ago, CAS_ual_TY said:

Ah, you get your attachment models from here

And then you add this attachment model's quads to the main list in this method

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

Link to comment
Share on other sites

Alright, I've had the time to implement the Baked Models suggestion. The card appears on the model! Yay!

But I've run into a snag, my item's camera transformation is screwed when my new Baked Model replaces the item model.

 

On a side note, I'm not too sure how I can perform transformations on the card to move it.

 

Here's my code. PackageDiendDriver is where I do the ModelBakeEvent, while the others are the Baked Model classes.

 

Edit: Oh nevermind, I looked into IBakedModel and saw that it uses Forge's default perspectives, so that's why my camera transformations were botched. Fixed that. Still unsure on performing transformations on the card model.

Edited by Spyeedy

width=620 height=260http://www.startrek.com/uploads/assets/articles/61c89a9d73c284bda486afaeaf01cdb27180359b.jpg[/img]

Till next time. Thank you for delivering funny scenes to Star Trek as Chekov :) . Will always remember you

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

    • Here is a tutorial from this same forum that I tried and kinda made work. Take into account that you will have to manage the offset (like rotation, and the offset relative to things like the main hand, offhand etc) by yourself and that can get very troublesome at times.  
    • I have done this now but have got the error:   'food(net.minecraft.world.food.FoodProperties)' in 'net.minecraft.world.item.Item.Properties' cannot be applied to                '(net.minecraftforge.registries.RegistryObject<net.minecraft.world.item.Item>)' public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register( "lemon_juice", () -> new Item( new HoneyBottleItem.Properties().stacksTo(1).food( (new FoodProperties.Builder()) .nutrition(3) .saturationMod(0.25F) .effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1500), 0.01f ) .build() ) )); The code above is from the ModFoods class, the one below from the ModItems class. public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register("lemon_juice", () -> new Item(new Item.Properties().food(ModFoods.LEMON_JUICE)));   I shall keep going between them to try and figure out the cause. I am sorry if this is too much for you to help with, though I thank you greatly for your patience and all the effort you have put in to help me.
    • I have been following these exact tutorials for quite a while, I must agree that they are amazing and easy to follow. I have registered the item in the ModFoods class, I tried to do it in ModItems (Where all the items should be registered) but got errors, I think I may need to revert this and figure it out from there. Once again, thank you for your help! 👍 Just looking back, I have noticed in your code you added ITEMS.register, which I am guessing means that they are being registered in ModFoods, I shall go through the process of trial and error to figure this out.
    • ♈+2349027025197ஜ Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join a brotherhood for protection and wealth here’s is your opportunity, but you should know there’s no ritual without repercussions but with the right guidance and support from this great temple your destiny is certain to be changed for the better and equally protected depending if you’re destined for greatness Call now for enquiry +2349027025197☎+2349027025197₩™ I want to join ILLUMINATI occult without human sacrificeGREATORLDRADO BROTHERHOOD OCCULT , Is The Club of the Riches and Famous; is the world oldest and largest fraternity made up of 3 Millions Members. We are one Family under one father who is the Supreme Being. In Greatorldrado BROTHERHOOD we believe that we were born in paradise and no member should struggle in this world. Hence all our new members are given Money Rewards once they join in order to upgrade their lifestyle.; interested viewers should contact us; on. +2349027025197 ۝ஐℰ+2349027025197 ₩Greatorldrado BROTHERHOOD OCCULT IS A SACRED FRATERNITY WITH A GRAND LODGE TEMPLE SITUATED IN G.R.A PHASE 1 PORT HARCOURT NIGERIA, OUR NUMBER ONE OBLIGATION IS TO MAKE EVERY INITIATE MEMBER HERE RICH AND FAMOUS IN OTHER RISE THE POWERS OF GUARDIANS OF AGE+. +2349027025197   SEARCHING ON HOW TO JOIN THE Greatorldrado BROTHERHOOD MONEY RITUAL OCCULT IS NOT THE PROBLEM BUT MAKE SURE YOU'VE THOUGHT ABOUT IT VERY WELL BEFORE REACHING US HERE BECAUSE NOT EVERYONE HAS THE HEART TO DO WHAT IT TAKES TO BECOME ONE OF US HERE, BUT IF YOU THINK YOU'RE SERIOUS MINDED AND READY TO RUN THE SPIRITUAL RACE OF LIFE IN OTHER TO ACQUIRE ALL YOU NEED HERE ON EARTH CONTACT SPIRITUAL GRANDMASTER NOW FOR INQUIRY +2349027025197   +2349027025197 Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join
  • Topics

×
×
  • Create New...

Important Information

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