Fixed blocks state <-> meta conversion (#31)

-Added missing state <-> meta conversion methods to blocks. Fixes #23.
This commit is contained in:
shartte
2016-08-11 11:40:34 +02:00
committed by Elix_x
parent 2208083b03
commit 8ddff3f459
4 changed files with 27 additions and 20 deletions
@@ -25,9 +25,9 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
@@ -52,10 +52,15 @@ import appeng.helpers.MetaRotation;
public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, ICustomCollision
{
// Cannot use the vanilla FACING property here because it excludes facing DOWN
public static final PropertyDirection FACING = PropertyDirection.create("facing");
public BlockQuartzTorch()
{
super( Material.CIRCUITS );
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.UP));
this.setFeature( EnumSet.of( AEFeature.DecorativeLights ) );
this.setLightLevel( 0.9375F );
this.setLightOpacity( 0 );
@@ -66,19 +71,20 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
@Override
public int getMetaFromState( final IBlockState state )
{
return 0;
return state.getValue(FACING).ordinal();
}
@Override
public IBlockState getStateFromMeta( final int meta )
{
return this.getDefaultState();
EnumFacing facing = EnumFacing.values()[meta];
return getDefaultState().withProperty(FACING, facing);
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { BlockTorch.FACING };
return new IProperty[] { FACING };
}
@Override
@@ -180,6 +186,6 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
@Override
public IOrientable getOrientable( final IBlockAccess w, final BlockPos pos )
{
return new MetaRotation( w, pos, true );
return new MetaRotation( w, pos, FACING );
}
}