net.minecraft.world.EnumSkyBlock Java Examples
The following examples show how to use
net.minecraft.world.EnumSkyBlock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityTofuSlime.java From TofuCraftReload with MIT License | 6 votes |
@Override public boolean getCanSpawnHere() { if (this.world.getDifficulty() != EnumDifficulty.PEACEFUL) { int lightValue = this.world.getLightFromNeighbors(new BlockPos(MathHelper.floor(this.posX), MathHelper.floor(this.posY), MathHelper.floor(this.posZ))); if (this.dimension == TofuMain.TOFU_DIMENSION.getId() && this.rand.nextInt((int) (this.world.getLightBrightness(getPosition()) * 10 + 30)) == 0 && this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(48.0D, 20.0D, 48.0D)).size() == 0) { //It does not spawn when there is a light like a torch (spawns when there is no light like a torch even if there is light in the sky) return this.world.getLightFor(EnumSkyBlock.BLOCK, getPosition()) < 2 + this.rand.nextInt(6) && this.baseGetCanSpawnHere(); } if (this.dimension == 0 && this.rand.nextInt(10) == 0 && isSpawnChunk(this.world, this.posX, this.posZ) && this.posY < 40.0D && lightValue <= this.rand.nextInt(10)) return this.baseGetCanSpawnHere(); } return false; }
Example #2
Source File: WorldOverlayRenderer.java From NotEnoughItems with MIT License | 6 votes |
private static int getSpawnMode(Chunk chunk, int x, int y, int z) { World world = chunk.getWorld(); BlockPos pos = new BlockPos(x, y, z); if (!WorldEntitySpawner.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, world, pos) || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) >= 8) { return 0; } c.set(x + 0.2, y + 0.01, z + 0.2, x + 0.8, y + 1.8, z + 0.8); AxisAlignedBB aabb = c.aabb(); if (!world.checkNoEntityCollision(aabb) || !world.getEntitiesWithinAABBExcludingEntity(null, aabb).isEmpty() || world.containsAnyLiquid(aabb)) { return 0; } if (chunk.getLightFor(EnumSkyBlock.SKY, pos) >= 8) { return 1; } return 2; }
Example #3
Source File: InvertedDaylightDetector.java From Et-Futurum with The Unlicense | 6 votes |
@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); } }
Example #4
Source File: ChunkGeneratorUnderWorld.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@Nonnull @Override public Chunk generateChunk(int x, int z) { ChunkPrimer chunkprimer = new ChunkPrimer(); // Get a list of blocks to check lighting for, as a "side effect" of // actually generating the clouds List<Pair<BlockPos, BlockPos>> litBlocks = generate(x, z, chunkprimer); Chunk chunk = new Chunk(world, chunkprimer, x, z); litBlocks.forEach(pair -> { BlockPos lower = pair.getFirst(); BlockPos upper = pair.getSecond(); for (int i = 0; i < 15; i++) { if (lower.getY() + i > upper.getY()) return; chunk.setLightFor(EnumSkyBlock.BLOCK, lower.up(i), 15 - i); } }); return chunk; }
Example #5
Source File: WorldOverlayRenderer.java From NotEnoughItems with MIT License | 6 votes |
private static int getSpawnMode(Chunk chunk, int x, int y, int z) { World world = chunk.getWorld(); BlockPos pos = new BlockPos(x, y, z); if (!SpawnerAnimals.canCreatureTypeSpawnAtLocation(SpawnPlacementType.ON_GROUND, world, pos) || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) >= 8) return 0; c.set(x+0.2, y+0.01, z+0.2, x+0.8, y+1.8, z+0.8); AxisAlignedBB aabb = c.aabb(); if (!world.checkNoEntityCollision(aabb) || !world.getCollidingBoundingBoxes(dummyEntity, aabb).isEmpty() || world.isAnyLiquid(aabb)) return 0; if (chunk.getLightFor(EnumSkyBlock.SKY, pos) >= 8) return 1; return 2; }
Example #6
Source File: WorldDayLightSensor.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
private int updateLightLevel(World par1World, int par2, int par3, int par4){ if(!par1World.provider.hasNoSky) { int i1 = par1World.getSavedLightValue(EnumSkyBlock.Sky, par2, par3, par4) - par1World.skylightSubtracted; float f = par1World.getCelestialAngleRadians(1.0F); if(f < (float)Math.PI) { f += (0.0F - f) * 0.2F; } else { f += ((float)Math.PI * 2F - f) * 0.2F; } i1 = Math.round(i1 * MathHelper.cos(f)); if(i1 < 0) { i1 = 0; } if(i1 > 15) { i1 = 15; } return i1; } return 0; }
Example #7
Source File: MoCEntityMob.java From mocreaturesdev with GNU General Public License v3.0 | 6 votes |
public boolean getCanSpawnHereMob() { int i = MathHelper.floor_double(posX); int j = MathHelper.floor_double(boundingBox.minY); int k = MathHelper.floor_double(posZ); if (worldObj.getSavedLightValue(EnumSkyBlock.Sky, i, j, k) > rand.nextInt(32)) { return false; } int l = worldObj.getBlockLightValue(i, j, k); if (worldObj.isThundering()) { int i1 = worldObj.skylightSubtracted; worldObj.skylightSubtracted = 10; l = worldObj.getBlockLightValue(i, j, k); worldObj.skylightSubtracted = i1; } return l <= rand.nextInt(8); }
Example #8
Source File: BlockBambooShoot.java From Sakura_mod with MIT License | 6 votes |
@Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (!worldIn.isAreaLoaded(pos, 1)) return; // Forge: prevent growing cactus from loading unloaded chunks with block update BlockPos blockpos = pos.up(); if (worldIn.isAirBlock(blockpos)) { if(worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 6 + worldIn.rand.nextInt(6)){ int j = state.getValue(AGE).intValue(); if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, blockpos, state, true)) { if (j == 6) { if(rand.nextInt() ==0){ if(worldIn.isAirBlock(blockpos.up(2)))worldIn.setBlockState(blockpos.up(2), BlockLoader.BAMBOO.getDefaultState()); } if(worldIn.isAirBlock(blockpos.up()))worldIn.setBlockState(blockpos.up(), BlockLoader.BAMBOO.getDefaultState()); if(worldIn.isAirBlock(blockpos)) worldIn.setBlockState(blockpos, BlockLoader.BAMBOO.getDefaultState()); worldIn.setBlockState(pos, BlockLoader.BAMBOO.getDefaultState()); } else { worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(j + 1)), 4); } net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos)); } } } }
Example #9
Source File: ShipStorage.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@Override public int getCombinedLight(BlockPos pos, int lightValue) { int sky = getLightSet(EnumSkyBlock.SKY, pos); int map = getLightSet(EnumSkyBlock.BLOCK, pos); return sky << 20 | map << 4; }
Example #10
Source File: ShipStorage.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public int getLightSet(EnumSkyBlock type, BlockPos pos) { if (type == EnumSkyBlock.SKY) { return 15; } else if (blockMap.get(pos) != null) { return blockMap.get(pos).light; } else { return 0; } }
Example #11
Source File: WorldDummy.java From AdvancedRocketry with MIT License | 5 votes |
@SideOnly(Side.CLIENT) public int getLightFromNeighborsFor(EnumSkyBlock type, BlockPos pos) { if(type == EnumSkyBlock.SKY) return 15; return super.getLightFromNeighborsFor(type, pos); }
Example #12
Source File: BlockSnow.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > content.maxLight) { worldIn.setBlockToAir(pos); } }
Example #13
Source File: TileBlockProtector.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void readCustomNBT(NBTTagCompound compound) { super.readCustomNBT(compound); aspectFilter = ASPECT; int oldRange = range; range = compound.getInteger("ProtectRange"); if(worldObj != null && worldObj.isRemote && oldRange != range) { worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); } }
Example #14
Source File: FakeWorldTCGeneration.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int getSavedLightValue(EnumSkyBlock type, int x, int y, int z) { if(type == EnumSkyBlock.Block) { ChunkBuffer buf = chunks.get(((long) x >> 4) | ((long) z >> 4) << 32); int keyX = (x & 15) << 7 << 4; int keyZ = (z & 15) << 7; int key = keyX | keyZ | y; return buf.lightData[key]; } return 0; }
Example #15
Source File: LightHelper.java From AgriCraft with MIT License | 5 votes |
@Nonnull public static byte[] getLightData(@Nonnull World world, @Nonnull BlockPos pos) { // Validate Preconditions.checkNotNull(world); Preconditions.checkNotNull(pos); // Create the array. final byte lightData[] = new byte[LIGHT_METHOD_COUNT]; // Fill the array. lightData[0] = (byte) world.getLight(pos); lightData[1] = (byte) world.getLight(pos, false); lightData[2] = (byte) world.getLight(pos, true); lightData[3] = (byte) world.getLightFor(EnumSkyBlock.SKY, pos); lightData[4] = (byte) world.getLightFor(EnumSkyBlock.BLOCK, pos); lightData[5] = (byte) world.getLightFromNeighbors(pos); if (world.isRemote) { lightData[6] = (byte) world.getLightFromNeighborsFor(EnumSkyBlock.SKY, pos); lightData[7] = (byte) world.getLightFromNeighborsFor(EnumSkyBlock.BLOCK, pos); } else { lightData[6] = (byte) 0; lightData[7] = (byte) 0; } lightData[8] = (byte) world.getLightBrightness(pos); // Return the array. return lightData; }
Example #16
Source File: FakeWorldTCGeneration.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void setLightValue(EnumSkyBlock type, int x, int y, int z, int light) { if(type == EnumSkyBlock.Block) { int key = ((x & 15) << 4 | (z & 15)) << 7 | y; buf.lightData[key] = light; } }
Example #17
Source File: TileEntityEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private void removeCamouflage() { if (this.getWorld().isRemote == false && this.camoState != null) { this.camoState = null; this.getWorld().playSound(null, this.getPos(), SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, SoundCategory.BLOCKS, 1f, 1f); this.notifyBlockUpdate(this.getPos()); // Check light changes in case the camo block emits light this.getWorld().checkLightFor(EnumSkyBlock.BLOCK, this.getPos()); this.markDirty(); } }
Example #18
Source File: TileEntityEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private boolean applyCamouflage(EntityPlayer player, ItemStack stackOffhand, EnumFacing side, float hitX, float hitY, float hitZ) { if (stackOffhand.getItem() instanceof ItemBlock && ((ItemBlock) stackOffhand.getItem()).getBlock() != null) { World world = this.getWorld(); BlockPos posSelf = this.getPos(); Block block = ((ItemBlock) stackOffhand.getItem()).getBlock(); int meta = stackOffhand.getItem().getMetadata(stackOffhand.getMetadata()); IBlockState state = block.getStateForPlacement(world, posSelf, side, hitX, hitY, hitZ, meta, player, EnumHand.OFF_HAND); if (state != this.camoState) { if (this.getWorld().isRemote == false) { this.camoState = state; this.getWorld().playSound(null, this.getPos(), SoundEvents.ENTITY_ITEMFRAME_ADD_ITEM, SoundCategory.BLOCKS, 1f, 1f); this.notifyBlockUpdate(this.getPos()); // Check light changes in case the camo block emits light this.getWorld().checkLightFor(EnumSkyBlock.BLOCK, this.getPos()); this.markDirty(); } return true; } } return false; }
Example #19
Source File: MobSpawnEspHack.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
private void scan() { BlockPos min = new BlockPos(WChunk.getX(chunk) << 4, 0, WChunk.getZ(chunk) << 4); BlockPos max = new BlockPos((WChunk.getX(chunk) << 4) + 15, 255, (WChunk.getZ(chunk) << 4) + 15); Stream<BlockPos> stream = StreamSupport .stream(BlockPos.getAllInBox(min, max).spliterator(), false); WorldClient world = WMinecraft.getWorld(); List<BlockPos> blocks = stream.filter(pos -> { return !BlockUtils.getMaterial(pos).blocksMovement() && !(BlockUtils.getBlock(pos) instanceof BlockLiquid) && BlockUtils.getState(pos.down()).isSideSolid(world, pos.down(), EnumFacing.UP); }).collect(Collectors.toList()); if(Thread.interrupted()) return; red.addAll(blocks.stream() .filter(pos -> world.getLightFor(EnumSkyBlock.BLOCK, pos) < 8) .filter(pos -> world.getLightFor(EnumSkyBlock.SKY, pos) < 8) .collect(Collectors.toList())); if(Thread.interrupted()) return; yellow.addAll(blocks.stream().filter(pos -> !red.contains(pos)) .filter(pos -> world.getLightFor(EnumSkyBlock.BLOCK, pos) < 8) .collect(Collectors.toList())); doneScanning = true; }
Example #20
Source File: GTTileLamp.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onNetworkUpdate(String field) { super.onNetworkUpdate(field); if (field.equals(NBT_LEVEL)) { this.world.markBlockRangeForRenderUpdate(this.getPos(), this.getPos()); this.world.checkLightFor(EnumSkyBlock.BLOCK, this.getPos()); } }
Example #21
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void relightSky(int x, int y, int z) { pos.setPos(x, y, z); nmsWorld.checkLightFor(EnumSkyBlock.SKY, pos); }
Example #22
Source File: TileEntityEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void handleUpdateTag(NBTTagCompound tag) { if (tag.hasKey("r")) { this.setFacing(EnumFacing.byIndex((byte)(tag.getByte("r") & 0x07))); } if (tag.hasKey("o", Constants.NBT.TAG_STRING)) { this.ownerData = new OwnerData(tag.getString("o"), tag.getBoolean("pu")); } if (tag.hasKey("Camo", Constants.NBT.TAG_INT)) { this.camoState = Block.getStateById(tag.getInteger("Camo")); World world = this.getWorld(); BlockPos pos = this.getPos(); IBlockState stateSelf = world.getBlockState(pos); // Temporarily place the target block to be able to grab its data if (this.camoState != null && this.camoState.getBlock() != Blocks.AIR) { try { BlockUtils.setBlockToAirWithoutSpillingContents(world, pos, 16); if (world.setBlockState(pos, this.camoState, 16)) { if (tag.hasKey("CD", Constants.NBT.TAG_COMPOUND)) { this.camoData = tag.getCompoundTag("CD"); TileEntity te = world.getTileEntity(pos); if (te != null) { te.handleUpdateTag(this.camoData); } } this.camoState = this.camoState.getActualState(world, pos); this.camoStateExtended = this.camoState.getBlock().getExtendedState(this.camoState, world, pos); BlockUtils.setBlockToAirWithoutSpillingContents(world, pos, 16); world.setBlockState(pos, stateSelf, 16); this.validate(); // re-validate after being removed by the setBlockState() to air world.setTileEntity(pos, this); } } catch (Exception e) { EnderUtilities.logger.warn("Exception while trying to grab the Extended state for a camo block: {}", this.camoState, e); } } } else { this.camoState = null; this.camoStateExtended = null; } this.getWorld().checkLightFor(EnumSkyBlock.BLOCK, this.getPos()); this.notifyBlockUpdate(this.getPos()); }
Example #23
Source File: MethodGetBrightness.java From AgriCraft with MIT License | 4 votes |
@Override protected Object[] onMethodCalled(TileEntityCrop crop) { return new Object[]{Math.max(crop.getWorld().getLightFor(EnumSkyBlock.SKY, crop.getPos()), crop.getWorld().getLightFor(EnumSkyBlock.BLOCK, crop.getPos()))}; }
Example #24
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void relightBlock(int x, int y, int z) { pos.setPos(x, y, z); nmsWorld.checkLightFor(EnumSkyBlock.BLOCK, pos); }
Example #25
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void relightSky(int x, int y, int z) { pos.setPos(x, y, z); nmsWorld.checkLightFor(EnumSkyBlock.SKY, pos); }
Example #26
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void relightBlock(int x, int y, int z) { pos.set(x, y, z); nmsWorld.checkLightFor(EnumSkyBlock.BLOCK, pos); }
Example #27
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void relightBlock(int x, int y, int z) { pos.setPos(x, y, z); nmsWorld.checkLightFor(EnumSkyBlock.BLOCK, pos); }
Example #28
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void relightSky(int x, int y, int z) { nmsWorld.updateLightByType(EnumSkyBlock.Sky, x, y, z); }
Example #29
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void relightBlock(int x, int y, int z) { nmsWorld.updateLightByType(EnumSkyBlock.Block, x, y, z); }
Example #30
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void relightSky(int x, int y, int z) { pos.setPos(x, y, z); nmsWorld.checkLightFor(EnumSkyBlock.SKY, pos); }