Ejemplo n.º 1
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());
            }
          }
        }
      }
    }
  }
Ejemplo n.º 2
0
  public boolean onBlockActivated(
      World worldIn,
      BlockPos pos,
      IBlockState state,
      EntityPlayer playerIn,
      EnumHand hand,
      @Nullable ItemStack heldItem,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    if (((Boolean) state.getValue(OPEN)).booleanValue()) {
      state = state.withProperty(OPEN, Boolean.valueOf(false));
      worldIn.setBlockState(pos, state, 10);
    } else {
      EnumFacing enumfacing = EnumFacing.fromAngle((double) playerIn.rotationYaw);

      if (state.getValue(FACING) == enumfacing.getOpposite()) {
        state = state.withProperty(FACING, enumfacing);
      }

      state = state.withProperty(OPEN, Boolean.valueOf(true));
      worldIn.setBlockState(pos, state, 10);
    }

    worldIn.playEvent(
        playerIn, ((Boolean) state.getValue(OPEN)).booleanValue() ? 1008 : 1014, pos, 0);
    return true;
  }
Ejemplo n.º 3
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);
  }
  @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;
  }
Ejemplo n.º 5
0
  /**
   * Called when a neighboring block was changed and marks that this state should perform any checks
   * during a neighbor change. Cases may include when redstone power is updated, cactus blocks
   * popping off due to a neighboring solid block, etc.
   */
  public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) {
    if (!worldIn.isRemote) {
      boolean flag = worldIn.isBlockPowered(pos);

      if (flag || blockIn.getDefaultState().canProvidePower()) {
        if (flag
            && !((Boolean) state.getValue(OPEN)).booleanValue()
            && !((Boolean) state.getValue(POWERED)).booleanValue()) {
          worldIn.setBlockState(
              pos,
              state
                  .withProperty(OPEN, Boolean.valueOf(true))
                  .withProperty(POWERED, Boolean.valueOf(true)),
              2);
          worldIn.playEvent((EntityPlayer) null, 1008, pos, 0);
        } else if (!flag
            && ((Boolean) state.getValue(OPEN)).booleanValue()
            && ((Boolean) state.getValue(POWERED)).booleanValue()) {
          worldIn.setBlockState(
              pos,
              state
                  .withProperty(OPEN, Boolean.valueOf(false))
                  .withProperty(POWERED, Boolean.valueOf(false)),
              2);
          worldIn.playEvent((EntityPlayer) null, 1014, pos, 0);
        } else if (flag != ((Boolean) state.getValue(POWERED)).booleanValue()) {
          worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(flag)), 2);
        }
      }
    }
  }
 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);
   }
 }
  private void func_176462_k(World world, BlockPos pos, IBlockState state) {
    int newStrength = this.func_176460_j(world, pos, state);
    int oldStrength =
        F.or(
            world.bindTileEntity(
                pos,
                TileEntityComparator.class,
                t -> {
                  int old = t.getOutputSignal();
                  t.setOutputSignal(newStrength);
                  return old;
                }),
            0);

    if (oldStrength != newStrength
        || state.getValue(MODE) == BlockRedstoneComparator.Mode.COMPARE) {
      boolean var9 = this.isPowered(world, pos, state);
      boolean var8 = this.isPowered(state);

      if (var8 && !var9) {
        world.setBlockState(pos, state.withProperty(POWERED, false), 2);
      } else if (!var8 && var9) {
        world.setBlockState(pos, state.withProperty(POWERED, true), 2);
      }

      this.updateRedstoneState(world, pos, state);
    }
  }
 @Override
 public void grow(World world, Random rand, BlockPos pos, IBlockState state) {
   int meta = this.getMetaFromState(state);
   if (meta < getMaxMeta(meta)) {
     int span = getMaxMeta(meta) - meta;
     int newMeta = meta + rand.nextInt(span) + 1;
     if (newMeta != meta) world.setBlockState(pos, this.getStateFromMeta(newMeta));
     meta = newMeta;
   }
   if (meta == 4 && world.isAirBlock(pos.add(0, 1, 0)))
     world.setBlockState(pos.add(0, 1, 0), this.getStateFromMeta(meta + 1));
 }
Ejemplo n.º 9
0
  public void neighborDidChange(
      World world, BlockPos pos, IBlockState state, IBlock neighborBlock) {
    boolean var5 = world.isBlockBeingPowered(pos) || world.isBlockBeingPowered(pos.offsetUp());
    boolean var6 = state.getValue(TRIGGERED);

    if (var5 && !var6) {
      world.scheduleUpdate(pos, this, this.tickRate(world));
      world.setBlockState(pos, state.withProperty(TRIGGERED, true), 4);
    } else if (!var5 && var6) {
      world.setBlockState(pos, state.withProperty(TRIGGERED, false), 4);
    }
  }
Ejemplo n.º 10
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);
        }
      }
    }
  }
Ejemplo n.º 11
0
  /** Called when a Block is right-clicked with this Item */
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer playerIn,
      World worldIn,
      BlockPos pos,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    if (side == EnumFacing.DOWN) {
      return false;
    } else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid()) {
      return false;
    } else {
      pos = pos.offset(side);

      if (!playerIn.canPlayerEdit(pos, side, stack)) {
        return false;
      } else if (!Blocks.standing_sign.canPlaceBlockAt(worldIn, pos)) {
        return false;
      } else if (worldIn.isRemote) {
        return true;
      } else {
        if (side == EnumFacing.UP) {
          int i =
              MathHelper.floor_double(
                      (double) ((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D)
                  & 15;
          worldIn.setBlockState(
              pos,
              Blocks.standing_sign
                  .getDefaultState()
                  .withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)),
              3);
        } else {
          worldIn.setBlockState(
              pos, Blocks.wall_sign.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
        }

        --stack.stackSize;
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntitySign
            && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack)) {
          playerIn.openEditSign((TileEntitySign) tileentity);
        }

        return true;
      }
    }
  }
 public void generateArchEW(World world, Random rand, BlockPos position) {
   int height = 3 + rand.nextInt(1);
   int width = 1 + rand.nextInt(2);
   for (int sides = 0; sides < height; sides++) {
     world.setBlockState(
         position.up(sides).north(width / 2), ModBlocks.frozenCobblestone.getDefaultState(), 3);
     world.setBlockState(
         position.up(sides).south(width / 2), ModBlocks.frozenCobblestone.getDefaultState(), 3);
   }
   for (int way = 0; way < width; way++) {
     world.setBlockState(
         position.up(height).south(way), ModBlocks.frozenCobblestone.getDefaultState(), 3);
   }
 }
Ejemplo n.º 13
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;
    }
  }
Ejemplo n.º 14
0
 @Override
 public void onBlockPlacedBy(
     World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack itemStack) {
   switch (getMetaUsage()) {
     case HORIZROTATION:
       world.setBlockState(
           pos, state.withProperty(FACING_HORIZ, placer.getHorizontalFacing().getOpposite()), 2);
       break;
     case ROTATION:
       world.setBlockState(pos, state.withProperty(FACING, getFacingFromEntity(pos, placer)), 2);
       break;
     case NONE:
       break;
   }
 }
Ejemplo n.º 15
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++;
   }
 }
Ejemplo n.º 16
0
 public void didPlaceBlock(
     World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
   world.setBlockState(
       pos, state.withProperty(FACING, BlockPistonBase.func_180695_a(world, pos, player)), 2);
   world.withTileEntity(
       pos, TileEntityDispenser.class, t -> stack.withDisplayName(t::setCustomName));
 }
 @Override
 public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
   int age = (Integer) state.getValue(AGE);
   if (age < 7 && rand.nextDouble() < this.default_ripeningProbability) {
     worldIn.setBlockState(pos, state.withProperty(AGE, age + 1), 2);
   }
 }
Ejemplo n.º 18
0
 @Override
 public void onBlockPlacedBy(
     World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
   final int angle = MathHelper.floor_double(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
   int change = EnumFacing.getHorizontal(angle).getOpposite().getIndex();
   worldIn.setBlockState(pos, getStateFromMeta(change), 3);
 }
 /*
  * 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;
 }
 void createPlane(World world, BlockPos center, int wdt, IBlockState state) {
   for (int x = -wdt / 2; x < wdt; x++) {
     for (int z = -wdt / 2; z < wdt; z++) {
       world.setBlockState(center.add(x, -1, z), state);
     }
   }
 }
Ejemplo n.º 21
0
  public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    if (rand.nextInt(25) == 0) {
      int var5 = 5;
      boolean var6 = true;
      Iterator var7 = BlockPos.getAllInBoxMutable(pos.add(-4, -1, -4), pos.add(4, 1, 4)).iterator();

      while (var7.hasNext()) {
        BlockPos var8 = (BlockPos) var7.next();

        if (worldIn.getBlockState(var8).getBlock() == this) {
          --var5;

          if (var5 <= 0) {
            return;
          }
        }
      }

      BlockPos var9 =
          pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);

      for (int var10 = 0; var10 < 4; ++var10) {
        if (worldIn.isAirBlock(var9) && this.canBlockStay(worldIn, var9, this.getDefaultState())) {
          pos = var9;
        }

        var9 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
      }

      if (worldIn.isAirBlock(var9) && this.canBlockStay(worldIn, var9, this.getDefaultState())) {
        worldIn.setBlockState(var9, this.getDefaultState(), 2);
      }
    }
  }
Ejemplo n.º 22
0
 public boolean onBlockActivated(
     World worldIn,
     BlockPos pos,
     IBlockState state,
     EntityPlayer playerIn,
     EnumFacing side,
     float hitX,
     float hitY,
     float hitZ) {
   if (((Boolean) state.getValue(POWERED)).booleanValue()) {
     return true;
   } else {
     worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
     worldIn.markBlockRangeForRenderUpdate(pos, pos);
     worldIn.playSoundEffect(
         (double) pos.getX() + 0.5D,
         (double) pos.getY() + 0.5D,
         (double) pos.getZ() + 0.5D,
         "random.click",
         0.3F,
         0.6F);
     this.notifyNeighbors(worldIn, pos, (EnumFacing) state.getValue(FACING));
     worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
     return true;
   }
 }
Ejemplo n.º 23
0
 /**
  * Called when a Block is right-clicked with this Item
  *
  * @param pos The block being right-clicked
  * @param side The side being right-clicked
  */
 public boolean onItemUse(
     ItemStack stack,
     EntityPlayer playerIn,
     World worldIn,
     BlockPos pos,
     EnumFacing side,
     float hitX,
     float hitY,
     float hitZ) {
   if (side != EnumFacing.UP) {
     return false;
   } else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack)) {
     return false;
   } else if (worldIn
           .getBlockState(pos)
           .getBlock()
           .canSustainPlant(worldIn, pos, EnumFacing.UP, this)
       && worldIn.isAirBlock(pos.up())) {
     worldIn.setBlockState(pos.up(), this.crops.getDefaultState());
     --stack.stackSize;
     return true;
   } else {
     return false;
   }
 }
Ejemplo n.º 24
0
        @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));
            }
        }
 @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);
 }
  /* Ticking methods */
  public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
    if (this.powered) {
      world.setBlockState(pos, this.getUnpoweredState(state).withProperty(POWERED, true), 4);
    }

    this.func_176462_k(world, pos, state);
  }
Ejemplo n.º 27
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;
    }
  }
Ejemplo n.º 28
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;
  }
Ejemplo n.º 29
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;
    }
  }
Ejemplo n.º 30
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;
  }