mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #885 from Voxelstice/its-oc-again
Some more changes with OpenComputers integration
This commit is contained in:
commit
5a1fa78350
@ -19,7 +19,19 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityLaunchPad extends TileEntityLoadedBase implements ISidedInventory, IEnergyUser {
|
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 api.hbm.item.IDesignatorItem;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import com.hbm.blocks.ModBlocks;
|
||||||
|
import com.hbm.blocks.bomb.LaunchPad;
|
||||||
|
|
||||||
|
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
||||||
|
public class TileEntityLaunchPad extends TileEntityLoadedBase implements ISidedInventory, IEnergyUser, SimpleComponent {
|
||||||
|
|
||||||
public ItemStack slots[];
|
public ItemStack slots[];
|
||||||
|
|
||||||
@ -30,7 +42,6 @@ public class TileEntityLaunchPad extends TileEntityLoadedBase implements ISidedI
|
|||||||
private static final int[] slots_bottom = new int[] { 0, 1, 2};
|
private static final int[] slots_bottom = new int[] { 0, 1, 2};
|
||||||
private static final int[] slots_side = new int[] {0};
|
private static final int[] slots_side = new int[] {0};
|
||||||
public int state = 0;
|
public int state = 0;
|
||||||
|
|
||||||
private String customName;
|
private String customName;
|
||||||
|
|
||||||
public TileEntityLaunchPad() {
|
public TileEntityLaunchPad() {
|
||||||
@ -256,4 +267,57 @@ public class TileEntityLaunchPad extends TileEntityLoadedBase implements ISidedI
|
|||||||
{
|
{
|
||||||
return 65536.0D;
|
return 65536.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do some opencomputer stuff
|
||||||
|
@Override
|
||||||
|
public String getComponentName() {
|
||||||
|
return "launch_pad";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getEnergyStored(Context context, Arguments args) {
|
||||||
|
return new Object[] {getPower()};
|
||||||
|
}
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getMaxEnergy(Context context, Arguments args) {
|
||||||
|
return new Object[] {getMaxPower()};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getCoords(Context context, Arguments args) {
|
||||||
|
if (slots[1] != null && slots[1].getItem() instanceof IDesignatorItem) {
|
||||||
|
int xCoord2 = slots[1].stackTagCompound.getInteger("xCoord");
|
||||||
|
int zCoord2 = slots[1].stackTagCompound.getInteger("zCoord");
|
||||||
|
|
||||||
|
// Not sure if i should have this
|
||||||
|
if(xCoord2 == xCoord && zCoord2 == zCoord) {
|
||||||
|
xCoord2 += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Object[] {xCoord2, zCoord2};
|
||||||
|
}
|
||||||
|
return new Object[] {"Designator not found"};
|
||||||
|
}
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] setCoords(Context context, Arguments args) {
|
||||||
|
if (slots[1] != null && slots[1].getItem() instanceof IDesignatorItem) {
|
||||||
|
slots[1].stackTagCompound.setInteger("xCoord", args.checkInteger(0));
|
||||||
|
slots[1].stackTagCompound.setInteger("zCoord", args.checkInteger(1));
|
||||||
|
|
||||||
|
return new Object[] {"Success"};
|
||||||
|
}
|
||||||
|
return new Object[] {"Designator not found"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] launch(Context context, Arguments args) {
|
||||||
|
//worldObj.getBlock(xCoord, yCoord, zCoord).explode(worldObj, xCoord, yCoord, zCoord);
|
||||||
|
((LaunchPad) ModBlocks.launch_pad).explode(worldObj, xCoord, yCoord, zCoord);
|
||||||
|
return new Object[] {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -339,16 +339,18 @@ public class TileEntityCoreEmitter extends TileEntityMachineBase implements IEne
|
|||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] setActive(Context context, Arguments args) {
|
public Object[] setActive(Context context, Arguments args) {
|
||||||
isOn = Boolean.parseBoolean(args.checkString(0));
|
isOn = args.checkBoolean(0);
|
||||||
return new Object[] {};
|
return new Object[] {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] setInput(Context context, Arguments args) {
|
public Object[] setInput(Context context, Arguments args) {
|
||||||
int newOutput = Integer.parseInt(args.checkString(0));
|
int newOutput = args.checkInteger(0);
|
||||||
if (newOutput > 100) {
|
if (newOutput > 100) {
|
||||||
newOutput = 100;
|
newOutput = 100;
|
||||||
|
} else if (newOutput < 0) {
|
||||||
|
newOutput = 0;
|
||||||
}
|
}
|
||||||
watts = newOutput;
|
watts = newOutput;
|
||||||
return new Object[] {};
|
return new Object[] {};
|
||||||
|
|||||||
@ -197,9 +197,11 @@ public class TileEntityCoreStabilizer extends TileEntityMachineBase implements I
|
|||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] setInput(Context context, Arguments args) {
|
public Object[] setInput(Context context, Arguments args) {
|
||||||
int newOutput = Integer.parseInt(args.checkString(0));
|
int newOutput = args.checkInteger(0);
|
||||||
if (newOutput > 100) {
|
if (newOutput > 100) {
|
||||||
newOutput = 100;
|
newOutput = 100;
|
||||||
|
} else if (newOutput < 0) {
|
||||||
|
newOutput = 0;
|
||||||
}
|
}
|
||||||
watts = newOutput;
|
watts = newOutput;
|
||||||
return new Object[] {};
|
return new Object[] {};
|
||||||
|
|||||||
@ -413,9 +413,11 @@ public class TileEntityReactorResearch extends TileEntityMachineBase implements
|
|||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] setLevel(Context context, Arguments args) {
|
public Object[] setLevel(Context context, Arguments args) {
|
||||||
double newLevel = Double.parseDouble(args.checkString(0))/100.0;
|
double newLevel = args.checkDouble(0)/100.0;
|
||||||
if (newLevel > 1) { // check if its above 100 so the control rod wont do funny things
|
if (newLevel > 1.0) {
|
||||||
newLevel = 1;
|
newLevel = 1.0;
|
||||||
|
} else if (newLevel < 0.0) {
|
||||||
|
newLevel = 0.0;
|
||||||
}
|
}
|
||||||
targetLevel = newLevel;
|
targetLevel = newLevel;
|
||||||
return new Object[] {};
|
return new Object[] {};
|
||||||
|
|||||||
@ -578,7 +578,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IF
|
|||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] setActive(Context context, Arguments args) {
|
public Object[] setActive(Context context, Arguments args) {
|
||||||
isOn = Boolean.parseBoolean(args.checkString(0));
|
isOn = args.checkBoolean(0);
|
||||||
return new Object[] {};
|
return new Object[] {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,14 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
|
|
||||||
public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements IFluidAcceptor, IFluidSource, IControlReceiver, IFluidStandardTransceiver {
|
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;
|
||||||
|
|
||||||
|
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
||||||
|
public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements IFluidAcceptor, IFluidSource, IControlReceiver, IFluidStandardTransceiver, SimpleComponent {
|
||||||
|
|
||||||
public FluidTank feed;
|
public FluidTank feed;
|
||||||
public FluidTank steam;
|
public FluidTank steam;
|
||||||
@ -314,4 +321,38 @@ public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements I
|
|||||||
public FluidTank[] getReceivingTanks() {
|
public FluidTank[] getReceivingTanks() {
|
||||||
return new FluidTank[] {feed};
|
return new FluidTank[] {feed};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do some opencomputer stuff
|
||||||
|
@Override
|
||||||
|
public String getComponentName() {
|
||||||
|
return "rbmk_boiler";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getHeat(Context context, Arguments args) {
|
||||||
|
return new Object[] {heat};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getSteam(Context context, Arguments args) {
|
||||||
|
return new Object[] {steam.getFill()};
|
||||||
|
}
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getSteamMax(Context context, Arguments args) {
|
||||||
|
return new Object[] {steam.getMaxFill()};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getWater(Context context, Arguments args) {
|
||||||
|
return new Object[] {feed.getFill()};
|
||||||
|
}
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getWaterMax(Context context, Arguments args) {
|
||||||
|
return new Object[] {feed.getMaxFill()};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,13 +131,13 @@ public abstract class TileEntityRBMKControl extends TileEntityRBMKSlottedBase im
|
|||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] getLevel(Context context, Arguments args) {
|
public Object[] getLevel(Context context, Arguments args) {
|
||||||
return new Object[] {getMult()};
|
return new Object[] {getMult() * 100};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] getTargetLevel(Context context, Arguments args) {
|
public Object[] getTargetLevel(Context context, Arguments args) {
|
||||||
return new Object[] {targetLevel};
|
return new Object[] {targetLevel * 100};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,10 +150,12 @@ public abstract class TileEntityRBMKControl extends TileEntityRBMKSlottedBase im
|
|||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] setLevel(Context context, Arguments args) {
|
public Object[] setLevel(Context context, Arguments args) {
|
||||||
double newLevel = Double.parseDouble(args.checkString(0))/100.0;
|
double newLevel = args.checkDouble(0)/100.0;
|
||||||
if (newLevel > 1) { // check if its above 100 so the control rod wont do funny things
|
if (newLevel > 1.0) {
|
||||||
newLevel = 1;
|
newLevel = 1.0;
|
||||||
}
|
} else if (newLevel < 0.0) {
|
||||||
|
newLevel = 0.0;
|
||||||
|
}
|
||||||
targetLevel = newLevel;
|
targetLevel = newLevel;
|
||||||
return new Object[] {};
|
return new Object[] {};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user