Jump to content

Recommended Posts

Posted

So, I'm currently in the process of making a mod that adds defensive blocks and items. Code is at GitHub, branch 'camera'.

 

Specifically, I'm creating a camera block. I'm trying and learning on how to change the current camera perspective. I've already done it using Minecraft#setRenderViewEntity, however the original player entity is not rendered. I've narrowed it down to this line of code in WorldRenderer, which is called for all entities in the world:

// WorldRenderer.class, version 1.15.2, 20200514-1.15.1 mappings, line 947
         if ((this.renderManager.shouldRender(entity, clippinghelperimpl, d0, d1, d2) || entity.isRidingOrBeingRiddenBy(this.mc.player)) && (entity != activeRenderInfoIn.getRenderViewEntity() || activeRenderInfoIn.isThirdPerson() || activeRenderInfoIn.getRenderViewEntity() instanceof LivingEntity && ((LivingEntity)activeRenderInfoIn.getRenderViewEntity()).isSleeping()) && (!(entity instanceof ClientPlayerEntity) || activeRenderInfoIn.getRenderViewEntity() == entity)) {

That's a long conditional, so I've broken it down into three parts that must all be true for the entity to render:

  • The entity's renderer's #shouldRender returning true, OR entity is/has passenger of the player
  • The entity is not the current renderViewEntity, OR the render is in 3rd person, OR
    • the renderViewEntity is an instance of LivingEntity, AND the renderViewEntity is sleeping
  • The entity is not an instance of ClientPlayerEntity, OR the entity is the renderViewEntity

 

The first two conditions are fine, however the third condition is giving me trouble because the player entity is not the renderViewEntity anymore, so the condition fails.

What I'm asking is, is there a better way to get around that third condition, without having to resort to using a coremod and rewriting the method? I am afraid to use coremods, after looking through posts by Forge modders which clearly state to never, ever use coremods if I can help it.

Posted (edited)

You can subscribe to RenderWorldLastEvent and manually render the player there.

Only do this on the client that has its view entity changed to the camera.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted

It works! And such a simpler solution than modifying class bytecode. A problem that I see doing this though is the nameplate is delayed in rendering, so it doesn't exactly follow the player model. (like when using command blocks to teleport armor stand to the player, there's a small gap when the player moves until the armor stand gets back in position to the player)

Posted (edited)
1 hour ago, sciwhiz12 said:

It works! And such a simpler solution than modifying class bytecode. A problem that I see doing this though is the nameplate is delayed in rendering, so it doesn't exactly follow the player model. (like when using command blocks to teleport armor stand to the player, there's a small gap when the player moves until the armor stand gets back in position to the player)

There won’t be any delay as you are rendering during the same frame.

Rendering per frame is drastically different from executing a command in a command block.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted (edited)

I phrased it wrongly; it was rendering as if the nameplate was a separate entity from the player, teleporting every tick, so movement means the nameplate had to catch up to the player. Anyway, that problem somehow fixed itself, but a new problem has manifested.

2020-06-13_08_31_53.png.1a36eee2d756a0d9471b0d5a27d3e3fc.pngAs the player model moves farther away from the center of the screen, held items (and, if the player is flying, the text on the nameplate) move also in the same direction. Also, the items are rendered in front of the player model, which is plainly wrong. Also, the nameplate and items were rendered in the inventory screen, but as I'm going to disable inventory access for players using cameras, this won't really be a problem I think.

If anyone can please help me troubleshoot this, I will greatly appreciate it. The code is at my GitHub, branch 'camera'.

Edited by sciwhiz12
edit in italics

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

    • Yep I did upgrade just because it showed me a new version available.  I'll redownload the mod list and make sure anything works.  Thanks!
    • The latest log was taken down by pastebin for some reason. Did you try removing the mods you added? The mods you updated, was there a specific reason you updated, or just because? It's possible the updates introduced incompatibilitie, or even need a newer build of forge. If you didn't need the updates for a specific reason, you could also try downgrading those mods.
    • Please read the FAQ, and post logs as described there. https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/
    • I am using forge 1.20.1 (version 47.3.0). My pc has an RTX 4080 super and an i9 14900 KF, I am on the latest Nvidia graphics driver, latest windows 10 software, I have java 23, forge 1.12.2 works and so does all vanilla versions but for some reason no version of forge 1.20.1 works and instead the game just crashes with the error code "-1." I have no mods in my mods fodler, I have deleted my options.txt and forge.cfg files in case my settings were causing a crash and have tried removing my forge version from the installations folder and reinstalling but no matter what I still crash with the same code and my log doesn't tell me anything: 18:34:53.924 game 2025-02-06 18:34:53,914 main WARN Advanced terminal features are not available in this environment 18:34:54.023 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, mrmirchi, --version, 1.20.1-forge-47.3.0, --gameDir, C:\Users\aryam\AppData\Roaming\.minecraft, --assetsDir, C:\Users\aryam\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, 2db00ea8d678420a8956109a85d90e9d, --accessToken, ????????, --clientId, ZWI3NThkNzMtNmNlZS00MGI5LTgyZTgtYmZkNzcwMTM5MGMx, --xuid, 2535436222989555, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\aryam\AppData\Roaming\.minecraft\quickPlay\java\1738838092785.json, --launchTarget, forgeclient, --fml.forgeVersion, 47.3.0, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] 18:34:54.027 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 10 arch amd64 version 10.0 18:34:54.132 game [18:34:54] [main/INFO] [ne.mi.fm.lo.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow 18:34:54.191 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 18:34:54.303 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 18:34:54.367 monitor Process Monitor Process crashed with exit code -1     screenshot of log: https://drive.google.com/file/d/1WdkH88H865XErvmIqAKjlg7yrmj8EYy7/view?usp=sharing
    • I am currently working on a big mod, but I'm having trouble with my tabs, I want to find a way to add tabs inside tabs, like how in mrcrayfishes furniture mod, his furniture tab has multiple other sub tabs to them, so i know it is possible but i just don't know how it is possible, any help would be appreciated, thanks
  • Topics

×
×
  • Create New...

Important Information

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