Implemented ME chest item + block model.

This commit is contained in:
Sebastian Hartte
2016-08-27 18:12:54 +02:00
parent 5465527ea0
commit 81984b3ad7
31 changed files with 330 additions and 23 deletions
@@ -22,12 +22,16 @@ package appeng.block.storage;
import javax.annotation.Nullable;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import appeng.api.AEApi;
@@ -43,10 +47,19 @@ import appeng.util.Platform;
public class BlockChest extends AEBaseTileBlock
{
private final static PropertyEnum<DriveSlotState> SLOT_STATE = PropertyEnum.create( "slot_state", DriveSlotState.class );
public BlockChest()
{
super( Material.IRON );
this.setTileEntity( TileChest.class );
this.setDefaultState( getDefaultState().withProperty( SLOT_STATE, DriveSlotState.EMPTY ) );
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { SLOT_STATE };
}
@Override
@@ -55,6 +68,30 @@ public class BlockChest extends AEBaseTileBlock
return BlockRenderLayer.CUTOUT;
}
@Override
public IBlockState getActualState( IBlockState state, IBlockAccess worldIn, BlockPos pos )
{
DriveSlotState slotState = DriveSlotState.EMPTY;
TileChest te = getTileEntity( worldIn, pos );
if( te != null )
{
if( te.getCellCount() >= 1 )
{
slotState = DriveSlotState.fromCellStatus( te.getCellStatus( 0 ) );
}
// Power-state has to be checked separately
if( !te.isPowered() && slotState != DriveSlotState.EMPTY )
{
slotState = DriveSlotState.OFFLINE;
}
}
return super.getActualState( state, worldIn, pos )
.withProperty( SLOT_STATE, slotState );
}
@Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
{