Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED][1.15.2] Render as 2D icon in GUI, 3D model in hand
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Woodside

[SOLVED][1.15.2] Render as 2D icon in GUI, 3D model in hand

By Woodside, January 17 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Woodside    0

Woodside

Woodside    0

  • Tree Puncher
  • Woodside
  • Members
  • 0
  • 13 posts
Posted January 17 (edited)

Hello,

 

Prior, one could implement IPerspectiveAwareModel to have an item render differently based on hand or GUI. This is no longer the case.

I see that when registering an item I can call .setISTER() and provide my own implementation of an ItemStackTileEntityRenderer, but that's used to render a different 3D model instead of just a flat icon. I also found that I couldn't get the method ItemStackTileEntityRenderer.render to even be called if I attached it to an item.

 

Is there a better way to accomplish what I want to do, or do I just have to make a 3D model that looks like a 2D icon for the sake of this? How do I even get it to invoke if that is the case?

Edited January 21 by Woodside
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 posts
Posted January 17

In 1.16 Forge has SeparatePerspectiveModel, which you can trivally port to 1.15.

  • Quote

Share this post


Link to post
Share on other sites

Woodside    0

Woodside

Woodside    0

  • Tree Puncher
  • Woodside
  • Members
  • 0
  • 13 posts
Posted January 17
40 minutes ago, diesieben07 said:

In 1.16 Forge has SeparatePerspectiveModel, which you can trivally port to 1.15.

Seem to be missing RenderMaterial which I cannot find.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 posts
Posted January 17

Well, you need to adjust the overrides. 

  • Quote

Share this post


Link to post
Share on other sites

Woodside    0

Woodside

Woodside    0

  • Tree Puncher
  • Woodside
  • Members
  • 0
  • 13 posts
Posted January 17
1 minute ago, diesieben07 said:

Well, you need to adjust the overrides. 

I replaced RenderMaterial with Material and it seems to be happy. Wonder if that were just a rename.

I also had to rename isSideLite to func_230044_c_ but that wasn't an issue.

  • Quote

Share this post


Link to post
Share on other sites

Woodside    0

Woodside

Woodside    0

  • Tree Puncher
  • Woodside
  • Members
  • 0
  • 13 posts
Posted January 17

I do not believe I understand how to apply SeparatePerspectiveModel. How do I tell a specific item to use it?

  • Quote

Share this post


Link to post
Share on other sites

poopoodice    118

poopoodice

poopoodice    118

  • Dragon Slayer
  • poopoodice
  • Members
  • 118
  • 928 posts
Posted January 17

You can replace with your own model through ModelBakeEvent.

  • Quote

Share this post


Link to post
Share on other sites

Woodside    0

Woodside

Woodside    0

  • Tree Puncher
  • Woodside
  • Members
  • 0
  • 13 posts
Posted January 17
59 minutes ago, poopoodice said:

You can replace with your own model through ModelBakeEvent.

How do I create the model to replace with though?

Instantiate a couple of BlockModels, and put them into a new SeparatePerspectiveModel, and then run "bake"? I can't find all the parameters I need to put into bake.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 posts
Posted January 18
9 hours ago, poopoodice said:

You can replace with your own model through ModelBakeEvent.

No. No no no.

 

You use "loader": "yourmod:your_loader" in your block's JSON model. The JSON data will then be passed to your loader to be loaded.

  • Quote

Share this post


Link to post
Share on other sites

Woodside    0

Woodside

Woodside    0

  • Tree Puncher
  • Woodside
  • Members
  • 0
  • 13 posts
Posted January 18
7 hours ago, diesieben07 said:

No. No no no.

 

You use "loader": "yourmod:your_loader" in your block's JSON model. The JSON data will then be passed to your loader to be loaded.

Loader, is that another class I extend off of? Is that SeparaterPerspectiveModel?
I really have no context for how these pieces of information fit together. Can you explain with some more detail?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 posts
Posted January 18
12 minutes ago, Woodside said:

Loader, is that another class I extend off of? Is that SeparaterPerspectiveModel?

The loader is an inner class: https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/src/main/java/net/minecraftforge/client/model/SeparatePerspectiveModel.java#L164

 

12 minutes ago, Woodside said:

I really have no context for how these pieces of information fit together. Can you explain with some more detail?

You need to register the loader (see where Forge does it). Then the loader will be called to load the JSON model into memory.

  • Quote

Share this post


Link to post
Share on other sites

Woodside    0

Woodside

Woodside    0

  • Tree Puncher
  • Woodside
  • Members
  • 0
  • 13 posts
Posted January 20

@diesieben07

Alright so I have the following, and the base model seems to be functioning just fine. However the GUI perspective just shows up as blank. No "missing model/texture" purple and black icon, just blank. Any idea why that might be?

 

I put some log messages in the code and found that it is detecting the GUI item model, and is loading it. It's just not doing it correctly for some reason.

 

{
	"loader": "mymodid:separate-perspective",
	"base": {
		"textures": {
			"0": "mymodid:item/flintlock",
			"particle": "mymodid:item/flintlock"
		},
		"elements": [
			{
				"from": [7, 6.75, -3],
				"to": [9, 8.75, 6],
				"rotation": {"angle": 0, "axis": "y", "origin": [8, 7.00105, 7.80305]},
				"faces": {
					"north": {"uv": [9.5, 2.5, 11.5, 0.5], "texture": "#0"},
					"east": {"uv": [0, 2, 9, 0], "rotation": 180, "texture": "#0"},
					"south": {"uv": [9.5, 2.5, 11.5, 0.5], "texture": "#0"},
					"west": {"uv": [0, 0, 9, 2], "texture": "#0"},
					"up": {"uv": [0, 2, 9, 0], "rotation": 90, "texture": "#0"},
					"down": {"uv": [0, 0, 9, 2], "rotation": 270, "texture": "#0"}
				}
			},
			{
				"from": [8, 8.75, -3],
				"to": [8, 9.75, -1],
				"rotation": {"angle": 0, "axis": "y", "origin": [8, 7.00105, 7.80305]},
				"faces": {
					"north": {"uv": [0, 0, 2, 1], "texture": "#0"},
					"east": {"uv": [6, 15, 4, 16], "texture": "#0"},
					"south": {"uv": [0, 0, 2, 1], "texture": "#0"},
					"west": {"uv": [4, 15, 6, 16], "texture": "#0"},
					"up": {"uv": [0, 0, 2, 1], "texture": "#0"},
					"down": {"uv": [0, 0, 2, 1], "texture": "#0"}
				}
			},
			{
				"from": [6.5, 7.75, 6],
				"to": [9.5, 8.75, 13],
				"rotation": {"angle": 0, "axis": "y", "origin": [8, 7.00105, 7.80305]},
				"faces": {
					"north": {"uv": [6, 10, 3, 11], "texture": "#0"},
					"east": {"uv": [7, 3, 14, 4], "texture": "#0"},
					"south": {"uv": [13, 0, 12, 3], "rotation": 90, "texture": "#0"},
					"west": {"uv": [14, 3, 7, 4], "texture": "#0"},
					"up": {"uv": [9, 9, 6, 16], "texture": "#0"},
					"down": {"uv": [7, 0, 0, 1], "texture": "#0"}
				}
			},
			{
				"from": [6.5, 4.75, 2],
				"to": [9.5, 7.75, 13],
				"rotation": {"angle": 0, "axis": "y", "origin": [8, 7.00105, 7.80305]},
				"faces": {
					"north": {"uv": [6, 11, 3, 14], "texture": "#0"},
					"east": {"uv": [14, 4, 3, 7], "texture": "#0"},
					"south": {"uv": [16, 0, 13, 3], "rotation": 270, "texture": "#0"},
					"west": {"uv": [3, 4, 14, 7], "texture": "#0"},
					"up": {"uv": [3, 3, 0, 14], "rotation": 180, "texture": "#0"},
					"down": {"uv": [3, 3, 0, 14], "texture": "#0"}
				}
			},
			{
				"from": [8, 2.75, 10],
				"to": [8, 4.75, 14],
				"rotation": {"angle": 0, "axis": "y", "origin": [8, 7.00105, 7.80305]},
				"faces": {
					"north": {"uv": [0, 0, 4, 2], "texture": "#0"},
					"east": {"uv": [4, 14, 0, 16], "texture": "#0"},
					"south": {"uv": [0, 0, 4, 2], "texture": "#0"},
					"west": {"uv": [0, 14, 4, 16], "texture": "#0"},
					"up": {"uv": [0, 0, 4, 2], "texture": "#0"},
					"down": {"uv": [0, 0, 4, 2], "texture": "#0"}
				}
			},
			{
				"from": [8, 8.75, 10],
				"to": [8, 9.75, 12],
				"rotation": {"angle": 0, "axis": "y", "origin": [8, 7.00105, 7.80305]},
				"faces": {
					"north": {"uv": [0, 0, 2, 1], "texture": "#0"},
					"east": {"uv": [6, 15, 4, 16], "texture": "#0"},
					"south": {"uv": [0, 0, 2, 1], "texture": "#0"},
					"west": {"uv": [4, 15, 6, 16], "texture": "#0"},
					"up": {"uv": [0, 0, 2, 1], "texture": "#0"},
					"down": {"uv": [0, 0, 2, 1], "texture": "#0"}
				}
			},
			{
				"from": [7, -4.43706, 9.71454],
				"to": [9, 4.56294, 12.71454],
				"rotation": {"angle": -45, "axis": "x", "origin": [8, 7.00105, 7.80305]},
				"faces": {
					"north": {"uv": [9, 7, 11, 16], "texture": "#0"},
					"east": {"uv": [13, 7, 16, 16], "texture": "#0"},
					"south": {"uv": [11, 7, 13, 16], "texture": "#0"},
					"west": {"uv": [16, 7, 13, 16], "texture": "#0"},
					"up": {"uv": [0, 0, 3, 9], "texture": "#0"},
					"down": {"uv": [14, 4, 16, 7], "texture": "#0"}
				}
			}
		],
		"display": {
			"thirdperson_righthand": {
				"rotation": [60, 0, 0],
				"translation": [0, 4, 1],
				"scale": [0.55, 0.55, 0.55]
			},
			"thirdperson_lefthand": {
				"rotation": [60, 0, 0],
				"translation": [0, 4, 1],
				"scale": [0.55, 0.55, 0.55]
			},
			"firstperson_righthand": {
				"translation": [1, 3, 1],
				"scale": [0.68, 0.68, 0.68]
			},
			"firstperson_lefthand": {
				"translation": [1, 3, 1],
				"scale": [0.68, 0.68, 0.68]
			},
			"ground": {
				"translation": [0, 2, 0],
				"scale": [0.5, 0.5, 0.5]
			},
			"gui": {
				"rotation": [30, 45, 0],
				"scale": [0.625, 0.625, 0.625]
			},
			"head": {
				"rotation": [0, 180, 0],
				"translation": [0, 13, 7]
			},
			"fixed": {
				"rotation": [90, 60, -90],
				"translation": [1, 2, 0]
			}
		},
		"groups": [
			{
				"name": "pistol Breech",
				"origin": [8, 7.00105, 7.80305],
				"children": [0, 1]
			},
			{
				"name": "pistol",
				"origin": [8, 7.00105, 7.80305],
				"children": [2, 3, 4, 5, 6]
			}
		]
	},
	"perspectives": {
		"gui": {
			"parent": "item/generated",
			"textures": {
				"layer0": "mymodid:item/flintlock_icon"
			}
		}
	}
}

 

  • Quote

Share this post


Link to post
Share on other sites

Woodside    0

Woodside

Woodside    0

  • Tree Puncher
  • Woodside
  • Members
  • 0
  • 13 posts
Posted January 20 (edited)

I have found also that setting the "base" model to be "item/generated" also results in a blank hand-held item.

 

Something about SeparatePerspectiveModel doesn't like stock item models, it seems?

 

EDIT: I see now that I cannot use existing model templates due to them requiring their own model loader... So I'll need to make the item model from scratch.
EDIT2: Upon further inspection, it should still be trying to use the appropriate model loader for items when SeparatePerspectiveModel deserializes the perspective objects. So I am confused as to why it's not working.

Edited January 20 by Woodside
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 posts
Posted January 20

Item models are generated at runtime, this is handled by Forge in 1.16, but not in 1.15.

It is easy to fix though, see the following change you need to make (this is not necessary in 1.16, only when copying this to 1.15):

https://github.com/MinecraftForge/MinecraftForge/compare/1.16.x...diesieben07:separate-perspective-itemmodel

 

  • Quote

Share this post


Link to post
Share on other sites

Woodside    0

Woodside

Woodside    0

  • Tree Puncher
  • Woodside
  • Members
  • 0
  • 13 posts
Posted January 20
13 hours ago, diesieben07 said:

Item models are generated at runtime, this is handled by Forge in 1.16, but not in 1.15.

It is easy to fix though, see the following change you need to make (this is not necessary in 1.16, only when copying this to 1.15):

https://github.com/MinecraftForge/MinecraftForge/compare/1.16.x...diesieben07:separate-perspective-itemmodel

 

Thanks for the diff! Nearly there, except the 2D GUI icon is darker than other 2D items. Is there some flag I need to set?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7697

diesieben07

diesieben07    7697

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7697
  • 56382 posts
Posted January 21

Good question. I don't know much about rendering, so nothing comes to mind immediately.

  • Quote

Share this post


Link to post
Share on other sites

Woodside    0

Woodside

Woodside    0

  • Tree Puncher
  • Woodside
  • Members
  • 0
  • 13 posts
Posted January 21

In the BakedModel class in SeparatePerspectiveModel, I changed func_230044_c_()/isSideLit() to return always false. That fixed the lighting issue with the GUI icon, but I cannot tell if it had any effect on the 3D model or not. It doesn't seem to have.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • GhostGamesFSM
      1.16 Ore generation.

      By GhostGamesFSM · Posted 10 minutes ago

      sorry for the txt, but thanks for the comment. I don't have a BiomeLoadingEvent, but I just have to see how I do that. When I have that I send you a message if that works.
    • HOTSAUCEMAN
      help with loading my world

      By HOTSAUCEMAN · Posted 11 minutes ago

      just ran it again to get more updated logs  debug-1.log.gz
    • HOTSAUCEMAN
      help with loading my world

      By HOTSAUCEMAN · Posted 15 minutes ago

      when loading into my world it says its loading, and then changes to a dirt background with no text; i've looked at multiple threads, forums and videos but i can't find any issue similar to mine (at least on a similar version)  debug-1.log.gz
    • Beethoven92
      [1.16.5] Beacon Overwrite (Screen Error)

      By Beethoven92 · Posted 22 minutes ago

      I apologize...i misread the part where you say that your custom beacon inventory actually opens fine! Yeah, the proximity check is doing its job, the problem seems to be that when pressing the confirm button you are sending a vanilla CUpdateBeaconPacket, then handled by the server, which will check if your open container is a BeaconContainer. It would be helpful to see the complete code you have, please post a link to your repository
    • Beethoven92
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By Beethoven92 · Posted 40 minutes ago

      Show what you tried then. It should be "enchantment.your_mod_id.your_enchantment_id"
  • Topics

    • GhostGamesFSM
      2
      1.16 Ore generation.

      By GhostGamesFSM
      Started 17 hours ago

    • HOTSAUCEMAN
      1
      help with loading my world

      By HOTSAUCEMAN
      Started 15 minutes ago

    • Nyko
      3
      [1.16.5] Beacon Overwrite (Screen Error)

      By Nyko
      Started Yesterday at 07:22 AM

    • samjviana
      5
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana
      Started Sunday at 10:00 PM

    • DrigglyEast
      0
      Fatally Missing Registry Entries

      By DrigglyEast
      Started 2 hours ago

  • Who's Online (See full list)

    • EdekaKuchen
    • alexro871
    • GhostGamesFSM
    • Beethoven92
    • IntentScarab
    • CookieLukas
    • Tavi007
    • HOTSAUCEMAN
    • zlappedx3
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [SOLVED][1.15.2] Render as 2D icon in GUI, 3D model in hand
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community