mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Added Machine in Buildcraft fixed pipe handler
Added AppEng
This commit is contained in:
parent
338f898a85
commit
846efa3c2a
@ -3,6 +3,7 @@ package li.cil.oc;
|
|||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
import li.cil.oc.driver.Registry;
|
import li.cil.oc.driver.Registry;
|
||||||
|
import li.cil.oc.driver.appeng.HandlerAppEng;
|
||||||
import li.cil.oc.driver.buildcraft.HandlerBuildCraft;
|
import li.cil.oc.driver.buildcraft.HandlerBuildCraft;
|
||||||
import li.cil.oc.driver.enderstorage.HandlerEnderStorage;
|
import li.cil.oc.driver.enderstorage.HandlerEnderStorage;
|
||||||
import li.cil.oc.driver.ic2.HandlerIndustrialCraft2;
|
import li.cil.oc.driver.ic2.HandlerIndustrialCraft2;
|
||||||
@ -17,6 +18,7 @@ public class OpenComponents {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(final FMLInitializationEvent e) {
|
public void init(final FMLInitializationEvent e) {
|
||||||
|
Registry.add(new HandlerAppEng());
|
||||||
Registry.add(new HandlerBuildCraft());
|
Registry.add(new HandlerBuildCraft());
|
||||||
Registry.add(new HandlerEnderStorage());
|
Registry.add(new HandlerEnderStorage());
|
||||||
Registry.add(new HandlerIndustrialCraft2());
|
Registry.add(new HandlerIndustrialCraft2());
|
||||||
|
@ -17,6 +17,7 @@ public final class Registry {
|
|||||||
public static void add(final IModHandler mod) {
|
public static void add(final IModHandler mod) {
|
||||||
final boolean alwaysEnabled = mod.getModId() == null || mod.getModId().isEmpty();
|
final boolean alwaysEnabled = mod.getModId() == null || mod.getModId().isEmpty();
|
||||||
if ((alwaysEnabled || Loader.isModLoaded(mod.getModId())) && handlers.add(mod)) {
|
if ((alwaysEnabled || Loader.isModLoaded(mod.getModId())) && handlers.add(mod)) {
|
||||||
|
System.out.println("Loading up: "+mod.getModId());
|
||||||
mod.initialize();
|
mod.initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
223
src/main/java/li/cil/oc/driver/appeng/DriverCellProvider.java
Normal file
223
src/main/java/li/cil/oc/driver/appeng/DriverCellProvider.java
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
package li.cil.oc.driver.appeng;
|
||||||
|
|
||||||
|
import appeng.api.IAEItemStack;
|
||||||
|
import appeng.api.me.tiles.ICellProvider;
|
||||||
|
import appeng.api.me.util.IMEInventoryHandler;
|
||||||
|
import buildcraft.core.IMachine;
|
||||||
|
import li.cil.oc.api.network.Arguments;
|
||||||
|
import li.cil.oc.api.network.Callback;
|
||||||
|
import li.cil.oc.api.network.Context;
|
||||||
|
import li.cil.oc.api.network.ManagedEnvironment;
|
||||||
|
import li.cil.oc.driver.ManagedTileEntityEnvironment;
|
||||||
|
import li.cil.oc.driver.Registry;
|
||||||
|
import li.cil.oc.driver.TileEntityDriver;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
public class DriverCellProvider extends TileEntityDriver {
|
||||||
|
@Override
|
||||||
|
public Class<?> getFilterClass() {
|
||||||
|
return ICellProvider.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
|
||||||
|
return new Environment((ICellProvider) world.getBlockTileEntity(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Environment extends ManagedTileEntityEnvironment<ICellProvider> {
|
||||||
|
public Environment(ICellProvider tileEntity) {
|
||||||
|
super(tileEntity, "celltileEntity");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getTotalItemTypes(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.getTotalItemTypes()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getPriority(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.getPriority()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] canHoldNewItem(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.canHoldNewItem()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getFreeBytes(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.freeBytes()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getAvailableItems(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
ArrayList<Map> list = new ArrayList<Map>();
|
||||||
|
for (IAEItemStack stack : cell.getAvailableItems()) {
|
||||||
|
Map m = HandlerAppEng.toMap(stack);
|
||||||
|
list.add(m);
|
||||||
|
}
|
||||||
|
return list.toArray();
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] containsItemType(final Context context, final Arguments args) {
|
||||||
|
try {
|
||||||
|
return new Object[]{((Integer) countOfItemType(context, args)[0]) > 0};
|
||||||
|
} catch (Throwable e) {
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] countOfItemType(final Context context, final Arguments args) {
|
||||||
|
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell == null) {
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
Iterator<IAEItemStack> iterator = cell.getAvailableItems().iterator();
|
||||||
|
long c = 0;
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
IAEItemStack next = iterator.next();
|
||||||
|
if (next.getItemID() == args.checkInteger(0) && next.getItemDamage() == args.checkInteger(1)) {
|
||||||
|
c += next.getStackSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{c};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getName(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.getName()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getPreformattedItems(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
ArrayList<Map> list = new ArrayList<Map>();
|
||||||
|
for (ItemStack stack : cell.getPreformattedItems()) {
|
||||||
|
Map m = Registry.toMap(stack);
|
||||||
|
list.add(m);
|
||||||
|
}
|
||||||
|
return list.toArray();
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] isFuzzyPreformatted(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.isFuzzyPreformatted()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] isPreformatted(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.isPreformatted()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getRemainingItemCount(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.remainingItemCount()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getRemainingItemTypes(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.remainingItemTypes()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getStoredItemCount(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.storedItemCount()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getStoredItemTypes(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.storedItemTypes()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getTotalBytes(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.totalBytes()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getUnusedItemCount(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.unusedItemCount()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getUnusedBytes(final Context context, final Arguments args) {
|
||||||
|
IMEInventoryHandler cell = tileEntity.provideCell();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.usedBytes()};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
286
src/main/java/li/cil/oc/driver/appeng/DriverGridTileEntity.java
Normal file
286
src/main/java/li/cil/oc/driver/appeng/DriverGridTileEntity.java
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
package li.cil.oc.driver.appeng;
|
||||||
|
|
||||||
|
import appeng.api.IAEItemStack;
|
||||||
|
import appeng.api.Util;
|
||||||
|
import appeng.api.exceptions.AppEngTileMissingException;
|
||||||
|
import appeng.api.me.tiles.ICellProvider;
|
||||||
|
import appeng.api.me.tiles.IGridTileEntity;
|
||||||
|
import appeng.api.me.util.IGridInterface;
|
||||||
|
import appeng.api.me.util.IMEInventoryHandler;
|
||||||
|
import li.cil.oc.api.network.Arguments;
|
||||||
|
import li.cil.oc.api.network.Callback;
|
||||||
|
import li.cil.oc.api.network.Context;
|
||||||
|
import li.cil.oc.api.network.ManagedEnvironment;
|
||||||
|
import li.cil.oc.driver.ManagedTileEntityEnvironment;
|
||||||
|
import li.cil.oc.driver.Registry;
|
||||||
|
import li.cil.oc.driver.TileEntityDriver;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by lordjoda on 06.02.14.
|
||||||
|
*/
|
||||||
|
public class DriverGridTileEntity extends TileEntityDriver {
|
||||||
|
@Override
|
||||||
|
public Class<?> getFilterClass() {
|
||||||
|
return IGridTileEntity.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
|
||||||
|
return new Environment((IGridTileEntity) world.getBlockTileEntity(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Environment extends ManagedTileEntityEnvironment<IGridTileEntity> {
|
||||||
|
public Environment(IGridTileEntity tileEntity) {
|
||||||
|
super(tileEntity, "gridtileEntity");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] requestCrafting(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
tileEntity.getGrid().craftingRequest(new ItemStack(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2)));
|
||||||
|
return new Object[]{true};
|
||||||
|
} catch (Throwable e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return new Object[]{false};
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Callback
|
||||||
|
// public int extractItem(final Context context, final Arguments args) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Callback
|
||||||
|
// public int insertItem(final Context context, final Arguments args) {
|
||||||
|
// //not used
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getTotalItemTypes(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.getTotalItemTypes()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getPriority(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.getPriority()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] canHoldNewItem(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.canHoldNewItem()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getFreeBytes(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.freeBytes()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getAvailableItems(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
ArrayList<Map> list = new ArrayList<Map>();
|
||||||
|
for (IAEItemStack stack : cell.getAvailableItems()) {
|
||||||
|
Map m = HandlerAppEng.toMap(stack);
|
||||||
|
list.add(m);
|
||||||
|
}
|
||||||
|
return list.toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] containsItemType(final Context context, final Arguments args) {
|
||||||
|
return new Object[]{((Integer) countOfItemType(context, args)[0]) > 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] countOfItemType(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid == null) {
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell == null) {
|
||||||
|
return new Object[]{null, "Cell Null"};
|
||||||
|
}
|
||||||
|
Iterator<IAEItemStack> iterator = cell.getAvailableItems().iterator();
|
||||||
|
long c = 0;
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
IAEItemStack next = iterator.next();
|
||||||
|
if (next.getItemID() == args.checkInteger(0) && next.getItemDamage() == args.checkInteger(1)) {
|
||||||
|
c += next.getStackSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{c};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getPreformattedItems(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
ArrayList<Map> list = new ArrayList<Map>();
|
||||||
|
for (ItemStack stack : cell.getPreformattedItems()) {
|
||||||
|
Map m = Registry.toMap(stack);
|
||||||
|
list.add(m);
|
||||||
|
}
|
||||||
|
return list.toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] isFuzzyPreformatted(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.isFuzzyPreformatted()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] isPreformatted(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.isPreformatted()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getRemainingItemCount(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.remainingItemCount()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getRemainingItemTypes(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.remainingItemTypes()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getStoredItemCount(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.storedItemCount()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getStoredItemTypes(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.storedItemTypes()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getTotalBytes(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.totalBytes()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getUnusedItemCount(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.unusedItemCount()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getUnusedBytes(final Context context, final Arguments args) {
|
||||||
|
IGridInterface grid = tileEntity.getGrid();
|
||||||
|
if (grid != null) {
|
||||||
|
IMEInventoryHandler cell = grid.getCellArray();
|
||||||
|
if (cell != null) {
|
||||||
|
return new Object[]{cell.usedBytes()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Grid Null"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package li.cil.oc.driver.appeng;
|
||||||
|
|
||||||
|
import appeng.api.me.tiles.IGridTileEntity;
|
||||||
|
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||||
|
import li.cil.oc.api.network.Arguments;
|
||||||
|
import li.cil.oc.api.network.Callback;
|
||||||
|
import li.cil.oc.api.network.Context;
|
||||||
|
import li.cil.oc.api.network.ManagedEnvironment;
|
||||||
|
import li.cil.oc.driver.ManagedTileEntityEnvironment;
|
||||||
|
import li.cil.oc.driver.Registry;
|
||||||
|
import li.cil.oc.driver.TileEntityDriver;
|
||||||
|
import li.cil.oc.util.Reflection;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by lordjoda on 07.02.14.
|
||||||
|
*/
|
||||||
|
public class DriverTileController extends TileEntityDriver {
|
||||||
|
|
||||||
|
|
||||||
|
private static final Class<?> TILECONTROLLER = Reflection.getClass("appeng.me.tile.TileController");
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getFilterClass() {
|
||||||
|
return TILECONTROLLER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
|
||||||
|
return new Environment(world.getBlockTileEntity(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Environment extends ManagedTileEntityEnvironment {
|
||||||
|
public Environment(TileEntity tileEntity) {
|
||||||
|
super(tileEntity, "gridtileEntity");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] getJobList(final Context context, final Arguments args) {
|
||||||
|
try {
|
||||||
|
ArrayList<Map> maps = new ArrayList<Map>();
|
||||||
|
for (ItemStack stack : (List<ItemStack>) Reflection.invoke(tileEntity, "getJobList")) {
|
||||||
|
maps.add(Registry.toMap(stack));
|
||||||
|
}
|
||||||
|
return maps.toArray();
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return new Object[]{null, "Unknown Error"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
46
src/main/java/li/cil/oc/driver/appeng/HandlerAppEng.java
Normal file
46
src/main/java/li/cil/oc/driver/appeng/HandlerAppEng.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package li.cil.oc.driver.appeng;
|
||||||
|
|
||||||
|
|
||||||
|
import appeng.api.IAEItemStack;
|
||||||
|
import li.cil.oc.api.Driver;
|
||||||
|
import li.cil.oc.driver.IModHandler;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public final class HandlerAppEng implements IModHandler {
|
||||||
|
@Override
|
||||||
|
public String getModId() {
|
||||||
|
return "AppliedEnergistics";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
Driver.add(new DriverCellProvider());
|
||||||
|
Driver.add(new DriverGridTileEntity());
|
||||||
|
Driver.add(new DriverTileController());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, Object> toMap(IAEItemStack stack) {
|
||||||
|
if (stack == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put("id", stack.getItemID());
|
||||||
|
map.put("damage", stack.getItemDamage());
|
||||||
|
map.put("size", stack.getStackSize());
|
||||||
|
map.put("hasTag", stack.hasTagCompound());
|
||||||
|
map.put("name", stack.getItemStack().getUnlocalizedName());
|
||||||
|
map.put("requestable", stack.getCountRequestable());
|
||||||
|
|
||||||
|
if(stack.getItemStack().getDisplayName()!= null){
|
||||||
|
map.put("label",stack.getItemStack().getDisplayName());
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void populate(Map<String, Object> map, ItemStack stack) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
43
src/main/java/li/cil/oc/driver/buildcraft/DriverMachine.java
Normal file
43
src/main/java/li/cil/oc/driver/buildcraft/DriverMachine.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package li.cil.oc.driver.buildcraft;
|
||||||
|
|
||||||
|
|
||||||
|
import buildcraft.core.IMachine;
|
||||||
|
import li.cil.oc.api.network.Arguments;
|
||||||
|
import li.cil.oc.api.network.Callback;
|
||||||
|
import li.cil.oc.api.network.Context;
|
||||||
|
import li.cil.oc.api.network.ManagedEnvironment;
|
||||||
|
import li.cil.oc.driver.ManagedTileEntityEnvironment;
|
||||||
|
import li.cil.oc.driver.TileEntityDriver;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public final class DriverMachine extends TileEntityDriver {
|
||||||
|
@Override
|
||||||
|
public Class<?> getFilterClass() {
|
||||||
|
return IMachine.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
|
||||||
|
return new Environment((IMachine) world.getBlockTileEntity(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Environment extends ManagedTileEntityEnvironment<IMachine> {
|
||||||
|
public Environment(IMachine tileEntity) {
|
||||||
|
super(tileEntity, "machine");
|
||||||
|
}
|
||||||
|
@Callback
|
||||||
|
public Object[] isActive(final Context context, final Arguments args) {
|
||||||
|
return new Object[]{tileEntity.isActive()};
|
||||||
|
}
|
||||||
|
@Callback
|
||||||
|
public Object[] manageFluids(final Context context, final Arguments args) {
|
||||||
|
return new Object[]{tileEntity.manageFluids()};
|
||||||
|
}
|
||||||
|
@Callback
|
||||||
|
public Object[] manageSolids(final Context context, final Arguments args) {
|
||||||
|
return new Object[]{tileEntity.manageSolids()};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
43
src/main/java/li/cil/oc/driver/buildcraft/DriverPipeTE.java
Normal file
43
src/main/java/li/cil/oc/driver/buildcraft/DriverPipeTE.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package li.cil.oc.driver.buildcraft;
|
||||||
|
|
||||||
|
import buildcraft.api.transport.IPipe;
|
||||||
|
import buildcraft.api.transport.IPipeTile;
|
||||||
|
import li.cil.oc.api.network.Arguments;
|
||||||
|
import li.cil.oc.api.network.Callback;
|
||||||
|
import li.cil.oc.api.network.Context;
|
||||||
|
import li.cil.oc.api.network.ManagedEnvironment;
|
||||||
|
import li.cil.oc.driver.ManagedTileEntityEnvironment;
|
||||||
|
import li.cil.oc.driver.TileEntityDriver;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public final class DriverPipeTE extends TileEntityDriver {
|
||||||
|
@Override
|
||||||
|
public Class<?> getFilterClass() {
|
||||||
|
return IPipeTile.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManagedEnvironment createEnvironment(final World world, final int x, final int y, final int z) {
|
||||||
|
return new Environment((IPipeTile) world.getBlockTileEntity(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Environment extends ManagedTileEntityEnvironment<IPipeTile> {
|
||||||
|
public Environment(IPipeTile tileEntity) {
|
||||||
|
super(tileEntity, "pipete");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] hasGate(final Context context, final Arguments args) {
|
||||||
|
return new Object[]{tileEntity.getPipe().hasGate()};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
public Object[] isWired(final Context context, final Arguments args) {
|
||||||
|
try {
|
||||||
|
return new Object[]{tileEntity.getPipe().isWired(IPipe.WireColor.valueOf(args.checkString(0)))};
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
}
|
||||||
|
return new Object[]{false};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,9 @@ public final class HandlerBuildCraft implements IModHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
Driver.add(new DriverPipe());
|
Driver.add(new DriverPipe());
|
||||||
|
Driver.add(new DriverPipeTE());
|
||||||
Driver.add(new DriverPowerReceptor());
|
Driver.add(new DriverPowerReceptor());
|
||||||
|
Driver.add(new DriverMachine());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,5 +36,9 @@ public final class HandlerVanilla implements IModHandler {
|
|||||||
map.put("size", stack.stackSize);
|
map.put("size", stack.stackSize);
|
||||||
map.put("maxSize", stack.getMaxStackSize());
|
map.put("maxSize", stack.getMaxStackSize());
|
||||||
map.put("hasTag", stack.hasTagCompound());
|
map.put("hasTag", stack.hasTagCompound());
|
||||||
|
map.put("name", stack.getUnlocalizedName());
|
||||||
|
if(stack.getDisplayName()!= null){
|
||||||
|
map.put("label",stack.getDisplayName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
src/main/optional/buildcraft/core/IMachine.java
Normal file
14
src/main/optional/buildcraft/core/IMachine.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package buildcraft.core;
|
||||||
|
|
||||||
|
import buildcraft.api.gates.IAction;
|
||||||
|
|
||||||
|
public abstract interface IMachine
|
||||||
|
{
|
||||||
|
public abstract boolean isActive();
|
||||||
|
|
||||||
|
public abstract boolean manageFluids();
|
||||||
|
|
||||||
|
public abstract boolean manageSolids();
|
||||||
|
|
||||||
|
public abstract boolean allowAction(IAction paramIAction);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user