static boolean isBottomSlab(IBlockState state) { return state.getBlock() instanceof BlockSlab && !((BlockSlab) state.getBlock()).isDouble() && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM; }
@Override public String getUnlocalizedName(int meta) { return super.getUnlocalizedName(); }
@Override public void getDrops(@Nonnull NonNullList<ItemStack> drops, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull IBlockState state, int fortune) { NNList<ItemStack> drops2 = new NNList<>(); super.getDrops(drops2, world, pos, state, fortune); boolean first = true; for (ItemStack drop : drops2) { if (first || !isDouble()) { PaintUtil.setSourceBlock(NullHelper.notnullM(drop, "null stack from getDrops()"), getPaintSource(state, world, pos)); first = false; } else { PaintUtil.setSourceBlock(NullHelper.notnullM(drop, "null stack from getDrops()"), getPaintSource2(state, world, pos)); } } drops.addAll(drops2); }
/** * Build a platform to sustain the barbarians. * @param target the target to build it. * @param world the world to build it in. */ private static void buildPlatform(final BlockPos target, final World world) { final IBlockState platformBlock = Blocks.WOODEN_SLAB.getDefaultState(); for (int z = 0; z < 5; z++) { for (int x = 0; x < 5; x++) { final int sum = x * x + z * z; if (sum < (5 * 5) / 4) { world.setBlockState(new BlockPos(target.getX() + x, target.getY()-1, target.getZ() + z), platformBlock); world.setBlockState(new BlockPos(target.getX() + x, target.getY()-1, target.getZ() -z), platformBlock); world.setBlockState(new BlockPos(target.getX() -x, target.getY()-1, target.getZ() + z), platformBlock); world.setBlockState(new BlockPos(target.getX() -x, target.getY()-1, target.getZ() -z), platformBlock); } } } } }
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (stack.getCount() != 0 && player.canPlayerEdit(pos.offset(facing), facing, stack)) { IBlockState state = world.getBlockState(pos); if (state.getBlock() == this.singleSlab) { AncientSlabBlock.EnumBlockHalf half = state.getValue(BlockSlab.HALF); if ((facing == EnumFacing.UP && half == BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && half == BlockSlab.EnumBlockHalf.TOP)) { AxisAlignedBB collisionBox = state.getSelectedBoundingBox(world, pos); IBlockState doubleSlabState = this.doubleSlab.getDefaultState(); if (collisionBox != Block.NULL_AABB && world.checkNoEntityCollision(collisionBox.offset(pos)) && world.setBlockState(pos, doubleSlabState, 11)) { SoundType sound = this.doubleSlab.getSoundType(); world.playSound(player, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume() + 1.0F) / 2.0F, sound.getPitch() * 0.8F); stack.shrink(1); } return EnumActionResult.SUCCESS; } } return this.tryPlace(player, stack, world, pos.offset(facing)) ? EnumActionResult.SUCCESS : super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); } else { return EnumActionResult.FAIL; } }
@Override public int getFlammability(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing face) { IBlockState bs = world.getBlockState(pos); return bs.getMaterial() == Material.WOOD ? 20 : super.getFlammability(world, pos, face); }
@Override public int getFireSpreadSpeed(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing face) { return world.getBlockState(pos).getMaterial() == Material.WOOD ? 5 : super.getFireSpreadSpeed(world, pos, face); }
@Override protected void generateLayers() { BlockWrapper us = new BlockWrapper(Blocks.STONE_SLAB.getDefaultState().withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP)); // upside down stone slab BlockWrapper rs = new BlockWrapper(Blocks.STONE_SLAB); BlockWrapper ds = new BlockWrapper(Blocks.DOUBLE_STONE_SLAB); BlockWrapper cb = new BlockWrapper(Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.CHISELED)); // chiseled brick BlockWrapper sb = new BlockWrapper(Blocks.STONEBRICK); BlockWrapper cs = new BlockWrapper(Blocks.STONE_SLAB.getDefaultState().withProperty(BlockStoneSlab.VARIANT, BlockStoneSlab.EnumType.COBBLESTONE)); // cobblestone slab BlockWrapper co = new BlockWrapper(Blocks.COBBLESTONE); BlockWrapper wa = new BlockWrapper(Blocks.WATER);
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 9, 0, 6, iblockstate, iblockstate, false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 0, 9, 4, 6, iblockstate, iblockstate, false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 5, 0, 9, 5, 6, Blocks.STONE_SLAB.getDefaultState(), Blocks.STONE_SLAB.getDefaultState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 5, 1, 8, 5, 5, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 0, 2, 3, 0, iblockstate3, iblockstate3, false); this.setBlockState(worldIn, Blocks.FURNACE.getDefaultState(), 6, 2, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.FURNACE.getDefaultState(), 6, 3, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 8, 1, 1, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 0, 2, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 0, 2, 4, structureBoundingBoxIn);
@SideOnly(Side.CLIENT) public int getMixedBrightnessForFacade(@Nonnull IBlockState bs, @Nonnull IBlockAccess worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState facade) { if (facade.getBlock() instanceof BlockSlab) { // TODO: this is wrong for glass and glowing slabs, isn't it? find a way to do them right---once we got some from somewhere if (((BlockSlab) facade.getBlock()).isDouble()) { return worldIn.getCombinedLight(pos, getLightValue(bs, worldIn, pos)); } return getNeightbourBrightness(worldIn, pos, facade.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP ? EnumFacing.UP : EnumFacing.DOWN); } else if (facade.useNeighborBrightness()) { // TODO: stairs... return getNeightbourBrightness(worldIn, pos, null); } else { return worldIn.getCombinedLight(pos, getLightValue(bs, worldIn, pos)); } }
@Override public String getUnlocalizedName(ItemStack stack) { return this.singleSlab.getUnlocalizedName(stack.getMetadata()); }
IBlockState defaultSlabState = Blocks.WOODEN_SLAB.getDefaultState(); for (EnumVanillaWoodType woodType : EnumVanillaWoodType.VALUES) { BlockPlanks.EnumType vanillaType = woodType.getVanillaType();
if (((BlockSlab) block).isDouble()) { count = 2;
@Override public String getUnlocalizedName(int meta) { return super.getUnlocalizedName() + "." + BlockCastleSlab.EnumType.byMetadata(meta).getUnlocalizedName(); }
if (((BlockSlab) block).isDouble()) { return true;
return COST_INF; // can't pillar from a ladder or vine onto something that isn't also climbable if (fromDown.getBlock() instanceof BlockSlab && !((BlockSlab) fromDown.getBlock()).isDouble() && fromDown.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) { return COST_INF; // can't pillar up from a bottom slab onto a non ladder
if (srcDown == Blocks.SOUL_SAND || (srcDown instanceof BlockSlab && !((BlockSlab) srcDown).isDouble())) { return COST_INF; // can't sneak and backplace against soul sand or half slabs (regardless of whether it's top half or bottom half) =/