pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,15 +18,8 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -42,66 +35,67 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockChest extends AEBaseTileBlock<TileChest> {
|
||||
|
||||
public class BlockChest extends AEBaseTileBlock<TileChest>
|
||||
{
|
||||
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.create("slot_state",
|
||||
DriveSlotState.class);
|
||||
|
||||
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.create( "slot_state", DriveSlotState.class );
|
||||
public BlockChest() {
|
||||
super(defaultProps(Material.IRON));
|
||||
this.setDefaultState(this.getDefaultState().with(SLOT_STATE, DriveSlotState.EMPTY));
|
||||
}
|
||||
|
||||
public BlockChest()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
this.setDefaultState( this.getDefaultState().with( SLOT_STATE, DriveSlotState.EMPTY ) );
|
||||
}
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(SLOT_STATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(SLOT_STATE);
|
||||
}
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileChest te) {
|
||||
DriveSlotState slotState = DriveSlotState.EMPTY;
|
||||
|
||||
@Override
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, TileChest te) {
|
||||
DriveSlotState slotState = DriveSlotState.EMPTY;
|
||||
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;
|
||||
}
|
||||
|
||||
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 currentState.with(SLOT_STATE, slotState);
|
||||
}
|
||||
|
||||
return currentState.with( SLOT_STATE, slotState );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
final TileChest tg = this.getTileEntity(w, pos);
|
||||
if (tg != null && !p.isCrouching()) {
|
||||
if (w.isRemote()) {
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
final TileChest tg = this.getTileEntity( w, pos );
|
||||
if( tg != null && !p.isCrouching() )
|
||||
{
|
||||
if( w.isRemote() )
|
||||
{
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
if (hit.getFace() == tg.getUp()) {
|
||||
if (!tg.openGui(p)) {
|
||||
p.sendMessage(PlayerMessages.ChestCannotReadStorageCell.get());
|
||||
}
|
||||
} else {
|
||||
ContainerOpener.openContainer(ContainerChest.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
|
||||
if (hit.getFace() == tg.getUp()) {
|
||||
if( !tg.openGui( p ) )
|
||||
{
|
||||
p.sendMessage( PlayerMessages.ChestCannotReadStorageCell.get() );
|
||||
}
|
||||
} else {
|
||||
ContainerOpener.openContainer(ContainerChest.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,8 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -35,34 +29,34 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockDrive extends AEBaseTileBlock<TileDrive> {
|
||||
|
||||
public class BlockDrive extends AEBaseTileBlock<TileDrive>
|
||||
{
|
||||
public BlockDrive() {
|
||||
super(defaultProps(Material.IRON));
|
||||
}
|
||||
|
||||
public BlockDrive()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (p.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
final TileDrive tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerDrive.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
final TileDrive tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(ContainerDrive.TYPE, p, ContainerLocator.forTileEntity(tg));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,8 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerIOPort;
|
||||
import appeng.fluids.container.ContainerFluidInterface;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -37,44 +31,44 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerIOPort;
|
||||
import appeng.fluids.container.ContainerFluidInterface;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockIOPort extends AEBaseTileBlock<TileIOPort> {
|
||||
|
||||
public class BlockIOPort extends AEBaseTileBlock<TileIOPort>
|
||||
{
|
||||
public BlockIOPort() {
|
||||
super(defaultProps(Material.IRON));
|
||||
}
|
||||
|
||||
public BlockIOPort()
|
||||
{
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
final TileIOPort te = this.getTileEntity(world, pos);
|
||||
if (te != null) {
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
|
||||
{
|
||||
final TileIOPort te = this.getTileEntity( world, pos );
|
||||
if( te != null )
|
||||
{
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (p.isCrouching()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( p.isCrouching() )
|
||||
{
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
final TileIOPort tg = this.getTileEntity( w, pos );
|
||||
if( tg != null )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
ContainerOpener.openContainer(ContainerIOPort.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
final TileIOPort tg = this.getTileEntity(w, pos);
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
ContainerOpener.openContainer(ContainerIOPort.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,8 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -42,85 +37,89 @@ import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockSkyChest extends AEBaseTileBlock<TileSkyChest> {
|
||||
|
||||
public class BlockSkyChest extends AEBaseTileBlock<TileSkyChest>
|
||||
{
|
||||
private static final double AABB_OFFSET_BOTTOM = 0.00;
|
||||
private static final double AABB_OFFSET_SIDES = 0.06;
|
||||
private static final double AABB_OFFSET_TOP = 0.125;
|
||||
|
||||
private static final double AABB_OFFSET_BOTTOM = 0.00;
|
||||
private static final double AABB_OFFSET_SIDES = 0.06;
|
||||
private static final double AABB_OFFSET_TOP = 0.125;
|
||||
public enum SkyChestType {
|
||||
STONE, BLOCK
|
||||
};
|
||||
|
||||
public enum SkyChestType
|
||||
{
|
||||
STONE, BLOCK
|
||||
};
|
||||
public final SkyChestType type;
|
||||
|
||||
public final SkyChestType type;
|
||||
public BlockSkyChest(final SkyChestType type, Properties props) {
|
||||
super(props);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public BlockSkyChest( final SkyChestType type, Properties props )
|
||||
{
|
||||
super( props );
|
||||
this.type = type;
|
||||
}
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
|
||||
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
|
||||
if (Platform.isServer()) {
|
||||
TileSkyChest tile = getTileEntity(w, pos);
|
||||
if (tile == null) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
TileSkyChest tile = getTileEntity(w, pos);
|
||||
if (tile == null) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
ContainerOpener.openContainer(ContainerSkyChest.TYPE, player, ContainerLocator.forTileEntity(tile));
|
||||
}
|
||||
|
||||
ContainerOpener.openContainer(ContainerSkyChest.TYPE, player, ContainerLocator.forTileEntity(tile));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
// TODO Cache this! It can't be that hard!
|
||||
AxisAlignedBB aabb = computeAABB(worldIn, pos);
|
||||
return VoxelShapes.create(aabb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
// TODO Cache this! It can't be that hard!
|
||||
AxisAlignedBB aabb = computeAABB(worldIn, pos);
|
||||
return VoxelShapes.create(aabb);
|
||||
}
|
||||
private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos) {
|
||||
final TileSkyChest sk = this.getTileEntity(w, pos);
|
||||
Direction o = Direction.UP;
|
||||
|
||||
private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos )
|
||||
{
|
||||
final TileSkyChest sk = this.getTileEntity( w, pos );
|
||||
Direction o = Direction.UP;
|
||||
if (sk != null) {
|
||||
o = sk.getUp();
|
||||
}
|
||||
|
||||
if( sk != null )
|
||||
{
|
||||
o = sk.getUp();
|
||||
}
|
||||
final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
final double offsetZ = o.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
|
||||
final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
final double offsetZ = o.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
|
||||
// for x/z top and bottom is swapped
|
||||
final double minX = Math.max(0.0,
|
||||
offsetX + (o.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getXOffset() * AABB_OFFSET_TOP)));
|
||||
final double minY = Math.max(0.0,
|
||||
offsetY + (o.getYOffset() < 0 ? AABB_OFFSET_TOP : (o.getYOffset() * AABB_OFFSET_BOTTOM)));
|
||||
final double minZ = Math.max(0.0,
|
||||
offsetZ + (o.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getZOffset() * AABB_OFFSET_TOP)));
|
||||
|
||||
// for x/z top and bottom is swapped
|
||||
final double minX = Math.max( 0.0, offsetX + ( o.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : ( o.getXOffset() * AABB_OFFSET_TOP ) ) );
|
||||
final double minY = Math.max( 0.0, offsetY + ( o.getYOffset() < 0 ? AABB_OFFSET_TOP : ( o.getYOffset() * AABB_OFFSET_BOTTOM ) ) );
|
||||
final double minZ = Math.max( 0.0, offsetZ + ( o.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : ( o.getZOffset() * AABB_OFFSET_TOP ) ) );
|
||||
final double maxX = Math.min(1.0,
|
||||
1.0 - offsetX - (o.getXOffset() < 0 ? AABB_OFFSET_TOP : (o.getXOffset() * AABB_OFFSET_BOTTOM)));
|
||||
final double maxY = Math.min(1.0,
|
||||
1.0 - offsetY - (o.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getYOffset() * AABB_OFFSET_TOP)));
|
||||
final double maxZ = Math.min(1.0,
|
||||
1.0 - offsetZ - (o.getZOffset() < 0 ? AABB_OFFSET_TOP : (o.getZOffset() * AABB_OFFSET_BOTTOM)));
|
||||
|
||||
final double maxX = Math.min( 1.0, 1.0 - offsetX - ( o.getXOffset() < 0 ? AABB_OFFSET_TOP : ( o.getXOffset() * AABB_OFFSET_BOTTOM ) ) );
|
||||
final double maxY = Math.min( 1.0, 1.0 - offsetY - ( o.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : ( o.getYOffset() * AABB_OFFSET_TOP ) ) );
|
||||
final double maxZ = Math.min( 1.0, 1.0 - offsetZ - ( o.getZOffset() < 0 ? AABB_OFFSET_TOP : ( o.getZOffset() * AABB_OFFSET_BOTTOM ) ) );
|
||||
|
||||
return new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ );
|
||||
}
|
||||
return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -30,19 +29,16 @@ import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.ColorableTileBlockColor;
|
||||
import appeng.client.render.StaticItemColor;
|
||||
|
||||
public class ChestRendering extends BlockRenderingCustomizer {
|
||||
|
||||
public class ChestRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
|
||||
// I checked, the ME chest doesn't keep its color in item form
|
||||
itemRendering.color( new StaticItemColor( AEColor.TRANSPARENT ) );
|
||||
rendering.blockColor( new ColorableTileBlockColor() );
|
||||
}
|
||||
// I checked, the ME chest doesn't keep its color in item form
|
||||
itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT));
|
||||
rendering.blockColor(new ColorableTileBlockColor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,18 +18,15 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
|
||||
public class DriveRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
@Override
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
}
|
||||
public class DriveRendering extends BlockRenderingCustomizer {
|
||||
@Override
|
||||
public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
|
||||
rendering.renderType(RenderType.getCutout());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,33 +18,28 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
|
||||
/**
|
||||
* Describes the type of cell present in a slot.
|
||||
*/
|
||||
public enum DriveSlotCellType implements IStringSerializable
|
||||
{
|
||||
public enum DriveSlotCellType implements IStringSerializable {
|
||||
|
||||
EMPTY("empty"),
|
||||
EMPTY("empty"),
|
||||
|
||||
ITEM("item"),
|
||||
ITEM("item"),
|
||||
|
||||
FLUID("fluid");
|
||||
FLUID("fluid");
|
||||
|
||||
private final String name;
|
||||
private final String name;
|
||||
|
||||
DriveSlotCellType(String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
DriveSlotCellType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,58 +18,52 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
|
||||
/**
|
||||
* Describes the different states a single slot of a BlockDrive can be in in terms of rendering.
|
||||
* Describes the different states a single slot of a BlockDrive can be in in
|
||||
* terms of rendering.
|
||||
*/
|
||||
public enum DriveSlotState implements IStringSerializable
|
||||
{
|
||||
public enum DriveSlotState implements IStringSerializable {
|
||||
|
||||
// No cell in slot
|
||||
EMPTY( "empty" ),
|
||||
// No cell in slot
|
||||
EMPTY("empty"),
|
||||
|
||||
// Cell in slot, but unpowered
|
||||
OFFLINE( "offline" ),
|
||||
// Cell in slot, but unpowered
|
||||
OFFLINE("offline"),
|
||||
|
||||
// Online and free space
|
||||
ONLINE( "online" ),
|
||||
// Online and free space
|
||||
ONLINE("online"),
|
||||
|
||||
// Types full, space left
|
||||
TYPES_FULL( "types_full" ),
|
||||
// Types full, space left
|
||||
TYPES_FULL("types_full"),
|
||||
|
||||
// Completely full
|
||||
FULL( "full" );
|
||||
// Completely full
|
||||
FULL("full");
|
||||
|
||||
private final String name;
|
||||
private final String name;
|
||||
|
||||
DriveSlotState( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
DriveSlotState(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public static DriveSlotState fromCellStatus( int cellStatus )
|
||||
{
|
||||
switch( cellStatus )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return DriveSlotState.EMPTY;
|
||||
case 1:
|
||||
return DriveSlotState.ONLINE;
|
||||
case 2:
|
||||
return DriveSlotState.TYPES_FULL;
|
||||
case 3:
|
||||
return DriveSlotState.FULL;
|
||||
}
|
||||
}
|
||||
public static DriveSlotState fromCellStatus(int cellStatus) {
|
||||
switch (cellStatus) {
|
||||
default:
|
||||
case 0:
|
||||
return DriveSlotState.EMPTY;
|
||||
case 1:
|
||||
return DriveSlotState.ONLINE;
|
||||
case 2:
|
||||
return DriveSlotState.TYPES_FULL;
|
||||
case 3:
|
||||
return DriveSlotState.FULL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,90 +18,76 @@
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
|
||||
/**
|
||||
* Contains the full information about what the state of the slots in a BlockDrive is.
|
||||
* Contains the full information about what the state of the slots in a
|
||||
* BlockDrive is.
|
||||
*/
|
||||
public class DriveSlotsState
|
||||
{
|
||||
public class DriveSlotsState {
|
||||
|
||||
private final Item[] cells;
|
||||
private final Item[] cells;
|
||||
|
||||
private final DriveSlotState[] states;
|
||||
private final DriveSlotState[] states;
|
||||
|
||||
public DriveSlotsState(Item[] cells, DriveSlotState[] states) {
|
||||
Preconditions.checkArgument(cells.length == states.length);
|
||||
this.cells = cells;
|
||||
this.states = states;
|
||||
}
|
||||
public DriveSlotsState(Item[] cells, DriveSlotState[] states) {
|
||||
Preconditions.checkArgument(cells.length == states.length);
|
||||
this.cells = cells;
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
public DriveSlotState getState(int index )
|
||||
{
|
||||
if( index >= this.states.length )
|
||||
{
|
||||
return DriveSlotState.EMPTY;
|
||||
}
|
||||
return this.states[index];
|
||||
}
|
||||
public DriveSlotState getState(int index) {
|
||||
if (index >= this.states.length) {
|
||||
return DriveSlotState.EMPTY;
|
||||
}
|
||||
return this.states[index];
|
||||
}
|
||||
|
||||
public Item getCell(int index )
|
||||
{
|
||||
if( index >= this.cells.length )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.cells[index];
|
||||
}
|
||||
public Item getCell(int index) {
|
||||
if (index >= this.cells.length) {
|
||||
return null;
|
||||
}
|
||||
return this.cells[index];
|
||||
}
|
||||
|
||||
public int getSlotCount()
|
||||
{
|
||||
return this.cells.length;
|
||||
}
|
||||
public int getSlotCount() {
|
||||
return this.cells.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an array that describes the state of each slot in this drive or chest.
|
||||
*/
|
||||
public static DriveSlotsState fromChestOrDrive( IChestOrDrive chestOrDrive )
|
||||
{
|
||||
DriveSlotState[] states = new DriveSlotState[chestOrDrive.getCellCount()];
|
||||
Item[] cells = new Item[chestOrDrive.getCellCount()];
|
||||
for( int i = 0; i < chestOrDrive.getCellCount(); i++ )
|
||||
{
|
||||
cells[i] = chestOrDrive.getCellItem(i);
|
||||
/**
|
||||
* Retrieve an array that describes the state of each slot in this drive or
|
||||
* chest.
|
||||
*/
|
||||
public static DriveSlotsState fromChestOrDrive(IChestOrDrive chestOrDrive) {
|
||||
DriveSlotState[] states = new DriveSlotState[chestOrDrive.getCellCount()];
|
||||
Item[] cells = new Item[chestOrDrive.getCellCount()];
|
||||
for (int i = 0; i < chestOrDrive.getCellCount(); i++) {
|
||||
cells[i] = chestOrDrive.getCellItem(i);
|
||||
|
||||
if( !chestOrDrive.isPowered() )
|
||||
{
|
||||
if( chestOrDrive.getCellStatus( i ) != 0 )
|
||||
{
|
||||
states[i] = DriveSlotState.OFFLINE;
|
||||
}
|
||||
else
|
||||
{
|
||||
states[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
states[i] = DriveSlotState.fromCellStatus( chestOrDrive.getCellStatus( i ) );
|
||||
}
|
||||
}
|
||||
return new DriveSlotsState( cells, states );
|
||||
}
|
||||
if (!chestOrDrive.isPowered()) {
|
||||
if (chestOrDrive.getCellStatus(i) != 0) {
|
||||
states[i] = DriveSlotState.OFFLINE;
|
||||
} else {
|
||||
states[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
} else {
|
||||
states[i] = DriveSlotState.fromCellStatus(chestOrDrive.getCellStatus(i));
|
||||
}
|
||||
}
|
||||
return new DriveSlotsState(cells, states);
|
||||
}
|
||||
|
||||
public static DriveSlotsState createEmpty( int slotCount )
|
||||
{
|
||||
DriveSlotState[] states = new DriveSlotState[slotCount];
|
||||
Item[] cells = new Item[slotCount];
|
||||
for( int i = 0; i < slotCount; i++ )
|
||||
{
|
||||
states[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
return new DriveSlotsState( cells, states );
|
||||
}
|
||||
public static DriveSlotsState createEmpty(int slotCount) {
|
||||
DriveSlotState[] states = new DriveSlotState[slotCount];
|
||||
Item[] cells = new Item[slotCount];
|
||||
for (int i = 0; i < slotCount; i++) {
|
||||
states[i] = DriveSlotState.EMPTY;
|
||||
}
|
||||
return new DriveSlotsState(cells, states);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user