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.

Featured Replies

Posted

I want to render a Blocks using dual Texture (actually triple, base texture and overlay + lightmap).

But I can't find anyway to make it efficient, as in swapping textures there and back(disabling and enabling the third texture + few other tweaks) take a good bit of CPU time, combining those calls would make a huge improvement.

I was just looking at the source of WorldRenderer and I can't find a way to inject code in WorldRenderer .updateRenderer() or RenderGlobal.sortAndRender().

 

Is there anyway to make it?

 

I can see few possible options:

-preRender and postRender events in the rendering into displayLists code

-onChunkRender events

-even onWorldRender would be fine

 

But I couldn't find any of those, if someone could help me I would appreciate it.

Hi

 

If you only want to dual texture for your custom blocks, you can just use an ISimpleBlockRenderingHandler and do whatever rendering you want.  If you're worried about flipping back and forth between different textures, you could register multiple icons for your block and just change the texture coordinates between each one?

 

You realise that Blocks are already rendered with 3 textures?  Perhaps you can hijack pass1 for what you want to do?

pass 0 (alpha blend off)

pass 1 (alpha blend on)

and

multitexturing (lightmap)?

 

Failing that, you could use a technique called ASM/reflection to insert calls to your rendering pass at the appropriate parts in the code.  To be honest I don't know if the events you mentioned will give you control at the right spot, but I haven't found anything suitable previously.

 

-TGG

  • Author

Thanks for the reply,

The thing is that I'm using lightmaps as well + 2x standard textures(2 different icons).

I need it to make sure no Z-Fighting occurs and to prevent other glitches.

(Example of Z-Fighting in XYCraft: http://i.imgur.com/5X3v7.jpg)

 

Maybe I have phrased the topic's title wrong, I need hooks in the beginning and at the end of the pre-rendering into DisplayLists code as I use custom rendering system that renders all of my blocks in a TextureArray that it then send to the graphics card.

Doing so for each block is wasteful, on the other hand doing that per chuck increases the performance significantly.

At the beginning of the pre-rendering I need to reset my buffers and before GL11.glEndList() I need to inject code to render my blocks for this to work the way it should.

 

I was looking for it in 1.6.4 and now in 1.7.2 without success.

 

I guess I will use ASM to inject the code, it shouldn't be too hard hopefully.

 

Thanks for helping

  • Author

OK, I have managed to get it working.

It's really confusing.

 

I had problems with ClassWriter.COMPUTE_FRAMES (only in release environment)

ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);

after changing it to

ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);

it worked fine, but I'm not sure if it is right?

 

Another thing is the obstructed classes, I have it hard-coded now, is there any API for getting the deobstructed - obstructed names?

 

Or is there a common way of doing ASM stuff in forge? I was looking around but couldn't find anything.

 

Also I have a question about reflection, the following code gives me exceptions (in dev environment):

Class<?> EntityLivingClass = Class.forName("net.minecraft.entity.EntityLiving");
EntityLiving_isPlayer = EntityLivingClass.getDeclaredMethod("isPlayer");

(It works if I use the methods normally and move the class into net.minecraft.entity, but then forge complains)

I was looking around and found info that it is recommended to use reflection instead of Access Transformers.

The question is: is there a common API for reflection in forge?

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.