Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package appeng.integration;
|
||||
|
||||
public abstract class BaseModule implements IIntegrationModule {
|
||||
|
||||
protected void TestClass( Class clz )
|
||||
{
|
||||
clz.isInstance(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void Init() throws Throwable;
|
||||
|
||||
@Override
|
||||
public abstract void PostInit() throws Throwable;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package appeng.integration;
|
||||
|
||||
public interface IIntegrationModule
|
||||
{
|
||||
|
||||
void Init() throws Throwable;
|
||||
|
||||
void PostInit() throws Throwable;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package appeng.integration;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import appeng.api.exceptions.ModNotInstalled;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class IntegrationNode
|
||||
{
|
||||
|
||||
IntegrationStage state = IntegrationStage.PREINIT;
|
||||
IntegrationStage failedStage = IntegrationStage.PREINIT;
|
||||
Throwable exception = null;
|
||||
|
||||
String displayName;
|
||||
String modID;
|
||||
|
||||
IntegrationType shortName;
|
||||
String name = null;
|
||||
Class classValue = null;
|
||||
Object instance;
|
||||
IIntegrationModule mod = null;
|
||||
|
||||
public IntegrationNode(String dspname, String _modID, IntegrationType sName, String n) {
|
||||
displayName = dspname;
|
||||
shortName = sName;
|
||||
modID = _modID;
|
||||
name = n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return shortName.name() + ":" + state.name();
|
||||
}
|
||||
|
||||
void Call(IntegrationStage stage)
|
||||
{
|
||||
if ( state != IntegrationStage.FAILED )
|
||||
{
|
||||
if ( state.ordinal() > stage.ordinal() )
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
switch (stage)
|
||||
{
|
||||
case PREINIT:
|
||||
|
||||
boolean enabled = modID == null || Loader.isModLoaded( modID );
|
||||
|
||||
AEConfig.instance
|
||||
.addCustomCategoryComment(
|
||||
"ModIntegration",
|
||||
"Valid Values are 'AUTO', 'ON', or 'OFF' - defaults to 'AUTO' ; Suggested that you leave this alone unless your experiencing an issue, or wish to disable the integration for a reason." );
|
||||
String Mode = AEConfig.instance.get( "ModIntegration", displayName.replace( " ", "" ), "AUTO" ).getString();
|
||||
|
||||
if ( Mode.toUpperCase().equals( "ON" ) )
|
||||
enabled = true;
|
||||
if ( Mode.toUpperCase().equals( "OFF" ) )
|
||||
enabled = false;
|
||||
|
||||
if ( enabled )
|
||||
{
|
||||
classValue = getClass().getClassLoader().loadClass( name );
|
||||
mod = (IIntegrationModule) classValue.getConstructor().newInstance();
|
||||
Field f = classValue.getField( "instance" );
|
||||
f.set( classValue, instance = mod );
|
||||
}
|
||||
else
|
||||
throw new ModNotInstalled( modID );
|
||||
|
||||
state = IntegrationStage.INIT;
|
||||
|
||||
break;
|
||||
case INIT:
|
||||
mod.Init();
|
||||
state = IntegrationStage.POSTINIT;
|
||||
|
||||
break;
|
||||
case POSTINIT:
|
||||
mod.PostInit();
|
||||
state = IntegrationStage.READY;
|
||||
|
||||
break;
|
||||
case FAILED:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
failedStage = stage;
|
||||
exception = t;
|
||||
state = IntegrationStage.FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
if ( stage == IntegrationStage.POSTINIT )
|
||||
{
|
||||
if ( state == IntegrationStage.FAILED )
|
||||
{
|
||||
AELog.info( displayName + " - Integration Disabled" );
|
||||
if ( !(exception instanceof ModNotInstalled) )
|
||||
AELog.integration( exception );
|
||||
}
|
||||
else
|
||||
{
|
||||
AELog.info( displayName + " - Integration Enable" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
if ( state == IntegrationStage.PREINIT )
|
||||
Call( IntegrationStage.PREINIT );
|
||||
|
||||
return state != IntegrationStage.FAILED;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package appeng.integration;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class IntegrationRegistry
|
||||
{
|
||||
|
||||
public static IntegrationRegistry instance = null;
|
||||
private LinkedList<IntegrationNode> modules = new LinkedList<IntegrationNode>();
|
||||
|
||||
public void add( IntegrationType type)
|
||||
{
|
||||
if ( type.side == IntegrationSide.CLIENT && FMLLaunchHandler.side() == Side.SERVER )
|
||||
return;
|
||||
|
||||
if ( type.side == IntegrationSide.SERVER && FMLLaunchHandler.side() == Side.CLIENT )
|
||||
return;
|
||||
|
||||
modules.add( new IntegrationNode( type.dspName, type.modID, type, "appeng.integration.modules." + type.name() ) );
|
||||
}
|
||||
|
||||
public IntegrationRegistry() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
for (IntegrationNode node : modules)
|
||||
node.Call( IntegrationStage.PREINIT );
|
||||
|
||||
for (IntegrationNode node : modules)
|
||||
node.Call( IntegrationStage.INIT );
|
||||
}
|
||||
|
||||
public void postinit()
|
||||
{
|
||||
for (IntegrationNode node : modules)
|
||||
node.Call( IntegrationStage.POSTINIT );
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
String out = null;
|
||||
|
||||
for (IntegrationNode node : modules)
|
||||
{
|
||||
String str = node.shortName + ":" + (node.state == IntegrationStage.FAILED ? "OFF" : "ON");
|
||||
|
||||
if ( out == null )
|
||||
out = str;
|
||||
else
|
||||
out += ", " + str;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public boolean isEnabled(IntegrationType name)
|
||||
{
|
||||
for (IntegrationNode node : modules)
|
||||
{
|
||||
if ( node.shortName == name )
|
||||
return node.isActive();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object getInstance(IntegrationType name)
|
||||
{
|
||||
for (IntegrationNode node : modules)
|
||||
{
|
||||
if ( node.shortName.equals( name ) && node.isActive() )
|
||||
{
|
||||
return node.instance;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException( "integration with "+name.name()+" is disabled." );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package appeng.integration;
|
||||
|
||||
public enum IntegrationSide
|
||||
{
|
||||
CLIENT, SERVER, BOTH
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package appeng.integration;
|
||||
|
||||
public enum IntegrationStage
|
||||
{
|
||||
|
||||
PREINIT, INIT, POSTINIT,
|
||||
|
||||
FAILED, READY
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package appeng.integration;
|
||||
|
||||
public enum IntegrationType
|
||||
{
|
||||
IC2(IntegrationSide.BOTH, "Industrial Craft 2", "IC2"),
|
||||
|
||||
RotaryCraft(IntegrationSide.BOTH, "Rotary Craft", "RotaryCraft"),
|
||||
|
||||
RC(IntegrationSide.BOTH, "Railcraft", "Railcraft"),
|
||||
|
||||
BC(IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon"),
|
||||
|
||||
MJ6(IntegrationSide.BOTH, "BuildCraft6 Power", null),
|
||||
|
||||
MJ5(IntegrationSide.BOTH, "BuildCraft5 Power", null),
|
||||
|
||||
RF(IntegrationSide.BOTH, "RedstoneFlux Power - Tiles", null),
|
||||
|
||||
RFItem(IntegrationSide.BOTH, "RedstoneFlux Power - Items", null),
|
||||
|
||||
MFR(IntegrationSide.BOTH, "Mine Factory Reloaded", "MineFactoryReloaded"),
|
||||
|
||||
DSU(IntegrationSide.BOTH, "Deep Storage Unit", null),
|
||||
|
||||
FZ(IntegrationSide.BOTH, "Factorization", "factorization"),
|
||||
|
||||
FMP(IntegrationSide.BOTH, "Forge MultiPart", "McMultipart"),
|
||||
|
||||
RB(IntegrationSide.BOTH, "Rotatable Blocks", "RotatableBlocks"),
|
||||
|
||||
CLApi(IntegrationSide.BOTH, "Colored Lights Core", "coloredlightscore"),
|
||||
|
||||
Waila(IntegrationSide.CLIENT, "Waila", "Waila"),
|
||||
|
||||
InvTweaks(IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks"),
|
||||
|
||||
NEI(IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems"),
|
||||
|
||||
CraftGuide(IntegrationSide.CLIENT, "Craft Guide", "craftguide"),
|
||||
|
||||
Mekanism(IntegrationSide.BOTH, "Mekanism", "Mekanism"),
|
||||
|
||||
ImmibisMicroblocks(IntegrationSide.BOTH, "ImmibisMicroblocks", "ImmibisMicroblocks"),
|
||||
|
||||
BetterStorage(IntegrationSide.BOTH, "BetterStorage", "betterstorage" );
|
||||
|
||||
public final IntegrationSide side;
|
||||
public final String dspName;
|
||||
public final String modID;
|
||||
|
||||
private IntegrationType(IntegrationSide side, String Name, String modid) {
|
||||
this.side = side;
|
||||
this.dspName = Name;
|
||||
this.modID = modid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
|
||||
public interface IBC
|
||||
{
|
||||
|
||||
boolean isWrench(Item eq);
|
||||
|
||||
boolean canWrench(Item i, EntityPlayer p, int x, int y, int z);
|
||||
|
||||
void wrenchUsed(Item i, EntityPlayer p, int x, int y, int z);
|
||||
|
||||
boolean canAddItemsToPipe(TileEntity te, ItemStack is, ForgeDirection dir);
|
||||
|
||||
boolean addItemsToPipe(TileEntity te, ItemStack is, ForgeDirection dir);
|
||||
|
||||
boolean isFacade(ItemStack is);
|
||||
|
||||
boolean isPipe(TileEntity te, ForgeDirection dir);
|
||||
|
||||
void addFacade(ItemStack item);
|
||||
|
||||
void registerPowerP2P();
|
||||
|
||||
void registerItemP2P();
|
||||
|
||||
void registerLiquidsP2P();
|
||||
|
||||
IFacadePart createFacadePart(Block blk, int meta, ForgeDirection side);
|
||||
|
||||
IFacadePart createFacadePart(ItemStack held, ForgeDirection side);
|
||||
|
||||
ItemStack getTextureForFacade(ItemStack facade);
|
||||
|
||||
IIcon getFacadeTexture();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
|
||||
public interface IBetterStorage
|
||||
{
|
||||
|
||||
boolean isStorageCrate(Object te);
|
||||
|
||||
InventoryAdaptor getAdaptor(Object te, ForgeDirection d);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
public interface ICLApi
|
||||
{
|
||||
|
||||
int colorLight(AEColor color, int light);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
|
||||
public interface IDSU
|
||||
{
|
||||
|
||||
IMEInventory getDSU(TileEntity te);
|
||||
|
||||
boolean isDSU(TileEntity te);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public interface IFMP
|
||||
{
|
||||
|
||||
IPartHost getOrCreateHost(TileEntity tile);
|
||||
|
||||
CableBusContainer getCableContainer(TileEntity te);
|
||||
|
||||
void registerPassThrough(Class<?> layerInterface);
|
||||
|
||||
Event newFMPPacketEvent(EntityPlayerMP sender);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
|
||||
public interface IFZ
|
||||
{
|
||||
|
||||
ItemStack barrelGetItem(TileEntity te);
|
||||
|
||||
int barrelGetMaxItemCount(TileEntity te);
|
||||
|
||||
int barrelGetItemCount(TileEntity te);
|
||||
|
||||
void setItemType(TileEntity te, ItemStack input);
|
||||
|
||||
void barrelSetCount(TileEntity te, int max);
|
||||
|
||||
IMEInventory getFactorizationBarrel(TileEntity te);
|
||||
|
||||
boolean isBarrel(TileEntity te);
|
||||
|
||||
void grinderRecipe(ItemStack is, ItemStack itemStack);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import appeng.api.features.IItemComparisonProvider;
|
||||
|
||||
public interface IForestry
|
||||
{
|
||||
|
||||
IItemComparisonProvider getGeneticsComparisonProvider();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
|
||||
public interface IGT
|
||||
{
|
||||
|
||||
boolean isQuantumChest(TileEntity te);
|
||||
|
||||
IMEInventory getQuantumChest(TileEntity te);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public interface IIC2
|
||||
{
|
||||
|
||||
void addToEnergyNet(TileEntity appEngTile);
|
||||
|
||||
void removeFromEnergyNet(TileEntity appEngTile);
|
||||
|
||||
ItemStack getItem(String string);
|
||||
|
||||
void maceratorRecipe(ItemStack in, ItemStack out);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.parts.IPartHost;
|
||||
|
||||
public interface IImmibisMicroblocks
|
||||
{
|
||||
|
||||
IPartHost getOrCreateHost(EntityPlayer player, int side, TileEntity te);
|
||||
|
||||
/**
|
||||
* @param te
|
||||
* @return true if this worked..
|
||||
*/
|
||||
boolean leaveParts(TileEntity te);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IInvTweaks
|
||||
{
|
||||
|
||||
int compareItems(ItemStack i, ItemStack j);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
|
||||
public interface ILP
|
||||
{
|
||||
|
||||
List<ItemStack> getCraftedItems(TileEntity te);
|
||||
|
||||
List<ItemStack> getProvidedItems(TileEntity te);
|
||||
|
||||
boolean isRequestPipe(TileEntity te);
|
||||
|
||||
List<ItemStack> performRequest(TileEntity te, ItemStack wanted);
|
||||
|
||||
IMEInventory getInv(TileEntity te);
|
||||
|
||||
Object getGetPowerPipe(TileEntity te);
|
||||
|
||||
boolean isPowerSource(TileEntity tt);
|
||||
|
||||
boolean canUseEnergy(Object pp, int ceil, List<Object> providersToIgnore);
|
||||
|
||||
boolean useEnergy(Object pp, int ceil, List<Object> providersToIgnore);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
|
||||
public interface IMJ5
|
||||
{
|
||||
|
||||
Object createPerdition(Object buildCraft);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.mj.IBatteryObject;
|
||||
|
||||
public interface IMJ6
|
||||
{
|
||||
|
||||
IBatteryObject provider(TileEntity te, ForgeDirection side);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IMekanism
|
||||
{
|
||||
|
||||
void addCrusherRecipe(ItemStack in, ItemStack out);
|
||||
|
||||
void addEnrichmentChamberRecipe(ItemStack in, ItemStack out);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public interface INEI
|
||||
{
|
||||
|
||||
void drawSlot(Slot s);
|
||||
|
||||
RenderItem setItemRender(RenderItem aeri2);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.util.IOrientable;
|
||||
|
||||
public interface IRB
|
||||
{
|
||||
|
||||
IOrientable getOrientable(TileEntity te);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IRC
|
||||
{
|
||||
|
||||
void rockCrusher(ItemStack input, ItemStack output);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package appeng.integration.abstraction;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface ITE
|
||||
{
|
||||
|
||||
void addPulverizerRecipe(int i, ItemStack blkQuartz, ItemStack blockDust);
|
||||
|
||||
void addPulverizerRecipe(int i, ItemStack blkQuartzOre, ItemStack matQuartz, ItemStack matQuartzDust);
|
||||
|
||||
boolean isPipe(TileEntity te, ForgeDirection opposite);
|
||||
|
||||
ItemStack addItemsToPipe(TileEntity ad, ItemStack itemstack, ForgeDirection dir);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package appeng.integration.abstraction.helpers;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
|
||||
public abstract class BaseMJperdition
|
||||
{
|
||||
|
||||
@Method(iname = "MJ5")
|
||||
public abstract PowerReceiver getPowerReceiver();
|
||||
|
||||
public abstract double useEnergy(double f, double required, boolean b);
|
||||
|
||||
public abstract void addEnergy(float failed);
|
||||
|
||||
public abstract void configure(int i, int j, float f, int k);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void Tick();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import appeng.integration.modules.BCHelpers.AERotatableBlockSchematic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.definitions.Blocks;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.facade.FacadePart;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.IBC;
|
||||
import appeng.integration.modules.BCHelpers.AECableSchematicTile;
|
||||
import appeng.integration.modules.BCHelpers.AEGenericSchematicTile;
|
||||
import appeng.integration.modules.BCHelpers.BCPipeHandler;
|
||||
import buildcraft.BuildCraftEnergy;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.blueprints.SchematicRegistry;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import buildcraft.transport.ItemFacade;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class BC extends BaseModule implements IBC
|
||||
{
|
||||
|
||||
public static BC instance;
|
||||
|
||||
public BC() {
|
||||
TestClass( IPipeConnection.class );
|
||||
TestClass( ItemFacade.class );
|
||||
TestClass( IToolWrench.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFacade(ItemStack item)
|
||||
{
|
||||
if ( item != null )
|
||||
FMLInterModComms.sendMessage( "BuildCraft|Transport", "add-facade", item );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWrench(Item eq)
|
||||
{
|
||||
return eq instanceof IToolWrench;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPipe(TileEntity te, ForgeDirection dir)
|
||||
{
|
||||
if ( te instanceof IPipeTile )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( te instanceof TileGenericPipe )
|
||||
if ( ((TileGenericPipe) te).hasPlug( dir.getOpposite() ) )
|
||||
return false;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench(Item i, EntityPlayer p, int x, int y, int z)
|
||||
{
|
||||
return ((IToolWrench) i).canWrench( p, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wrenchUsed(Item i, EntityPlayer p, int x, int y, int z)
|
||||
{
|
||||
((IToolWrench) i).wrenchUsed( p, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addItemsToPipe(TileEntity te, ItemStack is, ForgeDirection dir)
|
||||
{
|
||||
if ( is != null && te != null && te instanceof IPipeTile )
|
||||
{
|
||||
IPipeTile pt = (IPipeTile) te;
|
||||
if ( pt.getPipeType() == PipeType.ITEM )
|
||||
{
|
||||
int amt = pt.injectItem( is, false, dir );
|
||||
if ( amt == is.stackSize )
|
||||
{
|
||||
pt.injectItem( is, true, dir );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFacade(ItemStack is)
|
||||
{
|
||||
if ( is == null )
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
return is.getItem() instanceof ItemFacade && ItemFacade.getType( is ) == ItemFacade.FacadeType.Basic;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
try
|
||||
{
|
||||
return is.getItem() instanceof ItemFacade && ItemFacade.getType( is ) == ItemFacade.TYPE_BASIC;
|
||||
}
|
||||
catch (Throwable g)
|
||||
{
|
||||
return is.getItem() instanceof ItemFacade;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddItemsToPipe(TileEntity te, ItemStack is, ForgeDirection dir)
|
||||
{
|
||||
|
||||
if ( is != null && te != null && te instanceof IPipeTile )
|
||||
{
|
||||
IPipeTile pt = (IPipeTile) te;
|
||||
if ( pt.getPipeType() == PipeType.ITEM )
|
||||
{
|
||||
int amt = pt.injectItem( is, false, dir );
|
||||
if ( amt == is.stackSize )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPowerP2P()
|
||||
{
|
||||
IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftEnergy.engineBlock, 1, 0 ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftEnergy.engineBlock, 1, 1 ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftEnergy.engineBlock, 1, 2 ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerCobblestone ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerDiamond ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerGold ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerQuartz ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerStone ), TunnelType.BC_POWER );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipePowerWood ), TunnelType.BC_POWER );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemP2P()
|
||||
{
|
||||
IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsWood ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsVoid ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsSandstone ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsQuartz ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsObsidian ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsIron ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsGold ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsEmerald ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsDiamond ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsStone ), TunnelType.ITEM );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeItemsCobblestone ), TunnelType.ITEM );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerLiquidsP2P()
|
||||
{
|
||||
IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsCobblestone ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsEmerald ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsGold ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsIron ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsSandstone ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsStone ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsVoid ), TunnelType.FLUID );
|
||||
reg.addNewAttunement( new ItemStack( BuildCraftTransport.pipeFluidsWood ), TunnelType.FLUID );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
AEApi.instance().partHelper().registerNewLayer( "appeng.parts.layers.LayerIPipeConnection", "buildcraft.api.transport.IPipeConnection" );
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new BCPipeHandler() );
|
||||
|
||||
Blocks b = AEApi.instance().blocks();
|
||||
addFacade( b.blockFluix.stack( 1 ) );
|
||||
addFacade( b.blockQuartz.stack( 1 ) );
|
||||
addFacade( b.blockQuartzChiseled.stack( 1 ) );
|
||||
addFacade( b.blockQuartzPillar.stack( 1 ) );
|
||||
|
||||
try
|
||||
{
|
||||
initBuilderSupport();
|
||||
}
|
||||
catch (Throwable builderSupport)
|
||||
{
|
||||
// not supported?
|
||||
}
|
||||
|
||||
Block skyStone = b.blockSkyStone.block();
|
||||
if ( skyStone != null )
|
||||
{
|
||||
addFacade( new ItemStack( skyStone, 1, 0 ) );
|
||||
addFacade( new ItemStack( skyStone, 1, 1 ) );
|
||||
addFacade( new ItemStack( skyStone, 1, 2 ) );
|
||||
addFacade( new ItemStack( skyStone, 1, 3 ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void initBuilderSupport()
|
||||
{
|
||||
SchematicRegistry.declareBlueprintSupport( AppEng.modid );
|
||||
|
||||
Blocks blks = AEApi.instance().blocks();
|
||||
Block cable = blks.blockMultiPart.block();
|
||||
for (Field f : blks.getClass().getFields())
|
||||
{
|
||||
AEItemDefinition def;
|
||||
try
|
||||
{
|
||||
def = (AEItemDefinition) f.get( blks );
|
||||
if ( def != null )
|
||||
{
|
||||
Block myBlock = def.block();
|
||||
if ( myBlock instanceof IOrientableBlock && ((IOrientableBlock) myBlock).usesMetadata() && def.entity() == null )
|
||||
{
|
||||
SchematicRegistry.registerSchematicBlock( myBlock, AERotatableBlockSchematic.class );
|
||||
}
|
||||
else if ( myBlock == cable )
|
||||
{
|
||||
SchematicRegistry.registerSchematicBlock( myBlock, AECableSchematicTile.class );
|
||||
}
|
||||
else if ( def.entity() != null )
|
||||
{
|
||||
SchematicRegistry.registerSchematicBlock( myBlock, AEGenericSchematicTile.class );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
registerPowerP2P();
|
||||
registerItemP2P();
|
||||
registerLiquidsP2P();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadePart createFacadePart(Block blk, int meta, ForgeDirection side)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemStack fs = ItemFacade.getFacade( blk, meta );
|
||||
return new FacadePart( fs, side );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ItemStack fs = ItemFacade.getStack( blk, meta );
|
||||
return new FacadePart( fs, side );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadePart createFacadePart(ItemStack fs, ForgeDirection side)
|
||||
{
|
||||
return new FacadePart( fs, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getTextureForFacade(ItemStack facade)
|
||||
{
|
||||
try
|
||||
{
|
||||
Block blk[] = ItemFacade.getBlocks( facade );
|
||||
int meta[] = ItemFacade.getMetaValues( facade );
|
||||
if ( blk == null || blk.length < 1 )
|
||||
return null;
|
||||
|
||||
if ( blk[0] != null )
|
||||
return new ItemStack( blk[0], 1, meta[0] );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Block blk = ItemFacade.getBlock( facade );
|
||||
if ( blk != null )
|
||||
return new ItemStack( blk, 1, ItemFacade.getMetaData( facade ) );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getFacadeTexture()
|
||||
{
|
||||
try
|
||||
{
|
||||
return BuildCraftTransport.instance.pipeIconProvider.getIcon( PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal() ); // Structure
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
}
|
||||
return null;
|
||||
// Pipe
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package appeng.integration.modules.BCHelpers;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.parts.IFacadeContainer;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.LayerFlags;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
|
||||
public class AECableSchematicTile extends AEGenericSchematicTile implements IPartHost
|
||||
{
|
||||
|
||||
@Override
|
||||
public void rotateLeft(IBuilderContext context)
|
||||
{
|
||||
CableBusContainer cbc = new CableBusContainer( this );
|
||||
cbc.readFromNBT( tileNBT );
|
||||
|
||||
cbc.rotateLeft();
|
||||
|
||||
tileNBT = new NBTTagCompound();
|
||||
cbc.writeToNBT( tileNBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFacadeContainer getFacadeContainer()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddPart(ItemStack part, ForgeDirection side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection addPart(ItemStack is, ForgeDirection side, EntityPlayer owner)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPart getPart(ForgeDirection side)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePart(ForgeDirection side, boolean suppressUpdate)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTile()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColor getColor()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearContainer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocked(ForgeDirection side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SelectedPart selectPart(Vec3 pos)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForSave()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRedstone(ForgeDirection side)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<LayerFlags> getLayerFlags()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package appeng.integration.modules.BCHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.blueprints.SchematicTile;
|
||||
|
||||
public class AEGenericSchematicTile extends SchematicTile
|
||||
{
|
||||
|
||||
@Override
|
||||
public void writeRequirementsToBlueprint(IBuilderContext context, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = context.world().getTileEntity( x, y, z );
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
if ( tile instanceof AEBaseTile )
|
||||
{
|
||||
AEBaseTile tcb = (AEBaseTile) tile;
|
||||
tcb.getDrops( tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, list );
|
||||
}
|
||||
|
||||
storedRequirements = list.toArray( new ItemStack[list.size()] );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateLeft(IBuilderContext context)
|
||||
{
|
||||
if ( tileNBT.hasKey( "orientation_forward" ) && tileNBT.hasKey( "orientation_up" ) )
|
||||
{
|
||||
String forward = tileNBT.getString( "orientation_forward" );
|
||||
String up = tileNBT.getString( "orientation_up" );
|
||||
|
||||
if ( forward != null && up != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
ForgeDirection fdForward = ForgeDirection.valueOf( forward );
|
||||
ForgeDirection fdUp = ForgeDirection.valueOf( up );
|
||||
|
||||
fdForward = Platform.rotateAround( fdForward, ForgeDirection.DOWN );
|
||||
fdUp = Platform.rotateAround( fdUp, ForgeDirection.DOWN );
|
||||
|
||||
tileNBT.setString( "orientation_forward", fdForward.name() );
|
||||
tileNBT.setString( "orientation_up", fdUp.name() );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package appeng.integration.modules.BCHelpers;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.util.Platform;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.blueprints.SchematicBlock;
|
||||
|
||||
public class AERotatableBlockSchematic extends SchematicBlock
|
||||
{
|
||||
|
||||
@Override
|
||||
public void rotateLeft(IBuilderContext context)
|
||||
{
|
||||
if ( meta < 6 )
|
||||
{
|
||||
ForgeDirection d = Platform.rotateAround( ForgeDirection.values()[meta], ForgeDirection.DOWN );
|
||||
meta = d.ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package appeng.integration.modules.BCHelpers;
|
||||
|
||||
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.integration.modules.BC;
|
||||
|
||||
public class BCPipeHandler implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
|
||||
{
|
||||
return chan == StorageChannel.ITEMS && BC.instance.isPipe( te, d );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
return new BCPipeInventory( te, d );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package appeng.integration.modules.BCHelpers;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.integration.modules.BC;
|
||||
|
||||
public class BCPipeInventory implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
|
||||
TileEntity te;
|
||||
ForgeDirection dir;
|
||||
|
||||
public BCPipeInventory(TileEntity _te, ForgeDirection _dir) {
|
||||
te = _te;
|
||||
dir = _dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
if ( BC.instance.canAddItemsToPipe( te, input.getItemStack(), dir ) )
|
||||
return null;
|
||||
return input;
|
||||
}
|
||||
|
||||
if ( BC.instance.addItemsToPipe( te, input.getItemStack(), dir ) )
|
||||
return null;
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IBetterStorage;
|
||||
import appeng.integration.modules.helpers.BSCrateHandler;
|
||||
import appeng.integration.modules.helpers.BSCrateStorageAdaptor;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
|
||||
public class BetterStorage implements IIntegrationModule, IBetterStorage
|
||||
{
|
||||
|
||||
public static BetterStorage instance;
|
||||
|
||||
@Override
|
||||
public boolean isStorageCrate(Object te)
|
||||
{
|
||||
return te instanceof ICrateStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryAdaptor getAdaptor(Object te, ForgeDirection d)
|
||||
{
|
||||
if ( te instanceof ICrateStorage )
|
||||
{
|
||||
return new BSCrateStorageAdaptor( te, d );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new BSCrateHandler() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.ICLApi;
|
||||
|
||||
public class CLApi extends BaseModule implements ICLApi
|
||||
{
|
||||
|
||||
public static CLApi instance;
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
TestClass( coloredlightscore.src.api.CLApi.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorLight(AEColor color, int light)
|
||||
{
|
||||
int mv = color.mediumVariant;
|
||||
|
||||
float r = (mv >> 16) & 0xff;
|
||||
float g = (mv >> 8) & 0xff;
|
||||
float b = (mv >> 0) & 0xff;
|
||||
|
||||
return coloredlightscore.src.api.CLApi.makeRGBLightValue( r / 255.0f, g / 255.0f, b / 255.0f, light / 15.0f );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import uristqwerty.CraftGuide.CraftGuideLog;
|
||||
import uristqwerty.CraftGuide.DefaultRecipeTemplate;
|
||||
import uristqwerty.CraftGuide.RecipeGeneratorImplementation;
|
||||
import uristqwerty.CraftGuide.api.CraftGuideAPIObject;
|
||||
import uristqwerty.CraftGuide.api.CraftGuideRecipe;
|
||||
import uristqwerty.CraftGuide.api.ItemSlot;
|
||||
import uristqwerty.CraftGuide.api.RecipeGenerator;
|
||||
import uristqwerty.CraftGuide.api.RecipeProvider;
|
||||
import uristqwerty.CraftGuide.api.RecipeTemplate;
|
||||
import uristqwerty.CraftGuide.api.Slot;
|
||||
import uristqwerty.CraftGuide.api.SlotType;
|
||||
import uristqwerty.CraftGuide.api.StackInfo;
|
||||
import uristqwerty.CraftGuide.api.StackInfoSource;
|
||||
import uristqwerty.gui_craftguide.texture.DynamicTexture;
|
||||
import uristqwerty.gui_craftguide.texture.TextureClip;
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RegistrationError;
|
||||
import appeng.api.recipes.IIngredient;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.recipes.game.ShapedRecipe;
|
||||
import appeng.recipes.game.ShapelessRecipe;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModule, RecipeProvider, StackInfoSource, RecipeGenerator
|
||||
{
|
||||
|
||||
public static CraftGuide instance;
|
||||
|
||||
private final Slot[] shapelessCraftingSlots = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ), new ItemSlot( 21, 3, 16, 16 ), new ItemSlot( 39, 3, 16, 16 ),
|
||||
new ItemSlot( 3, 21, 16, 16 ), new ItemSlot( 21, 21, 16, 16 ), new ItemSlot( 39, 21, 16, 16 ), new ItemSlot( 3, 39, 16, 16 ),
|
||||
new ItemSlot( 21, 39, 16, 16 ), new ItemSlot( 39, 39, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
|
||||
|
||||
private final Slot[] craftingSlotsOwnBackground = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ).drawOwnBackground(),
|
||||
new ItemSlot( 21, 3, 16, 16 ).drawOwnBackground(), new ItemSlot( 39, 3, 16, 16 ).drawOwnBackground(),
|
||||
new ItemSlot( 3, 21, 16, 16 ).drawOwnBackground(), new ItemSlot( 21, 21, 16, 16 ).drawOwnBackground(),
|
||||
new ItemSlot( 39, 21, 16, 16 ).drawOwnBackground(), new ItemSlot( 3, 39, 16, 16 ).drawOwnBackground(),
|
||||
new ItemSlot( 21, 39, 16, 16 ).drawOwnBackground(), new ItemSlot( 39, 39, 16, 16 ).drawOwnBackground(),
|
||||
new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ).drawOwnBackground(), };
|
||||
|
||||
private final Slot[] smallCraftingSlotsOwnBackground = new ItemSlot[] { new ItemSlot( 12, 12, 16, 16 ).drawOwnBackground(),
|
||||
new ItemSlot( 30, 12, 16, 16 ).drawOwnBackground(), new ItemSlot( 12, 30, 16, 16 ).drawOwnBackground(),
|
||||
new ItemSlot( 30, 30, 16, 16 ).drawOwnBackground(), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ).drawOwnBackground(), };
|
||||
|
||||
private final Slot[] craftingSlots = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ), new ItemSlot( 21, 3, 16, 16 ), new ItemSlot( 39, 3, 16, 16 ),
|
||||
new ItemSlot( 3, 21, 16, 16 ), new ItemSlot( 21, 21, 16, 16 ), new ItemSlot( 39, 21, 16, 16 ), new ItemSlot( 3, 39, 16, 16 ),
|
||||
new ItemSlot( 21, 39, 16, 16 ), new ItemSlot( 39, 39, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
|
||||
|
||||
private final Slot[] smallCraftingSlots = new ItemSlot[] { new ItemSlot( 12, 12, 16, 16 ), new ItemSlot( 30, 12, 16, 16 ), new ItemSlot( 12, 30, 16, 16 ),
|
||||
new ItemSlot( 30, 30, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
|
||||
|
||||
private final Slot[] furnaceSlots = new ItemSlot[] { new ItemSlot( 13, 21, 16, 16 ),
|
||||
new ItemSlot( 50, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), };
|
||||
|
||||
@Override
|
||||
public String getInfo(ItemStack itemStack)
|
||||
{
|
||||
// :P
|
||||
return null;
|
||||
}
|
||||
|
||||
RecipeGenerator parent;
|
||||
|
||||
@Override
|
||||
public void generateRecipes(RecipeGenerator generator)
|
||||
{
|
||||
parent = generator;
|
||||
|
||||
RecipeTemplate craftingTemplate;
|
||||
RecipeTemplate smallCraftingTemplate;
|
||||
|
||||
if ( uristqwerty.CraftGuide.CraftGuide.newerBackgroundStyle )
|
||||
{
|
||||
craftingTemplate = generator.createRecipeTemplate( craftingSlotsOwnBackground, null );
|
||||
smallCraftingTemplate = generator.createRecipeTemplate( smallCraftingSlotsOwnBackground, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
craftingTemplate = new DefaultRecipeTemplate( craftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip(
|
||||
DynamicTexture.instance( "recipe_backgrounds" ), 1, 1, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 1,
|
||||
79, 58 ) );
|
||||
|
||||
smallCraftingTemplate = new DefaultRecipeTemplate( smallCraftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip(
|
||||
DynamicTexture.instance( "recipe_backgrounds" ), 1, 61, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 61,
|
||||
79, 58 ) );
|
||||
}
|
||||
|
||||
RecipeTemplate shapelessTemplate = new DefaultRecipeTemplate( shapelessCraftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip(
|
||||
DynamicTexture.instance( "recipe_backgrounds" ), 1, 121, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 121,
|
||||
79, 58 ) );
|
||||
|
||||
RecipeTemplate furnaceTemplate = new DefaultRecipeTemplate( furnaceSlots, new ItemStack( Blocks.furnace ), new TextureClip(
|
||||
DynamicTexture.instance( "recipe_backgrounds" ), 1, 181, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 181,
|
||||
79, 58 ) );
|
||||
|
||||
addCraftingRecipes( craftingTemplate, smallCraftingTemplate, shapelessTemplate, this );
|
||||
addGrinderRecipes( furnaceTemplate, this );
|
||||
addInscriberRecipes( furnaceTemplate, this );
|
||||
}
|
||||
|
||||
private void addCraftingRecipes(RecipeTemplate template, RecipeTemplate templateSmall, RecipeTemplate templateShapeless, RecipeGenerator generator)
|
||||
{
|
||||
List recipes = CraftingManager.getInstance().getRecipeList();
|
||||
|
||||
int errCount = 0;
|
||||
|
||||
for (Object o : recipes)
|
||||
{
|
||||
try
|
||||
{
|
||||
IRecipe recipe = (IRecipe) o;
|
||||
|
||||
Object[] items = generator.getCraftingRecipe( recipe, true );
|
||||
|
||||
if ( items == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if ( items.length == 5 )
|
||||
{
|
||||
generator.addRecipe( templateSmall, items );
|
||||
}
|
||||
else if ( recipe instanceof ShapelessRecipe )
|
||||
{
|
||||
generator.addRecipe( templateShapeless, items );
|
||||
}
|
||||
else
|
||||
{
|
||||
generator.addRecipe( template, items );
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if ( errCount == -1 )
|
||||
{
|
||||
}
|
||||
else if ( errCount++ >= 5 )
|
||||
{
|
||||
CraftGuideLog
|
||||
.log( "CraftGuide DefaultRecipeProvider: Stack trace limit reached, further stack traces from this invocation will not be logged to the console. They will still be logged to (.minecraft)/config/CraftGuide/CraftGuide.log",
|
||||
true );
|
||||
errCount = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
CraftGuideLog.log( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addGrinderRecipes(RecipeTemplate template, RecipeGenerator generator)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void addInscriberRecipes(RecipeTemplate template, RecipeGenerator generator)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType)
|
||||
{
|
||||
return parent.createRecipeTemplate( slots, craftingType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType, String backgroundTexture, int backgroundX, int backgroundY,
|
||||
int backgroundSelectedX, int backgroundSelectedY)
|
||||
{
|
||||
return parent.createRecipeTemplate( slots, craftingType, backgroundTexture, backgroundX, backgroundY, backgroundSelectedX, backgroundSelectedY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType, String backgroundTexture, int backgroundX, int backgroundY,
|
||||
String backgroundSelectedTexture, int backgroundSelectedX, int backgroundSelectedY)
|
||||
{
|
||||
return parent.createRecipeTemplate( slots, craftingType, backgroundTexture, backgroundX, backgroundY, backgroundSelectedTexture, backgroundSelectedX,
|
||||
backgroundSelectedY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(RecipeTemplate template, Object[] crafting)
|
||||
{
|
||||
parent.addRecipe( template, crafting );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(CraftGuideRecipe recipe, ItemStack craftingType)
|
||||
{
|
||||
parent.addRecipe( recipe, craftingType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultTypeVisibility(ItemStack type, boolean visible)
|
||||
{
|
||||
parent.setDefaultTypeVisibility( type, visible );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getCraftingRecipe(IRecipe recipe)
|
||||
{
|
||||
return getCraftingRecipe( recipe, true );
|
||||
}
|
||||
|
||||
Object[] getCraftingShapelessRecipe(List items, ItemStack recipeOutput)
|
||||
{
|
||||
Object[] output = new Object[10];
|
||||
|
||||
for (int i = 0; i < items.size(); i++)
|
||||
{
|
||||
output[i] = items.get( i );
|
||||
|
||||
if ( output[i] instanceof ItemStack[] )
|
||||
output[i] = Arrays.asList( (ItemStack[]) output[i] );
|
||||
|
||||
if ( output[i] instanceof IIngredient )
|
||||
{
|
||||
try
|
||||
{
|
||||
output[i] = toCG( ((IIngredient) output[i]).getItemStackSet() );
|
||||
}
|
||||
catch (RegistrationError e)
|
||||
{
|
||||
|
||||
}
|
||||
catch (MissingIngredientError e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output[9] = recipeOutput;
|
||||
return output;
|
||||
}
|
||||
|
||||
Object[] getCraftingShapedRecipe(int width, int height, Object[] items, ItemStack recipeOutput)
|
||||
{
|
||||
Object[] output = new Object[10];
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
int i = y * 3 + x;
|
||||
output[i] = items[y * width + x];
|
||||
|
||||
if ( output[i] instanceof ItemStack[] )
|
||||
output[i] = Arrays.asList( (ItemStack[]) output[i] );
|
||||
|
||||
if ( output[i] instanceof IIngredient )
|
||||
{
|
||||
try
|
||||
{
|
||||
output[i] = toCG( ((IIngredient) output[i]).getItemStackSet() );
|
||||
}
|
||||
catch (RegistrationError e)
|
||||
{
|
||||
|
||||
}
|
||||
catch (MissingIngredientError e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output[9] = recipeOutput;
|
||||
return output;
|
||||
}
|
||||
|
||||
Object[] getSmallShapedRecipe(int width, int height, Object[] items, ItemStack recipeOutput)
|
||||
{
|
||||
Object[] output = new Object[5];
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
int i = y * 2 + x;
|
||||
output[i] = items[y * width + x];
|
||||
|
||||
if ( output[i] instanceof ItemStack[] )
|
||||
output[i] = Arrays.asList( (ItemStack[]) output[i] );
|
||||
|
||||
if ( output[i] instanceof IIngredient )
|
||||
{
|
||||
try
|
||||
{
|
||||
output[i] = toCG( ((IIngredient) output[i]).getItemStackSet() );
|
||||
}
|
||||
catch (RegistrationError e)
|
||||
{
|
||||
|
||||
}
|
||||
catch (MissingIngredientError e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output[4] = recipeOutput;
|
||||
return output;
|
||||
}
|
||||
|
||||
private Object toCG(ItemStack[] itemStackSet)
|
||||
{
|
||||
List<ItemStack> list = Arrays.asList( itemStackSet );
|
||||
|
||||
for (int x = 0; x < list.size(); x++)
|
||||
{
|
||||
list.set( x, list.get( x ).copy() );
|
||||
if ( list.get( x ).stackSize == 0 )
|
||||
list.get( x ).stackSize = 1;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getCraftingRecipe(IRecipe recipe, boolean allowSmallGrid)
|
||||
{
|
||||
if ( recipe instanceof ShapelessRecipe )
|
||||
{
|
||||
List items = (List) ReflectionHelper.getPrivateValue( ShapelessRecipe.class, (ShapelessRecipe) recipe, "input" );
|
||||
return getCraftingShapelessRecipe( items, ((ShapelessRecipe) recipe).getRecipeOutput() );
|
||||
}
|
||||
else if ( recipe instanceof ShapedRecipe )
|
||||
{
|
||||
int width = (Integer) ReflectionHelper.getPrivateValue( ShapedRecipe.class, (ShapedRecipe) recipe, "width" );
|
||||
int height = (Integer) ReflectionHelper.getPrivateValue( ShapedRecipe.class, (ShapedRecipe) recipe, "height" );
|
||||
Object[] items = (Object[]) ReflectionHelper.getPrivateValue( ShapedRecipe.class, (ShapedRecipe) recipe, "input" );
|
||||
|
||||
if ( allowSmallGrid && width < 3 && height < 3 )
|
||||
{
|
||||
return getSmallShapedRecipe( width, height, items, ((ShapedRecipe) recipe).getRecipeOutput() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return getCraftingShapedRecipe( width, height, items, ((ShapedRecipe) recipe).getRecipeOutput() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
StackInfo.addSource( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.IDSU;
|
||||
import appeng.integration.modules.helpers.MFRDSU;
|
||||
import appeng.integration.modules.helpers.MFRDSUHandler;
|
||||
|
||||
public class DSU extends BaseModule implements IDSU
|
||||
{
|
||||
|
||||
public static DSU instance;
|
||||
|
||||
@Override
|
||||
public IMEInventory getDSU(TileEntity te)
|
||||
{
|
||||
return new MFRDSU( te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDSU(TileEntity te)
|
||||
{
|
||||
if ( te instanceof IDeepStorageUnit )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
TestClass( IDeepStorageUnit.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new MFRDSUHandler() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.Blocks;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.core.AELog;
|
||||
import appeng.fmp.CableBusPart;
|
||||
import appeng.fmp.FMPEvent;
|
||||
import appeng.fmp.FMPPlacementHelper;
|
||||
import appeng.fmp.PartRegistry;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IFMP;
|
||||
import appeng.integration.modules.helpers.FMPPacketEvent;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.microblock.BlockMicroMaterial;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartConverter;
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||
import codechicken.multipart.MultipartGenerator;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IFMP
|
||||
{
|
||||
|
||||
public static FMP instance;
|
||||
|
||||
@Override
|
||||
public TMultiPart createPart(String name, boolean client)
|
||||
{
|
||||
for (PartRegistry pr : PartRegistry.values())
|
||||
{
|
||||
if ( pr.getName() == name )
|
||||
return pr.construct( 0 );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart convert(World world, BlockCoord pos)
|
||||
{
|
||||
Block blk = world.getBlock( pos.x, pos.y, pos.z );
|
||||
int meta = world.getBlockMetadata( pos.x, pos.y, pos.z );
|
||||
|
||||
TMultiPart part = PartRegistry.getPartByBlock( blk, meta );
|
||||
if ( part instanceof CableBusPart )
|
||||
{
|
||||
CableBusPart cbp = (CableBusPart) part;
|
||||
cbp.convertFromTile( world.getTileEntity( pos.x, pos.y, pos.z ) );
|
||||
}
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
createAndRegister( AEApi.instance().blocks().blockQuartz.block(), 0 );
|
||||
createAndRegister( AEApi.instance().blocks().blockQuartzPillar.block(), 0 );
|
||||
createAndRegister( AEApi.instance().blocks().blockQuartzChiseled.block(), 0 );
|
||||
createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 0 );
|
||||
createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 1 );
|
||||
createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 2 );
|
||||
createAndRegister( AEApi.instance().blocks().blockSkyStone.block(), 3 );
|
||||
|
||||
PartRegistry reg[] = PartRegistry.values();
|
||||
|
||||
String data[] = new String[reg.length];
|
||||
for (int x = 0; x < data.length; x++)
|
||||
data[x] = reg[x].getName();
|
||||
|
||||
MultiPartRegistry.registerConverter( this );
|
||||
MultiPartRegistry.registerParts( this, data );
|
||||
|
||||
MultipartGenerator.registerPassThroughInterface( "appeng.helpers.AEMultiTile" );
|
||||
}
|
||||
|
||||
private void createAndRegister(Block block, int i)
|
||||
{
|
||||
if ( block != null )
|
||||
BlockMicroMaterial.createAndRegister( block, i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( new FMPEvent() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartHost getOrCreateHost(TileEntity tile)
|
||||
{
|
||||
try
|
||||
{
|
||||
BlockCoord loc = new BlockCoord( tile.xCoord, tile.yCoord, tile.zCoord );
|
||||
|
||||
TileMultipart mp = TileMultipart.getOrConvertTile( tile.getWorldObj(), loc );
|
||||
if ( mp != null )
|
||||
{
|
||||
scala.collection.Iterator<TMultiPart> i = mp.partList().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
TMultiPart p = i.next();
|
||||
if ( p instanceof CableBusPart )
|
||||
return (IPartHost) p;
|
||||
}
|
||||
|
||||
return new FMPPlacementHelper( mp );
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableBusContainer getCableContainer(TileEntity te)
|
||||
{
|
||||
if ( te instanceof TileMultipart )
|
||||
{
|
||||
TileMultipart mp = (TileMultipart) te;
|
||||
scala.collection.Iterator<TMultiPart> i = mp.partList().iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
TMultiPart p = i.next();
|
||||
if ( p instanceof CableBusPart )
|
||||
return ((CableBusPart) p).cb;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPassThrough(Class<?> layerInterface)
|
||||
{
|
||||
try
|
||||
{
|
||||
MultipartGenerator.registerPassThroughInterface( layerInterface.getName() );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.severe( "Failed to register " + layerInterface.getName() + " with FMP, some features may not work with MultiParts." );
|
||||
AELog.error( t );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Event newFMPPacketEvent(EntityPlayerMP sender)
|
||||
{
|
||||
return new FMPPacketEvent( sender );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Block> blockTypes()
|
||||
{
|
||||
Blocks def = AEApi.instance().blocks();
|
||||
return Arrays.asList( def.blockMultiPart.block(), def.blockQuartzTorch.block() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IFZ;
|
||||
import appeng.integration.modules.helpers.FactorizationBarrel;
|
||||
import appeng.integration.modules.helpers.FactorizationHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
/**
|
||||
* 100% Hacks.
|
||||
*/
|
||||
public class FZ implements IFZ, IIntegrationModule
|
||||
{
|
||||
|
||||
public static FZ instance;
|
||||
|
||||
private static Class day_BarrelClass;
|
||||
private static Method day_getItemCount;
|
||||
private static Method day_setItemCount;
|
||||
private static Method day_getMaxSize;
|
||||
private static Field day_item;
|
||||
|
||||
@Override
|
||||
public ItemStack barrelGetItem(TileEntity te)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemStack i = null;
|
||||
|
||||
if ( day_BarrelClass.isInstance( te ) )
|
||||
i = (ItemStack) day_item.get( te );
|
||||
|
||||
if ( i != null )
|
||||
i = Platform.cloneItemStack( i );
|
||||
|
||||
return i;
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int barrelGetMaxItemCount(TileEntity te)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( day_BarrelClass.isInstance( te ) )
|
||||
return (Integer) day_getMaxSize.invoke( te );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int barrelGetItemCount(TileEntity te)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( day_BarrelClass.isInstance( te ) )
|
||||
return (Integer) day_getItemCount.invoke( te );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemType(TileEntity te, ItemStack input)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( day_BarrelClass.isInstance( te ) )
|
||||
day_item.set( te, input == null ? null : input.copy() );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void barrelSetCount(TileEntity te, int max)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( day_BarrelClass.isInstance( te ) )
|
||||
day_setItemCount.invoke( te, max );
|
||||
|
||||
te.markDirty();
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getFactorizationBarrel(TileEntity te)
|
||||
{
|
||||
return new FactorizationBarrel( this, te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBarrel(TileEntity te)
|
||||
{
|
||||
if ( day_BarrelClass.isAssignableFrom( te.getClass() ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
day_BarrelClass = Class.forName( "factorization.weird.TileEntityDayBarrel" );
|
||||
|
||||
day_getItemCount = day_BarrelClass.getDeclaredMethod( "getItemCount", new Class[] {} );
|
||||
day_setItemCount = day_BarrelClass.getDeclaredMethod( "setItemCount", new Class[] { int.class } );
|
||||
day_getMaxSize = day_BarrelClass.getDeclaredMethod( "getMaxSize", new Class[] {} );
|
||||
day_item = day_BarrelClass.getDeclaredField( "item" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new FactorizationHandler() );
|
||||
}
|
||||
|
||||
public void grinderRecipe(ItemStack in, ItemStack out)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class c = Class.forName( "factorization.oreprocessing.TileEntityGrinder" );
|
||||
Method m = c.getMethod( "addRecipe", Object.class, ItemStack.class, float.class );
|
||||
|
||||
float amt = out.stackSize;
|
||||
out.stackSize = 1;
|
||||
|
||||
m.invoke( c, in, out, amt );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// AELog.info( "" );
|
||||
// throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import ic2.api.recipe.RecipeInputItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IIC2;
|
||||
|
||||
public class IC2 extends BaseModule implements IIntegrationModule, IIC2
|
||||
{
|
||||
|
||||
public static IC2 instance;
|
||||
|
||||
public IC2() {
|
||||
TestClass( IEnergyTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
IP2PTunnelRegistry reg = AEApi.instance().registries().p2pTunnel();
|
||||
reg.addNewAttunement( getItem( "copperCableItem" ), TunnelType.IC2_POWER );
|
||||
reg.addNewAttunement( getItem( "insulatedCopperCableItem" ), TunnelType.IC2_POWER );
|
||||
reg.addNewAttunement( getItem( "goldCableItem" ), TunnelType.IC2_POWER );
|
||||
reg.addNewAttunement( getItem( "insulatedGoldCableItem" ), TunnelType.IC2_POWER );
|
||||
reg.addNewAttunement( getItem( "ironCableItem" ), TunnelType.IC2_POWER );
|
||||
reg.addNewAttunement( getItem( "insulatedIronCableItem" ), TunnelType.IC2_POWER );
|
||||
reg.addNewAttunement( getItem( "insulatedTinCableItem" ), TunnelType.IC2_POWER );
|
||||
reg.addNewAttunement( getItem( "glassFiberCableItem" ), TunnelType.IC2_POWER );
|
||||
reg.addNewAttunement( getItem( "tinCableItem" ), TunnelType.IC2_POWER );
|
||||
reg.addNewAttunement( getItem( "detectorCableItem" ), TunnelType.IC2_POWER );
|
||||
reg.addNewAttunement( getItem( "splitterCableItem" ), TunnelType.IC2_POWER );
|
||||
|
||||
// this is gone?
|
||||
// AEApi.instance().registries().matterCannon().registerAmmo( getItem( "uraniumDrop" ), 238.0289 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maceratorRecipe(ItemStack in, ItemStack out)
|
||||
{
|
||||
ic2.api.recipe.Recipes.macerator.addRecipe( new RecipeInputItemStack( in, in.stackSize ), null, out );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToEnergyNet(TileEntity appEngTile)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileLoadEvent( (IEnergyTile) appEngTile ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFromEnergyNet(TileEntity appEngTile)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileUnloadEvent( (IEnergyTile) appEngTile ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(String name)
|
||||
{
|
||||
return ic2.api.item.IC2Items.getItem( name );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import mods.immibis.core.api.multipart.ICoverSystem;
|
||||
import mods.immibis.core.api.multipart.IMultipartTile;
|
||||
import mods.immibis.core.api.multipart.IPartContainer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.core.AELog;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.IImmibisMicroblocks;
|
||||
|
||||
public class ImmibisMicroblocks extends BaseModule implements IImmibisMicroblocks
|
||||
{
|
||||
|
||||
public static ImmibisMicroblocks instance;
|
||||
|
||||
boolean canConvertTiles = false;
|
||||
|
||||
private Class MicroblockAPIUtils;
|
||||
private Method mergeIntoMicroblockContainer;
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
TestClass( IMultipartTile.class );
|
||||
TestClass( ICoverSystem.class );
|
||||
TestClass( IPartContainer.class );
|
||||
|
||||
try
|
||||
{
|
||||
MicroblockAPIUtils = Class.forName( "mods.immibis.microblocks.api.MicroblockAPIUtils" );
|
||||
mergeIntoMicroblockContainer = MicroblockAPIUtils.getMethod( "mergeIntoMicroblockContainer", ItemStack.class, EntityPlayer.class, World.class,
|
||||
int.class, int.class, int.class, int.class, Block.class, int.class );
|
||||
canConvertTiles = true;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean leaveParts(TileEntity te)
|
||||
{
|
||||
if ( te instanceof IMultipartTile )
|
||||
{
|
||||
ICoverSystem ci = ((IMultipartTile) te).getCoverSystem();
|
||||
if ( ci != null )
|
||||
ci.convertToContainerBlock();
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartHost getOrCreateHost(EntityPlayer player, int side, TileEntity te)
|
||||
{
|
||||
if ( te instanceof IMultipartTile && canConvertTiles )
|
||||
{
|
||||
Block blk = AEApi.instance().blocks().blockMultiPart.block();
|
||||
ItemStack what = AEApi.instance().blocks().blockMultiPart.stack( 1 );
|
||||
|
||||
World w = te.getWorldObj();
|
||||
int x = te.xCoord;
|
||||
int y = te.yCoord;
|
||||
int z = te.zCoord;
|
||||
|
||||
try
|
||||
{
|
||||
// ItemStack.class, EntityPlayer.class, World.class,
|
||||
// int.class, int.class, int.class, int.class, Block.class, int.class );
|
||||
mergeIntoMicroblockContainer.invoke( null, what, player, w, x, y, z, side, blk, 0 );
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
canConvertTiles = false;
|
||||
return null; // nevermind..
|
||||
}
|
||||
|
||||
TileEntity tx = w.getTileEntity( x, y, z );
|
||||
if ( tx instanceof IPartHost )
|
||||
return (IPartHost) tx;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import invtweaks.api.InvTweaksAPI;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.IInvTweaks;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class InvTweaks extends BaseModule implements IInvTweaks
|
||||
{
|
||||
|
||||
public static InvTweaks instance;
|
||||
|
||||
static InvTweaksAPI api;
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
api = (InvTweaksAPI) Loader.instance().getIndexedModList().get( "inventorytweaks" ).getMod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
if ( api == null )
|
||||
throw new RuntimeException( "InvTweaks API Instance Failed." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareItems(ItemStack i, ItemStack j)
|
||||
{
|
||||
return api.compareItems( i, j );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection;
|
||||
import appeng.integration.BaseModule;
|
||||
|
||||
public class MFR extends BaseModule
|
||||
{
|
||||
|
||||
public static MFR instance;
|
||||
|
||||
public MFR() {
|
||||
TestClass( IRedNetConnection.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.IMJ5;
|
||||
import appeng.integration.modules.helpers.MJPerdition;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
|
||||
public class MJ5 extends BaseModule implements IMJ5
|
||||
{
|
||||
|
||||
public static MJ5 instance;
|
||||
|
||||
public MJ5() {
|
||||
TestClass( IPowerReceptor.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createPerdition(Object buildCraft)
|
||||
{
|
||||
if ( buildCraft instanceof IPowerReceptor )
|
||||
return new MJPerdition( (IPowerReceptor) buildCraft );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.IMJ6;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import buildcraft.api.mj.IBatteryObject;
|
||||
import buildcraft.api.mj.IBatteryProvider;
|
||||
import buildcraft.api.mj.ISidedBatteryProvider;
|
||||
import buildcraft.api.mj.MjAPI;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
|
||||
public class MJ6 extends BaseModule implements IMJ6
|
||||
{
|
||||
|
||||
public static MJ6 instance;
|
||||
|
||||
public MJ6() {
|
||||
TestClass( IBatteryObject.class );
|
||||
TestClass( IBatteryProvider.class );
|
||||
TestClass( ISidedBatteryProvider.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(iname = "MJ5")
|
||||
public IBatteryObject provider(final TileEntity te, final ForgeDirection side)
|
||||
{
|
||||
if ( te instanceof IPowerReceptor )
|
||||
{
|
||||
final IPowerReceptor recp = (IPowerReceptor) te;
|
||||
final PowerReceiver ph = recp.getPowerReceiver( side );
|
||||
|
||||
if ( ph == null )
|
||||
return null;
|
||||
|
||||
return new IBatteryObject() {
|
||||
|
||||
@Override
|
||||
public void setEnergyStored(double mj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBatteryObject reconfigure(double maxCapacity, double maxReceivedPerCycle, double minimumConsumption)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double minimumConsumption()
|
||||
{
|
||||
return ph.getMinEnergyReceived();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double maxReceivedPerCycle()
|
||||
{
|
||||
return ph.getMaxEnergyReceived();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double maxCapacity()
|
||||
{
|
||||
return ph.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String kind()
|
||||
{
|
||||
return MjAPI.DEFAULT_POWER_FRAMEWORK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergyStored()
|
||||
{
|
||||
return ph.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergyRequested()
|
||||
{
|
||||
return ph.getMaxEnergyStored() - ph.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double addEnergy(double mj, boolean ignoreCycleLimit)
|
||||
{
|
||||
return ph.receiveEnergy( Type.PIPE, mj, side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double addEnergy(double mj)
|
||||
{
|
||||
return ph.receiveEnergy( Type.PIPE, mj, side );
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import mekanism.api.RecipeHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.IMekanism;
|
||||
|
||||
public class Mekanism extends BaseModule implements IMekanism
|
||||
{
|
||||
|
||||
public static Mekanism instance;
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
TestClass( mekanism.api.energy.IStrictEnergyAcceptor.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCrusherRecipe(ItemStack in, ItemStack out)
|
||||
{
|
||||
RecipeHelper.addCrusherRecipe( in, out );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEnrichmentChamberRecipe(ItemStack in, ItemStack out)
|
||||
{
|
||||
RecipeHelper.addEnrichmentChamberRecipe( in, out );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.implementations.GuiCraftingTerm;
|
||||
import appeng.client.gui.implementations.GuiPatternTerm;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.INEI;
|
||||
import appeng.integration.modules.NEIHelpers.NEIAEShapedRecipeHandler;
|
||||
import appeng.integration.modules.NEIHelpers.NEIAEShapelessRecipeHandler;
|
||||
import appeng.integration.modules.NEIHelpers.NEICraftingHandler;
|
||||
import appeng.integration.modules.NEIHelpers.NEIFacadeRecipeHandler;
|
||||
import appeng.integration.modules.NEIHelpers.NEIGrinderRecipeHandler;
|
||||
import appeng.integration.modules.NEIHelpers.NEIInscriberRecipeHandler;
|
||||
import appeng.integration.modules.NEIHelpers.NEIWorldCraftingHandler;
|
||||
import appeng.integration.modules.NEIHelpers.TerminalCraftingSlotFinder;
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
|
||||
public class NEI extends BaseModule implements IIntegrationModule, INEI, IContainerTooltipHandler
|
||||
{
|
||||
|
||||
public static NEI instance;
|
||||
|
||||
Class API;
|
||||
|
||||
// recipe handler...
|
||||
Method registerRecipeHandler;
|
||||
Method registerUsageHandler;
|
||||
|
||||
public NEI() throws ClassNotFoundException {
|
||||
TestClass( GuiContainerManager.class );
|
||||
TestClass( codechicken.nei.recipe.ICraftingHandler.class );
|
||||
TestClass( codechicken.nei.recipe.IUsageHandler.class );
|
||||
API = Class.forName( "codechicken.nei.api.API" );
|
||||
}
|
||||
|
||||
public void registerRecipeHandler(Object o) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
||||
{
|
||||
registerRecipeHandler.invoke( API, o );
|
||||
registerUsageHandler.invoke( API, o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
registerRecipeHandler = API.getDeclaredMethod( "registerRecipeHandler", new Class[] { codechicken.nei.recipe.ICraftingHandler.class } );
|
||||
registerUsageHandler = API.getDeclaredMethod( "registerUsageHandler", new Class[] { codechicken.nei.recipe.IUsageHandler.class } );
|
||||
|
||||
registerRecipeHandler( new NEIAEShapedRecipeHandler() );
|
||||
registerRecipeHandler( new NEIAEShapelessRecipeHandler() );
|
||||
registerRecipeHandler( new NEIInscriberRecipeHandler() );
|
||||
registerRecipeHandler( new NEIWorldCraftingHandler() );
|
||||
registerRecipeHandler( new NEIGrinderRecipeHandler() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) && AEConfig.instance.isFeatureEnabled( AEFeature.enableFacadeCrafting ) )
|
||||
registerRecipeHandler( new NEIFacadeRecipeHandler() );
|
||||
|
||||
// large stack tooltips
|
||||
GuiContainerManager.addTooltipHandler( this );
|
||||
|
||||
// crafting terminal...
|
||||
Method registerGuiOverlay = API.getDeclaredMethod( "registerGuiOverlay", new Class[] { Class.class, String.class, IStackPositioner.class } );
|
||||
Class IOverlayHandler = Class.forName( "codechicken.nei.api.IOverlayHandler" );
|
||||
Class DefaultOverlayHandler = NEICraftingHandler.class;
|
||||
|
||||
Method registerGuiOverlayHandler = API.getDeclaredMethod( "registerGuiOverlayHandler", new Class[] { Class.class, IOverlayHandler, String.class } );
|
||||
registerGuiOverlay.invoke( API, GuiCraftingTerm.class, "crafting", new TerminalCraftingSlotFinder() );
|
||||
registerGuiOverlay.invoke( API, GuiPatternTerm.class, "crafting", new TerminalCraftingSlotFinder() );
|
||||
|
||||
Constructor DefaultOverlayHandlerConstructor = DefaultOverlayHandler.getConstructor( new Class[] { int.class, int.class } );
|
||||
registerGuiOverlayHandler.invoke( API, GuiCraftingTerm.class, DefaultOverlayHandlerConstructor.newInstance( 6, 75 ), "crafting" );
|
||||
registerGuiOverlayHandler.invoke( API, GuiPatternTerm.class, DefaultOverlayHandlerConstructor.newInstance( 6, 75 ), "crafting" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSlot(Slot s)
|
||||
{
|
||||
if ( s == null )
|
||||
return;
|
||||
|
||||
ItemStack stack = s.getStack();
|
||||
|
||||
if ( stack == null )
|
||||
return;
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
FontRenderer fontRenderer = mc.fontRenderer;
|
||||
int x = s.xDisplayPosition;
|
||||
int y = s.yDisplayPosition;
|
||||
|
||||
GuiContainerManager.drawItems.renderItemAndEffectIntoGUI( fontRenderer, mc.getTextureManager(), stack, x, y );
|
||||
GuiContainerManager.drawItems.renderItemOverlayIntoGUI( fontRenderer, mc.getTextureManager(), stack, x, y, "" + stack.stackSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderItem setItemRender(RenderItem aeri2)
|
||||
{
|
||||
try
|
||||
{
|
||||
RenderItem ri = GuiContainerManager.drawItems;
|
||||
GuiContainerManager.drawItems = aeri2;
|
||||
return ri;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( "Invalid version of NEI, please update", t );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemDisplayName(GuiContainer arg0, ItemStack arg1, List<String> current)
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiContainer guiScreen, ItemStack stack, int mousex, int mousey, List<String> currenttip)
|
||||
{
|
||||
if ( guiScreen instanceof AEBaseMEGui )
|
||||
return ((AEBaseMEGui) guiScreen).handleItemTooltip( stack, mousex, mousey, currenttip );
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiContainer arg0, int arg1, int arg2, List<String> current)
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package appeng.integration.modules.NEIHelpers;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RegistrationError;
|
||||
import appeng.api.recipes.IIngredient;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.recipes.game.ShapedRecipe;
|
||||
import appeng.util.Platform;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.DefaultOverlayRenderer;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
|
||||
public void loadTransferRects()
|
||||
{
|
||||
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "crafting", new Object[0] ) );
|
||||
}
|
||||
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return GuiCrafting.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return NEIClientUtils.translate( "recipe.shaped", new Object[0] );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if ( (outputId.equals( "crafting" )) && (getClass() == NEIAEShapedRecipeHandler.class) )
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes)
|
||||
{
|
||||
if ( (irecipe instanceof ShapedRecipe) )
|
||||
{
|
||||
if ( ((ShapedRecipe) irecipe).isEnabled() )
|
||||
{
|
||||
CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
|
||||
recipe.computeVisuals();
|
||||
arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.loadCraftingRecipes( outputId, results );
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes)
|
||||
{
|
||||
if ( (irecipe instanceof ShapedRecipe) )
|
||||
{
|
||||
if ( ((ShapedRecipe) irecipe).isEnabled() && NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) )
|
||||
{
|
||||
CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
|
||||
recipe.computeVisuals();
|
||||
arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes)
|
||||
{
|
||||
if ( (irecipe instanceof ShapedRecipe) )
|
||||
{
|
||||
CachedShapedRecipe recipe = new CachedShapedRecipe( (ShapedRecipe) irecipe );
|
||||
|
||||
if ( ((ShapedRecipe) irecipe).isEnabled() && recipe.contains( recipe.ingredients, ingredient.getItem() ) )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
||||
{
|
||||
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
|
||||
arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "textures/gui/container/crafting_table.png";
|
||||
}
|
||||
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "crafting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
|
||||
{
|
||||
return (super.hasOverlay( gui, container, recipe )) || ((isRecipe2x2( recipe )) && (RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" )));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
|
||||
{
|
||||
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
|
||||
if ( renderer != null )
|
||||
return renderer;
|
||||
|
||||
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
|
||||
if ( positioner == null )
|
||||
return null;
|
||||
|
||||
return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
|
||||
{
|
||||
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
|
||||
if ( handler != null )
|
||||
return handler;
|
||||
|
||||
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
|
||||
}
|
||||
|
||||
public boolean isRecipe2x2(int recipe)
|
||||
{
|
||||
for (PositionedStack stack : getIngredientStacks( recipe ))
|
||||
{
|
||||
if ( (stack.relx > 43) || (stack.rely > 24) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
public PositionedStack result;
|
||||
|
||||
public CachedShapedRecipe(ShapedRecipe irecipe) {
|
||||
result = new PositionedStack( irecipe.getRecipeOutput(), 119, 24 );
|
||||
ingredients = new ArrayList<PositionedStack>();
|
||||
setIngredients( irecipe.getWidth(), irecipe.getHeight(), irecipe.getIngredients() );
|
||||
}
|
||||
|
||||
public void setIngredients(int width, int height, Object[] items)
|
||||
{
|
||||
boolean useSingleItems = AEConfig.instance.disableColoredCableRecipesInNEI();
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
if ( items[(y * width + x)] != null )
|
||||
{
|
||||
IIngredient ing = (IIngredient) items[(y * width + x)];
|
||||
|
||||
try
|
||||
{
|
||||
ItemStack[] is = ing.getItemStackSet();
|
||||
PositionedStack stack = new PositionedStack( useSingleItems ? Platform.findPreferred( is ) : is, 25 + x * 18, 6 + y * 18, false );
|
||||
stack.setMaxSize( 1 );
|
||||
this.ingredients.add( stack );
|
||||
}
|
||||
catch (RegistrationError e)
|
||||
{
|
||||
|
||||
}
|
||||
catch (MissingIngredientError e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
return getCycledIngredients( cycleticks / 20, this.ingredients );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void computeVisuals()
|
||||
{
|
||||
for (PositionedStack p : this.ingredients)
|
||||
{
|
||||
p.generatePermutations();
|
||||
}
|
||||
this.result.generatePermutations();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package appeng.integration.modules.NEIHelpers;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import appeng.api.exceptions.MissingIngredientError;
|
||||
import appeng.api.exceptions.RegistrationError;
|
||||
import appeng.api.recipes.IIngredient;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.recipes.game.ShapelessRecipe;
|
||||
import appeng.util.Platform;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.DefaultOverlayRenderer;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
|
||||
public void loadTransferRects()
|
||||
{
|
||||
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "crafting", new Object[0] ) );
|
||||
}
|
||||
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return GuiCrafting.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return NEIClientUtils.translate( "recipe.shapeless", new Object[0] );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if ( (outputId.equals( "crafting" )) && (getClass() == NEIAEShapelessRecipeHandler.class) )
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes)
|
||||
{
|
||||
if ( (irecipe instanceof ShapelessRecipe) )
|
||||
{
|
||||
if ( ((ShapelessRecipe) irecipe).isEnabled() )
|
||||
{
|
||||
CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
|
||||
recipe.computeVisuals();
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.loadCraftingRecipes( outputId, results );
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes)
|
||||
{
|
||||
if ( (irecipe instanceof ShapelessRecipe) )
|
||||
{
|
||||
if ( ((ShapelessRecipe) irecipe).isEnabled() && NEIServerUtils.areStacksSameTypeCrafting( irecipe.getRecipeOutput(), result ) )
|
||||
{
|
||||
CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
|
||||
recipe.computeVisuals();
|
||||
arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes)
|
||||
{
|
||||
if ( (irecipe instanceof ShapelessRecipe) )
|
||||
{
|
||||
CachedShapelessRecipe recipe = new CachedShapelessRecipe( (ShapelessRecipe) irecipe );
|
||||
|
||||
if ( ((ShapelessRecipe) irecipe).isEnabled() && recipe.contains( recipe.ingredients, ingredient.getItem() ) )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
||||
{
|
||||
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "textures/gui/container/crafting_table.png";
|
||||
}
|
||||
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "crafting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
|
||||
{
|
||||
return (super.hasOverlay( gui, container, recipe )) || ((isRecipe2x2( recipe )) && (RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" )));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
|
||||
{
|
||||
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
|
||||
if ( renderer != null )
|
||||
return renderer;
|
||||
|
||||
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
|
||||
if ( positioner == null )
|
||||
return null;
|
||||
|
||||
return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
|
||||
{
|
||||
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
|
||||
if ( handler != null )
|
||||
return handler;
|
||||
|
||||
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
|
||||
}
|
||||
|
||||
public boolean isRecipe2x2(int recipe)
|
||||
{
|
||||
for (PositionedStack stack : getIngredientStacks( recipe ))
|
||||
{
|
||||
if ( (stack.relx > 43) || (stack.rely > 24) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public class CachedShapelessRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
public PositionedStack result;
|
||||
|
||||
public CachedShapelessRecipe(ShapelessRecipe irecipe) {
|
||||
result = new PositionedStack( irecipe.getRecipeOutput(), 119, 24 );
|
||||
ingredients = new ArrayList<PositionedStack>();
|
||||
setIngredients( irecipe.getInput().toArray() );
|
||||
}
|
||||
|
||||
public void setIngredients(Object[] items)
|
||||
{
|
||||
boolean useSingleItems = AEConfig.instance.disableColoredCableRecipesInNEI();
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
if ( items.length > (y * 3 + x) )
|
||||
{
|
||||
IIngredient ing = (IIngredient) items[(y * 3 + x)];
|
||||
|
||||
try
|
||||
{
|
||||
ItemStack[] is = ing.getItemStackSet();
|
||||
PositionedStack stack = new PositionedStack( useSingleItems ? Platform.findPreferred( is ) : ing.getItemStackSet(), 25 + x * 18,
|
||||
6 + y * 18, false );
|
||||
stack.setMaxSize( 1 );
|
||||
this.ingredients.add( stack );
|
||||
}
|
||||
catch (RegistrationError e)
|
||||
{
|
||||
|
||||
}
|
||||
catch (MissingIngredientError e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
return getCycledIngredients( cycleticks / 20, this.ingredients );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void computeVisuals()
|
||||
{
|
||||
for (PositionedStack p : this.ingredients)
|
||||
p.generatePermutations();
|
||||
|
||||
this.result.generatePermutations();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package appeng.integration.modules.NEIHelpers;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import appeng.client.gui.implementations.GuiCraftingTerm;
|
||||
import appeng.client.gui.implementations.GuiPatternTerm;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketNEIRecipe;
|
||||
import appeng.util.Platform;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
public class NEICraftingHandler implements IOverlayHandler
|
||||
{
|
||||
|
||||
public NEICraftingHandler(int x, int y)
|
||||
{
|
||||
offsetx = x;
|
||||
offsety = y;
|
||||
}
|
||||
|
||||
int offsetx;
|
||||
int offsety;
|
||||
|
||||
@Override
|
||||
public void overlayRecipe(GuiContainer gui, IRecipeHandler recipe, int recipeIndex, boolean shift)
|
||||
{
|
||||
try
|
||||
{
|
||||
List ingredients = recipe.getIngredientStacks( recipeIndex );
|
||||
overlayRecipe( gui, ingredients, shift );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
catch (Error err)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void overlayRecipe(GuiContainer gui, List<PositionedStack> ingredients, boolean shift)
|
||||
{
|
||||
try
|
||||
{
|
||||
NBTTagCompound recipe = new NBTTagCompound();
|
||||
|
||||
if ( gui instanceof GuiCraftingTerm || gui instanceof GuiPatternTerm )
|
||||
{
|
||||
for (int i = 0; i < ingredients.size(); i++)// identify slots
|
||||
{
|
||||
PositionedStack pstack = ingredients.get( i );
|
||||
int col = (pstack.relx - 25) / 18;
|
||||
int row = (pstack.rely - 6) / 18;
|
||||
if ( pstack.items != null && pstack.items.length > 0 )
|
||||
{
|
||||
for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( slot instanceof SlotCraftingMatrix || slot instanceof SlotFakeCraftingMatrix )
|
||||
{
|
||||
Slot ctSlot = (Slot) slot;
|
||||
if ( ctSlot.getSlotIndex() == col + row * 3 )
|
||||
{
|
||||
NBTTagList ilist = new NBTTagList();
|
||||
List<ItemStack> list = new LinkedList();
|
||||
|
||||
// prefer pure crystals.
|
||||
for (int x = 0; x < pstack.items.length; x++)
|
||||
{
|
||||
if ( Platform.isRecipePrioritized( pstack.items[x] ) )
|
||||
list.add( 0, pstack.items[x] );
|
||||
else
|
||||
list.add( pstack.items[x] );
|
||||
}
|
||||
|
||||
for (ItemStack is : list)
|
||||
{
|
||||
NBTTagCompound inbt = new NBTTagCompound();
|
||||
is.writeToNBT( inbt );
|
||||
ilist.appendTag( inbt );
|
||||
}
|
||||
|
||||
recipe.setTag( "#" + ctSlot.getSlotIndex(), ilist );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketNEIRecipe( recipe ) );
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
catch (Error err)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package appeng.integration.modules.NEIHelpers;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.DefaultOverlayRenderer;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class NEIFacadeRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
|
||||
final ItemFacade ifa = (ItemFacade) AEApi.instance().items().itemFacade.item();
|
||||
final ItemStack cable_anchor = AEApi.instance().parts().partCableAnchor.stack( 1 );
|
||||
|
||||
public void loadTransferRects()
|
||||
{
|
||||
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "crafting", new Object[0] ) );
|
||||
}
|
||||
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return GuiCrafting.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return GuiText.FacadeCrafting.getLocal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if ( (outputId.equals( "crafting" )) && (getClass() == NEIFacadeRecipeHandler.class) )
|
||||
{
|
||||
ItemFacade ifa = (ItemFacade) AEApi.instance().items().itemFacade.item();
|
||||
List<ItemStack> facades = ifa.getFacades();
|
||||
for (ItemStack is : facades)
|
||||
{
|
||||
CachedShapedRecipe recipe = new CachedShapedRecipe( is );
|
||||
recipe.computeVisuals();
|
||||
arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.loadCraftingRecipes( outputId, results );
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
if ( result.getItem() == ifa )
|
||||
{
|
||||
CachedShapedRecipe recipe = new CachedShapedRecipe( result );
|
||||
recipe.computeVisuals();
|
||||
arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
List<ItemStack> facades = ifa.getFacades();
|
||||
for (ItemStack is : facades)
|
||||
{
|
||||
CachedShapedRecipe recipe = new CachedShapedRecipe( is );
|
||||
|
||||
if ( recipe.contains( recipe.ingredients, ingredient.getItem() ) )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
||||
{
|
||||
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
|
||||
arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getGuiTexture()
|
||||
{
|
||||
return "textures/gui/container/crafting_table.png";
|
||||
}
|
||||
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "crafting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
|
||||
{
|
||||
return (super.hasOverlay( gui, container, recipe )) || ((isRecipe2x2( recipe )) && (RecipeInfo.hasDefaultOverlay( gui, "crafting2x2" )));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
|
||||
{
|
||||
IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe );
|
||||
if ( renderer != null )
|
||||
return renderer;
|
||||
|
||||
IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" );
|
||||
if ( positioner == null )
|
||||
return null;
|
||||
|
||||
return new DefaultOverlayRenderer( getIngredientStacks( recipe ), positioner );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
|
||||
{
|
||||
IOverlayHandler handler = super.getOverlayHandler( gui, recipe );
|
||||
if ( handler != null )
|
||||
return handler;
|
||||
|
||||
return RecipeInfo.getOverlayHandler( gui, "crafting2x2" );
|
||||
}
|
||||
|
||||
public boolean isRecipe2x2(int recipe)
|
||||
{
|
||||
for (PositionedStack stack : getIngredientStacks( recipe ))
|
||||
{
|
||||
if ( (stack.relx > 43) || (stack.rely > 24) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public class CachedShapedRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
public PositionedStack result;
|
||||
|
||||
public CachedShapedRecipe(ItemStack output) {
|
||||
output.stackSize = 4;
|
||||
result = new PositionedStack( output, 119, 24 );
|
||||
ingredients = new ArrayList<PositionedStack>();
|
||||
ItemStack in = ifa.getTextureItem( output );
|
||||
setIngredients( 3, 3, new Object[] { null, cable_anchor, null, cable_anchor, in, cable_anchor, null, cable_anchor, null } );
|
||||
}
|
||||
|
||||
public void setIngredients(int width, int height, Object[] items)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
if ( items[(y * width + x)] != null )
|
||||
{
|
||||
ItemStack is = (ItemStack) items[(y * width + x)];
|
||||
PositionedStack stack = new PositionedStack( is, 25 + x * 18, 6 + y * 18, false );
|
||||
stack.setMaxSize( 1 );
|
||||
this.ingredients.add( stack );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
return getCycledIngredients( cycleticks / 20, this.ingredients );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void computeVisuals()
|
||||
{
|
||||
for (PositionedStack p : this.ingredients)
|
||||
{
|
||||
p.generatePermutations();
|
||||
}
|
||||
this.result.generatePermutations();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package appeng.integration.modules.NEIHelpers;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IGrinderEntry;
|
||||
import appeng.client.gui.implementations.GuiGrinder;
|
||||
import appeng.core.localization.GuiText;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class NEIGrinderRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
|
||||
public void drawBackground(int recipe)
|
||||
{
|
||||
GL11.glColor4f( 1, 1, 1, 1 );
|
||||
changeTexture( getGuiTexture() );
|
||||
drawTexturedModalRect( 40, 10, 75, 16 + 10, 90, 66 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int recipe)
|
||||
{
|
||||
super.drawForeground( recipe );
|
||||
if ( this.arecipes.size() > recipe )
|
||||
{
|
||||
CachedRecipe cr = this.arecipes.get( recipe );
|
||||
if ( cr instanceof CachedGrindStoneRecipe )
|
||||
{
|
||||
CachedGrindStoneRecipe cgsr = (CachedGrindStoneRecipe) cr;
|
||||
if ( cgsr.hasOptional )
|
||||
{
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
int width = fr.getStringWidth( cgsr.Chance );
|
||||
fr.drawString( cgsr.Chance, (168 - width) / 2, 5, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
int width = fr.getStringWidth( GuiText.NoSecondOutput.getLocal() );
|
||||
fr.drawString( GuiText.NoSecondOutput.getLocal(), (168 - width) / 2, 5, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadTransferRects()
|
||||
{
|
||||
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "grindstone", new Object[0] ) );
|
||||
}
|
||||
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return GuiGrinder.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return GuiText.GrindStone.getLocal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if ( (outputId.equals( "grindstone" )) && (getClass() == NEIGrinderRecipeHandler.class) )
|
||||
{
|
||||
for (IGrinderEntry irecipe : AEApi.instance().registries().grinder().getRecipes())
|
||||
{
|
||||
CachedGrindStoneRecipe recipe = new CachedGrindStoneRecipe( irecipe );
|
||||
if ( recipe != null )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.loadCraftingRecipes( outputId, results );
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for (IGrinderEntry irecipe : AEApi.instance().registries().grinder().getRecipes())
|
||||
{
|
||||
if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.getOutput(), result ) )
|
||||
{
|
||||
CachedGrindStoneRecipe recipe = new CachedGrindStoneRecipe( irecipe );
|
||||
recipe.computeVisuals();
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
for (IGrinderEntry irecipe : AEApi.instance().registries().grinder().getRecipes())
|
||||
{
|
||||
CachedGrindStoneRecipe recipe = new CachedGrindStoneRecipe( irecipe );
|
||||
|
||||
if ( (recipe != null) && (recipe.contains( recipe.ingredients, ingredient.getItem() )) )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
||||
{
|
||||
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getGuiTexture()
|
||||
{
|
||||
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/guis/grinder.png" );
|
||||
String f = loc.toString();
|
||||
return f;
|
||||
}
|
||||
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "grindstone";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public class CachedGrindStoneRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
public PositionedStack result;
|
||||
|
||||
boolean hasOptional = false;
|
||||
public String Chance;
|
||||
|
||||
public CachedGrindStoneRecipe(IGrinderEntry irecipe) {
|
||||
result = new PositionedStack( irecipe.getOutput(), -30 + 107, 47 );
|
||||
ingredients = new ArrayList<PositionedStack>();
|
||||
|
||||
if ( irecipe.getOptionalOutput() != null )
|
||||
{
|
||||
hasOptional = true;
|
||||
Chance = ((int) (irecipe.getOptionalChance() * 100)) + GuiText.OfSecondOutput.getLocal();
|
||||
ingredients.add( new PositionedStack( irecipe.getOptionalOutput(), -30 + 107 + 18, 47 ) );
|
||||
}
|
||||
|
||||
if ( irecipe.getInput() != null )
|
||||
ingredients.add( new PositionedStack( irecipe.getInput(), 45, 24 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
return getCycledIngredients( cycleticks / 20, this.ingredients );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void computeVisuals()
|
||||
{
|
||||
for (PositionedStack p : this.ingredients)
|
||||
{
|
||||
p.generatePermutations();
|
||||
}
|
||||
this.result.generatePermutations();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package appeng.integration.modules.NEIHelpers;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.changeTexture;
|
||||
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.gui.implementations.GuiInscriber;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.recipes.handlers.Inscribe;
|
||||
import appeng.recipes.handlers.Inscribe.InscriberRecipe;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
|
||||
public class NEIInscriberRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
|
||||
public void drawBackground(int recipe)
|
||||
{
|
||||
GL11.glColor4f( 1, 1, 1, 1 );
|
||||
changeTexture( getGuiTexture() );
|
||||
drawTexturedModalRect( 0, 0, 5, 11, 166, 75 );
|
||||
}
|
||||
|
||||
public void loadTransferRects()
|
||||
{
|
||||
this.transferRects.add( new TemplateRecipeHandler.RecipeTransferRect( new Rectangle( 84, 23, 24, 18 ), "inscriber", new Object[0] ) );
|
||||
}
|
||||
|
||||
public Class<? extends GuiContainer> getGuiClass()
|
||||
{
|
||||
return GuiInscriber.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return GuiText.Inscriber.getLocal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results)
|
||||
{
|
||||
if ( (outputId.equals( "inscriber" )) && (getClass() == NEIInscriberRecipeHandler.class) )
|
||||
{
|
||||
for (InscriberRecipe irecipe : Inscribe.recipes)
|
||||
{
|
||||
CachedInscriberRecipe recipe = new CachedInscriberRecipe( irecipe );
|
||||
if ( recipe != null )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.loadCraftingRecipes( outputId, results );
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCraftingRecipes(ItemStack result)
|
||||
{
|
||||
for (InscriberRecipe irecipe : Inscribe.recipes)
|
||||
{
|
||||
if ( NEIServerUtils.areStacksSameTypeCrafting( irecipe.output, result ) )
|
||||
{
|
||||
CachedInscriberRecipe recipe = new CachedInscriberRecipe( irecipe );
|
||||
recipe.computeVisuals();
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUsageRecipes(ItemStack ingredient)
|
||||
{
|
||||
for (InscriberRecipe irecipe : Inscribe.recipes)
|
||||
{
|
||||
CachedInscriberRecipe recipe = new CachedInscriberRecipe( irecipe );
|
||||
|
||||
if ( (recipe != null) && (recipe.contains( recipe.ingredients, ingredient.getItem() )) )
|
||||
{
|
||||
recipe.computeVisuals();
|
||||
if ( recipe.contains( recipe.ingredients, ingredient ) )
|
||||
{
|
||||
recipe.setIngredientPermutation( recipe.ingredients, ingredient );
|
||||
this.arecipes.add( recipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getGuiTexture()
|
||||
{
|
||||
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/guis/inscriber.png" );
|
||||
String f = loc.toString();
|
||||
return f;
|
||||
}
|
||||
|
||||
public String getOverlayIdentifier()
|
||||
{
|
||||
return "inscriber";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public class CachedInscriberRecipe extends TemplateRecipeHandler.CachedRecipe
|
||||
{
|
||||
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
public PositionedStack result;
|
||||
|
||||
public CachedInscriberRecipe(InscriberRecipe irecipe) {
|
||||
result = new PositionedStack( irecipe.output, 108, 29 );
|
||||
ingredients = new ArrayList<PositionedStack>();
|
||||
|
||||
if ( irecipe.plateA != null )
|
||||
ingredients.add( new PositionedStack( irecipe.plateA, 40, 5 ) );
|
||||
|
||||
if ( irecipe.imprintable != null )
|
||||
ingredients.add( new PositionedStack( irecipe.imprintable, 40 + 18, 28 ) );
|
||||
|
||||
if ( irecipe.plateB != null )
|
||||
ingredients.add( new PositionedStack( irecipe.plateB, 40, 51 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients()
|
||||
{
|
||||
return getCycledIngredients( cycleticks / 20, this.ingredients );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void computeVisuals()
|
||||
{
|
||||
for (PositionedStack p : this.ingredients)
|
||||
{
|
||||
p.generatePermutations();
|
||||
}
|
||||
this.result.generatePermutations();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
package appeng.integration.modules.NEIHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.ICraftingHandler;
|
||||
import codechicken.nei.recipe.IUsageHandler;
|
||||
|
||||
public class NEIWorldCraftingHandler implements ICraftingHandler, IUsageHandler
|
||||
{
|
||||
|
||||
HashMap<AEItemDefinition, String> details = new HashMap<AEItemDefinition, String>();
|
||||
List<AEItemDefinition> offsets = new LinkedList();
|
||||
List<PositionedStack> outputs = new LinkedList();
|
||||
|
||||
ItemStack target;
|
||||
|
||||
private void addRecipe(AEItemDefinition def, String msg)
|
||||
{
|
||||
if ( NEIServerUtils.areStacksSameTypeCrafting( def.stack( 1 ), target ) )
|
||||
{
|
||||
offsets.add( def );
|
||||
outputs.add( new PositionedStack( def.stack( 1 ), 75, 4 ) );
|
||||
details.put( def, msg );
|
||||
}
|
||||
}
|
||||
|
||||
private void addRecipes()
|
||||
{
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CertusQuartzWorldGen ) )
|
||||
addRecipe( AEApi.instance().materials().materialCertusQuartzCrystalCharged,
|
||||
GuiText.ChargedQuartz.getLocal() + "\n\n" + GuiText.ChargedQuartzFind.getLocal() );
|
||||
else
|
||||
addRecipe( AEApi.instance().materials().materialCertusQuartzCrystalCharged, GuiText.ChargedQuartzFind.getLocal() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.MeteoriteWorldGen ) )
|
||||
{
|
||||
addRecipe( AEApi.instance().materials().materialLogicProcessorPress, GuiText.inWorldCraftingPresses.getLocal() );
|
||||
addRecipe( AEApi.instance().materials().materialCalcProcessorPress, GuiText.inWorldCraftingPresses.getLocal() );
|
||||
addRecipe( AEApi.instance().materials().materialEngProcessorPress, GuiText.inWorldCraftingPresses.getLocal() );
|
||||
}
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldFluix ) )
|
||||
addRecipe( AEApi.instance().materials().materialFluixCrystal, GuiText.inWorldFluix.getLocal() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldSingularity ) )
|
||||
addRecipe( AEApi.instance().materials().materialQESingularity, GuiText.inWorldSingularity.getLocal() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.inWorldPurification ) )
|
||||
{
|
||||
addRecipe( AEApi.instance().materials().materialPurifiedCertusQuartzCrystal, GuiText.inWorldPurificationCertus.getLocal() );
|
||||
addRecipe( AEApi.instance().materials().materialPurifiedNetherQuartzCrystal, GuiText.inWorldPurificationNether.getLocal() );
|
||||
addRecipe( AEApi.instance().materials().materialPurifiedFluixCrystal, GuiText.inWorldPurificationFluix.getLocal() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName()
|
||||
{
|
||||
return GuiText.InWorldCrafting.getLocal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int numRecipes()
|
||||
{
|
||||
return offsets.size();
|
||||
}
|
||||
|
||||
public void drawBackground(int recipe)
|
||||
{
|
||||
GL11.glColor4f( 1, 1, 1, 1 );// nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int recipe)
|
||||
{
|
||||
if ( this.outputs.size() > recipe )
|
||||
{
|
||||
// PositionedStack cr = this.outputs.get( recipe );
|
||||
String details = this.details.get( this.offsets.get( recipe ) );
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
fr.drawSplitString( details, 10, 25, 150, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredientStacks(int recipe)
|
||||
{
|
||||
return new ArrayList<PositionedStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks(int recipetype)
|
||||
{
|
||||
return new ArrayList<PositionedStack>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResultStack(int recipe)
|
||||
{
|
||||
return outputs.get( recipe );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recipiesPerPage()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipe)
|
||||
{
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(GuiRecipe gui, ItemStack stack, List<String> currenttip, int recipe)
|
||||
{
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiRecipe gui, int button, int recipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public NEIWorldCraftingHandler newInstance()
|
||||
{
|
||||
try
|
||||
{
|
||||
return getClass().newInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUsageHandler getUsageHandler(String inputId, Object... ingredients)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingHandler getRecipeHandler(String outputId, Object... results)
|
||||
{
|
||||
NEIWorldCraftingHandler g = newInstance();
|
||||
if ( results.length > 0 && results[0] instanceof ItemStack )
|
||||
{
|
||||
g.target = (ItemStack) results[0];
|
||||
g.addRecipes();
|
||||
return g;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.integration.modules.NEIHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
|
||||
public class TerminalCraftingSlotFinder implements IStackPositioner
|
||||
{
|
||||
|
||||
@Override
|
||||
public ArrayList<PositionedStack> positionStacks(ArrayList<PositionedStack> a)
|
||||
{
|
||||
for (PositionedStack ps : a)
|
||||
if ( ps != null )
|
||||
{
|
||||
ps.relx += GuiMEMonitorable.CraftingGridOffsetX;
|
||||
ps.rely += GuiMEMonitorable.CraftingGridOffsetY;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import rblocks.api.IOrientable;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.abstraction.IRB;
|
||||
|
||||
public class RB extends BaseModule implements IRB
|
||||
{
|
||||
|
||||
private class RBWrapper implements appeng.api.util.IOrientable
|
||||
{
|
||||
|
||||
final private IOrientable internal;
|
||||
|
||||
public RBWrapper(IOrientable ww) {
|
||||
internal = ww;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated()
|
||||
{
|
||||
return internal.canBeRotated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForward()
|
||||
{
|
||||
return internal.getForward();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getUp()
|
||||
{
|
||||
return internal.getUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation(ForgeDirection Forward, ForgeDirection Up)
|
||||
{
|
||||
internal.setOrientation( Forward, Up );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static RB instance;
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
TestClass( IOrientable.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public appeng.api.util.IOrientable getOrientable(TileEntity te)
|
||||
{
|
||||
if ( te instanceof IOrientable )
|
||||
return new RBWrapper( (IOrientable) te );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import mods.railcraft.api.crafting.IRockCrusherRecipe;
|
||||
import mods.railcraft.api.crafting.RailcraftCraftingManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import appeng.integration.abstraction.IRC;
|
||||
|
||||
public class RC extends BaseModule implements IIntegrationModule, IRC
|
||||
{
|
||||
|
||||
public static RC instance;
|
||||
|
||||
@Override
|
||||
public void rockCrusher(ItemStack input, ItemStack output)
|
||||
{
|
||||
IRockCrusherRecipe re = RailcraftCraftingManager.rockCrusher.createNewRecipe( input, true, true );
|
||||
re.addOutput( output, 1.0f );
|
||||
}
|
||||
|
||||
public RC() {
|
||||
TestClass( RailcraftCraftingManager.class );
|
||||
TestClass( IRockCrusherRecipe.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class RF extends BaseModule implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static RF instance;
|
||||
|
||||
public RF() {
|
||||
TestClass( cofh.api.energy.IEnergyHandler.class );
|
||||
TestClass( cofh.api.energy.IEnergyConnection.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
}
|
||||
|
||||
void RFStack(String mod, String name, int dmg)
|
||||
{
|
||||
ItemStack modItem = GameRegistry.findItemStack( mod, name, 1 );
|
||||
if ( modItem != null )
|
||||
{
|
||||
modItem.setItemDamage( dmg );
|
||||
AEApi.instance().registries().p2pTunnel().addNewAttunement( modItem, TunnelType.RF_POWER );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
RFStack( "ExtraUtilities", "extractor_base", 12 );
|
||||
RFStack( "ExtraUtilities", "pipes", 11 );
|
||||
RFStack( "ExtraUtilities", "pipes", 14 );
|
||||
RFStack( "ExtraUtilities", "generator", OreDictionary.WILDCARD_VALUE );
|
||||
|
||||
RFStack( "ThermalExpansion", "Cell", OreDictionary.WILDCARD_VALUE );
|
||||
RFStack( "ThermalExpansion", "Dynamo", OreDictionary.WILDCARD_VALUE );
|
||||
|
||||
RFStack( "EnderIO", "itemPowerConduit", OreDictionary.WILDCARD_VALUE );
|
||||
RFStack( "EnderIO", "blockCapacitorBank", 0 );
|
||||
RFStack( "EnderIO", "blockPowerMonitor", 0 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IIntegrationModule;
|
||||
|
||||
public class RFItem extends BaseModule implements IIntegrationModule
|
||||
{
|
||||
|
||||
public static RFItem instance;
|
||||
|
||||
public RFItem() {
|
||||
TestClass( cofh.api.energy.IEnergyContainerItem.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import appeng.integration.BaseModule;
|
||||
|
||||
public class RotaryCraft extends BaseModule
|
||||
{
|
||||
|
||||
public static RotaryCraft instance;
|
||||
|
||||
public RotaryCraft() {
|
||||
TestClass( Reika.RotaryCraft.API.ShaftPowerReceiver.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
package appeng.integration.modules;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaFMPAccessor;
|
||||
import mcp.mobius.waila.api.IWailaFMPProvider;
|
||||
import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.implementations.parts.IPartStorageMonitor;
|
||||
import appeng.api.parts.IFacadePart;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.WailaText;
|
||||
import appeng.integration.BaseModule;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
import appeng.parts.networking.PartDenseCable;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class Waila extends BaseModule implements IWailaDataProvider, IWailaFMPProvider
|
||||
{
|
||||
|
||||
public static Waila instance;
|
||||
|
||||
public static void register(IWailaRegistrar registrar)
|
||||
{
|
||||
Waila w = (Waila) AppEng.instance.getIntegration( IntegrationType.Waila );
|
||||
|
||||
registrar.registerBodyProvider( w, AEBaseBlock.class );
|
||||
registrar.registerBodyProvider( w, "ae2_cablebus" );
|
||||
|
||||
registrar.registerSyncedNBTKey( "internalCurrentPower", TileEnergyCell.class );
|
||||
registrar.registerSyncedNBTKey( "extra:6.usedChannels", TileCableBus.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Init() throws Throwable
|
||||
{
|
||||
TestClass( IWailaDataProvider.class );
|
||||
TestClass( IWailaRegistrar.class );
|
||||
FMLInterModComms.sendMessage( "Waila", "register", this.getClass().getName() + ".register" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PostInit() throws Throwable
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
TileEntity te = accessor.getTileEntity();
|
||||
MovingObjectPosition mop = accessor.getPosition();
|
||||
|
||||
NBTTagCompound nbt = null;
|
||||
|
||||
try
|
||||
{
|
||||
nbt = accessor.getNBTData();
|
||||
}
|
||||
catch (NullPointerException npe)
|
||||
{
|
||||
}
|
||||
|
||||
return getBody( itemStack, currenttip, accessor.getPlayer(), nbt, te, mop );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
TileEntity te = accessor.getTileEntity();
|
||||
MovingObjectPosition mop = accessor.getPosition();
|
||||
|
||||
NBTTagCompound nbt = null;
|
||||
|
||||
try
|
||||
{
|
||||
nbt = accessor.getNBTData();
|
||||
}
|
||||
catch (NullPointerException npe)
|
||||
{
|
||||
}
|
||||
|
||||
return getBody( itemStack, currenttip, accessor.getPlayer(), nbt, te, mop );
|
||||
}
|
||||
|
||||
public List<String> getBody(ItemStack itemStack, List<String> currenttip, EntityPlayer player, NBTTagCompound nbt, TileEntity te, MovingObjectPosition mop)
|
||||
{
|
||||
|
||||
Object ThingOfInterest = te;
|
||||
if ( te instanceof IPartHost )
|
||||
{
|
||||
Vec3 Pos = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ );
|
||||
SelectedPart sp = ((IPartHost) te).selectPart( Pos );
|
||||
if ( sp.facade != null )
|
||||
{
|
||||
IFacadePart fp = sp.facade;
|
||||
ThingOfInterest = fp;
|
||||
}
|
||||
else if ( sp.part != null )
|
||||
{
|
||||
IPart part = sp.part;
|
||||
ThingOfInterest = part;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( ThingOfInterest instanceof PartCableSmart || ThingOfInterest instanceof PartDenseCable )
|
||||
{
|
||||
NBTTagCompound c = nbt;
|
||||
if ( c != null && c.hasKey( "extra:6" ) )
|
||||
{
|
||||
NBTTagCompound ic = c.getCompoundTag( "extra:6" );
|
||||
if ( ic != null && ic.hasKey( "usedChannels" ) )
|
||||
{
|
||||
int channels = ic.getByte( "usedChannels" );
|
||||
currenttip.add( channels + " " + GuiText.Of.getLocal() + " " + (ThingOfInterest instanceof PartDenseCable ? 32 : 8) + " "
|
||||
+ WailaText.Channels.getLocal() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ThingOfInterest instanceof TileEnergyCell )
|
||||
{
|
||||
NBTTagCompound c = nbt;
|
||||
if ( c != null && c.hasKey( "internalCurrentPower" ) )
|
||||
{
|
||||
TileEnergyCell tec = (TileEnergyCell) ThingOfInterest;
|
||||
long power = (long) (100 * c.getDouble( "internalCurrentPower" ));
|
||||
currenttip.add( WailaText.Contains + ": " + Platform.formatPowerLong( power, false ) + " / "
|
||||
+ Platform.formatPowerLong( (long) (100 * tec.getAEMaxPower()), false ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
if ( ThingOfInterest instanceof IPartStorageMonitor )
|
||||
{
|
||||
IPartStorageMonitor psm = (IPartStorageMonitor) ThingOfInterest;
|
||||
IAEStack stack = psm.getDisplayed();
|
||||
boolean isLocked = psm.isLocked();
|
||||
|
||||
if ( stack instanceof IAEItemStack )
|
||||
{
|
||||
IAEItemStack ais = (IAEItemStack) stack;
|
||||
currenttip.add( WailaText.Showing.getLocal() + ": " + ais.getItemStack().getDisplayName() );
|
||||
}
|
||||
|
||||
if ( stack instanceof IAEFluidStack )
|
||||
{
|
||||
IAEFluidStack ais = (IAEFluidStack) stack;
|
||||
currenttip.add( WailaText.Showing.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
|
||||
}
|
||||
|
||||
if ( isLocked )
|
||||
currenttip.add( WailaText.Locked.getLocal() );
|
||||
else
|
||||
currenttip.add( WailaText.Unlocked.getLocal() );
|
||||
}
|
||||
|
||||
if ( ThingOfInterest instanceof TileCharger )
|
||||
{
|
||||
TileCharger tc = (TileCharger) ThingOfInterest;
|
||||
IInventory inv = tc.getInternalInventory();
|
||||
ItemStack is = inv.getStackInSlot( 0 );
|
||||
if ( is != null )
|
||||
{
|
||||
currenttip.add( WailaText.Contains + ": " + is.getDisplayName() );
|
||||
is.getItem().addInformation( is, player, currenttip, true );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ThingOfInterest instanceof IPowerChannelState )
|
||||
{
|
||||
IPowerChannelState pbs = (IPowerChannelState) ThingOfInterest;
|
||||
if ( pbs.isActive() && pbs.isPowered() )
|
||||
currenttip.add( WailaText.DeviceOnline.getLocal() );
|
||||
else if ( pbs.isPowered() )
|
||||
currenttip.add( WailaText.DeviceMissingChannel.getLocal() );
|
||||
else
|
||||
currenttip.add( WailaText.DeviceOffline.getLocal() );
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaFMPAccessor accessor, IWailaConfigHandler config)
|
||||
{
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class BSCrate implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
|
||||
ICrateStorage cs;
|
||||
ForgeDirection side;
|
||||
|
||||
public BSCrate(Object object, ForgeDirection d) {
|
||||
cs = (ICrateStorage) object;
|
||||
side = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
return null;
|
||||
|
||||
ItemStack failed = cs.insertItems( input.getItemStack() );
|
||||
if ( failed == null )
|
||||
return null;
|
||||
input.setStackSize( failed.stackSize );
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
int howMany = cs.getItemCount( request.getItemStack() );
|
||||
return howMany > request.getStackSize() ? request : request.copy().setStackSize( howMany );
|
||||
}
|
||||
|
||||
ItemStack Obtained = cs.extractItems( request.getItemStack(), (int) request.getStackSize() );
|
||||
return AEItemStack.create( Obtained );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList getAvailableItems(IItemList out)
|
||||
{
|
||||
for (ItemStack is : cs.getContents())
|
||||
{
|
||||
out.add( AEItemStack.create( is ) );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
|
||||
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;
|
||||
|
||||
public class BSCrateHandler implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc)
|
||||
{
|
||||
return channel == StorageChannel.ITEMS && te instanceof ICrateStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src)
|
||||
{
|
||||
if ( channel == StorageChannel.ITEMS )
|
||||
return new BSCrate( te, ForgeDirection.UNKNOWN );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
import appeng.util.iterators.StackToSlotIterator;
|
||||
|
||||
public class BSCrateStorageAdaptor extends InventoryAdaptor
|
||||
{
|
||||
|
||||
ICrateStorage cs;
|
||||
ForgeDirection side;
|
||||
|
||||
public BSCrateStorageAdaptor(Object te, ForgeDirection d) {
|
||||
cs = (ICrateStorage) te;
|
||||
side = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeItems(int how_many, ItemStack Filter, IInventoryDestination dest)
|
||||
{
|
||||
ItemStack target = null;
|
||||
|
||||
for (ItemStack is : cs.getContents())
|
||||
{
|
||||
if ( is != null )
|
||||
{
|
||||
if ( is.stackSize > 0 && (Filter == null || Platform.isSameItem( Filter, is )) )
|
||||
{
|
||||
if ( dest == null || dest.canInsert( is ) )
|
||||
{
|
||||
target = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( target != null )
|
||||
{
|
||||
ItemStack f = Platform.cloneItemStack( target );
|
||||
f.stackSize = how_many;
|
||||
return cs.extractItems( f, how_many );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateRemove(int how_many, ItemStack Filter, IInventoryDestination dest)
|
||||
{
|
||||
ItemStack target = null;
|
||||
|
||||
for (ItemStack is : cs.getContents())
|
||||
{
|
||||
if ( is != null )
|
||||
{
|
||||
if ( is.stackSize > 0 && (Filter == null || Platform.isSameItem( Filter, is )) )
|
||||
{
|
||||
if ( dest == null || dest.canInsert( is ) )
|
||||
{
|
||||
target = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( target != null )
|
||||
{
|
||||
int cnt = cs.getItemCount( target );
|
||||
if ( cnt == 0 )
|
||||
return null;
|
||||
if ( cnt > how_many )
|
||||
cnt = how_many;
|
||||
ItemStack c = target.copy();
|
||||
c.stackSize = cnt;
|
||||
return c;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeSimilarItems(int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination dest)
|
||||
{
|
||||
ItemStack target = null;
|
||||
|
||||
for (ItemStack is : cs.getContents())
|
||||
{
|
||||
if ( is != null )
|
||||
{
|
||||
if ( is.stackSize > 0 && (filter == null || Platform.isSameItemFuzzy( filter, is, fuzzyMode )) )
|
||||
{
|
||||
if ( dest == null || dest.canInsert( is ) )
|
||||
{
|
||||
target = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( target != null )
|
||||
{
|
||||
ItemStack f = Platform.cloneItemStack( target );
|
||||
f.stackSize = amount;
|
||||
return cs.extractItems( f, amount );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateSimilarRemove(int how_many, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination dest)
|
||||
{
|
||||
ItemStack target = null;
|
||||
|
||||
for (ItemStack is : cs.getContents())
|
||||
{
|
||||
if ( is != null )
|
||||
{
|
||||
if ( is.stackSize > 0 && (filter == null || Platform.isSameItemFuzzy( filter, is, fuzzyMode )) )
|
||||
{
|
||||
if ( dest == null || dest.canInsert( is ) )
|
||||
{
|
||||
target = is;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( target != null )
|
||||
{
|
||||
int cnt = cs.getItemCount( target );
|
||||
if ( cnt == 0 )
|
||||
return null;
|
||||
if ( cnt > how_many )
|
||||
cnt = how_many;
|
||||
ItemStack c = target.copy();
|
||||
c.stackSize = cnt;
|
||||
return c;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack addItems(ItemStack A)
|
||||
{
|
||||
return cs.insertItems( A );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateAdd(ItemStack A)
|
||||
{
|
||||
int items = cs.getSpaceForItem( A );
|
||||
ItemStack B = Platform.cloneItemStack( A );
|
||||
if ( A.stackSize <= items )
|
||||
return null;
|
||||
B.stackSize -= items;
|
||||
return B;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsItems()
|
||||
{
|
||||
return cs.getUniqueItems() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ItemSlot> iterator()
|
||||
{
|
||||
return new StackToSlotIterator( cs.getContents().iterator() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class FMPPacketEvent extends Event
|
||||
{
|
||||
|
||||
public final EntityPlayerMP sender;
|
||||
|
||||
public FMPPacketEvent(EntityPlayerMP sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.integration.abstraction.IFZ;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class FactorizationBarrel implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
|
||||
private final TileEntity te;
|
||||
IFZ fProxy;
|
||||
|
||||
public FactorizationBarrel(IFZ proxy, TileEntity tile) {
|
||||
te = tile;
|
||||
fProxy = proxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
public long remainingItemTypes()
|
||||
{
|
||||
return fProxy.barrelGetItem( te ) == null ? 1 : 0;
|
||||
}
|
||||
|
||||
public long remainingItemCount()
|
||||
{
|
||||
return fProxy.barrelGetMaxItemCount( te ) - fProxy.barrelGetItemCount( te );
|
||||
}
|
||||
|
||||
public boolean containsItemType(IAEItemStack i, boolean acceptEmpty)
|
||||
{
|
||||
ItemStack currentItem = fProxy.barrelGetItem( te );
|
||||
|
||||
// empty barrels want your love too!
|
||||
if ( acceptEmpty && currentItem == null )
|
||||
return true;
|
||||
|
||||
return i.equals( currentItem );
|
||||
}
|
||||
|
||||
public long storedItemCount()
|
||||
{
|
||||
return fProxy.barrelGetItemCount( te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( input == null )
|
||||
return null;
|
||||
if ( input.getStackSize() == 0 )
|
||||
return null;
|
||||
|
||||
ItemStack shared = input.getItemStack();
|
||||
if ( shared.isItemDamaged() )
|
||||
return input;
|
||||
|
||||
if ( remainingItemTypes() > 0 )
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
fProxy.setItemType( te, input.getItemStack() );
|
||||
}
|
||||
|
||||
if ( containsItemType( input, mode == Actionable.SIMULATE ) )
|
||||
{
|
||||
int max = fProxy.barrelGetMaxItemCount( te );
|
||||
int newTotal = (int) storedItemCount() + (int) input.getStackSize();
|
||||
if ( newTotal > max )
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
fProxy.barrelSetCount( te, max );
|
||||
IAEItemStack result = input.copy();
|
||||
result.setStackSize( newTotal - max );
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
fProxy.barrelSetCount( te, newTotal );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( containsItemType( request, false ) )
|
||||
{
|
||||
int howMany = (int) storedItemCount();
|
||||
if ( request.getStackSize() >= howMany )
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
fProxy.setItemType( te, null );
|
||||
fProxy.barrelSetCount( te, 0 );
|
||||
}
|
||||
|
||||
IAEItemStack r = request.copy();
|
||||
r.setStackSize( howMany );
|
||||
return r;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
fProxy.barrelSetCount( te, (int) (howMany - request.getStackSize()) );
|
||||
return request.copy();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||
{
|
||||
ItemStack i = fProxy.barrelGetItem( te );
|
||||
if ( i != null )
|
||||
{
|
||||
i.stackSize = fProxy.barrelGetItemCount( te );
|
||||
out.addStorage( AEItemStack.create( i ) );
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
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.integration.modules.FZ;
|
||||
import appeng.me.storage.MEMonitorIInventory;
|
||||
import appeng.util.inv.IMEAdaptor;
|
||||
|
||||
public class FactorizationHandler implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
|
||||
{
|
||||
return chan == StorageChannel.ITEMS && FZ.instance.isBarrel( te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
return new MEMonitorIInventory( new IMEAdaptor( FZ.instance.getFactorizationBarrel( te ), src ) );
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class MFRDSU implements IMEInventory<IAEItemStack>
|
||||
{
|
||||
|
||||
IDeepStorageUnit dsu;
|
||||
TileEntity te;
|
||||
|
||||
public MFRDSU(TileEntity ta) {
|
||||
te = ta;
|
||||
dsu = (IDeepStorageUnit) ta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
ItemStack is = dsu.getStoredItemType();
|
||||
if ( is != null )
|
||||
{
|
||||
if ( input.equals( is ) )
|
||||
{
|
||||
long max = dsu.getMaxStoredCount();
|
||||
long storedItems = is.stackSize;
|
||||
if ( max == storedItems )
|
||||
return input;
|
||||
|
||||
storedItems += input.getStackSize();
|
||||
if ( storedItems > max )
|
||||
{
|
||||
IAEItemStack overflow = AEItemStack.create( is );
|
||||
overflow.setStackSize( (int) (storedItems - max) );
|
||||
if ( mode == Actionable.MODULATE )
|
||||
dsu.setStoredItemCount( (int) max );
|
||||
return overflow;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
dsu.setStoredItemCount( is.stackSize + (int) input.getStackSize() );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( input.getTagCompound() != null )
|
||||
return input;
|
||||
if ( mode == Actionable.MODULATE )
|
||||
dsu.setStoredItemType( input.getItemStack(), (int) input.getStackSize() );
|
||||
return null;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
ItemStack is = dsu.getStoredItemType();
|
||||
if ( request.equals( is ) )
|
||||
{
|
||||
if ( request.getStackSize() >= is.stackSize )
|
||||
{
|
||||
is = is.copy();
|
||||
if ( mode == Actionable.MODULATE )
|
||||
dsu.setStoredItemCount( 0 );
|
||||
return AEItemStack.create( is );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mode == Actionable.MODULATE )
|
||||
dsu.setStoredItemCount( is.stackSize - (int) request.getStackSize() );
|
||||
return request.copy();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out)
|
||||
{
|
||||
ItemStack is = dsu.getStoredItemType();
|
||||
if ( is != null )
|
||||
{
|
||||
out.add( AEItemStack.create( is ) );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
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.integration.modules.DSU;
|
||||
import appeng.me.storage.MEMonitorIInventory;
|
||||
import appeng.util.inv.IMEAdaptor;
|
||||
|
||||
public class MFRDSUHandler implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
|
||||
{
|
||||
return chan == StorageChannel.ITEMS && DSU.instance.isDSU( te );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
return new MEMonitorIInventory( new IMEAdaptor( DSU.instance.getDSU( te ), src ) );
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
|
||||
public class MJBattery
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.integration.abstraction.helpers.BaseMJperdition;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
|
||||
public class MJPerdition extends BaseMJperdition
|
||||
{
|
||||
|
||||
final protected PowerHandler bcPowerHandler;
|
||||
|
||||
public MJPerdition(IPowerReceptor te) {
|
||||
bcPowerHandler = new PowerHandler( te, Type.MACHINE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Tick()
|
||||
{
|
||||
bcPowerHandler.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
bcPowerHandler.writeToNBT( data, "bcPowerHandler" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
bcPowerHandler.readFromNBT( data, "bcPowerHandler" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerReceiver getPowerReceiver()
|
||||
{
|
||||
return bcPowerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double useEnergy(double min, double max, boolean doUse)
|
||||
{
|
||||
return bcPowerHandler.useEnergy( min, max, doUse );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEnergy(float failed)
|
||||
{
|
||||
bcPowerHandler.addEnergy( failed );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(int i, int j, float f, int k)
|
||||
{
|
||||
bcPowerHandler.configure( i, j, f, k );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package appeng.integration.modules.helpers;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
public class NullRFHandler implements IEnergyHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user