mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-20 12:19:34 +00:00
CC&OC Integration Update
This commit is contained in:
1 parent
58c4619cfc
commit
aa8efe0c00
4 files changed
+59
-77
No files matched your search
+13
-39
@@ -1,14 +1,12 @@
|
||||
package com.brandon3055.draconicevolution.integration.computers;
|
||||
|
||||
import com.brandon3055.draconicevolution.integration.computers.cc.DEPeripheralProvider;
|
||||
import com.brandon3055.draconicevolution.integration.computers.cc.CCAdapter;
|
||||
import com.brandon3055.draconicevolution.integration.computers.oc.DEManagedPeripheral;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import li.cil.oc.api.Driver;
|
||||
import li.cil.oc.api.network.ManagedEnvironment;
|
||||
import li.cil.oc.api.prefab.DriverTileEntity;
|
||||
@@ -44,44 +42,20 @@ public class CCOCIntegration {
|
||||
|
||||
@Override
|
||||
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
|
||||
return new DEManagedPeripheral((IDEPeripheral)world.getTileEntity(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
public static class DEPeripheralProvider implements IPeripheralProvider {
|
||||
|
||||
@Override
|
||||
public IPeripheral getPeripheral(World world, int x, int y, int z, int i3) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof IDEPeripheral) return new DEManagedPeripheral((IDEPeripheral)tile);
|
||||
if (tile instanceof IDEPeripheral) {
|
||||
return new CCAdapter((IDEPeripheral)tile);
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CCAdapter implements IPeripheral {
|
||||
private IDEPeripheral peripheral;
|
||||
|
||||
public CCAdapter(IDEPeripheral peripheral){
|
||||
this.peripheral = peripheral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return peripheral.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMethodNames() {
|
||||
return peripheral.getMethodNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
|
||||
return peripheral.callMethod(peripheral.getMethodNames()[method], arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach(IComputerAccess iComputerAccess) {}
|
||||
|
||||
@Override
|
||||
public void detach(IComputerAccess iComputerAccess) {}
|
||||
|
||||
@Override
|
||||
public boolean equals(IPeripheral iPeripheral) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.brandon3055.draconicevolution.integration.computers.cc;
|
||||
|
||||
import com.brandon3055.draconicevolution.integration.computers.IDEPeripheral;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
/**
|
||||
* Created by brandon3055 on 21/9/2015.
|
||||
*/
|
||||
public class CCAdapter implements IPeripheral {
|
||||
private IDEPeripheral peripheral;
|
||||
|
||||
public CCAdapter(IDEPeripheral peripheral){
|
||||
this.peripheral = peripheral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return peripheral.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMethodNames() {
|
||||
return peripheral.getMethodNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
|
||||
return peripheral.callMethod(peripheral.getMethodNames()[method], arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach(IComputerAccess iComputerAccess) {}
|
||||
|
||||
@Override
|
||||
public void detach(IComputerAccess iComputerAccess) {}
|
||||
|
||||
@Override
|
||||
public boolean equals(IPeripheral iPeripheral) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
package com.brandon3055.draconicevolution.integration.computers.cc;
|
||||
|
||||
import com.brandon3055.draconicevolution.integration.computers.CCOCIntegration.CCAdapter;
|
||||
import com.brandon3055.draconicevolution.integration.computers.IDEPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Created by brandon3055 on 21/9/2015.
|
||||
*/
|
||||
public class DEPeripheralProvider implements IPeripheralProvider{
|
||||
|
||||
@Override
|
||||
public IPeripheral getPeripheral(World world, int x, int y, int z, int i3) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof IDEPeripheral) {
|
||||
return new CCAdapter((IDEPeripheral)tile);
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
+2
-15
@@ -4,16 +4,13 @@ import com.brandon3055.draconicevolution.integration.computers.IDEPeripheral;
|
||||
import li.cil.oc.api.driver.NamedBlock;
|
||||
import li.cil.oc.api.machine.Arguments;
|
||||
import li.cil.oc.api.machine.Context;
|
||||
import li.cil.oc.api.network.ManagedEnvironment;
|
||||
import li.cil.oc.api.network.ManagedPeripheral;
|
||||
import li.cil.oc.api.network.Message;
|
||||
import li.cil.oc.api.network.Node;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import li.cil.oc.api.prefab.ManagedEnvironment;
|
||||
|
||||
/**
|
||||
* Created by brandon3055 on 22/9/2015.
|
||||
*/
|
||||
public class DEManagedPeripheral implements ManagedPeripheral, ManagedEnvironment, NamedBlock{
|
||||
public class DEManagedPeripheral extends ManagedEnvironment implements ManagedPeripheral, NamedBlock{
|
||||
private IDEPeripheral peripheral;
|
||||
|
||||
public DEManagedPeripheral(IDEPeripheral peripheral){
|
||||
@@ -39,14 +36,4 @@ public class DEManagedPeripheral implements ManagedPeripheral, ManagedEnvironmen
|
||||
public int priority() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Unused Methods
|
||||
@Override public boolean canUpdate() { return false; }
|
||||
@Override public void update() {}
|
||||
@Override public Node node() {return null;}
|
||||
@Override public void onConnect(Node node) {}
|
||||
@Override public void onDisconnect(Node node) {}
|
||||
@Override public void onMessage(Message message) {}
|
||||
@Override public void load(NBTTagCompound nbtTagCompound) {}
|
||||
@Override public void save(NBTTagCompound nbtTagCompound) {}
|
||||
}
|
||||
Reference in new issue
Block a user