Jump to content

Koudja

Members
  • Posts

    6
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Koudja's Achievements

Tree Puncher

Tree Puncher (2/8)

3

Reputation

  1. I am using this code to render a moving block, whose location is not discrete. Fun fact, my snippet does not seem to work for FluidBlock; I shall look on that part later on.
  2. I found out why it was on top of everything else. There is 2 different RenderTypeBuffer.Impl available in client, one is for displaying stuff as part of GUI (in top of world rendering), the other is for world rendering. Thanks to everyone working with me on this ! Here is a working snippet for anyone struggling with same issue as me (needless to say, it's physical client-side code only) public void render(RenderWorldLastEvent event) { Vec3d location; // some location in world BlockState state; // some BlockState (does not have to be part of world) renderBlock(event.getMatrixStack(), location, state); } public static void renderBlock(MatrixStack matrixStack, Vec3d pos, BlockState state) { BlockRendererDispatcher renderer = Minecraft.getInstance().getBlockRendererDispatcher(); ClientWorld world = Minecraft.getInstance().world; IModelData model = renderer.getModelForState(state).getModelData(world, new BlockPos(pos), state, ModelDataManager.getModelData(world, new BlockPos(pos))); ActiveRenderInfo renderInfo = Minecraft.getInstance().gameRenderer.getActiveRenderInfo(); matrixStack.func_227860_a_(); // push matrixStack.func_227861_a_(-renderInfo.getProjectedView().getX() + pos.x, -renderInfo.getProjectedView().getY() + pos.y, -renderInfo.getProjectedView().getZ() + pos.z); // translate back to camera // Overlay texture = custom RGBA on top of texture, 0 -> red //func_228487_b_ -> display over everything else //func_228489_c_ -> display as part of chunk rendering Minecraft.getInstance().getBlockRendererDispatcher().renderBlock(state, matrixStack, Minecraft.getInstance().func_228019_au_().func_228489_c_(), 15728880, OverlayTexture.field_229196_a_, model); matrixStack.func_227865_b_(); // pop }
  3. Method in first snippet produced a block that was always behind world. Shall I use a different BufferBuilder to reproduce same behavior ?
  4. I managed to make use of renderBlock as mentionned: public static void renderBlock2(MatrixStack matrixStack, Vec3d pos, BlockState state) { BlockRendererDispatcher renderer = Minecraft.getInstance().getBlockRendererDispatcher(); ClientWorld world = Minecraft.getInstance().world; IModelData model = renderer.getModelForState(state).getModelData(world, new BlockPos(pos), state, ModelDataManager.getModelData(world, new BlockPos(pos))); ActiveRenderInfo renderInfo = Minecraft.getInstance().gameRenderer.getActiveRenderInfo(); matrixStack.func_227860_a_(); // push matrixStack.func_227861_a_(-renderInfo.getProjectedView().getX() + pos.x, -renderInfo.getProjectedView().getY() + pos.y, -renderInfo.getProjectedView().getZ() + pos.z); // translate back to camera Minecraft.getInstance().getBlockRendererDispatcher().renderBlock(state, matrixStack, Minecraft.getInstance().func_228019_au_().func_228487_b_(), 15728880, OverlayTexture.field_229196_a_, model); matrixStack.func_227865_b_(); // pop } The only issue left is that rendered block is always on top of everything else with this method.
  5. Yes, I have been trying to use it but could'nt figure out how rendering system knows where BlockPos is. I have been looking backward in stack looking for it (believing it was set before) without success I would prefer using this method rather than my own custom in fact.
  6. Hello ! I am currently working on a Forge mod that must display a fake block on client side ("fake" because only for visual). From picking up various render methods in previous versions, and somehow dive into 1.15 new rendering system, I've managed to display something succesfully on screen. I've got an unexpected side-effect: player's hand is disappearing (or probably just rendering far away ?). I've been struggling to understand why and would like to know if anybody could help me on that point. Some snippets MinecraftForge.EVENT_BUS.addListener(renderFake); // somewhere at client's init (FMLClientSetupEvent, Dist.CLIENT) private void renderFake(RenderWorldLastEvent event) { ActiveRenderInfo renderInfo = Minecraft.getInstance().gameRenderer.getActiveRenderInfo(); BlockPos pos = new Blockpos(0, 64, 0); // Just somewhere in the world matrixStack.func_227860_a_(); // push matrixStack.func_227861_a_(-renderInfo.getProjectedView().getX(), -renderInfo.getProjectedView().getY(), -renderInfo.getProjectedView().getZ()); // translate back to camera Matrix4f matrix4f = matrixStack.func_227866_c_().func_227870_a_(); // get final transformation matrix, handy to get yaw+pitch transformation RenderSystem.multMatrix(matrix4f); Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("textures/block/stone.png")); Tessellator.getInstance().getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); drawBlock(Tessellator.getInstance().getBuffer(), pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, 0, 1, 0, 1, 0.5,0.5,0.5); Tessellator.getInstance().draw(); matrixStack.func_227861_a_(0, 0, 0); // reset translation matrixStack.func_227865_b_(); // pop } private static void drawBlock(final BufferBuilder bufferbuilder, final double x, final double y, final double z, final float minU, final float maxU, final float minV, final float maxV, final double x_size, final double y_size, final double z_size) { // UP bufferbuilder.func_225582_a_(-x_size + x, y_size + y, -z_size + z).func_225583_a_(maxU, maxV).endVertex(); bufferbuilder.func_225582_a_(-x_size + x, y_size + y, z_size + z).func_225583_a_(maxU, minV).endVertex(); bufferbuilder.func_225582_a_(x_size + x, y_size + y, z_size + z).func_225583_a_(minU, minV).endVertex(); bufferbuilder.func_225582_a_(x_size + x, y_size + y, -z_size + z).func_225583_a_(minU, maxV).endVertex(); // DOWN bufferbuilder.func_225582_a_(-x_size + x, -y_size + y, z_size + z).func_225583_a_(minU, minV).endVertex(); bufferbuilder.func_225582_a_(-x_size + x, -y_size + y, -z_size + z).func_225583_a_(minU, maxV).endVertex(); bufferbuilder.func_225582_a_(x_size + x, -y_size + y, -z_size + z).func_225583_a_(maxU, maxV).endVertex(); bufferbuilder.func_225582_a_(x_size + x, -y_size + y, z_size + z).func_225583_a_(maxU, minV).endVertex(); // LEFT bufferbuilder.func_225582_a_(x_size + x, -y_size + y, z_size + z).func_225583_a_(maxU, minV).endVertex(); bufferbuilder.func_225582_a_(x_size + x, -y_size + y, -z_size + z).func_225583_a_(maxU, maxV).endVertex(); bufferbuilder.func_225582_a_(x_size + x, y_size + y, -z_size + z).func_225583_a_(minU, maxV).endVertex(); bufferbuilder.func_225582_a_(x_size + x, y_size + y, z_size + z).func_225583_a_(minU, minV).endVertex(); // RIGHT bufferbuilder.func_225582_a_(-x_size + x, -y_size + y, -z_size + z).func_225583_a_(minU, maxV).endVertex(); bufferbuilder.func_225582_a_(-x_size + x, -y_size + y, z_size + z).func_225583_a_(minU, minV).endVertex(); bufferbuilder.func_225582_a_(-x_size + x, y_size + y, z_size + z).func_225583_a_(maxU, minV).endVertex(); bufferbuilder.func_225582_a_(-x_size + x, y_size + y, -z_size + z).func_225583_a_(maxU, maxV).endVertex(); // BACK bufferbuilder.func_225582_a_(-x_size + x, -y_size + y, -z_size + z).func_225583_a_(minU, maxV).endVertex(); bufferbuilder.func_225582_a_(-x_size + x, y_size + y, -z_size + z).func_225583_a_(minU, minV).endVertex(); bufferbuilder.func_225582_a_(x_size + x, y_size + y, -z_size + z).func_225583_a_(maxU, minV).endVertex(); bufferbuilder.func_225582_a_(x_size + x, -y_size + y, -z_size + z).func_225583_a_(maxU, maxV).endVertex(); // FRONT bufferbuilder.func_225582_a_(x_size + x, -y_size + y, z_size + z).func_225583_a_(maxU, minV).endVertex(); bufferbuilder.func_225582_a_(x_size + x, y_size + y, z_size + z).func_225583_a_(maxU, maxV).endVertex(); bufferbuilder.func_225582_a_(-x_size + x, y_size + y, z_size + z).func_225583_a_(minU, maxV).endVertex(); bufferbuilder.func_225582_a_(-x_size + x, -y_size + y, z_size + z).func_225583_a_(minU, minV).endVertex(); } Before rendering "fake" block After rendering "fake" block (player's hand disappear)
×
×
  • Create New...

Important Information

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