AE2 First Commit, the dawn of 1.7 hast arrived.
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
package appeng.items.parts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockGlass;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.block.solids.OreQuartz;
|
||||
import appeng.client.render.BusRenderer;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.facade.FacadePart;
|
||||
import appeng.facade.IFacadeItem;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemFacade extends AEBaseItem implements IFacadeItem
|
||||
{
|
||||
|
||||
public ItemFacade() {
|
||||
super( ItemFacade.class );
|
||||
setfeature( EnumSet.of( AEFeature.Facades ) );
|
||||
setHasSubtypes( true );
|
||||
if ( Platform.isClient() )
|
||||
MinecraftForgeClient.registerItemRenderer( this.itemID, BusRenderer.instance );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
return AEApi.instance().partHelper().placeBus( is, x, y, z, side, player, w );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FacadePart createPartFromItemStack(ItemStack is, ForgeDirection side)
|
||||
{
|
||||
ItemStack in = getTextureItem( is );
|
||||
if ( in != null )
|
||||
return new FacadePart( is, side );
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ItemStack> subTypes = null;
|
||||
|
||||
@Override
|
||||
public void getSubItems(int number, CreativeTabs tab, List list)
|
||||
{
|
||||
calculateSubTypes();
|
||||
list.addAll( subTypes );
|
||||
}
|
||||
|
||||
public ItemStack createFromInts(int[] ids)
|
||||
{
|
||||
ItemStack is = new ItemStack( AEApi.instance().items().itemFacade.item() );
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setIntArray( "x", ids );
|
||||
is.setTagCompound( data );
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getTextureItem(ItemStack is)
|
||||
{
|
||||
Block blk = getBlock( is );
|
||||
if ( blk != null )
|
||||
return new ItemStack( blk, 1, getMeta( is ) );
|
||||
return null;
|
||||
}
|
||||
|
||||
private void calculateSubTypes()
|
||||
{
|
||||
if ( subTypes == null )
|
||||
{
|
||||
subTypes = new ArrayList();
|
||||
for (Block b : Block.blocksList)
|
||||
{
|
||||
if ( b != null && (b.isOpaqueCube() && !b.getTickRandomly() && !(b instanceof OreQuartz)) || b instanceof BlockGlass )
|
||||
{
|
||||
try
|
||||
{
|
||||
List<ItemStack> tmpList = new ArrayList();
|
||||
b.getSubBlocks( b.blockID, b.getCreativeTabToDisplayOn(), tmpList );
|
||||
for (ItemStack l : tmpList)
|
||||
{
|
||||
ItemStack is = new ItemStack( this );
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
int[] ds = new int[2];
|
||||
ds[0] = l.itemID;
|
||||
ds[1] = l.getItem().getMetadata( l.getItemDamage() );
|
||||
data.setIntArray( "x", ds );
|
||||
is.setTagCompound( data );
|
||||
|
||||
subTypes.add( is );
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// just absorb..
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock(ItemStack is)
|
||||
{
|
||||
NBTTagCompound data = is.getTagCompound();
|
||||
if ( data != null )
|
||||
{
|
||||
int[] blk = data.getIntArray( "x" );
|
||||
if ( blk != null && blk.length == 2 )
|
||||
return Block.blocksList[blk[0]];
|
||||
}
|
||||
return Block.glass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMeta(ItemStack is)
|
||||
{
|
||||
NBTTagCompound data = is.getTagCompound();
|
||||
if ( data != null )
|
||||
{
|
||||
int[] blk = data.getIntArray( "x" );
|
||||
if ( blk != null && blk.length == 2 )
|
||||
return blk[1];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemDisplayName(ItemStack is)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemStack in = getTextureItem( is );
|
||||
if ( in != null )
|
||||
{
|
||||
return super.getItemDisplayName( is ) + " - " + in.getDisplayName();
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return super.getItemDisplayName( is );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package appeng.items.parts;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.items.AEBaseItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemPart extends AEBaseItem implements IPartItem
|
||||
{
|
||||
|
||||
final PartType part;
|
||||
|
||||
public ItemPart(PartType type) {
|
||||
super( ItemPart.class, type.name() );
|
||||
setfeature( type.getFeature() );
|
||||
AEApi.instance().partHelper().setItemBusRenderer( this );
|
||||
part = type;
|
||||
if ( type == PartType.CableSmart || type == PartType.CableCovered || type == PartType.CableGlass )
|
||||
{
|
||||
setHasSubtypes( true );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY,
|
||||
float hitZ)
|
||||
{
|
||||
return AEApi.instance().partHelper().placeBus( is, x, y, z, side, player, w );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPart createPartFromItemStack(ItemStack is)
|
||||
{
|
||||
try
|
||||
{
|
||||
return part.getPart().getConstructor( ItemStack.class ).newInstance( is );
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
throw new RuntimeException( "Unable to construct IBusPart from IBusItem : " + part.getPart().getName()
|
||||
+ " ; Possibly didn't have correct constructor( ItemStack )", e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int number, CreativeTabs tab, List list)
|
||||
{
|
||||
if ( part == PartType.CableSmart || part == PartType.CableCovered || part == PartType.CableGlass )
|
||||
{
|
||||
list.add( new ItemStack( this, 1, 16 ) );
|
||||
for (int x = 0; x < 16; x++)
|
||||
list.add( new ItemStack( this, 1, x ) );
|
||||
return;
|
||||
}
|
||||
super.getSubItems( number, tab, list );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package appeng.items.parts;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.parts.automation.PartAnnihilationPlane;
|
||||
import appeng.parts.automation.PartExportBus;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.automation.PartImportBus;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import appeng.parts.misc.PartCableAnchor;
|
||||
import appeng.parts.misc.PartInvertedToggleBus;
|
||||
import appeng.parts.misc.PartP2PTunnel;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.parts.misc.PartToggleBus;
|
||||
import appeng.parts.networking.PartCableCovered;
|
||||
import appeng.parts.networking.PartCableGlass;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartQuartzFiber;
|
||||
import appeng.parts.reporting.PartConversionMonitor;
|
||||
import appeng.parts.reporting.PartCraftingMonitor;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartDarkMonitor;
|
||||
import appeng.parts.reporting.PartMonitor;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartSemiDarkMonitor;
|
||||
import appeng.parts.reporting.PartStorageMonitor;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
|
||||
public enum PartType
|
||||
{
|
||||
ToggleBus(AEFeature.Core, PartToggleBus.class),
|
||||
|
||||
InvertedToggleBus(AEFeature.Core, PartInvertedToggleBus.class),
|
||||
|
||||
CableSmart(AEFeature.Core, PartCableSmart.class), CableCovered(AEFeature.Core, PartCableCovered.class), CableGlass(AEFeature.Core, PartCableGlass.class),
|
||||
|
||||
CableAnchor(AEFeature.Core, PartCableAnchor.class),
|
||||
|
||||
QuartzFiber(AEFeature.Core, PartQuartzFiber.class),
|
||||
|
||||
Monitior(AEFeature.Core, PartMonitor.class),
|
||||
|
||||
SemiDarkMonitor(AEFeature.Core, PartSemiDarkMonitor.class),
|
||||
|
||||
DarkMonitor(AEFeature.Core, PartDarkMonitor.class),
|
||||
|
||||
StorageBus(AEFeature.StorageBus, PartStorageBus.class),
|
||||
|
||||
ImportBus(AEFeature.ImportBus, PartImportBus.class),
|
||||
|
||||
ExportBus(AEFeature.ExportBus, PartExportBus.class),
|
||||
|
||||
LevelEmitter(AEFeature.LevelEmiter, PartLevelEmitter.class),
|
||||
|
||||
AnnihilationPlane(AEFeature.AnnihilationPlane, PartAnnihilationPlane.class),
|
||||
|
||||
FormationPlane(AEFeature.FormationPlane, PartFormationPlane.class),
|
||||
|
||||
P2PTunnel(AEFeature.P2PTunnel, PartP2PTunnel.class),
|
||||
|
||||
CraftingMonitor(AEFeature.Crafting, PartCraftingMonitor.class),
|
||||
|
||||
PatternTerminal(AEFeature.CraftingTerminal, PartPatternTerminal.class),
|
||||
|
||||
CraftingTerminal(AEFeature.CraftingTerminal, PartCraftingTerminal.class),
|
||||
|
||||
Terminal(AEFeature.Core, PartTerminal.class),
|
||||
|
||||
StorageMonitor(AEFeature.StorageMonitor, PartStorageMonitor.class),
|
||||
|
||||
ConversionMonitor(AEFeature.PartConversionMonitor, PartConversionMonitor.class);
|
||||
|
||||
private EnumSet<AEFeature> features;
|
||||
private Class<? extends IPart> myPart;
|
||||
|
||||
PartType(AEFeature part, Class<? extends IPart> c) {
|
||||
features = EnumSet.of( part );
|
||||
myPart = c;
|
||||
}
|
||||
|
||||
public EnumSet<AEFeature> getFeature()
|
||||
{
|
||||
return features;
|
||||
}
|
||||
|
||||
public Class<? extends IPart> getPart()
|
||||
{
|
||||
return myPart;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user