本文整理汇总了Java中net.minecraft.block.BlockSlab类的典型用法代码示例。如果您正苦于以下问题:Java BlockSlab类的具体用法?Java BlockSlab怎么用?Java BlockSlab使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockSlab类属于net.minecraft.block包,在下文中一共展示了BlockSlab类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BlockWoodSlab
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
public BlockWoodSlab(WoodMaterial wd) {
super(Material.WOOD);
this.setSoundType(SoundType.WOOD);
this.wood = wd;
this.blockHardness = wood.getPlankBlockHardness();
this.blockResistance = wood.getBlastResistance();
this.setHarvestLevel("axe", wood.getRequiredHarvestLevel());
Blocks.FIRE.setFireInfo(this, 5, 20);
IBlockState iblockstate = this.blockState.getBaseState();
if (!this.isDouble()) {
iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
}
this.setDefaultState(iblockstate.withProperty(VARIANT, BlockWoodSlab.Variant.DEFAULT));
this.useNeighborBrightness = !this.isDouble();
}
示例2: canPlaceBlockOnSide
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
BlockPos blockpos = pos;
IProperty iproperty = this.singleSlab.getVariantProperty();
Object object = this.singleSlab.getVariant(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab)
{
boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;
if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && object == iblockstate.getValue(iproperty))
{
return true;
}
}
pos = pos.offset(side);
IBlockState iblockstate1 = worldIn.getBlockState(pos);
return iblockstate1.getBlock() == this.singleSlab && object == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos, side, player, stack);
}
示例3: BlockRubberSlab
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
public BlockRubberSlab() {
super(Material.WOOD, MapColor.WOOD);
IBlockState iblockstate = this.blockState.getBaseState();
if (!this.isDouble()) {
iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
setRegistryName(new ResourceLocation(TRConstants.MOD_ID, "rubber_slab"));
} else {
setRegistryName(new ResourceLocation(TRConstants.MOD_ID, "rubber_double_slab"));
}
setCreativeTab(TechRebornCreativeTab.TECHREBORN);
setUnlocalizedName(getRegistryName().toString());
setHarvestLevel("axe", 0);
setHardness(2.0F);
setResistance(15);
setSoundType(SoundType.WOOD);
TechReborn.blockModelsToRegister.add(this);
this.setDefaultState(iblockstate.withProperty(VARIANT, BlockRubberSlab.Variant.DEFAULT));
}
示例4: test_getSubtype
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void test_getSubtype() throws Exception
{
ContentBlockSlab content = new ContentBlockSlab();
content.subtypes = new int[] {0, 1, 2, 3, 4, 5, 6, 7};
content.id = "test_getSubtype";
Block block = content.createBlock();
CSBlock<ContentBlockSlab> csblock = (CSBlock<ContentBlockSlab>) block;
for (int subtype = 0; subtype < 8; subtype++)
{
for (BlockSlab.EnumBlockHalf facing : BlockSlabWithSubtypes.HALF.getAllowedValues())
{
IBlockState state = block.getDefaultState()
.withProperty(BlockSlabWithSubtypes.HALF, facing)
.withProperty(BlockHelper.getSubtypeProperty(content.subtypes), EnumSubtype.values()[subtype]);
assertEquals(subtype, csblock.getSubtype(state));
}
}
}
示例5: canPlaceBlockOnSide
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
BlockPos blockpos = pos;
IProperty<?> iproperty = this.singleSlab.getVariantProperty();
Comparable<?> comparable = this.singleSlab.getTypeForItem(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab)
{
boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;
if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && comparable == iblockstate.getValue(iproperty))
{
return true;
}
}
pos = pos.offset(side);
IBlockState iblockstate1 = worldIn.getBlockState(pos);
return iblockstate1.getBlock() == this.singleSlab && comparable == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos, side, player, stack);
}
示例6: canPlaceBlockOnSide
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
BlockPos blockpos = pos;
IProperty<?> iproperty = this.singleSlab.getVariantProperty();
Comparable<?> comparable = this.singleSlab.getTypeForItem(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab)
{
boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;
if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && comparable == iblockstate.getValue(iproperty))
{
return true;
}
}
pos = pos.offset(side);
IBlockState iblockstate1 = worldIn.getBlockState(pos);
return iblockstate1.getBlock() == this.singleSlab && comparable == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos, side, player, stack);
}
示例7: placeHut
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
public static void placeHut(final World world, BlockPos startpos, int[][][] data, IBlockState[] states, Random rand) {
for (int pass = 0; pass <= 1; pass++) {
for (int y = 0; y < data.length; y++) {
for (int x = 0; x < 6; x++) {
for (int z = 0; z < 6; z++) {
BlockPos pos = startpos.add(x + 5, -y + 5, z + 5);
if (data[y][z][x] != -1) {
IBlockState state = states[data[y][z][x]];
if (state == null || (pass == 0 && (state.getBlock() instanceof BlockCarpet || state.getBlock() instanceof BlockSapling))) {
world.setBlockToAir(pos);
} else if (state.getBlock() instanceof BlockFalling) {
while (world.getBlockState(pos).getBlock().isReplaceable(world, pos) && !world.isAirBlock(new BlockPos(pos.getX(), 0, pos.getZ()))) {
world.setBlockState(pos, state);
world.immediateBlockTick(pos, state, rand);
}
} else if (!(state.getBlock() instanceof BlockSlab)
|| (world.getBlockState(pos).getBlock().isReplaceable(world, pos) && world.getBlockState(pos).getMaterial() != Material.WATER)) {
world.setBlockState(pos, state);
}
}
}
}
}
}
}
示例8: getMetaFromState
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
@Override
public int getMetaFromState(IBlockState state)
{
if (!this.isDouble())
{
if (state.getValue(HALF) == BlockSlab.EnumBlockHalf.BOTTOM)
{
return 0;
}
else if (state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP)
{
return 1;
}
}
return 0;
}
示例9: canPlaceBlockOnSide
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack)
{
BlockPos blockpos = pos;
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab)
{
boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;
if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag))
{
return true;
}
}
pos = pos.offset(side);
IBlockState iblockstate1 = worldIn.getBlockState(pos);
return iblockstate1.getBlock() == this.singleSlab ? true : super.canPlaceBlockOnSide(worldIn, blockpos, side, player, stack);
}
示例10: BlockGlassSlab
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
public BlockGlassSlab()
{
super(Material.GLASS);
this.setSoundType(SoundType.GLASS);
IBlockState iblockstate = this.blockState.getBaseState();
this.setHardness(0.5F);
if (!this.isDouble())
{
iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
ModRegistry.setBlockName(this, "block_half_glass_slab");
this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
}
else
{
ModRegistry.setBlockName(this, "block_glass_slab");
}
iblockstate = iblockstate.withProperty(VARIANT_PROPERTY, false);
this.setDefaultState(iblockstate);
this.useNeighborBrightness = !this.isDouble();
}
示例11: BlockGraniteSlab
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
public BlockGraniteSlab()
{
super(Material.ROCK);
this.setSoundType(SoundType.STONE);
IBlockState iblockstate = this.blockState.getBaseState();
this.setHardness(0.5F);
if (!this.isDouble())
{
iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
ModRegistry.setBlockName(this, "block_half_granite_slab");
this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
}
else
{
ModRegistry.setBlockName(this, "block_granite_slab");
}
iblockstate = iblockstate.withProperty(VARIANT_PROPERTY, false);
this.setDefaultState(iblockstate);
this.useNeighborBrightness = !this.isDouble();
}
示例12: BlockDioriteSlab
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
public BlockDioriteSlab()
{
super(Material.ROCK);
this.setSoundType(SoundType.STONE);
IBlockState iblockstate = this.blockState.getBaseState();
this.setHardness(0.5F);
if (!this.isDouble())
{
iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
ModRegistry.setBlockName(this, "block_half_diorite_slab");
this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
}
else
{
ModRegistry.setBlockName(this, "block_diorite_slab");
}
iblockstate = iblockstate.withProperty(VARIANT_PROPERTY, false);
this.setDefaultState(iblockstate);
this.useNeighborBrightness = !this.isDouble();
}
示例13: BlockAndesiteSlab
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
public BlockAndesiteSlab()
{
super(Material.ROCK);
this.setSoundType(SoundType.STONE);
IBlockState iblockstate = this.blockState.getBaseState();
this.setHardness(0.5F);
if (!this.isDouble())
{
iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
ModRegistry.setBlockName(this, "block_half_andesite_slab");
this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
}
else
{
ModRegistry.setBlockName(this, "block_andesite_slab");
}
iblockstate = iblockstate.withProperty(VARIANT_PROPERTY, false);
this.setDefaultState(iblockstate);
this.useNeighborBrightness = !this.isDouble();
}
示例14: canPlaceBlockOnSide
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) {
if (block instanceof AlchemyBlockSlab && !((BlockSlab) block).isDouble()) {
BlockSlab singleSlab = (BlockSlab) block;
BlockPos blockpos = pos;
IProperty<?> iproperty = singleSlab.getVariantProperty();
Comparable<?> comparable = singleSlab.getTypeForItem(stack);
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == singleSlab) {
boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;
if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && comparable == iblockstate.getValue(iproperty))
return true;
}
pos = pos.offset(side);
IBlockState iblockstate1 = worldIn.getBlockState(pos);
return iblockstate1.getBlock() == singleSlab && comparable == iblockstate1.getValue(iproperty) ?
true : super.canPlaceBlockOnSide(worldIn, blockpos, side, player, stack);
} else
return super.canPlaceBlockOnSide(worldIn, pos, side, player, stack);
}
示例15: tryPlace
import net.minecraft.block.BlockSlab; //导入依赖的package包/类
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos, Object itemSlabType) {
if (block instanceof AlchemyBlockSlab && !((BlockSlab) block).isDouble()) {
BlockSlab singleSlab = (BlockSlab) block;
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == singleSlab) {
Comparable<?> comparable = iblockstate.getValue(singleSlab.getVariantProperty());
if (comparable == itemSlabType) {
IBlockState iblockstate1 = makeSlabState(singleSlab.getVariantProperty(), comparable);
AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, pos);
if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) &&
worldIn.setBlockState(pos, iblockstate1, 11)) {
SoundType soundtype = singleSlab.getSoundType(iblockstate1, worldIn, pos, player);
worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS,
(soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
stack.setCount(stack.getCount() - 1);
}
return true;
}
}
}
return false;
}