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:

  Reveal hidden contents

 

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)
  On 6/12/2020 at 7:44 AM, 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)

Expand  

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:

  Reveal hidden contents

 

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

    • Sorry for the late response, but the game opened and I made a world but it's stuck at 0% Here's the latest.log https://mclo.gs/peEb1R8 I disabled The Factory Must Grow and soulsweapons
    • Hey everyone! Two of my friends downloaded this modpack and are having an issue with the blocks loading in correctly. Grass looks like bamboo, waystones look like two barrels stacked on eachother, and wheat looks like water and stairs. What is this problem? How can we fix it? Neither of my other friends or myself had this issue. 
    • I removed Yung's cave biome mod and It wasnt in one of those biomes however the log file said the same line (([25Apr2025 21:20:15.500] [Flywheel Task Executor #5/WARN] [Embeddium-MixinTaintDetector/]: Mod(s) [oculus] are modifying Embeddium class me.jellysquid.mods.sodium.client.render.vertex.serializers.VertexSerializerRegistryImpl, which may cause instability.))
    • Note: i had a couple of ideas, but i just don't know how to execute them. The main idea was to make the new block (let's exemplify with a mixer) be essentially a clone of the mechanical mixer (different texture tho) that would have a different recipe type (instead of mixing, advanced_mixing) and i would copy all the create mod recipes and edit the processing time while also adding the tier dependent ones.
    • Hi! Before everything, thank you for even reading. I'm coming here in need of help making a few aspects for a create mod addon. It's an addon that aims to add almost the full periodic table with realistic ways of obtaining all the elements and capability of almost full automation. For what purpose? A techy armor and to go to the moon and rocky planets of the solar system. It'll have 3 different tiers of machines (mixer, millstone, crushing wheels): basic (just the normal create mod machines but renamed), advanced (25% faster and has recipes only possible for this tier and above) end elite (75% faster than basic and recipes only available for this tier). The problem is, I'm not a coder. I know less than the basics. I know how to do everything else but these machine tiers and i need some help if you can.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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