Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Zergatul

Members
  • Joined

  • Last visited

  1. @SubscribeEvent public void onKeyInputEvent(InputEvent.Key event) { if (Minecraft.getInstance().options.keyForward.isDown()) { // ... } } or if (Minecraft.getInstance().player.input.up) { // ... }
  2. Thanks, works like a charm!
  3. Thanks, but I don't need parameter in vanilla classes, I need parameters in my own mod classes. The reason for this I developed simple scripting language I integrated in my mod, and I want to automatically build API reference by using reflection over API classes. Parameter names can be good to understand what method is doing.
  4. I am using IntelliJ (not sure if it matters). How can I add java compiler parameter to "runClient" configuration and "build" gradle task? I want to add harmless "-parameters" flag, so class files inside jar will contain original parameter names.
  5. Working code for 1.19: Vec3 view = mc.gameRenderer.getMainCamera().getPosition(); RenderSystem.depthMask(false); RenderSystem.disableCull(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.disableTexture(); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); var tesselator = Tesselator.getInstance(); var buffer = tesselator.getBuilder(); buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); buffer.vertex(0, 0, 0).color(1f, 1f, 1f, 1f).endVertex(); buffer.vertex(100, 200, 100).color(1f, 1f, 1f, 1f).endVertex(); vertexBuffer.bind(); vertexBuffer.upload(buffer.end()); PoseStack matrix = event.getPoseStack(); matrix.pushPose(); matrix.translate(-view.x, -view.y, -view.z); var shader = GameRenderer.getPositionColorShader(); vertexBuffer.drawWithShader(matrix.last().pose(), event.getProjectionMatrix().copy(), shader); matrix.popPose(); VertexBuffer.unbind();
  6. In 1.18 I used this code, but it no longer works. Could you give me some hints or example from other mods source code? I know I can look into Minecraft source, but they use VertexFormat.Mode.LINES and vertex format with normal. var tesselator = Tesselator.getInstance(); var buffer = tesselator.getBuilder(); buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); buffer.vertex(x1, y1, z1).color(1f, 1f, 1f, 1f).endVertex(); buffer.vertex(x2, y2, z2).color(1f, 1f, 1f, 1f).endVertex(); buffer.end(); vertexBuffer.upload(buffer); RenderSystem.depthMask(false); RenderSystem.disableCull(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.disableTexture(); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_DEPTH_TEST); PoseStack poseStack = event.getPoseStack(); poseStack.pushPose(); poseStack.translate(-view.x, -view.y, -view.z); var shader = GameRenderer.getPositionColorShader(); vertexBuffer.drawWithShader(poseStack.last().pose(), event.getProjectionMatrix().copy(), shader); poseStack.popPose(); RenderSystem.depthMask(true); RenderSystem.disableBlend(); RenderSystem.enableCull(); RenderSystem.enableTexture();
  7. It is simple task when View Bobbing is disabled. In RenderWorldLastEvent I do this: Vector3d view = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); MatrixStack stack = event.getMatrixStack(); stack.translate(-view.x, -view.y, -view.z); GL11.glPushMatrix(); RenderSystem.multMatrix(stack.last().pose()); double centerX = view.x; double centerY = view.y; double centerZ = view.z; double drawBeforeCameraDist = 1; double pitch = (mc.player.xRot) * Math.PI / 180; double yaw = (mc.player.yRot) * Math.PI / 180; centerX -= Math.sin(yaw) * Math.cos(pitch) * drawBeforeCameraDist; centerZ += Math.cos(yaw) * Math.cos(pitch) * drawBeforeCameraDist; centerY -= Math.sin(pitch) * drawBeforeCameraDist; But when I enabled View Bobbing, the center point starts moving in half-circle trajectory. I looked into GameRenderer class, bobView method. It calculates few float values and applies them to MatrixStack. I don't know if I can use this matrix (it comes in RenderWorldLastEvent), so I copied code from bobView and started experimentation. This is the best I can get: // omitted same lines from my first example double centerX = view.x; double centerY = view.y; double centerZ = view.z; double deltaXRot = 0; double deltaZRot = 0; double translateX = 0; double translateY = 0; if (mc.options.bobView && mc.getCameraEntity() instanceof PlayerEntity) { PlayerEntity playerentity = (PlayerEntity)mc.getCameraEntity(); float f = playerentity.walkDist - playerentity.walkDistO; float f1 = -(playerentity.walkDist + f * event.getPartialTicks()); float f2 = MathHelper.lerp(event.getPartialTicks(), playerentity.oBob, playerentity.bob); translateX = (double)(MathHelper.sin(f1 * (float)Math.PI) * f2 * 0.5F); translateY = (double)(-Math.abs(MathHelper.cos(f1 * (float)Math.PI) * f2)); deltaZRot = MathHelper.sin(f1 * (float)Math.PI) * f2 * 3.0F; deltaXRot = Math.abs(MathHelper.cos(f1 * (float)Math.PI - 0.2F) * f2) * 5.0F; } double drawBeforeCameraDist = 1; double yaw = (mc.player.yRot) * Math.PI / 180; double pitch = (mc.player.xRot + deltaXRot) * Math.PI / 180; centerY -= translateY; centerX += translateX * Math.cos(yaw); centerZ += translateX * Math.sin(yaw); centerX -= Math.sin(yaw) * Math.cos(pitch) * drawBeforeCameraDist; centerZ += Math.cos(yaw) * Math.cos(pitch) * drawBeforeCameraDist; centerY -= Math.sin(pitch) * drawBeforeCameraDist; Now center point doesn't jump to the right and left on the screen. And it doesn't jump up and down, but only if I look straight forward. As pitch angle goes far from 0 (either to -90 or 90), center point jumps harder up and down. Is my approach right? Or should I learn about MatrixStack and try to use it?

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.