net.minecraft.world.World.isRainingAt()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中net.minecraft.world.World.isRainingAt()方法的一些代码示例,展示了World.isRainingAt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.isRainingAt()方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:isRainingAt

World.isRainingAt介绍

暂无

代码示例

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public boolean isRainingAt(@Nonnull BlockPos strikePosition) {
 return wrapped.isRainingAt(strikePosition);
}

代码示例来源:origin: ForestryMC/ForestryMC

public void updateServer(World world, BlockPos coordinates) {
  if (world.isRainingAt(coordinates.up())) {
    if (hydrationDelay > 0) {
      hydrationDelay--;
    } else {
      ticksSinceRainfall = 0;
    }
  } else {
    hydrationDelay = DELAY_HYDRATION;
    if (ticksSinceRainfall < Integer.MAX_VALUE) {
      ticksSinceRainfall++;
    }
  }
}

代码示例来源:origin: amadornes/MCMultiPart

@Override
public boolean isRainingAt(BlockPos strikePosition) {
  return getActualWorld().isRainingAt(strikePosition);
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public boolean isRaining() {
  BlockPos topCenter = getTopCenterCoord();
  return world.isRainingAt(topCenter.add(0, 2, 0));
}

代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft

@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
  if (worldIn.isRainingAt(pos)) //todo
    worldIn.setBlockState(pos, state.withProperty(LIT, false), 2);
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public boolean isRaining() {
  return world.isRainingAt(getPos().up());
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public boolean isRaining() {
  return world.isRainingAt(getPos().up());
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public boolean isRaining() {
  return world.isRainingAt(getPosition().up());
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public boolean shouldBeAtHome() {
  return (world.provider.hasSkyLight() && !world.isDaytime()) || world.isRainingAt(getPosition());
}

代码示例来源:origin: PenguinSquad/Harvest-Festival

@SuppressWarnings("deprecation")
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
  if (worldIn.isRainingAt(pos.up()) && !worldIn.getBlockState(pos.down()).isFullyOpaque() && rand.nextInt(15) == 1) {
    double d0 = (double) ((float) pos.getX() + rand.nextFloat());
    double d1 = (double) pos.getY() - 0.05D;
    double d2 = (double) ((float) pos.getZ() + rand.nextFloat());
    worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D);
  }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) {
  int i = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face);
  if (random.nextInt(chance) < i && worldIn.isAirBlock(pos)) {//safe fire: only set fire if air
   IBlockState iblockstate = worldIn.getBlockState(pos);
   if (random.nextInt(age + 10) < 5 && !worldIn.isRainingAt(pos)) {
    int j = age + random.nextInt(5) / 4;
    if (j > 15) {
     j = 15;
    }
    worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
   }
   if (iblockstate.getBlock() == Blocks.TNT) {
    Blocks.TNT.onPlayerDestroy(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
   }
  }
 }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

public boolean shouldBeAtHome() {
  if (getAttackTarget() != null || !hasHome()) {
    return false;
  }
  if (world.isRainingAt(getPosition()))
    setRainedOn(true);
  return shouldSleep() || isWaitingForRainToStop();
}

代码示例来源:origin: Glitchfiend/ToughAsNails

@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
  super.updateTick(worldIn, pos, state, rand);
  int age = ((Integer)state.getValue(AGE)).intValue();
  if (state.getValue(BURNING) == true)
  {
    if (worldIn.isRainingAt(pos))
    {
      worldIn.setBlockState(pos, state.withProperty(BURNING, false).withProperty(AGE, 7), 2);
      worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
      for (int i = 0; i < 8; ++i)
      {           
        worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)((float)pos.getX() + 0.75F - (rand.nextFloat() / 2.0F)), (double)((float)pos.getY() + 0.9F), (double)((float)pos.getZ() + 0.75F - (rand.nextFloat() / 2.0F)), 0.0D, 0.0D, 0.0D, new int[] {Block.getStateId(state)});
      }
    }
    if (rand.nextInt(1) == 0)
    {
      worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(age + 1)), 2);
      if (age + 1 == 7)
      {
        worldIn.setBlockState(pos, state.withProperty(BURNING, false), 2);
      }
    }
  }
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
  int moisture = state.getValue(MOISTURE);
  if (!this.hasWater(world, pos) && !world.isRainingAt(pos.up()) && !(world.getBiome(pos) instanceof BiomeSwamp)) {
    if (moisture > 0) {
      world.setBlockState(pos, state.withProperty(MOISTURE, moisture - 1), 2);
    } else {
      world.setBlockState(pos, Blocks.DIRT.getDefaultState());
    }
  } else if (moisture < 7) {
    world.setBlockState(pos, state.withProperty(MOISTURE, 7), 2);
  }
}

代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
{
  int current = state.getValue(MOISTURE);
  int target = world.isRainingAt(pos.up()) ? MAX_MOISTURE : getWaterScore(world, pos);
  if (current < target)
  {
    if (current < MAX_MOISTURE) world.setBlockState(pos, state.withProperty(MOISTURE, current + 1), 2);
  }
  else if (current > target || target == 0)
  {
    if (current > 0) world.setBlockState(pos, state.withProperty(MOISTURE, current - 1), 2);
    else if (!hasCrops(world, pos)) turnToDirt(world, pos);
  }
  super.updateTick(world, pos, state, rand);
}

代码示例来源:origin: ForestryMC/Binnie

@Override
public EnumMoisture getNaturalMoisture(World world, BlockPos pos) {
  float moisture = getBiomeMoisture(world, pos);
  for (int offsetX = -1; offsetX < 2; ++offsetX) {
    for (int offsetY = -1; offsetY < 2; ++offsetY) {
      if (offsetX != 0 || offsetY != 0) {
        Block block = world.getBlockState(pos.add(offsetX, 0, offsetY)).getBlock();
        if (block == Blocks.SAND) {
          moisture -= 1.5;
        } else if (block == Blocks.WATER) {
          moisture += 1.5;
        }
      }
    }
  }
  if (world.isRainingAt(pos.up())) {
    moisture += 1.5;
  }
  for (int offsetX = -1; offsetX < 2; ++offsetX) {
    for (int offsetY = -1; offsetY < 2; ++offsetY) {
      if (offsetX != 0 || offsetY != 0) {
        Block block = world.getBlockState(pos.add(offsetX, 0, offsetY)).getBlock();
        if (block == Blocks.GRAVEL && moisture > 0.0f) {
          moisture *= 0.4f;
        }
      }
    }
  }
  return EnumMoisture.getFromValue(moisture);
}

代码示例来源:origin: Glitchfiend/ToughAsNails

if (!worldIn.isRainingAt(pos))

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public void updateServerSide() {
  if (updateOnInterval(20)) {
    IErrorLogic errorLogic = getErrorLogic();
    BlockPos pos = getPos();
    Biome biome = world.getBiome(pos);
    errorLogic.setCondition(!biome.canRain(), EnumErrorCode.NO_RAIN_BIOME);
    BlockPos posAbove = pos.up();
    boolean hasSky = world.canBlockSeeSky(posAbove);
    errorLogic.setCondition(!hasSky, EnumErrorCode.NO_SKY_RAIN_TANK);
    errorLogic.setCondition(!world.isRainingAt(posAbove), EnumErrorCode.NOT_RAINING);
    if (!errorLogic.hasErrors()) {
      resourceTank.fillInternal(WATER_PER_UPDATE, true);
    }
    containerFiller.updateServerSide();
  }
  if (canDumpBelow == null) {
    canDumpBelow = FluidHelper.canAcceptFluid(world, getPos().down(), EnumFacing.UP, STACK_WATER);
  }
  if (canDumpBelow) {
    if (dumpingFluid || updateOnInterval(20)) {
      dumpingFluid = dumpFluidBelow();
    }
  }
}

代码示例来源:origin: Glitchfiend/ToughAsNails

private static TargetWater getRightClickedWater(final EntityPlayer player) {
  // first do rain check (cheaper)
  if (SyncedConfig.getBooleanValue(GameplayOption.ENABLE_THIRST_RAIN) &&
      player.world.isRainingAt(player.getPosition()) &&
      (-75.0f > player.rotationPitch) && // 75 degrees is mostly upwards
      (player.world.canSeeSky(player.getPosition())))
  {
    return new TargetWater(null, WaterType.RAIN);
  } else if (SyncedConfig.getBooleanValue(GameplayOption.ENABLE_THIRST_WORLD)) {
    // do raytrace for liquid blocks within reach distance of player
    final Vec3d vecPlayerOrigin = player.getPositionEyes(1.0f);
    final Vec3d vecPlayerLook = player.getLook(1.0f);
    final double playerReachDistance = player.getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() * 0.5D;
    final Vec3d vecPlayerSee = vecPlayerOrigin.addVector(vecPlayerLook.x * playerReachDistance, vecPlayerLook.y * playerReachDistance, vecPlayerLook.z * playerReachDistance);
    final RayTraceResult raytraceResult = player.getEntityWorld().rayTraceBlocks(vecPlayerOrigin, vecPlayerSee, true, false, false);
    if ((null != raytraceResult) && (RayTraceResult.Type.BLOCK == raytraceResult.typeOfHit)) {
      final Block block = player.getEntityWorld().getBlockState(raytraceResult.getBlockPos()).getBlock();
      if (block instanceof BlockPurifiedWaterFluid) {
        return new TargetWater(raytraceResult.getBlockPos(), WaterType.PURIFIED);
      } else if (Blocks.WATER == block) {
        return new TargetWater(raytraceResult.getBlockPos(), WaterType.NORMAL);
      }
    }
  }
  return null;
}

代码示例来源:origin: CoFH/ThermalExpansion

isRaining = world.isRainingAt(pos);
timeConstant = getTimeConstant();

相关文章

微信公众号

最新文章

更多

World类方法