More Opencomputers compatibility!

:woo:
This commit is contained in:
BallOfEnergy 2023-08-26 03:47:34 -05:00
parent 6b62d7c295
commit f3c27c02e5
9 changed files with 101 additions and 96 deletions

View File

@ -279,17 +279,6 @@ public class TileEntityLaunchPad extends TileEntityLoadedBase implements ISidedI
return "launch_pad"; return "launch_pad";
} }
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getEnergyStored(Context context, Arguments args) {
return new Object[] {getPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getMaxEnergy(Context context, Arguments args) {
return new Object[] {getMaxPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback @Callback
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] getEnergyInfo(Context context, Arguments args) { public Object[] getEnergyInfo(Context context, Arguments args) {

View File

@ -611,18 +611,6 @@ public class TileEntityLaunchTable extends TileEntityLoadedBase implements ISide
return "large_launch_pad"; return "large_launch_pad";
} }
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getEnergyStored(Context context, Arguments args) {
return new Object[] {getPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getMaxEnergy(Context context, Arguments args) {
return new Object[] {getMaxPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback @Callback
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] getEnergyInfo(Context context, Arguments args) { public Object[] getEnergyInfo(Context context, Arguments args) {

View File

@ -279,18 +279,6 @@ public class TileEntityCoreEmitter extends TileEntityMachineBase implements IEne
return "dfc_emitter"; return "dfc_emitter";
} }
@Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers")
public Object[] getEnergyStored(Context context, Arguments args) {
return new Object[] {getPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers")
public Object[] getMaxEnergy(Context context, Arguments args) {
return new Object[] {getMaxPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback(direct = true, limit = 4) @Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] getEnergyInfo(Context context, Arguments args) { public Object[] getEnergyInfo(Context context, Arguments args) {

View File

@ -191,18 +191,6 @@ public class TileEntityCoreReceiver extends TileEntityMachineBase implements IEn
return "dfc_receiver"; return "dfc_receiver";
} }
@Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers")
public Object[] getInput(Context context, Arguments args) {
return new Object[] {joules, "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers")
public Object[] getOutput(Context context, Arguments args) {
return new Object[] {getPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback(direct = true, limit = 4) @Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] getEnergyInfo(Context context, Arguments args) { public Object[] getEnergyInfo(Context context, Arguments args) {

View File

@ -172,18 +172,6 @@ public class TileEntityCoreStabilizer extends TileEntityMachineBase implements I
return "dfc_stabilizer"; return "dfc_stabilizer";
} }
@Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers")
public Object[] getEnergyStored(Context context, Arguments args) {
return new Object[] {getPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers")
public Object[] getMaxEnergy(Context context, Arguments args) {
return new Object[] {getMaxPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback(direct = true, limit = 4) @Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] getEnergyInfo(Context context, Arguments args) { public Object[] getEnergyInfo(Context context, Arguments args) {

View File

@ -298,32 +298,41 @@ public class TileEntityMachineRadar extends TileEntityTickingBase implements IEn
return "ntm_radar"; return "ntm_radar";
} }
@Callback @Callback(direct = true, limit = 8)
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] getPower(Context context, Arguments args) { public Object[] getEnergyInfo(Context context, Arguments args) {
return new Object[] {power}; return new Object[] {getPower(), getMaxPower()};
} }
@Callback @Callback(direct = true, limit = 8)
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] isJammed(Context context, Arguments args) { public Object[] isJammed(Context context, Arguments args) {
return new Object[] {jammed}; return new Object[] {jammed};
} }
@Callback @Callback(direct = true, limit = 8)
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] getEntities(Context context, Arguments args) { public Object[] getEntities(Context context, Arguments args) { //fuck fuck fuck
int index = args.checkInteger(0); if(!jammed) {
boolean raw = args.checkBoolean(1); List<Object> list = new ArrayList();
if(!raw && !jammed) { list.add(entList.size()); // small header of how many entities in the list
Entity e = entList.get(index); for (Entity e : entList) {
double a = (e.posX); list.add(e.posX); // positions
double b = (e.posY); list.add(e.posY);
double c = (e.posZ); list.add(e.posZ);
boolean d = (e instanceof EntityPlayer); list.add(e.motionX);
return new Object[] {a, b, c, d}; list.add(e.motionY);
} else if (!jammed) { list.add(e.motionZ);
return new Object[] {entList}; list.add(e.rotationYaw); // just do rotation so you can calculate DOT
list.add(Math.sqrt(Math.pow(e.posX - xCoord, 2) + Math.pow(e.posZ - zCoord, 2))); // distance
boolean player = e instanceof EntityPlayer;
list.add(player); // isPlayer boolean
if(!player) // missile tier
list.add(((IRadarDetectable) e).getTargetType().ordinal());
else // player name (hopefully)
list.add(((EntityPlayer) e).getDisplayName());
}
return new Object[] {list}; // long-ass list (like 9 entries per entity)
} else { } else {
return new Object[] {"Radar jammed!"}; return new Object[] {"Radar jammed!"};
} }

View File

@ -2,6 +2,7 @@ package com.hbm.tileentity.machine;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.ReactorResearch; import com.hbm.blocks.machine.ReactorResearch;
import com.hbm.handler.CompatHandler;
import com.hbm.interfaces.IControlReceiver; import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.container.ContainerReactorControl; import com.hbm.inventory.container.ContainerReactorControl;
import com.hbm.inventory.gui.GUIReactorControl; import com.hbm.inventory.gui.GUIReactorControl;
@ -9,8 +10,13 @@ import com.hbm.items.ModItems;
import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.tileentity.TileEntityMachineBase;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
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 net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -23,7 +29,8 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
public class TileEntityReactorControl extends TileEntityMachineBase implements IControlReceiver, IGUIProvider { @Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityReactorControl extends TileEntityMachineBase implements IControlReceiver, IGUIProvider, SimpleComponent {
public TileEntityReactorControl() { public TileEntityReactorControl() {
super(1); super(1);
@ -244,6 +251,67 @@ public class TileEntityReactorControl extends TileEntityMachineBase implements I
LOG LOG
} }
// do some opencomputer stuff
@Override
public String getComponentName() {
return "research_reactor_control";
}
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] isLinked(Context context, Arguments args) {
return new Object[] {isLinked};
}
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getReactor(Context context, Arguments args) {
return new Object[] {getDisplayData()};
}
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] setParams(Context context, Arguments args) { //i hate my life
int newFunction = args.checkInteger(0);
double newMaxheat = args.checkDouble(1);
double newMinheat = args.checkDouble(2);
double newMaxlevel = args.checkDouble(3)/100.0;
double newMinlevel = args.checkDouble(4)/100.0;
if (newFunction > 2) { //no more out of bounds for you (and yes there's integer values for functions, sue me)
newFunction = 0;
} else if (newFunction < 0) {
newFunction = 0;
}
if (newMaxheat < 0.0) {
newMaxheat = 0.0;
}
if (newMinheat < 0.0) {
newMinheat = 0.0;
}
if (newMaxlevel < 0.0) {
newMaxlevel = 0.0;
} else if (newMaxlevel > 1.0) {
newMaxlevel = 1.0;
}
if (newMinlevel < 0.0) {
newMinlevel = 0.0;
} else if (newMinlevel > 1.0) {
newMinlevel = 1.0;
}
function = RodFunction.values()[newFunction];
heatUpper = newMaxheat;
heatLower = newMinheat;
levelUpper = newMaxlevel;
levelLower = newMinlevel;
return new Object[] {};
}
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getParams(Context context, Arguments args) {
return new Object[] {function.ordinal(), heatUpper, heatLower, levelUpper, levelLower};
}
@Override @Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerReactorControl(player.inventory, this); return new ContainerReactorControl(player.inventory, this);

View File

@ -342,9 +342,8 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece
@Callback(direct = true, limit = 4) @Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] move(Context context, Arguments args) { public Object[] move(Context context, Arguments args) {
if(setUpCrane == true) { if(setUpCrane) {
String textbruh = args.checkString(0); String textbruh = args.checkString(0);
switch(textbruh) { switch(textbruh) {
case "up": case "up":
tiltFront = 30; tiltFront = 30;
@ -372,7 +371,7 @@ public class TileEntityCraneConsole extends TileEntity implements INBTPacketRece
@Callback(direct = true, limit = 4) @Callback(direct = true, limit = 4)
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] load(Context context, Arguments args) { public Object[] load(Context context, Arguments args) {
if (setUpCrane == true) { if (setUpCrane) {
goesDown = true; goesDown = true;
return new Object[] {}; return new Object[] {};
} }

View File

@ -395,18 +395,6 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
return "ntm_energy_storage"; //ok if someone else can figure out how to do this that'd be nice (change the component name based on the type of storage block) return "ntm_energy_storage"; //ok if someone else can figure out how to do this that'd be nice (change the component name based on the type of storage block)
} }
@Callback(direct = true, limit = 8)
@Optional.Method(modid = "OpenComputers")
public Object[] getEnergyStored(Context context, Arguments args) { //TODO for gamma: when ready remove these deprecated functions in all components
return new Object[] {getPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback(direct = true, limit = 8)
@Optional.Method(modid = "OpenComputers")
public Object[] getMaxEnergy(Context context, Arguments args) {
return new Object[] {getMaxPower(), "Consider switching to the main function 'getEnergyInfo', as this function is deprecated and will soon be removed."};
}
@Callback(direct = true, limit = 8) @Callback(direct = true, limit = 8)
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] getEnergyInfo(Context context, Arguments args) { public Object[] getEnergyInfo(Context context, Arguments args) {