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

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

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

World.getLightFromNeighbors介绍

暂无

代码示例

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

  1. @Override
  2. public int getWeakPower( final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side )
  3. {
  4. if( w instanceof World && ( (TileLightDetector) this.getTileEntity( w, pos ) ).isReady() )
  5. {
  6. return ( (World) w ).getLightFromNeighbors( pos ) - 6;
  7. }
  8. return 0;
  9. }

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

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

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

  1. private boolean doWork()
  2. {
  3. if( this.isOutput() )
  4. {
  5. return false;
  6. }
  7. final TileEntity te = this.getTile();
  8. final World w = te.getWorld();
  9. final int newLevel = w.getLightFromNeighbors( te.getPos().offset( this.getSide().getFacing() ) );
  10. if( this.lastValue != newLevel && this.getProxy().isActive() )
  11. {
  12. this.lastValue = newLevel;
  13. try
  14. {
  15. for( final PartP2PLight out : this.getOutputs() )
  16. {
  17. out.setLightLevel( this.lastValue );
  18. }
  19. }
  20. catch( final GridAccessException e )
  21. {
  22. // :P
  23. }
  24. return true;
  25. }
  26. return false;
  27. }

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

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

代码示例来源:origin: SonarSonic/Calculator

  1. @Override
  2. public void updateTick(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, Random rand) {
  3. if (!worldIn.isRemote) {
  4. super.updateTick(worldIn, pos, state, rand);
  5. if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) {
  6. this.grow(worldIn, pos, state, rand);
  7. }
  8. }
  9. }

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

  1. @Override
  2. public int getBlockLightValue() {
  3. BlockPos topCenter = getTopCenterCoord();
  4. return world.getLightFromNeighbors(topCenter.up());
  5. }

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

  1. @Override
  2. public int getBlockLightValue() {
  3. return world.getLightFromNeighbors(getPosition().up());
  4. }

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

  1. @Override
  2. public int getBlockLightValue() {
  3. return world.getLightFromNeighbors(getPos().up());
  4. }

代码示例来源:origin: jabelar/ExampleMod-1.12

  1. @Override
  2. public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
  3. {
  4. if (!worldIn.isRemote)
  5. {
  6. super.updateTick(worldIn, pos, state, rand);
  7. if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0)
  8. {
  9. grow(worldIn, rand, pos, state);
  10. }
  11. }
  12. }

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

  1. @Override
  2. public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
  3. if (!world.isRemote) {
  4. super.updateTick(world, pos, state, rand);
  5. if (world.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) {
  6. this.grow(world, pos, state, rand);
  7. }
  8. }
  9. }

代码示例来源:origin: vadis365/TheErebus

  1. public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
  2. if (!world.isRemote) {
  3. super.updateTick(world, pos, state, rand);
  4. if (world.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) {
  5. grow(world, rand, pos, state);
  6. }
  7. }
  8. }

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

  1. @Override
  2. public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
  3. if (!worldIn.isRemote) {
  4. super.updateTick(worldIn, pos, state, rand);
  5. if (!worldIn.isAreaLoaded(pos, 1))
  6. return;
  7. if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) {
  8. this.grow(worldIn, rand, pos, state);
  9. }
  10. }
  11. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public boolean getCanSpawnHere() {
  3. BlockPos blockpos = new BlockPos(posX, getEntityBoundingBox().minY, posZ);
  4. if (blockpos.getY() >= 120 || blockpos.getY() <= 20)
  5. return false;
  6. else {
  7. int lightValue = world.getLightFromNeighbors(blockpos);
  8. if (rand.nextBoolean())
  9. return false;
  10. return lightValue > rand.nextInt(7) ? false : isNotColliding() && super.getCanSpawnHere();
  11. }
  12. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public boolean getCanSpawnHere() {
  3. BlockPos blockpos = new BlockPos(posX, getEntityBoundingBox().minY, posZ);
  4. if (blockpos.getY() >= 120 || blockpos.getY() <= 20)
  5. return false;
  6. else {
  7. int lightValue = world.getLightFromNeighbors(blockpos);
  8. if (rand.nextBoolean())
  9. return false;
  10. return lightValue > rand.nextInt(4) ? false : isNotColliding() && super.getCanSpawnHere();
  11. }
  12. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public boolean getCanSpawnHere() {
  3. BlockPos blockpos = new BlockPos(posX, getEntityBoundingBox().minY, posZ);
  4. if (blockpos.getY() > 100)
  5. return false;
  6. else {
  7. int lightValue = world.getLightFromNeighbors(blockpos);
  8. return lightValue > rand.nextInt(7) ? false : isNotColliding() && super.getCanSpawnHere();
  9. }
  10. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public boolean getCanSpawnHere() {
  3. BlockPos blockpos = new BlockPos(posX, getEntityBoundingBox().minY, posZ);
  4. if (blockpos.getY() > 100)
  5. return false;
  6. else {
  7. int lightValue = world.getLightFromNeighbors(blockpos);
  8. return lightValue > rand.nextInt(7) ? false : isNotColliding() && super.getCanSpawnHere();
  9. }
  10. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public boolean getCanSpawnHere() {
  3. BlockPos blockpos = new BlockPos(posX, getEntityBoundingBox().minY, posZ);
  4. if (blockpos.getY() > 100)
  5. return false;
  6. else {
  7. int lightValue = world.getLightFromNeighbors(blockpos);
  8. return lightValue > rand.nextInt(7) ? false : isNotColliding() && super.getCanSpawnHere();
  9. }
  10. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
  3. if (!world.isRemote) {
  4. super.updateTick(world, pos, state, rand);
  5. if (world.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) {
  6. if(this != EnumWood.BAMBOO.getSapling())
  7. grow(world, pos, state, rand);
  8. else
  9. world.setBlockState(pos, EnumWood.BAMBOO.getLog().getDefaultState(), 3);
  10. }
  11. }
  12. }

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

  1. @Override
  2. public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
  3. super.updateTick(world, pos, state, rand);
  4. if (world.getLightFromNeighbors(pos.up()) >= 9) {
  5. int i = state.getValue(this.getAgeProperty());
  6. if (i < this.getMaxAge()) {
  7. float f = getGrowthChance(this, world, pos);
  8. if (rand.nextInt((int) (25.0F / f) + 1) == 0) {
  9. world.setBlockState(pos, state.withProperty(this.getAgeProperty(), i + 1), 2);
  10. }
  11. }
  12. }
  13. }

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

  1. @Override
  2. public boolean canGenerateTree(World world, BlockPos pos, Tree treeType)
  3. {
  4. // Check if there is soil beneath
  5. if (!BlocksTFC.isSoil(world.getBlockState(pos.down())))
  6. return false;
  7. // Check the position for liquids, etc.
  8. if (world.getBlockState(pos).getMaterial().isLiquid() || !world.getBlockState(pos).getMaterial().isReplaceable())
  9. if (!(world.getBlockState(pos) instanceof BlockSapling))
  10. return false;
  11. // Check if there is sufficient light level
  12. return world.getLightFromNeighbors(pos) >= 7;
  13. }

相关文章

World类方法