类net.minecraft.world.EnumSkyBlock源码实例Demo

下面列出了怎么用net.minecraft.world.EnumSkyBlock的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TofuCraftReload   文件: EntityTofuSlime.java
@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;
}
 
源代码2 项目: Sakura_mod   文件: BlockBambooShoot.java
@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));
        }
    	}
    }
}
 
源代码3 项目: Wizardry   文件: ChunkGeneratorUnderWorld.java
@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;
}
 
源代码4 项目: NotEnoughItems   文件: WorldOverlayRenderer.java
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;
}
 
源代码5 项目: Et-Futurum   文件: InvertedDaylightDetector.java
@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);
	}
}
 
源代码6 项目: NotEnoughItems   文件: WorldOverlayRenderer.java
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;
}
 
源代码7 项目: mocreaturesdev   文件: MoCEntityMob.java
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);
}
 
源代码8 项目: PneumaticCraft   文件: WorldDayLightSensor.java
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;
}
 
源代码9 项目: CommunityMod   文件: ShipStorage.java
@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;
}
 
源代码10 项目: CommunityMod   文件: ShipStorage.java
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;
	}
}
 
源代码11 项目: GT-Classic   文件: GTTileLamp.java
@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());
	}
}
 
源代码12 项目: ForgeWurst   文件: MobSpawnEspHack.java
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;
}
 
源代码13 项目: customstuff4   文件: BlockSnow.java
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > content.maxLight)
    {
        worldIn.setBlockToAir(pos);
    }
}
 
源代码14 项目: Gadomancy   文件: FakeWorldTCGeneration.java
@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;
    }
}
 
源代码15 项目: Gadomancy   文件: FakeWorldTCGeneration.java
@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;
}
 
源代码16 项目: Gadomancy   文件: TileBlockProtector.java
@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);
    }
}
 
源代码17 项目: AdvancedRocketry   文件: WorldDummy.java
@SideOnly(Side.CLIENT)
public int getLightFromNeighborsFor(EnumSkyBlock type, BlockPos pos)
{
	if(type == EnumSkyBlock.SKY)
		return 15;
	return super.getLightFromNeighborsFor(type, pos);
}
 
源代码18 项目: AgriCraft   文件: LightHelper.java
@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;
}
 
源代码19 项目: enderutilities   文件: TileEntityEnderUtilities.java
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();
    }
}
 
源代码20 项目: enderutilities   文件: TileEntityEnderUtilities.java
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;
}
 
源代码21 项目: Sakura_mod   文件: WorldGenHotSpring.java
public boolean generate(World worldIn, Random rand, BlockPos position) {
      for (position = position.add(-8, 0, -8); position.getY() > 5 && worldIn.isAirBlock(position); position = position.down()) {
          ;
      }
position = position.down(4);
boolean[] aboolean = new boolean[2048];
int i = rand.nextInt(4) + 4;

for (int j = 0; j < i; ++j) {
    double d0 = rand.nextDouble() * 6.0D + 3.0D;
    double d1 = rand.nextDouble() * 4.0D + 2.0D;
    double d2 = rand.nextDouble() * 6.0D + 3.0D;
    double d3 = rand.nextDouble() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D;
    double d4 = rand.nextDouble() * (8.0D - d1 - 4.0D) + 2.0D + d1 / 2.0D;
    double d5 = rand.nextDouble() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D;

    for (int l = 1; l < 15; ++l) {
        for (int i1 = 1; i1 < 15; ++i1) {
            for (int j1 = 1; j1 < 7; ++j1) {
                double d6 = (l - d3) / (d0 / 2.0D);
                double d7 = (j1 - d4) / (d1 / 2.0D);
                double d8 = (i1 - d5) / (d2 / 2.0D);
                double d9 = d6 * d6 + d7 * d7 + d8 * d8;

                if (d9 < 1.0D)
                    aboolean[(l * 16 + i1) * 8 + j1] = true;
            }
        }
    }
}

for (int k1 = 0; k1 < 16; ++k1){
    for (int l2 = 0; l2 < 16; ++l2) {
        for (int k = 0; k < 8; ++k) {
            boolean flag = !aboolean[(k1 * 16 + l2) * 8 + k] && (k1 < 15 && aboolean[((k1 + 1) * 16 + l2) * 8 + k] || k1 > 0 && aboolean[((k1 - 1) * 16 + l2) * 8 + k] || l2 < 15 && aboolean[(k1 * 16 + l2 + 1) * 8 + k] || l2 > 0 && aboolean[(k1 * 16 + (l2 - 1)) * 8 + k] || k < 7 && aboolean[(k1 * 16 + l2) * 8 + k + 1] || k > 0 && aboolean[(k1 * 16 + l2) * 8 + (k - 1)]);

            if (flag) {
                Material material = worldIn.getBlockState(position.add(k1, k, l2)).getMaterial();

                if (k >= 4 && material.isLiquid())  {
                    return false;
                }

                if (k < 4 && !material.isSolid() && worldIn.getBlockState(position.add(k1, k, l2)).getBlock() != BlockLoader.HOT_SPRING_WATER)  {
                    return false;
                }
            }
        }
    }
}

for (int l1 = 0; l1 < 16; ++l1) {
    for (int i3 = 0; i3 < 16; ++i3) {
        for (int i4 = 0; i4 < 8; ++i4) {
            if (aboolean[(l1 * 16 + i3) * 8 + i4]) {
                worldIn.setBlockState(position.add(l1, i4, i3), i4 >= 4 ? Blocks.AIR.getDefaultState() : BlockLoader.HOT_SPRING_WATER.getDefaultState(), 2);
            }
        }
    }
}

for (int i2 = 0; i2 < 16; ++i2){
    for (int j3 = 0; j3 < 16; ++j3) {
        for (int j4 = 4; j4 < 8; ++j4) {
            if (aboolean[(i2 * 16 + j3) * 8 + j4]) {
                BlockPos blockpos = position.add(i2, j4 - 1, j3);

                if (worldIn.getBlockState(blockpos).getBlock() == Blocks.DIRT && worldIn.getLightFor(EnumSkyBlock.SKY, position.add(i2, j4, j3)) > 0) {
                    Biome biome = worldIn.getBiome(blockpos);

                    if (biome.topBlock.getBlock() == Blocks.MYCELIUM) {
                        worldIn.setBlockState(blockpos, Blocks.MYCELIUM.getDefaultState(), 2);
                    }
                    else {
                        worldIn.setBlockState(blockpos, Blocks.GRASS.getDefaultState(), 2);
                    }
                }
            }
        }
    }
}
   for (int j2 = 0; j2 < 16; ++j2) {
       for (int k3 = 0; k3 < 16; ++k3) {
           for (int k4 = 0; k4 < 8; ++k4) {
               boolean flag1 = !aboolean[(j2 * 16 + k3) * 8 + k4] && (j2 < 15 && aboolean[((j2 + 1) * 16 + k3) * 8 + k4] || j2 > 0 && aboolean[((j2 - 1) * 16 + k3) * 8 + k4] || k3 < 15 && aboolean[(j2 * 16 + k3 + 1) * 8 + k4] || k3 > 0 && aboolean[(j2 * 16 + (k3 - 1)) * 8 + k4] || k4 < 7 && aboolean[(j2 * 16 + k3) * 8 + k4 + 1] || k4 > 0 && aboolean[(j2 * 16 + k3) * 8 + (k4 - 1)]);
               if (flag1 && (k4 < 4 || rand.nextInt(2) != 0) && worldIn.getBlockState(position.add(j2, k4, k3)).getMaterial().isSolid()){
                   worldIn.setBlockState(position.add(j2, k4, k3), Blocks.STONE.getDefaultState(), 2);
               }
           }
       }
   }

return true;
  }
 
源代码22 项目: Hyperium   文件: MixinChunk.java
@Inject(method = "getLightFor", at = @At("HEAD"), cancellable = true)
private void getLightFor(EnumSkyBlock type, BlockPos pos, CallbackInfoReturnable<Integer> ci) {
    setLightValueInt(ci);
}
 
源代码23 项目: Kettle   文件: CraftBlock.java
public byte getLightFromSky() {
    return (byte) chunk.getHandle().getWorld().getLightFor(EnumSkyBlock.SKY, new BlockPos(this.x, this.y, this.z));
}
 
源代码24 项目: Kettle   文件: CraftBlock.java
public byte getLightFromBlocks() {
    return (byte) chunk.getHandle().getWorld().getLightFor(EnumSkyBlock.BLOCK, new BlockPos(this.x, this.y, this.z));
}
 
源代码25 项目: litematica   文件: WorldSchematic.java
@Override
public int getLightFor(EnumSkyBlock type, BlockPos pos)
{
    return 15;
}
 
源代码26 项目: litematica   文件: WorldSchematic.java
@Override
public int getLightFromNeighborsFor(EnumSkyBlock type, BlockPos pos)
{
    return 15;
}
 
源代码27 项目: litematica   文件: WorldSchematic.java
@Override
public boolean checkLightFor(EnumSkyBlock lightType, BlockPos pos)
{
    return false;
}
 
源代码28 项目: litematica   文件: ChunkSchematic.java
@Override
public int getLightFor(EnumSkyBlock type, BlockPos pos)
{
    return 15;
}
 
源代码29 项目: litematica   文件: ChunkSchematic.java
@Override
public void setLightFor(EnumSkyBlock type, BlockPos pos, int value)
{
    // NO-OP
}
 
源代码30 项目: ForgeHax   文件: WorldCheckLightForEvent.java
public WorldCheckLightForEvent(EnumSkyBlock enumSkyBlock, BlockPos pos) {
  this.enumSkyBlock = enumSkyBlock;
  this.pos = pos;
}
 
 类所在包
 类方法
 同包方法