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

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

本文整理了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

private void maxLit()
{
  if( this.isLit > 14 )
  {
    this.isLit = 14;
  }
  if( this.world != null )
  {
    this.world.getLightFor( EnumSkyBlock.BLOCK, this.pos );
  }
}

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

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

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

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

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

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

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

@Nonnull
  @Override
  public Map<Object, Object> getMeta(@Nonnull IPartialContext<BlockReference> context) {
    if (!context.getModules().hasModule(IntegrationVanilla.daylightSensorMod)) return Collections.emptyMap();

    IWorldLocation location = context.getTarget().getLocation();
    World world = location.getWorld();
    BlockPos pos = location.getPos();

    Map<Object, Object> out = Maps.newHashMap();
    if (!world.provider.hasSkyLight()) {
      out.put("sky", world.getLightFor(EnumSkyBlock.SKY, pos) - world.getSkylightSubtracted());
    }

    out.put("block", world.getLightFor(EnumSkyBlock.BLOCK, pos));
    return out;
  }
}

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

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

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

public void manageChagrgeAmount() {
  if (!world.isRemote) {
    if (world.provider.hasSkyLight()) {
      float f = 0;
      int i1 = world.getLightFor(EnumSkyBlock.SKY, getPos().up()) - world.getSkylightSubtracted();
      if (i1 >= 15) {
        f = getTime();
      }
      chargeAmount = (byte) Math.round(CHARGE_AMOUNT * f);
    } else {
      chargeAmount = 0;
    }
  }
}

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

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

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

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

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

protected boolean isLowLightLevel() {
  BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);
  if (this.world.getLightFor(EnumSkyBlock.SKY, blockpos) > this.rand.nextInt(32)) {
    return false;
  } else {
    int i = this.world.getLightFromNeighbors(blockpos);
    if (this.world.isThundering()) {
      int j = this.world.getSkylightSubtracted();
      this.world.setSkylightSubtracted(10);
      i = this.world.getLightFromNeighbors(blockpos);
      this.world.setSkylightSubtracted(j);
    }
    return i <= this.rand.nextInt(8);
  }
}

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

/**
 * @see EntityMob
 */
private boolean isValidLightLevel() {
  BlockPos blockpos = new BlockPos(posX, getEntityBoundingBox().minY, posZ);
  if (world.getLightFor(EnumSkyBlock.SKY, blockpos) > rand.nextInt(32)) {
    return false;
  } else {
    int i = world.getLightFromNeighbors(blockpos);
    if (world.isThundering()) {
      int j = world.getSkylightSubtracted();
      world.setSkylightSubtracted(10);
      i = world.getLightFromNeighbors(blockpos);
      world.setSkylightSubtracted(j);
    }
    return i <= rand.nextInt(8);
  }
}

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

/**
 * Checks to make sure the light is not too bright where the mob is spawning
 */
private boolean isValidLightLevel() {
  BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);
  if (this.world.getLightFor(EnumSkyBlock.SKY, blockpos) > this.rand.nextInt(32)) {
    return false;
  } else {
    int i = this.world.getLightFromNeighbors(blockpos);
    if (this.world.isThundering()) {
      int j = this.world.getSkylightSubtracted();
      this.world.setSkylightSubtracted(10);
      i = this.world.getLightFromNeighbors(blockpos);
      this.world.setSkylightSubtracted(j);
    }
    return i <= this.rand.nextInt(8);
  }
}

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

protected boolean isValidLightLevel()
{
  BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);
  if (this.world.getLightFor(EnumSkyBlock.SKY, blockpos) > this.rand.nextInt(32))
  {
    return false;
  }
  else
  {
    int i = this.world.getLightFromNeighbors(blockpos);
    if (this.world.isThundering())
    {
      int j = this.world.getSkylightSubtracted();
      this.world.setSkylightSubtracted(10);
      i = this.world.getLightFromNeighbors(blockpos);
      this.world.setSkylightSubtracted(j);
    }
    return i <= this.rand.nextInt(8);
  }
}

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

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

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

@Override
protected boolean isValidLightLevel() {
  if (!restrictLightLevel()) {
    return true;
  }
  BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);
  if (this.world.getLightFor(EnumSkyBlock.SKY, blockpos) > this.rand.nextInt(32)) {
    return false;
  } else {
    int i = this.world.getLightFromNeighbors(blockpos);
    if (this.world.isThundering()) {
      int j = this.world.getSkylightSubtracted();
      this.world.setSkylightSubtracted(10);
      i = this.world.getLightFromNeighbors(blockpos);
      this.world.setSkylightSubtracted(j);
    }
    return i <= this.rand.nextInt(getSpawnLightLevel());
  }
}

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

private void transformWerewolfVillager(LivingUpdateEvent event) {
  if(event.getEntity() instanceof EntityVillager && !event.getEntity().world.isRemote) {
    EntityVillager villager = (EntityVillager) event.getEntity();
    if(Werewolf.isWerewolfTime(event.getEntity().world) && Configs.isEnabled(WerewolfVillagerConfig.class)
        && villager.getProfessionForge() == WerewolfVillager.getInstance()
        && villager.world.getLightFor(EnumSkyBlock.SKY, villager.getPosition()) > 0) {
      Werewolf.replaceVillager(villager);
    }
  }
}

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

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

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

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

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

@Override
public boolean canSnowAt(@Nonnull BlockPos pos, boolean checkLight) {
  Biome biome = world.getBiome(pos);
  if (!biome.canRain() || biome.isHighHumidity()) {
    return super.canSnowAt(pos, checkLight);
  } else if (biome.isSnowyBiome()) {
    Weather weather = HFApi.calendar.getWeather(world);
    return !weather.isRain() && super.canSnowAt(pos, checkLight);
  } else {
    Weather weather = HFApi.calendar.getWeather(world);
    float f = biome.getFloatTemperature(pos);
    if (weather.isSnow() && f > 0.15F) {
      if (!checkLight) {
        return true;
      } else {
        if (pos.getY() >= 0 && pos.getY() < 256 && world.getLightFor(EnumSkyBlock.BLOCK, pos) < 10) {
          IBlockState iblockstate = world.getBlockState(pos);
          if (iblockstate.getBlock() != Blocks.SNOW_LAYER && iblockstate.getBlock().isReplaceable(world, pos) && Blocks.SNOW_LAYER.canPlaceBlockAt(world, pos)) {
            HFApi.tickable.addTickable(world, pos, SnowLoader.INSTANCE);
            return true;
          }
        }
        return false;
      }
    } else return super.canSnowAt(pos, checkLight);
  }
}

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

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

相关文章

微信公众号

最新文章

更多

World类方法