本文整理了Java中net.minecraft.world.World.getBlockState()
方法的一些代码示例,展示了World.getBlockState()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.getBlockState()
方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:getBlockState
暂无
代码示例来源:origin: EngineHub/WorldEdit
@Override
public void simulateBlockMine(BlockVector3 position) {
BlockPos pos = ForgeAdapter.toBlockPos(position);
IBlockState state = getWorld().getBlockState(pos);
state.getBlock().dropBlockAsItem(getWorld(), pos, state, 0);
getWorld().setBlockToAir(pos);
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public BlockState getBlock(BlockVector3 position) {
World world = getWorld();
BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
IBlockState mcState = world.getBlockState(pos);
BlockType blockType = BlockType.REGISTRY.get(Block.REGISTRY.getNameForObject(mcState.getBlock()).toString());
return blockType.getState(adaptProperties(blockType, mcState.getProperties()));
}
代码示例来源:origin: Vazkii/Botania
@Override
public LexiconEntry getEntry(World world, BlockPos pos, EntityPlayer player, ItemStack lexicon) {
boolean isDefaultVariant = world.getBlockState(pos).getValue(BotaniaStateProps.LIVINGROCK_VARIANT) == LivingRockVariant.DEFAULT;
return isDefaultVariant ? LexiconData.pureDaisy : LexiconData.decorativeBlocks;
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
public static boolean isBlockAir( final World w, final BlockPos pos )
{
try
{
return w.getBlockState( pos ).getBlock().isAir( w.getBlockState( pos ), w, pos );
}
catch( final Throwable e )
{
return false;
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
private void dropTorch( final World w, final BlockPos pos )
{
final IBlockState prev = w.getBlockState( pos );
w.destroyBlock( pos, true );
w.notifyBlockUpdate( pos, prev, w.getBlockState( pos ), 3 );
}
代码示例来源:origin: Vazkii/Botania
@Override
public LexiconEntry getEntry(World world, BlockPos pos, EntityPlayer player, ItemStack lexicon) {
SpreaderVariant variant = world.getBlockState(pos).getValue(BotaniaStateProps.SPREADER_VARIANT);
return variant == SpreaderVariant.MANA ? LexiconData.spreader : variant == SpreaderVariant.REDSTONE ? LexiconData.redstoneSpreader : LexiconData.dreamwoodSpreader;
}
代码示例来源:origin: Vazkii/Botania
@Override
public LexiconEntry getEntry(World world, BlockPos pos, EntityPlayer player, ItemStack lexicon) {
boolean defaultVariant = world.getBlockState(pos).getValue(BotaniaStateProps.LIVINGWOOD_VARIANT) == LivingWoodVariant.DEFAULT;
return defaultVariant ? LexiconData.pureDaisy : LexiconData.decorativeBlocks;
}
代码示例来源:origin: Vazkii/Botania
@Nonnull
@Override
public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) {
return new ItemStack(this, 1, getMetaFromState(world.getBlockState(pos)));
}
代码示例来源:origin: Vazkii/Botania
@Nonnull
@Override
public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) {
return new ItemStack(this, 1, getMetaFromState(world.getBlockState(pos)));
}
代码示例来源:origin: Vazkii/Botania
private boolean isValidBinding() {
BlockPos nextDest = getNextDestination();
if(nextDest == null)
return false;
Block block = world.getBlockState(nextDest).getBlock();
return block == ModBlocks.lightRelay;
}
代码示例来源:origin: Vazkii/Botania
@Override
public int getAvailableSpaceForMana() {
int space = Math.max(0, manaCap - getCurrentMana());
if(space > 0)
return space;
else if(world.getBlockState(pos.down()).getBlock() == ModBlocks.manaVoid)
return manaCap;
else return 0;
}
代码示例来源:origin: Vazkii/Botania
@Override
public boolean canPlaceBlockAt(World world, BlockPos pos) {
return world.getBlockState(pos.down()).getBlock() == ModBlocks.redStringRelay
|| world.getBlockState(pos.down()).getBlock() == Blocks.MYCELIUM
|| super.canPlaceBlockAt(world, pos);
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@Override
public void onReady()
{
super.onReady();
final int value = this.world.getBlockState( this.pos ).getValue( BlockEnergyCell.ENERGY_STORAGE );
this.currentMeta = (byte) value;
this.changePowerLevel();
}
代码示例来源:origin: Vazkii/Botania
private boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
if (!world.setBlockState(pos, newState, 3)) return false;
IBlockState state = world.getBlockState(pos);
if (state.getBlock() == ModBlocks.buriedPetals)
{
// setTileEntityNBT(world, player, pos, stack);
ModBlocks.buriedPetals.onBlockPlacedBy(world, pos, state, player, stack);
}
return true;
}
代码示例来源:origin: Vazkii/Botania
@Override
public boolean bindTo(EntityPlayer player, ItemStack wand, BlockPos pos, EnumFacing side) {
if(player.world.getBlockState(pos).getBlock() != ModBlocks.lightRelay || pos.distanceSq(getPos()) > MAX_DIST * MAX_DIST)
return false;
bindPos = pos;
return true;
}
代码示例来源:origin: Vazkii/Botania
private RecipePureDaisy findRecipe(BlockPos coords) {
IBlockState state = getWorld().getBlockState(coords);
for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes) {
if(recipe.matches(getWorld(), coords, this, state)) {
return recipe;
}
}
return null;
}
代码示例来源:origin: Vazkii/Botania
private boolean isPlant(BlockPos pos) {
IBlockState state = supertile.getWorld().getBlockState(pos);
Block block = state.getBlock();
if(block == Blocks.GRASS || block == Blocks.LEAVES || block == Blocks.LEAVES2 || block instanceof BlockBush && !(block instanceof BlockCrops) && !(block instanceof BlockSapling))
return false;
Material mat = state.getMaterial();
return mat != null && (mat == Material.PLANTS || mat == Material.CACTUS || mat == Material.GRASS || mat == Material.LEAVES || mat == Material.GOURD) && block instanceof IGrowable && ((IGrowable) block).canGrow(supertile.getWorld(), pos, supertile.getWorld().getBlockState(pos), supertile.getWorld().isRemote);
}
代码示例来源:origin: Vazkii/Botania
public boolean onWanded() {
AlfPortalState state = world.getBlockState(getPos()).getValue(BotaniaStateProps.ALFPORTAL_STATE);
if(state == AlfPortalState.OFF) {
AlfPortalState newState = getValidState();
if(newState != AlfPortalState.OFF) {
world.setBlockState(getPos(), world.getBlockState(getPos()).withProperty(BotaniaStateProps.ALFPORTAL_STATE, newState), 1 | 2);
return true;
}
}
return false;
}
代码示例来源:origin: Vazkii/Botania
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
if(!world.isRemote && state.getBlock() == this && world.getLight(pos.up()) >= 9) {
AltGrassVariant variant = state.getValue(BotaniaStateProps.ALTGRASS_VARIANT);
for(int l = 0; l < 4; ++l) {
BlockPos pos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
world.getBlockState(pos1.up()).getBlock();
if(world.getBlockState(pos1).getBlock() == Blocks.DIRT && world.getBlockState(pos1).getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && world.getLight(pos1.up()) >= 4 && world.getBlockLightOpacity(pos1.up()) <= 2)
world.setBlockState(pos1, getDefaultState().withProperty(BotaniaStateProps.ALTGRASS_VARIANT, variant), 1 | 2);
}
}
}
代码示例来源:origin: Vazkii/Botania
@Override
public void render(@Nonnull TilePylon pylon, double d0, double d1, double d2, float pticks, int digProgress, float unused) {
boolean renderingItem = pylon == ForwardingTEISR.DUMMY;
if(!renderingItem && (!pylon.getWorld().isBlockLoaded(pylon.getPos(), false) || pylon.getWorld().getBlockState(pylon.getPos()).getBlock() != ModBlocks.pylon))
return;
renderPylon(pylon, d0, d1, d2, pticks, renderingItem);
}
内容来源于网络,如有侵权,请联系作者删除!