Implemented drive models. Fixed issues with the UVL model loader using a null model loader (and thus crashing).
This commit is contained in:
@@ -22,13 +22,19 @@ package appeng.block.storage;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
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 net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
@@ -40,6 +46,8 @@ import appeng.util.Platform;
|
||||
public class BlockDrive extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
public static final DriveSlotsStateProperty SLOTS_STATE = new DriveSlotsStateProperty();
|
||||
|
||||
public BlockDrive()
|
||||
{
|
||||
super( Material.IRON );
|
||||
@@ -52,6 +60,29 @@ public class BlockDrive extends AEBaseTileBlock
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState( this, getAEStates(), new IUnlistedProperty[] {
|
||||
SLOTS_STATE,
|
||||
FORWARD,
|
||||
UP
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
TileDrive te = getTileEntity( world, pos );
|
||||
if( te == null )
|
||||
{
|
||||
return super.getExtendedState( state, world, pos );
|
||||
}
|
||||
|
||||
IExtendedBlockState extState = (IExtendedBlockState) super.getExtendedState( state, world, pos );
|
||||
return extState.withProperty( SLOTS_STATE, DriveSlotsState.fromChestOrDrive( te ) );
|
||||
}
|
||||
|
||||
@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 )
|
||||
{
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.model.DriveModel;
|
||||
|
||||
|
||||
public class DriveRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
@Override
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.builtInModel( "models/block/builtin/drive", new DriveModel() );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
/**
|
||||
* Describes the different states a single slot of a BlockDrive can be in in terms of rendering.
|
||||
*/
|
||||
public enum DriveSlotState
|
||||
{
|
||||
|
||||
// No cell in slot
|
||||
EMPTY,
|
||||
|
||||
// Cell in slot, but unpowered
|
||||
OFFLINE,
|
||||
|
||||
// Online and free space
|
||||
ONLINE,
|
||||
|
||||
// Types full, space left
|
||||
TYPES_FULL,
|
||||
|
||||
// Completely full
|
||||
FULL
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
|
||||
|
||||
/**
|
||||
* Contains the full information about what the state of the slots in a BlockDrive is.
|
||||
*/
|
||||
public class DriveSlotsState
|
||||
{
|
||||
|
||||
private final DriveSlotState[] slots;
|
||||
|
||||
private DriveSlotsState( DriveSlotState[] slots )
|
||||
{
|
||||
this.slots = slots;
|
||||
}
|
||||
|
||||
public DriveSlotState getState( int index )
|
||||
{
|
||||
if( index >= slots.length )
|
||||
{
|
||||
return DriveSlotState.EMPTY;
|
||||
}
|
||||
return slots[index];
|
||||
}
|
||||
|
||||
public int getSlotCount()
|
||||
{
|
||||
return slots.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an array that describes the state of each slot in this drive or chest.
|
||||
*/
|
||||
public static DriveSlotsState fromChestOrDrive( IChestOrDrive chestOrDrive )
|
||||
{
|
||||
DriveSlotState[] slots = new DriveSlotState[chestOrDrive.getCellCount()];
|
||||
for( int i = 0; i < chestOrDrive.getCellCount(); i++ )
|
||||
{
|
||||
if( !chestOrDrive.isPowered() )
|
||||
{
|
||||
if( chestOrDrive.getCellStatus( i ) != 0 )
|
||||
{
|
||||
slots[i] = DriveSlotState.OFFLINE;
|
||||
}
|
||||
else
|
||||
{
|
||||
slots[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( chestOrDrive.getCellStatus( i ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
slots[i] = DriveSlotState.EMPTY;
|
||||
break;
|
||||
case 1:
|
||||
slots[i] = DriveSlotState.ONLINE;
|
||||
break;
|
||||
case 2:
|
||||
slots[i] = DriveSlotState.TYPES_FULL;
|
||||
break;
|
||||
case 3:
|
||||
slots[i] = DriveSlotState.FULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new DriveSlotsState( slots );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
|
||||
public class DriveSlotsStateProperty implements IUnlistedProperty<DriveSlotsState>
|
||||
{
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "drive_slots_state";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( DriveSlotsState value )
|
||||
{
|
||||
return value != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<DriveSlotsState> getType()
|
||||
{
|
||||
return DriveSlotsState.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString( DriveSlotsState value )
|
||||
{
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user