Toma™ Posted September 13, 2019 Posted September 13, 2019 (edited) I'm trying to render shape in world similar to mc's world border, but I'm getting some weird issues with colors. When I rotate in specific angle, the color turns black and otherwise it's just plain blue. I cannot figure this out at all, and I have no idea what I'm doing wrong. Anyway, I'd be very happy if someone offered help. So there's the render code: Spoiler @SubscribeEvent public void renderBlueZone(RenderWorldLastEvent e) { Minecraft mc = Minecraft.getMinecraft(); World world = mc.world; IGameData gameData = world.getCapability(IGameData.GameDataProvider.GAMEDATA, null); Game game = gameData.getCurrentGame(); if (!gameData.isPlaying() || gameData.isInactiveGame()) { return; } BlueZone zone = game.zone; if (zone == null) { return; } EntityPlayerSP player = mc.player; double maxClientRenderDist = mc.gameSettings.renderDistanceChunks * 16; if (isCloseToBorder(player, zone, maxClientRenderDist)) { float partialTicks = e.getPartialTicks(); double interpolatedPlayerX = interpolate(player.posX, player.lastTickPosX, partialTicks); double interpolatedPlayerY = interpolate(player.posY, player.lastTickPosY, partialTicks); double interpolatedPlayerZ = interpolate(player.posZ, player.lastTickPosZ, partialTicks); int clientZoneColor = ConfigPMC.client.other.zoneColor; float a = 0.75F; float r = 0.0F; float g = 1.0F; float b = 1.0F; //actual rendering Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); GlStateManager.enableBlend(); GlStateManager.color(1f, 1f, 1f); mc.getTextureManager().bindTexture(dummy); GlStateManager.pushMatrix(); GlStateManager.alphaFunc(516, 0.1F); GlStateManager.enableAlpha(); GlStateManager.disableCull(); bufferBuilder.begin(7, DefaultVertexFormats.POSITION_COLOR); bufferBuilder.setTranslation(-interpolatedPlayerX, -interpolatedPlayerY, -interpolatedPlayerZ); double minRenderPosZ = Math.max(Math.floor(interpolatedPlayerZ - maxClientRenderDist), zone.minZ()); double maxRenderPosZ = Math.min(Math.ceil(interpolatedPlayerZ + maxClientRenderDist), zone.maxZ()); double minRenderPosX = Math.max(Math.floor(interpolatedPlayerX - maxClientRenderDist), zone.minX()); double maxRenderPosX = Math.min(Math.ceil(interpolatedPlayerX + maxClientRenderDist), zone.maxX()); if (interpolatedPlayerX > zone.maxX() - maxClientRenderDist) { bufferBuilder.pos(zone.maxX(), 256D, minRenderPosZ).color(r, g, b, a).endVertex(); bufferBuilder.pos(zone.maxX(), 256D, maxRenderPosZ).color(r, g, b, a).endVertex(); bufferBuilder.pos(zone.maxX(), 0D, maxRenderPosZ).color(r, g, b, a).endVertex(); bufferBuilder.pos(zone.maxX(), 0D, minRenderPosZ).color(r, g, b, a).endVertex(); } if(interpolatedPlayerX < zone.minX() + maxClientRenderDist) { bufferBuilder.pos(zone.minX(), 256D, minRenderPosZ).color(r, g, b, a).endVertex(); bufferBuilder.pos(zone.minX(), 256D, maxRenderPosZ).color(r, g, b, a).endVertex(); bufferBuilder.pos(zone.minX(), 0D, maxRenderPosZ).color(r, g, b, a).endVertex(); bufferBuilder.pos(zone.minX(), 0D, minRenderPosZ).color(r, g, b, a).endVertex(); } if(interpolatedPlayerZ > zone.maxZ() - maxClientRenderDist) { bufferBuilder.pos(minRenderPosX, 256D, zone.maxZ()).color(r, g, b, a).endVertex(); bufferBuilder.pos(maxRenderPosX, 256D, zone.maxZ()).color(r, g, b, a).endVertex(); bufferBuilder.pos(maxRenderPosX, 0D, zone.maxZ()).color(r, g, b, a).endVertex(); bufferBuilder.pos(minRenderPosX, 0D, zone.maxZ()).color(r, g, b, a).endVertex(); } if(interpolatedPlayerZ < zone.minZ() + maxClientRenderDist) { bufferBuilder.pos(minRenderPosX, 256D, zone.minZ()).color(r, g, b, a).endVertex(); bufferBuilder.pos(maxRenderPosX, 256D, zone.minZ()).color(r, g, b, a).endVertex(); bufferBuilder.pos(maxRenderPosX, 0D, zone.minZ()).color(r, g, b, a).endVertex(); bufferBuilder.pos(minRenderPosX, 0D, zone.minZ()).color(r, g, b, a).endVertex(); } tessellator.draw(); bufferBuilder.setTranslation(0, 0, 0); GlStateManager.enableCull(); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); } And some images for reference: Spoiler https://prnt.sc/p5ufzdhttps://prnt.sc/p5ug6n Edited September 14, 2019 by Toma™ mark as solved Quote
Toma™ Posted September 14, 2019 Author Posted September 14, 2019 Nevermind, I just forgot to to call disableTexture2D function. That solved it. Quote
Recommended Posts
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.