@Override
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   if (l > 0
       && Block.blocksList[l].canProvidePower()
       && world.isBlockIndirectlyGettingPowered(i, j, k)
       && world.getBlockMetadata(i, j, k) != 12
       && world.getBlockMetadata(i, j, k) != 0
       && world.getBlockMetadata(i, j, k) != 15) {
     onBlockDestroyedByExplosion(world, i, j, k);
     world.setBlockWithNotify(i, j, k, 0);
   }
 }
  @Override
  public void onBlockAdded(World world, int i, int j, int k) {
    super.onBlockAdded(world, i, j, k);

    if (world.isBlockIndirectlyGettingPowered(i, j, k)
        && world.getBlockMetadata(i, j, k) != 12
        && world.getBlockMetadata(i, j, k) != 0
        && world.getBlockMetadata(i, j, k) != 15) {
      onBlockDestroyedByExplosion(world, i, j, k);
      world.setBlockWithNotify(i, j, k, 0);
    }
  }
  @Override
  public void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer) {
    world.markBlockNeedsUpdate(i, j, k);
    TileEntityMissile titty = (TileEntityMissile) world.getBlockTileEntity(i, j, k);

    if (entityplayer.getCurrentEquippedItem() != null
        && entityplayer.getCurrentEquippedItem().getItem() instanceof ItemRangefinder) {
      titty.targetX = ItemRangefinder.ecks;
      titty.targetZ = ItemRangefinder.zee;
    } else {
      if ((int) Math.floor(entityplayer.posX) > i) {
        titty.targetX -= 5;
      } else if ((int) Math.floor(entityplayer.posX) < i) {
        titty.targetX += 5;
      }

      if ((int) Math.floor(entityplayer.posZ) > k) {
        titty.targetZ -= 5;
      } else if ((int) Math.floor(entityplayer.posZ) < k) {
        titty.targetZ += 5;
      }
    }

    String name;

    if (world.getBlockMetadata(i, j, k) == 12
        || world.getBlockMetadata(i, j, k) == 0
        || world.getBlockMetadata(i, j, k) == 15) {
      name = "Passenger rocket";
    } else if (world.getBlockMetadata(i, j, k) == 8) {
      name = "Nuclear missile";
    } else if (world.getBlockMetadata(i, j, k) == 4) {
      name = "Incendiary missile";
    } else if (world.getBlockMetadata(i, j, k) == 13) {
      name = "Thermonuclear missile";
    } else {
      name = "Missile";
    }

    ModLoader.getMinecraftInstance()
        .ingameGUI
        .addChatMessage(
            name
                + " targeted at ("
                + titty.targetX
                + ", "
                + titty.targetZ
                + ") relative to current position.");
  }
  @Override
  public boolean isIndirectlyPoweringTo(World world, int i, int j, int k, int l) {
    int i1 = world.getBlockMetadata(i, j, k);

    if ((i1 & 8) == 0) {
      return false;
    }

    int j1 = i1 & 7;

    if (j1 == 6 && l == 1) {
      return true;
    }

    if (j1 == 5 && l == 1) {
      return true;
    }

    if (j1 == 4 && l == 2) {
      return true;
    }

    if (j1 == 3 && l == 3) {
      return true;
    }

    if (j1 == 2 && l == 4) {
      return true;
    }

    return j1 == 1 && l == 5;
  }
示例#5
0
  private void tryToFall(World world, int i, int j, int k) {
    int meta = world.getBlockMetadata(i, j, k);
    if (!BlockCollapsable.isNearSupport(world, i, j, k)
        && BlockCollapsable.canFallBelow(world, i, j - 1, k)
        && j >= 0) {
      byte byte0 = 32;
      if (fallInstantly
          || !world.checkChunksExist(
              i - byte0, j - byte0, k - byte0, i + byte0, j + byte0, k + byte0)) {
        world.setBlockWithNotify(i, j, k, 0);
        for (; canFallBelow(world, i, j - 1, k) && j > 0; j--) {}
        if (j > 0) {
          world.setBlockWithNotify(i, j, k, blockID);
        }
      } else if (!world.isRemote) {

        EntityFallingStone2 ent =
            new EntityFallingStone2(
                world, (float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, blockID, meta, 0);
        world.spawnEntityInWorld(ent);
        Random R = new Random(i * j + k);
        world.playSoundAtEntity(ent, "fallingrockshort", 1.0F, 0.8F + (R.nextFloat() / 2));
      }
    }
  }
 public void updateTick(World world, int i, int j, int k, Random random1) {
   int l = world.getBlockMetadata(i, j, k);
   world.setBlockAndMetadata(i, j, k, blockID, l);
   TileEntityChest tileentitychest = (TileEntityChest) world.getBlockTileEntity(i, j, k);
   if (tileentitychest != null) {
     if (chanceToTick == 0) {
       boolean continueChecking = true;
       int slotNumber = 0;
       while (continueChecking == true) {
         if (tileentitychest.getStackInSlot(slotNumber) == null && slotNumber < 27) {
           if (slotNumber == 26) {
             if (world.getClosestPlayer(i, j, k, 32) == null) {
               WeightedRandomChestContent.generateChestContents(
                   random1,
                   ChestHookRegistry.chestCommonContents,
                   tileentitychest,
                   random1.nextInt(5) + 1);
               DayZLog.info("Refilled Common Chest at " + i + ", " + j + ", " + k + ".");
               continueChecking = false;
             } else {
               continueChecking = false;
             }
           } else {
             slotNumber++;
           }
         } else {
           continueChecking = false;
         }
       }
     }
   }
 }
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor blockID
   */
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
    int var6 = par1World.getBlockMetadata(par2, par3, par4);
    boolean var7 = false;

    if (var6 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, 2)) {
      var7 = true;
    }

    if (var6 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, 3)) {
      var7 = true;
    }

    if (var6 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, 4)) {
      var7 = true;
    }

    if (var6 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, 5)) {
      var7 = true;
    }

    if (!var7) {
      this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0);
      par1World.setBlockWithNotify(par2, par3, par4, 0);
    }

    super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
  }
示例#8
0
  @Override
  public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving) {
    if (!(world.getBlockMetadata(x, y, z) == 6)) {
      TileEntityBasicMachine tileEntity =
          (TileEntityBasicMachine) world.getBlockTileEntity(x, y, z);
      int side =
          MathHelper.floor_double((double) (entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
      int change = 3;

      switch (side) {
        case 0:
          change = 2;
          break;
        case 1:
          change = 5;
          break;
        case 2:
          change = 3;
          break;
        case 3:
          change = 4;
          break;
      }

      tileEntity.setFacing((short) change);
    }
  }
示例#9
0
 private void glow(World world, int i, int j, int k) {
   if (world.getBlockMetadata(i, j, k) > 11) sparkle(world, i, j, k);
   /*if (blockID == Block.oreRedstone.blockID)
   {
       world.setBlockWithNotify(i, j, k, Block.oreRedstoneGlowing.blockID);
   }*/
 }
示例#10
0
  public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
    meta = world.getBlockMetadata(i, j, k);
    xCoord = i;
    yCoord = j;
    zCoord = k;
    // Minecraft mc = ModLoader.getMinecraftInstance();
    ItemStack equippedItem = entityplayer.getCurrentEquippedItem();
    int itemid;
    if (equippedItem != null) {
      itemid = entityplayer.getCurrentEquippedItem().itemID;
    } else {
      itemid = 0;
    }

    if (world.isRemote) {
      return true;
    } else {
      if ((TileEntityTerraMetallurgy) world.getBlockTileEntity(i, j, k) != null) {
        TileEntityTerraMetallurgy tileentityanvil;
        tileentityanvil = (TileEntityTerraMetallurgy) world.getBlockTileEntity(i, j, k);
        ItemStack is = entityplayer.getCurrentEquippedItem();

        entityplayer.openGui(mod_TFC.instance, mod_TFC.terraMetallurgyGuiId, world, i, j, k);
        // ModLoader.openGUI(entityplayer, new GuiTerraMetallurgy(entityplayer.inventory,
        // tileentityanvil, world));
      }
      return true;
    }
  }
示例#11
0
  /*
   * 成長速度を管理しているメソッドです。
   * 最初の行の
   * float f = 1.0F; で管理してるので、この数字増やせばグングン
   */
  private float getGrowthRate(World world, int i, int j, int k) {
    float f = 1.0F;
    int l = world.getBlockId(i, j, k - 1);
    int i1 = world.getBlockId(i, j, k + 1);
    int j1 = world.getBlockId(i - 1, j, k);
    int k1 = world.getBlockId(i + 1, j, k);
    int l1 = world.getBlockId(i - 1, j, k - 1);
    int i2 = world.getBlockId(i + 1, j, k - 1);
    int j2 = world.getBlockId(i + 1, j, k + 1);
    int k2 = world.getBlockId(i - 1, j, k + 1);
    boolean flag = j1 == blockID || k1 == blockID;
    boolean flag1 = l == blockID || i1 == blockID;
    boolean flag2 = l1 == blockID || i2 == blockID || j2 == blockID || k2 == blockID;
    for (int l2 = i - 1; l2 <= i + 1; l2++) {
      for (int i3 = k - 1; i3 <= k + 1; i3++) {
        int j3 = world.getBlockId(l2, j - 1, i3);
        float f1 = 0.0F;
        if (j3 == Block.tilledField.blockID) {
          f1 = 1.0F;
          if (world.getBlockMetadata(l2, j - 1, i3) > 0) {
            f1 = 3F;
          }
        }
        if (l2 != i || i3 != k) {
          f1 /= 4F;
        }
        f += f1;
      }
    }

    if (flag2 || flag && flag1) {
      f /= 2.0F;
    }
    return f;
  }
  @Override
  public void updateBlockMetadata(
      World world,
      int i,
      int j,
      int k,
      int l,
      float something1,
      float something2,
      float something3) {
    int i1 = world.getBlockMetadata(i, j, k);
    int j1 = i1 & 8;
    i1 &= 7;
    i1 = -1;

    if (l == 1 && world.isBlockNormalCube(i, j - 1, k)) {
      i1 = 5 + world.rand.nextInt(2);
    }

    if (l == 2 && world.isBlockNormalCube(i, j, k + 1)) {
      i1 = 4;
    }

    if (l == 3 && world.isBlockNormalCube(i, j, k - 1)) {
      i1 = 3;
    }

    if (l == 4 && world.isBlockNormalCube(i + 1, j, k)) {
      i1 = 2;
    }

    if (l == 5 && world.isBlockNormalCube(i - 1, j, k)) {
      i1 = 1;
    }

    if (i1 == -1) {
      dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
      world.setBlockWithNotify(i, j, k, 0);
    } else {
      System.out.println("metadata = " + (i1));
      world.setBlockMetadataWithNotify(i, j, k, i1 + j1);
    }

    super.updateBlockMetadata(world, i, j, k, l, something1, something2, something3);
  }
示例#13
0
  @Override
  public void onNeighborBlockChange(World world, int x, int y, int z, int par4) {

    /* Check that we are still on a solid block */
    if (!world.isBlockSolidOnSide(x, y - 1, z, ForgeDirection.UP)) {
      this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
      world.setBlockWithNotify(x, y, z, 0);
    }
  }
示例#14
0
  /** Called when the block is clicked by a player. Args: x, y, z, entityPlayer */
  @Override
  public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) {
    boolean hasHammer = false;
    for (int i = 0; i < 9; i++) {
      if (entityplayer.inventory.mainInventory[i] != null
          && entityplayer.inventory.mainInventory[i].getItem() instanceof ItemHammer)
        hasHammer = true;
    }
    if (entityplayer.getCurrentEquippedItem() != null
        && entityplayer.getCurrentEquippedItem().getItem() instanceof ItemChisel
        && hasHammer) {
      MovingObjectPosition objectMouseOver = Helper.getMouseOverObject(entityplayer, world);
      if (objectMouseOver == null) {
        return false;
      }
      int side = objectMouseOver.sideHit;

      int id = world.getBlockId(x, y, z);
      byte meta = (byte) world.getBlockMetadata(x, y, z);

      byte newMeta = 0;
      if (side == 0) {
        newMeta = (byte) (newMeta | 4);
      }

      int rot =
          MathHelper.floor_double((double) (entityplayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
      byte flip = (byte) (newMeta & 4);
      byte m = 0;

      if (rot == 0) {
        m = (byte) (2 | flip);
      } else if (rot == 1) {
        m = (byte) (1 | flip);
      } else if (rot == 2) {
        m = (byte) (3 | flip);
      } else if (rot == 3) {
        m = (byte) (0 | flip);
      }

      int mode = 0;
      if (!TFC_Core.isClient()) {
        PlayerInfo pi = PlayerManagerTFC.getInstance().getPlayerInfoFromPlayer(entityplayer);

        if (pi != null) mode = pi.ChiselMode;
      } else mode = ItemChisel.mode;

      if (mode == 1) {
        ItemChisel.CreateStairs(world, x, y, z, id, meta, m);
        return true;
      } else if (mode == 2) {
        ItemChisel.CreateSlab(world, x, y, z, id, meta, side);
        return true;
      }
    }
    return false;
  }
示例#15
0
 @Override
 public void onBlockRemoval(World world, int i, int j, int k) {
   int l = world.getBlockMetadata(i, j, k);
   if (l > 0) {
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
   }
   super.onBlockRemoval(world, i, j, k);
 }
示例#16
0
 @Override
 public void updateTick(World world, int i, int j, int k, Random random) {
   if (world.getBlockMetadata(i, j, k) < 2) {
     if (random.nextInt(5) == 2) {
       world.setBlockWithNotify(i, j, k, 0);
     } else {
       world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
     }
   }
 }
 public void onEntityCollidedWithBlock(
     World par1World, int par2, int par3, int par4, Entity par5Entity) {
   if (par5Entity.posY > yaxis) {
     if (par5Entity instanceof EntityLiving && !par5Entity.isSprinting()) {
       this.dropBlockAsItem(
           par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
       par1World.setBlockWithNotify(par2, par3, par4, 0);
       par1World.playAuxSFX(2002, par2, par3, par4, 0);
     }
   }
 }
示例#18
0
  /**
   * Adds to the supplied array any colliding bounding boxes with the passed in bounding box. Args:
   * world, x, y, z, axisAlignedBB, arrayList
   */
  public void getCollidingBoundingBoxes(
      World var1, int var2, int var3, int var4, AxisAlignedBB var5, ArrayList var6) {
    int var7 = var1.getBlockMetadata(var2, var3, var4);
    float var8 = 0.0F;
    float var9 = 0.0F;
    float var10 = 0.0F;
    float var11 = 1.0F;
    float var12 = 1.0F;
    float var13 = 1.0F;

    if (var7 == 0) {
      var8 = 0.2F;
      var9 = 0.2F;
      var10 = 0.45F;
      var11 = 0.8F;
      var12 = 0.8F;
      var13 = 1.0F;
      this.setBlockBounds(var8, var9, var10, var11, var12, var13);
      super.getCollidingBoundingBoxes(var1, var2, var3, var4, var5, var6);
    }

    if (var7 == 1) {
      var8 = 0.0F;
      var9 = 0.2F;
      var10 = 0.2F;
      var11 = 0.55F;
      var12 = 0.8F;
      var13 = 0.8F;
      this.setBlockBounds(var8, var9, var10, var11, var12, var13);
      super.getCollidingBoundingBoxes(var1, var2, var3, var4, var5, var6);
    }

    if (var7 == 2) {
      var8 = 0.2F;
      var9 = 0.2F;
      var10 = 0.0F;
      var11 = 0.8F;
      var12 = 0.8F;
      var13 = 0.55F;
      this.setBlockBounds(var8, var9, var10, var11, var12, var13);
      super.getCollidingBoundingBoxes(var1, var2, var3, var4, var5, var6);
    }

    if (var7 == 3) {
      var8 = 0.45F;
      var9 = 0.2F;
      var10 = 0.2F;
      var11 = 1.0F;
      var12 = 0.8F;
      var13 = 0.8F;
      this.setBlockBounds(var8, var9, var10, var11, var12, var13);
      super.getCollidingBoundingBoxes(var1, var2, var3, var4, var5, var6);
    }
  }
示例#19
0
 public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
   int metadata = world.getBlockMetadata(i, j, k);
   if (metadata == 2)
     ModLoader.openGUI(
         entityplayer, new GuiVehicleCrafting(entityplayer.inventory, world, i, j, k));
   else
     ModLoader.openGUI(
         entityplayer,
         new GuiPlaneCrafting(entityplayer.inventory, world, i, j, k, metadata == 1));
   return true;
 }
  /**
   * calculateFlowCost(World world, int x, int y, int z, int accumulatedCost, int
   * previousDirectionOfFlow) - Used to determine the path of least resistance, this method returns
   * the lowest possible flow cost for the direction of flow indicated. Each necessary horizontal
   * flow adds to the flow cost.
   */
  private int calculateFlowCost(
      final World par1World,
      final int par2,
      final int par3,
      final int par4,
      final int par5,
      final int par6) {
    int var7 = 1000;

    for (int var8 = 0; var8 < 4; ++var8) {
      if (((var8 != 0) || (par6 != 1))
          && ((var8 != 1) || (par6 != 0))
          && ((var8 != 2) || (par6 != 3))
          && ((var8 != 3) || (par6 != 2))) {
        int var9 = par2;
        int var11 = par4;

        if (var8 == 0) {
          var9 = par2 - 1;
        }

        if (var8 == 1) {
          ++var9;
        }

        if (var8 == 2) {
          var11 = par4 - 1;
        }

        if (var8 == 3) {
          ++var11;
        }

        if (!this.blockBlocksFlow(par1World, var9, par3, var11)
            && ((par1World.getBlockMaterial(var9, par3, var11) != this.blockMaterial)
                || (par1World.getBlockMetadata(var9, par3, var11) != 0))) {
          if (!this.blockBlocksFlow(par1World, var9, par3 - 1, var11)) {
            return par5;
          }

          if (par5 < 4) {
            final int var12 = this.calculateFlowCost(par1World, var9, par3, var11, par5 + 1, var8);

            if (var12 < var7) {
              var7 = var12;
            }
          }
        }
      }
    }

    return var7;
  }
示例#21
0
 /*
  * ここで成長処理判定
  * world.getBlockLightValueが光度判定
  * 9以上なら成長するよという記述 最大15(太陽が一番照っているとき)
  */
 public void updateTick(World world, int i, int j, int k, Random random) {
   super.updateTick(world, i, j, k, random);
   if (world.getBlockLightValue(i, j + 1, k) >= 9) {
     int l = world.getBlockMetadata(i, j, k);
     if (l < 7) {
       float f = getGrowthRate(world, i, j, k);
       if (random.nextInt((int) (25F / f) + 1) == 0) {
         l++;
         world.setBlockMetadataWithNotify(i, j, k, l);
       }
     }
   }
 }
示例#22
0
  public void cacheActiveRenderInfo(
      World par1World,
      RenderEngine par2RenderEngine,
      FontRenderer par3FontRenderer,
      EntityLiving par4EntityLiving,
      GameSettings par5GameSettings,
      float par6) {
    this.worldObj = par1World;
    this.renderEngine = par2RenderEngine;
    this.options = par5GameSettings;
    this.livingPlayer = par4EntityLiving;
    this.fontRenderer = par3FontRenderer;
    if (par4EntityLiving.isPlayerSleeping()) {
      int var7 =
          par1World.getBlockId(
              MathHelper.floor_double(par4EntityLiving.posX),
              MathHelper.floor_double(par4EntityLiving.posY),
              MathHelper.floor_double(par4EntityLiving.posZ));
      if (var7 == Block.bed.blockID) {
        int var8 =
            par1World.getBlockMetadata(
                MathHelper.floor_double(par4EntityLiving.posX),
                MathHelper.floor_double(par4EntityLiving.posY),
                MathHelper.floor_double(par4EntityLiving.posZ));
        int var9 = var8 & 3;
        this.playerViewY = (float) (var9 * 90 + 180);
        this.playerViewX = 0.0F;
      }
    } else {
      this.playerViewY =
          par4EntityLiving.prevRotationYaw
              + (par4EntityLiving.rotationYaw - par4EntityLiving.prevRotationYaw) * par6;
      this.playerViewX =
          par4EntityLiving.prevRotationPitch
              + (par4EntityLiving.rotationPitch - par4EntityLiving.prevRotationPitch) * par6;
    }

    if (par5GameSettings.thirdPersonView == 2) {
      this.playerViewY += 180.0F;
    }

    this.field_1222_l =
        par4EntityLiving.lastTickPosX
            + (par4EntityLiving.posX - par4EntityLiving.lastTickPosX) * (double) par6;
    this.field_1221_m =
        par4EntityLiving.lastTickPosY
            + (par4EntityLiving.posY - par4EntityLiving.lastTickPosY) * (double) par6;
    this.field_1220_n =
        par4EntityLiving.lastTickPosZ
            + (par4EntityLiving.posZ - par4EntityLiving.lastTickPosZ) * (double) par6;
  }
  /**
   * Returns a boolean array indicating which flow directions are optimal based on each direction's
   * calculated flow cost. Each array index corresponds to one of the four cardinal directions. A
   * value of true indicates the direction is optimal.
   */
  private boolean[] getOptimalFlowDirections(
      final World par1World, final int par2, final int par3, final int par4) {
    int var5;
    int var6;

    for (var5 = 0; var5 < 4; ++var5) {
      this.flowCost[var5] = 1000;
      var6 = par2;
      int var8 = par4;

      if (var5 == 0) {
        var6 = par2 - 1;
      }

      if (var5 == 1) {
        ++var6;
      }

      if (var5 == 2) {
        var8 = par4 - 1;
      }

      if (var5 == 3) {
        ++var8;
      }

      if (!this.blockBlocksFlow(par1World, var6, par3, var8)
          && ((par1World.getBlockMaterial(var6, par3, var8) != this.blockMaterial)
              || (par1World.getBlockMetadata(var6, par3, var8) != 0))) {
        if (this.blockBlocksFlow(par1World, var6, par3 - 1, var8)) {
          this.flowCost[var5] = this.calculateFlowCost(par1World, var6, par3, var8, 1, var5);
        } else {
          this.flowCost[var5] = 0;
        }
      }
    }

    var5 = this.flowCost[0];

    for (var6 = 1; var6 < 4; ++var6) {
      if (this.flowCost[var6] < var5) {
        var5 = this.flowCost[var6];
      }
    }

    for (var6 = 0; var6 < 4; ++var6) {
      this.isOptimalFlowDirection[var6] = this.flowCost[var6] == var5;
    }

    return this.isOptimalFlowDirection;
  }
示例#24
0
 public boolean isWater(World world, int i, int j, int k) {
   if (world.getBlockId(i, j, k) == mod_NWater.nwater.blockID) {
     return true;
   }
   if (world.getBlockId(i, j, k) == mod_NWater.nwater_still.blockID) {
     return true;
   }
   if (world.getBlockId(i, j, k) == mod_NWater.nlava.blockID) {
     return true;
   }
   if (world.getBlockId(i, j, k) == mod_NWater.nlava_still.blockID) {
     return true;
   }
   return (world.getBlockId(i, j, k) == mod_NWater.grate.blockID)
       & (world.getBlockMetadata(i, j, k) != 10);
 }
  @Override
  public boolean onBlockActivated(
      World world,
      int i,
      int j,
      int k,
      EntityPlayer entityplayer,
      int something1,
      float something2,
      float something3,
      float something4) {
    if (world.isRemote) {
      return true;
    }

    TileEntityCamoFull entity = (TileEntityCamoFull) world.getBlockTileEntity(i, j, k);
    System.out.println("ACTIVATED: " + entity.getCopyID());

    int l = world.getBlockMetadata(i, j, k);
    int i1 = l & 7;
    int j1 = 8 - (l & 8);
    world.setBlockMetadataWithNotify(i, j, k, i1 + j1);
    world.markBlocksDirty(i, j, k, i, j, k);
    world.playSoundEffect(
        (double) i + 0.5D,
        (double) j + 0.5D,
        (double) k + 0.5D,
        "random.click",
        0.3F,
        j1 <= 0 ? 0.5F : 0.6F);
    world.notifyBlocksOfNeighborChange(i, j, k, blockID);
    world.markBlockNeedsUpdate(i, j, k);

    if (i1 == 1) {
      world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
    } else if (i1 == 2) {
      world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
    } else if (i1 == 3) {
      world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
    } else if (i1 == 4) {
      world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
    } else {
      world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
    }

    return true;
  }
  /**
   * flowIntoBlock(World world, int x, int y, int z, int newFlowDecay) - Flows into the block at the
   * coordinates and changes the block type to the liquid.
   */
  private void flowIntoBlock(
      final World par1World, final int par2, final int par3, final int par4, final int par5) {
    if (this.liquidCanDisplaceBlock(par1World, par2, par3, par4)) {
      final int var6 = par1World.getBlockId(par2, par3, par4);

      if (var6 > 0) {
        if (this.blockMaterial == Material.lava) {
          this.triggerLavaMixEffects(par1World, par2, par3, par4);
        } else {
          Block.blocksList[var6].dropBlockAsItem(
              par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
        }
      }

      par1World.setBlockAndMetadataWithNotify(par2, par3, par4, this.blockID, par5);
    }
  }
示例#27
0
  /**
   * Called when a block is placed using an item. Used often for taking the facing and figuring out
   * how to position the item. Args: x, y, z, facing
   */
  public void onBlockPlaced(World par1World, int par2, int par3, int par4, int par5) {
    int var6 = par1World.getBlockMetadata(par2, par3, par4);

    if ((var6 == 0 || par5 == 2) && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, 2)) {
      var6 = 2;
    }

    if ((var6 == 0 || par5 == 3) && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, 3)) {
      var6 = 3;
    }

    if ((var6 == 0 || par5 == 4) && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, 4)) {
      var6 = 4;
    }

    if ((var6 == 0 || par5 == 5) && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, 5)) {
      var6 = 5;
    }

    par1World.setBlockMetadataWithNotify(par2, par3, par4, var6);
  }
示例#28
0
  private int getBlockColor(World world, int x, int y, int z) {
    int color24 = 0;

    try {
      if (MinimapConfig.getInstance().isColor() && !MinimapConfig.getInstance().isCavemap()) {
        if (x == (int) map.getPlayerX() && z == (int) map.getPlayerZ()) return 0xff0000;
        if ((world.getBlockMaterial(x, y + 1, z) == Material.ice)
            || (world.getBlockMaterial(x, y + 1, z) == Material.snow)) {
          color24 = 0xffffff;
        } else {
          BlockColor col =
              BlockColor.getBlockColor(world.getBlockId(x, y, z), world.getBlockMetadata(x, y, z));
          color24 = col.color;
        }
      }
    } catch (Exception e) {
      return 0;
    }

    return color24;
  }
  @Override
  public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
    int arg = world.getBlockMetadata(i, j, k);

    if (entityplayer != null
        && entityplayer.getCurrentEquippedItem() != null
        && (entityplayer.getCurrentEquippedItem().itemID == Ic2Items.wrench.itemID
            || entityplayer.getCurrentEquippedItem().itemID == Ic2Items.electricWrench.itemID)) {
      this.dropBlockAsItem(world, i, j, k, arg, 1);
      world.setBlockWithNotify(i, j, k, 0);
      world.setBlockWithNotify(i, j + 1, k, 0);
      return false;
    }

    if (arg == 12 || arg == 15 || arg == 0) {
      TileEntityMissile titty = (TileEntityMissile) world.getBlockTileEntity(i, j, k);
      titty.launch(entityplayer);
    }

    return false;
  }
示例#30
0
  /** Returns the bounding box of the wired rectangular prism to render. */
  public AxisAlignedBB getSelectedBoundingBoxFromPool(
      World par1World, int par2, int par3, int par4) {
    int var5 = par1World.getBlockMetadata(par2, par3, par4);
    float var6 = 0.125F;

    if (var5 == 2) {
      this.setBlockBounds(0.0F, 0.0F, 1.0F - var6, 1.0F, 1.0F, 1.0F);
    }

    if (var5 == 3) {
      this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, var6);
    }

    if (var5 == 4) {
      this.setBlockBounds(1.0F - var6, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

    if (var5 == 5) {
      this.setBlockBounds(0.0F, 0.0F, 0.0F, var6, 1.0F, 1.0F);
    }

    return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4);
  }