I have just recently added a new slab into my mod, and everything works great except for the fact that i can't place slabs by right clicking with one under the top slab.
Here is a link to a YouTube video of the problem, it might make more sense if the issue was shown rather than described.
This is the main slab class:
package com.ProfitOrange.moshiz.blocks;
import java.util.Random;
import com.ProfitOrange.moshiz.MoShizMain;
import com.ProfitOrange.moshiz.init.MoShizBlocks;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public abstract class SlabBlock extends BlockSlab
{
public SlabBlock(String name)
{
super(Material.IRON);
this.setUnlocalizedName(name);
this.setRegistryName(name);
//this.setCreativeTab(MoShizMain.tabTest);
this.setHardness(3.0F);
this.setResistance(20.0F);
IBlockState state = this.blockState.getBaseState();
if(!this.isDouble())
{
state.withProperty(HALF, EnumBlockHalf.BOTTOM);
}
setDefaultState(state);
this.useNeighborBrightness = true;
}
@Override
public String getUnlocalizedName(int meta)
{
return this.getUnlocalizedName();
}
@Override
public IProperty<?> getVariantProperty()
{
return HALF;
}
@Override
public Comparable<?> getTypeForItem(ItemStack itemstack)
{
return EnumBlockHalf.BOTTOM;
}
@Override
public int damageDropped(IBlockState state)
{
return 0;
}
@Override
public IBlockState getStateFromMeta(int meta)
{
if(!this.isDouble())
{
return this.getDefaultState().withProperty(HALF, EnumBlockHalf.values()[meta % EnumBlockHalf.values().length]);
}
return this.getDefaultState();
}
@Override
public int getMetaFromState(IBlockState state)
{
if(this.isDouble())
{
return 0;
}
return ((EnumBlockHalf)state.getValue(HALF)).ordinal() + 1;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Item.getItemFromBlock(MoShizBlocks.glowood_half);
}
@Override
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, new IProperty[] {HALF});
}
}
This is the half slab class:
package com.ProfitOrange.moshiz.blocks.slab;
import com.ProfitOrange.moshiz.blocks.SlabBlock;
import net.minecraft.block.material.Material;
public class SlabHalf extends SlabBlock
{
public SlabHalf(String name)
{
super(name);
}
@Override
public boolean isDouble()
{
return false;
}
}
The double slab class:
package com.ProfitOrange.moshiz.blocks.slab;
import com.ProfitOrange.moshiz.blocks.SlabBlock;
import net.minecraft.block.material.Material;
public class SlabDouble extends SlabBlock
{
public SlabDouble(String name)
{
super(name);
}
@Override
public boolean isDouble()
{
return true;
}
}
And the block is registered as such:
package com.ProfitOrange.moshiz.init;
import com.ProfitOrange.moshiz.MoShizMain;
import com.ProfitOrange.moshiz.Reference;
import com.ProfitOrange.moshiz.blocks.MoShizBlock;
import com.ProfitOrange.moshiz.blocks.MoShizOre;
import com.ProfitOrange.moshiz.blocks.nether.MoShizSand;
import com.ProfitOrange.moshiz.blocks.nether.NetherGlass;
import com.ProfitOrange.moshiz.blocks.nether.NetherReed;
import com.ProfitOrange.moshiz.blocks.slab.SlabDouble;
import com.ProfitOrange.moshiz.blocks.slab.SlabHalf;
import net.minecraft.block.Block;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.BlockOldLog;
import net.minecraft.block.BlockSand;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSlab;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class MoShizBlocks
{
//Test Slabs
public static SlabHalf glowood_half;
public static SlabDouble glowood_double;
public static void init()
{
//Slab test
glowood_half = new SlabHalf("slab/glowood_half");
glowood_double = new SlabDouble("slab/glowood_double");
}
public static void register()
{
//Slab
registerBlock(glowood_half, new ItemSlab(glowood_half, glowood_half, glowood_double));
GameRegistry.register(glowood_double);
}
private static void registerBlock(Block block)
{
GameRegistry.register(block);
GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
}
public static void registerBlock(Block block, ItemBlock itemBlock)
{
block.setCreativeTab(MoShizMain.tabTest);
GameRegistry.register(block);
GameRegistry.register(itemBlock.setRegistryName(block.getRegistryName()));
}
public static void registerRenders()
{
//Slab
registerRender(glowood_half);
}
//Blockstates json files hnadles the texture when the block is placed
public static void registerRender(Block block)
{
Item item = Item.getItemFromBlock(block);
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}
}
I just want my custom slabs to as close to vanilla slabs as possible. Any help would be greatly appreciated!
I have just recently added a new slab into my mod, and everything works great except for the fact that i can't place slabs by right clicking with one under the top slab.
Here is a link to a YouTube video of the problem, it might make more sense if the issue was shown rather than described.
This is the main slab class:
This is the half slab class:
The double slab class:
And the block is registered as such:
I just want my custom slabs to as close to vanilla slabs as possible. Any help would be greatly appreciated!
Owner and developer of the Mo' Shiz Mod