Exemple #1
0
  @Override
  public int inGameLoop(Minecraft mc) {

    EntityPlayer player = mc.thePlayer;

    if (player.getDistance(startX, startY, startZ) >= 100) returnHome = true;

    if (returnHome && player.getDistance(startX, startY, startZ) <= 1) McBot.stopBot();

    if (returnHome) {

      McBot.walkTo(startX + .5, startY, startZ + .5, true);

      return 0;
    }

    MovingObjectPosition mop = player.rayTrace(1, 1);

    if (mc.theWorld != null) {

      if (mop != null && mc.theWorld.getBlockId(mop.blockX, mop.blockY, mop.blockZ) != 0) {

        McBot.mineBlock(mop.blockX, mop.blockY, mop.blockZ, false);

        if (!McBot.isBlockDangerous(mop.blockX, mop.blockY, mop.blockZ)
            && !McBot.isBlockDangerous(mop.blockX, mop.blockY - 1, mop.blockZ)
            && !McBot.isBlockDangerous(mop.blockX, mop.blockY - 2, mop.blockZ)) ;
        McBot.walkTo(mop.blockX + .5, mop.blockY + .5, mop.blockZ + .5, false);

      } else {

        if (Camera.getPitch() == 45) Camera.setPitch(0);
        else Camera.setPitch(45);

        mop = player.rayTrace(10, 1);

        if (mop != null
            && !McBot.isBlockDangerous(mop.blockX, mop.blockY, mop.blockZ)
            && !McBot.isBlockDangerous(mop.blockX, mop.blockY - 1, mop.blockZ)
            && !McBot.isBlockDangerous(mop.blockX, mop.blockY - 2, mop.blockZ))
          McBot.walkTo(mop.blockX + .5, mop.blockY + .5, mop.blockZ + .5, false);
      }
    }

    return 1;
  }
  public void renderParticle(
      Tessellator tessellator,
      float partialframe,
      float cosyaw,
      float cospitch,
      float sinyaw,
      float sinsinpitch,
      float cossinpitch) {
    EntityPlayer renderentity = ModLoader.getMinecraftInstance().thePlayer;
    int visibleDistance = 100;
    if (!ModLoader.getMinecraftInstance().gameSettings.fancyGraphics) visibleDistance = 50;
    if (renderentity.getDistance(this.posX, this.posY, this.posZ) > visibleDistance) return;

    boolean wasDrawing = tessellator.isDrawing;
    if (wasDrawing) tessellator.draw();
    GL11.glPushMatrix();

    Minecraft.getMinecraft()
        .renderEngine
        .bindTexture(ModInfo.RESOURCES_BASE + "/misc/bolt_small.png");

    GL11.glDepthMask(false);
    GL11.glEnable(3042);

    this.particleRed = (this.particleGreen = this.particleBlue = 1.0F);

    int brightness = 983280;

    switch (this.type) {
      case 0:
        this.particleRed = 0.1F;
        this.particleGreen = 0.1F;
        this.particleBlue = 0.6F;
        GL11.glBlendFunc(770, 1);
        break;
      case 1:
        this.particleRed = 0.6F;
        this.particleGreen = 0.6F;
        this.particleBlue = 0.1F;
        GL11.glBlendFunc(770, 1);
        break;
      case 2:
        this.particleRed = 0.6F;
        this.particleGreen = 0.1F;
        this.particleBlue = 0.6F;
        GL11.glBlendFunc(770, 1);
        break;
      case 3:
        this.particleRed = 0.1F;
        this.particleGreen = 1.0F;
        this.particleBlue = 0.1F;
        GL11.glBlendFunc(770, 1);
        break;
      case 4:
        this.particleRed = 0.6F;
        this.particleGreen = 0.1F;
        this.particleBlue = 0.1F;
        GL11.glBlendFunc(770, 1);
        break;
      case 5:
        this.particleRed = 0.6F;
        this.particleGreen = 0.3F;
        this.particleBlue = 0.6F;
        GL11.glBlendFunc(770, 771);
        break;
      case 6:
        this.particleRed = 0.1F;
        this.particleGreen = 0.1F;
        this.particleBlue = 0.1F;
        GL11.glBlendFunc(770, 1);
        brightness = 983040;
      case 7:
        this.particleRed = (this.particleGreen = this.particleBlue = 1.0F);
        GL11.glBlendFunc(770, 1);
    }

    tessellator.startDrawingQuads();
    tessellator.setBrightness(brightness);
    renderBolt(tessellator, partialframe, cosyaw, cospitch, sinyaw, cossinpitch, 0);
    tessellator.draw();

    brightness = 983280;

    switch (this.type) {
      case 0:
        this.particleRed = 1.0F;
        this.particleGreen = 0.6F;
        this.particleBlue = 1.0F;
        break;
      case 1:
        this.particleRed = 0.1F;
        this.particleGreen = 0.1F;
        this.particleBlue = 1.0F;
        break;
      case 2:
        this.particleRed = 0.0F;
        this.particleGreen = 0.0F;
        this.particleBlue = 0.0F;
        break;
      case 3:
        this.particleRed = 0.1F;
        this.particleGreen = 0.6F;
        this.particleBlue = 0.1F;
        break;
      case 4:
        this.particleRed = 1.0F;
        this.particleGreen = 0.1F;
        this.particleBlue = 0.1F;
        break;
      case 5:
        this.particleRed = 1.0F;
        this.particleGreen = 1.0F;
        this.particleBlue = 0.1F;
        GL11.glBlendFunc(770, 771);
        break;
      case 6:
        this.particleRed = 0.6F;
        this.particleGreen = 0.1F;
        this.particleBlue = 0.6F;
        GL11.glBlendFunc(770, 1);
        brightness = 983136;
    }

    tessellator.startDrawingQuads();
    tessellator.setBrightness(brightness);
    renderBolt(tessellator, partialframe, cosyaw, cospitch, sinyaw, cossinpitch, 1);
    tessellator.draw();

    brightness = 983280;

    switch (this.type) {
      case 0:
        this.particleRed = 1.0F;
        this.particleGreen = 0.6F;
        this.particleBlue = 1.0F;
        break;
      case 1:
        this.particleRed = 0.1F;
        this.particleGreen = 0.1F;
        this.particleBlue = 1.0F;
        break;
      case 2:
        this.particleRed = 0.0F;
        this.particleGreen = 0.0F;
        this.particleBlue = 0.0F;
        break;
      case 3:
        this.particleRed = 0.1F;
        this.particleGreen = 0.6F;
        this.particleBlue = 0.1F;
        break;
      case 4:
        this.particleRed = 1.0F;
        this.particleGreen = 0.1F;
        this.particleBlue = 0.1F;
        break;
      case 5:
        this.particleRed = 1.0F;
        this.particleGreen = 1.0F;
        this.particleBlue = 0.1F;
        GL11.glBlendFunc(770, 771);
        break;
      case 6:
        this.particleRed = 0.6F;
        this.particleGreen = 0.1F;
        this.particleBlue = 0.6F;
        GL11.glBlendFunc(770, 1);
        brightness = 983136;
    }

    tessellator.startDrawingQuads();
    tessellator.setBrightness(brightness);
    renderBolt(tessellator, partialframe, cosyaw, cospitch, sinyaw, cossinpitch, 2);
    tessellator.draw();

    GL11.glDisable(3042);
    GL11.glDepthMask(true);
    GL11.glPopMatrix();

    if (wasDrawing) tessellator.startDrawingQuads();
  }
 /** Do not make give this method the name canInteractWith because it clashes with Container */
 public boolean isUseableByPlayer(EntityPlayer entityplayer) {
   return entityplayer.getDistance(
           (double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D)
       <= 64.0D;
 }
 @Override
 public boolean isUseableByPlayer(EntityPlayer entityplayer) {
   return entityplayer.getDistance(xCoord, yCoord, zCoord) < 8;
 }