/*
  * This messy function is a work in progress.  It is a temporary setup for
  * placing a custom block from my mod over the door of the given npch.
  *
  * Returns the location of where the sign should be placed.
  *
  * Needs to be rewritten badly.
  */
 public static BlockPos placeBlockOverDoor(
     ItemStack stack,
     EntityPlayer playerIn,
     World worldIn,
     NPCHouse npch,
     String block_name,
     float hitX,
     float hitY,
     float hitZ) {
   String placeMe = ("bh_housing:" + block_name);
   BlockPos door = BlockHelper.findDoor(worldIn, npch);
   if (!door.equals(npch.getCorner(0))) {
     int north = npch.getCorner(0).getZ();
     int south = npch.getCorner(2).getZ();
     int west = npch.getCorner(0).getX();
     int east = npch.getCorner(1).getX();
     BlockPos placeHere = door;
     boolean shouldUse = false;
     EnumFacing direction = EnumFacing.NORTH;
     if (worldIn.getBlockState(placeHere).getBlock() instanceof NPCHouse_Block) {
       return placeHere;
     } else if (door.getX() == west) {
       placeHere = door.up().west();
       direction = EnumFacing.WEST;
     } else if (door.getX() == east) {
       placeHere = door.up().east();
       direction = EnumFacing.EAST;
     } else if (door.getZ() == north) {
       placeHere = door.up().north();
       direction = EnumFacing.NORTH;
     } else if (door.getZ() == south) {
       placeHere = door.up().south();
       direction = EnumFacing.SOUTH;
     }
     shouldUse =
         worldIn.setBlockState(
             placeHere,
             NPCHouse_Block.getBlockFromName(placeMe)
                 .getDefaultState()
                 .withProperty(NPCHouse_Block.FACING, direction),
             3);
     if (shouldUse) {
       --stack.stackSize;
       if (stack.stackSize == 0) {
         playerIn.destroyCurrentEquippedItem();
       }
       if (block_name == "npch_block") {
         NPCHouse_Block npchblock = (NPCHouse_Block) worldIn.getBlockState(placeHere).getBlock();
         npchblock.setNPCHouse(npch);
       }
       IBlockState temp = worldIn.getBlockState(placeHere);
       if (temp.getBlock().getRegistryName() == "npch_block") {
         ItemBlock.setTileEntityNBT(
             worldIn, playerIn, placeHere, new ItemStack(Block.getBlockFromName("npch_block"), 1));
       }
     }
     return placeHere;
   }
   return null;
 }
  protected int getRedstonePower(World world, BlockPos pos, IBlockState state) {
    int var4 = super.getRedstonePower(world, pos, state);
    EnumDirection var5 = state.getValue(DIRECTION);
    BlockPos var6 = pos.offset(var5);
    IBlock var7 = world.getBlockState(var6).getBlock();

    if (var7.hasComparatorInputOverride()) {
      var4 = var7.getComparatorInputOverride(world, var6);
    } else if (var4 < 15 && var7.isNormalCube()) {
      var6 = var6.offset(var5);
      var7 = world.getBlockState(var6).getBlock();

      if (var7.hasComparatorInputOverride()) {
        var4 = var7.getComparatorInputOverride(world, var6);
      } else if (var7.getMaterial() == Material.air) {
        EntityItemFrame var8 = this.func_176461_a(world, var5, var6);

        if (var8 != null) {
          var4 = var8.func_174866_q();
        }
      }
    }

    return var4;
  }
  protected int calculateInputStrength(World worldIn, BlockPos pos, IBlockState state) {
    int i = super.calculateInputStrength(worldIn, pos, state);
    EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
    BlockPos blockpos = pos.offset(enumfacing);
    IBlockState iblockstate = worldIn.getBlockState(blockpos);

    if (iblockstate.hasComparatorInputOverride()) {
      i = iblockstate.getComparatorInputOverride(worldIn, blockpos);
    } else if (i < 15 && iblockstate.isNormalCube()) {
      blockpos = blockpos.offset(enumfacing);
      iblockstate = worldIn.getBlockState(blockpos);

      if (iblockstate.hasComparatorInputOverride()) {
        i = iblockstate.getComparatorInputOverride(worldIn, blockpos);
      } else if (iblockstate.getMaterial() == Material.AIR) {
        EntityItemFrame entityitemframe = this.findItemFrame(worldIn, enumfacing, blockpos);

        if (entityitemframe != null) {
          i = entityitemframe.getAnalogOutput();
        }
      }
    }

    return i;
  }
示例#4
0
  public boolean generate(World worldIn, Random p_180709_2_, BlockPos p_180709_3_) {
    while (worldIn.isAirBlock(p_180709_3_) && p_180709_3_.getY() > 2) {
      p_180709_3_ = p_180709_3_.offsetDown();
    }

    if (worldIn.getBlockState(p_180709_3_).getBlock() != Blocks.snow) {
      return false;
    } else {
      int var4 = p_180709_2_.nextInt(this.field_150554_b - 2) + 2;
      byte var5 = 1;

      for (int var6 = p_180709_3_.getX() - var4; var6 <= p_180709_3_.getX() + var4; ++var6) {
        for (int var7 = p_180709_3_.getZ() - var4; var7 <= p_180709_3_.getZ() + var4; ++var7) {
          int var8 = var6 - p_180709_3_.getX();
          int var9 = var7 - p_180709_3_.getZ();

          if (var8 * var8 + var9 * var9 <= var4 * var4) {
            for (int var10 = p_180709_3_.getY() - var5;
                var10 <= p_180709_3_.getY() + var5;
                ++var10) {
              BlockPos var11 = new BlockPos(var6, var10, var7);
              Block var12 = worldIn.getBlockState(var11).getBlock();

              if (var12 == Blocks.dirt || var12 == Blocks.snow || var12 == Blocks.ice) {
                worldIn.setBlockState(var11, this.field_150555_a.getDefaultState(), 2);
              }
            }
          }
        }
      }

      return true;
    }
  }
示例#5
0
  public boolean generate(World worldIn, Random rand, BlockPos position) {
    for (int i = 0; i < 20; ++i) {
      BlockPos blockpos =
          position.add(rand.nextInt(4) - rand.nextInt(4), 0, rand.nextInt(4) - rand.nextInt(4));

      if (worldIn.isAirBlock(blockpos)) {
        BlockPos blockpos1 = blockpos.down();

        if (worldIn.getBlockState(blockpos1.west()).getBlock().getMaterial() == Material.water
            || worldIn.getBlockState(blockpos1.east()).getBlock().getMaterial() == Material.water
            || worldIn.getBlockState(blockpos1.north()).getBlock().getMaterial() == Material.water
            || worldIn.getBlockState(blockpos1.south()).getBlock().getMaterial()
                == Material.water) {
          int j = 2 + rand.nextInt(rand.nextInt(3) + 1);

          for (int k = 0; k < j; ++k) {
            if (Blocks.reeds.canBlockStay(worldIn, blockpos)) {
              worldIn.setBlockState(blockpos.up(k), Blocks.reeds.getDefaultState(), 2);
            }
          }
        }
      }
    }

    return true;
  }
示例#6
0
  public boolean generate(World worldIn, Random rand, BlockPos position) {
    if (worldIn.getBlockState(position).getBlock().getMaterial() != Material.water) {
      return false;
    } else {
      int i = rand.nextInt(this.numberOfBlocks - 2) + 2;
      int j = 1;

      for (int k = position.getX() - i; k <= position.getX() + i; ++k) {
        for (int l = position.getZ() - i; l <= position.getZ() + i; ++l) {
          int i1 = k - position.getX();
          int j1 = l - position.getZ();

          if (i1 * i1 + j1 * j1 <= i * i) {
            for (int k1 = position.getY() - j; k1 <= position.getY() + j; ++k1) {
              BlockPos blockpos = new BlockPos(k, k1, l);
              Block block = worldIn.getBlockState(blockpos).getBlock();

              if (block == Blocks.dirt || block == Blocks.clay) {
                worldIn.setBlockState(blockpos, this.field_150546_a.getDefaultState(), 2);
              }
            }
          }
        }
      }

      return true;
    }
  }
示例#7
0
 @Override
 public void onNeighborBlockChange(
     World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
   if (worldIn.getBlockState(pos).getValue(META_PROPERTY) == WoodType.Palm
       && worldIn.getBlockState(pos.down()).getBlock() != TFCBlocks.LogNatural2) {
     worldIn.setBlockState(pos, Blocks.air.getDefaultState());
   }
 }
示例#8
0
 public Vector blockToWorldSpace(World world, BlockPos pos, Vector v) {
   switch (getMetaUsage()) {
     case HORIZROTATION:
       return BlockTools.blockToWorldSpaceHoriz(v, world.getBlockState(pos));
     case ROTATION:
       return BlockTools.blockToWorldSpace(v, world.getBlockState(pos));
     case NONE:
     default:
       return v;
   }
 }
 private boolean checkGround(World w, BlockPos pos) {
   Block b = w.getBlockState(pos).getBlock();
   Material m = b.getMaterial();
   if (m.isLiquid()) {
     return false;
   }
   if (m == Material.air || m == Material.vine) {
     w.setBlockState(pos, w.getBlockState(pos.down()));
     return true;
   }
   return b.isNormalCube();
 }
示例#10
0
 @Override
 public EnumFacing worldToBlockSpace(World world, BlockPos pos, EnumFacing side) {
   switch (getMetaUsage()) {
     case HORIZROTATION:
       return BlockTools.worldToBlockSpaceHoriz(side, world.getBlockState(pos));
     case ROTATION:
       return BlockTools.worldToBlockSpace(side, world.getBlockState(pos));
     case NONE:
     default:
       return side;
   }
 }
  @Override
  public void onNeighborBlockChange(
      World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
    if (worldIn.getBlockState(pos.up()).getBlock() != null) {
      if (worldIn.getBlockState(pos.up()).getBlock() == CookingPlusMain.blockBananaLeaves) {

      } else {
        dropBlockAsItem(worldIn, pos, state, 0);
        worldIn.setBlockToAir(pos);
      }
    }
  }
示例#12
0
  private void spawnRubble(Random random, int chunkX, int chunkZ, World world) {

    // Spawn above ground
    for (int i = 0; i < random.nextInt(ROCK_TRIES); i++) {
      int x = chunkX * 16 + random.nextInt(16);
      int z = chunkZ * 16 + random.nextInt(16);
      BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).down();
      Block block = world.getBlockState(pos).getBlock();
      if (isRockSpawnable(block)) {
        if (world.isAirBlock(pos.up())) {
          world.setBlockState(
              pos.up(),
              ModBlocks.rockBlock
                  .getDefaultState()
                  .withProperty(
                      GenericBlock.FACING_HORIZ, EnumFacing.getHorizontal(random.nextInt(4))),
              3);
        }
      }
    }
    for (int i = 0; i < random.nextInt(STICK_TRIES); i++) {
      int x = chunkX * 16 + random.nextInt(16);
      int z = chunkZ * 16 + random.nextInt(16);
      BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).down();
      Block block = world.getBlockState(pos).getBlock();
      if (isStickSpawnable(block)) {
        trySpawnSticks(world, pos, random);
      }
    }

    // Spawn in caves
    for (int i = 0; i < random.nextInt(ROCK_TRIES); i++) {
      int x = chunkX * 16 + random.nextInt(16);
      int z = chunkZ * 16 + random.nextInt(16);
      BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).down();
      int y = findCaveSpot(world, pos);
      pos = new BlockPos(x, y, z);
      Block block = world.getBlockState(pos).getBlock();
      if (y != -1 && isRockSpawnable(block)) {
        if (world.isAirBlock(pos.up())) {
          world.setBlockState(
              pos.up(),
              ModBlocks.rockBlock
                  .getDefaultState()
                  .withProperty(
                      GenericBlock.FACING_HORIZ, EnumFacing.getHorizontal(random.nextInt(4))),
              3);
        }
      }
    }
  }
示例#13
0
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer playerIn,
      World worldIn,
      BlockPos pos,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    IBlockState var9 = worldIn.getBlockState(pos);
    Block var10 = var9.getBlock();
    if (var10 == Blocks.snow_layer
        && ((Integer) var9.getValue(BlockSnow.LAYERS_PROP)).intValue() < 1) {
      side = EnumFacing.UP;
    } else if (!var10.isReplaceable(worldIn, pos)) {
      pos = pos.offset(side);
    }

    if (stack.stackSize == 0) {
      return false;
    } else if (!playerIn.func_175151_a(pos, side, stack)) {
      return false;
    } else if (pos.getY() == 255 && this.block.getMaterial().isSolid()) {
      return false;
    } else if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity) null, stack)) {
      int var11 = this.getMetadata(stack.getMetadata());
      IBlockState var12 =
          this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, var11, playerIn);
      if (worldIn.setBlockState(pos, var12, 3)) {
        var12 = worldIn.getBlockState(pos);
        if (var12.getBlock() == this.block) {
          setTileEntityNBT(worldIn, pos, stack);
          this.block.onBlockPlacedBy(worldIn, pos, var12, playerIn, stack);
        }

        worldIn.playSoundEffect(
            (double) ((float) pos.getX() + 0.5F),
            (double) ((float) pos.getY() + 0.5F),
            (double) ((float) pos.getZ() + 0.5F),
            this.block.stepSound.getPlaceSound(),
            (this.block.stepSound.getVolume() + 1.0F) / 2.0F,
            this.block.stepSound.getFrequency() * 0.8F);
        --stack.stackSize;
      }

      return true;
    } else {
      return false;
    }
  }
示例#14
0
  public static void placeDoor(World worldIn, BlockPos pos, EnumFacing facing, Block door) {
    BlockPos blockpos = pos.offset(facing.rotateY());
    BlockPos blockpos1 = pos.offset(facing.rotateYCCW());
    int i =
        (worldIn.getBlockState(blockpos1).getBlock().isNormalCube() ? 1 : 0)
            + (worldIn.getBlockState(blockpos1.up()).getBlock().isNormalCube() ? 1 : 0);
    int j =
        (worldIn.getBlockState(blockpos).getBlock().isNormalCube() ? 1 : 0)
            + (worldIn.getBlockState(blockpos.up()).getBlock().isNormalCube() ? 1 : 0);
    boolean flag =
        worldIn.getBlockState(blockpos1).getBlock() == door
            || worldIn.getBlockState(blockpos1.up()).getBlock() == door;
    boolean flag1 =
        worldIn.getBlockState(blockpos).getBlock() == door
            || worldIn.getBlockState(blockpos.up()).getBlock() == door;
    boolean flag2 = false;

    if (flag && !flag1 || j > i) {
      flag2 = true;
    }

    BlockPos blockpos2 = pos.up();
    IBlockState iblockstate =
        door.getDefaultState()
            .withProperty(BlockDoor.FACING, facing)
            .withProperty(
                BlockDoor.HINGE,
                flag2 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT);
    worldIn.setBlockState(
        pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2);
    worldIn.setBlockState(
        blockpos2, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2);
    worldIn.notifyNeighborsOfStateChange(pos, door);
    worldIn.notifyNeighborsOfStateChange(blockpos2, door);
  }
示例#15
0
  public boolean generate(World worldIn, Random p_180709_2_, BlockPos p_180709_3_) {
    if (worldIn.getBlockState(p_180709_3_.offsetUp()).getBlock() != Blocks.netherrack) {
      return false;
    } else if (worldIn.getBlockState(p_180709_3_).getBlock().getMaterial() != Material.air
        && worldIn.getBlockState(p_180709_3_).getBlock() != Blocks.netherrack) {
      return false;
    } else {
      int var4 = 0;

      if (worldIn.getBlockState(p_180709_3_.offsetWest()).getBlock() == Blocks.netherrack) {
        ++var4;
      }

      if (worldIn.getBlockState(p_180709_3_.offsetEast()).getBlock() == Blocks.netherrack) {
        ++var4;
      }

      if (worldIn.getBlockState(p_180709_3_.offsetNorth()).getBlock() == Blocks.netherrack) {
        ++var4;
      }

      if (worldIn.getBlockState(p_180709_3_.offsetSouth()).getBlock() == Blocks.netherrack) {
        ++var4;
      }

      if (worldIn.getBlockState(p_180709_3_.offsetDown()).getBlock() == Blocks.netherrack) {
        ++var4;
      }

      int var5 = 0;

      if (worldIn.isAirBlock(p_180709_3_.offsetWest())) {
        ++var5;
      }

      if (worldIn.isAirBlock(p_180709_3_.offsetEast())) {
        ++var5;
      }

      if (worldIn.isAirBlock(p_180709_3_.offsetNorth())) {
        ++var5;
      }

      if (worldIn.isAirBlock(p_180709_3_.offsetSouth())) {
        ++var5;
      }

      if (worldIn.isAirBlock(p_180709_3_.offsetDown())) {
        ++var5;
      }

      if (!this.field_94524_b && var4 == 4 && var5 == 1 || var4 == 5) {
        worldIn.setBlockState(p_180709_3_, this.field_150553_a.getDefaultState(), 2);
        worldIn.func_175637_a(this.field_150553_a, p_180709_3_, p_180709_2_);
      }

      return true;
    }
  }
示例#16
0
  public boolean generate(World worldIn, Random rand, BlockPos position) {
    if (worldIn.isAirBlock(position)
        && worldIn.getBlockState(position.down()).getBlock() == this.baseBlockRequired) {
      int i = rand.nextInt(32) + 6;
      int j = rand.nextInt(4) + 1;
      BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

      for (int k = position.getX() - j; k <= position.getX() + j; ++k) {
        for (int l = position.getZ() - j; l <= position.getZ() + j; ++l) {
          int i1 = k - position.getX();
          int j1 = l - position.getZ();

          if (i1 * i1 + j1 * j1 <= j * j + 1
              && worldIn
                      .getBlockState(blockpos$mutableblockpos.set(k, position.getY() - 1, l))
                      .getBlock()
                  != this.baseBlockRequired) {
            return false;
          }
        }
      }

      for (int l1 = position.getY(); l1 < position.getY() + i && l1 < 256; ++l1) {
        for (int i2 = position.getX() - j; i2 <= position.getX() + j; ++i2) {
          for (int j2 = position.getZ() - j; j2 <= position.getZ() + j; ++j2) {
            int k2 = i2 - position.getX();
            int k1 = j2 - position.getZ();

            if (k2 * k2 + k1 * k1 <= j * j + 1) {
              worldIn.setBlockState(new BlockPos(i2, l1, j2), Blocks.obsidian.getDefaultState(), 2);
            }
          }
        }
      }

      Entity entity = new EntityEnderCrystal(worldIn);
      entity.setLocationAndAngles(
          (double) ((float) position.getX() + 0.5F),
          (double) (position.getY() + i),
          (double) ((float) position.getZ() + 0.5F),
          rand.nextFloat() * 360.0F,
          0.0F);
      worldIn.spawnEntityInWorld(entity);
      worldIn.setBlockState(position.up(i), Blocks.bedrock.getDefaultState(), 2);
      return true;
    } else {
      return false;
    }
  }
 // Only call if world is remote
 private static BlockPos iterateDownFromTop(World w, BlockPos pos) {
   pos = pos.offset(EnumFacing.DOWN, 1);
   while ((w.isAirBlock(pos) || w.getBlockState(pos) instanceof BlockFire) && pos.getY() > -1) {
     pos = pos.offset(EnumFacing.DOWN, 1);
   }
   return pos.up(1);
 }
示例#18
0
  public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    if (this.blockMaterial == Material.lava) {
      if (worldIn.getGameRules().getGameRuleBooleanValue("doFireTick")) {
        int var5 = rand.nextInt(3);

        if (var5 > 0) {
          BlockPos var6 = pos;

          for (int var7 = 0; var7 < var5; ++var7) {
            var6 = var6.add(rand.nextInt(3) - 1, 1, rand.nextInt(3) - 1);
            Block var8 = worldIn.getBlockState(var6).getBlock();

            if (var8.blockMaterial == Material.air) {
              if (this.isSurroundingBlockFlammable(worldIn, var6)) {
                worldIn.setBlockState(var6, Blocks.fire.getDefaultState());
                return;
              }
            } else if (var8.blockMaterial.blocksMovement()) {
              return;
            }
          }
        } else {
          for (int var9 = 0; var9 < 3; ++var9) {
            BlockPos var10 = pos.add(rand.nextInt(3) - 1, 0, rand.nextInt(3) - 1);

            if (worldIn.isAirBlock(var10.offsetUp()) && this.getCanBlockBurn(worldIn, var10)) {
              worldIn.setBlockState(var10.offsetUp(), Blocks.fire.getDefaultState());
            }
          }
        }
      }
    }
  }
 @Override
 public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
   IBlockState soil = worldIn.getBlockState(pos.down());
   return super.canPlaceBlockAt(worldIn, pos)
       && soil.getBlock()
           .canSustainPlant(soil, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this);
 }
 float getGrowthSpeed(World world, BlockPos pos, IBlockState sate, int light) {
   float growth = 0.125f * (light - 11);
   if (world.canBlockSeeSky(pos)) growth += 2f;
   IBlockState soil = world.getBlockState(pos.add(0, -1, 0));
   if (soil.getBlock().isFertile(world, pos.add(0, -1, 0))) growth *= 1.5f;
   return 1f + growth;
 }
 public void generateGoldPile(World world, Random rand, BlockPos position) {
   int height = 1 + new Random().nextInt(7);
   int chance = rand.nextInt(100);
   if (chance < 20) {
     world.setBlockState(
         position,
         Blocks.CHEST
             .getDefaultState()
             .withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[new Random().nextInt(3)]),
         3);
     if (world.getBlockState(position).getBlock() instanceof BlockChest) {
       TileEntity tileentity1 = world.getTileEntity(position);
       if (tileentity1 instanceof TileEntityChest
           && !((TileEntityChest) tileentity1).isInvalid()) {
         ((TileEntityChest) tileentity1)
             .setLootTable(WorldGenIceDragonCave.ICEDRAGON_CHEST, new Random().nextLong());
       }
     }
   } else {
     world.setBlockState(
         position,
         ModBlocks.silverPile.getDefaultState().withProperty(BlockGoldPile.LAYERS, height),
         3);
   }
 }
  @Override
  public boolean onBlockActivated(
      World world,
      BlockPos pos,
      IBlockState state,
      EntityPlayer player,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    state = world.getBlockState(pos);
    int i = ((Integer) state.getValue(COLOR)).intValue();
    if (world.isBlockPowered(pos)) {
      world.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)));
    }

    if (((Boolean) state.getValue(POWERED)).booleanValue() == true) {
      if (i < 3) {
        world.setBlockState(pos, state.withProperty(COLOR, i + 1));
      } else if (i == 3) {
        world.setBlockState(pos, state.withProperty(COLOR, 0));
      } else {
        return false;
      }
    } else {
      return false;
    }

    return true;
  }
示例#23
0
  public boolean onItemUse(
      ItemStack par1ItemStack,
      EntityPlayer par2EntityPlayer,
      World par3World,
      BlockPos pos,
      EnumFacing par5EnumFacing,
      float hitX,
      float hitY,
      float hitZ) {
    if (!par3World.isRemote) {
      if (BlockUtils.getBlock(par3World, pos) == mod_SecurityCraft.frame) {
        String owner = ((IOwnable) par3World.getTileEntity(pos)).getOwnerName();
        String uuid = ((IOwnable) par3World.getTileEntity(pos)).getOwnerUUID();
        EnumFacing enumfacing =
            (EnumFacing) par3World.getBlockState(pos).getValue(BlockKeypad.FACING);
        par3World.setBlockState(
            pos,
            mod_SecurityCraft
                .Keypad
                .getDefaultState()
                .withProperty(BlockKeypad.FACING, enumfacing)
                .withProperty(BlockKeypad.POWERED, false));
        ((IOwnable) par3World.getTileEntity(pos)).setOwner(uuid, owner);
        par1ItemStack.stackSize -= 1;
      }

      return true;
    }

    return false;
  }
  public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
    MovingObjectPosition var4 = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, false);
    if (var4 != null
        && var4.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK
        && worldIn.getBlockState(var4.func_178782_a()).getBlock() == Blocks.end_portal_frame) {
      return itemStackIn;
    } else {
      if (!worldIn.isRemote) {
        BlockPos var5 = worldIn.func_180499_a("Stronghold", new BlockPos(playerIn));
        if (var5 != null) {
          EntityEnderEye var6 =
              new EntityEnderEye(worldIn, playerIn.posX, playerIn.posY, playerIn.posZ);
          var6.func_180465_a(var5);
          worldIn.spawnEntityInWorld(var6);
          worldIn.playSoundAtEntity(
              playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
          worldIn.playAuxSFXAtEntity((EntityPlayer) null, 1002, new BlockPos(playerIn), 0);
          if (!playerIn.capabilities.isCreativeMode) {
            --itemStackIn.stackSize;
          }

          playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
        }
      }

      return itemStackIn;
    }
  }
示例#25
0
 /**
  * Return an {@link AxisAlignedBB} that controls the visible scope of a {@link
  * TileEntitySpecialRenderer} associated with this {@link TileEntity} Defaults to the collision
  * bounding box {@link Block#getCollisionBoundingBoxFromPool(World, int, int, int)} associated
  * with the block at this location.
  *
  * @return an appropriately size {@link AxisAlignedBB} for the {@link TileEntity}
  */
 @SideOnly(Side.CLIENT)
 public net.minecraft.util.math.AxisAlignedBB getRenderBoundingBox() {
   net.minecraft.util.math.AxisAlignedBB bb = INFINITE_EXTENT_AABB;
   Block type = getBlockType();
   BlockPos pos = getPos();
   if (type == Blocks.ENCHANTING_TABLE) {
     bb = new net.minecraft.util.math.AxisAlignedBB(pos, pos.add(1, 1, 1));
   } else if (type == Blocks.CHEST || type == Blocks.TRAPPED_CHEST) {
     bb = new net.minecraft.util.math.AxisAlignedBB(pos.add(-1, 0, -1), pos.add(2, 2, 2));
   } else if (type != null && type != Blocks.BEACON) {
     net.minecraft.util.math.AxisAlignedBB cbb = null;
     try {
       cbb =
           worldObj
               .getBlockState(getPos())
               .getCollisionBoundingBox(worldObj, pos)
               .addCoord(pos.getX(), pos.getY(), pos.getZ());
     } catch (Exception e) {
       // We have to capture any exceptions that may occur here because BUKKIT servers like to send
       // the tile entity data BEFORE the chunk data, you know, the OPPOSITE of what vanilla does!
       // So we can not GARENTEE that the world state is the real state for the block...
       // So, once again in the long line of US having to accommodate BUKKIT breaking things,
       // here it is, assume that the TE is only 1 cubic block. Problem with this is that it may
       // cause the TileEntity renderer to error further down the line! But alas, nothing we can
       // do.
       cbb =
           new net.minecraft.util.math.AxisAlignedBB(
               getPos().add(-1, 0, -1), getPos().add(1, 1, 1));
     }
     if (cbb != null) bb = cbb;
   }
   return bb;
 }
 @Override
 protected void generateStalagmiteBase(World world, Random random, BlockPos botY, int aux) {
   if (world.getBlockState(botY.down()) == Blocks.stone)
     world.setBlockState(botY.down(), Blocks.sandstone.getDefaultState(), 2);
   super.generateStalagmiteBase(world, random, botY, aux);
   Utils.convertToSandType(world, random, botY);
 }
示例#27
0
 private void trySpawnSticks(World world, BlockPos pos, Random random) {
   int x = pos.getX();
   int y = pos.getY();
   int z = pos.getZ();
   y++;
   if (!world.isAirBlock(new BlockPos(x, y, z))) {
     return;
   }
   y++;
   if (!BlockTools.isTopValidAndSolid(world, pos)) {
     return;
   }
   for (int i = 0; i < 15; i++) {
     if (!world.isAirBlock(new BlockPos(x, y, z))) {
       if (isLeafBlock(world.getBlockState(new BlockPos(x, y, z)).getBlock())) {
         world.setBlockState(
             pos.up(),
             ModBlocks.sticksBlock
                 .getDefaultState()
                 .withProperty(
                     GenericBlock.FACING_HORIZ, EnumFacing.getHorizontal(random.nextInt(4))),
             3);
         SticksTE sticksTE = (SticksTE) world.getTileEntity(pos.up());
         sticksTE.setSticks(random.nextInt(6) + 1);
       }
       return;
     }
     y++;
   }
 }
        @Override
        /**
         * Updates the task
         */
        public void updateTask()
        {
            Random random = this.field_179473_a.getRNG();
            World world = this.field_179473_a.worldObj;
            int i = MathHelper.floor_double(this.field_179473_a.posX - 2.0D + random.nextDouble() * 4.0D);
            int j = MathHelper.floor_double(this.field_179473_a.posY + random.nextDouble() * 3.0D);
            int k = MathHelper.floor_double(this.field_179473_a.posZ - 2.0D + random.nextDouble() * 4.0D);
            BlockPos blockpos = new BlockPos(i, j, k);
            IBlockState iblockstate = world.getBlockState(blockpos);
            Block block = iblockstate.getBlock();

            if (EntityChaoticEnderman.carriableBlocks.contains(block))
            {
            	int blockMeta = ModBlocks.chaos_Block.getMetaFromState(iblockstate);
            	if (block != ModBlocks.chaos_Block || (blockMeta < 4)) {
            		this.field_179473_a.func_175490_a(iblockstate);
            		world.setBlockState(blockpos, Blocks.air.getDefaultState());
            	} else
            		this.field_179473_a.func_175490_a(ModBlocks.chaos_Block.getStateFromMeta((world.rand.nextFloat() >= 0.2F ?
            			13 : 14) + blockMeta < 2 ? 0 : 1));
            }
        }
 public void generateStructures(World world, Random rand, BlockPos position, int radius) {
   for (int i = 0; radius >= 0 && i < 3; ++i) {
     int j = radius + rand.nextInt(2);
     int k = (radius + rand.nextInt(2));
     int l = radius + rand.nextInt(2);
     float f = (float) (j + k + l) * 0.333F + 0.5F;
     for (BlockPos blockpos :
         BlockPos.getAllInBox(position.add(-j, -k, -l), position.add(j, k, l))) {
       if (blockpos.distanceSq(position) <= (double) (f * f)
           && world.isAirBlock(blockpos)
           && world
               .getBlockState(blockpos.down())
               .getBlock()
               .getUnlocalizedName()
               .contains("frozen")) {
         int chance = rand.nextInt(100);
         if (chance < 4) {
           int chance2 = rand.nextInt(20);
           System.out.println(chance2);
           switch (chance2) {
             default:
               generateGoldPile(world, rand, blockpos);
               break;
             case 1:
               generateArchNS(world, rand, blockpos);
               break;
             case 2:
               generateArchEW(world, rand, blockpos);
               break;
           }
         }
       }
     }
   }
 }
 private boolean onPlayerPlaceBlock(
     PlayerControllerMP controller,
     EntityPlayer player,
     ItemStack offhand,
     BlockPos pos,
     EnumFacing l,
     Vec3 hitVec) {
   final World worldObj = player.worldObj;
   if (!worldObj.getWorldBorder().contains(pos)) {
     return false;
   }
   float f = (float) hitVec.xCoord - (float) pos.getX();
   float f1 = (float) hitVec.yCoord - (float) pos.getY();
   float f2 = (float) hitVec.zCoord - (float) pos.getZ();
   boolean flag = false;
   if (!controller.isSpectatorMode()) {
     if (offhand.getItem().onItemUseFirst(offhand, player, worldObj, pos, l, f, f1, f2)) {
       return true;
     }
     if (!player.isSneaking()
         || player.getCurrentEquippedItem() == null
         || player.getCurrentEquippedItem().getItem().doesSneakBypassUse(worldObj, pos, player)) {
       IBlockState b = worldObj.getBlockState(pos);
       if (!b.getBlock().isAir(worldObj, pos)
           && b.getBlock().onBlockActivated(worldObj, pos, b, player, l, f, f1, f2)) {
         flag = true;
       }
     }
     if (!flag && offhand.getItem() instanceof ItemBlock) {
       ItemBlock itemblock = (ItemBlock) offhand.getItem();
       if (!itemblock.canPlaceBlockOnSide(worldObj, pos, l, player, offhand)) {
         return false;
       }
     }
   }
   Battlegear.packetHandler.sendPacketToServer(
       new OffhandPlaceBlockPacket(pos, l, offhand, f, f1, f2).generatePacket());
   if (flag || controller.isSpectatorMode()) {
     return true;
   } else if (offhand == null) {
     return false;
   } else {
     if (controller.isInCreativeMode()) {
       int i1 = offhand.getMetadata();
       int j1 = offhand.stackSize;
       boolean flag1 = offhand.onItemUse(player, worldObj, pos, l, f, f1, f2);
       offhand.setItemDamage(i1);
       offhand.stackSize = j1;
       return flag1;
     } else {
       if (!offhand.onItemUse(player, worldObj, pos, l, f, f1, f2)) {
         return false;
       }
       if (offhand.stackSize <= 0) {
         ForgeEventFactory.onPlayerDestroyItem(player, offhand);
       }
       return true;
     }
   }
 }