Pire que cela, si je bouges la souris elle est figée, si je bouges dans le jeu elle ce comportement bizarrement selon la direction elle change de sens, va faire l’écran ou devient plus petite.
J’ai testé le code suivant en changeant le MODID et cela fonctionne parfaitement:
| @SubscribeEvent |
| public static void renderWorldLastEvent(RenderWorldLastEvent event) { |
| MatrixStack ms = event.getMatrixStack(); |
| IRenderTypeBuffer.Impl buffers = IRenderTypeBuffer.getImpl(Tessellator.getInstance().getBuffer()); |
| RenderSystem.disableCull(); |
| ms.push(); |
| |
| for (Entity e : Minecraft.getInstance().world.getAllEntities()) { |
| if (!Minecraft.getInstance().player.equals(e) && !(e instanceof ItemEntity) && !(e instanceof ExperienceOrbEntity)) { |
| drawCube(ms, buffers, new AxisAlignedBB(e.getPosition()).expand(0, 1, 0), new Color(0, 255, 0, 127)); |
| draw3dOutline(ms, buffers, new AxisAlignedBB(e.getPosition()).expand(0, 1, 0), new Color(255, 255, 255, 255)); |
| } |
| } |
| draw3dOutline(ms, buffers, new AxisAlignedBB(new BlockPos(0, 10, 0)), new Color(255, 255, 255, 255)); |
| |
| ms.pop(); |
| buffers.finish(); |
| } |
| |
| public static void drawCube(MatrixStack ms, IRenderTypeBuffer buffers, AxisAlignedBB aabb, Color color) { |
| draw3dRectangle(ms, buffers, aabb, color, "TOP"); |
| draw3dRectangle(ms, buffers, aabb, color, "BOTTOM"); |
| draw3dRectangle(ms, buffers, aabb, color, "NORTH"); |
| draw3dRectangle(ms, buffers, aabb, color, "EAST"); |
| draw3dRectangle(ms, buffers, aabb, color, "SOUTH"); |
| draw3dRectangle(ms, buffers, aabb, color, "WEST"); |
| } |
| |
| public static void draw3dRectangle(MatrixStack ms, IRenderTypeBuffer buffers, AxisAlignedBB aabb, Color color, String side) { |
| int r = color.getRed(); |
| int g = color.getGreen(); |
| int b = color.getBlue(); |
| int a = color.getAlpha(); |
| double renderPosX = Minecraft.getInstance().getRenderManager().info.getProjectedView().getX(); |
| double renderPosY = Minecraft.getInstance().getRenderManager().info.getProjectedView().getY(); |
| double renderPosZ = Minecraft.getInstance().getRenderManager().info.getProjectedView().getZ(); |
| |
| ms.push(); |
| ms.translate(aabb.minX - renderPosX, aabb.minY - renderPosY, aabb.minZ - renderPosZ); |
| |
| IVertexBuilder buffer = buffers.getBuffer(RenderType.makeType(HypixelClient.MODID + ":rectangle_highlight", DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, 256, false, true, RenderType.State.getBuilder().transparency(ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228515_g_")).cull(new RenderState.CullState(false)).build(false))); |
| Matrix4f mat = ms.getLast().getMatrix(); |
| |
| float x = (float) (aabb.maxX - aabb.minX); |
| float y = (float) (aabb.maxY - aabb.minY); |
| float z = (float) (aabb.maxZ - aabb.minZ); |
| |
| switch (side) { |
| case "TOP": |
| buffer.pos(mat, x, y, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, y, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, y, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, y, z).color(r, g, b, a).endVertex(); |
| break; |
| case "BOTTOM": |
| buffer.pos(mat, x, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, 0, z).color(r, g, b, a).endVertex(); |
| break; |
| case "NORTH": |
| buffer.pos(mat, 0, y, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, y, 0).color(r, g, b, a).endVertex(); |
| break; |
| case "EAST": |
| buffer.pos(mat, x, y, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, y, z).color(r, g, b, a).endVertex(); |
| break; |
| case "SOUTH": |
| buffer.pos(mat, 0, y, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, y, z).color(r, g, b, a).endVertex(); |
| break; |
| case "WEST": |
| buffer.pos(mat, 0, y, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, y, z).color(r, g, b, a).endVertex(); |
| break; |
| } |
| ms.pop(); |
| } |
| |
| public static void draw3dOutline(MatrixStack ms, IRenderTypeBuffer buffers, AxisAlignedBB aabb, Color color) { |
| int r = color.getRed(); |
| int g = color.getGreen(); |
| int b = color.getBlue(); |
| int a = color.getAlpha(); |
| double renderPosX = Minecraft.getInstance().getRenderManager().info.getProjectedView().getX(); |
| double renderPosY = Minecraft.getInstance().getRenderManager().info.getProjectedView().getY(); |
| double renderPosZ = Minecraft.getInstance().getRenderManager().info.getProjectedView().getZ(); |
| |
| ms.push(); |
| ms.translate(aabb.minX - renderPosX, aabb.minY - renderPosY, aabb.minZ - renderPosZ); |
| |
| RenderType.State glState = RenderType.State.getBuilder().line(new RenderState.LineState(OptionalDouble.of(1))).layer(ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228500_J_")).transparency(ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228515_g_")).writeMask(new RenderState.WriteMaskState(true, false)).depthTest(new RenderState.DepthTestState(GL11.GL_ALWAYS)).build(false); |
| IVertexBuilder buffer = buffers.getBuffer(RenderType.makeType(HypixelClient.MODID + ":line_1_no_depth", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 128, glState)); |
| Matrix4f mat = ms.getLast().getMatrix(); |
| |
| float x = (float) (aabb.maxX - aabb.minX); |
| float y = (float) (aabb.maxY - aabb.minY); |
| float z = (float) (aabb.maxZ - aabb.minZ); |
| |
| |
| buffer.pos(mat, x, y, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, y, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, y, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, y, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, y, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, y, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, y, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, y, 0).color(r, g, b, a).endVertex(); |
| |
| |
| buffer.pos(mat, x, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, 0, 0).color(r, g, b, a).endVertex(); |
| |
| |
| buffer.pos(mat, x, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, y, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, y, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, 0).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, y, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, 0, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, 0, z).color(r, g, b, a).endVertex(); |
| buffer.pos(mat, x, y, z).color(r, g, b, a).endVertex(); |
| |
| ms.pop(); |
| } |
Je vais essayer de l’étudier et de faire quelque chose de propre.
De créer des fonctions qui mâche le travail et un tuto cela donne ça:

Je vais travailler sur cela même si j’ai peu de temps 