Rotation not working with own mod

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

  1. GregoriMarow

    GregoriMarow New Member

    hi,

    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:
    http://www.minecraftforge.net/forum...otation-solved/?do=findComment&comment=253111

    And here is the full code of the rotation class.

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

    import akka.actor.Props;
    import mcaddicts.modpack.McaAdditionsMod;
    import net.minecraft.block.BlockHorizontal;
    import net.minecraft.block.SoundType;
    import net.minecraft.block.material.Material;
    import net.minecraft.block.properties.PropertyDirection;
    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;
    import net.minecraft.world.World;


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

    public BlockRotate(String name) {
    super(Material.ROCK, name);
    setSoundType(SoundType.STONE);
    setHardness(3f);
    setResistance(5f);
    this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
    }
    @Override
    public BlockRotate setCreativeTab(CreativeTabs tab) {
    super.setCreativeTab(tab);
    return this;
    }
    @Override
    public BlockStateContainer createBlockState() {
         return new BlockStateContainer(this, FACING);
    }
    //Meta from State
    @Override
    public int getMetaFromState(IBlockState state) {
         return ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
    }

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

    @Override
    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);
         }
    }

    }
    [​IMG]
  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": [
                  0,
                  0,
                  -1
                ]
    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.