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

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

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

World.canSeeSky介绍

暂无

代码示例

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

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

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

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

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

  1. @Override
  2. public boolean getCanSpawnHere() {
  3. return super.getCanSpawnHere() && this.world.canSeeSky(new BlockPos(this));
  4. }

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

  1. private boolean canFill(BlockPos pos)
  2. {
  3. //Only spread within enclosed areas, significantly reduces the impact on performance and suits the purpose of coils
  4. return !this.getWorld().isBlockFullCube(pos) && (!this.getWorld().canSeeSky(pos));
  5. }

代码示例来源:origin: NanamiArihara/FoodCraft-Reloaded

  1. @Override
  2. public boolean matches(World world, BlockPos pos) {
  3. return world.getLight(pos.up()) >= this.level || world.canSeeSky(pos.up());
  4. }
  5. }

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

  1. public boolean getCanSpawnHere() {
  2. BlockPos pos = new BlockPos(this);
  3. return this.getRNG().nextInt(IceAndFire.CONFIG.trollSpawnCheckChance + 1) == 0 && !this.world.canSeeSky(pos) && pos.getY() <= 50 && super.getCanSpawnHere();
  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. world.setEntityState(this, (byte) 11);
  7. attackEntityFrom(DamageSource.OUT_OF_WORLD, EntityAttributes.MAX_HEALTH_2 * 0.25F);
  8. }
  9. }
  10. for (int var2 = 0; var2 < 2; ++var2) {
  11. world.spawnParticle(EnumParticleTypes.PORTAL, posX + (rand.nextDouble() - 0.5D) * width, posY + rand.nextDouble() * height, posZ + (rand.nextDouble() - 0.5D) * width, 0.0D, 0.0D, 0.0D);
  12. }
  13. super.onLivingUpdate();
  14. }

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

  1. @Nullable
  2. private Vec3d findPossibleShelter() {
  3. Random random = npc.getRNG();
  4. BlockPos entityPos = new BlockPos(npc.posX, getMinY(), npc.posZ);
  5. for (int i = 0; i < 10; ++i) {
  6. BlockPos randomPos = entityPos.add(random.nextInt(20) - 10, random.nextInt(6) - 3, random.nextInt(20) - 10);
  7. if (!world.canSeeSky(randomPos) && npc.getBlockPathWeight(randomPos) > 0.0F) {
  8. return new Vec3d((double) randomPos.getX(), (double) randomPos.getY(), (double) randomPos.getZ());
  9. }
  10. }
  11. return null;
  12. }

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

  1. @Nullable
  2. private Vec3d findLocation(boolean outside) {
  3. Random random = theCreature.getRNG();
  4. BlockPos blockpos = new BlockPos(theCreature.posX, theCreature.getEntityBoundingBox().minY, theCreature.posZ);
  5. for (int i = 0; i < 10; ++i) {
  6. BlockPos blockpos1 = blockpos.add(random.nextInt(20) - 10, random.nextInt(6) - 3, random.nextInt(20) - 10);
  7. if (world.canSeeSky(blockpos1) == outside && theCreature.getBlockPathWeight(blockpos1) < 0.0F) {
  8. return new Vec3d((double)blockpos1.getX(), (double)blockpos1.getY(), (double)blockpos1.getZ());
  9. }
  10. }
  11. return null;
  12. }
  13. }

代码示例来源:origin: WayofTime/BloodMagic

  1. @Override
  2. public double getArmourProtection(EntityLivingBase wearer, DamageSource source) {
  3. if (wearer.getEntityWorld().canSeeSky(wearer.getPosition()) || wearer.getEntityWorld().provider.isDaytime()) {
  4. return protectionLevel[this.level];
  5. }
  6. return 0;
  7. }

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

  1. @Nullable
  2. private Vec3d findPossibleShelter() {
  3. Random random = this.troll.getRNG();
  4. BlockPos blockpos = new BlockPos(this.troll.posX, this.troll.getEntityBoundingBox().minY, this.troll.posZ);
  5. for (int i = 0; i < 10; ++i) {
  6. BlockPos blockpos1 = blockpos.add(random.nextInt(20) - 10, random.nextInt(6) - 3, random.nextInt(20) - 10);
  7. if (!this.world.canSeeSky(blockpos1) && this.troll.getBlockPathWeight(blockpos1) < 0.0F) {
  8. return new Vec3d((double) blockpos1.getX(), (double) blockpos1.getY(), (double) blockpos1.getZ());
  9. }
  10. }
  11. return null;
  12. }
  13. }

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

  1. @Override
  2. public boolean getServerActive() {
  3. if (world.provider.hasSkyLight()) {
  4. boolean i1 = world.canSeeSky(getPos().up());
  5. float time = getTime();
  6. if (i1 && time > 0.5) {
  7. return true;
  8. }
  9. }
  10. return false;
  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: 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: 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: JurassiCraftTeam/JurassiCraft2

  1. @Override
  2. public boolean canBlockStay(World world, BlockPos pos, IBlockState state) {
  3. return (world.getLight(pos) >= 8 || world.canSeeSky(pos)) && world.getBlockState(pos.down()).getBlock().canSustainPlant(state, world, pos.down(), net.minecraft.util.EnumFacing.UP, this);
  4. }

代码示例来源: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: WayofTime/BloodMagic

  1. @Override
  2. public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) {
  3. counter++;
  4. if (world.canSeeSky(player.getPosition()) || world.provider.isDaytime()) {
  5. if (counter % regenCooldown[this.level] == 0 && player.getHealth() < player.getMaxHealth()) {
  6. player.heal(1);
  7. }
  8. if (fireResistTime[this.level] != 0 && counter % fireResistCooldown[this.level] == 0) {
  9. player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, fireResistTime[this.level], 0, false, false));
  10. }
  11. }
  12. }

相关文章

World类方法