本文整理汇总了Java中net.minecraft.block.state.IBlockState.getLightOpacity方法的典型用法代码示例。如果您正苦于以下问题:Java IBlockState.getLightOpacity方法的具体用法?Java IBlockState.getLightOpacity怎么用?Java IBlockState.getLightOpacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.block.state.IBlockState
的用法示例。
在下文中一共展示了IBlockState.getLightOpacity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTick
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity(worldIn, pos.up()) > 2)
{
worldIn.setBlockState(pos,Util.getDirt(state));
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
{
return;
}
IBlockState iblockstate = worldIn.getBlockState(blockpos.up());
IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
if (Util.isDirt(iblockstate1.getBlock()) && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate.getLightOpacity(worldIn, pos.up()) <= 2)
{
worldIn.setBlockState(blockpos, Util.getGrass(iblockstate1));
}
}
}
}
}
}
示例2: updateTick
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity(worldIn, pos.up()) > 2)
{
worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState());
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
{
return;
}
IBlockState iblockstate = worldIn.getBlockState(blockpos.up());
IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
if (iblockstate1.getBlock() == Blocks.DIRT && iblockstate1.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate.getLightOpacity(worldIn, pos.up()) <= 2)
{
worldIn.setBlockState(blockpos, UCBlocks.oldGrass.getDefaultState());
}
}
}
}
}
}
示例3: generateHeightMap
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
* Generates the height map for a chunk from scratch
*/
protected void generateHeightMap()
{
int i = this.getTopFilledSegment();
this.heightMapMinimum = Integer.MAX_VALUE;
for (int j = 0; j < 16; ++j)
{
for (int k = 0; k < 16; ++k)
{
this.precipitationHeightMap[j + (k << 4)] = -999;
for (int l = i + 16; l > 0; --l)
{
IBlockState iblockstate = this.getBlockState(j, l - 1, k);
if (iblockstate.getLightOpacity() != 0)
{
this.heightMap[k << 4 | j] = l;
if (l < this.heightMapMinimum)
{
this.heightMapMinimum = l;
}
break;
}
}
}
}
this.isModified = true;
}
示例4: canBlockSeeSky
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public boolean canBlockSeeSky(BlockPos pos)
{
if (pos.getY() >= this.getSeaLevel())
{
return this.canSeeSky(pos);
}
else
{
BlockPos blockpos = new BlockPos(pos.getX(), this.getSeaLevel(), pos.getZ());
if (!this.canSeeSky(blockpos))
{
return false;
}
else
{
for (blockpos = blockpos.down(); blockpos.getY() > pos.getY(); blockpos = blockpos.down())
{
IBlockState iblockstate = this.getBlockState(blockpos);
if (iblockstate.getLightOpacity() > 0 && !iblockstate.getMaterial().isLiquid())
{
return false;
}
}
return true;
}
}
}
示例5: updateTick
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity() > 2)
{
worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
IBlockState iblockstate1 = worldIn.getBlockState(blockpos.up());
if (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate1.getLightOpacity() <= 2)
{
worldIn.setBlockState(blockpos, this.getDefaultState());
}
}
}
}
}
}
示例6: updateTick
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if ((rand.nextInt(3) == 0 || this.countNeighbors(worldIn, pos) < 4) && worldIn.getLightFromNeighbors(pos) > 11 - ((Integer)state.getValue(AGE)).intValue() - state.getLightOpacity())
{
this.slightlyMelt(worldIn, pos, state, rand, true);
}
else
{
worldIn.scheduleUpdate(pos, this, MathHelper.getInt(rand, 20, 40));
}
}
示例7: updateTick
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity() > 2)
{
worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState());
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
{
return;
}
IBlockState iblockstate = worldIn.getBlockState(blockpos.up());
IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
if (iblockstate1.getBlock() == Blocks.DIRT && iblockstate1.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate.getLightOpacity() <= 2)
{
worldIn.setBlockState(blockpos, Blocks.GRASS.getDefaultState());
}
}
}
}
}
}
示例8: generateHeightMap
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
* Generates the height map for a chunk from scratch
*/
@SideOnly(Side.CLIENT)
protected void generateHeightMap()
{
int i = this.getTopFilledSegment();
this.heightMapMinimum = Integer.MAX_VALUE;
for (int j = 0; j < 16; ++j)
{
for (int k = 0; k < 16; ++k)
{
this.precipitationHeightMap[j + (k << 4)] = -999;
for (int l = i + 16; l > 0; --l)
{
IBlockState iblockstate = this.getBlockState(j, l - 1, k);
if (iblockstate.getLightOpacity(this.worldObj, new BlockPos(j, l - 1, k)) != 0)
{
this.heightMap[k << 4 | j] = l;
if (l < this.heightMapMinimum)
{
this.heightMapMinimum = l;
}
break;
}
}
}
}
this.isModified = true;
}
示例9: updateTick
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity(worldIn, pos.up()) > 2)
{
worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
IBlockState iblockstate1 = worldIn.getBlockState(blockpos.up());
if (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate1.getLightOpacity(worldIn, blockpos.up()) <= 2)
{
worldIn.setBlockState(blockpos, this.getDefaultState());
}
}
}
}
}
}
示例10: updateTick
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if ((rand.nextInt(3) == 0 || this.countNeighbors(worldIn, pos) < 4) && worldIn.getLightFromNeighbors(pos) > 11 - ((Integer)state.getValue(AGE)).intValue() - state.getLightOpacity())
{
this.slightlyMelt(worldIn, pos, state, rand, true);
}
else
{
worldIn.scheduleUpdate(pos, this, MathHelper.getRandomIntegerInRange(rand, 20, 40));
}
}
示例11: updateTick
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity(worldIn, pos.up()) > 2)
{
worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState());
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
if (blockpos.getY() >= 0 && blockpos.getY() < 256 && !worldIn.isBlockLoaded(blockpos))
{
return;
}
IBlockState iblockstate = worldIn.getBlockState(blockpos.up());
IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
if (iblockstate1.getBlock() == Blocks.DIRT && iblockstate1.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && iblockstate.getLightOpacity(worldIn, pos.up()) <= 2)
{
worldIn.setBlockState(blockpos, Blocks.GRASS.getDefaultState());
}
}
}
}
}
}
示例12: setBlockState
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
* Sets the block state at a given location. Flag 1 will cause a block update. Flag 2 will send the change to
* clients (you almost always want this). Flag 4 prevents the block from being re-rendered, if this is a client
* world. Flags can be added together.
*/
public boolean setBlockState(BlockPos pos, IBlockState newState, int flags)
{
if (this.isOutsideBuildHeight(pos))
{
return false;
}
else if (!this.isRemote && this.worldInfo.getTerrainType() == WorldType.DEBUG_WORLD)
{
return false;
}
else
{
Chunk chunk = this.getChunkFromBlockCoords(pos);
Block block = newState.getBlock();
IBlockState iblockstate = chunk.setBlockState(pos, newState);
if (iblockstate == null)
{
return false;
}
else
{
if (newState.getLightOpacity() != iblockstate.getLightOpacity() || newState.getLightValue() != iblockstate.getLightValue())
{
this.theProfiler.startSection("checkLight");
this.checkLight(pos);
this.theProfiler.endSection();
}
if ((flags & 2) != 0 && (!this.isRemote || (flags & 4) == 0) && chunk.isPopulated())
{
this.notifyBlockUpdate(pos, iblockstate, newState, flags);
}
if (!this.isRemote && (flags & 1) != 0)
{
this.notifyNeighborsRespectDebug(pos, iblockstate.getBlock(), true);
if (newState.hasComparatorInputOverride())
{
this.updateComparatorOutputLevel(pos, block);
}
}
else if (!this.isRemote && (flags & 16) == 0)
{
this.func_190522_c(pos, block);
}
return true;
}
}
}
示例13: getRawLight
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
* gets the light level at the supplied position
*/
private int getRawLight(BlockPos pos, EnumSkyBlock lightType)
{
if (lightType == EnumSkyBlock.SKY && this.canSeeSky(pos))
{
return 15;
}
else
{
IBlockState iblockstate = this.getBlockState(pos);
int i = lightType == EnumSkyBlock.SKY ? 0 : iblockstate.getLightValue();
int j = iblockstate.getLightOpacity();
if (j >= 15 && iblockstate.getLightValue() > 0)
{
j = 1;
}
if (j < 1)
{
j = 1;
}
if (j >= 15)
{
return 0;
}
else if (i >= 14)
{
return i;
}
else
{
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain();
for (EnumFacing enumfacing : EnumFacing.values())
{
blockpos$pooledmutableblockpos.setPos(pos).move(enumfacing);
int k = this.getLightFor(lightType, blockpos$pooledmutableblockpos) - j;
if (k > i)
{
i = k;
}
if (i >= 14)
{
return i;
}
}
blockpos$pooledmutableblockpos.release();
return i;
}
}
}
示例14: getBlockLightOpacity
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
private int getBlockLightOpacity(int x, int y, int z)
{
IBlockState state = this.getBlockState(x, y, z); //Forge: Can sometimes be called before we are added to the global world list. So use the less accurate one during that. It'll be recalculated later
return this.unloaded ? state.getLightOpacity() : state.getLightOpacity(this.worldObj, new BlockPos(x, y, z));
}
示例15: setBlockState
import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
* Sets the block state at a given location. Flag 1 will cause a block update. Flag 2 will send the change to
* clients (you almost always want this). Flag 4 prevents the block from being re-rendered, if this is a client
* world. Flags can be added together.
*/
public boolean setBlockState(BlockPos pos, IBlockState newState, int flags)
{
if (this.isOutsideBuildHeight(pos))
{
return false;
}
else if (!this.isRemote && this.worldInfo.getTerrainType() == WorldType.DEBUG_WORLD)
{
return false;
}
else
{
Chunk chunk = this.getChunkFromBlockCoords(pos);
Block block = newState.getBlock();
net.minecraftforge.common.util.BlockSnapshot blockSnapshot = null;
if (this.captureBlockSnapshots && !this.isRemote)
{
blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(this, pos, flags);
this.capturedBlockSnapshots.add(blockSnapshot);
}
IBlockState oldState = getBlockState(pos);
int oldLight = oldState.getLightValue(this, pos);
int oldOpacity = oldState.getLightOpacity(this, pos);
IBlockState iblockstate = chunk.setBlockState(pos, newState);
if (iblockstate == null)
{
if (blockSnapshot != null) this.capturedBlockSnapshots.remove(blockSnapshot);
return false;
}
else
{
if (newState.getLightOpacity(this, pos) != oldOpacity || newState.getLightValue(this, pos) != oldLight)
{
this.theProfiler.startSection("checkLight");
this.checkLight(pos);
this.theProfiler.endSection();
}
if (blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates
{
this.markAndNotifyBlock(pos, chunk, iblockstate, newState, flags);
}
return true;
}
}
}