Jump to content

BufferBuilder rendering black and purple texture


Recommended Posts

I'm working on a forge mod for 1.16.5 and I made a custom Dimension and I made a custom sky for my dimension but when I test the mod the sun is just a black and purple texture, I'm pretty new at modding so I don't know what to do.

Here is the code for the custom sky:

public class ClientEventBus {
	private static final ResourceLocation DIM_RENDER_INFO = new ResourceLocation("star_craft", "moon");
	private static final ResourceLocation SUN_TEXTURES = new ResourceLocation("textures/sky/earth.png");
	private static final ResourceLocation MOON_PHASES_TEXTURES = new ResourceLocation("textures/moonsky/moon_phases.png");
	private static final ResourceLocation SKY_TEXTURE = new ResourceLocation("star_craft", "textures/sky/moonsky.png");
	@SubscribeEvent(priority = EventPriority.HIGHEST)
	public static void clientSetup(FMLClientSetupEvent event) {
		// public net.minecraft.client.world.DimensionRenderInfo field_239208_a_ #
		// field_239208_a_
		// public net.minecraft.client.renderer.Minecraft.getInstance().worldRenderer
		// field_175012_t # skyVBO
		// public net.minecraft.client.renderer.Minecraft.getInstance().worldRenderer
		// field_175014_r # skyVertexFormat
		// public net.minecraft.client.renderer.Minecraft.getInstance().worldRenderer
		// field_175013_s # starVBO
		// public net.minecraft.client.renderer.Minecraft.getInstance().worldRenderer
		// field_175011_u # sky2VBO
		DimensionRenderInfo.field_239208_a_.put(DIM_RENDER_INFO,
				// cloudHeight, alternate sky color, fog type, render sky, diffuse lighting
				new DimensionRenderInfo(128, true, FogType.NORMAL, true, false) {
					@Override
					// adjustSkyColor
					public Vector3d func_230494_a_(Vector3d fogColor, float partialTicks) {
						return fogColor;
					}
					
					
					@Override
					// useThickFog
					public boolean func_230493_a_(int posX, int posY) {
						return false;
					}
					@Override
					public ISkyRenderHandler getSkyRenderHandler() {
						return new ISkyRenderHandler() {
							@SuppressWarnings({ "resource", "deprecation" })
							@Override
							public void render(int ticks, float partialTicks, MatrixStack matrixStack,
									ClientWorld world, Minecraft mc) {
								RenderSystem.disableTexture();
								Vector3d vector3d = world.getSkyColor(
										Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getBlockPos(),
										partialTicks);
								float f = (float) vector3d.x;
								float f1 = (float) vector3d.y;
								float f2 = (float) vector3d.z;
								FogRenderer.applyFog();
								BufferBuilder bufferbuilder = Tessellator.getInstance().getBuffer();
								RenderSystem.depthMask(false);
								RenderSystem.enableFog();
								RenderSystem.color3f(f, f1, f2);
								Minecraft.getInstance().worldRenderer.skyVBO.bindBuffer();
								Minecraft.getInstance().worldRenderer.skyVertexFormat.setupBufferState(0L);
								Minecraft.getInstance().worldRenderer.skyVBO.draw(matrixStack.getLast().getMatrix(), 7);
								VertexBuffer.unbindBuffer();
								Minecraft.getInstance().worldRenderer.skyVertexFormat.clearBufferState();
								RenderSystem.disableFog();
								RenderSystem.disableAlphaTest();
								RenderSystem.enableBlend();
								RenderSystem.defaultBlendFunc();
								float[] afloat = world.func_239132_a_()
										.func_230492_a_(world.func_242415_f(partialTicks), partialTicks);
								if (afloat != null) {
									RenderSystem.disableTexture();
									RenderSystem.shadeModel(7425);
									matrixStack.push();
									matrixStack.rotate(Vector3f.XP.rotationDegrees(90.0F));
									float f3 = MathHelper.sin(world.getCelestialAngleRadians(partialTicks)) < 0.0F
											? 180.0F
											: 0.0F;
									matrixStack.rotate(Vector3f.ZP.rotationDegrees(f3));
									matrixStack.rotate(Vector3f.ZP.rotationDegrees(90.0F));
									float f4 = afloat[0];
									float f5 = afloat[1];
									float f6 = afloat[2];
									Matrix4f matrix4f = matrixStack.getLast().getMatrix();
									bufferbuilder.begin(6, DefaultVertexFormats.POSITION_COLOR);
									bufferbuilder.pos(matrix4f, 0.0F, 100.0F, 0.0F).color(f4, f5, f6, afloat[3])
											.endVertex();
									for (int j = 0; j <= 16; ++j) {
										float f7 = (float) j * ((float) Math.PI * 2F) / 16.0F;
										float f8 = MathHelper.sin(f7);
										float f9 = MathHelper.cos(f7);
										bufferbuilder.pos(matrix4f, f8 * 120.0F, f9 * 120.0F, -f9 * 40.0F * afloat[3])
												.color(afloat[0], afloat[1], afloat[2], 0.0F).endVertex();
									}
									bufferbuilder.finishDrawing();
									WorldVertexBufferUploader.draw(bufferbuilder);
									matrixStack.pop();
									RenderSystem.shadeModel(7424);
								}
								RenderSystem.enableTexture();
								RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA,
										GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE,
										GlStateManager.DestFactor.ZERO);
								matrixStack.push();
								float f11 = 1.0F - world.getRainStrength(partialTicks);
								RenderSystem.color4f(1.0F, 1.0F, 1.0F, f11);
								matrixStack.rotate(Vector3f.YP.rotationDegrees(-90.0F));
								matrixStack.rotate(
										Vector3f.XP.rotationDegrees(world.func_242415_f(partialTicks) * 360.0F));
								Matrix4f matrix4f1 = matrixStack.getLast().getMatrix();
								float f12 = 30.0F;

								
								
								Minecraft.getInstance().getTextureManager().bindTexture(SUN_TEXTURES);
								bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
								bufferbuilder.pos(matrix4f1, -f12, 100.0F, -f12).tex(0.0F, 0.0F).endVertex();
								bufferbuilder.pos(matrix4f1, f12, 100.0F, -f12).tex(1.0F, 0.0F).endVertex();
								bufferbuilder.pos(matrix4f1, f12, 100.0F, f12).tex(1.0F, 1.0F).endVertex();
								bufferbuilder.pos(matrix4f1, -f12, 100.0F, f12).tex(0.0F, 1.0F).endVertex();
								bufferbuilder.finishDrawing();
								WorldVertexBufferUploader.draw(bufferbuilder);
								f12 = 20.0F;
								
								Minecraft.getInstance().getTextureManager().bindTexture(MOON_PHASES_TEXTURES);
								int k = world.getMoonPhase();
								int l = k % 4;
								int i1 = k / 4 % 2;
								float f13 = (float) (l + 0) / 4.0F;
								float f14 = (float) (i1 + 0) / 2.0F;
								float f15 = (float) (l + 1) / 4.0F;
								float f16 = (float) (i1 + 1) / 2.0F;
								bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
								bufferbuilder.pos(matrix4f1, -f12, -100.0F, f12).tex(f15, f16).endVertex();
								bufferbuilder.pos(matrix4f1, f12, -100.0F, f12).tex(f13, f16).endVertex();
								bufferbuilder.pos(matrix4f1, f12, -100.0F, -f12).tex(f13, f14).endVertex();
								bufferbuilder.pos(matrix4f1, -f12, -100.0F, -f12).tex(f15, f14).endVertex();
								bufferbuilder.finishDrawing();
								WorldVertexBufferUploader.draw(bufferbuilder);
								RenderSystem.disableTexture();
								float f10 = world.getStarBrightness(partialTicks) * f11;
								if (f10 > 0.0F) {
									RenderSystem.color4f(f10, f10, f10, f10);
									Minecraft.getInstance().worldRenderer.starVBO.bindBuffer();
									Minecraft.getInstance().worldRenderer.skyVertexFormat.setupBufferState(0L);
									Minecraft.getInstance().worldRenderer.starVBO
											.draw(matrixStack.getLast().getMatrix(), 7);
									VertexBuffer.unbindBuffer();
									Minecraft.getInstance().worldRenderer.skyVertexFormat.clearBufferState();
								}
								RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
								RenderSystem.disableBlend();
								RenderSystem.enableAlphaTest();
								RenderSystem.enableFog();
  							    matrixStack.pop();
								RenderSystem.disableTexture();
								RenderSystem.color3f(0.0F, 0.0F, 0.0F);
								double d0 = Minecraft.getInstance().player.getEyePosition(partialTicks).y
										- world.getWorldInfo().getVoidFogHeight();
								if (d0 < 0.0D) {
									matrixStack.push();
									matrixStack.translate(0.0D, 12.0D, 0.0D);
									Minecraft.getInstance().worldRenderer.sky2VBO.bindBuffer();
									Minecraft.getInstance().worldRenderer.skyVertexFormat.setupBufferState(0L);
									Minecraft.getInstance().worldRenderer.sky2VBO
											.draw(matrixStack.getLast().getMatrix(), 7);
									VertexBuffer.unbindBuffer();
									Minecraft.getInstance().worldRenderer.skyVertexFormat.clearBufferState();
									matrixStack.pop();
								}
								if (world.func_239132_a_().func_239216_b_()) {
									RenderSystem.color3f(f * 0.2F + 0.04F, f1 * 0.2F + 0.04F, f2 * 0.6F + 0.1F);
								} else {
									RenderSystem.color3f(f, f1, f2);
								}
								
								Minecraft.getInstance().worldRenderer.skyVBO.bindBuffer();
								Minecraft.getInstance().worldRenderer.skyVertexFormat.setupBufferState(0L);
								Minecraft.getInstance().worldRenderer.skyVBO.draw(matrixStack.getLast().getMatrix(), 7);
								VertexBuffer.unbindBuffer();
								Minecraft.getInstance().worldRenderer.skyVertexFormat.clearBufferState();
								
								RenderSystem.enableTexture();
								RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA,
										GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE,
										GlStateManager.DestFactor.ZERO);
								RenderSystem.color4f(0.8F, 0.8F, 0.8F, 0.2F);
								Minecraft.getInstance().getTextureManager().bindTexture(SKY_TEXTURE);
								bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
								bufferbuilder.pos(64, 16, 64).tex(0.0F, 0.0F).endVertex();
								bufferbuilder.pos(-64, 16, 64).tex(1.0F, 0.0F).endVertex();
								bufferbuilder.pos(-64, 16, -64).tex(1.0F, 1.0F).endVertex();
								bufferbuilder.pos(64, 16, -64).tex(0.0F, 1.0F).endVertex();
								bufferbuilder.finishDrawing();
								WorldVertexBufferUploader.draw(bufferbuilder);
								RenderSystem.disableTexture();
								RenderSystem.enableTexture();
								RenderSystem.depthMask(true);
								RenderSystem.disableFog();
							}
						};
					}
				});
	}
}

 

Here is how it looks like:

KiVDpUD.png

Link to comment
Share on other sites

Quote

private static final ResourceLocation SUN_TEXTURES = new ResourceLocation("textures/sky/earth.png");

Is your sun texture really called earth.png?

A black and purple square is minecraft's way of saying "missing texture".

 

Try doing the following in that method:

System.out.println(Minecraft.getInstance().getResourceManager().getResource(SUN_TEXTURES));

 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Actually I think your problem is that you should be doing

Quote

new ResourceLocation(MOD_ID, "textures/sky/earth.png")

You are looking for minecraft/textures/sky/earth.png if you don't specify your MOD_ID.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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

    • 6:26:58 PM: Executing 'wrapper'... Download http://files.minecraftforge.net/maven/net/minecraftforge/gradle/ForgeGradle/2.1-SNAPSHOT/maven-metadata.xml, took 3 s 928 ms Download http://files.minecraftforge.net/maven/net/minecraftforge/fernflower/2.0-SNAPSHOT/maven-metadata.xml, took 2 s 332 ms FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\Slacker201\Desktop\MinecraftMacro\build.gradle' line: 16 * What went wrong: A problem occurred evaluating root project 'MinecraftMacro'. > Failed to apply plugin 'net.minecraftforge.gradle.forge'.    > Configuration with name 'compile' not found. * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 56s Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. 6:27:54 PM: Execution finished 'wrapper'.
    • Against the Odds: How I Recovered $86,000 from a Binary Options Fraud unmasking the scam. I never thought I’d see my money again. After months of frustration, I had lost hope of recovering the $86,000 I invested in a binary options trading platform. But today, I want to share my journey and prove that recovery is possible. Living in Colombia, I first encountered the platform through a flashy online advertisement. It promised quick returns through binary options trading, a concept I didn’t fully grasp but found alluring. Initially, I invested $2,000, encouraged by what appeared to be substantial gains. As my balance grew, I became more confident and ended up investing an additional $84,000. For a while, everything seemed to be going well. The platform displayed impressive profits, claiming I had made $175,000. However, when I tried to withdraw a significant portion of my earnings, I faced an onslaught of obstacles. My requests were met with delays and vague excuses. Each time I was prompted to pay withdrawal fees, I complied, only to find more fees waiting for me: taxes, processing charges, and even unexpected compliance fees. I realized too late that I was trapped in a scam, having lost another $26,000 in fees alone. The experience was not only financially devastating but also emotionally draining. I felt embarrassed for trusting a platform I barely understood. Yet, despite the discouragement, I was determined to fight for my money. After extensive research, I discovered Rapid Digital Recovery and their promising testimonials. Skeptical but desperate, I decided to reach out, WHAT SAPP: + 1 41 4 80 7 14 85.... To my surprise, Rapid Digital Recovery managed to recover 100% of my investment. The relief I felt was indescribable. Although I still grapple with regret over my initial decisions, I’m incredibly thankful for the support I received. They restored not just my funds but also my confidence in the recovery process. If you’re into scam, don’t lose hope. Reach out to Rapid Digital Recovery You don’t have to go through this alone, and there is a way to reclaim what you’ve lost. Web site: https: // ra pi ddigit alrecove ry .o rg
    • Replace it with other/older builds: https://www.curseforge.com/minecraft/mc-mods/farmers-delight/files/all?page=1&pageSize=20&version=1.20.1
    • idk how to show a screenshot with a url, but i have the forge file on desktop, and its just a paper folded in the corner and not the forge logo and i cant open it and go to the installer
  • Topics

×
×
  • Create New...

Important Information

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