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

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

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

World.isDaytime介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void update() {
  3. boolean state = world.getBlockState(getPos()).getValue(BotaniaStateProps.POWERED);
  4. if(!world.isRemote) {
  5. boolean newState = !world.isDaytime();
  6. if(newState != state) {
  7. world.setBlockState(getPos(), world.getBlockState(getPos()).withProperty(BotaniaStateProps.POWERED, newState), 1 | 2);
  8. state = newState;
  9. }
  10. }
  11. if(state) {
  12. double radius = 512;
  13. int iter = 2;
  14. for(int i = 0; i < iter; i++) {
  15. double x = pos.getX() + 0.5 + (Math.random() - 0.5) * radius;
  16. double y = Math.min(256, pos.getY() + Botania.proxy.getClientRenderDistance() * 16);
  17. double z = pos.getZ() + 0.5 + (Math.random() - 0.5) * radius;
  18. float w = 0.6F;
  19. float c = 1F - w;
  20. float r = w + (float) Math.random() * c;
  21. float g = w + (float) Math.random() * c;
  22. float b = w + (float) Math.random() * c;
  23. float s = 20F + (float) Math.random() * 20F;
  24. int m = 50;
  25. Botania.proxy.sparkleFX(x, y, z, r, g, b, s, m);
  26. }
  27. }
  28. }

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

  1. @Override
  2. public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1, IClimateProvider climate) {
  3. if (world.isDaytime() == daytime) {
  4. return 1;
  5. }
  6. return 0;
  7. }

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

  1. @Override
  2. public boolean isDaytime() {
  3. return wrapped.isDaytime();
  4. }

代码示例来源:origin: Alex-the-666/Ice_and_Fire

  1. public boolean isDaytime() {
  2. return this.world.isDaytime();
  3. }

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

  1. @Override
  2. public int getBlockLightValue() {
  3. return getWorld().isDaytime() ? 15 : 0; // hives may have the sky obstructed but should still be active
  4. }

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

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

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

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

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

  1. private boolean canFly(World world) {
  2. return (!world.isRaining() || getGenome().getTolerantFlyer()) &&
  3. isActiveThisTime(world.isDaytime());
  4. }

代码示例来源:origin: Silentine/GrimoireOfGaia

  1. @Override
  2. public void onLivingUpdate() {
  3. if (world.isDaytime() && !world.isRemote) {
  4. float f = getBrightness();
  5. if (f > 0.5F && rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && world.canSeeSky(getPosition())) {
  6. setFire(8);
  7. attackEntityFrom(DamageSource.OUT_OF_WORLD, EntityAttributes.MAX_HEALTH_2 * 0.25F);
  8. }
  9. }
  10. super.onLivingUpdate();
  11. }

代码示例来源:origin: Silentine/GrimoireOfGaia

  1. @Override
  2. public void onLivingUpdate() {
  3. if (world.isDaytime() && !world.isRemote) {
  4. float f = getBrightness();
  5. if (f > 0.5F && rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && world.canSeeSky(getPosition())) {
  6. setFire(8);
  7. attackEntityFrom(DamageSource.OUT_OF_WORLD, EntityAttributes.MAX_HEALTH_1 * 0.10F);
  8. }
  9. }
  10. super.onLivingUpdate();
  11. }

代码示例来源:origin: TeamLapen/Vampirism

  1. @Override
  2. public boolean getCanSpawnHere() {
  3. if (isGettingSundamage(true) || (world.isDaytime() && rand.nextInt(5) != 0)) return false;
  4. if (isGettingGarlicDamage(true) != EnumStrength.NONE) return false;
  5. if (world.getVillageCollection().getNearestVillage(getPosition(), 1) != null) {
  6. if (getRNG().nextInt(60) != 0) {
  7. return false;
  8. }
  9. }
  10. return super.getCanSpawnHere() && (!restrictedSpawn || getCanSpawnHereRestricted());
  11. }

代码示例来源:origin: GregTechCE/GregTech

  1. private boolean canSeeSunClearly(World world, BlockPos blockPos) {
  2. if(!world.canSeeSky(blockPos)) {
  3. return false;
  4. }
  5. if(world.isRaining()) {
  6. Biome biome = world.getBiome(blockPos);
  7. if(biome.canRain() || biome.getEnableSnow()) {
  8. return false;
  9. }
  10. }
  11. return world.isDaytime();
  12. }
  13. }

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

  1. private void doSunBurn() {
  2. if (burnsInSun() && world.isDaytime() && !world.isRemote) {
  3. float brightness = getBrightness();
  4. BlockPos blockpos = getRidingEntity() instanceof EntityBoat ? (new BlockPos(posX, (double) Math.round(posY), posZ)).up() : new BlockPos(posX, Math.round(posY), posZ);
  5. if (brightness > 0.5F && rand.nextFloat() * 30.0F < (brightness - 0.4F) * 2.0F && world.canSeeSky(blockpos)) {
  6. ItemStack helmet = getItemStackFromSlot(EntityEquipmentSlot.HEAD);
  7. if (helmet.isEmpty()) {
  8. setFire(8);
  9. } else {
  10. damageHelmet(helmet);
  11. }
  12. }
  13. }
  14. }

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

  1. @Override
  2. public void playLivingSound() {
  3. if (!world.isRemote || world.isDaytime() || getAttackTarget() != null) {
  4. return;
  5. }
  6. playSound(getAmbientSound(), getSoundVolume() * ZooConfig.owlHootVolumeMultiplier.get(), 0.8f * getSoundPitch());
  7. }

代码示例来源:origin: Silentine/GrimoireOfGaia

  1. @Override
  2. protected void updateAITasks() {
  3. if (isWet()) {
  4. attackEntityFrom(DamageSource.DROWN, 1.0F);
  5. }
  6. if (world.isDaytime() && ticksExisted >= targetChangeTime + 600) {
  7. float f = getBrightness();
  8. if (f > 0.5F && world.canSeeSky(new BlockPos(this)) && rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
  9. setAttackTarget(null);
  10. teleportRandomly();
  11. }
  12. }
  13. super.updateAITasks();
  14. }

代码示例来源:origin: Silentine/GrimoireOfGaia

  1. @Override
  2. protected void updateAITasks() {
  3. if (isWet()) {
  4. attackEntityFrom(DamageSource.DROWN, 1.0F);
  5. }
  6. if (world.isDaytime() && ticksExisted >= targetChangeTime + 600) {
  7. float f = getBrightness();
  8. if (f > 0.5F && world.canSeeSky(new BlockPos(this)) && rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
  9. setAttackTarget(null);
  10. teleportRandomly();
  11. }
  12. }
  13. super.updateAITasks();
  14. }

代码示例来源:origin: GregTechCE/GregTech

  1. protected boolean checkCanSeeSun() {
  2. BlockPos blockPos = getPos().up();
  3. if(!getWorld().canBlockSeeSky(blockPos))
  4. return false;
  5. return !getWorld().isRaining() && getWorld().isDaytime();
  6. }

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

  1. @Override
  2. public void onBihourlyTick() {
  3. World world = animal.world;
  4. boolean dayTime = world.isDaytime();
  5. boolean isRaining = world.isRaining();
  6. boolean isOutside = world.canBlockSeeSky(new BlockPos(animal));
  7. boolean isOutsideInSun = !isRaining && isOutside && dayTime && HFApi.calendar.getDate(world).getSeason() != Season.WINTER;
  8. if (isOutsideInSun && wasOutsideInSun) {
  9. affectHappiness(type.getRelationshipBonus(AnimalAction.OUTSIDE));
  10. }
  11. //Mark the past value
  12. wasOutsideInSun = isOutsideInSun;
  13. }

代码示例来源:origin: OpenModularTurretsTeam/OpenModularTurrets

  1. public static void updateSolarPanelAddon(TurretBase base) {
  2. OMEnergyStorage storage = (OMEnergyStorage) base.getCapability(CapabilityEnergy.ENERGY, EnumFacing.DOWN);
  3. if (!hasSolarPanelAddon(base) || storage == null) {
  4. return;
  5. }
  6. if (base.getWorld().isDaytime() && !base.getWorld().isRaining() && base.getWorld().canBlockSeeSky(base.getPos().up(2))) {
  7. storage.receiveEnergy(OMTConfig.MISCELLANEOUS.solarPanelAddonGen, false);
  8. }
  9. }

代码示例来源:origin: TeamLapen/Vampirism

  1. @Override
  2. public boolean shouldExecute() {
  3. if (creature.ticksExisted % 10 == 3) {
  4. Biome biome = creature.getEntityWorld().getBiome(creature.getPosition());
  5. cache = VampirismAPI.sundamageRegistry().getSundamageInDim(creature.getEntityWorld().provider.getDimension()) && VampirismAPI.sundamageRegistry().getSundamageInBiome(biome);
  6. }
  7. return cache && creature.getEntityWorld().isDaytime() && !vampire.isIgnoringSundamage();
  8. }

相关文章

World类方法