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

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

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

World.getLightFor介绍

暂无

代码示例

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

  1. private void maxLit()
  2. {
  3. if( this.isLit > 14 )
  4. {
  5. this.isLit = 14;
  6. }
  7. if( this.world != null )
  8. {
  9. this.world.getLightFor( EnumSkyBlock.BLOCK, this.pos );
  10. }
  11. }

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

  1. public static int getLightBrightnessForSkyBlocks(@Nonnull World world, @Nonnull BlockPos pos, int min) {
  2. int i1 = world.getLightFor(EnumSkyBlock.SKY, pos);
  3. int j1 = world.getLightFor(EnumSkyBlock.BLOCK, pos);
  4. if (j1 < min) {
  5. j1 = min;
  6. }
  7. return i1 << 20 | j1 << 4;
  8. }

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

  1. @Override
  2. public int getLightFor(@Nonnull EnumSkyBlock type, @Nonnull BlockPos pos) {
  3. return wrapped.getLightFor(type, pos);
  4. }

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

  1. @Override
  2. public int getLightFor(EnumSkyBlock type, BlockPos pos) {
  3. return getActualWorld().getLightFor(type, pos);
  4. }

代码示例来源:origin: SquidDev-CC/plethora

  1. @Nonnull
  2. @Override
  3. public Map<Object, Object> getMeta(@Nonnull IPartialContext<BlockReference> context) {
  4. if (!context.getModules().hasModule(IntegrationVanilla.daylightSensorMod)) return Collections.emptyMap();
  5. IWorldLocation location = context.getTarget().getLocation();
  6. World world = location.getWorld();
  7. BlockPos pos = location.getPos();
  8. Map<Object, Object> out = Maps.newHashMap();
  9. if (!world.provider.hasSkyLight()) {
  10. out.put("sky", world.getLightFor(EnumSkyBlock.SKY, pos) - world.getSkylightSubtracted());
  11. }
  12. out.put("block", world.getLightFor(EnumSkyBlock.BLOCK, pos));
  13. return out;
  14. }
  15. }

代码示例来源:origin: SquidDev-CC/plethora

  1. @SubtargetedModuleObjectMethod.Inject(
  2. module = IntegrationVanilla.daylightSensor, target = IWorldLocation.class,
  3. doc = "function():int -- The light level from surrounding blocks"
  4. )
  5. public static Object[] getBlockLight(IWorldLocation location, IContext<IModuleContainer> context, Object[] args) {
  6. World world = location.getWorld();
  7. BlockPos pos = location.getPos();
  8. return new Object[]{world.getLightFor(EnumSkyBlock.BLOCK, pos)};
  9. }

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

  1. public void manageChagrgeAmount() {
  2. if (!world.isRemote) {
  3. if (world.provider.hasSkyLight()) {
  4. float f = 0;
  5. int i1 = world.getLightFor(EnumSkyBlock.SKY, getPos().up()) - world.getSkylightSubtracted();
  6. if (i1 >= 15) {
  7. f = getTime();
  8. }
  9. chargeAmount = (byte) Math.round(CHARGE_AMOUNT * f);
  10. } else {
  11. chargeAmount = 0;
  12. }
  13. }
  14. }

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

  1. protected void updateLighting() {
  2. int light2 = world.getLightFor(EnumSkyBlock.BLOCK, pos), light1 = getLightValue();
  3. if (light1 != light2 && world.checkLightFor(EnumSkyBlock.BLOCK, pos)) {
  4. IBlockState state = world.getBlockState(pos);
  5. world.notifyBlockUpdate(pos, state, state, 3);
  6. }
  7. }

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

  1. public @Nonnull List<BakedQuad> getGeneralQuads(@Nonnull IBlockStateWrapper state, BlockRenderLayer layer) {
  2. List<BakedQuad> result = new ArrayList<BakedQuad>();
  3. TileEntity tileEntity = state.getTileEntity();
  4. if (tileEntity instanceof TileConduitBundle) {
  5. IConduitBundle bundle = (IConduitBundle) tileEntity;
  6. if (layer == null) {
  7. addBreakingQuads(bundle, result);
  8. } else {
  9. float brightness;
  10. if (!ConduitConfig.updateLightingWhenHidingFacades.get() && bundle.hasFacade()) {
  11. brightness = 15 << 20 | 15 << 4;
  12. } else {
  13. brightness = bundle.getEntity().getWorld().getLightFor(EnumSkyBlock.SKY, bundle.getLocation());
  14. }
  15. // TODO: check if this is the client thread, if not, make a copy of the bundle and its conduits in a thread-safe way
  16. addConduitQuads(state, bundle, brightness, layer, result);
  17. }
  18. }
  19. return result;
  20. }

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

  1. protected boolean isLowLightLevel() {
  2. BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);
  3. if (this.world.getLightFor(EnumSkyBlock.SKY, blockpos) > this.rand.nextInt(32)) {
  4. return false;
  5. } else {
  6. int i = this.world.getLightFromNeighbors(blockpos);
  7. if (this.world.isThundering()) {
  8. int j = this.world.getSkylightSubtracted();
  9. this.world.setSkylightSubtracted(10);
  10. i = this.world.getLightFromNeighbors(blockpos);
  11. this.world.setSkylightSubtracted(j);
  12. }
  13. return i <= this.rand.nextInt(8);
  14. }
  15. }

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

  1. /**
  2. * @see EntityMob
  3. */
  4. private boolean isValidLightLevel() {
  5. BlockPos blockpos = new BlockPos(posX, getEntityBoundingBox().minY, posZ);
  6. if (world.getLightFor(EnumSkyBlock.SKY, blockpos) > rand.nextInt(32)) {
  7. return false;
  8. } else {
  9. int i = world.getLightFromNeighbors(blockpos);
  10. if (world.isThundering()) {
  11. int j = world.getSkylightSubtracted();
  12. world.setSkylightSubtracted(10);
  13. i = world.getLightFromNeighbors(blockpos);
  14. world.setSkylightSubtracted(j);
  15. }
  16. return i <= rand.nextInt(8);
  17. }
  18. }

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

  1. /**
  2. * Checks to make sure the light is not too bright where the mob is spawning
  3. */
  4. private boolean isValidLightLevel() {
  5. BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);
  6. if (this.world.getLightFor(EnumSkyBlock.SKY, blockpos) > this.rand.nextInt(32)) {
  7. return false;
  8. } else {
  9. int i = this.world.getLightFromNeighbors(blockpos);
  10. if (this.world.isThundering()) {
  11. int j = this.world.getSkylightSubtracted();
  12. this.world.setSkylightSubtracted(10);
  13. i = this.world.getLightFromNeighbors(blockpos);
  14. this.world.setSkylightSubtracted(j);
  15. }
  16. return i <= this.rand.nextInt(8);
  17. }
  18. }

代码示例来源:origin: CyclopsMC/EvilCraft

  1. protected boolean isValidLightLevel()
  2. {
  3. BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);
  4. if (this.world.getLightFor(EnumSkyBlock.SKY, blockpos) > this.rand.nextInt(32))
  5. {
  6. return false;
  7. }
  8. else
  9. {
  10. int i = this.world.getLightFromNeighbors(blockpos);
  11. if (this.world.isThundering())
  12. {
  13. int j = this.world.getSkylightSubtracted();
  14. this.world.setSkylightSubtracted(10);
  15. i = this.world.getLightFromNeighbors(blockpos);
  16. this.world.setSkylightSubtracted(j);
  17. }
  18. return i <= this.rand.nextInt(8);
  19. }
  20. }

代码示例来源:origin: SquidDev-CC/plethora

  1. @SubtargetedModuleObjectMethod.Inject(
  2. module = IntegrationVanilla.daylightSensor, target = IWorldLocation.class,
  3. doc = "function():int -- The light level from the sun"
  4. )
  5. public static Object[] getSkyLight(IWorldLocation location, IContext<IModuleContainer> context, Object[] args) throws LuaException {
  6. World world = location.getWorld();
  7. if (!world.provider.hasSkyLight()) {
  8. throw new LuaException("The world has no sky");
  9. } else {
  10. BlockPos pos = location.getPos();
  11. return new Object[]{world.getLightFor(EnumSkyBlock.SKY, pos) - world.getSkylightSubtracted()};
  12. }
  13. }

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

  1. @Override
  2. protected boolean isValidLightLevel() {
  3. if (!restrictLightLevel()) {
  4. return true;
  5. }
  6. BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);
  7. if (this.world.getLightFor(EnumSkyBlock.SKY, blockpos) > this.rand.nextInt(32)) {
  8. return false;
  9. } else {
  10. int i = this.world.getLightFromNeighbors(blockpos);
  11. if (this.world.isThundering()) {
  12. int j = this.world.getSkylightSubtracted();
  13. this.world.setSkylightSubtracted(10);
  14. i = this.world.getLightFromNeighbors(blockpos);
  15. this.world.setSkylightSubtracted(j);
  16. }
  17. return i <= this.rand.nextInt(getSpawnLightLevel());
  18. }
  19. }

代码示例来源:origin: CyclopsMC/EvilCraft

  1. private void transformWerewolfVillager(LivingUpdateEvent event) {
  2. if(event.getEntity() instanceof EntityVillager && !event.getEntity().world.isRemote) {
  3. EntityVillager villager = (EntityVillager) event.getEntity();
  4. if(Werewolf.isWerewolfTime(event.getEntity().world) && Configs.isEnabled(WerewolfVillagerConfig.class)
  5. && villager.getProfessionForge() == WerewolfVillager.getInstance()
  6. && villager.world.getLightFor(EnumSkyBlock.SKY, villager.getPosition()) > 0) {
  7. Werewolf.replaceVillager(villager);
  8. }
  9. }
  10. }

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

  1. private boolean canSnowAt(BlockPos pos)
  2. {
  3. if (!world.isAirBlock(pos) && !world.isAirBlock(pos.add(0, -1, 0)) && !SNOW.getBlock().canPlaceBlockAt(world, pos))
  4. return false;
  5. if (ClimateTFC.getHeightAdjustedTemp(world, pos) >= 0F) return false;
  6. if (world.getLightFor(EnumSkyBlock.BLOCK, pos) < 10 /* todo: why? && CalenderTFC.getTotalMonths() < 1*/)
  7. return false;
  8. return world.getBlockState(pos.add(0, -1, 0)).getMaterial().blocksMovement();
  9. }

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

  1. private boolean canMobsSpawnInPos(World world, BlockPos pos) {
  2. if(world.isSideSolid(pos.down(), EnumFacing.UP) && !world.isBlockNormalCube(pos, false)
  3. && !world.isBlockNormalCube(pos.up(), false) && !world.getBlockState(pos).getMaterial().isLiquid()) {
  4. IBlockState state = world.getBlockState(pos);
  5. if(ModuleLoader.isFeatureEnabled(BlackAsh.class) && state.getBlock() == BlackAsh.black_ash || world.getBlockState(pos.down(2)).getBlock() == BlackAsh.black_ash)
  6. return false;
  7. int lightLevel = world.getLightFor(EnumSkyBlock.BLOCK, pos);
  8. return lightLevel < 8 && (world.isAirBlock(pos) || state.getCollisionBoundingBox(world, pos) == null);
  9. }
  10. return false;
  11. }

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

  1. @Override
  2. public boolean canSnowAt(@Nonnull BlockPos pos, boolean checkLight) {
  3. Biome biome = world.getBiome(pos);
  4. if (!biome.canRain() || biome.isHighHumidity()) {
  5. return super.canSnowAt(pos, checkLight);
  6. } else if (biome.isSnowyBiome()) {
  7. Weather weather = HFApi.calendar.getWeather(world);
  8. return !weather.isRain() && super.canSnowAt(pos, checkLight);
  9. } else {
  10. Weather weather = HFApi.calendar.getWeather(world);
  11. float f = biome.getFloatTemperature(pos);
  12. if (weather.isSnow() && f > 0.15F) {
  13. if (!checkLight) {
  14. return true;
  15. } else {
  16. if (pos.getY() >= 0 && pos.getY() < 256 && world.getLightFor(EnumSkyBlock.BLOCK, pos) < 10) {
  17. IBlockState iblockstate = world.getBlockState(pos);
  18. if (iblockstate.getBlock() != Blocks.SNOW_LAYER && iblockstate.getBlock().isReplaceable(world, pos) && Blocks.SNOW_LAYER.canPlaceBlockAt(world, pos)) {
  19. HFApi.tickable.addTickable(world, pos, SnowLoader.INSTANCE);
  20. return true;
  21. }
  22. }
  23. return false;
  24. }
  25. } else return super.canSnowAt(pos, checkLight);
  26. }
  27. }

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

  1. float brightness = bundle.getEntity().getWorld().getLightFor(EnumSkyBlock.SKY, bundle.getLocation());

相关文章

World类方法