Passing rotations to models

Implemented passing of rotations to models. Removed unused unlisted
properties. Included dummy grinder model. Found bugs that have to be
fixed.
Referencing #10.
This commit is contained in:
elix-x 2016-06-30 15:51:42 +02:00
parent 0be0635a8f
commit e24d166f6a
10 changed files with 60 additions and 23 deletions

View file

@ -128,19 +128,10 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
return this.featureFullName;
}
public static final UnlistedBlockPos AE_BLOCK_POS = new UnlistedBlockPos();
public static final UnlistedBlockAccess AE_BLOCK_ACCESS = new UnlistedBlockAccess();
@Override
protected final BlockStateContainer createBlockState()
protected BlockStateContainer createBlockState()
{
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] { AE_BLOCK_POS, AE_BLOCK_ACCESS } );
}
@Override
public final IBlockState getExtendedState( final IBlockState state, final IBlockAccess world, final BlockPos pos )
{
return ( (IExtendedBlockState) super.getExtendedState( state, world, pos ) ).withProperty( AE_BLOCK_POS, pos ).withProperty( AE_BLOCK_ACCESS, world );
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] {} );
}
protected IProperty[] getAEStates()

View file

@ -32,6 +32,9 @@ import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@ -46,6 +49,9 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import appeng.api.implementations.items.IMemoryCard;
@ -69,7 +75,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
{
@Nonnull
private Class<? extends TileEntity> tileEntityType;
private Class<? extends AEBaseTile> tileEntityType;
public AEBaseTileBlock( final Material mat )
{
@ -80,7 +86,29 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
{
super( mat, subName );
}
public static final PropertyDirection AE_BLOCK_FORWARD = PropertyDirection.create( "forward" );
public static final PropertyDirection AE_BLOCK_UP = PropertyDirection.create( "up" );
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP };
}
@Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
{
AEBaseTile tile = (AEBaseTile) world.getTileEntity( pos );
return super.getActualState( state, world, pos ).withProperty( AE_BLOCK_FORWARD, tile.getForward()).withProperty( AE_BLOCK_UP, tile.getUp() );
}
@Override
public int getMetaFromState( IBlockState state )
{
return 0;
}
@Override
protected void setFeature( final EnumSet<AEFeature> f )
{
@ -88,7 +116,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
this.setHandler( featureHandler );
}
protected void setTileEntity( final Class<? extends TileEntity> c )
protected void setTileEntity( final Class<? extends AEBaseTile> c )
{
this.tileEntityType = c;
this.setInventory( IInventory.class.isAssignableFrom( c ) );

View file

@ -138,7 +138,7 @@ public class BlockCraftingUnit extends AEBaseTileBlock
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { POWERED, FORMED };
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP, POWERED, FORMED };
}
@Override

View file

@ -75,7 +75,8 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { BlockTorch.FACING };
//TODO 1.10-R - wtf?
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP, BlockTorch.FACING };
}
@Override

View file

@ -78,8 +78,8 @@ public class BlockCableBus extends AEBaseTileBlock // implements
{
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
private static Class<? extends TileEntity> noTesrTile;
private static Class<? extends TileEntity> tesrTile;
private static Class<? extends AEBaseTile> noTesrTile;
private static Class<? extends AEBaseTile> tesrTile;
/**
* Immibis MB Support.
@ -390,12 +390,12 @@ public class BlockCableBus extends AEBaseTileBlock // implements
}
}
public static Class<? extends TileEntity> getTesrTile()
public static Class<? extends AEBaseTile> getTesrTile()
{
return tesrTile;
}
public static Class<? extends TileEntity> getNoTesrTile()
public static Class<? extends AEBaseTile> getNoTesrTile()
{
return noTesrTile;
}

View file

@ -56,7 +56,7 @@ public class BlockController extends AEBaseTileBlock
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { CONTROLLER_STATE };
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP, CONTROLLER_STATE };
}
@Override

View file

@ -88,7 +88,7 @@ public class BlockEnergyCell extends AEBaseTileBlock
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { ENERGY_STORAGE };
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP, ENERGY_STORAGE };
}
@Override

View file

@ -62,7 +62,8 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench /* , ITool
{
if( Platform.isClient() )
{
return !world.isRemote ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
//TODO 1.10-R - if we return FAIL on client, action will not be sent to server. Fix that in all Block#onItemUseFirst overrides.
return !world.isRemote ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
}
if( b.rotateBlock( world, pos, side ) )

View file

@ -0,0 +1,8 @@
{
"variants": {
"forward=north,up=up": { "model": "appliedenergistics2:tile.BlockGrinder" },
"forward=south,up=up": { "model": "appliedenergistics2:tile.BlockGrinder", "y": 180 },
"forward=west,up=up": { "model": "appliedenergistics2:tile.BlockGrinder", "y": 270 },
"forward=east,up=up": { "model": "appliedenergistics2:tile.BlockGrinder", "y": 90 }
}
}

View file

@ -0,0 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"top": "blocks/furnace_top",
"front": "blocks/furnace_front_off",
"side": "blocks/furnace_side"
}
}