Block class
public class BlockHead extends Block {
public BlockHead() {
super(Material.WOOD);
setRegistryName("Head");
setUnlocalizedName("head");
setCreativeTab(DECreativeTab.DE_tabBlocks);
GameRegistry.register(this);
GameRegistry.register(new ItemBlock(this), this.getRegistryName());
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
}
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
public boolean isFullCube(IBlockState state)
{
return false;
}
public static final PropertyDirection FACING = BlockHorizontal.FACING;
private static boolean keepInventory;
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos) && worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos, EnumFacing.UP);
}
public IBlockState withRotation(IBlockState state, Rotation rot)
{
return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING)));
}
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
}
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
}
public int getMetaFromState(IBlockState state)
{
return ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
}
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, new IProperty[] {FACING});
}
}
blockstates
{
"variants": {
"facing=south": { "model": "DecorativeExpansion:Head" },
"facing=west": { "model": "DecorativeExpansion:Head", "y": 90 },
"facing=north": { "model": "DecorativeExpansion:Head", "y": 180 },
"facing=east": { "model": "DecorativeExpansion:Head", "y": 270 }
}
}
Model
{ "parent": "block/block",
"ambientocclusion": false,
"textures": {
"particle": "blocks/glass",
"glass": "blocks/glass",
"obsidian": "blocks/obsidian",
"beacon": "blocks/beacon"
},
"elements": [
{ "__comment": "Glass shell",
"from": [ 0, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" },
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" },
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" }
}
},
{ "__comment": "Obsidian base",
"from": [ 2, 0.1, 2 ],
"to": [ 14, 3, 14 ],
"faces": {
"down": { "uv": [ 2, 2, 14, 14 ], "texture": "#obsidian" },
"up": { "uv": [ 2, 2, 14, 14 ], "texture": "#obsidian" },
"north": { "uv": [ 2, 13, 14, 16 ], "texture": "#obsidian" },
"south": { "uv": [ 2, 13, 14, 16 ], "texture": "#obsidian" },
"west": { "uv": [ 2, 13, 14, 16 ], "texture": "#obsidian" },
"east": { "uv": [ 2, 13, 14, 16 ], "texture": "#obsidian" }
}
},
{ "__comment": "Inner beacon texture",
"from": [ 3, 3, 3 ],
"to": [ 13, 14, 13 ],
"faces": {
"down": { "uv": [ 3, 3, 13, 13 ], "texture": "#beacon" },
"up": { "uv": [ 3, 3, 13, 13 ], "texture": "#beacon" },
"north": { "uv": [ 3, 2, 13, 13 ], "texture": "#beacon" },
"south": { "uv": [ 3, 2, 13, 13 ], "texture": "#beacon" },
"west": { "uv": [ 3, 2, 13, 13 ], "texture": "#beacon" },
"east": { "uv": [ 3, 2, 13, 13 ], "texture": "#beacon" }
}
}
]
}