Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.10] Editing EntityRenderer : ASM mandatory ?

Featured Replies

Posted

Hi.

 

I would like to edit what EntityRender does. I first tried the naive way : extend it, and replace the (already public) field Minecraft.entityRenderer, at preInit.

		assert(Minecraft.getMinecraft().entityRenderer != null);
	Minecraft.getMinecraft().entityRenderer = new ModdedEntityRenderer(Minecraft.getMinecraft(), Minecraft.getMinecraft().getResourceManager());
	((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(Minecraft.getMinecraft().entityRenderer);

As expected, Crash report : http://hastebin.com/uzumikujim.txt

The original renderer is instanciated at startGame() and probably holds data I loose when overriding the field with a fresh instance, hence the crash I suppose.

Could I do it any other way than byte code patching or is it really too deep for more.. conventional modding ?

 

 

Question: Where did you initlialize the renderer? Your preInit in your main class? Client-Proxy? CommonProxy?

Minecraft#getMinecraft is purely client-side. Running it on the server-side will always return nullpointer, because for the server, that method does not exist.

 

I do apologize if you already know of this. You'd be surprised how many try to run Minecraft#getMinecraft server-side.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

	EntityRendererSpecial entityRenderer = (EntityRendererSpecial) Minecraft.getMinecraft().entityRenderer;
	Minecraft.getMinecraft().entityRenderer = entityRenderer;

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • Author

In the client proxy, yes.

 

Anyone can try for himself. Do a class that extends EntityRenderer (no need to edit anything, just do a useless class) and add the code I posted in OP in ClientProxy.preInit(), the crash will happen, it's easy to reproduce.

 

I do not know exactly what happens between startGame() and the triggering of preInit(), maybe doing the swap earlier (than preInit()) could do the trick.. which is assuming the rest of startGame() after the instanciation does not modify entityRenderer which is a big assumption since it has already been registered and can by that point be called by absolutely everything in the mean time.

 

Given prompts that appear sometimes, I'm f*cking up something with FML too, so my hope is decreasing.

 

 

This piece of code didn't crash for me

 

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	if (event.getSide() == Side.CLIENT) {
		EntityRendererSpecial entityRenderer = (EntityRendererSpecial) Minecraft.getMinecraft().entityRenderer;
		Minecraft.getMinecraft().entityRenderer = entityRenderer;
	}
}

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • Author

Now add a simple test() method with let's say, a println, and call it.

((SpecialEntityRenderer) Minecraft.getMinecraft().entityRenderer).test().

Boom, crash. Because this is not an instance of SpecialEntityRenderer, so you're calling something the object don't have.

When existing methods are called, it's the EntityRenderer behavior that will be chosen, not the Special one.

  • Author

I would like to differentiate the lightmap updating between dimensions by editing EntityRenderer.updateLightmap(), change the perceived brightness (lighter/darker) according to moon phases or random days I decided.

I would like to differentiate the lightmap updating between dimensions by editing EntityRenderer.updateLightmap(), change the perceived brightness (lighter/darker) according to moon phases or random days I decided.

There is a way with reflection for that, look at how the dynamic texture is managed.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

  • Author

There is a way with reflection for that, look at how the dynamic texture is managed.

 

Forcing my own lightmap texture so ? I think it does handle sky exposure, maybe phases.. I'm not sure how that would work out...

 

You already did it yourself in the past ?

 

Believe me as I've been stupid enough to try this; DO NOT REPLACE THE ENTITYRENDERER! You'll break Optifine, you'll break shaders, you'll need to rewrite all your code with every update; just dont do it.

 

Changing the EntityRenderer.updateLightmap() is extremely basic using an ASM system, or a Forge Hook if you get one. I'd much rather look into both than making that mistake again

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.