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

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

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

World.isRainingAt介绍

暂无

代码示例

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

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

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

  1. public void updateServer(World world, BlockPos coordinates) {
  2. if (world.isRainingAt(coordinates.up())) {
  3. if (hydrationDelay > 0) {
  4. hydrationDelay--;
  5. } else {
  6. ticksSinceRainfall = 0;
  7. }
  8. } else {
  9. hydrationDelay = DELAY_HYDRATION;
  10. if (ticksSinceRainfall < Integer.MAX_VALUE) {
  11. ticksSinceRainfall++;
  12. }
  13. }
  14. }

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

  1. @Override
  2. public boolean isRainingAt(BlockPos strikePosition) {
  3. return getActualWorld().isRainingAt(strikePosition);
  4. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. public boolean shouldBeAtHome() {
  2. if (getAttackTarget() != null || !hasHome()) {
  3. return false;
  4. }
  5. if (world.isRainingAt(getPosition()))
  6. setRainedOn(true);
  7. return shouldSleep() || isWaitingForRainToStop();
  8. }

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

  1. @Override
  2. public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
  3. {
  4. super.updateTick(worldIn, pos, state, rand);
  5. int age = ((Integer)state.getValue(AGE)).intValue();
  6. if (state.getValue(BURNING) == true)
  7. {
  8. if (worldIn.isRainingAt(pos))
  9. {
  10. worldIn.setBlockState(pos, state.withProperty(BURNING, false).withProperty(AGE, 7), 2);
  11. worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
  12. for (int i = 0; i < 8; ++i)
  13. {
  14. 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)});
  15. }
  16. }
  17. if (rand.nextInt(1) == 0)
  18. {
  19. worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(age + 1)), 2);
  20. if (age + 1 == 7)
  21. {
  22. worldIn.setBlockState(pos, state.withProperty(BURNING, false), 2);
  23. }
  24. }
  25. }
  26. }

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

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

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

  1. @Override
  2. public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
  3. {
  4. int current = state.getValue(MOISTURE);
  5. int target = world.isRainingAt(pos.up()) ? MAX_MOISTURE : getWaterScore(world, pos);
  6. if (current < target)
  7. {
  8. if (current < MAX_MOISTURE) world.setBlockState(pos, state.withProperty(MOISTURE, current + 1), 2);
  9. }
  10. else if (current > target || target == 0)
  11. {
  12. if (current > 0) world.setBlockState(pos, state.withProperty(MOISTURE, current - 1), 2);
  13. else if (!hasCrops(world, pos)) turnToDirt(world, pos);
  14. }
  15. super.updateTick(world, pos, state, rand);
  16. }

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

  1. @Override
  2. public EnumMoisture getNaturalMoisture(World world, BlockPos pos) {
  3. float moisture = getBiomeMoisture(world, pos);
  4. for (int offsetX = -1; offsetX < 2; ++offsetX) {
  5. for (int offsetY = -1; offsetY < 2; ++offsetY) {
  6. if (offsetX != 0 || offsetY != 0) {
  7. Block block = world.getBlockState(pos.add(offsetX, 0, offsetY)).getBlock();
  8. if (block == Blocks.SAND) {
  9. moisture -= 1.5;
  10. } else if (block == Blocks.WATER) {
  11. moisture += 1.5;
  12. }
  13. }
  14. }
  15. }
  16. if (world.isRainingAt(pos.up())) {
  17. moisture += 1.5;
  18. }
  19. for (int offsetX = -1; offsetX < 2; ++offsetX) {
  20. for (int offsetY = -1; offsetY < 2; ++offsetY) {
  21. if (offsetX != 0 || offsetY != 0) {
  22. Block block = world.getBlockState(pos.add(offsetX, 0, offsetY)).getBlock();
  23. if (block == Blocks.GRAVEL && moisture > 0.0f) {
  24. moisture *= 0.4f;
  25. }
  26. }
  27. }
  28. }
  29. return EnumMoisture.getFromValue(moisture);
  30. }

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

  1. if (!worldIn.isRainingAt(pos))

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

  1. @Override
  2. public void updateServerSide() {
  3. if (updateOnInterval(20)) {
  4. IErrorLogic errorLogic = getErrorLogic();
  5. BlockPos pos = getPos();
  6. Biome biome = world.getBiome(pos);
  7. errorLogic.setCondition(!biome.canRain(), EnumErrorCode.NO_RAIN_BIOME);
  8. BlockPos posAbove = pos.up();
  9. boolean hasSky = world.canBlockSeeSky(posAbove);
  10. errorLogic.setCondition(!hasSky, EnumErrorCode.NO_SKY_RAIN_TANK);
  11. errorLogic.setCondition(!world.isRainingAt(posAbove), EnumErrorCode.NOT_RAINING);
  12. if (!errorLogic.hasErrors()) {
  13. resourceTank.fillInternal(WATER_PER_UPDATE, true);
  14. }
  15. containerFiller.updateServerSide();
  16. }
  17. if (canDumpBelow == null) {
  18. canDumpBelow = FluidHelper.canAcceptFluid(world, getPos().down(), EnumFacing.UP, STACK_WATER);
  19. }
  20. if (canDumpBelow) {
  21. if (dumpingFluid || updateOnInterval(20)) {
  22. dumpingFluid = dumpFluidBelow();
  23. }
  24. }
  25. }

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

  1. private static TargetWater getRightClickedWater(final EntityPlayer player) {
  2. // first do rain check (cheaper)
  3. if (SyncedConfig.getBooleanValue(GameplayOption.ENABLE_THIRST_RAIN) &&
  4. player.world.isRainingAt(player.getPosition()) &&
  5. (-75.0f > player.rotationPitch) && // 75 degrees is mostly upwards
  6. (player.world.canSeeSky(player.getPosition())))
  7. {
  8. return new TargetWater(null, WaterType.RAIN);
  9. } else if (SyncedConfig.getBooleanValue(GameplayOption.ENABLE_THIRST_WORLD)) {
  10. // do raytrace for liquid blocks within reach distance of player
  11. final Vec3d vecPlayerOrigin = player.getPositionEyes(1.0f);
  12. final Vec3d vecPlayerLook = player.getLook(1.0f);
  13. final double playerReachDistance = player.getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() * 0.5D;
  14. final Vec3d vecPlayerSee = vecPlayerOrigin.addVector(vecPlayerLook.x * playerReachDistance, vecPlayerLook.y * playerReachDistance, vecPlayerLook.z * playerReachDistance);
  15. final RayTraceResult raytraceResult = player.getEntityWorld().rayTraceBlocks(vecPlayerOrigin, vecPlayerSee, true, false, false);
  16. if ((null != raytraceResult) && (RayTraceResult.Type.BLOCK == raytraceResult.typeOfHit)) {
  17. final Block block = player.getEntityWorld().getBlockState(raytraceResult.getBlockPos()).getBlock();
  18. if (block instanceof BlockPurifiedWaterFluid) {
  19. return new TargetWater(raytraceResult.getBlockPos(), WaterType.PURIFIED);
  20. } else if (Blocks.WATER == block) {
  21. return new TargetWater(raytraceResult.getBlockPos(), WaterType.NORMAL);
  22. }
  23. }
  24. }
  25. return null;
  26. }

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

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

相关文章

World类方法