Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

garfield1002

Members
  • Posts

    3
  • Joined

  • Last visited

garfield1002's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I found the solution. The error was not even in the code I put up, turns out the order in which the IVertexBuilder are created matters. (Create solid THEN translucent for good result) IVertexBuilder
  2. I am attempting to create a semi transparent model that will appear in a GUI. However, you can see behind the GUI with it and not behind in the GUI @SubscribeEvent public static void onTextureStitch(TextureStitchEvent.Pre event){ if(event.getMap().getTextureLocation().equals(AtlasTexture.LOCATION_BLOCKS_TEXTURE)){ event.addSprite(new ResourceLocation(MOD_ID, "planets/default")); } } @Mod.EventBusSubscriber(modid=Main.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class GUIBlockScreen extends ContainerScreen<GUIBlockContainer> { public GUIBlockScreen(GUIBlockContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { super(screenContainer, inv, titleIn); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); drawEntityOnScreen(this.width / 2, this.height / 2, (int) pow(30 - this.zoom / 3, 2 )); } public void drawOnScreen(int posX, int posY, int scale) { RenderSystem.pushMatrix(); // I have tried all of these but it dosn't seem to do anything // RenderSystem.enableBlend(); // RenderSystem.enableTexture(); // RenderSystem.enableDepthTest(); // RenderSystem.disableCull(); // RenderSystem.enableRescaleNormal(); // RenderSystem.enableAlphaTest(); // RenderSystem.defaultAlphaFunc(); // RenderSystem.enableBlend(); // RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); // RenderSystem.defaultBlendFunc(); RenderSystem.translatef((float)posX, (float)posY, -1050.0F); RenderSystem.scalef(0.12F, 0.12F, 0.12F); MatrixStack matrixstack = new MatrixStack(); IRenderTypeBuffer.Impl irendertypebuffer$impl = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource(); IVertexBuilder vertexBuilder = irendertypebuffer$impl.getBuffer(RenderType.getTranslucent()); Material material = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(Main.MOD_ID, "planets/defaulttransparency")); drawCube(new Vec3d(0.5, 0, 0), new Vec3d(0, 0.5, 0), new Vec3d(0, 0, 0.5), matrixstack, vertexBuilder, this.material, 0.3F); irendertypebuffer$impl.finish(); RenderSystem.popMatrix(); } } private static void add(IVertexBuilder renderer, Matrix4f matrixPos, Vec3d A, Vec3d N, float u, float v, float opacity) { renderer.pos(matrixPos, (float) A.x, (float) A.y, (float) A.z) .color(1.0F, 1.0F, 1.0F, opacity) .tex(u, v) .lightmap(0, 240) .normal((float) N.x, (float) N.y, (float) N.z) .endVertex(); } private static void square(IVertexBuilder renderer, Matrix4f matrixPos, Vec3d A, Vec3d B, Vec3d C, Material material, float opacity) { Vec3d N = A.crossProduct(B).normalize(); float u = material.getSprite().getMinU(); float U = material.getSprite().getMaxU(); float v = material.getSprite().getMinV(); float V = material.getSprite().getMaxV(); add(renderer, matrixPos, C, N, u, v, opacity); add(renderer, matrixPos, A.add(C), N, U, v, opacity); add(renderer, matrixPos, A.add(B).add(C), N, U, V, opacity); add(renderer, matrixPos, B.add(C), N, u, V, opacity); } public static void drawCube(Vec3d A, Vec3d B, Vec3d C, MatrixStack matrixstack, IVertexBuilder renderBuffer, Material material, float opacity) { // retrieves a position matrix Matrix4f matrixPos = matrixstack.getLast().getMatrix(); // draws the 6 sides square(renderBuffer, matrixPos, A, B, Vec3d.ZERO, material, opacity); square(renderBuffer, matrixPos, B, A, C, material, opacity); square(renderBuffer, matrixPos, C, A, Vec3d.ZERO, material, opacity); square(renderBuffer, matrixPos, A, C, B, material, opacity); square(renderBuffer, matrixPos, B, C, Vec3d.ZERO, material, opacity); square(renderBuffer, matrixPos, C, B, A, material, opacity); }
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.