Crafting CPU basics.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import appeng.client.texture.ExtraTextures;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
|
||||
public class BlockCraftingMonitor extends BlockCraftingUnit
|
||||
{
|
||||
|
||||
public BlockCraftingMonitor() {
|
||||
super( BlockCraftingMonitor.class );
|
||||
setTileEntiy( TileCraftingMonitorTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case 0 | FLAG_FORMED:
|
||||
return ExtraTextures.BlockCraftingMonitorFit.getIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item i, CreativeTabs c, List l)
|
||||
{
|
||||
l.add( new ItemStack( this, 1, 0 ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import appeng.client.texture.ExtraTextures;
|
||||
import appeng.tile.crafting.TileCraftingStorageTile;
|
||||
|
||||
public class BlockCraftingStorage extends BlockCraftingUnit
|
||||
{
|
||||
|
||||
public BlockCraftingStorage() {
|
||||
super( BlockCraftingStorage.class );
|
||||
setTileEntiy( TileCraftingStorageTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
switch (metadata & (~4))
|
||||
{
|
||||
default:
|
||||
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case 1:
|
||||
return ExtraTextures.BlockCraftingStorage4k.getIcon();
|
||||
case 2:
|
||||
return ExtraTextures.BlockCraftingStorage16k.getIcon();
|
||||
case 3:
|
||||
return ExtraTextures.BlockCraftingStorage64k.getIcon();
|
||||
|
||||
case 0 | FLAG_FORMED:
|
||||
return ExtraTextures.BlockCraftingStorage1kFit.getIcon();
|
||||
case 1 | FLAG_FORMED:
|
||||
return ExtraTextures.BlockCraftingStorage4kFit.getIcon();
|
||||
case 2 | FLAG_FORMED:
|
||||
return ExtraTextures.BlockCraftingStorage16kFit.getIcon();
|
||||
case 3 | FLAG_FORMED:
|
||||
return ExtraTextures.BlockCraftingStorage64kFit.getIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item i, CreativeTabs c, List l)
|
||||
{
|
||||
l.add( new ItemStack( this, 1, 0 ) );
|
||||
l.add( new ItemStack( this, 1, 1 ) );
|
||||
l.add( new ItemStack( this, 1, 2 ) );
|
||||
l.add( new ItemStack( this, 1, 3 ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -9,9 +8,7 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
@@ -23,49 +20,42 @@ import appeng.tile.crafting.TileCraftingTile;
|
||||
public class BlockCraftingUnit extends AEBaseBlock
|
||||
{
|
||||
|
||||
public final static int BASE_DAMAGE = 0;
|
||||
public final static int BASE_MONITOR = 1;
|
||||
public final static int BASE_STORAGE = 2;
|
||||
public final static int BASE_ACCELERATOR = 3;
|
||||
public static final int FLAG_FORMED = 8;
|
||||
public static final int FLAG_POWERED = 4;
|
||||
|
||||
static public boolean checkType(int meta, int type)
|
||||
{
|
||||
return (meta & 7) == type;
|
||||
public BlockCraftingUnit(Class<? extends BlockCraftingUnit> childClass) {
|
||||
super( childClass, Material.iron );
|
||||
hasSubtypes = true;
|
||||
setfeature( EnumSet.of( AEFeature.Crafting ) );
|
||||
}
|
||||
|
||||
public BlockCraftingUnit() {
|
||||
super( BlockCraftingUnit.class, Material.iron );
|
||||
hasSubtypes = true;
|
||||
setfeature( EnumSet.of( AEFeature.Crafting ) );
|
||||
this( BlockCraftingUnit.class );
|
||||
setTileEntiy( TileCraftingTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageValue(World w, int x, int y, int z)
|
||||
{
|
||||
int meta = w.getBlockMetadata( x, y, z );
|
||||
return meta & 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case BASE_MONITOR:
|
||||
if ( direction == 0 )
|
||||
return ExtraTextures.BlockCraftingStorageMonitor.getIcon();
|
||||
break;
|
||||
case BASE_STORAGE:
|
||||
return ExtraTextures.BlockCraftingStorage1k.getIcon();
|
||||
case BASE_ACCELERATOR:
|
||||
default:
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case 1:
|
||||
return ExtraTextures.BlockCraftingAccelerator.getIcon();
|
||||
case BASE_MONITOR | 8:
|
||||
if ( direction == 0 )
|
||||
return ExtraTextures.BlockCraftingStorageMonitorFit.getIcon();
|
||||
break;
|
||||
case BASE_STORAGE | 8:
|
||||
return ExtraTextures.BlockCraftingStorage1kFit.getIcon();
|
||||
case BASE_ACCELERATOR | 8:
|
||||
return ExtraTextures.BlockCraftingAcceleratorFit.getIcon();
|
||||
case BASE_DAMAGE | 8:
|
||||
case 0 | FLAG_FORMED:
|
||||
return ExtraTextures.BlockCraftingUnitFit.getIcon();
|
||||
case 1 | FLAG_FORMED:
|
||||
return ExtraTextures.BlockCraftingAcceleratorFit.getIcon();
|
||||
}
|
||||
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,62 +72,10 @@ public class BlockCraftingUnit extends AEBaseBlock
|
||||
cp.updateMultiBlock();
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(World world, int x, int y, int z)
|
||||
{
|
||||
TileCraftingTile ct = getTileEntity( world, x, y, z );
|
||||
|
||||
int meta = world.getBlockMetadata( x, y, z ) & 7;
|
||||
if ( ct != null && meta == BASE_STORAGE )
|
||||
{
|
||||
return createStackForBytes( ct.getStorageBytes() );
|
||||
}
|
||||
|
||||
return new ItemStack( this, 1, meta );
|
||||
}
|
||||
|
||||
private ItemStack createStackForBytes(long storageBytes)
|
||||
{
|
||||
ItemStack itemDetails = new ItemStack( this, 1, BASE_STORAGE );
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setLong( "bytes", storageBytes );
|
||||
itemDetails.setTagCompound( tag );
|
||||
return itemDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
||||
{
|
||||
ArrayList<ItemStack> out = new ArrayList();
|
||||
|
||||
ItemStack is = getItemStack( world, x, y, z );
|
||||
if ( is != null )
|
||||
out.add( is );
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
return getItemStack( world, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item i, CreativeTabs c, List l)
|
||||
{
|
||||
l.add( new ItemStack( this, 1, BASE_DAMAGE ) );
|
||||
l.add( new ItemStack( this, 1, BASE_MONITOR ) );
|
||||
l.add( new ItemStack( this, 1, BASE_ACCELERATOR ) );
|
||||
l.add( createStackForBytes( 1024 ) );
|
||||
l.add( createStackForBytes( 1024 * 4 ) );
|
||||
l.add( createStackForBytes( 1024 * 16 ) );
|
||||
l.add( createStackForBytes( 1024 * 64 ) );
|
||||
l.add( new ItemStack( this, 1, 0 ) );
|
||||
l.add( new ItemStack( this, 1, 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getItemBlockClass()
|
||||
{
|
||||
return ItemBlockCraftingUnit.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class ItemBlockCraftingUnit extends AEBaseItemBlock
|
||||
{
|
||||
|
||||
public ItemBlockCraftingUnit(Block id) {
|
||||
super( id );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
switch (is.getItemDamage())
|
||||
{
|
||||
case BlockCraftingUnit.BASE_STORAGE:
|
||||
return "tile.appliedenergistics2.BlockCraftingStorage";
|
||||
case BlockCraftingUnit.BASE_ACCELERATOR:
|
||||
return "tile.appliedenergistics2.BlockCraftingAccelerator";
|
||||
case BlockCraftingUnit.BASE_MONITOR:
|
||||
return "tile.appliedenergistics2.BlockCraftingMonitor";
|
||||
}
|
||||
|
||||
return super.getUnlocalizedName( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack is)
|
||||
{
|
||||
String name = super.getItemStackDisplayName( is );
|
||||
|
||||
long storageBytes = getStorageBytes( is );
|
||||
if ( storageBytes > 0 )
|
||||
return name + " - " + GuiText.Stores.getLocal() + " " + (storageBytes / 1024) + "k";
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public long getStorageBytes(ItemStack is)
|
||||
{
|
||||
NBTTagCompound tag = is.getTagCompound();
|
||||
|
||||
if ( tag != null )
|
||||
{
|
||||
return tag.getLong( "bytes" );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user