public int getLightSubtracted(BlockPos pos, int amount) { int i = pos.getX() & 15; int j = pos.getY(); int k = pos.getZ() & 15; ExtendedBlockStorage extendedblockstorage = this.storageArrays[j >> 4]; if (extendedblockstorage == null) { return !this.worldObj.provider.getHasNoSky() && amount < EnumSkyBlock.SKY.defaultLightValue ? EnumSkyBlock.SKY.defaultLightValue - amount : 0; } else { int l = this.worldObj.provider.getHasNoSky() ? 0 : extendedblockstorage.getExtSkylightValue(i, j & 15, k); l = l - amount; int i1 = extendedblockstorage.getExtBlocklightValue(i, j & 15, k); if (i1 > l) { l = i1; } return l; } }
/** * Checks to make sure the light is not too bright where the mob is spawning */ protected boolean isValidLightLevel() { BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ); if (this.worldObj.getLightFor(EnumSkyBlock.SKY, blockpos) > this.rand.nextInt(32)) { return false; } else { int i = this.worldObj.getLightFromNeighbors(blockpos); if (this.worldObj.isThundering()) { int j = this.worldObj.getSkylightSubtracted(); this.worldObj.setSkylightSubtracted(10); i = this.worldObj.getLightFromNeighbors(blockpos); this.worldObj.setSkylightSubtracted(j); } return i <= this.rand.nextInt(8); } }
public void updatePower(World worldIn, BlockPos pos) { if (!worldIn.provider.getHasNoSky()) { IBlockState iblockstate = worldIn.getBlockState(pos); int i = worldIn.getLightFor(EnumSkyBlock.SKY, pos) - worldIn.getSkylightSubtracted(); float f = worldIn.getCelestialAngleRadians(1.0F); float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F); f = f + (f1 - f) * 0.2F; i = Math.round((float)i * MathHelper.cos(f)); i = MathHelper.clamp_int(i, 0, 15); if (this.inverted) { i = 15 - i; } if (((Integer)iblockstate.getValue(POWER)).intValue() != i) { worldIn.setBlockState(pos, iblockstate.withProperty(POWER, Integer.valueOf(i)), 3); } } }
@Override public void func_149957_e(World world, int x, int y, int z) { if (!world.provider.hasNoSky) { int meta = world.getBlockMetadata(x, y, z); int light = world.getSavedLightValue(EnumSkyBlock.Sky, x, y, z) - world.skylightSubtracted; float angle = world.getCelestialAngleRadians(1.0F); if (angle < (float) Math.PI) angle += (0.0F - angle) * 0.2F; else angle += ((float) Math.PI * 2F - angle) * 0.2F; light = Math.round(light * MathHelper.cos(angle)); if (light < 0) light = 0; if (light > 15) light = 15; light = invertedValues[light]; if (meta != light) world.setBlockMetadataWithNotify(x, y, z, light, 3); } }
/** * Checks to make sure the light is not too bright where the mob is spawning * Adapted from net.minecraft.entity.monster.EntityMob#isValidLightLevel * */ private static boolean EntityMob_isValidLightLevel(EntityLivingBase entity) { BlockPos pos = new BlockPos(entity.posX, entity.getEntityBoundingBox().minY, entity.posZ); if (entity.world.getLightFor(EnumSkyBlock.SKY, pos) > entity.world.rand.nextInt(32)) { return false; } else { int i = entity.world.getLightFromNeighbors(pos); if (entity.world.isThundering()) { int j = entity.world.getSkylightSubtracted(); entity.world.setSkylightSubtracted(10); i = entity.world.getLightFromNeighbors(pos); entity.world.setSkylightSubtracted(j); } return i <= entity.world.rand.nextInt(8); } }
private void trySpread(World world, BlockPos pos) { for (EnumFacing face : EnumFacing.HORIZONTALS) { BlockPos looppos = pos.offset(face); if (world.getLightFor(EnumSkyBlock.BLOCK, looppos) > 5) continue; if (world.isAirBlock(looppos) && (world.getBlockState(looppos.down()).getBlock() == Blocks.DIRT || world.getBlockState(looppos.down()).getBlock() == Blocks.FARMLAND)) { if (world.rand.nextInt(2) == 0) { if (world.getBlockState(looppos.down()).getBlock() == Blocks.DIRT) world.setBlockState(looppos.down(), Blocks.FARMLAND.getDefaultState(), 3); else world.setBlockState(looppos, UCBlocks.cropDevilsnare.getDefaultState(), 3); break; } } } }
@Override public boolean receiveClientEvent(int i, int j) { if (world != null && !world.isRemote) return true; if (i == 1) { facing = (byte) j; return true; } else if (i == 2) { isActive = j == 1; if (world != null) world.checkLightFor(EnumSkyBlock.BLOCK, pos); else updateLight = true; return true; } return super.receiveClientEvent(i, j); }
public int getLightSubtracted(BlockPos pos, int amount) { int i = pos.getX() & 15; int j = pos.getY(); int k = pos.getZ() & 15; ExtendedBlockStorage extendedblockstorage = this.storageArrays[j >> 4]; if (extendedblockstorage == NULL_BLOCK_STORAGE) { return this.worldObj.provider.func_191066_m() && amount < EnumSkyBlock.SKY.defaultLightValue ? EnumSkyBlock.SKY.defaultLightValue - amount : 0; } else { int l = !this.worldObj.provider.func_191066_m() ? 0 : extendedblockstorage.getExtSkylightValue(i, j & 15, k); l = l - amount; int i1 = extendedblockstorage.getExtBlocklightValue(i, j & 15, k); if (i1 > l) { l = i1; } return l; } }
/** * Checks to make sure the light is not too bright where the mob is spawning */ 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); } }
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 <= 4 + this.rand.nextInt(4); } }
public int getLightSubtracted(BlockPos pos, int amount) { int i = pos.getX() & 15; int j = pos.getY(); int k = pos.getZ() & 15; ExtendedBlockStorage extendedblockstorage = this.storageArrays[j >> 4]; if (extendedblockstorage == NULL_BLOCK_STORAGE) { return !this.worldObj.provider.getHasNoSky() && amount < EnumSkyBlock.SKY.defaultLightValue ? EnumSkyBlock.SKY.defaultLightValue - amount : 0; } else { int l = this.worldObj.provider.getHasNoSky() ? 0 : extendedblockstorage.getExtSkylightValue(i, j & 15, k); l = l - amount; int i1 = extendedblockstorage.getExtBlocklightValue(i, j & 15, k); if (i1 > l) { l = i1; } return l; } }
protected void playMoodSoundAndCheckLight(int p_147467_1_, int p_147467_2_, Chunk chunkIn) { super.playMoodSoundAndCheckLight(p_147467_1_, p_147467_2_, chunkIn); if (this.ambienceTicks == 0) { this.updateLCG = this.updateLCG * 3 + 1013904223; int i = this.updateLCG >> 2; int j = i & 15; int k = i >> 8 & 15; int l = i >> 16 & 255; BlockPos blockpos = new BlockPos(j + p_147467_1_, l, k + p_147467_2_); IBlockState iblockstate = chunkIn.getBlockState(blockpos); j = j + p_147467_1_; k = k + p_147467_2_; if (iblockstate.getMaterial() == Material.AIR && this.getLight(blockpos) <= this.rand.nextInt(8) && this.getLightFor(EnumSkyBlock.SKY, blockpos) <= 0 && this.mc.thePlayer != null && this.mc.thePlayer.getDistanceSq((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D) > 4.0D) { this.playSound((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, SoundEvents.AMBIENT_CAVE, SoundCategory.AMBIENT, 0.7F, 0.8F + this.rand.nextFloat() * 0.2F, false); this.ambienceTicks = this.rand.nextInt(12000) + 6000; } } }
public int updatePower(World worldIn, BlockPos pos) { if (worldIn.provider.hasSkyLight()) { int i = worldIn.getLightFor(EnumSkyBlock.SKY, pos) - worldIn.getSkylightSubtracted(); float f = worldIn.getCelestialAngleRadians(1.0F); float f1 = f < (float) Math.PI ? 0.0F : (float) Math.PI * 2F; f = f + (f1 - f) * 0.2F; i = Math.round(i * MathHelper.cos(f)); i = MathHelper.clamp(i, 0, 15); return i; } return 0; }
private void setLightsOn(boolean lightsOn) { boolean check = areLightsOn != lightsOn; areLightsOn = lightsOn; if (check) { getWorld().checkLightFor(EnumSkyBlock.BLOCK, getPos()); sendDescriptionPacket(); } }
private boolean enlightenBlocks(int i, int j, int k, World world) { enlightenedBlocks.preload(i >> 4, k >> 4); Optional<ChunkPositionSet> chunkMapOpt = enlightenedBlocks.get(i >> 4, k >> 4); if (chunkMapOpt.map(m -> m.contains(i & 15, j, k & 15)).orElse(false)) { return false; } ChunkPositionSet chunkMap = chunkMapOpt.orElseGet(ChunkPositionSet::create); if (!chunkMapOpt.isPresent()) { enlightenedBlocks.put(i >> 4, k >> 4, chunkMap); } chunkMap.add(i & 15, j, k & 15); world.checkLightFor(EnumSkyBlock.BLOCK, new BlockPos(i, j, k)); return true; }
private int getLightCombonation(BlockPos pos, int lightValue) { int i = world.getLightFromNeighborsFor(EnumSkyBlock.SKY, pos); int j = world.getLightFromNeighborsFor(EnumSkyBlock.BLOCK, pos); if (j < lightValue) { j = lightValue; } return i << 20 | j << 4; }
private void updateSkylightNeighborHeight(int x, int z, int startY, int endY) { if (endY > startY && this.worldObj.isAreaLoaded(new BlockPos(x, 0, z), 16)) { for (int i = startY; i < endY; ++i) { this.worldObj.checkLightFor(EnumSkyBlock.SKY, new BlockPos(x, i, z)); } this.isModified = true; } }
public int getLightFor(EnumSkyBlock p_177413_1_, BlockPos pos) { int i = pos.getX() & 15; int j = pos.getY(); int k = pos.getZ() & 15; ExtendedBlockStorage extendedblockstorage = this.storageArrays[j >> 4]; return extendedblockstorage == null ? (this.canSeeSky(pos) ? p_177413_1_.defaultLightValue : 0) : (p_177413_1_ == EnumSkyBlock.SKY ? (this.worldObj.provider.getHasNoSky() ? 0 : extendedblockstorage.getExtSkylightValue(i, j & 15, k)) : (p_177413_1_ == EnumSkyBlock.BLOCK ? extendedblockstorage.getExtBlocklightValue(i, j & 15, k) : p_177413_1_.defaultLightValue)); }
public void setLightFor(EnumSkyBlock p_177431_1_, BlockPos pos, int value) { int i = pos.getX() & 15; int j = pos.getY(); int k = pos.getZ() & 15; ExtendedBlockStorage extendedblockstorage = this.storageArrays[j >> 4]; if (extendedblockstorage == null) { extendedblockstorage = this.storageArrays[j >> 4] = new ExtendedBlockStorage(j >> 4 << 4, !this.worldObj.provider.getHasNoSky()); this.generateSkylightMap(); } this.isModified = true; if (p_177431_1_ == EnumSkyBlock.SKY) { if (!this.worldObj.provider.getHasNoSky()) { extendedblockstorage.setExtSkylightValue(i, j & 15, k, value); } } else if (p_177431_1_ == EnumSkyBlock.BLOCK) { extendedblockstorage.setExtBlocklightValue(i, j & 15, k, value); } }
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11 - this.getLightOpacity()) { if (worldIn.provider.doesWaterVaporize()) { worldIn.setBlockToAir(pos); } else { this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); worldIn.setBlockState(pos, Blocks.water.getDefaultState()); } } }
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11) { this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); worldIn.setBlockToAir(pos); } }