Jump to content

thebear

Members
  • Posts

    10
  • Joined

  • Last visited

thebear's Achievements

Tree Puncher

Tree Puncher (2/8)

6

Reputation

  1. I actually had the same problem in the beginning too. What I did was, I downloaded the latest version from the forge website. Make sure you download "latest", not "recommended". In the latest version, the function names should be deobfuscated. The version I used was 1.15.2-31.1.19. Im not sure why, the mapping for it is 20200225-1.15.1. Hope it helps you!
  2. Alright, I solved my problem now. What I did is, I force loaded the chunk with ServerWorld::forceChunk and then got the BlockState with ServerWorld::getBlockState.
  3. The reason I want to do this is, that I'm writing a mod that gets the shortest path to a location. To be able to find a path, I need to get the blocks. Oh that makes sense. If the block isn't loaded, it doesn't have a state. Is there any way of getting the type of block at some position in an unloaded chunk then?
  4. So basically what I'm trying to do is to get the BlockState of a block in an unloaded chunk. I tried to do so by using World::getBlockState() which works fine in loaded chunks, but in unloaded chunks, it returns a BlockState whose block is always VOID_AIR. As soon as the chunk gets loaded though, it works correctly. Is there a way to get the BlockState of a block in an unloaded chunk?
  5. Actually it didn't quite work in the nether, but now it does. The reason I am posting this is, that if someone has the same problem in the future, they will find this. I searched for this on google for a good hour, but didn't find anything. New code: @SubscribeEvent public void render(RenderWorldLastEvent event) { IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource(); IVertexBuilder builder = buffer.getBuffer(RenderType.LINES); MatrixStack matrixStack = event.getMatrixStack(); PlayerEntity player = Minecraft.getInstance().player; double x = player.lastTickPosX + (player.getPosX() - player.lastTickPosX) * event.getPartialTicks(); double y = player.lastTickPosY + (player.getPosY() - player.lastTickPosY) * event.getPartialTicks(); double z = player.lastTickPosZ + (player.getPosZ() - player.lastTickPosZ) * event.getPartialTicks(); matrixStack.push(); matrixStack.translate(-x, -y, -z); Matrix4f matrix = matrixStack.getLast().getMatrix(); builder.pos(matrix, 0, 0, 0).color(1f, 0, 0, 1f).endVertex(); builder.pos(matrix, 0, 256, 0).color(1f, 0, 0, 1f).endVertex(); matrixStack.pop(); RenderSystem.disableDepthTest(); buffer.finish(RenderType.LINES); }
  6. Thanks for your reply! Finally got it working correctly! new code: public class PathRenderer { private Minecraft mc; public PathRenderer() { mc = Minecraft.getInstance(); } @SubscribeEvent public void render(RenderWorldLastEvent event){ Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); MatrixStack matrixStack = event.getMatrixStack(); Vec3d pos = mc.player.getPositionVec(); matrixStack.push(); matrixStack.translate(-pos.x, -pos.y, -pos.z); RenderSystem.color3f(1, 0, 0); RenderSystem.lineWidth(6); buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); Matrix4f matrix = matrixStack.getLast().getMatrix(); Color c = new Color(1f, 0f, 0f, 1f); drawLine(matrix, buffer, new Vec3d(0, 57, 0), new Vec3d(5, 57, 0)); tessellator.draw(); matrixStack.pop(); } private void drawLine(Matrix4f matrix, BufferBuilder buffer, Vec3d p1, Vec3d p2) { buffer.pos(matrix, (float)p1.x + 0.5f, (float)p1.y + 0.5f, (float)p1.z + 0.5f).endVertex(); buffer.pos(matrix, (float)p2.x + 0.5f, (float)p2.y + 0.5f, (float)p2.z + 0.5f).endVertex(); } }
  7. So I just tried the exact same code 1.14.4 and it worked perfectly. Is there something about rendering that has changed from 1.14.4 to 1.15.2?
  8. Hi, im fairly new to forge modding, so please forgive for asking such a stupid question. Now for my problem. Im trying to draw a line between two positions. Drawing the line works, but when I change pitch or yaw, the line doesn't adjust, it just stays in the same position on screen. I want it to adjust it's position, just like a normal block would. What happens: https://imgur.com/EwpOGuo What I tried: Main class: @Mod("path") public class path { public path() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); } private void setup(final FMLCommonSetupEvent event) { MinecraftForge.EVENT_BUS.register(new PathRenderer()); } } Renderer: public class PathRenderer { private Minecraft mc; public PathRenderer() { mc = Minecraft.getInstance(); } @SubscribeEvent public void render(RenderWorldLastEvent event){ double x = mc.player.getPositionVec().x; double y = mc.player.getPositionVec().y; double z = mc.player.getPositionVec().z; Vec3d p1 = new Vec3d(0, 57, 0); Vec3d p2 = new Vec3d(5, 57, 0); GL11.glPushMatrix(); GL11.glTranslated(-x, -y, -z); GL11.glLineWidth(6.0f); GL11.glColor3ub((byte)255,(byte)0,(byte)0); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3d(p1.x, p1.y, p1.z); GL11.glVertex3d(p2.x, p2.y, p2.z); GL11.glEnd(); GL11.glPopMatrix(); } }
×
×
  • Create New...

Important Information

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