mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #2295 from PewPewCricket/master
Add OpenComputers compat for fluid pump and fix CCGT allowing throttle over max when using OpenComputers callbacks
This commit is contained in:
commit
85bef7672e
@ -3,6 +3,12 @@ package com.hbm.blocks.network;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hbm.handler.CompatHandler;
|
||||||
|
import cpw.mods.fml.common.Optional;
|
||||||
|
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.SimpleComponent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import com.hbm.blocks.ILookOverlay;
|
import com.hbm.blocks.ILookOverlay;
|
||||||
@ -124,7 +130,8 @@ public class FluidPump extends BlockContainer implements INBTTransformable, ILoo
|
|||||||
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
|
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TileEntityFluidPump extends TileEntityLoadedBase implements IFluidStandardTransceiverMK2, IControlReceiver {
|
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
||||||
|
public static class TileEntityFluidPump extends TileEntityLoadedBase implements IFluidStandardTransceiverMK2, IControlReceiver, SimpleComponent, CompatHandler.OCComponent {
|
||||||
|
|
||||||
public int bufferSize = 100;
|
public int bufferSize = 100;
|
||||||
public FluidTank[] tank;
|
public FluidTank[] tank;
|
||||||
@ -217,6 +224,126 @@ public class FluidPump extends BlockContainer implements INBTTransformable, ILoo
|
|||||||
|
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public String getComponentName() {
|
||||||
|
return "ntm_fluid_pump";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 4)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getFluid(Context context, Arguments args) {
|
||||||
|
return new Object[] {
|
||||||
|
tank[0].getTankType().getUnlocalizedName()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 4)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getPressure(Context context, Arguments args) {
|
||||||
|
return new Object[] {
|
||||||
|
tank[0].getPressure()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 4)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getFlow(Context context, Arguments args) {
|
||||||
|
return new Object[] {
|
||||||
|
bufferSize
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 4)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getPriority(Context context, Arguments args) {
|
||||||
|
return new Object[] {
|
||||||
|
getFluidPriority()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 4)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getInfo(Context context, Arguments args) {
|
||||||
|
return new Object[] {
|
||||||
|
tank[0].getTankType().getUnlocalizedName(),
|
||||||
|
tank[0].getPressure(),
|
||||||
|
bufferSize,
|
||||||
|
getFluidPriority()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 4)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] setPriority(Context context, Arguments args) {
|
||||||
|
int num = args.checkInteger(0);
|
||||||
|
switch (num) {
|
||||||
|
case 0:
|
||||||
|
priority = ConnectionPriority.LOWEST;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
priority = ConnectionPriority.LOW;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
priority = ConnectionPriority.NORMAL;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
priority = ConnectionPriority.HIGH;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
priority = ConnectionPriority.HIGHEST;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return new Object[] {null, "Not a valid Priority."};
|
||||||
|
}
|
||||||
|
return new Object[] {true};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true, limit = 4)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] setFlow(Context context, Arguments args) {
|
||||||
|
int input = args.checkInteger(0);
|
||||||
|
if (input > 10000 || input < 0)
|
||||||
|
return new Object[] {null, "Number outside of bounds."};
|
||||||
|
return new Object[] {true};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public String[] methods() {
|
||||||
|
return new String[] {
|
||||||
|
"getPriority",
|
||||||
|
"getPressure",
|
||||||
|
"getFluid",
|
||||||
|
"getFlow",
|
||||||
|
"getInfo",
|
||||||
|
"setPriority",
|
||||||
|
"setFlow"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] invoke(String method, Context context, Arguments args) throws Exception {
|
||||||
|
switch (method) {
|
||||||
|
case ("getPriority"):
|
||||||
|
return getPriority(context, args);
|
||||||
|
case ("getPressure"):
|
||||||
|
return getPressure(context, args);
|
||||||
|
case ("getFluid"):
|
||||||
|
return getFluid(context, args);
|
||||||
|
case ("getFlow"):
|
||||||
|
return getFlow(context, args);
|
||||||
|
case ("getInfo"):
|
||||||
|
return getInfo(context, args);
|
||||||
|
case ("setPriority"):
|
||||||
|
return setPriority(context, args);
|
||||||
|
case ("setFlow"):
|
||||||
|
return setFlow(context, args);
|
||||||
|
}
|
||||||
|
throw new NoSuchMethodException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GUIPump extends GuiScreen {
|
public static class GUIPump extends GuiScreen {
|
||||||
|
|||||||
@ -619,8 +619,11 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement
|
|||||||
@Callback(direct = true, limit = 4)
|
@Callback(direct = true, limit = 4)
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] setThrottle(Context context, Arguments args) {
|
public Object[] setThrottle(Context context, Arguments args) {
|
||||||
powerSliderPos = (int) (args.checkInteger(0) * 60D / 100D);
|
double input = args.checkInteger(0) * 60D / 100D;
|
||||||
return new Object[] {};
|
if (input < 0 || input > 100)
|
||||||
|
return new Object[] {null, "Input out of range."};
|
||||||
|
powerSliderPos = (int) (input);
|
||||||
|
return new Object[] {true};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(direct = true, limit = 4)
|
@Callback(direct = true, limit = 4)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user