Rotation not working with own mod

Discussion in 'WorldEdit' started by GregoriMarow, Mar 10, 2017.

  1. GregoriMarow

    GregoriMarow New Member


    I have created an own mod with blocks that can rotate. The block rotation itself works great but if I want to use worldedit and mark a couple of them, copy and rotate them 90°C to the right its not working. So something in the code is missing. Any help?
    Here is the minecraft forge topic:

    And here is the full code of the rotation class.

    Code (Text):
    package mcaddicts.modpack.blocks;

    import mcaddicts.modpack.McaAdditionsMod;
    import net.minecraft.block.BlockHorizontal;
    import net.minecraft.block.SoundType;
    import net.minecraft.block.material.Material;
    import net.minecraft.block.state.BlockStateContainer;
    import net.minecraft.block.state.IBlockState;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.EnumFacing;
    import net.minecraft.util.math.BlockPos;

    public class BlockRotate extends BlockBase {
    public static final PropertyDirection FACING = BlockHorizontal.FACING;

    public BlockRotate(String name) {
    super(Material.ROCK, name);
    this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
    public BlockRotate setCreativeTab(CreativeTabs tab) {
    return this;
    public BlockStateContainer createBlockState() {
         return new BlockStateContainer(this, FACING);
    //Meta from State
    public int getMetaFromState(IBlockState state) {
         return ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();

    //State from Meta
    public IBlockState getStateFromMeta(int meta) {
         return getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));

    public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack) {
         EnumFacing entityFacing = entity.getHorizontalFacing();

         if(!world.isRemote) {
             if(entityFacing == EnumFacing.NORTH) {
                 entityFacing = EnumFacing.NORTH;
             } else if(entityFacing == EnumFacing.SOUTH) {
                 entityFacing = EnumFacing.SOUTH;
             } else if(entityFacing == EnumFacing.EAST) {
                 entityFacing = EnumFacing.EAST;
             } else if(entityFacing == EnumFacing.WEST) {
                 entityFacing = EnumFacing.WEST;

             world.setBlockState(pos, state.withProperty(FACING, entityFacing), 2);

  2. wizjany

    wizjany Administrator Developer

  3. GregoriMarow

    GregoriMarow New Member

    Thanks :), one more questions on that:
    1) Is there a documentation about the direction values? 0,0 and -1 whats that?
    Code (Text):
    "values": {
              "north": {
                "data": 2,
                "direction": [
    Last edited: Mar 10, 2017
  4. wizjany

    wizjany Administrator Developer

    x y and z of the way that blocks faces when it has the given data value.
    note that you can decide which way is "front" arbitrarily, it just has to be consistent. look at the vanilla blocks for examples.