private static boolean func_150119_a(Block p_150119_0_) {
   if (disableValidation) return true;
   return p_150119_0_.getMaterial().isOpaque() && p_150119_0_.renderAsNormalBlock()
       || p_150119_0_ == Blocks.glowstone
       || p_150119_0_ instanceof BlockSlab
       || p_150119_0_ instanceof BlockStairs;
 }
 public ItemStack getPickBlock() {
   Block block = getBlock();
   if (block != null) {
     return block.getPickBlock(toMovingObjectPosition(), world, x, y, z);
   }
   return null;
 }
 @Override
 public void explosion(int power, boolean flag) {
   int radius = getPowered() ? (int) (ECVars.darkCreeperRadius * power) : ECVars.darkCreeperRadius;
   for (int x = -radius; x <= radius; x++)
     for (int y = -radius; y <= radius; y++)
       for (int z = -radius; z <= radius; z++) {
         Block id = worldObj.getBlock((int) posX + x, (int) posY + y, (int) posZ + z);
         if (id != null && id.getLightValue() > 0.5F) {
           id.dropBlockAsItem(
               worldObj,
               (int) posX + x,
               (int) posY + y,
               (int) posZ + z,
               worldObj.getBlockMetadata((int) posX + x, (int) posY + y, (int) posZ + z),
               0);
           worldObj.setBlockToAir((int) posX + x, (int) posY + y, (int) posZ + z);
           id.onBlockDestroyedByExplosion(
               worldObj,
               (int) posX + x,
               (int) posY + y,
               (int) posZ + z,
               new Explosion(worldObj, this, 0.0D, 0.0D, 0.0D, 0.0F));
         }
       }
 }
 private void onPlantGrow(
     World world, int x, int y, int z, int sourceX, int sourceY, int sourceZ) {
   Block block = Block.blocksList[world.getBlockId(x, y, z)];
   if (block != null) {
     block.onPlantGrow(world, x, y, z, sourceX, sourceY, sourceZ);
   }
 }
Example #5
0
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  public void onLivingUpdate() {
    super.onLivingUpdate();

    if (this.attackTimer > 0) {
      --this.attackTimer;
    }

    if (this.holdRoseTick > 0) {
      --this.holdRoseTick;
    }

    if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D
        && this.rand.nextInt(5) == 0) {
      int i = MathHelper.floor_double(this.posX);
      int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
      int k = MathHelper.floor_double(this.posZ);
      IBlockState iblockstate = this.worldObj.getBlockState(new BlockPos(i, j, k));
      Block block = iblockstate.getBlock();

      if (block.getMaterial() != Material.air) {
        this.worldObj.spawnParticle(
            EnumParticleTypes.BLOCK_CRACK,
            this.posX + ((double) this.rand.nextFloat() - 0.5D) * (double) this.width,
            this.getEntityBoundingBox().minY + 0.1D,
            this.posZ + ((double) this.rand.nextFloat() - 0.5D) * (double) this.width,
            4.0D * ((double) this.rand.nextFloat() - 0.5D),
            0.5D,
            ((double) this.rand.nextFloat() - 0.5D) * 4.0D,
            new int[] {Block.getStateId(iblockstate)});
      }
    }
  }
 public float getStrVsBlock(ItemStack p_150893_1_, Block p_150893_2_) {
   return p_150893_2_.getMaterial() != Material.iron
           && p_150893_2_.getMaterial() != Material.anvil
           && p_150893_2_.getMaterial() != Material.rock
       ? super.getStrVsBlock(p_150893_1_, p_150893_2_)
       : this.efficiencyOnProperMaterial;
 }
 public boolean canBlockCatchFire(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
   Block block = Block.blocksList[world.getBlockId(x, y, z)];
   if (block != null) {
     return block.isFlammable(world, x, y, z, world.getBlockMetadata(x, y, z), face);
   }
   return false;
 }
Example #8
0
  private boolean func_75496_b(
      int p_75496_1_,
      int p_75496_2_,
      int p_75496_3_,
      int p_75496_4_,
      int p_75496_5_,
      int p_75496_6_,
      Vec3 p_75496_7_,
      double p_75496_8_,
      double p_75496_10_) {
    for (int var12 = p_75496_1_; var12 < p_75496_1_ + p_75496_4_; ++var12) {
      for (int var13 = p_75496_2_; var13 < p_75496_2_ + p_75496_5_; ++var13) {
        for (int var14 = p_75496_3_; var14 < p_75496_3_ + p_75496_6_; ++var14) {
          double var15 = (double) var12 + 0.5D - p_75496_7_.field_72450_a;
          double var17 = (double) var14 + 0.5D - p_75496_7_.field_72449_c;
          if (var15 * p_75496_8_ + var17 * p_75496_10_ >= 0.0D) {
            Block var19 = this.field_75513_b.func_147439_a(var12, var13, var14);
            if (!var19.func_149655_b(this.field_75513_b, var12, var13, var14)) {
              return false;
            }
          }
        }
      }
    }

    return true;
  }
Example #9
0
 /**
  * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with
  * plants.
  */
 public boolean canBlockStay(World par1World, int par2, int par3, int par4) {
   Block soil = blocksList[par1World.getBlockId(par2, par3 - 1, par4)];
   return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8
           || par1World.canBlockSeeTheSky(par2, par3, par4))
       && (soil != null
           && soil.canSustainPlant(par1World, par2, par3 - 1, par4, ForgeDirection.UP, this));
 }
Example #10
0
  @Override
  public void onUpdate() {
    super.onUpdate();

    if ((this.ticksExisted - 1) % 20 == 0
        && this.worldObj.isRemote
        && FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
      this.flagData =
          ClientUtil.updateFlagData(
              this.getOwner(),
              Minecraft.getMinecraft().thePlayer.getDistanceToEntity(this) < 50.0D);
    }

    Vector3 vec = new Vector3(this.posX, this.posY, this.posZ);
    vec = vec.translate(new Vector3(0, -1, 0));
    final Block blockAt = vec.getBlock(this.worldObj);

    if (blockAt != null) {
      if (blockAt instanceof BlockFence) {

      } else if (blockAt.isAir(this.worldObj, vec.intX(), vec.intY(), vec.intZ())) {
        this.motionY -= 0.02F;
      }
    }

    this.moveEntity(this.motionX, this.motionY, this.motionZ);
  }
Example #11
0
 @Override
 public void updateTick(World world, int x, int y, int z, Random rand) {
   // they don't disappear anymore
   int blocks = 0;
   for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
     ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i];
     Block block = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
     if (!block.isAir(world, x, y, z)) {
       blocks++;
     }
   }
   if (blocks != 6) {
     int randInt = 0;
     if (leafType == 3) {
       randInt = rand.nextInt(20);
     } else if (leafType < 2) {
       randInt = rand.nextInt(8);
     } else {
       randInt = rand.nextInt(10);
     }
     if (randInt == 2) {
       int meta = world.getBlockMetadata(x, y, z);
       if (meta != 5) {
         world.setBlockMetadataWithNotify(x, y, z, meta + 2, 2);
       }
     }
   }
 }
  /**
   * Returns a boolean indicating whether or not the current location for the tree, spanning basePos
   * to to the height limit, is valid.
   */
  boolean validTreeLocation() {
    int[] aint = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]};
    int[] aint1 =
        new int[] {this.basePos[0], this.basePos[1] + this.heightLimit - 1, this.basePos[2]};
    int i = this.worldObj.getBlockId(this.basePos[0], this.basePos[1] - 1, this.basePos[2]);

    Block soil = Block.blocksList[i];
    boolean isValidSoil =
        (soil != null
            && soil.canSustainPlant(
                worldObj,
                basePos[0],
                basePos[1] - 1,
                basePos[2],
                ForgeDirection.UP,
                (BlockDreamSaplings) ModBlocks.dreamSaplings));
    if (!isValidSoil) {
      return false;
    } else {
      int j = this.checkBlockLine(aint, aint1);

      if (j == -1) {
        return true;
      } else if (j < 6) {
        return false;
      } else {
        this.heightLimit = j;
        return true;
      }
    }
  }
Example #13
0
  /* Place bushes on dirt, grass, or other bushes only */
  @Override
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float par8,
      float par9,
      float par10) {
    if (side != 1) return false;
    else if (player.canPlayerEdit(x, y, z, side, stack)
        && player.canPlayerEdit(x, y + 1, z, side, stack)) {
      Block block = Block.blocksList[world.getBlockId(x, y, z)];

      if (block != null
          && (block.canSustainPlant(
                  world, x, y, z, ForgeDirection.UP, (IPlantable) NContent.netherBerryBush)
              || block == Block.netherrack)
          && world.isAirBlock(x, y + 1, z)) {
        world.setBlock(x, y + 1, z, NContent.netherBerryBush.blockID, stack.getItemDamage() % 4, 3);
        if (!player.capabilities.isCreativeMode) stack.stackSize--;
        if (!world.isRemote) world.playAuxSFX(2001, x, y, z, NContent.netherBerryBush.blockID);
        return true;
      } else return false;
    } else return false;
  }
Example #14
0
 public static boolean isAirBlock(World aWorld, int aX, int aY, int aZ) {
   Block tID = aWorld.getBlock(aX, aY, aZ);
   if (tID != Blocks.air) {
     return tID.isAir(aWorld, aX, aY, aZ);
   }
   return true;
 }
Example #15
0
  @Override
  public void decorate(World world, Random random, int chunkX, int chunkZ) {
    super.decorate(world, random, chunkX, chunkZ);

    int var5 = 12 + random.nextInt(6);

    for (int var6 = 0; var6 < var5; ++var6) {
      int x = chunkX + random.nextInt(16);
      int y = random.nextInt(28) + 4;
      int z = chunkZ + random.nextInt(16);

      Block block = world.getBlock(x, y, z);

      if (block != null && block.isReplaceableOreGen(world, x, y, z, Blocks.stone)) {
        world.setBlock(x, y, z, BOPBlockHelper.get("gemOre"), 10, 2);
      }
    }

    for (int var6 = 0; var6 < 10; ++var6) {
      int var7 = chunkX + random.nextInt(16) + 8;
      short var8 = 62;
      int var9 = chunkZ + random.nextInt(16) + 8;

      new WorldGenMarsh().generate(world, random, var7, var8, var9);
    }
  }
Example #16
0
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    int var11;

    Block block = null;
    do {
      block = par1World.getBlock(par3, par4, par5);
      if (block != null && !block.isLeaves(par1World, par3, par4, par5)) {
        break;
      }
      par4--;
    } while (par4 > 0);

    for (int var7 = 0; var7 < 4; ++var7) {
      int var8 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8);
      int var9 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4);
      int var10 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8);

      if (par1World.isAirBlock(var8, var9, var10)
          && this.deadBush.canBlockStay(par1World, var8, var9, var10)) {
        par1World.setBlock(var8, var9, var10, this.deadBush, 0, 2);
      }
    }

    return true;
  }
Example #17
0
  @Override
  public boolean onItemUse(
      ItemStack itemstack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    if (itemstack != null && itemstack.getItemDamage() == 0) {
      if (side == 1
          && player.canPlayerEdit(x, y, z, side, itemstack)
          && player.canPlayerEdit(x, y + 1, z, side, itemstack)) {
        Block block = world.getBlock(x, y, z);

        if (block != Blocks.bedrock
            && block.canSustainPlant(world, x, y, z, ForgeDirection.UP, this)
            && world.isAirBlock(x, y + 1, z)) {
          world.setBlock(x, y + 1, z, getPlant(world, x, y, z));

          --itemstack.stackSize;

          return true;
        }
      }

      return false;
    }

    return super.onItemUse(itemstack, player, world, x, y, z, side, hitX, hitY, hitZ);
  }
 @Override
 public boolean onBlockDestroyed(
     ItemStack is, World world, int blockID, int x, int y, int z, EntityLivingBase e) {
   if (is.getItemDamage() > 0 && e instanceof EntityPlayer) {
     EntityPlayer ep = (EntityPlayer) e;
     Block b = Block.blocksList[blockID];
     if (b.blockMaterial == Material.leaves) {
       is.setItemDamage(is.getItemDamage() - 1);
       int r = 3;
       for (int i = -r; i <= r; i++) {
         for (int j = -r; j <= r; j++) {
           for (int k = -r; k <= r; k++) {
             int dx = x + i;
             int dy = y + j;
             int dz = z + k;
             Block b2 = Block.blocksList[world.getBlockId(dx, dy, dz)];
             if (b2 != null && b2.blockMaterial == Material.leaves) {
               b2.dropBlockAsItem(world, dx, dy, dz, world.getBlockMetadata(dx, dy, dz), 0);
               b2.removeBlockByPlayer(world, ep, dx, dy, dz);
               is.setItemDamage(is.getItemDamage() - 1);
             }
           }
         }
       }
       e.setCurrentItemOrArmor(0, is);
       return true;
     }
   }
   return false;
 }
 private void tryToCatchBlockOnFire(
     World par1World,
     int par2,
     int par3,
     int par4,
     int par5,
     Random par6Random,
     int par7,
     ForgeDirection face) {
   int j1 = 0;
   Block block = Block.blocksList[par1World.getBlockId(par2, par3, par4)];
   if (block != null) {
     j1 =
         block.getFlammability(
             par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), face);
   }
   if (par6Random.nextInt(par5) < j1) {
     boolean flag = par1World.getBlockId(par2, par3, par4) == Block.tnt.blockID;
     if ((par6Random.nextInt(par7 + 10) < 5)
         && (!par1World.canLightningStrikeAt(par2, par3, par4))) {
       int k1 = par7 + par6Random.nextInt(5) / 4;
       if (k1 > 15) {
         k1 = 15;
       }
       par1World.setBlock(par2, par3, par4, this.blockID, k1, 3);
     } else {
       par1World.setBlockToAir(par2, par3, par4);
     }
     if (flag) {
       Block.tnt.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
     }
   }
 }
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    int l;

    Block block = null;
    do {
      block = Block.blocksList[par1World.getBlockId(par3, par4, par5)];
      if (block != null && !block.isLeaves(par1World, par3, par4, par5)) {
        break;
      }
      par4--;
    } while (par4 > 0);

    for (int i1 = 0; i1 < 128; ++i1) {
      int j1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8);
      int k1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4);
      int l1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8);

      if (par1World.isAirBlock(j1, k1, l1)
          && Block.blocksList[this.tallGrassID].canBlockStay(par1World, j1, k1, l1)) {
        par1World.setBlock(j1, k1, l1, this.tallGrassID, this.tallGrassMetadata, 2);
      }
    }

    return true;
  }
  private void growLeaves(
      World par1World, int par2, int par3, int par4, int par5, Random par6Random) {
    byte b0 = 2;

    for (int i1 = par4 - b0; i1 <= par4; ++i1) {
      int j1 = i1 - par4;
      int k1 = par5 + 1 - j1;

      for (int l1 = par2 - k1; l1 <= par2 + k1 + 1; ++l1) {
        int i2 = l1 - par2;

        for (int j2 = par3 - k1; j2 <= par3 + k1 + 1; ++j2) {
          int k2 = j2 - par3;

          if ((i2 >= 0 || k2 >= 0 || i2 * i2 + k2 * k2 <= k1 * k1)
              && (i2 <= 0 && k2 <= 0 || i2 * i2 + k2 * k2 <= (k1 + 1) * (k1 + 1))
              && (par6Random.nextInt(4) != 0 || i2 * i2 + k2 * k2 <= (k1 - 1) * (k1 - 1))) {
            int l2 = par1World.getBlockId(l1, i1, j2);
            Block block = Block.blocksList[l2];

            if (block == null || block.canBeReplacedByLeaves(par1World, l1, i1, j2)) {
              this.setBlockAndMetadata(
                  par1World, l1, i1, j2, Main.McLeaf.blockID, this.leavesMetadata);
            }
          }
        }
      }
    }
  }
Example #22
0
 @Override
 public boolean canHarvestBlock(Block block) {
   return block != null
       && (block.getMaterial() == Material.iron
           || block.getMaterial() == Material.anvil
           || block.getMaterial() == Material.rock);
 }
  @Mod.EventHandler
  public void remap(FMLMissingMappingsEvent event) {
    for (FMLMissingMappingsEvent.MissingMapping mapping : event.get()) {
      if (mapping.name.equals("BuildCraft|Silicon:null")) {
        if (mapping.type == GameRegistry.Type.ITEM) {
          mapping.remap(Item.getItemFromBlock(assemblyTableBlock));
        } else {
          mapping.remap(assemblyTableBlock);
        }
      }

      // Silicon -> Robotics migration code
      if (mapping.type == GameRegistry.Type.ITEM) {
        if (mapping.name.equals("BuildCraft|Silicon:robot")) {
          mapping.remap((Item) Item.itemRegistry.getObject("BuildCraft|Robotics:robot"));
        } else if (mapping.name.equals("BuildCraft|Silicon:redstone_board")) {
          mapping.remap((Item) Item.itemRegistry.getObject("BuildCraft|Robotics:redstone_board"));
        } else if (mapping.name.equals("BuildCraft|Silicon:requester")) {
          mapping.remap((Item) Item.itemRegistry.getObject("BuildCraft|Robotics:requester"));
        } else if (mapping.name.equals("BuildCraft|Silicon:zonePlan")) {
          mapping.remap((Item) Item.itemRegistry.getObject("BuildCraft|Robotics:zonePlan"));
        }
      } else if (mapping.type == GameRegistry.Type.BLOCK) {
        if (mapping.name.equals("BuildCraft|Silicon:requester")) {
          mapping.remap(Block.getBlockFromName("BuildCraft|Robotics:requester"));
        } else if (mapping.name.equals("BuildCraft|Silicon:zonePlan")) {
          mapping.remap(Block.getBlockFromName("BuildCraft|Robotics:zonePlan"));
        }
      }
    }
  }
Example #24
0
  void destroyWood(
      World world, int x, int y, int z, ItemStack stack, NBTTagCompound tags, EntityPlayer player) {
    for (int xPos = x - 1; xPos <= x + 1; xPos++) {
      for (int yPos = y - 1; yPos <= y + 1; yPos++) {
        for (int zPos = z - 1; zPos <= z + 1; zPos++) {
          if (!(tags.getBoolean("Broken"))) {
            Block block = world.getBlock(xPos, yPos, zPos);
            int meta = world.getBlockMetadata(xPos, yPos, zPos);
            int hlvl = block.getHarvestLevel(meta);

            if (block != null && block.getMaterial() == Material.wood) {
              if (hlvl <= tags.getInteger("HarvestLevel")) {
                boolean cancelHarvest = false;
                for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
                  if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
                    cancelHarvest = true;
                }

                if (!cancelHarvest) {
                  WorldHelper.setBlockToAir(world, xPos, yPos, zPos);
                  if (!player.capabilities.isCreativeMode) {
                    // TODO harvestBlock
                    block.harvestBlock(world, player, xPos, yPos, zPos, meta);
                    onBlockDestroyed(stack, world, block, xPos, yPos, zPos, player);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
Example #25
0
  /** Checking right click actions on blocks. */
  public boolean checkBlockInteraction(
      Resident res, BlockPos bp, PlayerInteractEvent.Action action) {
    Block blockType =
        DimensionManager.getWorld(bp.getDim()).getBlock(bp.getX(), bp.getY(), bp.getZ());
    for (SegmentBlock segment : segmentsBlocks) {
      if (segment.getCheckClass().isAssignableFrom(blockType.getClass())
          && (segment.getMeta() == -1
              || segment.getMeta()
                  == DimensionManager.getWorld(bp.getDim())
                      .getBlockMetadata(bp.getX(), bp.getY(), bp.getZ()))
          && (segment.getType() == BlockType.ANY_CLICK
              || segment.getType() == BlockType.RIGHT_CLICK
                  && action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
              || segment.getType() == BlockType.LEFT_CLICK
                  && action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)) {
        int dim = bp.getDim();
        int x = bp.getX();
        int y = bp.getY();
        int z = bp.getZ();

        if (!hasPermission(res, segment, dim, x, y, z)) {
          if (segment.hasClientUpdate())
            sendClientUpdate(
                segment.getClientUpdateCoords(), bp, (EntityPlayerMP) res.getPlayer(), null);
          return true;
        }
      }
    }

    return false;
  }
  public List<ChunkCoordinates> getCoordsToPut(int xCoord, int yCoord, int zCoord) {
    List<ChunkCoordinates> possibleCoords = new ArrayList();
    List<ChunkCoordinates> selectedCoords = new ArrayList();
    int range = 4;
    int rangeY = 4;

    for (int i = -range; i < range + 1; i++)
      for (int j = -rangeY; j < rangeY; j++)
        for (int k = -range; k < range + 1; k++) {
          int x = xCoord + i;
          int y = yCoord + j;
          int z = zCoord + k;
          Block block = worldObj.getBlock(x, y, z);
          if (block != null && block.isReplaceableOreGen(worldObj, x, y, z, Blocks.stone))
            possibleCoords.add(new ChunkCoordinates(x, y, z));
        }

    int count = 64;
    while (!possibleCoords.isEmpty() && count > 0) {
      ChunkCoordinates coords = possibleCoords.get(worldObj.rand.nextInt(possibleCoords.size()));
      possibleCoords.remove(coords);
      selectedCoords.add(coords);
      count--;
    }
    return selectedCoords;
  }
  /** Called when the mob is falling. Calculates and applies fall damage. */
  protected void fall(float distance) {
    if (distance > 1.0F) {
      this.playSound("mob.horse.land", 0.4F, 1.0F);
    }

    int i = MathHelper.ceiling_float_int(distance * 0.5F - 3.0F);

    if (i > 0) {
      this.attackEntityFrom(DamageSource.fall, (float) i);

      if (this.riddenByEntity != null) {
        this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float) i);
      }

      Block block =
          this.worldObj.getBlock(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.posY - 0.2D - (double) this.prevRotationYaw),
              MathHelper.floor_double(this.posZ));

      if (block.getMaterial() != Material.air) {
        Block.SoundType soundtype = block.stepSound;
        this.worldObj.playSoundAtEntity(
            this,
            soundtype.getStepSound(),
            soundtype.getVolume() * 0.5F,
            soundtype.getFrequency() * 0.75F);
      }
    }
  }
  @SuppressWarnings({"rawtypes"})
  public static BlockStateInfo fromString(final String input) throws LocalizedException {
    final int start = input.indexOf('[');
    final int end = input.indexOf(']');

    final String blockName;
    final String stateData;
    if (start > -1 && end > -1) {
      blockName = input.substring(0, start);
      stateData = input.substring(start + 1, end);
    } else {
      blockName = input;
      stateData = "";
    }

    final ResourceLocation location = new ResourceLocation(blockName);
    if (!BLOCK_REGISTRY.containsKey(location)) {
      throw new LocalizedException(Names.Messages.INVALID_BLOCK, blockName);
    }

    final Block block = BLOCK_REGISTRY.getObject(location);
    final Map<IProperty, Comparable> propertyData =
        parsePropertyData(block.getDefaultState(), stateData, true);
    return new BlockStateInfo(block, propertyData);
  }
 @Override
 protected void drawSlot(int id, int x, int y, int var4, int var5, int var6) {
   Block block = blocks.get(id);
   ItemStack itemStack = new ItemStack(Item.getItemFromBlock(block));
   GlStateManager.enableRescaleNormal();
   GlStateManager.enableBlend();
   RenderHelper.enableGUIStandardItemLighting();
   GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
   if (itemStack.getItem() != null)
     try {
       Minecraft.getMinecraft()
           .getRenderItem()
           .renderItemAndEffectIntoGUI(itemStack, x + 4, y + 4);
     } catch (Exception e) {
       e.printStackTrace();
     }
   else mc.fontRendererObj.drawString("?", x + 10, y + 9, 10526880);
   Minecraft.getMinecraft()
       .getRenderItem()
       .func_175030_a(Minecraft.getMinecraft().fontRendererObj, itemStack, x + 4, y + 4);
   RenderHelper.disableStandardItemLighting();
   GlStateManager.disableRescaleNormal();
   GlStateManager.disableBlend();
   glDisable(GL_LIGHTING);
   mc.fontRendererObj.drawString(
       "Name: "
           + (itemStack.getItem() == null ? block.getLocalizedName() : itemStack.getDisplayName()),
       x + 31,
       y + 3,
       10526880);
   int blockID = Block.getIdFromBlock(block);
   mc.fontRendererObj.drawString("ID: " + blockID, x + 31, y + 15, 10526880);
 }
Example #30
0
  public boolean generate(World world, Random random, int xPos, int yPos, int zPos) {
    int height = random.nextInt(this.treeHeightRange) + this.minTreeHeight;
    boolean flag = true;
    if (seekHeight) {
      yPos = findGround(world, xPos, yPos, zPos);
      if (yPos == -1) return false;
    }

    if (yPos >= 1 && yPos + height + 1 <= 256) {
      Block soil = Block.blocksList[world.getBlockId(xPos, yPos - 1, zPos)];
      boolean isSoil =
          (soil != null
              && soil.canSustainPlant(
                  world, xPos, yPos - 1, zPos, ForgeDirection.UP, NContent.rareSapling));

      if (isSoil) {
        if (!checkClear(world, xPos, yPos, zPos, height)) return false;

        soil.onPlantGrow(world, xPos, yPos - 1, zPos, xPos, yPos, zPos);
        placeCanopy(world, random, xPos, yPos, zPos, height);
        placeTrunk(world, xPos, yPos, zPos, height);
        return true;
      }
    }
    return false;
  }