Jump to content

[1.10.2] Advanced TileEntity Renderers


Zane49er

Recommended Posts

I have been searching for a way to make the rifts in my mod look how I want them to for a very long time, and I think I've found it - a custom renderer! I want them to have the following properties:

*Fulbright

*any color

*slightly procedural (explained later)

 

My current code can be found here https://github.com/zane49er2/VMC , or in the spoiler.

Spoiler

package zane49er.VolkiharEchoes.features.tileEntities;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.tileentity.TileEntity;

public class RiftRenderer extends TileEntitySpecialRenderer {
	
	int r = 200;
	int g = 200;
	int b = 200;
	
	@Override
	public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick, int destroyStage) {
		GlStateManager.pushMatrix(); {
			GlStateManager.translate(x + 0.5, y + 0.066, z + 0.75);
			//GlStateManager.rotate(90F, 1.0F, 0.0F, 0.0F);
			//GlStateManager.scale(0.25F, 0.25F, 0.25F);
			GlStateManager.color(r, g, b);
	        GlStateManager.disableLighting();
			Tessellator wrt = Tessellator.getInstance();
	        VertexBuffer wr = wrt.getBuffer();
	        wr.begin(7, DefaultVertexFormats.POSITION_COLOR);
	        wr.color(r, g, b, 255);
			wr.pos(x, y, z);
			wr.pos(x+1, y, z);
			wr.pos(x+1, y+1, z);
			wr.pos(x, y+1, z);
			wrt.draw();
		}
		GlStateManager.popMatrix();
	}
}

 

 

This code renders literally nothing, though. I copied it from 3 different places (chest, beacon, and internet) and 2 hours of research, so it might just be that I'm combining way too many methods into the same thing.

 

By "slightly procedural" I mean that there will be a list of 'arms' in the TileEntity that is randomly generated. Those arms are what eventually want to render.

 

I want the final product to look like a 3D crack in the sky from any angle. The closest thing I can think of in reality (or other mods) is a ball of lightning generated by tesla coil or something, but concentrated and larger in the center to look like glass cracking.

 

Is this entirely stupid, or how can I implement it?

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Link to comment
Share on other sites

  • color is a property of a vertex, you can't just put it into a buffer without any context and expect it to work.
  • After defining a vertex you must end it's definition with VertexBuffer::endVertex.
  • There is no point in applying color with GlStateManager as your vertex format already specifies a color.
  • If you are changing states of GlStateManager - reset them after you are done. If you are disabling the lighting before drawing enable it after you are done.
  • You have already translated everything by xyz with GlStateManager.translate. Putting xyz as origin in your vertices is going to translate them again, causing issues.
  • If you want your rendering 'fullbright' disabling lighting is not going to be enough, you will need to specify lightmap coordinates.
16 minutes ago, Zane49er said:

how can I implement it?

That is really up tou you. I do not think there are any tutorials out there that would describe how to render "a rift". You would want to play with rendering untill you achieve the effect you are after.

Link to comment
Share on other sites

I really just have no Idea how the vertexbuffer system works. what I meant by "how can I implement it?" was "how can I make the colored, fullbright, procedural model?"

 

  • Vertexes = vertices = points, so how can color be for vertex and not face? where do I define the color?
  • I'll try putting that just before the draw, but I don't know if that's right
  • good point.
  • thanks
  • thanks
  • how?

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Link to comment
Share on other sites

8 minutes ago, Zane49er said:

Vertexes = vertices = points, so how can color be for vertex and not face?

Have you heard of gradients? How do you think they work? The color is a property of a vertex, aka a point. If you define a point with a red color and a point with a green color the color of the line drawn between those two points will be linearly interpolated.

 

8 minutes ago, Zane49er said:

I'll try putting that just before the draw, but I don't know if that's right

You put it after you define a vertex. When you call pos you define a position element of a vertex. When you call color you define another element of a vertex.

wr.pos(0, 0, 0).color(100, 100, 100, 255).endVertex(); is a fully defined position + color vertex.

 

8 minutes ago, Zane49er said:

how?

You would either select a vertex format that uses lightmap as one of it's vertex elements or manualy set it with OpenGlHelper.setLightmapTextureCoords. If you use the later do not forget to reset it back.

 

Additionally if your vertex format does not include UVs(texture) disable it before rendering(GlStateManager.disableTexture2D) and enable it after you are done.

Edited by V0idWa1k3r
  • Like 1
Link to comment
Share on other sites

this:

Spoiler

package zane49er.VolkiharEchoes.features.tileEntities;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.tileentity.TileEntity;

public class RiftRenderer extends TileEntitySpecialRenderer {
	
	int r = 200;
	int g = 200;
	int b = 200;
	
	@Override
	public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick, int destroyStage) {
		GlStateManager.pushMatrix(); {
			GlStateManager.translate(x + 0.5, y + 0.066, z + 0.75);
			//GlStateManager.rotate(90F, 1.0F, 0.0F, 0.0F);
			//GlStateManager.scale(0.25F, 0.25F, 0.25F);
			//GlStateManager.color(r, g, b);
	        GlStateManager.disableLighting();
	        GlStateManager.disableTexture2D();
			Tessellator wrt = Tessellator.getInstance();
	        VertexBuffer wr = wrt.getBuffer();
	        wr.begin(7, DefaultVertexFormats.POSITION_COLOR);
			wr.pos(0, 0, 0).color(r, b, g, 255).lightmap(255, 255).endVertex();
			wr.pos(1, 0, 0).color(r, b, g, 255).lightmap(255, 255).endVertex();
			wr.pos(1, 1, 0).color(r, b, g, 255).lightmap(255, 255).endVertex();
			wr.pos(0, 1, 0).color(r, b, g, 255).lightmap(255, 255).endVertex();
			wrt.draw();
	        GlStateManager.enableLighting();
	        GlStateManager.enableTexture2D();
		}
		GlStateManager.popMatrix();
	}
}

 

still does nothing.

Edited by Zane49er

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Link to comment
Share on other sites

Spoiler

package zane49er.VolkiharEchoes.features.tileEntities;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.tileentity.TileEntity;

public class RiftRenderer extends TileEntitySpecialRenderer {
	
	int r = 200;
	int g = 200;
	int b = 200;
	
	@Override
	public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick, int destroyStage) {
		GlStateManager.pushMatrix(); {
			GlStateManager.translate(x + 0.5, y + 0.066, z + 0.75);
			//GlStateManager.rotate(90F, 1.0F, 0.0F, 0.0F);
			//GlStateManager.scale(0.25F, 0.25F, 0.25F);
			//GlStateManager.color(r, g, b);
	        GlStateManager.disableLighting();
	        GlStateManager.disableTexture2D();
			Tessellator wrt = Tessellator.getInstance();
	        VertexBuffer wr = wrt.getBuffer();
	        wr.begin(7, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
			wr.pos(0, 0, 0).lightmap(255, 255).color(r, b, g, 255).endVertex();
			wr.pos(1, 0, 0).lightmap(255, 255).color(r, b, g, 255).endVertex();
			wr.pos(1, 1, 0).lightmap(255, 255).color(r, b, g, 255).endVertex();
			wr.pos(0, 1, 0).lightmap(255, 255).color(r, b, g, 255).endVertex();
			wrt.draw();
	        GlStateManager.enableLighting();
	        GlStateManager.enableTexture2D();
		}
		GlStateManager.popMatrix();
	}
}

2017-08-03_01.21.57.png2017-08-03_01.21.37.png2017-08-03_01.21.24.png

It's definitely rendering something now! I still don't get light maps or why they have stretched to infinity.

Edited by Zane49er

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Link to comment
Share on other sites

The ordering matters. If your format is POSITION_TEX_LMAP_COLOR then you must specify a position, a set of UVs, a lightmap and color in that order. Also as this format uses UVs you shouldn't disable the texture. You should also provide a set of UVs that makes sense, not fill it with zeroes.

Additionally I believe that lightmap of 255 255 is actually pretty dark. I use 240 240 when I want full brightness.

 

As you've pretty much got it done here is a code snippet that renders your quad:

wr.pos(0, 0, 0).tex(0, 0).lightmap(240, 240).color(r, b, g, 255).endVertex();
wr.pos(1, 0, 0).tex(1, 0).lightmap(240, 240).color(r, b, g, 255).endVertex();
wr.pos(1, 1, 0).tex(1, 1).lightmap(240, 240).color(r, b, g, 255).endVertex();
wr.pos(0, 1, 0).tex(0, 1).lightmap(240, 240).color(r, b, g, 255).endVertex();

Note that it rendrs whatever texture was bound last, and it is a small face that only renders when you look at it from a specific side. This is most likely not what you want to achieve but it is a starting point, I suppose ;)

Link to comment
Share on other sites

Ideally It'd have no texture, but I only saw the one format with light map... is there something I'm missing? Also, thanks a lot for the help. This is, indeed, a start... and often the math stuff is easier than the language stuff for me, so I expect most of the work is in that start.

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Link to comment
Share on other sites

Just now, Zane49er said:

Ideally It'd have no texture, but I only saw the one format with light map... is there something I'm missing?

You can use 

39 minutes ago, V0idWa1k3r said:

OpenGlHelper.setLightmapTextureCoords

 Store the previous coordinates in locals(the current coordinates are stored in OpenGlHelper.lastBrightnessX and OpenGlHelper.lastBrightnessY), set the coordinates to whatever you want, render your thing and reset them back. The target parameter for OpenGlHelper.setLightmapTextureCoords would be OpenGlHelper.lightmapTexUnit

 

  • Like 1
Link to comment
Share on other sites

Spoiler

package zane49er.VolkiharEchoes.features.tileEntities;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.GlStateManager;

import net.minecraft.client.renderer.OpenGlHelper;

import net.minecraft.client.renderer.Tessellator;

import net.minecraft.client.renderer.VertexBuffer;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

import net.minecraft.client.renderer.vertex.DefaultVertexFormats;

import net.minecraft.tileentity.TileEntity;

 

public class RiftRenderer extends TileEntitySpecialRenderer {

 

int r = 255;

int g = 0;

int b = 0;

 

@Override

public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick, int destroyStage) {

GlStateManager.pushMatrix(); {

 

float PBX = OpenGlHelper.lastBrightnessX;

float PBY = OpenGlHelper.lastBrightnessX;

 

//GlStateManager.translate(x + 0.5, y + 0.066, z + 0.75);

//GlStateManager.rotate(90F, 1.0F, 0.0F, 0.0F);

//GlStateManager.scale(0.25F, 0.25F, 0.25F);

 

Tessellator wrt = Tessellator.getInstance();

VertexBuffer wr = wrt.getBuffer();

 

GlStateManager.disableLighting();

GlStateManager.disableTexture2D();

OpenGlHelper.setLightmapTextureCoords(240, 240, 240);

 

wr.begin(7, DefaultVertexFormats.POSITION_COLOR);

wr.pos(0, 0, 0).color(r, b, g, 255).endVertex();

wr.pos(1, 0, 0).color(r, b, g, 255).endVertex();

wr.pos(1, 1, 0).color(r, b, g, 255).endVertex();

wr.pos(0, 1, 0).color(r, b, g, 255).endVertex();

 

wr.begin(7, DefaultVertexFormats.POSITION_COLOR);

wr.pos(0, 0, 0).color(r, b, g, 255).endVertex();

wr.pos(0, 1, 0).color(r, b, g, 255).endVertex();

wr.pos(1, 1, 0).color(r, b, g, 255).endVertex();

wr.pos(1, 0, 0).color(r, b, g, 255).endVertex();

 

wrt.draw();

 

GlStateManager.enableLighting();

GlStateManager.enableTexture2D();

OpenGlHelper.setLightmapTextureCoords(???, ???, ???);

 

}

GlStateManager.popMatrix();

}

}

I am now even more confused about how minecraft's Lightmaps work...

This crashes the game (even without the use of ??? as an integer)

Really, a 3d lightmap? or a strange integer in a float lightmap?

??????

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Link to comment
Share on other sites

Thanks, everything is working!

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Link to comment
Share on other sites

Okay, one more thing: can I make it so it renders no matter how far away you are? Like a beacon, instead of a sign, it is still visible when you are several chunks away.

2017-08-03_11.27.14.png

There are a few rifts, signs, and chests surrounding the beam.

Edited by Zane49er

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Link to comment
Share on other sites

good point, I'm still not really used to having access to them... I just managed to decompile Minecraft on Wednesday. :P

 

edit: hmmm, this:

public boolean isGlobalRenderer(TileEntityRift te) {

return true;

}

 

doesn't work...

Edited by Zane49er

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Link to comment
Share on other sites

You need to potentially override TileEntity::getRenderBoundingBox and TileEntity::getMaxRenderDistanceSquared. The first method dictates whether to render your TE if it is's origin is not within camera's viewport, the second one dictates the distance to stop rendering your TE at. Mind the "squared" in the name of the method. By default it returns 4096 that translates to 64 blocks.

  • Like 1
Link to comment
Share on other sites

Yep, that was it! thanks again for all the help.

Lord Volkihar has requested that I send the following message to everyone who is gifted, intellectually or artistically:

We hope that some people could help us share an epic tale of lord Volkihar's achievements and magnificent life. we plan to do this through modern media such as books, games, and mods.

For lost details, we are looking for around 5 gallons of Cortexiphan, and some N.Z.T.(around 50 pills) also, if you happen to know how to create a gel with the same density as human flesh, but low viscosity and adhesion, recipes would be appreciated.

Link to comment
Share on other sites

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello, I don't have much experience with forge but I have some java knowledge, I want to add a button that says "Explore New Packs" to the Pause Screen that opens when we enter a world in the game and press the "esc" button, but I couldn't understand it (or I don't know how to use it), although I did research from artificial intelligence or different places. I was told that I can do it using mixins but I have no idea how to do it, can you explain step by step
    • We need the crash report or debug.log, as explained in the FAQ
    • i have the decocraft mod and i can see all of them. i can click right click and place the items but as soon as i put it down it disappears. im so sad it doesnt work and i dont know how to fix it. i used cursed forge to launch minecraft as well.
    • Me and my friend wanted to make a custom mod pack hosted on aternos. I downloaded the same mods as the server then started the server and my minecraft and I joined the server without issues. Then I sent the mods to my friend compressed in a zip folder (i don’t know if that has anything to do with the issue). He unpacked it put it in his mod folder and started it but couldn't join the server and got this issue:   internal exception: java.lang.runtimeexception: server not initialized yet! call IMDLib.entityHandler (modid)   Also we are using curseforge launcher to manage the mods on client side. But as I said it works on my side but not with my friend, that’s why it doesn’t make sense   Mod list:   xplosives-1.2.0.jar whisperwoods-1.18.2-2.1.0-forge.jar waystones-forge-1.18.2-10.2.2.jar voicechat-forge-1.18.2-2.4.32.jar trashslot-forge-1.18.2-11.0.3.jar towns_and_towers_forge-1.10.0.1+1.18.2.jar torchmaster-18.2.1.jar ToolBelt-1.18.2-1.18.9.jar toms_storage-1.18.2-1.4.4.jar swingthroughgrass-1.18.2-1.9.1.jar strictly_origins_v5.1_1.18.2.jar starlight-1.0.2+forge.546ae87.jar SpartanWeaponry-1.18.2-3.0.4.jar SimpleQuarry-1.18.2-18.2.5.jar simpleplanes-1.18.2-5.2.2.jar secretrooms-1.18.2-1.1.5.jar right-click-harvest-3.2.0+1.18.2-forge.jar REIPluginCompatibilities-forge-8.0.89.jar RoughlyEnough|tems-8.3.681-forge.jar RegionsUnexploredForge-0.4.1_1+1.18.2.jar TerraBlender-forge-1.18.2-1.2.0.126.jar Recall_Potion_v1.0.3-1.18.2.jar Quark-3.2-358.jar PickleTweaks-1.18.2-6.1.2.jar Pehkui-3.7.11+1.18.2-forge.jar Origins-1.18.2-1.4.1.4-unified.jar naturalist-forge-1.1.1-1.18.2.jar mysticaloaktree-1.18.2-1.2.jar selene-1.18.2-1.17.14.jar MysticalAgradditions-1.18.2-5.1.4.jar MysticalAgriculture-1.18.2-5.1.5.jar MultiMine-1.18.7.jar moyai-1.18.2-1.1.4.jar ModernDynamicSurroundings-5.0.0.4.jar lootbeams-1.18.1-release-july1722.jar journeymap-1.18.2-5.9.7-forge.jar ironfurnaces-1.18.2-3.3.3.jar ironchest-1.18.2-13.2.11.jar industrial-foregoing-1.18.2-3.3.1.6-10.jar titanium-1.18.2-3.5.11-45.jar immersive_armors-1.5.6+1.18.2-forge.jar hardcorerevival-forge-1.18.2-8.0.1.jar HammerLib-1.18.2-18.2.16. jar gravestone-1.18.2-1.0.1.jar geckolib-forge-1.18-3.0.57.jar findme-3.0.6-forge.jar faithfulbackrooms3.0.0.7.jar elevatorid-1.18.2-1.8.4.jar EasyMagic-v3.3.0-1.18.2-Forge.jar PuzzlesLib-v3.5.9-1.18.2-Forge.jar easy_villagers-1.18.2-1.0.11.jar easy_mob_farm_1.18.2-7.1.0.jar DynamicTrees-1.18.2-1.0.4.jar dragonseeker-1.1.1-1.18.2.jar iceandfire-2.1.12-1.18.2.jar Cucumber-1.18.2-5.1.5 jar cloth-config-6.5.116-forge.jar citadel-1.11.3-1.18.2.jar chunkloaders-1.2.8a-forge-mc1.18.jar supermartijn642configlib-1.1.8-forge-mc1.18.jar supermartijn642corelib-1.1.17-forge-mc1.18.jar cave_dweller-1.18.2-1.6.4.jar carryon-1.18.2-1.17.1.12.jar caelus-forge-1.18.1-3.0.0.2.jar BotanyTrees-Forge-1.18.2-4.0.13.jar BotanyPots-Forge-1.18.2-8.1.29.jar Bookshelf-Forge-1.18.2-13.3.56.jar balm-3.2.6.jar AutoRegLib-1.7-53.jar ars_nouveau-1.18.2-2.9.0.jar curios-forge-1.18.2-5.0.9.2.jar Patchouli-1.18.2-71.1.jar architectury-4.12.94-forge.jar almostunified-forge-1.18.2-0.3.10.jar [1.18.2] SecurityCraft v1.9.8.jar
  • Topics

×
×
  • Create New...

Important Information

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