Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package appeng.core.features;
|
||||
|
||||
public enum AEFeature
|
||||
{
|
||||
Core(null), // stuff that has no reason for ever being turned off, or that
|
||||
// is just flat out required by tons of
|
||||
// important stuff.
|
||||
|
||||
CertusQuartzWorldGen("World"), MeteoriteWorldGen("World"),
|
||||
|
||||
DecorativeLights("World"), DecorativeQuartzBlocks("World"), SkyStoneChests("World"), SpawnPressesInMeteorites("World"),
|
||||
|
||||
GrindStone("World"), Flour("World"), Inscriber("World"),
|
||||
|
||||
ChestLoot("World"), VillagerTrading("World"),
|
||||
|
||||
TinyTNT("World"),
|
||||
|
||||
PoweredTools("ToolsClassifications"),
|
||||
|
||||
CertusQuartzTools("ToolsClassifications"),
|
||||
|
||||
NetherQuartzTools("ToolsClassifications"),
|
||||
|
||||
QuartzHoe("Tools"), QuartzSpade("Tools"), QuartzSword("Tools"), QuartzPickaxe("Tools"), QuartzAxe("Tools"), QuartzKnife("Tools"), QuartzWrench("Tools"),
|
||||
|
||||
ChargedStaff("Tools"), EntropyManipulator("Tools"), MatterCannon("Tools"), WirelessAccessTerminal("Tools"), ColorApplicator("Tools"),
|
||||
|
||||
CraftingCPU("CraftingFeatures"), PowerGen("NetworkFeatures"), Security("NetworkFeatures"),
|
||||
|
||||
SpatialIO("NetworkFeatures"), QuantumNetworkBridge("NetworkFeatures"), Channels("NetworkFeatures"),
|
||||
|
||||
LevelEmitter("NetworkBuses"), CraftingTerminal("NetworkBuses"), StorageMonitor("NetworkBuses"), P2PTunnel("NetworkBuses"), FormationPlane("NetworkBuses"), AnnihilationPlane(
|
||||
"NetworkBuses"), ImportBus("NetworkBuses"), ExportBus("NetworkBuses"), StorageBus("NetworkBuses"), PartConversionMonitor("NetworkBuses"),
|
||||
|
||||
StorageCells("Storage"), PortableCell("PortableCell"), MEChest("Storage"), MEDrive("Storage"), IOPort("Storage"),
|
||||
|
||||
NetworkTool("NetworkTool"),
|
||||
|
||||
DenseEnergyCells("HigherCapacity"), DenseCables("HigherCapacity"),
|
||||
|
||||
P2PTunnelRF("P2PTunnels"), P2PTunnelME("P2PTunnels"), P2PTunnelItems("P2PTunnels"), P2PTunnelRedstone("P2PTunnels"), P2PTunnelEU("P2PTunnels"), P2PTunnelMJ(
|
||||
"P2PTunnels"), P2PTunnelLiquids("P2PTunnels"), P2PTunnelLight("P2PTunnels"),
|
||||
|
||||
MassCannonBlockDamage("BlockFeatures"), TinyTNTBlockDamage("BlockFeatures"), Facades("Facades"),
|
||||
|
||||
VersionChecker("Services"), UnsupportedDeveloperTools("Misc", false), Creative("Misc"),
|
||||
|
||||
GrinderLogging("Misc", false), Logging("Misc"), IntegrationLogging("Misc", false), CustomRecipes("Crafting", false), WebsiteRecipes("Misc", false),
|
||||
|
||||
enableFacadeCrafting("Crafting"), inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting"), UpdateLogging("Misc", false),
|
||||
|
||||
AlphaPass("Rendering"), PaintBalls("Tools"), PacketLogging("Misc", false), CraftingLog("Misc", false), InterfaceTerminal("Crafting"), LightDetector("Misc"),
|
||||
|
||||
enableDisassemblyCrafting("Crafting"), MolecularAssembler("CraftingFeatures"), MeteoriteCompass("Tools"), Patterns("CraftingFeatures"),
|
||||
|
||||
ChunkLoggerTrace("Commands", false), LogSecurityAudits("Misc", false), Achievements("Misc");
|
||||
|
||||
String Category;
|
||||
boolean visible = true;
|
||||
boolean defValue = true;
|
||||
|
||||
private AEFeature(String cat) {
|
||||
Category = cat;
|
||||
visible = !this.name().equals( "Core" );
|
||||
}
|
||||
|
||||
private AEFeature(String cat, boolean defv) {
|
||||
this( cat );
|
||||
defValue = defv;
|
||||
}
|
||||
|
||||
public String getCategory()
|
||||
{
|
||||
return Category;
|
||||
}
|
||||
|
||||
public Boolean defaultValue()
|
||||
{
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public Boolean isVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class AEFeatureHandler implements AEItemDefinition
|
||||
{
|
||||
|
||||
private final EnumSet<AEFeature> myFeatures;
|
||||
|
||||
private final String subname;
|
||||
private IAEFeature obj;
|
||||
|
||||
private Item ItemData;
|
||||
private Block BlockData;
|
||||
|
||||
public AEFeatureHandler(EnumSet<AEFeature> featureSet, IAEFeature _obj, String _subname) {
|
||||
myFeatures = featureSet;
|
||||
obj = _obj;
|
||||
subname = _subname;
|
||||
}
|
||||
|
||||
public void register()
|
||||
{
|
||||
if ( isFeatureAvailable() )
|
||||
{
|
||||
if ( obj instanceof Item )
|
||||
initItem( (Item) obj );
|
||||
if ( obj instanceof Block )
|
||||
initBlock( (Block) obj );
|
||||
}
|
||||
}
|
||||
|
||||
public static String getName(Class o, String subname)
|
||||
{
|
||||
String name = o.getSimpleName();
|
||||
|
||||
if ( name.startsWith( "ItemMultiPart" ) )
|
||||
name = name.replace( "ItemMultiPart", "ItemPart" );
|
||||
else if ( name.startsWith( "ItemMultiMaterial" ) )
|
||||
name = name.replace( "ItemMultiMaterial", "ItemMaterial" );
|
||||
|
||||
if ( subname != null )
|
||||
{
|
||||
// simple hack to allow me to do get nice names for these without
|
||||
// mode code outside of AEBaseItem
|
||||
if ( subname.startsWith( "P2PTunnel" ) )
|
||||
return "ItemPart.P2PTunnel";
|
||||
|
||||
if ( subname.equals( "CertusQuartzTools" ) )
|
||||
return name.replace( "Quartz", "CertusQuartz" );
|
||||
if ( subname.equals( "NetherQuartzTools" ) )
|
||||
return name.replace( "Quartz", "NetherQuartz" );
|
||||
|
||||
name += "." + subname;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
private void initItem(Item i)
|
||||
{
|
||||
ItemData = i;
|
||||
|
||||
String name = getName( i.getClass(), subname );
|
||||
i.setTextureName( "appliedenergistics2:" + name );
|
||||
i.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
|
||||
if ( i instanceof ItemFacade )
|
||||
i.setCreativeTab( CreativeTabFacade.instance );
|
||||
else
|
||||
i.setCreativeTab( CreativeTab.instance );
|
||||
|
||||
if ( name.equals( "ItemMaterial" ) )
|
||||
name = "ItemMultiMaterial";
|
||||
else if ( name.equals( "ItemPart" ) )
|
||||
name = "ItemMultiPart";
|
||||
|
||||
GameRegistry.registerItem( i, "item." + name );
|
||||
}
|
||||
|
||||
private void initBlock(Block b)
|
||||
{
|
||||
BlockData = b;
|
||||
|
||||
String name = getName( b.getClass(), subname );
|
||||
b.setCreativeTab( CreativeTab.instance );
|
||||
b.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
b.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
if ( Platform.isClient() && BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = (AEBaseBlock) b;
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( bb.getTileEntityClass(), bb );
|
||||
}
|
||||
|
||||
Class itemBlock = AEBaseItemBlock.class;
|
||||
if ( b instanceof AEBaseBlock )
|
||||
itemBlock = ((AEBaseBlock) b).getItemBlockClass();
|
||||
|
||||
GameRegistry.registerBlock( b, itemBlock, "tile." + name );
|
||||
}
|
||||
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return myFeatures.clone();
|
||||
}
|
||||
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
boolean enabled = true;
|
||||
|
||||
for (AEFeature f : myFeatures)
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return BlockData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
if ( BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = (AEBaseBlock) BlockData;
|
||||
return bb.getTileEntityClass();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
if ( ItemData == null && BlockData != null )
|
||||
return Item.getItemFromBlock( BlockData );
|
||||
return ItemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
if ( isFeatureAvailable() )
|
||||
{
|
||||
ItemStack rv = null;
|
||||
|
||||
if ( ItemData != null )
|
||||
rv = new ItemStack( ItemData );
|
||||
else
|
||||
rv = new ItemStack( BlockData );
|
||||
|
||||
rv.stackSize = stackSize;
|
||||
return rv;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack is)
|
||||
{
|
||||
if ( isFeatureAvailable() )
|
||||
return Platform.isSameItemType( is, stack( 1 ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if ( isFeatureAvailable() && BlockData != null )
|
||||
return world.getBlock( x, y, z ) == block();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
|
||||
public class ColoredItemDefinition implements AEColoredItemDefinition
|
||||
{
|
||||
|
||||
ItemStackSrc colors[] = new ItemStackSrc[17];
|
||||
|
||||
@Override
|
||||
public Item item(AEColor color)
|
||||
{
|
||||
ItemStackSrc is = colors[color.ordinal()];
|
||||
|
||||
if ( is == null )
|
||||
return null;
|
||||
|
||||
return is.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(AEColor color, int stackSize)
|
||||
{
|
||||
ItemStackSrc is = colors[color.ordinal()];
|
||||
|
||||
if ( is == null )
|
||||
return null;
|
||||
|
||||
return is.stack( stackSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAs(AEColor color, ItemStack comparableItem)
|
||||
{
|
||||
ItemStackSrc is = colors[color.ordinal()];
|
||||
|
||||
if ( comparableItem == null || is == null )
|
||||
return false;
|
||||
|
||||
return comparableItem.getItem() == is.item && comparableItem.getItemDamage() == is.damage;
|
||||
}
|
||||
|
||||
public void add(AEColor v, ItemStackSrc is)
|
||||
{
|
||||
colors[v.ordinal()] = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block(AEColor color)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity(AEColor color)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] allStacks(int stackSize)
|
||||
{
|
||||
ItemStack is[] = new ItemStack[colors.length];
|
||||
for (int x = 0; x < is.length; x++)
|
||||
is[x] = colors[x].stack( 1 );
|
||||
return is;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
|
||||
public class DamagedItemDefinition implements AEItemDefinition
|
||||
{
|
||||
|
||||
final IStackSrc src;
|
||||
|
||||
public DamagedItemDefinition(IStackSrc is) {
|
||||
src = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return src.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
return src.stack( stackSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack comparableItem)
|
||||
{
|
||||
if ( comparableItem == null )
|
||||
return false;
|
||||
|
||||
return comparableItem.getItem() == src.getItem() && comparableItem.getItemDamage() == src.getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package appeng.core.features;
|
||||
|
||||
public interface IAEFeature
|
||||
{
|
||||
|
||||
public AEFeatureHandler feature();
|
||||
|
||||
void postInit();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IStackSrc
|
||||
{
|
||||
|
||||
ItemStack stack(int i);
|
||||
|
||||
Item getItem();
|
||||
|
||||
int getDamage();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemStackSrc implements IStackSrc
|
||||
{
|
||||
|
||||
public final Item item;
|
||||
public final Block block;
|
||||
public final int damage;
|
||||
|
||||
public ItemStackSrc(Item i, int dmg) {
|
||||
block = null;
|
||||
item = i;
|
||||
damage = dmg;
|
||||
}
|
||||
|
||||
public ItemStackSrc(Block b, int dmg) {
|
||||
item = null;
|
||||
block = b;
|
||||
damage = dmg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int i)
|
||||
{
|
||||
if ( block != null )
|
||||
return new ItemStack( block, i, damage );
|
||||
|
||||
if ( item != null )
|
||||
return new ItemStack( item, i, damage );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem()
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamage()
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.items.materials.MaterialType;
|
||||
|
||||
public class MaterialStackSrc implements IStackSrc
|
||||
{
|
||||
|
||||
MaterialType src;
|
||||
|
||||
public MaterialStackSrc(MaterialType src) {
|
||||
this.src = src;
|
||||
if ( src == null )
|
||||
throw new RuntimeException( "Invalid Item Stack" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
return src.stack( stackSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem()
|
||||
{
|
||||
return src.itemInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamage()
|
||||
{
|
||||
return src.damageValue;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
|
||||
public class NullItemDefinition implements AEItemDefinition
|
||||
{
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack comparableItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
|
||||
public class WrappedDamageItemDefinition implements AEItemDefinition
|
||||
{
|
||||
|
||||
final AEItemDefinition baseItem;
|
||||
final int damage;
|
||||
|
||||
public WrappedDamageItemDefinition(AEItemDefinition def, int dmg) {
|
||||
baseItem = def;
|
||||
damage = dmg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return baseItem.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return baseItem.item();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return baseItem.entity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
if ( baseItem == null )
|
||||
return null;
|
||||
|
||||
return new ItemStack( baseItem.block(), stackSize, damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack comparableItem)
|
||||
{
|
||||
if ( comparableItem == null )
|
||||
return false;
|
||||
|
||||
return comparableItem.getItem() == baseItem.item() && comparableItem.getItemDamage() == damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if ( block() != null )
|
||||
return world.getBlock( x, y, z ) == block() && world.getBlockMetadata( x, y, z ) == damage;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellRegistry;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
|
||||
public class CellRegistry implements ICellRegistry
|
||||
{
|
||||
|
||||
List<ICellHandler> handlers;
|
||||
|
||||
public CellRegistry() {
|
||||
handlers = new ArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCellHandler(ICellHandler h)
|
||||
{
|
||||
if ( h != null )
|
||||
handlers.add( h );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellHandled(ItemStack is)
|
||||
{
|
||||
if ( is == null )
|
||||
return false;
|
||||
for (ICellHandler ch : handlers)
|
||||
if ( ch.isCell( is ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICellHandler getHandler(ItemStack is)
|
||||
{
|
||||
if ( is == null )
|
||||
return null;
|
||||
for (ICellHandler ch : handlers)
|
||||
{
|
||||
if ( ch.isCell( is ) )
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel chan)
|
||||
{
|
||||
if ( is == null )
|
||||
return null;
|
||||
for (ICellHandler ch : handlers)
|
||||
{
|
||||
if ( ch.isCell( is ) )
|
||||
{
|
||||
return ch.getCellInventory( is, container, chan );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IExternalStorageRegistry;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.core.features.registries.entries.ExternalIInv;
|
||||
|
||||
public class ExternalStorageRegistry implements IExternalStorageRegistry
|
||||
{
|
||||
|
||||
List<IExternalStorageHandler> Handlers;
|
||||
final ExternalIInv lastHandler = new ExternalIInv();
|
||||
|
||||
public ExternalStorageRegistry() {
|
||||
Handlers = new ArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExternalStorageHandler getHandler(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
|
||||
{
|
||||
for (IExternalStorageHandler x : Handlers)
|
||||
{
|
||||
if ( x.canHandle( te, d, chan, mySrc ) )
|
||||
return x;
|
||||
}
|
||||
|
||||
if ( lastHandler.canHandle( te, d, chan, mySrc ) )
|
||||
return lastHandler;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExternalStorageInterface(IExternalStorageHandler ei)
|
||||
{
|
||||
Handlers.add( ei );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridCache;
|
||||
import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.core.AELog;
|
||||
|
||||
public class GridCacheRegistry implements IGridCacheRegistry
|
||||
{
|
||||
|
||||
final private HashMap<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap();
|
||||
|
||||
@Override
|
||||
public void registerGridCache(Class<? extends IGridCache> iface, Class<? extends IGridCache> implementation)
|
||||
{
|
||||
if ( iface.isAssignableFrom( implementation ) )
|
||||
caches.put( iface, implementation );
|
||||
else
|
||||
throw new RuntimeException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Class<? extends IGridCache>, IGridCache> createCacheInstance(IGrid g)
|
||||
{
|
||||
HashMap<Class<? extends IGridCache>, IGridCache> map = new HashMap();
|
||||
|
||||
for (Class<? extends IGridCache> iface : caches.keySet())
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor<? extends IGridCache> c = caches.get( iface ).getConstructor( IGrid.class );
|
||||
map.put( iface, c.newInstance( g ) );
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.features.IGrinderEntry;
|
||||
import appeng.api.features.IGrinderRegistry;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.registries.entries.AppEngGrinderRecipe;
|
||||
import appeng.recipes.ores.IOreListener;
|
||||
import appeng.recipes.ores.OreDictionaryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GrinderRecipeManager implements IGrinderRegistry, IOreListener
|
||||
{
|
||||
|
||||
public List<IGrinderEntry> RecipeList;
|
||||
|
||||
private ItemStack copy(ItemStack is)
|
||||
{
|
||||
if ( is != null )
|
||||
return is.copy();
|
||||
return null;
|
||||
}
|
||||
|
||||
public GrinderRecipeManager() {
|
||||
RecipeList = new ArrayList();
|
||||
|
||||
addOre( "Coal", new ItemStack( Items.coal ) );
|
||||
addOre( "Charcoal", new ItemStack( Items.coal, 1, 1 ) );
|
||||
|
||||
addOre( "NetherQuartz", new ItemStack( Blocks.quartz_ore ) );
|
||||
addIngot( "NetherQuartz", new ItemStack( Items.quartz ) );
|
||||
|
||||
addOre( "Gold", new ItemStack( Blocks.gold_ore ) );
|
||||
addIngot( "Gold", new ItemStack( Items.gold_ingot ) );
|
||||
|
||||
addOre( "Iron", new ItemStack( Blocks.iron_ore ) );
|
||||
addIngot( "Iron", new ItemStack( Items.iron_ingot ) );
|
||||
|
||||
addOre( "Obsidian", new ItemStack( Blocks.obsidian ) );
|
||||
|
||||
addIngot( "Ender", new ItemStack( Items.ender_pearl ) );
|
||||
addIngot( "EnderPearl", new ItemStack( Items.ender_pearl ) );
|
||||
|
||||
addIngot( "Wheat", new ItemStack( Items.wheat ) );
|
||||
|
||||
OreDictionaryHandler.instance.observe( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IGrinderEntry> getRecipes()
|
||||
{
|
||||
log( "API - getRecipes" );
|
||||
return RecipeList;
|
||||
}
|
||||
|
||||
private void injectRecipe(AppEngGrinderRecipe appEngGrinderRecipe)
|
||||
{
|
||||
for (IGrinderEntry gr : RecipeList)
|
||||
if ( Platform.isSameItemPrecise( gr.getInput(), appEngGrinderRecipe.getInput() ) )
|
||||
return;
|
||||
|
||||
RecipeList.add( appEngGrinderRecipe );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(ItemStack in, ItemStack out, int cost)
|
||||
{
|
||||
if ( in == null || out == null )
|
||||
{
|
||||
log( "Invalid Grinder Recipe Specified." );
|
||||
return;
|
||||
}
|
||||
|
||||
log( "Allow Grinding of " + Platform.getItemDisplayName( in ) + " to " + Platform.getItemDisplayName( out ) + " for " + cost );
|
||||
injectRecipe( new AppEngGrinderRecipe( copy( in ), copy( out ), cost ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(ItemStack in, ItemStack out, ItemStack optional, float chance, int cost)
|
||||
{
|
||||
if ( in == null || (optional == null && out == null) )
|
||||
{
|
||||
log( "Invalid Grinder Recipe Specified." );
|
||||
return;
|
||||
}
|
||||
|
||||
log( "Allow Grinding of " + Platform.getItemDisplayName( in ) + " to " + Platform.getItemDisplayName( out ) + " with optional "
|
||||
+ Platform.getItemDisplayName( optional ) + " for " + cost );
|
||||
injectRecipe( new AppEngGrinderRecipe( copy( in ), copy( out ), copy( optional ), chance, cost ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(ItemStack in, ItemStack out, ItemStack optional, float chance, ItemStack optional2, float chance2, int cost)
|
||||
{
|
||||
if ( in == null || (optional == null && out == null && optional2 == null) )
|
||||
{
|
||||
log( "Invalid Grinder Recipe Specified." );
|
||||
return;
|
||||
}
|
||||
|
||||
log( "Allow Grinding of " + Platform.getItemDisplayName( in ) + " to " + Platform.getItemDisplayName( out ) + " with optional "
|
||||
+ Platform.getItemDisplayName( optional ) + " for " + cost );
|
||||
injectRecipe( new AppEngGrinderRecipe( copy( in ), copy( out ), copy( optional ), chance, cost ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrinderEntry getRecipeForInput(ItemStack input)
|
||||
{
|
||||
log( "Looking up recipe for " + Platform.getItemDisplayName( input ) );
|
||||
if ( input != null )
|
||||
{
|
||||
for (IGrinderEntry r : RecipeList)
|
||||
{
|
||||
if ( Platform.isSameItem( input, r.getInput() ) )
|
||||
{
|
||||
log( "Recipe for " + input.getUnlocalizedName() + " found " + Platform.getItemDisplayName( r.getOutput() ) );
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
log( "Could not find recipe for " + Platform.getItemDisplayName( input ) );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void log(String o)
|
||||
{
|
||||
AELog.grinder( o );
|
||||
}
|
||||
|
||||
private int getDustToOreRatio(String name)
|
||||
{
|
||||
if ( name.equals( "Obsidian" ) )
|
||||
return 1;
|
||||
if ( name.equals( "Charcoal" ) )
|
||||
return 1;
|
||||
if ( name.equals( "Coal" ) )
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
public Map<ItemStack, String> Ores = new HashMap<ItemStack, String>();
|
||||
public Map<ItemStack, String> Ingots = new HashMap<ItemStack, String>();
|
||||
public Map<String, ItemStack> Dusts = new HashMap<String, ItemStack>();
|
||||
|
||||
private void addOre(String name, ItemStack item)
|
||||
{
|
||||
if ( item == null )
|
||||
return;
|
||||
log( "Adding Ore - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
|
||||
Ores.put( item, name );
|
||||
|
||||
if ( Dusts.containsKey( name ) )
|
||||
{
|
||||
ItemStack is = Dusts.get( name ).copy();
|
||||
int ratio = getDustToOreRatio( name );
|
||||
if ( ratio > 1 )
|
||||
{
|
||||
ItemStack extra = is.copy();
|
||||
extra.stackSize = ratio - 1;
|
||||
addRecipe( item, is, extra, (float) (AEConfig.instance.oreDoublePercentage / 100.0), 8 );
|
||||
}
|
||||
else
|
||||
addRecipe( item, is, 8 );
|
||||
}
|
||||
}
|
||||
|
||||
private void addIngot(String name, ItemStack item)
|
||||
{
|
||||
if ( item == null )
|
||||
return;
|
||||
log( "Adding Ingot - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
|
||||
Ingots.put( item, name );
|
||||
|
||||
if ( Dusts.containsKey( name ) )
|
||||
{
|
||||
addRecipe( item, Dusts.get( name ), 4 );
|
||||
}
|
||||
}
|
||||
|
||||
private void addDust(String name, ItemStack item)
|
||||
{
|
||||
if ( item == null )
|
||||
return;
|
||||
if ( Dusts.containsKey( name ) )
|
||||
{
|
||||
log( "Rejecting Dust - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
return;
|
||||
}
|
||||
|
||||
log( "Adding Dust - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
|
||||
Dusts.put( name, item );
|
||||
|
||||
for (Entry<ItemStack, String> d : Ores.entrySet())
|
||||
if ( name.equals( d.getValue() ) )
|
||||
{
|
||||
ItemStack is = item.copy();
|
||||
is.stackSize = 1;
|
||||
int ratio = getDustToOreRatio( name );
|
||||
if ( ratio > 1 )
|
||||
{
|
||||
ItemStack extra = is.copy();
|
||||
extra.stackSize = ratio - 1;
|
||||
addRecipe( d.getKey(), is, extra, (float) (AEConfig.instance.oreDoublePercentage / 100.0), 8 );
|
||||
}
|
||||
else
|
||||
addRecipe( d.getKey(), is, 8 );
|
||||
}
|
||||
|
||||
for (Entry<ItemStack, String> d : Ingots.entrySet())
|
||||
if ( name.equals( d.getValue() ) )
|
||||
addRecipe( d.getKey(), item, 4 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void oreRegistered(String Name, ItemStack item)
|
||||
{
|
||||
if ( Name.startsWith( "ore" ) || Name.startsWith( "crystal" ) || Name.startsWith( "gem" ) || Name.startsWith( "ingot" ) || Name.startsWith( "dust" ) )
|
||||
{
|
||||
for (String ore : AEConfig.instance.grinderOres)
|
||||
{
|
||||
if ( Name.equals( "ore" + ore ) )
|
||||
{
|
||||
addOre( ore, item );
|
||||
}
|
||||
else if ( Name.equals( "crystal" + ore ) || Name.equals( "ingot" + ore ) || Name.equals( "gem" + ore ) )
|
||||
{
|
||||
addIngot( ore, item );
|
||||
}
|
||||
else if ( Name.equals( "dust" + ore ) )
|
||||
{
|
||||
addDust( ore, item );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import appeng.api.events.LocatableEventAnnounce;
|
||||
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.ILocatableRegistry;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class LocatableRegistry implements ILocatableRegistry
|
||||
{
|
||||
|
||||
private HashMap<Long, ILocatable> set;
|
||||
|
||||
@SubscribeEvent
|
||||
public void updateLocatable(LocatableEventAnnounce e)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return; // IGNORE!
|
||||
|
||||
if ( e.change == LocatableEvent.Register )
|
||||
{
|
||||
set.put( e.target.getLocatableSerial(), e.target );
|
||||
}
|
||||
else if ( e.change == LocatableEvent.Unregister )
|
||||
{
|
||||
set.remove( e.target.getLocatableSerial() );
|
||||
}
|
||||
}
|
||||
|
||||
public LocatableRegistry() {
|
||||
set = new HashMap();
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a locate-able object by its serial.
|
||||
*/
|
||||
@Override
|
||||
public Object findLocatableBySerial(long ser)
|
||||
{
|
||||
return set.get( ser );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
import appeng.recipes.ores.IOreListener;
|
||||
import appeng.recipes.ores.OreDictionaryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class MatterCannonAmmoRegistry implements IOreListener, IMatterCannonAmmoRegistry
|
||||
{
|
||||
|
||||
private HashMap<ItemStack, Double> DamageModifiers = new HashMap<ItemStack, Double>();
|
||||
|
||||
@Override
|
||||
public void registerAmmo(ItemStack ammo, double weight)
|
||||
{
|
||||
DamageModifiers.put( ammo, weight );
|
||||
}
|
||||
|
||||
private void considerItem(String ore, ItemStack item, String Name, double weight)
|
||||
{
|
||||
if ( ore.equals( "berry" + Name ) || ore.equals( "nugget" + Name ) )
|
||||
{
|
||||
registerAmmo( item, weight );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void oreRegistered(String Name, ItemStack item)
|
||||
{
|
||||
if ( !(Name.startsWith( "berry" ) || Name.startsWith( "nugget" )) )
|
||||
return;
|
||||
|
||||
// addNugget( "Cobble", 18 ); // ?
|
||||
considerItem( Name, item, "MeatRaw", 32 );
|
||||
considerItem( Name, item, "MeatCooked", 32 );
|
||||
considerItem( Name, item, "Meat", 32 );
|
||||
considerItem( Name, item, "Chicken", 32 );
|
||||
considerItem( Name, item, "Beef", 32 );
|
||||
considerItem( Name, item, "Sheep", 32 );
|
||||
considerItem( Name, item, "Fish", 32 );
|
||||
|
||||
// real world...
|
||||
considerItem( Name, item, "Lithium", 6.941 );
|
||||
considerItem( Name, item, "Beryllium", 9.0122 );
|
||||
considerItem( Name, item, "Boron", 10.811 );
|
||||
considerItem( Name, item, "Carbon", 12.0107 );
|
||||
considerItem( Name, item, "Coal", 12.0107 );
|
||||
considerItem( Name, item, "Charcoal", 12.0107 );
|
||||
considerItem( Name, item, "Sodium", 22.9897 );
|
||||
considerItem( Name, item, "Magnesium", 24.305 );
|
||||
considerItem( Name, item, "Aluminum", 26.9815 );
|
||||
considerItem( Name, item, "Silicon", 28.0855 );
|
||||
considerItem( Name, item, "Phosphorus", 30.9738 );
|
||||
considerItem( Name, item, "Sulfur", 32.065 );
|
||||
considerItem( Name, item, "Potassium", 39.0983 );
|
||||
considerItem( Name, item, "Calcium", 40.078 );
|
||||
considerItem( Name, item, "Scandium", 44.9559 );
|
||||
considerItem( Name, item, "Titanium", 47.867 );
|
||||
considerItem( Name, item, "Vanadium", 50.9415 );
|
||||
considerItem( Name, item, "Manganese", 54.938 );
|
||||
considerItem( Name, item, "Iron", 55.845 );
|
||||
considerItem( Name, item, "Nickel", 58.6934 );
|
||||
considerItem( Name, item, "Cobalt", 58.9332 );
|
||||
considerItem( Name, item, "Copper", 63.546 );
|
||||
considerItem( Name, item, "Zinc", 65.39 );
|
||||
considerItem( Name, item, "Gallium", 69.723 );
|
||||
considerItem( Name, item, "Germanium", 72.64 );
|
||||
considerItem( Name, item, "Bromine", 79.904 );
|
||||
considerItem( Name, item, "Krypton", 83.8 );
|
||||
considerItem( Name, item, "Rubidium", 85.4678 );
|
||||
considerItem( Name, item, "Strontium", 87.62 );
|
||||
considerItem( Name, item, "Yttrium", 88.9059 );
|
||||
considerItem( Name, item, "Zirconiumm", 91.224 );
|
||||
considerItem( Name, item, "Niobiumm", 92.9064 );
|
||||
considerItem( Name, item, "Technetium", 98 );
|
||||
considerItem( Name, item, "Ruthenium", 101.07 );
|
||||
considerItem( Name, item, "Rhodium", 102.9055 );
|
||||
considerItem( Name, item, "Palladium", 106.42 );
|
||||
considerItem( Name, item, "Silver", 107.8682 );
|
||||
considerItem( Name, item, "Cadmium", 112.411 );
|
||||
considerItem( Name, item, "Indium", 114.818 );
|
||||
considerItem( Name, item, "Tin", 118.71 );
|
||||
considerItem( Name, item, "Antimony", 121.76 );
|
||||
considerItem( Name, item, "Iodine", 126.9045 );
|
||||
considerItem( Name, item, "Tellurium", 127.6 );
|
||||
considerItem( Name, item, "Xenon", 131.293 );
|
||||
considerItem( Name, item, "Cesium", 132.9055 );
|
||||
considerItem( Name, item, "Barium", 137.327 );
|
||||
considerItem( Name, item, "Lanthanum", 138.9055 );
|
||||
considerItem( Name, item, "Cerium", 140.116 );
|
||||
considerItem( Name, item, "Tantalum", 180.9479 );
|
||||
considerItem( Name, item, "Tungsten", 183.84 );
|
||||
considerItem( Name, item, "Osmium", 190.23 );
|
||||
considerItem( Name, item, "Iridium", 192.217 );
|
||||
considerItem( Name, item, "Platinum", 195.078 );
|
||||
considerItem( Name, item, "Lead", 207.2 );
|
||||
considerItem( Name, item, "Bismuth", 208.9804 );
|
||||
considerItem( Name, item, "Uranium", 238.0289 );
|
||||
considerItem( Name, item, "Plutonium", 244 );
|
||||
|
||||
// TE stuff...
|
||||
considerItem( Name, item, "Invar", (58.6934 + 55.845 + 55.845) / 3.0 );
|
||||
considerItem( Name, item, "Electrum", (107.8682 + 196.96655) / 2.0 );
|
||||
}
|
||||
|
||||
public MatterCannonAmmoRegistry() {
|
||||
OreDictionaryHandler.instance.observe( this );
|
||||
registerAmmo( new ItemStack( Items.gold_nugget ), 196.96655 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPenetration(ItemStack is)
|
||||
{
|
||||
for (ItemStack o : DamageModifiers.keySet())
|
||||
{
|
||||
if ( Platform.isSameItem( o, is ) )
|
||||
return DamageModifiers.get( o ).floatValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.movable.IMovableHandler;
|
||||
import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import appeng.spatial.DefaultSpatialHandler;
|
||||
|
||||
public class MovableTileRegistry implements IMovableRegistry
|
||||
{
|
||||
|
||||
private HashSet<Block> blacklisted = new HashSet();
|
||||
|
||||
private HashMap<Class<? extends TileEntity>, IMovableHandler> Valid = new HashMap<Class<? extends TileEntity>, IMovableHandler>();
|
||||
private LinkedList<Class<? extends TileEntity>> test = new LinkedList<Class<? extends TileEntity>>();
|
||||
private LinkedList<IMovableHandler> handlers = new LinkedList<IMovableHandler>();
|
||||
private DefaultSpatialHandler dsh = new DefaultSpatialHandler();
|
||||
|
||||
private IMovableHandler nullHandler = new DefaultSpatialHandler();
|
||||
|
||||
private IMovableHandler testClass(Class myClass, TileEntity te)
|
||||
{
|
||||
IMovableHandler handler = null;
|
||||
|
||||
// ask handlers...
|
||||
for (IMovableHandler han : handlers)
|
||||
{
|
||||
if ( han.canHandle( myClass, te ) )
|
||||
{
|
||||
handler = han;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if you have a handler your opted in
|
||||
if ( handler != null )
|
||||
{
|
||||
Valid.put( myClass, handler );
|
||||
return handler;
|
||||
|
||||
}
|
||||
|
||||
// if your movable our opted in
|
||||
if ( te instanceof IMovableTile )
|
||||
{
|
||||
Valid.put( myClass, dsh );
|
||||
return dsh;
|
||||
}
|
||||
|
||||
// if you are on the white list your opted in.
|
||||
for (Class<? extends TileEntity> testClass : test)
|
||||
{
|
||||
if ( testClass.isAssignableFrom( myClass ) )
|
||||
{
|
||||
Valid.put( myClass, dsh );
|
||||
return dsh;
|
||||
}
|
||||
}
|
||||
|
||||
Valid.put( myClass, nullHandler );
|
||||
return nullHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean askToMove(TileEntity te)
|
||||
{
|
||||
Class myClass = te.getClass();
|
||||
IMovableHandler canMove = Valid.get( myClass );
|
||||
|
||||
if ( canMove == null )
|
||||
canMove = testClass( myClass, te );
|
||||
|
||||
if ( canMove != nullHandler )
|
||||
{
|
||||
if ( te instanceof IMovableTile )
|
||||
((IMovableTile) te).prepareToMove();
|
||||
|
||||
te.invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneMoving(TileEntity te)
|
||||
{
|
||||
if ( te instanceof IMovableTile )
|
||||
{
|
||||
IMovableTile mt = (IMovableTile) te;
|
||||
mt.doneMoving();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whiteListTileEntity(Class<? extends TileEntity> c)
|
||||
{
|
||||
|
||||
if ( c.getName().equals( TileEntity.class.getName() ) )
|
||||
{
|
||||
throw new RuntimeException( new AppEngException(
|
||||
"Someone tried to make all tiles movable, this is a clear violation of the purpose of the white list." ) );
|
||||
}
|
||||
|
||||
test.add( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHandler(IMovableHandler han)
|
||||
{
|
||||
handlers.add( han );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMovableHandler getHandler(TileEntity te)
|
||||
{
|
||||
Class myClass = te.getClass();
|
||||
IMovableHandler h = Valid.get( myClass );
|
||||
return h == null ? dsh : h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMovableHandler getDefaultHandler()
|
||||
{
|
||||
return dsh;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blacklistBlock(Block blk)
|
||||
{
|
||||
blacklisted.add( blk );
|
||||
}
|
||||
|
||||
public boolean isBlacklisted(Block blk)
|
||||
{
|
||||
return blacklisted.contains( blk );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.definitions.Parts;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
{
|
||||
|
||||
HashMap<ItemStack, TunnelType> Tunnels = new HashMap();
|
||||
|
||||
public ItemStack getModItem(String modID, String Name, int meta)
|
||||
{
|
||||
ItemStack myItemStack = GameRegistry.findItemStack( modID, Name, 1 );
|
||||
|
||||
if ( myItemStack == null )
|
||||
return null;
|
||||
|
||||
myItemStack.setItemDamage( meta );
|
||||
return myItemStack;
|
||||
}
|
||||
|
||||
public void configure()
|
||||
{
|
||||
/**
|
||||
* light!
|
||||
*/
|
||||
addNewAttunement( new ItemStack( Blocks.torch ), TunnelType.LIGHT );
|
||||
addNewAttunement( new ItemStack( Blocks.glowstone ), TunnelType.LIGHT );
|
||||
|
||||
/**
|
||||
* attune based on most redstone base items.
|
||||
*/
|
||||
addNewAttunement( new ItemStack( Items.redstone ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Items.repeater ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.redstone_lamp ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.unpowered_comparator ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.powered_comparator ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.powered_repeater ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.unpowered_repeater ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.daylight_detector ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.redstone_wire ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.redstone_block ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.lever ), TunnelType.REDSTONE );
|
||||
addNewAttunement( getModItem( "EnderIO", "itemRedstoneConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.REDSTONE );
|
||||
|
||||
/**
|
||||
* attune based on lots of random item related stuff
|
||||
*/
|
||||
appeng.api.definitions.Blocks AEBlocks = AEApi.instance().blocks();
|
||||
Parts Parts = AEApi.instance().parts();
|
||||
|
||||
addNewAttunement( AEBlocks.blockInterface.stack( 1 ), TunnelType.ITEM );
|
||||
addNewAttunement( Parts.partInterface.stack( 1 ), TunnelType.ITEM );
|
||||
addNewAttunement( Parts.partStorageBus.stack( 1 ), TunnelType.ITEM );
|
||||
addNewAttunement( Parts.partImportBus.stack( 1 ), TunnelType.ITEM );
|
||||
addNewAttunement( Parts.partExportBus.stack( 1 ), TunnelType.ITEM );
|
||||
addNewAttunement( new ItemStack( Blocks.hopper ), TunnelType.ITEM );
|
||||
addNewAttunement( new ItemStack( Blocks.chest ), TunnelType.ITEM );
|
||||
addNewAttunement( new ItemStack( Blocks.trapped_chest ), TunnelType.ITEM );
|
||||
addNewAttunement( getModItem( "ExtraUtilities", "extractor_base", 0 ), TunnelType.ITEM );
|
||||
addNewAttunement( getModItem( "Mekanism", "PartTransmitter", 9 ), TunnelType.ITEM );
|
||||
addNewAttunement( getModItem( "EnderIO", "itemItemConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.ITEM );
|
||||
|
||||
/**
|
||||
* attune based on lots of random item related stuff
|
||||
*/
|
||||
addNewAttunement( new ItemStack( Items.bucket ), TunnelType.FLUID );
|
||||
addNewAttunement( new ItemStack( Items.lava_bucket ), TunnelType.FLUID );
|
||||
addNewAttunement( new ItemStack( Items.milk_bucket ), TunnelType.FLUID );
|
||||
addNewAttunement( new ItemStack( Items.water_bucket ), TunnelType.FLUID );
|
||||
addNewAttunement( getModItem( "Mekanism", "MachineBlock2", 11 ), TunnelType.FLUID );
|
||||
addNewAttunement( getModItem( "Mekanism", "PartTransmitter", 4 ), TunnelType.FLUID );
|
||||
addNewAttunement( getModItem( "ExtraUtilities", "extractor_base", 6 ), TunnelType.FLUID );
|
||||
addNewAttunement( getModItem( "ExtraUtilities", "drum", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
||||
addNewAttunement( getModItem( "EnderIO", "itemLiquidConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
||||
|
||||
for (AEColor c : AEColor.values())
|
||||
{
|
||||
addNewAttunement( Parts.partCableGlass.stack( c, 1 ), TunnelType.ME );
|
||||
addNewAttunement( Parts.partCableCovered.stack( c, 1 ), TunnelType.ME );
|
||||
addNewAttunement( Parts.partCableSmart.stack( c, 1 ), TunnelType.ME );
|
||||
addNewAttunement( Parts.partCableDense.stack( c, 1 ), TunnelType.ME );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewAttunement(ItemStack trigger, TunnelType type)
|
||||
{
|
||||
if ( type == null || trigger == null )
|
||||
return;
|
||||
|
||||
Tunnels.put( trigger, type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TunnelType getTunnelTypeByItem(ItemStack trigger)
|
||||
{
|
||||
if ( trigger != null )
|
||||
{
|
||||
if ( FluidContainerRegistry.isContainer( trigger ) )
|
||||
return TunnelType.FLUID;
|
||||
|
||||
for (ItemStack is : Tunnels.keySet())
|
||||
{
|
||||
if ( is.getItem() == trigger.getItem() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
|
||||
return Tunnels.get( is );
|
||||
|
||||
if ( Platform.isSameItem( is, trigger ) )
|
||||
return Tunnels.get( is );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.api.features.IPlayerRegistry;
|
||||
import appeng.core.WorldSettings;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public class PlayerRegistry implements IPlayerRegistry
|
||||
{
|
||||
|
||||
@Override
|
||||
public int getID(GameProfile username)
|
||||
{
|
||||
return WorldSettings.getInstance().getPlayerID( username );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID(EntityPlayer player)
|
||||
{
|
||||
return WorldSettings.getInstance().getPlayerID( player.getGameProfile() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer findPlayer(int playerID)
|
||||
{
|
||||
return WorldSettings.getInstance().getPlayerFromID( playerID );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import appeng.api.features.IRecipeHandlerRegistry;
|
||||
import appeng.api.recipes.ICraftHandler;
|
||||
import appeng.api.recipes.IRecipeHandler;
|
||||
import appeng.api.recipes.ISubItemResolver;
|
||||
import appeng.core.AELog;
|
||||
import appeng.recipes.RecipeHandler;
|
||||
|
||||
public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
|
||||
{
|
||||
|
||||
HashMap<String, Class<? extends ICraftHandler>> handlers = new HashMap<String, Class<? extends ICraftHandler>>();
|
||||
LinkedList<ISubItemResolver> resolvers = new LinkedList<ISubItemResolver>();
|
||||
|
||||
@Override
|
||||
public void addNewCraftHandler(String name, Class<? extends ICraftHandler> handler)
|
||||
{
|
||||
handlers.put( name.toLowerCase(), handler );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftHandler getCraftHandlerFor(String name)
|
||||
{
|
||||
Class<? extends ICraftHandler> clz = handlers.get( name );
|
||||
if ( clz == null )
|
||||
return null;
|
||||
try
|
||||
{
|
||||
return clz.newInstance();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
AELog.severe( "Error Caused when trying to construct " + clz.getName() );
|
||||
AELog.error( e );
|
||||
handlers.put( name, null ); // clear it..
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeHandler createNewRecipehandler()
|
||||
{
|
||||
return new RecipeHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewSubItemResolver(ISubItemResolver sir)
|
||||
{
|
||||
resolvers.add( sir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveItem(String nameSpace, String itemName)
|
||||
{
|
||||
for (ISubItemResolver sir : resolvers)
|
||||
{
|
||||
Object rr = null;
|
||||
|
||||
try
|
||||
{
|
||||
rr = sir.resolveItemByName( nameSpace, itemName );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
if ( rr != null )
|
||||
return rr;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import appeng.api.features.IGrinderRegistry;
|
||||
import appeng.api.features.ILocatableRegistry;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.features.IPlayerRegistry;
|
||||
import appeng.api.features.IRecipeHandlerRegistry;
|
||||
import appeng.api.features.IRegistryContainer;
|
||||
import appeng.api.features.ISpecialComparisonRegistry;
|
||||
import appeng.api.features.IWirelessTermRegistry;
|
||||
import appeng.api.features.IWorldGen;
|
||||
import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.api.storage.ICellRegistry;
|
||||
import appeng.api.storage.IExternalStorageRegistry;
|
||||
|
||||
public class RegistryContainer implements IRegistryContainer
|
||||
{
|
||||
|
||||
private GrinderRecipeManager GrinderRecipes = new GrinderRecipeManager();
|
||||
private ExternalStorageRegistry ExternalStorageHandlers = new ExternalStorageRegistry();
|
||||
private CellRegistry CellRegistry = new CellRegistry();
|
||||
private LocatableRegistry LocatableRegistry = new LocatableRegistry();
|
||||
private SpecialComparisonRegistry SpecialComparisonRegistry = new SpecialComparisonRegistry();
|
||||
private WirelessRegistry WirelessRegistry = new WirelessRegistry();
|
||||
private GridCacheRegistry GridCacheRegistry = new GridCacheRegistry();
|
||||
private P2PTunnelRegistry P2PRegistry = new P2PTunnelRegistry();
|
||||
private MovableTileRegistry MovableReg = new MovableTileRegistry();
|
||||
private MatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry();
|
||||
private PlayerRegistry playerreg = new PlayerRegistry();
|
||||
private IRecipeHandlerRegistry recipeReg = new RecipeHandlerRegistry();
|
||||
|
||||
@Override
|
||||
public IWirelessTermRegistry wireless()
|
||||
{
|
||||
return WirelessRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICellRegistry cell()
|
||||
{
|
||||
return CellRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrinderRegistry grinder()
|
||||
{
|
||||
return GrinderRecipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpecialComparisonRegistry specialComparison()
|
||||
{
|
||||
return SpecialComparisonRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExternalStorageRegistry externalStorage()
|
||||
{
|
||||
return ExternalStorageHandlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILocatableRegistry locatable()
|
||||
{
|
||||
return LocatableRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridCacheRegistry gridCache()
|
||||
{
|
||||
return GridCacheRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMovableRegistry movable()
|
||||
{
|
||||
return MovableReg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IP2PTunnelRegistry p2pTunnel()
|
||||
{
|
||||
return P2PRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMatterCannonAmmoRegistry matterCannon()
|
||||
{
|
||||
return matterCannonReg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayerRegistry players()
|
||||
{
|
||||
return playerreg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeHandlerRegistry recipes()
|
||||
{
|
||||
return recipeReg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorldGen worldgen()
|
||||
{
|
||||
return WorldGenRegistry.instance;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.features.IItemComparisonProvider;
|
||||
import appeng.api.features.IItemComparison;
|
||||
import appeng.api.features.ISpecialComparisonRegistry;
|
||||
|
||||
public class SpecialComparisonRegistry implements ISpecialComparisonRegistry
|
||||
{
|
||||
|
||||
private List<IItemComparisonProvider> CompRegistry;
|
||||
|
||||
public SpecialComparisonRegistry() {
|
||||
CompRegistry = new ArrayList<IItemComparisonProvider>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemComparison getSpecialComparison(ItemStack stack)
|
||||
{
|
||||
for (IItemComparisonProvider i : CompRegistry)
|
||||
{
|
||||
IItemComparison comp = i.getComparison( stack );
|
||||
if ( comp != null )
|
||||
{
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addComparisonProvider(IItemComparisonProvider prov)
|
||||
{
|
||||
CompRegistry.add( prov );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class WirelessRangeResult
|
||||
{
|
||||
|
||||
public WirelessRangeResult(TileEntity t, float d) {
|
||||
dist = d;
|
||||
te = t;
|
||||
}
|
||||
|
||||
final public float dist;
|
||||
final public TileEntity te;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.features.IWirelessTermRegistry;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessRegistry implements IWirelessTermRegistry
|
||||
{
|
||||
|
||||
List<IWirelessTermHandler> handlers;
|
||||
|
||||
public WirelessRegistry() {
|
||||
handlers = new ArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerWirelessHandler(IWirelessTermHandler handler)
|
||||
{
|
||||
if ( handler != null )
|
||||
handlers.add( handler );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWirelessTerminal(ItemStack is)
|
||||
{
|
||||
for (IWirelessTermHandler h : handlers)
|
||||
{
|
||||
if ( h.canHandle( is ) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWirelessTermHandler getWirelessTerminalHandler(ItemStack is)
|
||||
{
|
||||
for (IWirelessTermHandler h : handlers)
|
||||
{
|
||||
if ( h.canHandle( is ) )
|
||||
return h;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openWirelessTerminalGui(ItemStack item, World w, EntityPlayer player)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
IWirelessTermHandler handler = getWirelessTerminalHandler( item );
|
||||
if ( handler == null )
|
||||
{
|
||||
player.addChatMessage( new ChatComponentText( "Item is not a wireless terminal." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( handler.hasPower( player, 0.5, item ) )
|
||||
{
|
||||
Platform.openGUI( player, null, null, GuiBridge.GUI_WIRELESS_TERM );
|
||||
}
|
||||
else
|
||||
player.addChatMessage( PlayerMessages.DeviceNotPowered.get() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import appeng.api.features.IWorldGen;
|
||||
|
||||
public class WorldGenRegistry implements IWorldGen
|
||||
{
|
||||
|
||||
private class TypeSet
|
||||
{
|
||||
|
||||
HashSet<Class<? extends WorldProvider>> badProviders = new HashSet();
|
||||
HashSet<Integer> badDimensions = new HashSet();
|
||||
|
||||
};
|
||||
|
||||
TypeSet[] types;
|
||||
|
||||
static final public WorldGenRegistry instance = new WorldGenRegistry();
|
||||
|
||||
private WorldGenRegistry() {
|
||||
|
||||
types = new TypeSet[WorldGenType.values().length];
|
||||
|
||||
for (WorldGenType type : WorldGenType.values())
|
||||
{
|
||||
types[type.ordinal()] = new TypeSet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldGenEnabled(WorldGenType type, World w)
|
||||
{
|
||||
if ( type == null )
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
|
||||
if ( w == null )
|
||||
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||
|
||||
if ( types[type.ordinal()].badProviders.contains( w.provider.getClass() ) || types[type.ordinal()].badDimensions.contains( w.provider.dimensionId ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableWorldGenForProviderID(WorldGenType type, Class<? extends WorldProvider> provider)
|
||||
{
|
||||
if ( type == null )
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
|
||||
if ( provider == null )
|
||||
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||
|
||||
types[type.ordinal()].badProviders.add( provider );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableWorldGenForDimension(WorldGenType type, int dimid)
|
||||
{
|
||||
if ( type == null )
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
|
||||
types[type.ordinal()].badDimensions.add( dimid );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.features.IGrinderEntry;
|
||||
|
||||
public class AppEngGrinderRecipe implements IGrinderEntry
|
||||
{
|
||||
|
||||
private ItemStack in;
|
||||
private ItemStack out;
|
||||
|
||||
private float optionalChance;
|
||||
private ItemStack optionalOutput;
|
||||
|
||||
private float optionalChance2;
|
||||
private ItemStack optionalOutput2;
|
||||
|
||||
private int energy;
|
||||
|
||||
public AppEngGrinderRecipe(ItemStack a, ItemStack b, int cost) {
|
||||
in = a;
|
||||
out = b;
|
||||
energy = cost;
|
||||
}
|
||||
|
||||
public AppEngGrinderRecipe(ItemStack a, ItemStack b, ItemStack c, float chance, int cost) {
|
||||
in = a;
|
||||
out = b;
|
||||
|
||||
optionalOutput = c;
|
||||
optionalChance = chance;
|
||||
|
||||
energy = cost;
|
||||
}
|
||||
|
||||
public AppEngGrinderRecipe(ItemStack a, ItemStack b, ItemStack c, ItemStack d, float chance, float chance2, int cost) {
|
||||
in = a;
|
||||
out = b;
|
||||
|
||||
optionalOutput = c;
|
||||
optionalChance = chance;
|
||||
|
||||
optionalOutput2 = d;
|
||||
optionalChance2 = chance2;
|
||||
|
||||
energy = cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getInput()
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInput(ItemStack i)
|
||||
{
|
||||
in = i.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutput()
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutput(ItemStack o)
|
||||
{
|
||||
out = o.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyCost()
|
||||
{
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergyCost(int c)
|
||||
{
|
||||
energy = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOptionalOutput()
|
||||
{
|
||||
return optionalOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptionalOutput(ItemStack output, float chance)
|
||||
{
|
||||
optionalOutput = output.copy();
|
||||
optionalChance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getOptionalChance()
|
||||
{
|
||||
return optionalChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSecondOptionalOutput()
|
||||
{
|
||||
return optionalOutput2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondOptionalOutput(ItemStack output, float chance)
|
||||
{
|
||||
optionalChance2 = chance;
|
||||
optionalOutput2 = output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSecondOptionalChance()
|
||||
{
|
||||
return optionalChance2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.storage.CellInventory;
|
||||
import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BasicCellHandler implements ICellHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isCell(ItemStack is)
|
||||
{
|
||||
return CellInventory.isCell( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel channel)
|
||||
{
|
||||
if ( channel == StorageChannel.ITEMS )
|
||||
return CellInventory.getCell( is, container );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Dark()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Dark.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Light()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Light.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Medium()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Medium.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui(EntityPlayer player, IChestOrDrive chest, ICellHandler cellHandler, IMEInventoryHandler inv, ItemStack is, StorageChannel chan)
|
||||
{
|
||||
Platform.openGUI( player, (AEBaseTile) chest, chest.getUp(), GuiBridge.GUI_ME );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell(ItemStack is, IMEInventory handler)
|
||||
{
|
||||
if ( handler instanceof CellInventoryHandler )
|
||||
{
|
||||
CellInventoryHandler ci = (CellInventoryHandler) handler;
|
||||
return ci.getStatusForCell();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double cellIdleDrain(ItemStack is, IMEInventory handler)
|
||||
{
|
||||
ICellInventory inv = ((ICellInventoryHandler) handler).getCellInv();
|
||||
return inv.getIdleDrain();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.storage.ItemCreativeStorageCell;
|
||||
import appeng.me.storage.CreativeCellInventory;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CreativeCellHandler implements ICellHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isCell(ItemStack is)
|
||||
{
|
||||
return is != null && is.getItem() instanceof ItemCreativeStorageCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel channel)
|
||||
{
|
||||
if ( channel == StorageChannel.ITEMS && is != null && is.getItem() instanceof ItemCreativeStorageCell )
|
||||
return CreativeCellInventory.getCell( is );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui(EntityPlayer player, IChestOrDrive chest, ICellHandler cellHandler, IMEInventoryHandler inv, ItemStack is, StorageChannel chan)
|
||||
{
|
||||
Platform.openGUI( player, (AEBaseTile) chest, chest.getUp(), GuiBridge.GUI_ME );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell(ItemStack is, IMEInventory handler)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double cellIdleDrain(ItemStack is, IMEInventory handler)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Light()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Light.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Medium()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Medium.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Dark()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Dark.getIcon();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.me.storage.MEMonitorIInventory;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
|
||||
public class ExternalIInv implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc)
|
||||
{
|
||||
return channel == StorageChannel.ITEMS && te instanceof IInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src)
|
||||
{
|
||||
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( (IInventory) te, d );
|
||||
|
||||
if ( channel == StorageChannel.ITEMS && ad != null )
|
||||
return new MEMonitorIInventory( ad );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user