Initial work on open computers support, more to come in the future.
When things are a bit more final with it, I will add some docs onto the wiki pages.
This commit is contained in:
parent
f7008d9c87
commit
2180fe4ef2
4 changed files with 119 additions and 0 deletions
|
@ -78,6 +78,10 @@ repositories {
|
|||
name "BuildCraft"
|
||||
artifactPattern "http://www.mod-buildcraft.com/releases/BuildCraft/[revision]/[module]-[revision].[ext]"
|
||||
}
|
||||
maven {
|
||||
name "OpenComputer"
|
||||
url "http://maven.cil.li/"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
@ -126,6 +130,7 @@ dependencies {
|
|||
deobfCompile 'cofh:ThermalDynamics:1.12.2-2.3.9.3:universal', withoutOldJEI
|
||||
deobfCompile 'cofh:ThermalExpansion:1.12.2-5.3.9.9:universal', withoutOldJEI
|
||||
deobfCompile 'MCMultiPart2:MCMultiPart:2.4.1'
|
||||
deobfCompile "li.cil.oc:OpenComputers:MC1.12.1-1.7.1+"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import techreborn.compat.buildcraft.BuildcraftBuildersCompat;
|
|||
import techreborn.compat.buildcraft.BuildcraftCompat;
|
||||
import techreborn.compat.crafttweaker.CraftTweakerCompat;
|
||||
import techreborn.compat.ic2.RecipesIC2;
|
||||
import techreborn.compat.opencomputers.CompatOpenComputers;
|
||||
import techreborn.compat.theoneprobe.TheOneProbeCompat;
|
||||
import techreborn.compat.thermalexpansion.RecipeThermalExpansion;
|
||||
import techreborn.compat.tinkers.CompatModuleTinkers;
|
||||
|
@ -62,6 +63,7 @@ public class CompatManager {
|
|||
register(BuildcraftBuildersCompat.class, "buildcraftbuilders");
|
||||
register(BuildcraftCompat.class, "buildcraftcore");
|
||||
register(RecipeThermalExpansion.class, "thermalexpansion");
|
||||
register(CompatOpenComputers.class, "opencomputers");
|
||||
}
|
||||
|
||||
public void register(Class<? extends ICompatModule> moduleClass, Object... objs) {
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package techreborn.compat.opencomputers;
|
||||
|
||||
import li.cil.oc.api.Driver;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import techreborn.compat.ICompatModule;
|
||||
|
||||
public class CompatOpenComputers implements ICompatModule {
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
Driver.add(new DriverMachine());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package techreborn.compat.opencomputers;
|
||||
|
||||
import li.cil.oc.api.Network;
|
||||
import li.cil.oc.api.driver.DriverBlock;
|
||||
import li.cil.oc.api.driver.NamedBlock;
|
||||
import li.cil.oc.api.machine.Arguments;
|
||||
import li.cil.oc.api.machine.Callback;
|
||||
import li.cil.oc.api.machine.Context;
|
||||
import li.cil.oc.api.network.ManagedEnvironment;
|
||||
import li.cil.oc.api.network.Visibility;
|
||||
import li.cil.oc.api.prefab.AbstractManagedEnvironment;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
|
||||
public class DriverMachine implements DriverBlock {
|
||||
@Override
|
||||
public boolean worksWith(World world, BlockPos blockPos, EnumFacing enumFacing) {
|
||||
return world.getTileEntity(blockPos) instanceof TilePowerAcceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedEnvironment createEnvironment(World world, BlockPos blockPos, EnumFacing enumFacing) {
|
||||
return new MachineEnvironment((TilePowerAcceptor) world.getTileEntity(blockPos));
|
||||
}
|
||||
|
||||
public static class MachineEnvironment extends AbstractManagedEnvironment implements NamedBlock {
|
||||
TilePowerAcceptor machine;
|
||||
|
||||
public MachineEnvironment(TilePowerAcceptor machine) {
|
||||
this.machine = machine;
|
||||
setNode(Network.newNode(this, Visibility.Network).withComponent("tr_machine", Visibility.Network).create());
|
||||
}
|
||||
|
||||
@Callback(value = "getTeir", getter = true, doc = "Gets the current teir of the machine, this changes with upgrades")
|
||||
public Object[] getTeir(Context context, Arguments arguments) throws Exception {
|
||||
return getObjects(machine.getTier().name());
|
||||
}
|
||||
|
||||
@Callback(value = "getEnergy", getter = true, doc = "Gets the currentally stored energy of the machine. in EU")
|
||||
public Object[] getEnergy(Context context, Arguments arguments) throws Exception {
|
||||
return getObjects(machine.getEnergy());
|
||||
}
|
||||
|
||||
|
||||
@Callback(value = "getMaxPower", getter = true, doc = "Gets the maximum energy that can be stored in the machine. in EU")
|
||||
public Object[] getMaxPower(Context context, Arguments arguments) throws Exception {
|
||||
return getObjects(machine.getMaxPower());
|
||||
}
|
||||
|
||||
@Callback(value = "getMaxInput", getter = true, doc = "Gets the maximum energy that can be inputted in to the machine. in EU")
|
||||
public Object[] getMaxInput(Context context, Arguments arguments) throws Exception {
|
||||
return getObjects(machine.getMaxInput());
|
||||
}
|
||||
|
||||
@Callback(value = "getMaxOutput", getter = true, doc = "Gets the maximum energy that can be extracted from the machine. in EU")
|
||||
public Object[] getMaxOutput(Context context, Arguments arguments) throws Exception {
|
||||
return getObjects(machine.getMaxOutput());
|
||||
}
|
||||
|
||||
@Callback(value = "canBeUprgaded", getter = true, doc = "Returns true if the machine can be upgraded")
|
||||
public Object[] canBeUprgaded(Context context, Arguments arguments) throws Exception {
|
||||
return getObjects(machine instanceof IUpgradeable && machine.canBeUpgraded());
|
||||
}
|
||||
|
||||
private Object[] getObjects(Object... objects){
|
||||
return objects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String preferredName() {
|
||||
return "tr_machine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int priority() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue