示例#1
0
  public boolean generateNode(World world, Random random, int i, int j, int k) {
    setBlockAndMetadata(world, i, j, k, FloraTrees.redwood.blockID, mdWood);
    for (int l = i - 1; l <= i + 1; l++) {
      for (int k1 = k - 1; k1 <= k + 1; k1++) {
        for (int j2 = j - 1; j2 <= j + 1; j2++) {
          int i3 = world.getBlockId(l, j2, k1);
          if (i3 != FloraTrees.floraLeaves.blockID && !Block.opaqueCubeLookup[i3]) {
            setBlockAndMetadata(world, l, j2, k1, FloraTrees.floraLeaves.blockID, mdLeaves);
          }
        }
      }
    }

    for (int i1 = i - 1; i1 <= i + 1; i1++) {
      for (int l1 = k - 2; l1 <= k + 2; l1++) {
        int k2 = world.getBlockId(i1, j, l1);
        if (k2 != FloraTrees.floraLeaves.blockID && !Block.opaqueCubeLookup[k2]) {
          setBlockAndMetadata(world, i1, j, l1, FloraTrees.floraLeaves.blockID, mdLeaves);
        }
      }
    }

    for (int j1 = i - 2; j1 <= i + 2; j1++) {
      for (int i2 = k - 1; i2 <= k + 1; i2++) {
        int l2 = world.getBlockId(j1, j + 1, i2);
        if (l2 != FloraTrees.floraLeaves.blockID && !Block.opaqueCubeLookup[l2]) {
          setBlockAndMetadata(world, j1, j, i2, FloraTrees.floraLeaves.blockID, mdLeaves);
        }
      }
    }

    return true;
  }
  /**
   * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
   */
  public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
    int var5 = 0;

    if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID) {
      ++var5;
    }

    if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID) {
      ++var5;
    }

    if (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID) {
      ++var5;
    }

    if (par1World.getBlockId(par2, par3, par4 + 1) == this.blockID) {
      ++var5;
    }

    return var5 > 1
        ? false
        : (this.isThereANeighborChest(par1World, par2 - 1, par3, par4)
            ? false
            : (this.isThereANeighborChest(par1World, par2 + 1, par3, par4)
                ? false
                : (this.isThereANeighborChest(par1World, par2, par3, par4 - 1)
                    ? false
                    : !this.isThereANeighborChest(par1World, par2, par3, par4 + 1))));
  }
示例#3
0
 public void updateTick(World world, int i, int j, int k, Random random) {
   if (world.isRemote) {
     return;
   }
   if (world.getBlockLightValue(i, j + 1, k) < 4
       && Block.lightOpacity[world.getBlockId(i, j + 1, k)] > 2) {
     world.setBlockWithNotify(i, j, k, Block.dirt.blockID);
   } else if (world.getBlockLightValue(i, j + 1, k) >= 9) {
     for (int l = 0; l < 4; l++) {
       int i1 = (i + random.nextInt(3)) - 1;
       int j1 = (j + random.nextInt(5)) - 3;
       int k1 = (k + random.nextInt(3)) - 1;
       int l1 = world.getBlockId(i1, j1 + 1, k1);
       if (world.getBlockId(i1, j1, k1) == Block.dirt.blockID
           && world.getBlockLightValue(i1, j1 + 1, k1) >= 4
           && Block.lightOpacity[l1] <= 2) {
         if (blockID == ZooDirts.savannah.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.savannah.blockID);
         }
         if (blockID == ZooDirts.tropical.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.tropical.blockID);
         }
         if (blockID == ZooDirts.coniferous.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.coniferous.blockID);
         }
         if (blockID == ZooDirts.deciduous.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.deciduous.blockID);
         }
       }
     }
   }
 }
 /** Checks the neighbor blocks to see if there is a chest there. Args: world, x, y, z */
 private boolean isThereANeighborChest(World par1World, int par2, int par3, int par4) {
   return par1World.getBlockId(par2, par3, par4) != this.blockID
       ? false
       : (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID
           ? true
           : (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID
               ? true
               : (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID
                   ? true
                   : par1World.getBlockId(par2, par3, par4 + 1) == this.blockID)));
 }
  /** Called when the block is placed in the world. */
  public void onBlockPlacedBy(
      World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) {
    int var6 = par1World.getBlockId(par2, par3, par4 - 1);
    int var7 = par1World.getBlockId(par2, par3, par4 + 1);
    int var8 = par1World.getBlockId(par2 - 1, par3, par4);
    int var9 = par1World.getBlockId(par2 + 1, par3, par4);
    byte var10 = 0;
    int var11 =
        MathHelper.floor_double((double) (par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

    if (var11 == 0) {
      var10 = 2;
    }

    if (var11 == 1) {
      var10 = 5;
    }

    if (var11 == 2) {
      var10 = 3;
    }

    if (var11 == 3) {
      var10 = 4;
    }

    if (var6 != this.blockID
        && var7 != this.blockID
        && var8 != this.blockID
        && var9 != this.blockID) {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
    } else {
      if ((var6 == this.blockID || var7 == this.blockID) && (var10 == 4 || var10 == 5)) {
        if (var6 == this.blockID) {
          par1World.setBlockMetadataWithNotify(par2, par3, par4 - 1, var10);
        } else {
          par1World.setBlockMetadataWithNotify(par2, par3, par4 + 1, var10);
        }

        par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
      }

      if ((var8 == this.blockID || var9 == this.blockID) && (var10 == 2 || var10 == 3)) {
        if (var8 == this.blockID) {
          par1World.setBlockMetadataWithNotify(par2 - 1, par3, par4, var10);
        } else {
          par1World.setBlockMetadataWithNotify(par2 + 1, par3, par4, var10);
        }

        par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
      }
    }
  }
  public ItemStack fillCustomBucket(World w, int i, int j, int k) {
    if (w.getBlockId(i, j, k) == Zoo.saltwaterStill.blockID
        || w.getBlockId(i, j, k) == Zoo.saltwaterMoving.blockID) {
      w.setBlockWithNotify(i, j, k, 0);

      EntityPlayer player = ModLoader.getMinecraftInstance().thePlayer;
      if (!player.capabilities.isCreativeMode) {
        return new ItemStack(this);
      }
    }

    return null;
  }
  @Override
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    for (int i = 0;
        ((i = par1World.getBlockId(par3, par4, par5)) == 0 || i == Block.leaves.blockID)
            && par4 > 0;
        par4--) {}

    for (int j = 0; j < 128; j++) {
      int k = (par3 + par2Random.nextInt(8)) - par2Random.nextInt(8);
      int l = (par4 + par2Random.nextInt(4)) - par2Random.nextInt(4);
      int i1 = (par5 + par2Random.nextInt(8)) - par2Random.nextInt(8);

      boolean old =
          ODNBXlite.MapFeatures < ODNBXlite.FEATURES_13
              || ODNBXlite.Generator < ODNBXlite.GEN_NEWBIOMES;
      boolean oldc =
          ((BlockFlower) Block.blocksList[tallGrassID]).canBlockStay(par1World, k, l, i1);
      boolean newc = Block.blocksList[tallGrassID].canBlockStay(par1World, k, l, i1);
      if (par1World.isAirBlock(k, l, i1) && ((oldc && old) || (!old && newc))) {
        par1World.setBlock(k, l, i1, tallGrassID, tallGrassMetadata, 0);
      }
    }

    return true;
  }
  @Override
  public void decorate(World par1World, Random par2Random, int par3, int par4) {
    super.decorate(par1World, par2Random, par3, par4);
    int var5 = 3 + par2Random.nextInt(6);

    for (int var6 = 0; var6 < var5; ++var6) {
      int var7 = par3 + par2Random.nextInt(16);
      int var8 = par2Random.nextInt(28) + 4;
      int var9 = par4 + par2Random.nextInt(16);
      int var10 = par1World.getBlockId(var7, var8, var9);

      if (var10 == Block.stone.blockID) {
        int var11 = 0;

        if (var8 <= 48 + par1World.rand.nextInt(2)) {
          byte var12 = 1;

          if (var8 <= 24 + par1World.rand.nextInt(2)) {
            var12 = 2;
          }

          var11 = Block.oreEmerald.GetMetadataConversionForStrataLevel(var12, 0);
        }

        par1World.setBlock(var7, var8, var9, Block.oreEmerald.blockID, var11, 2);
      }
    }
  }
  @Override
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    if (par1World.getBlockMaterial(par3, par4, par5) != Material.water) return false;
    else {
      int var6 = par2Random.nextInt(radius - 2) + 2;
      byte var7 = 2;

      for (int var8 = par3 - var6; var8 <= par3 + var6; ++var8) {
        for (int var9 = par5 - var6; var9 <= par5 + var6; ++var9) {
          int var10 = var8 - par3;
          int var11 = var9 - par5;

          if (var10 * var10 + var11 * var11 <= var6 * var6) {
            for (int var12 = par4 - var7; var12 <= par4 + var7; ++var12) {
              int var13 = par1World.getBlockId(var8, var12, var9);

              if (var13 == Block.sand.blockID) {
                par1World.setBlock(var8, var12, var9, sandID);
              }
            }
          }
        }
      }

      return true;
    }
  }
示例#10
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);
 }
 public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
   int v1 = par1World.getBlockId(par2, par3 - 1, par4);
   int v2 = par1World.getBlockId(par2, par3 + 1, par4);
   if (v1 != mod_ExtendedGlasses.GlassTrapID && v2 != mod_ExtendedGlasses.GlassTrapID) {
     return true;
   }
   return false;
 }
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  @Override
  public void onBlockAdded(final World par1World, final int par2, final int par3, final int par4) {
    super.onBlockAdded(par1World, par2, par3, par4);

    if (par1World.getBlockId(par2, par3, par4) == this.blockID) {
      par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
    }
  }
示例#13
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;
  }
  @Override
  public boolean canPlaceBlockAt(World world, int i, int j, int k) {
    if (!super.canPlaceBlockAt(world, i, j, k)) {
      return false;
    }

    int l = world.getBlockId(i, j + 1, k);
    return l == 0;
  }
示例#15
0
 @Override
 public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) {
   if (world.multiplayerWorld) {
     return null;
   }
   if (world.getBlockId(i, j + 1, k) != 0) {
     setBlockBounds(-0.01F, 0.01F, 0.01F, 1.01F, 1.01F, 1.01F);
   }
   return null;
 }
  protected void placeTreasureAtCurrentPosition(
      World var1, Random var2, int var3, int var4, int var5, StructureBoundingBox var7) {
    int var8 = this.getXWithOffset(var3, var5);
    int var9 = this.getYWithOffset(var4);
    int var10 = this.getZWithOffset(var3, var5);

    if (var7.isVecInside(var8, var9, var10)
        && var1.getBlockId(var8, var9, var10) != Block.chest.blockID) {
      GCUtil.generateChestContents(var1, var2, var8, var9, var10);
    }
  }
示例#17
0
  @Override
  public void decorate(World par1World, Random par2Random, int par3, int par4) {
    super.decorate(par1World, par2Random, par3, par4);
    int var5 = 12 + par2Random.nextInt(6);

    for (int var6 = 0; var6 < var5; ++var6) {
      int var7 = par3 + par2Random.nextInt(16);
      int var8 = par2Random.nextInt(28) + 4;
      int var9 = par4 + par2Random.nextInt(16);
      int var10 = par1World.getBlockId(var7, var8, var9);
    }
  }
示例#18
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;
  }
示例#19
0
 int findGround(World world, int i, int j, int k) {
   int l = 0;
   int i1 = world.getBlockId(i, j - 1, k);
   if (!Block.opaqueCubeLookup[world.getBlockId(i, j, k)]
       && (i1 == Block.netherrack.blockID || i1 == Block.slowSand.blockID)) {
     return j;
   }
   int k1 = 96;
   do {
     if (k1 < 32) {
       break;
     }
     int j1 = world.getBlockId(i, k1, k);
     if ((j1 == Block.netherrack.blockID || j1 == Block.slowSand.blockID)
         && !Block.opaqueCubeLookup[world.getBlockId(i, k1 + 1, k)]) {
       l = k1 + 1;
       break;
     }
     k1--;
   } while (true);
   return l;
 }
示例#20
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;
  }
示例#21
0
 public static boolean canFallBelow(World world, int i, int j, int k) {
   int l = world.getBlockId(i, j, k);
   if (l == 0) {
     return true;
   }
   if (l == Block.fire.blockID) {
     return true;
   }
   Material material = Block.blocksList[l].blockMaterial;
   if (material == Material.water) {
     return true;
   }
   return material == Material.lava;
 }
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    super.onBlockAdded(par1World, par2, par3, par4);
    this.unifyAdjacentChests(par1World, par2, par3, par4);
    int var5 = par1World.getBlockId(par2, par3, par4 - 1);
    int var6 = par1World.getBlockId(par2, par3, par4 + 1);
    int var7 = par1World.getBlockId(par2 - 1, par3, par4);
    int var8 = par1World.getBlockId(par2 + 1, par3, par4);

    if (var5 == this.blockID) {
      this.unifyAdjacentChests(par1World, par2, par3, par4 - 1);
    }

    if (var6 == this.blockID) {
      this.unifyAdjacentChests(par1World, par2, par3, par4 + 1);
    }

    if (var7 == this.blockID) {
      this.unifyAdjacentChests(par1World, par2 - 1, par3, par4);
    }

    if (var8 == this.blockID) {
      this.unifyAdjacentChests(par1World, par2 + 1, par3, par4);
    }
  }
  /**
   * 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);
    }
  }
示例#24
0
  @Override
  public boolean generate(World var1, Random var2, int var3, int var4, int var5) {
    while (var1.isAirBlock(var3, var4, var5) && var4 > 2) {
      --var4;
    }

    int var6 = var1.getBlockId(var3, var4, var5);

    if (var6 != Block.grass.blockID) return false;
    else {
      for (int var7 = -2; var7 <= 2; ++var7) {
        for (int var8 = -2; var8 <= 2; ++var8) {
          if (var1.isAirBlock(var3 + var7, var4 - 1, var5 + var8)
              && var1.isAirBlock(var3 + var7, var4 - 2, var5 + var8)) return false;
        }
      }

      var1.setBlock(var3, var4, var5, Block.dirt.blockID);
      var1.setBlock(var3, var4 + 1, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 2, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 3, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 4, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 5, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 6, var5, Block.wood.blockID);
      var1.setBlock(var3, var4 + 7, var5, Block.wood.blockID);
      var1.setBlock(var3 + 1, var4 + 7, var5, Block.leaves.blockID);
      var1.setBlock(var3 - 1, var4 + 7, var5, Block.leaves.blockID);
      var1.setBlock(var3, var4 + 7, var5 + 1, Block.leaves.blockID);
      var1.setBlock(var3, var4 + 7, var5 - 1, Block.leaves.blockID);

      var1.setBlock(var3 + 1, var4 + 8, var5, Block.leaves.blockID);
      var1.setBlock(var3 - 1, var4 + 8, var5, Block.leaves.blockID);
      var1.setBlock(var3, var4 + 8, var5 + 1, Block.leaves.blockID);
      var1.setBlock(var3, var4 + 8, var5 - 1, Block.leaves.blockID);

      var1.setBlock(var3 + 1, var4 + 8, var5 + 1, Block.leaves.blockID);
      var1.setBlock(var3 + 1, var4 + 8, var5 - 1, Block.leaves.blockID);
      var1.setBlock(var3 - 1, var4 + 8, var5 + 1, Block.leaves.blockID);
      var1.setBlock(var3 - 1, var4 + 8, var5 - 1, Block.leaves.blockID);
      var1.setBlock(var3, var4 + 8, var5, Block.leaves.blockID);

      var1.setBlock(var3, var4 + 9, var5, Block.leaves.blockID);
      return true;
    }
  }
示例#25
0
  @Override
  public boolean tryPlaceIntoWorld(
      ItemStack itemstack,
      EntityPlayer entityplayer,
      World world,
      int i,
      int j,
      int k,
      int l,
      float par8,
      float par9,
      float par10) {
    int blockID = BuildCraftTransport.genericPipeBlock.blockID;

    if (world.getBlockId(i, j, k) == Block.snow.blockID) l = 0;
    else {
      if (l == 0) j--;
      if (l == 1) j++;
      if (l == 2) k--;
      if (l == 3) k++;
      if (l == 4) i--;
      if (l == 5) i++;
    }

    if (itemstack.stackSize == 0) return false;
    if (entityplayer.canPlayerEdit(i, j, k)) {
      //		if (world.canBlockBePlacedAt(blockID, i, j, k, false, l)) {

      Pipe pipe = BlockGenericPipe.createPipe(shiftedIndex);
      if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) {

        // Block.blocksList[blockID].onBlockPlaced(world, i, j, k, l);
        Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer);
        // To move to a proxt
        // world.playSoundEffect((float)i + 0.5F, (float)j + 0.5F,
        // (float)k + 0.5F, block.stepSound.func_1145_d(),
        // (block.stepSound.getVolume() + 1.0F) / 2.0F,
        // block.stepSound.getPitch() * 0.8F);
        itemstack.stackSize--;
      }
      return true;
    } else return false;
  }
  /** Returns true if block at coords blocks fluids */
  private boolean blockBlocksFlow(
      final World par1World, final int par2, final int par3, final int par4) {
    final int var5 = par1World.getBlockId(par2, par3, par4);

    if ((var5 != Block.doorWood.blockID)
        && (var5 != Block.doorSteel.blockID)
        && (var5 != Block.signPost.blockID)
        && (var5 != Block.ladder.blockID)
        && (var5 != Block.reed.blockID)) {
      if (var5 == 0) {
        return false;
      } else {
        final Material var6 = Block.blocksList[var5].blockMaterial;
        return var6 == Material.portal ? true : var6.blocksMovement();
      }
    } else {
      return true;
    }
  }
  @Override
  protected void setWoodBlock(World world, int x, int y, int z) {
    final int id = world.getBlockId(x, y, z);

    if (Block.blocksList[id] == null
        || id == Block.snow.blockID
        || Block.blocksList[id].isLeaves(world, x, y, z)) {
      setBlockAndMetadata(world, x, y, z, blockWood, metaWood);
      setMetadata(world, x, y, z, WideLog.metadataWithDirection(metaWood, Direction.SOUTH));

      setBlockAndMetadata(world, x - 1, y, z, blockWood, metaWood);
      setMetadata(world, x - 1, y, z, WideLog.metadataWithDirection(metaWood, Direction.WEST));

      setBlockAndMetadata(world, x, y, z - 1, blockWood, metaWood);
      setMetadata(world, x, y, z - 1, WideLog.metadataWithDirection(metaWood, Direction.NORTH));

      setBlockAndMetadata(world, x - 1, y, z - 1, blockWood, metaWood);
      setMetadata(world, x - 1, y, z - 1, WideLog.metadataWithDirection(metaWood, Direction.EAST));
    }
  }
示例#28
0
 @Override
 public boolean onItemUseFirst(
     ItemStack stack, EntityPlayer player, World world, int X, int Y, int Z, int side) {
   TileEntity te = world.getBlockTileEntity(X, Y, Z);
   if (te != null && te instanceof TileEntityIronChest) {
     TileEntityIronChest ironchest = (TileEntityIronChest) te;
     TileEntityIronChest newchest = ironchest.applyUpgradeItem(this);
     if (newchest == null) {
       return false;
     }
     world.setBlockTileEntity(X, Y, Z, newchest);
     world.setBlockMetadataWithNotify(X, Y, Z, newchest.getType().ordinal());
     world.notifyBlocksOfNeighborChange(X, Y, Z, world.getBlockId(X, Y, Z));
     world.markBlockNeedsUpdate(X, Y, Z);
     stack.stackSize = 0;
     return true;
   } else {
     return false;
   }
 }
示例#29
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;
  }
  protected void placeSpawnerAtCurrentPosition(
      World var1,
      Random var2,
      int var3,
      int var4,
      int var5,
      String var6,
      StructureBoundingBox var7) {
    int var8 = this.getXWithOffset(var3, var5);
    int var9 = this.getYWithOffset(var4);
    int var10 = this.getZWithOffset(var3, var5);

    if (var7.isVecInside(var8, var9, var10)
        && var1.getBlockId(var8, var9, var10) != Block.mobSpawner.blockID) {
      var1.setBlockWithNotify(var8, var9, var10, Block.mobSpawner.blockID);
      TileEntityMobSpawner var11 =
          (TileEntityMobSpawner) var1.getBlockTileEntity(var8, var9, var10);

      if (var11 != null) {
        var11.setMobID(var6);
      }
    }
  }