public class Wallpaper extends BasicBlockWithCustomModel {
public static final PropertyBool isAngle = PropertyBool.create("isangle");
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
private static AxisAlignedBB[] SIDE_AABB = new AxisAlignedBB[] {
new AxisAlignedBB(0D, 0D, 1D, 1D, 1D, 0.99D),
new AxisAlignedBB(0D, 0D, 0.01D, 1D, 1D, 0D),
new AxisAlignedBB(0.01D, 0D, 1D, 0D, 1D, 0D),
new AxisAlignedBB(1D, 0D, 0D, 0.99D, 1D, 1D)
};
public Wallpaper(Material materialIn, String name, float hardness, float resistanse, SoundType soundtype) {
super(materialIn, name, hardness, resistanse, soundtype);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(isAngle, false));
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot)
{
return state.withProperty(FACING, rot.rotate(state.getValue(FACING)));
}
@Override
public int getMetaFromState(IBlockState state)
{
int i = 0;
i = i | state.getValue(FACING).getHorizontalIndex();
return i;
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
return state.withRotation(mirrorIn.toRotation(state.getValue(FACING)));
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
world.scheduleBlockUpdate(pos, this,1, 0);
EnumFacing facing = EnumFacing.fromAngle(placer.getRotationYawHead());
float facingstate = state.getValue(FACING).getHorizontalIndex();
System.out.println(facingstate);
System.out.println(facing);
world.setBlockState(pos, state.withProperty(isAngle, false).withProperty(FACING, facing));
}
// world.setBlockState(pos, state.withProperty(isAngle, true).withProperty(FACING, facing));
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
switch (state.getValue(FACING))
{
case SOUTH:
return this.SIDE_AABB[0];
case NORTH:
default:
return this.SIDE_AABB[1];
case WEST:
return this.SIDE_AABB[2];
case EAST:
return this.SIDE_AABB[3];
}
}
@Override
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, new IProperty[] {FACING,isAngle});
}
}