mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-22 13:09:40 +00:00
Started CC&OC Integration
This commit is contained in:
1 parent
9aabf5f650
commit
58c4619cfc
10 files changed
+208
-10
No files matched your search
@@ -29,6 +29,7 @@ import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.rea
|
||||
import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.reactor.TileReactorStabilizer;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import com.brandon3055.draconicevolution.common.world.DraconicWorldGenerator;
|
||||
import com.brandon3055.draconicevolution.integration.computers.CCOCIntegration;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
@@ -37,6 +38,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import li.cil.oc.api.machine.Callback;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
@@ -97,6 +99,7 @@ public class CommonProxy {
|
||||
registerEntities();
|
||||
DETab.initialize();
|
||||
PotionHandler.init();
|
||||
CCOCIntegration.init();
|
||||
|
||||
LogHelper.info("Finished Initialization");
|
||||
}
|
||||
@@ -178,6 +181,7 @@ public class CommonProxy {
|
||||
GameRegistry.registerWorldGenerator(new DraconicWorldGenerator(), 0);
|
||||
}
|
||||
|
||||
@Callback
|
||||
public void registerEntities() {
|
||||
EntityRegistry.registerModEntity(EntityCustomDragon.class, "EnderDragon", 0, DraconicEvolution.instance, 256, 3, true);
|
||||
EntityRegistry.registerModEntity(EntityPersistentItem.class, "Persistent Item", 1, DraconicEvolution.instance, 32, 5, true);
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
/**
|
||||
* Created by Brandon on 5/7/2015.
|
||||
*/
|
||||
public class ReactorStabilizer extends BlockDE {
|
||||
public class ReactorStabilizer extends BlockDE{
|
||||
public ReactorStabilizer() {
|
||||
this.setCreativeTab(DraconicEvolution.tabBlocksItems);
|
||||
this.setBlockName("reactorStabilizer");
|
||||
|
||||
+22
-6
@@ -7,6 +7,8 @@ import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.render.particle.ParticleReactorBeam;
|
||||
import com.brandon3055.draconicevolution.common.blocks.multiblock.IReactorPart;
|
||||
import com.brandon3055.draconicevolution.common.blocks.multiblock.MultiblockHelper.TileLocation;
|
||||
import com.brandon3055.draconicevolution.common.utills.LogHelper;
|
||||
import com.brandon3055.draconicevolution.integration.computers.IDEPeripheral;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
@@ -15,10 +17,12 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Created by brandon3055 on 5/7/2015.
|
||||
*/
|
||||
public class TileReactorStabilizer extends TileEntity implements IReactorPart, IEnergyProvider{
|
||||
public class TileReactorStabilizer extends TileEntity implements IReactorPart, IEnergyProvider, IDEPeripheral {
|
||||
|
||||
public float coreRotation = 0F;
|
||||
public float ringRotation = 0F;
|
||||
@@ -205,9 +209,21 @@ public class TileReactorStabilizer extends TileEntity implements IReactorPart, I
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 40960.0D;
|
||||
}
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// @Override
|
||||
// public AxisAlignedBB getRenderBoundingBox() {
|
||||
// return INFINITE_EXTENT_AABB;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
LogHelper.info("name");
|
||||
return "draconic_reactor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getMethodNames() {
|
||||
return new String[] {"test1", "test2"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod(String method, Object... args) {
|
||||
LogHelper.info(method+" "+ Arrays.asList(args));
|
||||
return new Object[0];
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package com.brandon3055.draconicevolution.integration.computers;
|
||||
|
||||
import com.brandon3055.draconicevolution.integration.computers.cc.DEPeripheralProvider;
|
||||
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 li.cil.oc.api.Driver;
|
||||
import li.cil.oc.api.network.ManagedEnvironment;
|
||||
import li.cil.oc.api.prefab.DriverTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Created by brandon3055 on 21/9/2015.
|
||||
*/
|
||||
public class CCOCIntegration {
|
||||
|
||||
public static void init() {
|
||||
if (Loader.isModLoaded("ComputerCraft")) initCC();
|
||||
if (Loader.isModLoaded("OpenComputers")) initOC();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
public static void initCC() {
|
||||
ComputerCraftAPI.registerPeripheralProvider(new DEPeripheralProvider());
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public static void initOC() {
|
||||
Driver.add(new OCAdapter());
|
||||
}
|
||||
|
||||
public static class OCAdapter extends DriverTileEntity {
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return IDEPeripheral.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof IDEPeripheral) return new DEManagedPeripheral((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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.brandon3055.draconicevolution.integration.computers;
|
||||
|
||||
/**
|
||||
* Created by brandon3055 on 21/9/2015.
|
||||
*/
|
||||
public interface IDEPeripheral {
|
||||
|
||||
/**Get the unique name for this peripheral type */
|
||||
public String getName();
|
||||
|
||||
/**Get a list of methods for this peripheral*/
|
||||
public String[] getMethodNames();
|
||||
|
||||
/**Call a method*/
|
||||
public Object[] callMethod(String method, Object... args);
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.brandon3055.draconicevolution.integration.computers.oc;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Created by brandon3055 on 22/9/2015.
|
||||
*/
|
||||
public class DEManagedPeripheral implements ManagedPeripheral, ManagedEnvironment, NamedBlock{
|
||||
private IDEPeripheral peripheral;
|
||||
|
||||
public DEManagedPeripheral(IDEPeripheral peripheral){
|
||||
this.peripheral = peripheral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] methods() {
|
||||
return peripheral.getMethodNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] invoke(String method, Context context, Arguments args) throws Exception {
|
||||
return peripheral.callMethod(method, args.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String preferredName() {
|
||||
return "draconic_reactor";
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.brandon3055.draconicevolution.common.plugins.nei;
|
||||
package com.brandon3055.draconicevolution.integration.nei;
|
||||
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.nei.FastTransferManager;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.brandon3055.draconicevolution.common.plugins.nei;
|
||||
package com.brandon3055.draconicevolution.integration.nei;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.brandon3055.draconicevolution.common.plugins.nei;
|
||||
package com.brandon3055.draconicevolution.integration.nei;
|
||||
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
Reference in new issue
Block a user