2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* 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>.
|
|
|
|
*/
|
|
|
|
|
2014-05-18 05:19:23 +02:00
|
|
|
package appeng.tile.crafting;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2016-08-24 19:06:10 +02:00
|
|
|
import java.util.Optional;
|
|
|
|
|
2014-07-13 21:42:52 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-12-24 02:07:03 +01:00
|
|
|
|
2014-07-13 21:42:52 +02:00
|
|
|
import appeng.api.AEApi;
|
2015-01-03 02:53:14 +01:00
|
|
|
import appeng.api.definitions.IBlocks;
|
2015-06-16 02:44:59 +02:00
|
|
|
import appeng.block.crafting.BlockCraftingUnit;
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2014-07-13 21:42:52 +02:00
|
|
|
|
2014-05-18 05:19:23 +02:00
|
|
|
public class TileCraftingStorageTile extends TileCraftingTile
|
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
private static final int KILO_SCALAR = 1024;
|
2014-07-13 21:42:52 +02:00
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
protected ItemStack getItemFromTile( final Object obj )
|
2014-07-13 21:42:52 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
2015-04-03 08:54:31 +02:00
|
|
|
final int storage = ( (TileCraftingTile) obj ).getStorageBytes() / KILO_SCALAR;
|
2014-07-13 21:42:52 +02:00
|
|
|
|
2016-08-24 19:06:10 +02:00
|
|
|
Optional<ItemStack> is;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
switch( storage )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
case 4:
|
2016-08-24 19:06:10 +02:00
|
|
|
is = blocks.craftingStorage4k().maybeStack( 1 );
|
2015-01-03 02:53:14 +01:00
|
|
|
break;
|
|
|
|
case 16:
|
2016-08-24 19:06:10 +02:00
|
|
|
is = blocks.craftingStorage16k().maybeStack( 1 );
|
2015-01-03 02:53:14 +01:00
|
|
|
break;
|
|
|
|
case 64:
|
2016-08-24 19:06:10 +02:00
|
|
|
is = blocks.craftingStorage64k().maybeStack( 1 );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
is = Optional.empty();
|
2015-01-03 02:53:14 +01:00
|
|
|
break;
|
|
|
|
}
|
2014-07-13 21:42:52 +02:00
|
|
|
|
2016-08-24 19:06:10 +02:00
|
|
|
return is.orElseGet( () -> super.getItemFromTile( obj ) );
|
2014-07-13 21:42:52 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 20:34:00 +02:00
|
|
|
@Override
|
2014-05-18 05:19:23 +02:00
|
|
|
public boolean isAccelerator()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-28 20:34:00 +02:00
|
|
|
@Override
|
2014-05-18 05:19:23 +02:00
|
|
|
public boolean isStorage()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-28 20:34:00 +02:00
|
|
|
@Override
|
2014-05-18 05:19:23 +02:00
|
|
|
public int getStorageBytes()
|
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.worldObj == null || this.notLoaded() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-07-13 21:42:52 +02:00
|
|
|
return 0;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-07-13 21:42:52 +02:00
|
|
|
|
2015-12-24 02:03:16 +01:00
|
|
|
final BlockCraftingUnit unit = (BlockCraftingUnit) this.worldObj.getBlockState( this.pos ).getBlock();
|
2015-06-16 02:44:59 +02:00
|
|
|
switch( unit.type )
|
2014-05-18 05:19:23 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
default:
|
2015-06-16 02:44:59 +02:00
|
|
|
case STORAGE_1K:
|
2015-04-03 08:54:31 +02:00
|
|
|
return 1024;
|
2015-06-16 02:44:59 +02:00
|
|
|
case STORAGE_4K:
|
2015-04-03 08:54:31 +02:00
|
|
|
return 4 * 1024;
|
2015-06-16 02:44:59 +02:00
|
|
|
case STORAGE_16K:
|
2015-04-03 08:54:31 +02:00
|
|
|
return 16 * 1024;
|
2015-06-16 02:44:59 +02:00
|
|
|
case STORAGE_64K:
|
2015-04-03 08:54:31 +02:00
|
|
|
return 64 * 1024;
|
2014-05-18 05:19:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|