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

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

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

World.getLight介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

  1. @Override
  2. public int getBlockLightLevel(BlockVector3 position) {
  3. checkNotNull(position);
  4. return getWorld().getLight(ForgeAdapter.toBlockPos(position));
  5. }

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

  1. public void updateLight()
  2. {
  3. final int val = this.world.getLight( this.pos );
  4. if( this.lastLight != val )
  5. {
  6. this.lastLight = val;
  7. Platform.notifyBlocksOfNeighbors( this.world, this.pos );
  8. }
  9. }

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

  1. @Override
  2. public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
  3. if(!world.isRemote && state.getBlock() == this && world.getLight(pos.up()) >= 9) {
  4. AltGrassVariant variant = state.getValue(BotaniaStateProps.ALTGRASS_VARIANT);
  5. for(int l = 0; l < 4; ++l) {
  6. BlockPos pos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
  7. world.getBlockState(pos1.up()).getBlock();
  8. if(world.getBlockState(pos1).getBlock() == Blocks.DIRT && world.getBlockState(pos1).getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && world.getLight(pos1.up()) >= 4 && world.getBlockLightOpacity(pos1.up()) <= 2)
  9. world.setBlockState(pos1, getDefaultState().withProperty(BotaniaStateProps.ALTGRASS_VARIANT, variant), 1 | 2);
  10. }
  11. }
  12. }

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

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

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

  1. @Override
  2. public int getLight(@Nonnull BlockPos pos, boolean checkNeighbors) {
  3. return wrapped.getLight(pos, checkNeighbors);
  4. }

代码示例来源:origin: MCTCP/TerrainControl

  1. @Override
  2. public int getLightLevel(int x, int y, int z)
  3. {
  4. // Actually, this calculates the block and skylight as it were day.
  5. return this.world.getLight(new BlockPos(x, y, z));
  6. }

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

  1. @Override
  2. public boolean canGrow(World world, BlockPos pos, Crop crop) {
  3. return super.canGrow(world, pos, crop) && world.getLight(pos) >= 12;
  4. }
  5. }

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

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

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

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

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

  1. @Override
  2. public int getLight(BlockPos pos, boolean checkNeighbors) {
  3. return getActualWorld().getLight(pos, checkNeighbors);
  4. }

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

  1. public static void setupLightmapCoords(@Nonnull BlockPos pos, @Nonnull World world) {
  2. float f = world.getLight(pos);
  3. int l = RenderUtil.getLightBrightnessForSkyBlocks(world, pos, 0);
  4. int l1 = l % 65536;
  5. int l2 = l / 65536;
  6. GlStateManager.color(f, f, f);
  7. OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
  8. }

代码示例来源:origin: sinkillerj/ProjectE

  1. public int getSunLevel()
  2. {
  3. if (world.provider.doesWaterVaporize())
  4. {
  5. return 16;
  6. }
  7. return world.getLight(getPos().up()) + 1;
  8. }

代码示例来源: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: ata4/dragon-mounts

  1. @Override
  2. public boolean isHabitatEnvironment(EntityTameableDragon dragon) {
  3. if (dragon.posY > dragon.worldObj.getHeight() * 0.25) {
  4. // woah dude, too high!
  5. return false;
  6. }
  7. BlockPos pos = dragon.getPosition();
  8. if (dragon.worldObj.canBlockSeeSky(pos)) {
  9. // sun is shining!
  10. return false;
  11. }
  12. if (dragon.worldObj.getLight(pos) > 4) {
  13. // too bright!
  14. return false;
  15. }
  16. return true;
  17. }

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

  1. public static float getHeightAdjustedBiomeTemp(World world, BlockPos pos)
  2. {
  3. float temp = adjustTempByHeight(pos.getY(), getAverageBiomeTemp(world, pos));
  4. if (temp <= 0 || !world.canBlockSeeSky(pos)) return temp;
  5. return temp - (temp * (0.25f * (1 - (world.getLight(pos) / 15f))));
  6. }

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

  1. public static float getHeightAdjustedTemp(World world, BlockPos pos)
  2. {
  3. float temp = adjustTempByHeight(pos.getY(), getTemp(world, pos));
  4. if (temp <= 0 || !world.canBlockSeeSky(pos)) return temp;
  5. return temp - (temp * (0.25f * (1 - (world.getLight(pos) / 15f))));
  6. }

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

  1. @Override
  2. public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) {
  3. if (world.getLight(player.getPosition(), false) <= 9) {
  4. isActive = true;
  5. if (player.isPotionActive(MobEffects.NIGHT_VISION)) {
  6. int dur = player.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration();
  7. if (dur > 100 && dur < 20 * 60 * 20) {
  8. //Don't override the potion effect if the other potion effect is sufficiently long.
  9. return;
  10. }
  11. }
  12. player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, Constants.Misc.NIGHT_VISION_CONSTANT_BEGIN, 0, false, false));
  13. } else {
  14. isActive = false;
  15. }
  16. }

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

  1. public boolean getCanSpawnHere() {
  2. int i = MathHelper.floor(this.posX);
  3. int j = MathHelper.floor(this.getEntityBoundingBox().minY);
  4. int k = MathHelper.floor(this.posZ);
  5. BlockPos blockpos = new BlockPos(i, j, k);
  6. return this.world.getBlockState(blockpos.down()).getBlock() == this.spawnableBlock && this.getRNG().nextInt(1 + IceAndFire.CONFIG.deathWormSpawnCheckChance) == 0 && this.world.getLight(blockpos) > 8 && super.getCanSpawnHere();
  7. }

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

  1. @Override
  2. public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) {
  3. if (pos.getY() >= 0 && pos.getY() < 256) {
  4. IBlockState iblockstate = worldIn.getBlockState(pos.down());
  5. return iblockstate.getBlock() == Blocks.MYCELIUM || (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL || worldIn.getLight(pos) < 13 && iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this));
  6. } else {
  7. return false;
  8. }
  9. }

相关文章

World类方法