Example #1
0
  /**
   * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY,
   * hitZ, block metadata
   */
  public int onBlockPlaced(
      World p_149660_1_,
      int p_149660_2_,
      int p_149660_3_,
      int p_149660_4_,
      int p_149660_5_,
      float p_149660_6_,
      float p_149660_7_,
      float p_149660_8_,
      int p_149660_9_) {
    int j1 = p_149660_9_;

    if ((p_149660_9_ == 0 || p_149660_5_ == 2)
        && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH)) {
      j1 = 2;
    }

    if ((j1 == 0 || p_149660_5_ == 3)
        && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH)) {
      j1 = 3;
    }

    if ((j1 == 0 || p_149660_5_ == 4)
        && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST)) {
      j1 = 4;
    }

    if ((j1 == 0 || p_149660_5_ == 5)
        && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST)) {
      j1 = 5;
    }

    return j1;
  }
  @Override
  public int onBlockPlaced(
      World world,
      int x,
      int y,
      int z,
      int side,
      float hitX,
      float hitY,
      float hitZ,
      int metadata) {
    if (side == 0 && world.isSideSolid(x, y + 1, z, DOWN, false)) {
      metadata = 0;
    }

    if (side == 5 && world.isSideSolid(x - 1, y, z, EAST, true)) {
      metadata = 1;
    }

    if (side == 2 && world.isSideSolid(x, y, z + 1, NORTH, true)) {
      metadata = 2;
    }

    if (side == 4 && world.isSideSolid(x + 1, y, z, WEST, true)) {
      metadata = 3;
    }

    if (side == 3 && world.isSideSolid(x, y, z - 1, SOUTH, true)) {
      metadata = 4;
    }

    return metadata;
  }
Example #3
0
 /**
  * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
  */
 public boolean canPlaceBlockAt(
     World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) {
   return p_149742_1_.isSideSolid(p_149742_2_ - 1, p_149742_3_, p_149742_4_, EAST)
       || p_149742_1_.isSideSolid(p_149742_2_ + 1, p_149742_3_, p_149742_4_, WEST)
       || p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ - 1, SOUTH)
       || p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ + 1, NORTH);
 }
Example #4
0
  /**
   * 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 Block
   */
  public void onNeighborBlockChange(
      World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) {
    int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_);
    boolean flag = false;

    if (l == 2 && p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ + 1, NORTH)) {
      flag = true;
    }

    if (l == 3 && p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ - 1, SOUTH)) {
      flag = true;
    }

    if (l == 4 && p_149695_1_.isSideSolid(p_149695_2_ + 1, p_149695_3_, p_149695_4_, WEST)) {
      flag = true;
    }

    if (l == 5 && p_149695_1_.isSideSolid(p_149695_2_ - 1, p_149695_3_, p_149695_4_, EAST)) {
      flag = true;
    }

    if (!flag) {
      this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0);
      p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
    }

    super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_);
  }
  @Override
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) {
    int i1 = par1World.getBlockMetadata(par2, par3, par4);
    boolean flag = false;

    if (i1 == 0 && par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH)) {
      flag = true;
    }

    if (i1 == 1 && par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH)) {
      flag = true;
    }

    if (i1 == 2 && par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST)) {
      flag = true;
    }

    if (i1 == 3 && par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST)) {
      flag = true;
    }

    if (!flag) {
      this.dropBlockAsItem(par1World, par2, par3, par4, i1, 0);
      par1World.setBlockToAir(par2, par3, par4);
    }

    super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
  }
 @Override
 public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
   return par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST)
       || par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST)
       || par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH)
       || par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH);
 }
Example #7
0
  public IInventory func_149951_m(World world, int x, int y, int z) {
    Object object = (TileEntityBlueMateriaChest) world.getTileEntity(x, y, z);

    if (object == null) {
      return null;
    } else if (world.isSideSolid(x, y + 1, z, DOWN)) {
      return null;
    } else if (SittingOcelot(world, x, y, z)) {
      return null;
    } else if (world.getBlock(x - 1, y, z) == this
        && (world.isSideSolid(x - 1, y + 1, z, DOWN) || SittingOcelot(world, x - 1, y, z))) {
      return null;
    } else if (world.getBlock(x + 1, y, z) == this
        && (world.isSideSolid(x + 1, y + 1, z, DOWN) || SittingOcelot(world, x + 1, y, z))) {
      return null;
    } else if (world.getBlock(x, y, z - 1) == this
        && (world.isSideSolid(x, y + 1, z - 1, DOWN) || SittingOcelot(world, x, y, z - 1))) {
      return null;
    } else if (world.getBlock(x, y, z + 1) == this
        && (world.isSideSolid(x, y + 1, z + 1, DOWN) || SittingOcelot(world, x, y, z + 1))) {
      return null;
    } else {
      return (IInventory) object;
    }
  }
  @Override
  public int onBlockPlaced(
      World par1World,
      int par2,
      int par3,
      int par4,
      int par5,
      float par6,
      float par7,
      float par8,
      int par9) {
    int j1 = par9;

    if ((j1 == 0 || par5 == 0)
        && par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH)) {
      j1 = 0;
    }

    if ((j1 == 0 || par5 == 1)
        && par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH)) {
      j1 = 1;
    }

    if ((j1 == 0 || par5 == 2)
        && par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST)) {
      j1 = 2;
    }

    if ((j1 == 0 || par5 == 3)
        && par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST)) {
      j1 = 3;
    }

    return j1;
  }
 /**
  * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
  */
 public boolean canPlaceBlockAt(World world, int x, int y, int z) {
   return world.isSideSolid(x - 1, y, z, EAST, true)
       || world.isSideSolid(x + 1, y, z, WEST, true)
       || world.isSideSolid(x, y, z - 1, SOUTH, true)
       || world.isSideSolid(x, y, z + 1, NORTH, true)
       || isSolid(world, x, y - 1, z)
       || isSolid(world, x, y + 1, z);
 }
  protected boolean neighbourChanged(World world, int x, int y, int z, Block block) {
    if (canPlaceAt(world, x, y, z)) {
      int metadata = world.getBlockMetadata(x, y, z);
      boolean canSupport = true;

      if (!world.isSideSolid(x - 1, y, z, EAST, true) && metadata == 1) {
        canSupport = false;
      } else if (!world.isSideSolid(x + 1, y, z, WEST, true) && metadata == 2) {
        canSupport = false;
      } else if (!world.isSideSolid(x, y, z - 1, SOUTH, true) && metadata == 3) {
        canSupport = false;
      } else if (!world.isSideSolid(x, y, z + 1, NORTH, true) && metadata == 4) {
        canSupport = false;
      } else if (!isSolid(world, x, y - 1, z) && metadata == 5) {
        canSupport = false;
      } else if (!isSolid(world, x, y + 1, z) && metadata == 6) {
        canSupport = false;
      }

      if (!canSupport) {
        if (new Random().nextInt(9) == 0) {
          if (!world.isRemote
              && world.getGameRules().getGameRuleBooleanValue("doTileDrops")
              && !world.restoringBlockSnapshots) // do not drop items while restoring blockstates,
          // prevents item dupe
          {
            float f = 0.7F;
            double motionX = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
            double motionY = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
            double motionZ = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
            EntityItem entityitem =
                new EntityItem(
                    world,
                    x + motionX,
                    y + motionY,
                    z + motionZ,
                    new ItemStack(TFBlocks.energonCrystal));
            entityitem.delayBeforeCanPickup = 10;
            world.spawnEntityInWorld(entityitem);
          }
        } else {
          this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
        }

        world.setBlockToAir(x, y, z);

        return true;
      } else {
        return false;
      }
    } else {
      return true;
    }
  }
  /**
   * checks to see if you can place this block can be placed on that side of a block: BlockLever
   * overrides
   */
  public boolean canPlaceBlockOnSide(
      World p_149707_1_, int p_149707_2_, int p_149707_3_, int p_149707_4_, int p_149707_5_) {
    if (disableValidation) return true;
    if (p_149707_5_ == 0) {
      return false;
    } else if (p_149707_5_ == 1) {
      return false;
    } else {
      if (p_149707_5_ == 2) {
        ++p_149707_4_;
      }

      if (p_149707_5_ == 3) {
        --p_149707_4_;
      }

      if (p_149707_5_ == 4) {
        ++p_149707_2_;
      }

      if (p_149707_5_ == 5) {
        --p_149707_2_;
      }

      return func_150119_a(p_149707_1_.getBlock(p_149707_2_, p_149707_3_, p_149707_4_))
          || p_149707_1_.isSideSolid(p_149707_2_, p_149707_3_, p_149707_4_, ForgeDirection.UP);
    }
  }
Example #12
0
 protected static boolean func_181088_a(
     World p_181088_0_, BlockPos p_181088_1_, EnumFacing p_181088_2_) {
   return p_181088_2_ == EnumFacing.DOWN
           && World.doesBlockHaveSolidTopSurface(p_181088_0_, p_181088_1_.down())
       ? true
       : p_181088_0_.isSideSolid(p_181088_1_.offset(p_181088_2_), p_181088_2_.getOpposite());
 }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (player.isSneaking()) return true;
    else if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) return true;
    else {
      if (!world.isRemote) {
        TileEntityMagneticChest tileMagneticChest =
            (TileEntityMagneticChest) world.getTileEntity(x, y, z);

        if (tileMagneticChest != null) {
          player.displayGUIChest(tileMagneticChest);
        }
      }

      return true;
    }
  }
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  public void onBlockAdded(World world, int x, int y, int z) {
    if (world.getBlockMetadata(x, y, z) == 0) {
      if (world.isSideSolid(x - 1, y, z, EAST, true)) {
        world.setBlockMetadataWithNotify(x, y, z, 1, 2);
      } else if (world.isSideSolid(x + 1, y, z, WEST, true)) {
        world.setBlockMetadataWithNotify(x, y, z, 2, 2);
      } else if (world.isSideSolid(x, y, z - 1, SOUTH, true)) {
        world.setBlockMetadataWithNotify(x, y, z, 3, 2);
      } else if (world.isSideSolid(x, y, z + 1, NORTH, true)) {
        world.setBlockMetadataWithNotify(x, y, z, 4, 2);
      } else if (isSolid(world, x, y - 1, z)) {
        world.setBlockMetadataWithNotify(x, y, z, 5, 2);
      } else if (isSolid(world, x, y + 1, z)) {
        world.setBlockMetadataWithNotify(x, y, z, 6, 2);
      }
    }

    canPlaceAt(world, x, y, z);
  }
  @Override
  public boolean canBlockStay(World world, int x, int y, int z) {

    if (world.isSideSolid(x, y - 1, z, ForgeDirection.UP)) {
      return true;
    }
    for (ForgeDirection d : _attachDirections) {
      BlockPosition bp = new BlockPosition(x, y, z, d);
      for (int i = 0; i < _attachDistance; i++) {
        bp.moveForwards(1);
        if (world.getBlock(bp.x, bp.y, bp.z).equals(this)) {
          if (world.isSideSolid(bp.x, bp.y - 1, bp.z, ForgeDirection.UP)) {
            return true;
          }
        } else break;
      }
    }
    return false;
  }
  /**
   * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY,
   * hitZ, block metadata
   */
  public int onBlockPlaced(
      World world,
      int x,
      int y,
      int z,
      int side,
      float hitX,
      float hitY,
      float hitZ,
      int metadata) {
    int rotation = metadata;

    if (side == 0 && isSolid(world, x, y + 1, z)) {
      rotation = 6;
    }

    if (side == 1 && isSolid(world, x, y - 1, z)) {
      rotation = 5;
    }

    if (side == 2 && world.isSideSolid(x, y, z + 1, NORTH, true)) {
      rotation = 4;
    }

    if (side == 3 && world.isSideSolid(x, y, z - 1, SOUTH, true)) {
      rotation = 3;
    }

    if (side == 4 && world.isSideSolid(x + 1, y, z, WEST, true)) {
      rotation = 2;
    }

    if (side == 5 && world.isSideSolid(x - 1, y, z, EAST, true)) {
      rotation = 1;
    }

    return rotation;
  }
  /**
   * Gets the inventory of the chest at the specified coords, accounting for blocks or ocelots on
   * top of the chest, and double chests.
   */
  public IInventory getInventory(World par1World, int par2, int par3, int par4) {
    Object object = (TileEntityBoundChest) par1World.getTileEntity(par2, par3, par4);

    if (object == null) {
      return null;
    } else if (par1World.isSideSolid(par2, par3 + 1, par4, ForgeDirection.DOWN)) {
      return null;
    } else if (isOcelotBlockingChest(par1World, par2, par3, par4)) {
      return null;
    } else {

      return (IInventory) object;
    }
  }
Example #18
0
 @Override
 public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
   try {
     TileEntity tile = world.getTileEntity(x, y, z);
     if (tile instanceof TileSignalFoundation) {
       TileSignalFoundation structure = (TileSignalFoundation) tile;
       if (structure.getSignalType().needsSupport()
           && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP))
         world.func_147480_a(x, y, z, true);
       else structure.onNeighborBlockChange(block);
     }
   } catch (StackOverflowError error) {
     Game.logThrowable(Level.ERROR, "Error in BlockSignalBase.onNeighborBlockChange()", 10, error);
     throw error;
   }
 }
 @Override
 public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
   try {
     TileEntity tile = world.getTileEntity(x, y, z);
     if ((tile instanceof TileDigitalReceiverBox)) {
       TileDigitalReceiverBox structure = (TileDigitalReceiverBox) tile;
       if ((structure.getSignalType().needsSupport())
           && (!world.isSideSolid(x, y - 1, z, ForgeDirection.UP))
           && !(Mods.isLoaded(Mods.OpenComputers)
               && world.getTileEntity(x, y - 1, z) instanceof Environment)) {
         world.func_147480_a(x, y, z, true);
       } else {
         structure.onNeighborBlockChange(block);
       }
     }
   } catch (StackOverflowError error) {
     Computronics.log.error("Error in BlockDigitalReceiverBox.onNeighborBlockChange()");
     throw error;
   }
 }
  /**
   * 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 Block
   */
  public void onNeighborBlockChange(
      World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) {
    if (!p_149695_1_.isRemote) {
      int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_);
      int i1 = p_149695_2_;
      int j1 = p_149695_4_;

      if ((l & 3) == 0) {
        j1 = p_149695_4_ + 1;
      }

      if ((l & 3) == 1) {
        --j1;
      }

      if ((l & 3) == 2) {
        i1 = p_149695_2_ + 1;
      }

      if ((l & 3) == 3) {
        --i1;
      }

      if (!(func_150119_a(p_149695_1_.getBlock(i1, p_149695_3_, j1))
          || p_149695_1_.isSideSolid(
              i1, p_149695_3_, j1, ForgeDirection.getOrientation((l & 3) + 2)))) {
        p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
        this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0);
      }

      boolean flag =
          p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_);

      if (flag || p_149695_5_.canProvidePower()) {
        this.func_150120_a(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, flag);
      }
    }
  }
Example #21
0
 public boolean suitableGround(World world, BlockPos groundpos) {
   return world.isSideSolid(groundpos, EnumFacing.UP);
 }
  @Override
  public boolean onBlockActivated(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    Object var10 = par1World.getTileEntity(par2, par3, par4);

    if (var10 == null) {
      return true;
    } else if (par1World.isSideSolid(par2, par3 + 1, par4, ForgeDirection.DOWN)) {
      return true;
    } else if (T10TreasureChest.isOcelotBlockingChest(par1World, par2, par3, par4)) {
      return true;
    } else if (par1World.getBlock(par2 - 1, par3, par4) == this
        && (par1World.isSideSolid(par2 - 1, par3 + 1, par4, ForgeDirection.DOWN)
            || T10TreasureChest.isOcelotBlockingChest(par1World, par2 - 1, par3, par4))) {
      return true;
    } else if (par1World.getBlock(par2 + 1, par3, par4) == this
        && (par1World.isSideSolid(par2 + 1, par3 + 1, par4, ForgeDirection.DOWN)
            || T10TreasureChest.isOcelotBlockingChest(par1World, par2 + 1, par3, par4))) {
      return true;
    } else if (par1World.getBlock(par2, par3, par4 - 1) == this
        && (par1World.isSideSolid(par2, par3 + 1, par4 - 1, ForgeDirection.DOWN)
            || T10TreasureChest.isOcelotBlockingChest(par1World, par2, par3, par4 - 1))) {
      return true;
    } else if (par1World.getBlock(par2, par3, par4 + 1) == this
        && (par1World.isSideSolid(par2, par3 + 1, par4 + 1, ForgeDirection.DOWN)
            || T10TreasureChest.isOcelotBlockingChest(par1World, par2, par3, par4 + 1))) {
      return true;
    } else {
      if (par1World.getBlock(par2 - 1, par3, par4) == this) {
        var10 =
            new InventoryLargeChest(
                "container.chestDouble",
                (TileEntityT10TreasureChest) par1World.getTileEntity(par2 - 1, par3, par4),
                (IInventory) var10);
      }

      if (par1World.getBlock(par2 + 1, par3, par4) == this) {
        var10 =
            new InventoryLargeChest(
                "container.chestDouble",
                (IInventory) var10,
                (TileEntityT10TreasureChest) par1World.getTileEntity(par2 + 1, par3, par4));
      }

      if (par1World.getBlock(par2, par3, par4 - 1) == this) {
        var10 =
            new InventoryLargeChest(
                "container.chestDouble",
                (TileEntityT10TreasureChest) par1World.getTileEntity(par2, par3, par4 - 1),
                (IInventory) var10);
      }

      if (par1World.getBlock(par2, par3, par4 + 1) == this) {
        var10 =
            new InventoryLargeChest(
                "container.chestDouble",
                (IInventory) var10,
                (TileEntityT10TreasureChest) par1World.getTileEntity(par2, par3, par4 + 1));
      }

      if (par1World.isRemote) {
        return true;
      } else {
        par5EntityPlayer.displayGUIChest((IInventory) var10);
        return true;
      }
    }
  }
Example #23
0
  void markValidLakesThenFill(World world, int chunkX, int chunkZ) {
    int size = 16 * 3;

    int dx, dz;
    int ndx, ndz;
    int yPos, nhgt, chunkIndex, nchunkIndex;

    int rain =
        VCraftWorld.instance.getRainfall(
            world.getHorizon(new BlockPos(chunkX * 16 + 8, 0, chunkZ * 16 + 8)));
    if (rain < 100) rain /= 2;
    int maxTries = (rain * rain) / (8 * 255);
    // System.out.println("rain = "+rain+", so tries: " + maxTries);

    Queue<Point> queue = new LinkedList<Point>();
    Queue<Point> water = new LinkedList<Point>();

    int lakeYPos;

    while (maxTries-- > 0) {
      dx = world.rand.nextInt(16);
      dz = world.rand.nextInt(16);

      queue.clear();
      water.clear();
      int[] checked = new int[size * size];

      BlockPos pos = getHorizon(world, new BlockPos(chunkX * 16 + dx, 0, chunkZ * 16 + dz));
      if (pos == null) continue;

      lakeYPos = pos.getY();
      queue.add(new Point(dx, dz));
      checked[(dz + 16) * size + dx + 16] = 1;

      while (!queue.isEmpty()) {
        Point p = queue.remove();

        for (int i = 0; i < EnumFacing.HORIZONTALS.length; i++) {
          EnumFacing direction = EnumFacing.HORIZONTALS[i];
          ndx = p.x + direction.getFrontOffsetX();
          ndz = p.y + direction.getFrontOffsetZ();

          BlockPos neibpos = new BlockPos(chunkX * 16 + ndx, lakeYPos, chunkZ * 16 + ndz);

          // Cannot be at our 3x3 chunk border and we need a solid face below the water
          // otherwise cancel lake generation
          if (ndx > -15
              && ndz > -15
              && ndx < 31
              && ndz < 31
              && world.isSideSolid(neibpos.down(), EnumFacing.UP)) {

            // Already checked or did we reach a lake border?
            if (checked[(ndz + 16) * size + ndx + 16] == 0
                && world.getBlockState(neibpos).getBlock().isReplaceable(world, neibpos)) {
              queue.add(new Point(ndx, ndz));
              water.add(new Point(ndx, ndz));
              checked[(ndz + 16) * size + ndx + 16] = 1;
            }

          } else {
            water.clear();
            queue.clear();
            break;
          }
        }
      }

      /*if (water.size() > 0) {
      	System.out.println("found " + water.size() + " water points");
      }*/

      for (Point p : water) {
        pos = new BlockPos(chunkX * 16 + p.x, lakeYPos, chunkZ * 16 + p.y);

        if (world.getBlockState(pos).getBlock().isReplaceable(world, pos)) {
          world.setBlockState(pos, Blocks.water.getDefaultState());
        }
      }
    }
  }
Example #24
0
  // Copied from vanila skull itemBlock. Relevant edits are indicated.
  @Nonnull
  @Override
  public EnumActionResult onItemUse(
      ItemStack stack,
      EntityPlayer playerIn,
      World worldIn,
      BlockPos pos,
      EnumHand hand,
      EnumFacing facing,
      float hitX,
      float hitY,
      float hitZ) {
    if (facing == EnumFacing.DOWN) {
      return EnumActionResult.FAIL;
    } else {
      if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) {
        facing = EnumFacing.UP;
        pos = pos.down();
      }
      IBlockState iblockstate = worldIn.getBlockState(pos);
      Block block = iblockstate.getBlock();
      boolean flag = block.isReplaceable(worldIn, pos);

      if (!flag) {
        if (!worldIn.getBlockState(pos).getMaterial().isSolid()
            && !worldIn.isSideSolid(pos, facing, true)) {
          return EnumActionResult.FAIL;
        }

        pos = pos.offset(facing);
      }

      if (playerIn.canPlayerEdit(pos, facing, stack)
          && Blocks.SKULL.canPlaceBlockAt(worldIn, pos)) {
        if (worldIn.isRemote) {
          return EnumActionResult.SUCCESS;
        } else {
          worldIn.setBlockState(
              pos,
              ModBlocks.gaiaHead.getDefaultState().withProperty(BlockSkull.FACING, facing),
              11); // Botania - skull -> gaia head
          int i = 0;

          if (facing == EnumFacing.UP) {
            i = MathHelper.floor_double(playerIn.rotationYaw * 16.0F / 360.0F + 0.5D) & 15;
          }

          TileEntity tileentity = worldIn.getTileEntity(pos);

          if (tileentity instanceof TileEntitySkull) {
            TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;

            if (stack.getMetadata() == 3) // Botania - do not retrieve skins
            {
              /*GameProfile gameprofile = null;

              if (stack.hasTagCompound())
              {
              	NBTTagCompound nbttagcompound = stack.getTagCompound();

              	if (nbttagcompound.hasKey("SkullOwner", 10))
              	{
              		gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
              	}
              	else if (nbttagcompound.hasKey("SkullOwner", 8) && !nbttagcompound.getString("SkullOwner").isEmpty())
              	{
              		gameprofile = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
              	}
              }

              tileentityskull.setPlayerProfile(gameprofile);*/
            } else {
              tileentityskull.setType(3); // Botania - Force type to 3 (humanoid)
            }

            tileentityskull.setSkullRotation(i);
            Blocks.SKULL.checkWitherSpawn(worldIn, pos, tileentityskull);
          }

          --stack.stackSize;
          return EnumActionResult.SUCCESS;
        }
      } else {
        return EnumActionResult.FAIL;
      }
    }
  }