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.

Kokkie

Forge Modder
  • Joined

  • Last visited

Everything posted by Kokkie

  1. You shouldn't use ID's...
  2. Thanks, it works
  3. This..? public class AMUtils { public static void drawLineMiddle(BlockPos start, BlockPos end, double x, double y, double z) { drawLine(start, end, x + 0.5, y + 0.5, z + 0.5); } public static void drawLine(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder buffer = Tessellator.getInstance().getBuffer(); buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); buffer.pos(x, y, z).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(x + posDiff.x, y + posDiff.y, z + posDiff.z).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } public static void drawBox(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); double minX = x + posDiff.x - 0.01; double minY = y + posDiff.y - 0.01; double minZ = z + posDiff.z - 0.01; double maxX = x + posDiff.x + 1.01; double maxY = y + posDiff.y + 1.01; double maxZ = z + posDiff.z + 1.01; GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder buffer = Tessellator.getInstance().getBuffer(); buffer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); buffer.pos(minX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 0).endVertex(); buffer.pos(minX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(maxX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(maxX, minY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(minX, minY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(minX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(minX, maxY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(maxX, maxY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(maxX, maxY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(minX, maxY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(minX, maxY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(minX, maxY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 0).endVertex(); buffer.pos(minX, minY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(maxX, maxY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 0).endVertex(); buffer.pos(maxX, minY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(maxX, maxY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 0).endVertex(); buffer.pos(maxX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(maxX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 0).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } public static void drawCross(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder buffer = Tessellator.getInstance().getBuffer(); buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); buffer.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); buffer.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } }
  4. So like this? public class AMUtils { public static void drawLineMiddle(BlockPos start, BlockPos end, double x, double y, double z) { drawLine(start, end, x + 0.5, y + 0.5, z + 0.5); } public static void drawLine(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); bb.pos(x, y, z).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); bb.pos(x + posDiff.x, y + posDiff.y, z + posDiff.z).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } public static void drawBox(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); double minX = x + posDiff.x - 0.01; double minY = y + posDiff.y - 0.01; double minZ = z + posDiff.z - 0.01; double maxX = x + posDiff.x + 1.01; double maxY = y + posDiff.y + 1.01; double maxZ = z + posDiff.z + 1.01; GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder buffer = Tessellator.getInstance().getBuffer(); buffer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); buffer.lightmap(240, 240); buffer.pos(minX, minY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(maxX, minY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(maxX, minY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(minX, minY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(minX, minY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(minX, maxY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(maxX, maxY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(maxX, maxY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(minX, maxY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(minX, maxY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(minX, minY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(maxX, minY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); buffer.pos(maxX, minY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } public static void drawCross(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); bb.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex(); bb.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex(); bb.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex(); bb.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex(); bb.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex(); bb.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex(); bb.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex(); bb.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } }
  5. So this? public class AMUtils { public static void drawLineMiddle(BlockPos start, BlockPos end, double x, double y, double z) { drawLine(start, end, x + 0.5, y + 0.5, z + 0.5); } public static void drawLine(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); bb.pos(x, y, z).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); bb.pos(x + posDiff.x, y + posDiff.y, z + posDiff.z).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } public static void drawBox(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); double minX = x + posDiff.x - 0.01; double minY = y + posDiff.y - 0.01; double minZ = z + posDiff.z - 0.01; double maxX = x + posDiff.x + 1.01; double maxY = y + posDiff.y + 1.01; double maxZ = z + posDiff.z + 1.01; GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); bb.lightmap(240, 240); RenderGlobal.drawBoundingBox(bb, minX, minY, minZ, maxX, maxY, maxZ, 1, 0, 0, 1); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } public static void drawCross(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); bb.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); bb.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); bb.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); bb.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); bb.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); bb.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); bb.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); bb.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } } Because this isn't working...
  6. Do I have to reset the lightmap after rendering?
  7. It can't be, I disable the lighting..
  8. How can I remove or disable the color being darkened by idk what? Like, I set it to red but it is a dark color red instead of just bright red. Also, it becomes bright red when I don't look at the block and are a few blocks away from it.
  9. Now, how would I render a cube? (6 squares)
  10. Thanks!
  11. I've sort of got it working, it only draws 4 lines instead of 12... Only the top Z lines and bottom X lines. public class TESRAutoMiner extends TileEntitySpecialRenderer<TileEntityAutoMiner> { @Override public void render(TileEntityAutoMiner te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { if (te.DRAW_LINE) { AMUtils.drawLineMiddle(te.getPos(), te.BEGIN_LINE_POS, x, y, z); AMUtils.drawBox(te.getPos(), te.BEGIN_LINE_POS, x, y, z); } } @Override public boolean isGlobalRenderer(TileEntityAutoMiner te) { return true; } } public class AMUtils { public static void drawLineMiddle(BlockPos start, BlockPos end, double x, double y, double z) { drawLine(start, end, x + 0.5, y + 0.5, z + 0.5); } private static void drawLine(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); bb.pos(x, y, z).color(1, 0, 0, 1F).endVertex(); bb.pos(x + posDiff.x, y + posDiff.y, z + posDiff.z).color(1, 0, 0, 1F).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } public static void drawBox(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); double minX = x + posDiff.x; double minY = y + posDiff.y; double minZ = z + posDiff.z; double maxX = x + posDiff.x + 1; double maxY = y + posDiff.y + 1; double maxZ = z + posDiff.z + 1; GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); RenderGlobal.drawBoundingBox(bb, minX, minY, minZ, maxX, maxY, maxZ, 1, 0, 0, 1); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } } Also, how can I make it so it renders even if you can't see the block, like beacons?
  12. I now have this. public class TESRAutoMiner extends TileEntitySpecialRenderer<TileEntityAutoMiner> { @Override public void render(TileEntityAutoMiner te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { if (te.DRAW_LINE) { AMUtils.drawLineMiddle(te.getPos(), te.BEGIN_LINE_POS, x, y, z); AMUtils.drawBox(te.BEGIN_LINE_POS, x, y, z); } } @Override public boolean isGlobalRenderer(TileEntityAutoMiner te) { return true; } } public class AMUtils { public static void drawLineMiddle(BlockPos start, BlockPos end, double x, double y, double z) { drawLine(start, end, x + 0.5, y + 0.5, z + 0.5); } private static void drawLine(BlockPos start, BlockPos end, double x, double y, double z) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); bb.pos(x, y, z).color(1, 0, 0, 1F).endVertex(); bb.pos(x + posDiff.x, y + posDiff.y, z + posDiff.z).color(1, 0, 0, 1F).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } public static void drawBox(BlockPos block, double x, double y, double z) { double minX = block.getX(); double minY = block.getY(); double minZ = block.getZ(); double maxX = block.getX() + 1; double maxY = block.getY() + 1; double maxZ = block.getZ() + 1; GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.glLineWidth(2.0F); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); RenderGlobal.drawBoundingBox(minX, minY, minZ, maxX, maxY, maxZ, 1, 0, 0, 1); GlStateManager.depthMask(true); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); } } It renders the line, but doesn't render the box.
  13. So, now I want to add a block outline of where it used to be, but it doesn't, also the line doesn't work anymore either. public class TESRAutoMiner extends TileEntitySpecialRenderer<TileEntityAutoMiner> { @Override public void render(TileEntityAutoMiner te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { if (te.DRAW_LINE) { BlockPos pos = new BlockPos(x, y, z); AMUtils.drawLineMiddle(te.getPos(), te.BEGIN_LINE_POS, pos); AMUtils.drawBox(te.BEGIN_LINE_POS, pos); } } } public class AMUtils { public static void drawLineMiddle(BlockPos start, BlockPos end, BlockPos pos) { BlockPos start1 = start.add(0.5, 0.5, 0.5); BlockPos end1 = end.add(0.5, 0.5, 0.5); drawLine(start1, end1, pos); } private static void drawLine(BlockPos start, BlockPos end, BlockPos pos) { Vec3d start1 = new Vec3d(start); Vec3d end1 = new Vec3d(end); Vec3d posDiff = end1.subtract(start1); GlStateManager.pushMatrix(); GlStateManager.glLineWidth(2F); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); bb.pos(pos.getX(), pos.getY(), pos.getZ()).color(0, 1, 0, 1F).endVertex(); bb.pos(pos.getX() + posDiff.x, pos.getY() + posDiff.y, pos.getZ() + posDiff.z).color(0, 1, 0, 1F).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); } public static void drawBox(BlockPos block, BlockPos pos) { drawLine(block, block.add(1, 0, 0), pos); drawLine(block, block.add(0, 1, 0), pos); drawLine(block, block.add(0, 0, 1), pos); drawLine(block.add(1, 0, 0), block.add(1, 1, 0), pos); drawLine(block.add(1, 0, 0), block.add(1, 0, 1), pos); drawLine(block.add(0, 1, 0), block.add(1, 1, 0), pos); drawLine(block.add(0, 1, 0), block.add(0, 1, 1), pos); drawLine(block.add(0, 0, 1), block.add(1, 0, 1), pos); drawLine(block.add(0, 0, 1), block.add(0, 1, 1), pos); drawLine(block.add(1, 1, 0), block.add(1, 1, 1), pos); drawLine(block.add(1, 0, 1), block.add(1, 1, 1), pos); drawLine(block.add(0, 1, 1), block.add(1, 1, 1), pos); } }
  14. Thanks, it works!
  15. I think it uses metadata.
  16. You can get the type from the tileentity
  17. Changed it to this. Vec3d start = new Vec3d(x, y, z); Vec3d end = new Vec3d(te.BEGIN_LINE_POS.subtract(te.getPos())); GlStateManager.disableTexture2D(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR); bb.pos(x + 0.5, y + 0.5, z + 0.5).color(0, 1, 1, 1F).endVertex(); bb.pos(end.x + 0.5, end.y + 0.5, end.z + 0.5).color(0, 1, 1, 1F).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableTexture2D(); Doesn't work.
  18. So.. This? Vec3i start = new Vec3i(x, y, z); Vec3d end = new Vec3d(te.BEGIN_LINE_POS.subtract(start)); GlStateManager.disableTexture2D(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR); bb.pos(x + 0.5, y + 0.5, z + 0.5).color(0, 1, 1, 1F).endVertex(); bb.pos(end.x + 0.5, end.y + 0.5, end.z + 0.5).color(0, 1, 1, 1F).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableTexture2D(); It for some reason draws a line from the block to a random place...
  19. Why wouldn't this work? Vec3d start = new Vec3d(te.getPos()); Vec3d end = new Vec3d(te.BEGIN_LINE_POS); GlStateManager.disableTexture2D(); BufferBuilder bb = Tessellator.getInstance().getBuffer(); bb.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR); bb.pos(start.x + 0.5, start.y + 0.5, start.z + 0.5).color(0, 1, 1, 1F).endVertex(); bb.pos(end.x, end.y, end.z).color(0, 1, 1, 1F).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableTexture2D(); Can someone explain?
  20. Thanks, but now how do I change the pos it draws the line to (from the te pos)?
  21. Added a TESR. Changed it to DefaultVertexFormats.POSITION_COLOR. It doesn't work though. Block. public class BlockAutoMiner extends Block { public static final PropertyDirection FACING = BlockHorizontal.FACING; public static IProperty ACTIVATED = PropertyBool.create("activated"); public BlockAutoMiner() { super(Material.PISTON); setDefaultState( blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVATED, false)); } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { setDefaultFacing(worldIn, pos, state); } private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState iblockstate = worldIn.getBlockState(pos.north()); IBlockState iblockstate1 = worldIn.getBlockState(pos.south()); IBlockState iblockstate2 = worldIn.getBlockState(pos.west()); IBlockState iblockstate3 = worldIn.getBlockState(pos.east()); EnumFacing enumfacing = state.getValue(FACING); if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock()) { enumfacing = EnumFacing.SOUTH; } else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock()) { enumfacing = EnumFacing.NORTH; } else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock()) { enumfacing = EnumFacing.EAST; } else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock()) { enumfacing = EnumFacing.WEST; } worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } } @Override public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()), 2); if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.setLinePos(pos); } } @Override public IBlockState getStateFromMeta(int meta) { EnumFacing enumfacing = EnumFacing.getFront(meta); if (enumfacing.getAxis() == EnumFacing.Axis.Y) { enumfacing = EnumFacing.NORTH; } return getDefaultState().withProperty(FACING, enumfacing); } @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); return state.withProperty(ACTIVATED, te.ACTIVATED); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(FACING).getIndex(); } @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } @Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation(state.getValue(FACING))); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] { FACING, ACTIVATED }); } @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); if (te.ACTIVATED) { EnumFacing enumfacing = stateIn.getValue(FACING); double d0 = pos.getX() + 0.5D; double d1 = pos.getY() + 0.5D; double d2 = pos.getZ() + 0.5D; double d3 = 0.52D; double d4 = rand.nextDouble() * 0.6D - 0.3D; switch (enumfacing) { case WEST: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]); break; case EAST: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]); break; case NORTH: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]); break; case SOUTH: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]); default: break; } } } } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { if (hand == EnumHand.MAIN_HAND) { if (TileEntityFurnace.isItemFuel(playerIn.getHeldItem(hand))) { if (!playerIn.isCreative()) { playerIn.getHeldItem(hand).shrink(1); } if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.addFuel(getItemBurnTime(playerIn.getHeldItem(hand))); } } else if (playerIn.getHeldItem(hand).getItem() == AMItems.WRENCH) { if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); if (te.ACTIVATED) { te.setActivated(false); } else { if (te.FUEL_AMOUNT > 0) { te.setActivated(true); } } } } else if (playerIn.getHeldItem(hand).getItem() == Item.getItemFromBlock(Blocks.TORCH)) { if (!playerIn.isCreative()) { playerIn.getHeldItem(hand).shrink(1); } if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.addTorch(); } } else if (playerIn.getHeldItem(hand).getItem() == Item.getItemFromBlock(Blocks.COBBLESTONE)) { if (!playerIn.isCreative()) { playerIn.getHeldItem(hand).shrink(1); } if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.addBlock(); } } else if (playerIn.getHeldItem(hand).getItem() == AMItems.LINE_BUTTON) { if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.toggleDrawLine(); } } } } else { if (hand == EnumHand.MAIN_HAND) { if (playerIn.getHeldItem(hand).getItem() == AMItems.WRENCH || TileEntityFurnace.isItemFuel(playerIn.getHeldItem(hand)) || playerIn.getHeldItem(hand).getItem() == AMItems.LINE_BUTTON) { Minecraft.getMinecraft().player.swingArm(hand); } } } return true; } private int getItemBurnTime(ItemStack stack) { if (stack.isEmpty()) { return 0; } else { Item item = stack.getItem(); if (!item.getRegistryName().getResourceDomain().equals("minecraft")) { int burnTime = net.minecraftforge.fml.common.registry.GameRegistry.getFuelValue(stack); if (burnTime != 0) { return burnTime; } } if (item == Item.getItemFromBlock(Blocks.WOODEN_SLAB)) { return 160; } else if (item == Item.getItemFromBlock(Blocks.WOOL)) { return 120; } else if (item == Item.getItemFromBlock(Blocks.CARPET)) { return 80; } else if (item == Item.getItemFromBlock(Blocks.LADDER)) { return 320; } else if (item == Item.getItemFromBlock(Blocks.WOODEN_BUTTON)) { return 120; } else if (Block.getBlockFromItem(item).getDefaultState().getMaterial() == Material.WOOD) { return 320; } else if (item == Item.getItemFromBlock(Blocks.COAL_BLOCK)) { return 16000; } else if (item instanceof ItemTool && "WOOD".equals(((ItemTool) item).getToolMaterialName())) { return 200; } else if (item instanceof ItemSword && "WOOD".equals(((ItemSword) item).getToolMaterialName())) { return 200; } else if (item instanceof ItemHoe && "WOOD".equals(((ItemHoe) item).getMaterialName())) { return 200; } else if (item == Items.STICK) { return 120; } else if (item != Items.BOW && item != Items.FISHING_ROD) { if (item == Items.SIGN) { return 200; } else if (item == Items.COAL) { return 1600; } else if (item == Items.LAVA_BUCKET) { return 20000; } else if (item != Item.getItemFromBlock(Blocks.SAPLING) && item != Items.BOWL) { if (item == Items.BLAZE_ROD) { return 2400; } else if (item instanceof ItemDoor && item != Items.IRON_DOOR) { return 200; } else { return item instanceof ItemBoat ? 400 : 0; } } else { return 120; } } else { return 320; } } } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); for (int i = 0; i < te.TORCHES; i++) { worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY() + 1, pos.getZ(), new ItemStack(Blocks.TORCH))); } for (int x = 0; x < te.BLOCKS; x++) { worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY() + 1, pos.getZ(), new ItemStack(Blocks.COBBLESTONE))); } } } super.breakBlock(worldIn, pos, state); } @Override public boolean hasTileEntity() { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityAutoMiner(); } @Override public boolean hasTileEntity(IBlockState state) { return true; } } TileEntity. public class TileEntityAutoMiner extends TileEntity implements ITickable { public int FUEL_AMOUNT = 0; public boolean ACTIVATED = false; public boolean UPDATE = false; public int TICKS = 0; public int TORCHES = 0; public int PLACE_TORCH = 0; public int BLOCKS = 0; public boolean DRAW_LINE = false; public BlockPos BEGIN_LINE_POS = new BlockPos(0, 0, 0); public int DRAW_LINE_X = 0; public int DRAW_LINE_Y = 0; public int DRAW_LINE_Z = 0; public TileEntityAutoMiner() { } public void addFuel(int amount) { FUEL_AMOUNT += amount; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void removeFuel() { if (FUEL_AMOUNT > 0) { FUEL_AMOUNT--; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } } public void addTorch() { TORCHES++; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void removeTorches(int amount) { TORCHES -= amount; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void addPlaceTorch() { PLACE_TORCH++; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void removePlaceTorches() { PLACE_TORCH = 0; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void addBlock() { BLOCKS++; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void removeBlock() { BLOCKS--; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void setActivated(boolean active) { ACTIVATED = active; markDirty(); IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); world.notifyBlockUpdate(pos, state, state, 3); world.scheduleBlockUpdate(pos, getBlockType(), 0, 0); } public void addTick() { TICKS++; markDirty(); IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); } public void removeTicks() { TICKS = 0; markDirty(); IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); } public void toggleDrawLine() { DRAW_LINE = !DRAW_LINE; System.out.println(DRAW_LINE); markDirty(); IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); } public void setLinePos(BlockPos pos) { BEGIN_LINE_POS = pos; DRAW_LINE_X = pos.getX(); DRAW_LINE_Y = pos.getY(); DRAW_LINE_Z = pos.getZ(); markDirty(); IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("FuelAmount", FUEL_AMOUNT); compound.setBoolean("Activated", ACTIVATED); compound.setInteger("Ticks", TICKS); compound.setInteger("Torches", TORCHES); compound.setInteger("PlaceTorch", PLACE_TORCH); compound.setInteger("Blocks", BLOCKS); compound.setBoolean("DrawLine", DRAW_LINE); compound.setInteger("PosX", DRAW_LINE_X); compound.setInteger("PosY", DRAW_LINE_Y); compound.setInteger("PosZ", DRAW_LINE_Z); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); FUEL_AMOUNT = compound.getInteger("FuelAmount"); ACTIVATED = compound.getBoolean("Activated"); TICKS = compound.getInteger("Ticks"); TORCHES = compound.getInteger("Torches"); PLACE_TORCH = compound.getInteger("PlaceTorch"); BLOCKS = compound.getInteger("Blocks"); DRAW_LINE = compound.getBoolean("DrawLine"); DRAW_LINE_X = compound.getInteger("PosX"); DRAW_LINE_Y = compound.getInteger("PosY"); DRAW_LINE_Z = compound.getInteger("PosZ"); BEGIN_LINE_POS = new BlockPos(DRAW_LINE_X, DRAW_LINE_Y, DRAW_LINE_Z); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); handleUpdateTag(pkt.getNbtCompound()); } @Override public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(pos, 3, getUpdateTag()); } @Override public NBTTagCompound getUpdateTag() { return writeToNBT(new NBTTagCompound()); } @Override public void update() { if (ACTIVATED) { addTick(); UPDATE = true; removeFuel(); if (FUEL_AMOUNT <= 0) { FUEL_AMOUNT = 0; setActivated(false); markDirty(); } if (TICKS == 20) { if (!world.isRemote) { EnumFacing facing = world.getBlockState(pos).getValue(BlockAutoMiner.FACING); EnumFacing facingL = facing.rotateYCCW(); EnumFacing facingR = facing.rotateY(); Random random = new Random(); BlockPos positionC = pos.offset(world.getBlockState(pos).getValue(BlockAutoMiner.FACING)); BlockPos positionL = positionC.offset(facingL); BlockPos positionR = positionC.offset(facingR); BlockPos positionCU = positionC.up(); BlockPos positionLU = positionL.up(); BlockPos positionRU = positionR.up(); BlockPos positionCUU = positionCU.up(); BlockPos positionLUU = positionLU.up(); BlockPos positionRUU = positionRU.up(); IBlockState stateC = world.getBlockState(positionC); IBlockState stateL = world.getBlockState(positionL); IBlockState stateR = world.getBlockState(positionR); IBlockState stateCU = world.getBlockState(positionCU); IBlockState stateLU = world.getBlockState(positionLU); IBlockState stateRU = world.getBlockState(positionRU); IBlockState stateCUU = world.getBlockState(positionCUU); IBlockState stateLUU = world.getBlockState(positionLUU); IBlockState stateRUU = world.getBlockState(positionRUU); List<ItemStack> stackC = stateC.getBlock().getDrops(world, positionC, stateC, 0); List<ItemStack> stackL = stateL.getBlock().getDrops(world, positionL, stateL, 0); List<ItemStack> stackR = stateR.getBlock().getDrops(world, positionR, stateR, 0); List<ItemStack> stackCU = stateCU.getBlock().getDrops(world, positionCU, stateCU, 0); List<ItemStack> stackLU = stateLU.getBlock().getDrops(world, positionLU, stateLU, 0); List<ItemStack> stackRU = stateRU.getBlock().getDrops(world, positionRU, stateRU, 0); List<ItemStack> stackCUU = stateCUU.getBlock().getDrops(world, positionCUU, stateCUU, 0); List<ItemStack> stackLUU = stateLUU.getBlock().getDrops(world, positionLUU, stateLUU, 0); List<ItemStack> stackRUU = stateRUU.getBlock().getDrops(world, positionRUU, stateRUU, 0); dropItems(stackC, stateC, positionC); dropItems(stackL, stateL, positionL); dropItems(stackR, stateR, positionR); dropItems(stackCU, stateCU, positionCU); dropItems(stackLU, stateLU, positionLU); dropItems(stackRU, stateRU, positionRU); dropItems(stackCUU, stateCUU, positionCUU); dropItems(stackLUU, stateLUU, positionLUU); dropItems(stackRUU, stateRUU, positionRUU); setBlockToAir(stateC, positionC); setBlockToAir(stateL, positionL); setBlockToAir(stateR, positionR); setBlockToAir(stateCU, positionCU); setBlockToAir(stateLU, positionLU); setBlockToAir(stateRU, positionRU); setBlockToAir(stateCUU, positionCUU); setBlockToAir(stateLUU, positionLUU); setBlockToAir(stateRUU, positionRUU); if ((TORCHES >= 2) && (PLACE_TORCH >= 6)) { BlockPos positionLLU = positionLU.offset(facingL); BlockPos positionRRU = positionRU.offset(facingR); if (world.getBlockState(positionLLU).isSideSolid(world, positionLLU, facingR) && (world.getBlockState(positionLU).getMaterial() == Material.AIR)) { if (world.setBlockState(positionLU, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, facingR))) { removeTorches(1); removePlaceTorches(); } } if (world.getBlockState(positionRRU).isSideSolid(world, positionRRU, facingL) && (world.getBlockState(positionRU).getMaterial() == Material.AIR)) { if (world.setBlockState(positionRU, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, facingL))) { removeTorches(1); removePlaceTorches(); } } } else { addPlaceTorch(); } BlockPos positionD = positionC.down(); IBlockState stateD = world.getBlockState(positionD); if (BLOCKS > 0) { if (!stateD.isTopSolid()) { world.setBlockState(positionD, Blocks.COBBLESTONE.getDefaultState()); removeBlock(); } } else { if (!stateD.isTopSolid()) { setActivated(false); removeTicks(); } } if (!world.getBlockState(pos.down()).isTopSolid()) { setActivated(false); removeTicks(); } if (world.getBlockState(positionC).getMaterial().isSolid()) { setActivated(false); removeTicks(); } } } if (TICKS == 40) { if (!world.isRemote) { BlockPos position = pos.offset(world.getBlockState(pos).getValue(BlockAutoMiner.FACING)); BlockPos position1 = pos; world.setBlockState(position, world.getBlockState(pos)); TileEntityAutoMiner te = new TileEntityAutoMiner(); te.ACTIVATED = ACTIVATED; te.FUEL_AMOUNT = FUEL_AMOUNT; te.TICKS = TICKS; te.UPDATE = UPDATE; te.TORCHES = TORCHES; te.PLACE_TORCH = PLACE_TORCH; te.BLOCKS = BLOCKS; te.BEGIN_LINE_POS = BEGIN_LINE_POS; te.DRAW_LINE = DRAW_LINE; te.DRAW_LINE_X = DRAW_LINE_X; te.DRAW_LINE_Y = DRAW_LINE_Y; te.DRAW_LINE_Z = DRAW_LINE_Z; ACTIVATED = false; TICKS = 0; UPDATE = false; TORCHES = 0; PLACE_TORCH = 0; BLOCKS = 0; BEGIN_LINE_POS = new BlockPos(0, 0, 0); DRAW_LINE = false; DRAW_LINE_X = 0; DRAW_LINE_Y = 0; DRAW_LINE_Z = 0; world.setTileEntity(position, te); world.setBlockToAir(position1); } } } else { if (UPDATE) { IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); } UPDATE = false; } if (TICKS >= 40) { removeTicks(); } } private void dropItems(List<ItemStack> stackList, IBlockState state, BlockPos pos) { for (int i = 0; i < stackList.size(); i++) { ItemStack stack = stackList.get(i); if ((stack.getItem() instanceof ItemBlock) && ((Block.getBlockFromItem(stack.getItem()).getBlockHardness(state, world, pos) < 0F) || (Block.getBlockFromItem(stack.getItem()).getBlockHardness(state, world, pos) > 30F))) { continue; } world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), stack)); } } private void setBlockToAir(IBlockState state, BlockPos pos) { if (!(state.getBlockHardness(world, pos) > 30F) && !(state.getBlockHardness(world, pos) < 0F)) { world.setBlockToAir(pos); } } } TESR. public class TESRAutoMiner extends TileEntitySpecialRenderer<TileEntityAutoMiner> { @Override public void render(TileEntityAutoMiner te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { super.render(te, x, y, z, partialTicks, destroyStage, alpha); if (te.DRAW_LINE) { GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glTranslated(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ()); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); drawLine(new Vec3d(te.DRAW_LINE_X, te.DRAW_LINE_Y, te.DRAW_LINE_Z), new Vec3d(te.getPos())); GL11.glPopAttrib(); GL11.glPopMatrix(); } } private void drawLine(Vec3d blockA, Vec3d blockB) { Tessellator tess = Tessellator.getInstance(); BufferBuilder buff = tess.getBuffer(); blockB.addVector(0, 1, 0); blockB.addVector(0, -1, 0); blockA.addVector(0, -0.02f, 0); buff.begin(7, DefaultVertexFormats.POSITION_COLOR); buff.color(0F, 1F, 1F, 1F); Vec3d recLong = blockA.subtract(blockB); Vec3d perpendicular = Vec3d.fromPitchYaw(1.0F, 1.0F); perpendicular = perpendicular.normalize(); float Width = 1f / 16f; Vec3d R1 = blockA.subtract(blockB); Vec3d R2 = blockA.subtract(blockB); Vec3d R3 = blockA.subtract(blockB); Vec3d R4 = blockA.subtract(blockB); R1.addVector(blockA.x + perpendicular.x * Width, 0, 0); R1.addVector(0, 0, blockA.z + perpendicular.z * Width); R2.addVector(blockA.x - perpendicular.x * Width, 0, 0); R2.addVector(0, 0, blockA.z - perpendicular.z * Width); R1.addVector(0, blockA.y - 0.01, 0); R2.addVector(0, blockA.y - 0.01, 0); R3.addVector(blockB.x + perpendicular.x * Width, 0, 0); R3.addVector(0, 0, blockB.z + perpendicular.z * Width); R4.addVector(blockB.x - perpendicular.x * Width, 0, 0); R4.addVector(0, 0, blockB.z - perpendicular.z * Width); R3.addVector(0, blockB.y + 0.75, 0); R4.addVector(0, blockB.y + 0.75, 0); int[] a = { (int) (R1.x + 0.5), (int) R1.y, (int) (R1.z + 0.5) }; int[] b = { (int) (R3.x + 0.5), (int) R3.y, (int) (R3.z + 0.5) }; int[] c = { (int) (R4.x + 0.5), (int) R4.y, (int) (R4.z + 0.5) }; int[] d = { (int) (R2.x + 0.5), (int) R2.y, (int) (R2.z + 0.5) }; buff.addVertexData(a); buff.addVertexData(b); buff.addVertexData(c); buff.addVertexData(d); tess.draw(); } }
  22. Now, I saw this post. I thought, you know, let's add that to my mod. So I basically did the things in there and made some changes. But it doesn't work. Here's my block class. public class BlockAutoMiner extends Block { public static final PropertyDirection FACING = BlockHorizontal.FACING; public static IProperty ACTIVATED = PropertyBool.create("activated"); public BlockAutoMiner() { super(Material.PISTON); setDefaultState( blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVATED, false)); } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { setDefaultFacing(worldIn, pos, state); } private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState iblockstate = worldIn.getBlockState(pos.north()); IBlockState iblockstate1 = worldIn.getBlockState(pos.south()); IBlockState iblockstate2 = worldIn.getBlockState(pos.west()); IBlockState iblockstate3 = worldIn.getBlockState(pos.east()); EnumFacing enumfacing = state.getValue(FACING); if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock()) { enumfacing = EnumFacing.SOUTH; } else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock()) { enumfacing = EnumFacing.NORTH; } else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock()) { enumfacing = EnumFacing.EAST; } else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock()) { enumfacing = EnumFacing.WEST; } worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } } @Override public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing()), 2); if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.setLinePos(pos); } } @Override public IBlockState getStateFromMeta(int meta) { EnumFacing enumfacing = EnumFacing.getFront(meta); if (enumfacing.getAxis() == EnumFacing.Axis.Y) { enumfacing = EnumFacing.NORTH; } return getDefaultState().withProperty(FACING, enumfacing); } @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); return state.withProperty(ACTIVATED, te.ACTIVATED); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(FACING).getIndex(); } @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } @Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation(state.getValue(FACING))); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] { FACING, ACTIVATED }); } @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); if (te.ACTIVATED) { EnumFacing enumfacing = stateIn.getValue(FACING); double d0 = pos.getX() + 0.5D; double d1 = pos.getY() + 0.5D; double d2 = pos.getZ() + 0.5D; double d3 = 0.52D; double d4 = rand.nextDouble() * 0.6D - 0.3D; switch (enumfacing) { case WEST: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]); break; case EAST: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]); break; case NORTH: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]); break; case SOUTH: worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]); default: break; } } } } @Override public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { if (playerIn.getHeldItemMainhand().getItem() == AMItems.LINE_BUTTON && worldIn.isRemote) { playerIn.swingArm(EnumHand.MAIN_HAND); } else if (playerIn.getHeldItemMainhand().getItem() == AMItems.LINE_BUTTON && !worldIn.isRemote) { if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.setDrawLine(false); } } } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { if (hand == EnumHand.MAIN_HAND) { if (TileEntityFurnace.isItemFuel(playerIn.getHeldItem(hand))) { if (!playerIn.isCreative()) { playerIn.getHeldItem(hand).shrink(1); } if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.addFuel(getItemBurnTime(playerIn.getHeldItem(hand))); } } else if (playerIn.getHeldItem(hand).getItem() == AMItems.WRENCH) { if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); if (te.ACTIVATED) { te.setActivated(false); } else { if (te.FUEL_AMOUNT > 0) { te.setActivated(true); } } } } else if (playerIn.getHeldItem(hand).getItem() == Item.getItemFromBlock(Blocks.TORCH)) { if (!playerIn.isCreative()) { playerIn.getHeldItem(hand).shrink(1); } if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.addTorch(); } } else if (playerIn.getHeldItem(hand).getItem() == Item.getItemFromBlock(Blocks.COBBLESTONE)) { if (!playerIn.isCreative()) { playerIn.getHeldItem(hand).shrink(1); } if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.addBlock(); } } else if (playerIn.getHeldItem(hand).getItem() == AMItems.LINE_BUTTON) { if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); te.setDrawLine(true); } } } } else { if (hand == EnumHand.MAIN_HAND) { if (playerIn.getHeldItem(hand).getItem() == AMItems.WRENCH || TileEntityFurnace.isItemFuel(playerIn.getHeldItem(hand)) || playerIn.getHeldItem(hand).getItem() == AMItems.LINE_BUTTON) { Minecraft.getMinecraft().player.swingArm(hand); } } } return true; } private int getItemBurnTime(ItemStack stack) { if (stack.isEmpty()) { return 0; } else { Item item = stack.getItem(); if (!item.getRegistryName().getResourceDomain().equals("minecraft")) { int burnTime = net.minecraftforge.fml.common.registry.GameRegistry.getFuelValue(stack); if (burnTime != 0) { return burnTime; } } if (item == Item.getItemFromBlock(Blocks.WOODEN_SLAB)) { return 160; } else if (item == Item.getItemFromBlock(Blocks.WOOL)) { return 120; } else if (item == Item.getItemFromBlock(Blocks.CARPET)) { return 80; } else if (item == Item.getItemFromBlock(Blocks.LADDER)) { return 320; } else if (item == Item.getItemFromBlock(Blocks.WOODEN_BUTTON)) { return 120; } else if (Block.getBlockFromItem(item).getDefaultState().getMaterial() == Material.WOOD) { return 320; } else if (item == Item.getItemFromBlock(Blocks.COAL_BLOCK)) { return 16000; } else if (item instanceof ItemTool && "WOOD".equals(((ItemTool) item).getToolMaterialName())) { return 200; } else if (item instanceof ItemSword && "WOOD".equals(((ItemSword) item).getToolMaterialName())) { return 200; } else if (item instanceof ItemHoe && "WOOD".equals(((ItemHoe) item).getMaterialName())) { return 200; } else if (item == Items.STICK) { return 120; } else if (item != Items.BOW && item != Items.FISHING_ROD) { if (item == Items.SIGN) { return 200; } else if (item == Items.COAL) { return 1600; } else if (item == Items.LAVA_BUCKET) { return 20000; } else if (item != Item.getItemFromBlock(Blocks.SAPLING) && item != Items.BOWL) { if (item == Items.BLAZE_ROD) { return 2400; } else if (item instanceof ItemDoor && item != Items.IRON_DOOR) { return 200; } else { return item instanceof ItemBoat ? 400 : 0; } } else { return 120; } } else { return 320; } } } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { if (worldIn.getTileEntity(pos) instanceof TileEntityAutoMiner) { TileEntityAutoMiner te = (TileEntityAutoMiner) worldIn.getTileEntity(pos); for (int i = 0; i < te.TORCHES; i++) { worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY() + 1, pos.getZ(), new ItemStack(Blocks.TORCH))); } for (int x = 0; x < te.BLOCKS; x++) { worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY() + 1, pos.getZ(), new ItemStack(Blocks.COBBLESTONE))); } } } super.breakBlock(worldIn, pos, state); } @Override public boolean hasTileEntity() { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityAutoMiner(); } @Override public boolean hasTileEntity(IBlockState state) { return true; } } My tile entity class. public class TileEntityAutoMiner extends TileEntity implements ITickable { public int FUEL_AMOUNT = 0; public boolean ACTIVATED = false; public boolean UPDATE = false; public int TICKS = 0; public int TORCHES = 0; public int PLACE_TORCH = 0; public int BLOCKS = 0; public boolean DRAW_LINE = false; public BlockPos BEGIN_LINE_POS = new BlockPos(0, 0, 0); public int DRAW_LINE_X = 0; public int DRAW_LINE_Y = 0; public int DRAW_LINE_Z = 0; public TileEntityAutoMiner() { } public void addFuel(int amount) { FUEL_AMOUNT += amount; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void removeFuel() { if (FUEL_AMOUNT > 0) { FUEL_AMOUNT--; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } } public void addTorch() { TORCHES++; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void removeTorches(int amount) { TORCHES -= amount; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void addPlaceTorch() { PLACE_TORCH++; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void removePlaceTorches() { PLACE_TORCH = 0; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void addBlock() { BLOCKS++; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void removeBlock() { BLOCKS--; IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); markDirty(); } public void setActivated(boolean active) { ACTIVATED = active; markDirty(); IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); world.notifyBlockUpdate(pos, state, state, 3); world.scheduleBlockUpdate(pos, getBlockType(), 0, 0); } public void addTick() { TICKS++; markDirty(); IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); } public void removeTicks() { TICKS = 0; markDirty(); IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); } public void setDrawLine(boolean draw) { DRAW_LINE = draw; markDirty(); IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); } public void setLinePos(BlockPos pos) { BEGIN_LINE_POS = pos; DRAW_LINE_X = pos.getX(); DRAW_LINE_Y = pos.getY(); DRAW_LINE_Z = pos.getZ(); markDirty(); IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("FuelAmount", FUEL_AMOUNT); compound.setBoolean("Activated", ACTIVATED); compound.setInteger("Ticks", TICKS); compound.setInteger("Torches", TORCHES); compound.setInteger("PlaceTorch", PLACE_TORCH); compound.setInteger("Blocks", BLOCKS); compound.setBoolean("DrawLine", DRAW_LINE); compound.setInteger("PosX", DRAW_LINE_X); compound.setInteger("PosY", DRAW_LINE_Y); compound.setInteger("PosZ", DRAW_LINE_Z); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); FUEL_AMOUNT = compound.getInteger("FuelAmount"); ACTIVATED = compound.getBoolean("Activated"); TICKS = compound.getInteger("Ticks"); TORCHES = compound.getInteger("Torches"); PLACE_TORCH = compound.getInteger("PlaceTorch"); BLOCKS = compound.getInteger("Blocks"); DRAW_LINE = compound.getBoolean("DrawLine"); DRAW_LINE_X = compound.getInteger("PosX"); DRAW_LINE_Y = compound.getInteger("PosY"); DRAW_LINE_Z = compound.getInteger("PosZ"); BEGIN_LINE_POS = new BlockPos(DRAW_LINE_X, DRAW_LINE_Y, DRAW_LINE_Z); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); handleUpdateTag(pkt.getNbtCompound()); } @Override public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(pos, 3, getUpdateTag()); } @Override public NBTTagCompound getUpdateTag() { return writeToNBT(new NBTTagCompound()); } @Override public void update() { if (ACTIVATED) { addTick(); UPDATE = true; removeFuel(); if (FUEL_AMOUNT <= 0) { FUEL_AMOUNT = 0; setActivated(false); markDirty(); } if (TICKS == 20) { if (!world.isRemote) { EnumFacing facing = world.getBlockState(pos).getValue(BlockAutoMiner.FACING); EnumFacing facingL = facing.rotateYCCW(); EnumFacing facingR = facing.rotateY(); Random random = new Random(); BlockPos positionC = pos.offset(world.getBlockState(pos).getValue(BlockAutoMiner.FACING)); BlockPos positionL = positionC.offset(facingL); BlockPos positionR = positionC.offset(facingR); BlockPos positionCU = positionC.up(); BlockPos positionLU = positionL.up(); BlockPos positionRU = positionR.up(); BlockPos positionCUU = positionCU.up(); BlockPos positionLUU = positionLU.up(); BlockPos positionRUU = positionRU.up(); IBlockState stateC = world.getBlockState(positionC); IBlockState stateL = world.getBlockState(positionL); IBlockState stateR = world.getBlockState(positionR); IBlockState stateCU = world.getBlockState(positionCU); IBlockState stateLU = world.getBlockState(positionLU); IBlockState stateRU = world.getBlockState(positionRU); IBlockState stateCUU = world.getBlockState(positionCUU); IBlockState stateLUU = world.getBlockState(positionLUU); IBlockState stateRUU = world.getBlockState(positionRUU); List<ItemStack> stackC = stateC.getBlock().getDrops(world, positionC, stateC, 0); List<ItemStack> stackL = stateL.getBlock().getDrops(world, positionL, stateL, 0); List<ItemStack> stackR = stateR.getBlock().getDrops(world, positionR, stateR, 0); List<ItemStack> stackCU = stateCU.getBlock().getDrops(world, positionCU, stateCU, 0); List<ItemStack> stackLU = stateLU.getBlock().getDrops(world, positionLU, stateLU, 0); List<ItemStack> stackRU = stateRU.getBlock().getDrops(world, positionRU, stateRU, 0); List<ItemStack> stackCUU = stateCUU.getBlock().getDrops(world, positionCUU, stateCUU, 0); List<ItemStack> stackLUU = stateLUU.getBlock().getDrops(world, positionLUU, stateLUU, 0); List<ItemStack> stackRUU = stateRUU.getBlock().getDrops(world, positionRUU, stateRUU, 0); dropItems(stackC, stateC, positionC); dropItems(stackL, stateL, positionL); dropItems(stackR, stateR, positionR); dropItems(stackCU, stateCU, positionCU); dropItems(stackLU, stateLU, positionLU); dropItems(stackRU, stateRU, positionRU); dropItems(stackCUU, stateCUU, positionCUU); dropItems(stackLUU, stateLUU, positionLUU); dropItems(stackRUU, stateRUU, positionRUU); setBlockToAir(stateC, positionC); setBlockToAir(stateL, positionL); setBlockToAir(stateR, positionR); setBlockToAir(stateCU, positionCU); setBlockToAir(stateLU, positionLU); setBlockToAir(stateRU, positionRU); setBlockToAir(stateCUU, positionCUU); setBlockToAir(stateLUU, positionLUU); setBlockToAir(stateRUU, positionRUU); if ((TORCHES >= 2) && (PLACE_TORCH >= 6)) { BlockPos positionLLU = positionLU.offset(facingL); BlockPos positionRRU = positionRU.offset(facingR); if (world.getBlockState(positionLLU).isSideSolid(world, positionLLU, facingR) && (world.getBlockState(positionLU).getMaterial() == Material.AIR)) { if (world.setBlockState(positionLU, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, facingR))) { removeTorches(1); removePlaceTorches(); } } if (world.getBlockState(positionRRU).isSideSolid(world, positionRRU, facingL) && (world.getBlockState(positionRU).getMaterial() == Material.AIR)) { if (world.setBlockState(positionRU, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, facingL))) { removeTorches(1); removePlaceTorches(); } } } else { addPlaceTorch(); } BlockPos positionD = positionC.down(); IBlockState stateD = world.getBlockState(positionD); if (BLOCKS > 0) { if (!stateD.isTopSolid()) { world.setBlockState(positionD, Blocks.COBBLESTONE.getDefaultState()); removeBlock(); } } else { if (!stateD.isTopSolid()) { setActivated(false); removeTicks(); } } if (!world.getBlockState(pos.down()).isTopSolid()) { setActivated(false); removeTicks(); } if (world.getBlockState(positionC).getMaterial().isSolid()) { setActivated(false); removeTicks(); } } } if (TICKS == 40) { if (!world.isRemote) { BlockPos position = pos.offset(world.getBlockState(pos).getValue(BlockAutoMiner.FACING)); BlockPos position1 = pos; world.setBlockState(position, world.getBlockState(pos)); TileEntityAutoMiner te = new TileEntityAutoMiner(); te.ACTIVATED = ACTIVATED; te.FUEL_AMOUNT = FUEL_AMOUNT; te.TICKS = TICKS; te.UPDATE = UPDATE; te.TORCHES = TORCHES; te.PLACE_TORCH = PLACE_TORCH; te.BLOCKS = BLOCKS; te.BEGIN_LINE_POS = BEGIN_LINE_POS; te.DRAW_LINE = DRAW_LINE; te.DRAW_LINE_X = DRAW_LINE_X; te.DRAW_LINE_Y = DRAW_LINE_Y; te.DRAW_LINE_Z = DRAW_LINE_Z; ACTIVATED = false; TICKS = 0; UPDATE = false; TORCHES = 0; PLACE_TORCH = 0; BLOCKS = 0; BEGIN_LINE_POS = new BlockPos(0, 0, 0); DRAW_LINE = false; DRAW_LINE_X = 0; DRAW_LINE_Y = 0; DRAW_LINE_Z = 0; world.setTileEntity(position, te); world.setBlockToAir(position1); } } } else { if (UPDATE) { IBlockState state = world.getBlockState(pos); world.markBlockRangeForRenderUpdate(pos, pos); } UPDATE = false; } if (TICKS >= 40) { removeTicks(); } if (DRAW_LINE) { GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glTranslated(-pos.getX(), -pos.getY(), -pos.getZ()); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); drawLine(new Vec3d(DRAW_LINE_X, DRAW_LINE_Y, DRAW_LINE_Z), new Vec3d(getPos())); GL11.glPopAttrib(); GL11.glPopMatrix(); } } private void drawLine(Vec3d blockA, Vec3d blockB) { Tessellator tess = Tessellator.getInstance(); BufferBuilder buff = tess.getBuffer(); blockB.addVector(0, 1, 0); blockB.addVector(0, -1, 0); blockA.addVector(0, -0.02f, 0); buff.begin(7, buff.getVertexFormat()); buff.color(0F, 1F, 1F, 1F); Vec3d recLong = blockA.subtract(blockB); Vec3d perpendicular = Vec3d.fromPitchYaw(1.0F, 1.0F); perpendicular = perpendicular.normalize(); float Width = 1f / 16f; Vec3d R1 = blockA.subtract(blockB); Vec3d R2 = blockA.subtract(blockB); Vec3d R3 = blockA.subtract(blockB); Vec3d R4 = blockA.subtract(blockB); R1.addVector(blockA.x + perpendicular.x * Width, 0, 0); R1.addVector(0, 0, blockA.z + perpendicular.z * Width); R2.addVector(blockA.x - perpendicular.x * Width, 0, 0); R2.addVector(0, 0, blockA.z - perpendicular.z * Width); R1.addVector(0, blockA.y - 0.01, 0); R2.addVector(0, blockA.y - 0.01, 0); R3.addVector(blockB.x + perpendicular.x * Width, 0, 0); R3.addVector(0, 0, blockB.z + perpendicular.z * Width); R4.addVector(blockB.x - perpendicular.x * Width, 0, 0); R4.addVector(0, 0, blockB.z - perpendicular.z * Width); R3.addVector(0, blockB.y + 0.75, 0); R4.addVector(0, blockB.y + 0.75, 0); int[] a = { (int) (R1.x + 0.5), (int) R1.y, (int) (R1.z + 0.5) }; int[] b = { (int) (R3.x + 0.5), (int) R3.y, (int) (R3.z + 0.5) }; int[] c = { (int) (R4.x + 0.5), (int) R4.y, (int) (R4.z + 0.5) }; int[] d = { (int) (R2.x + 0.5), (int) R2.y, (int) (R2.z + 0.5) }; buff.addVertexData(a); buff.addVertexData(b); buff.addVertexData(c); buff.addVertexData(d); tess.draw(); } private void dropItems(List<ItemStack> stackList, IBlockState state, BlockPos pos) { for (int i = 0; i < stackList.size(); i++) { ItemStack stack = stackList.get(i); if ((stack.getItem() instanceof ItemBlock) && ((Block.getBlockFromItem(stack.getItem()).getBlockHardness(state, world, pos) < 0F) || (Block.getBlockFromItem(stack.getItem()).getBlockHardness(state, world, pos) > 30F))) { continue; } world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), stack)); } } private void setBlockToAir(IBlockState state, BlockPos pos) { if (!(state.getBlockHardness(world, pos) > 30F) && !(state.getBlockHardness(world, pos) < 0F)) { world.setBlockToAir(pos); } } } Also, how can I cancel the player breaking the block in the onBlockClicked() method?
  23. These methods need to be static.
  24. Ah ok, I thought it might have been for a cheat which aren't supported here. Just making sure

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.