Jump to content

[1.8.0] [Solved] Metadata Slabs


Eractnod

Recommended Posts

It has taken a few days to finally get my meta data version of slabs to work in 1.8.0.  However, when I place the slabs as a half block all is fine, but when I place as a double slab, they all revert to the setDefautState enumtype.  In my case TELVARITE_COBBLE.  When you break the block, you get two telvarite cobble half slabs, so it is not a texture issue.  If I change the default enumtype to AMATITE_COBBLE, then all double slabs are of that type.  I am not sure if it is a registration problem as the block used to find the iblockstate is always null.

 

Any help would be greatly appreciated.

 

Declaration and registration

//Slabs
public static BlockTEStoneSlab te_stone_slab;
public static BlockTEStoneSlab te_stone_slab_double;

te_stone_slab = new BlockTEStoneSlab(Material.rock, "slabStoneS", 2.0f, 15.0f);
	te_stone_slab_double = new BlockTEStoneSlabDouble(Material.rock, "slabStoneD", 2.0f, 15.0f);
	registerSlab("te_stone_slab", "te_stone_slab_double", te_stone_slab, te_stone_slab_double);

public static void registerSlab(String name, String name2, Block one, Block two){
	GameRegistry.registerBlock(two, ItemBlockModTEStoneSlab.class, name2, new Object[]{one, two});
	GameRegistry.registerBlock(one, ItemBlockModTEStoneSlab.class, name, new Object[]{one, two});
        blockList.add(name);
}

 

Itemblock class

package com.eractnod.telvarianexpanse.itemblocks;


import com.eractnod.telvarianexpanse.blocks.BlockTEStoneSlab;
import com.eractnod.telvarianexpanse.blocks.BlockTEStoneSlabDouble;

import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSlab;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ItemBlockModTEStoneSlab extends ItemBlock{

private final BlockSlab single;
    private final BlockSlab twoOf;

public ItemBlockModTEStoneSlab(Block block, BlockTEStoneSlab single, BlockTEStoneSlabDouble twoOf) {
	super(block);
       this.single = single;
       this.twoOf = twoOf;
       this.setMaxDamage(0);
       this.setHasSubtypes(true);
    }

    /**
     * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is
     * placed as a Block (mostly used with ItemBlocks).
     */
    public int getMetadata(int damage)
    {
        return damage;
    }

    /**
     * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have
     * different names based on their damage or NBT.
     */
    public String getUnlocalizedName(ItemStack stack)
    {
        return this.single.getFullSlabName(stack.getMetadata());
    }

    /**
     * Called when a Block is right-clicked with this Item
     *  
     * @param pos The block being right-clicked
     * @param side The side being right-clicked
     */
    public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
    {
        if (stack.stackSize == 0)
        {
            return false;
        }
        else if (!playerIn.func_175151_a(pos.offset(side), side, stack))
        {
            return false;
        }
        else
        {
            Object object = this.single.func_176553_a(stack);
            IBlockState iblockstate = worldIn.getBlockState(pos);

            if (iblockstate.getBlock() == this.single)
            {
                BlockSlab.EnumBlockHalf enumblockhalf = (BlockSlab.EnumBlockHalf)iblockstate.getValue(BlockSlab.HALF_PROP);

                if ((side == EnumFacing.UP && enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && enumblockhalf == BlockSlab.EnumBlockHalf.TOP))
                {
                    IBlockState iblockstate1 = this.twoOf.getDefaultState();

                    if (worldIn.checkNoEntityCollision(this.twoOf.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3))
                    {
                        worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.twoOf.stepSound.getPlaceSound(), (this.twoOf.stepSound.getVolume() + 1.0F) / 2.0F, this.twoOf.stepSound.getFrequency() * 0.8F);
                        --stack.stackSize;
                    }

                    return true;
                }
            }

            return this.placeDouble(stack, worldIn, pos.offset(side), object) ? true : super.onItemUse(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ);
        }
    }

    @SideOnly(Side.CLIENT)
    public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing facing, EntityPlayer player, ItemStack stack)
    {
        BlockPos blockpos1 = pos;
        Object object = this.single.func_176553_a(stack);
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == this.single)
        {
            boolean flag = iblockstate.getValue(BlockSlab.HALF_PROP) == BlockSlab.EnumBlockHalf.TOP;

            if ((facing == EnumFacing.UP && !flag || facing == EnumFacing.DOWN && flag))
            {
                return true;
            }
        }

        pos = pos.offset(facing);
        IBlockState iblockstate1 = worldIn.getBlockState(pos);
        return iblockstate1.getBlock() == this.single ? true : super.canPlaceBlockOnSide(worldIn, blockpos1, facing, player, stack);
    }

    private boolean placeDouble(ItemStack stack, World worldIn, BlockPos pos, Object obj)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == this.single)
        {
                IBlockState iblockstate1 = this.twoOf.getDefaultState();

                if (worldIn.checkNoEntityCollision(this.twoOf.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3))
                {
                    worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.twoOf.stepSound.getPlaceSound(), (this.twoOf.stepSound.getVolume() + 1.0F) / 2.0F, this.twoOf.stepSound.getFrequency() * 0.8F);
                    --stack.stackSize;
                }

                return true;
        }

        return false;
    }
}

 

Slab block class

package com.eractnod.telvarianexpanse.blocks;

import java.util.List;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.BlockStoneSlab;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockTEStoneSlab extends BlockSlab
{
    public static final PropertyBool seamlessBool = PropertyBool.create("seamless");
    public static final PropertyEnum typeVar = PropertyEnum.create("variant", BlockTEStoneSlab.EnumType.class);

    public BlockTEStoneSlab(Material mat, String name, float hardness, float resistance)
    {
        super(Material.rock);
        IBlockState iblockstate = this.blockState.getBaseState();
        if (this.isDouble())
        {
            iblockstate = iblockstate.withProperty(seamlessBool, Boolean.valueOf(false));
        }
        else
        {
            iblockstate = iblockstate.withProperty(HALF_PROP, BlockSlab.EnumBlockHalf.BOTTOM);
        }
        this.setDefaultState(iblockstate.withProperty(typeVar, BlockTEStoneSlab.EnumType.TELVARITE_COBBLE));
        this.setCreativeTab(CreativeTabs.tabBlock);
        this.setHardness(hardness);
        this.setResistance(resistance);
    }

    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return Item.getItemFromBlock(TEBlocks.te_stone_slab);
    }

    @SideOnly(Side.CLIENT)
    public Item getItem(World worldIn, BlockPos pos)
    {
    	
        return Item.getItemFromBlock(TEBlocks.te_stone_slab);
    }

    public String getFullSlabName(int meta)
    {
        return super.getUnlocalizedName() + "." + BlockTEStoneSlab.EnumType.func_176625_a(meta).func_176627_c();
    }

    public IProperty func_176551_l()
    {
        return typeVar;
    }

    public Object func_176553_a(ItemStack stack)
    {
        return BlockTEStoneSlab.EnumType.func_176625_a(stack.getMetadata() & 7);
    }

    @SideOnly(Side.CLIENT)
    public void getSubBlocks(Item itemIn, CreativeTabs tab, List list)
    {
        if (itemIn != Item.getItemFromBlock(TEBlocks.te_stone_slab_double))
        {
            BlockTEStoneSlab.EnumType[] aenumtype = BlockTEStoneSlab.EnumType.values();
            int i = aenumtype.length;

            for (int j = 0; j < i; ++j)
            {
                BlockTEStoneSlab.EnumType enumtype = aenumtype[j];

                    list.add(new ItemStack(itemIn, 1, enumtype.func_176624_a()));
               
            }
        }
    }

    public IBlockState getStateFromMeta(int meta)
    {
        IBlockState iblockstate = this.getDefaultState().withProperty(typeVar, BlockTEStoneSlab.EnumType.func_176625_a(meta & 7));

        if (this.isDouble())
        {
            iblockstate = iblockstate.withProperty(seamlessBool, Boolean.valueOf((meta &  != 0));
        }
        else
        {
            iblockstate = iblockstate.withProperty(HALF_PROP, (meta &  == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
        }

        return iblockstate;
    }

    public int getMetaFromState(IBlockState state)
    {
        byte b0 = 0;
        int i = b0 | ((BlockTEStoneSlab.EnumType)state.getValue(typeVar)).func_176624_a();

        if (this.isDouble())
        {
            if (((Boolean)state.getValue(seamlessBool)).booleanValue())
            {
                i |= 8;
            }
        }
        else if (state.getValue(HALF_PROP) == BlockSlab.EnumBlockHalf.TOP)
        {
            i |= 8;
        }

        return i;
    }

    protected BlockState createBlockState()
    {
        return this.isDouble() ? new BlockState(this, new IProperty[] {seamlessBool, typeVar}): new BlockState(this, new IProperty[] {HALF_PROP, typeVar});
    }

    public int damageDropped(IBlockState state)
    {
        return ((BlockTEStoneSlab.EnumType)state.getValue(typeVar)).func_176624_a();
    }

    public static enum EnumType implements IStringSerializable
    {
    	TELVARITE_COBBLE(0, "te_stone_slab", "telvarite_cobble"),
        AMATITE_COBBLE(1, "amatite_te_stone_slab", "amatite_cobble"),
        VARIANITE_COBBLE(2, "varianite_te_stone_slab", "varianite_cobble"),
        ORAMIRITE_COBBLE(3, "oramirite_te_stone_slab", "oramirite_cobble"),
        TELVARITE_BRICK(4, "telvarite_brick_te_stone_slab", "telvarite_brick"),
        AMATITE_BRICK(5, "amatite_brick_te_stone_slab", "amatite_brick"),
        VARIANITE_BRICK(6, "varianite_brick_te_stone_slab", "varianite_brick"),
        ORAMIRITE_BRICK(7, "oramirite_brick_te_stone_slab", "oramirite_brick");

        private static final BlockTEStoneSlab.EnumType[] field_176640_i = new BlockTEStoneSlab.EnumType[values().length];
        private final int meta;
        private final String variantName;
        private final String name;


        private EnumType(int meta, String name)
        {
            this(meta, name, name);
        }

        private EnumType(int meta, String variantName, String name)
        {
            this.meta = meta;
            this.variantName = variantName;
            this.name = name;
        }

        public int func_176624_a()
        {
            return this.meta;
        }

        public String toString()
        {
            return this.variantName;
        }

        public static BlockTEStoneSlab.EnumType func_176625_a(int meta)
        {
            if (meta < 0 || meta >= field_176640_i.length)
            {
                meta = 0;
            }

            return field_176640_i[meta];
        }

        public String getName()
        {
            return this.variantName;
        }

        public String func_176627_c()
        {
            return this.name;
        }

        static
        {
            BlockTEStoneSlab.EnumType[] var0 = values();
            int var1 = var0.length;

            for (int var2 = 0; var2 < var1; ++var2)
            {
                BlockTEStoneSlab.EnumType var3 = var0[var2];
                field_176640_i[var3.func_176624_a()] = var3;
            }
        }
    }

@Override
public boolean isDouble() {
	return false;
}

}

 

Double slab block class

package com.eractnod.telvarianexpanse.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockTEStoneSlabDouble extends BlockTEStoneSlab{

public BlockTEStoneSlabDouble(Material mat, String name, float hardness, float resistance) {
	super(mat, name, hardness, resistance);
	setCreativeTab(null);
}

@Override
public boolean isDouble(){
	return true;
}


}

 

Client Proxy

package com.eractnod.telvarianexpanse.client;

import com.eractnod.telvarianexpanse.TelvarianExpanse;
import com.eractnod.telvarianexpanse.blocks.TEBlocks;
import com.eractnod.telvarianexpanse.items.TEItems;
import com.eractnod.telvarianexpanse.lamps.TileEntityChandelier;
import com.eractnod.telvarianexpanse.lamps.TileEntityChandelierRenderer;
import com.eractnod.telvarianexpanse.lamps.TileEntityFloorLamp;
import com.eractnod.telvarianexpanse.lamps.TileEntityFloorLampRenderer;
import com.eractnod.telvarianexpanse.lamps.TileEntityStreetLamp;
import com.eractnod.telvarianexpanse.lamps.TileEntityStreetLampRenderer;
import com.eractnod.telvarianexpanse.machines.TEMachines;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;


@SideOnly(Side.CLIENT)
public class ClientProxy {

public static void init(){

	for(String name : TEItems.itemList){
		System.out.println("real item&&&&&&&&&&&&&&&&&&& " + name);
	    registerItem(GameRegistry.findItem(TelvarianExpanse.MODID, name), TelvarianExpanse.MODID + ":" + name);
	}

	for(String name : TEBlocks.blockList){
		Item i = GameRegistry.findItem(TelvarianExpanse.MODID, name);
		System.out.println("Item********************* " + name);
		registerItem(i, TelvarianExpanse.MODID + ":" + name);
	}

	for(String name : TEMachines.machineList){
		Item i = GameRegistry.findItem(TelvarianExpanse.MODID, name);
		System.out.println("Item********************* " + name);
		registerItem(i, TelvarianExpanse.MODID + ":" + name);
	}




	Item te_stone_slab = GameRegistry.findItem(TelvarianExpanse.MODID, "te_stone_slab");
	registerItem(te_stone_slab, 0, TelvarianExpanse.MODID + ":te_stone_slab");
	registerItem(te_stone_slab, 1, TelvarianExpanse.MODID + ":amatite_te_stone_slab");
	registerItem(te_stone_slab, 2, TelvarianExpanse.MODID + ":varianite_te_stone_slab");
	registerItem(te_stone_slab, 3, TelvarianExpanse.MODID + ":oramirite_te_stone_slab");
	registerItem(te_stone_slab, 4, TelvarianExpanse.MODID + ":telvarite_brick_te_stone_slab");
	registerItem(te_stone_slab, 5, TelvarianExpanse.MODID + ":amatite_brick_te_stone_slab");
	registerItem(te_stone_slab, 6, TelvarianExpanse.MODID + ":varianite_brick_te_stone_slab");
	registerItem(te_stone_slab, 7, TelvarianExpanse.MODID + ":oramirite_brick_te_stone_slab");


	Item te_stone_slab_double = GameRegistry.findItem(TelvarianExpanse.MODID, "te_stone_slab_double");
	registerItem(te_stone_slab_double, 0, TelvarianExpanse.MODID + ":te_stone_slab_double");
	registerItem(te_stone_slab_double, 1, TelvarianExpanse.MODID + ":amatite_te_stone_slab_double");
	registerItem(te_stone_slab_double, 2, TelvarianExpanse.MODID + ":varianite_te_stone_slab_double");
	registerItem(te_stone_slab_double, 3, TelvarianExpanse.MODID + ":oramirite_te_stone_slab_double");
	registerItem(te_stone_slab_double, 4, TelvarianExpanse.MODID + ":telvarite_brick_te_stone_slab_double");
	registerItem(te_stone_slab_double, 5, TelvarianExpanse.MODID + ":amatite_brick_te_stone_slab_double");
	registerItem(te_stone_slab_double, 6, TelvarianExpanse.MODID + ":varianite_brick_te_stone_slab_double");
	registerItem(te_stone_slab_double, 7, TelvarianExpanse.MODID + ":oramirite_brick_te_stone_slab_double");




}

public static void preInit(){
	ModelBakery.addVariantName(Item.getItemFromBlock(TEBlocks.te_stone_slab), new String[]{TelvarianExpanse.MODID + ":te_stone_slab", TelvarianExpanse.MODID + ":amatite_te_stone_slab", TelvarianExpanse.MODID + ":varianite_te_stone_slab", TelvarianExpanse.MODID + ":oramirite_te_stone_slab", TelvarianExpanse.MODID + ":telvarite_brick_te_stone_slab", TelvarianExpanse.MODID + ":amatite_brick_te_stone_slab", TelvarianExpanse.MODID + ":varianite_brick_te_stone_slab", TelvarianExpanse.MODID + ":oramirite_brick_te_stone_slab"});


}

public static void registerItem(Item item, int metadata, String itemName)
    {
        ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
        mesher.register(item, metadata, new ModelResourceLocation(itemName, "inventory"));
    }

    public static void registerBlock(Block block, int metadata, String blockName)
    {
        registerItem(Item.getItemFromBlock(block), metadata, blockName);
    }

    public static void registerBlock(Block block, String blockName)
    {
        registerBlock(block, 0, blockName);
    }

    public static void registerItem(Item item, String itemName)
    {
        registerItem(item, 0, itemName);
    }
}


Link to comment
Share on other sites

As always, the issue turned out to be me.  I was using my single slab Itemblock which defaults to the default blockstate.  Made changes to the Itemblock class, and now doubles are placing correctly.  Code listed below.

 

ItemBlock

package com.eractnod.telvarianexpanse.itemblocks;


import com.eractnod.telvarianexpanse.blocks.BlockTEStoneSlab;
import com.eractnod.telvarianexpanse.blocks.BlockTEStoneSlabDouble;

import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSlab;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ItemBlockModTEStoneSlab extends ItemBlock{

private final BlockSlab single;
    private final BlockSlab twoOf;

public ItemBlockModTEStoneSlab(Block block, BlockTEStoneSlab single, BlockTEStoneSlabDouble twoOf) {
	super(block);
       this.single = single;
       this.twoOf = twoOf;
       this.setMaxDamage(0);
       this.setHasSubtypes(true);
    }

    /**
     * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is
     * placed as a Block (mostly used with ItemBlocks).
     */
    public int getMetadata(int damage)
    {
        return damage;
    }

    /**
     * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have
     * different names based on their damage or NBT.
     */
    public String getUnlocalizedName(ItemStack stack)
    {
        return this.single.getFullSlabName(stack.getMetadata());
    }

    /**
     * Called when a Block is right-clicked with this Item
     *  
     * @param pos The block being right-clicked
     * @param side The side being right-clicked
     */
    public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
    {
        if (stack.stackSize == 0)
        {
            return false;
        }
        else if (!playerIn.func_175151_a(pos.offset(side), side, stack))
        {
            return false;
        }
        else
        {
            Object object = this.single.func_176553_a(stack);
            IBlockState iblockstate = worldIn.getBlockState(pos);

            if (iblockstate.getBlock() == this.single)
            {
                IProperty iproperty = this.single.func_176551_l();
                Comparable comparable = iblockstate.getValue(iproperty);
                BlockSlab.EnumBlockHalf enumblockhalf = (BlockSlab.EnumBlockHalf)iblockstate.getValue(BlockSlab.HALF_PROP);

                if ((side == EnumFacing.UP && enumblockhalf == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && enumblockhalf == BlockSlab.EnumBlockHalf.TOP) && comparable == object)
                {
                    IBlockState iblockstate1 = this.twoOf.getDefaultState().withProperty(iproperty, comparable);

                    if (worldIn.checkNoEntityCollision(this.twoOf.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3))
                    {
                        worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.twoOf.stepSound.getPlaceSound(), (this.twoOf.stepSound.getVolume() + 1.0F) / 2.0F, this.twoOf.stepSound.getFrequency() * 0.8F);
                        --stack.stackSize;
                    }

                    return true;
                }
            }

            return this.placeDouble(stack, worldIn, pos.offset(side), object) ? true : super.onItemUse(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ);
        }
    }

    @SideOnly(Side.CLIENT)
    public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing facing, EntityPlayer player, ItemStack stack)
    {
        BlockPos blockpos1 = pos;
        IProperty iproperty = this.single.func_176551_l();
        Object object = this.single.func_176553_a(stack);
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == this.single)
        {
            boolean flag = iblockstate.getValue(BlockSlab.HALF_PROP) == BlockSlab.EnumBlockHalf.TOP;

            if ((facing == EnumFacing.UP && !flag || facing == EnumFacing.DOWN && flag) && object == iblockstate.getValue(iproperty))
            {
                return true;
            }
        }

        pos = pos.offset(facing);
        IBlockState iblockstate1 = worldIn.getBlockState(pos);
        return iblockstate1.getBlock() == this.single && object == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos1, facing, player, stack);
    }

    private boolean placeDouble(ItemStack stack, World worldIn, BlockPos pos, Object obj)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == this.single)
        {
            Comparable comparable = iblockstate.getValue(this.single.func_176551_l());

            if (comparable == obj)
            {
                IBlockState iblockstate1 = this.twoOf.getDefaultState().withProperty(this.single.func_176551_l(), comparable);

                if (worldIn.checkNoEntityCollision(this.twoOf.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3))
                {
                    worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.twoOf.stepSound.getPlaceSound(), (this.twoOf.stepSound.getVolume() + 1.0F) / 2.0F, this.twoOf.stepSound.getFrequency() * 0.8F);
                    --stack.stackSize;
                }

                return true;
            }
        }

        return false;
    }
}

Link to comment
Share on other sites

  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.