Posted June 12, 20205 yr 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.
June 12, 20205 yr 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 June 12, 20205 yr 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.
June 12, 20205 yr Author 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)
June 12, 20205 yr 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 June 12, 20205 yr 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.
June 13, 20205 yr Author 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. As 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 June 13, 20205 yr 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.