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
  • [1.12.2] Rendering item in front of everything else
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Nuparu00

[1.12.2] Rendering item in front of everything else

By Nuparu00, December 6, 2019 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Nuparu00    1

Nuparu00

Nuparu00    1

  • Tree Puncher
  • Nuparu00
  • Members
  • 1
  • 15 posts
Posted December 6, 2019 (edited)

Hi.

In my mod, I am rendering custom first-person arms when certain items are held. I managed to do this and it works and looks quite well. However, there is one major issue - the arms and the held item can clip through blocks, mobs, etc.. So I looked at how Minecraft renders its arms, and figured out, that it "disables depth" ( using GlStateManager.disableDepth() ) so the arms are rendered on top of everything else + it also enables culling ( GlStateManager.enableCull() ). I call these before rendering the arms (and also their "opposite functions" after rendering the arms), and it works - the arms are rendered as the vanilla ones. However, it doesn't work with complex items.

It seems that this disables the "depth check" even between vertices that are part of the item, so the faces that are hidden and face the camera are rendered on top.

 

My code: https://pastebin.com/qR8kJJDF

 

EDIT: The problem almost surely is not with my models, as I tested it with vanilla items, and the same glitch occurred, though since Minecraft items are flat it is not this much visible.

 

d.png

 

b.png

c.png

e.png

Edited December 6, 2019 by Nuparu00
Better picture
  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

SerpentDagger    18

SerpentDagger

SerpentDagger    18

  • Creeper Killer
  • SerpentDagger
  • Members
  • 18
  • 132 posts
Posted December 15, 2019 (edited)
On 12/6/2019 at 8:52 AM, Nuparu00 said:

the arms and the held item can clip through blocks, mobs, etc

Could you show an example of this? I'm not sure what you mean.

 

On 12/6/2019 at 8:52 AM, Nuparu00 said:

that it "disables depth"

That seems odd. For example, when I disable depth in one of my rendering sections, the arms and rendering turn out like this. (It's an opaque sphere.)
2019-12-14_17_44_59.png.c1bb188f4a7f2db64e62869dbb480f33.png

 

I think you may have been looking in the wrong location there.

In fact, I can't find any reference to GlStateManager#disableDepth() within ItemRenderer#renderItemInFirstPerson(), ItemRenderer#renderArmFirstPerson(), RenderPlayer#renderRightArm(), or ModelRenderer#doRender().

Moreover, cull is actually disabled in RenderLivingBase#doRender().

 

To solve your problem, then, I think you need to disable culling, and enable depth.

That might just get you back to your original issue, but I'd like to make sure I understand what that is before I try and help there.

2019-12-14_17.42.13.png

Edited December 15, 2019 by SerpentDagger
  • Quote

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

Share this post


Link to post
Share on other sites

Nuparu00    1

Nuparu00

Nuparu00    1

  • Tree Puncher
  • Nuparu00
  • Members
  • 1
  • 15 posts
Posted December 29, 2019
 
 
 
 
On 12/15/2019 at 3:06 AM, SerpentDagger said:

Could you show an example of this? I'm not sure what you mean.

 

Here is a video that I recorded.

 

  • 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

    • gamer650xd
      whenever I join a server it shows me this error

      By gamer650xd · Posted 2 minutes ago

      crash-2021-01-16_21.37.09-client.txt
    • Bailym
      Cant Get a Config File Working 1.16.5

      By Bailym · Posted 3 minutes ago

      I initially removed the .gitignore because i wanted to preserve the world saves, ill add it back in with the necessary exceptions.   Just to clarify. If you set enableOakWood to false in extraarmor-common.toml the line    System.out.println(ArmorConfig.COMMON.enableOakWood.get()); //Always True   returns false as expected? As i'm not getting the same behavior
    • gamer650xd
      whenever I join a server it shows me this error

      By gamer650xd · Posted 6 minutes ago

      internal exception: com.google.common.util.concurrent.UncheckedExecutionException:net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Minecraft Forge (forge)   crash-2021-01-16_21.37.09-client.txt
    • diesieben07
      Cant Get a Config File Working 1.16.5

      By diesieben07 · Posted 9 minutes ago

      I can't reproduce this. I cloned your repo and re-enabled the commented-out config registration. Setting a value to false in the common config file worked fine.   Your Git repository contains a lot of unnecessary stuff and is therefor slow to clone. The MDK comes with a gitignore file for a reason - please use it.
    • e2rifia
      (1.16.2) How do I use onPlayerTick?

      By e2rifia · Posted 18 minutes ago

      It works! It works!   public static void onPlayerTick(TickEvent.PlayerTickEvent event){         if (event.phase != Phase.START || event.player == null) return;         if (!event.player.world.isRemote) {         PlayerEntity player = event.player;         Vector3d v3 = player.getLook(1);         SmallFireballEntity fireball = new SmallFireballEntity(player.getEntityWorld(), player.getPosX(), player.getPosY() + player.getEyeHeight(), player.getPosZ(), v3.x, v3.y, v3.z);         fireball.setShooter(player);         player.getEntityWorld().addEntity(fireball);         }     }
  • Topics

    • gamer650xd
      1
      whenever I join a server it shows me this error

      By gamer650xd
      Started 6 minutes ago

    • Bailym
      10
      Cant Get a Config File Working 1.16.5

      By Bailym
      Started 1 hour ago

    • e2rifia
      4
      (1.16.2) How do I use onPlayerTick?

      By e2rifia
      Started 3 hours ago

    • kiou.23
      11
      [1.16] Custom Sign won't render

      By kiou.23
      Started 9 hours ago

    • Ipsissimus418
      1
      [1.16.4] WorldTickEvent Concurrent Access Exception

      By Ipsissimus418
      Started 31 minutes ago

  • Who's Online (See full list)

    • diesieben07
    • Bailym
    • Beethoven92
    • Boetam
    • gamer650xd
    • Babatunde
    • Linky132
    • Lellian
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] Rendering item in front of everything else
  • Theme

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