Revamped some Opencomputers stuff

This commit is contained in:
BallOfEnergy1 2023-03-14 15:48:45 -05:00
parent ce0b31d536
commit edb94e966f
5 changed files with 100 additions and 40 deletions

View File

@ -361,6 +361,11 @@ public class TileEntityRBMKBoiler extends TileEntityRBMKSlottedBase implements I
return new Object[] {feed.getMaxFill()}; return new Object[] {feed.getMaxFill()};
} }
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getInfo(Context context, Arguments args) {
return new Object[] {heat, steam.getFill(), steam.getMaxFill(), feed.getFill(), feed.getMaxFill()};
}
@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 ContainerRBMKGeneric(player.inventory); return new ContainerRBMKGeneric(player.inventory);

View File

@ -147,6 +147,12 @@ public abstract class TileEntityRBMKControl extends TileEntityRBMKSlottedBase im
return new Object[] {heat}; return new Object[] {heat};
} }
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getInfo(Context context, Arguments args) {
return new Object[] {heat, getMult() * 100, targetLevel * 100};
}
@Callback @Callback
@Optional.Method(modid = "OpenComputers") @Optional.Method(modid = "OpenComputers")
public Object[] setLevel(Context context, Arguments args) { public Object[] setLevel(Context context, Arguments args) {

View File

@ -10,44 +10,51 @@ import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.lib.Library; import com.hbm.lib.Library;
import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKConsole.ColumnType;
import li.cil.oc.api.network.SimpleComponent;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
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 TileEntityRBMKCooler extends TileEntityRBMKBase implements IFluidAcceptor, IFluidStandardReceiver, SimpleComponent {
public class TileEntityRBMKCooler extends TileEntityRBMKBase implements IFluidAcceptor, IFluidStandardReceiver {
private FluidTank tank; private FluidTank tank;
private int lastCooled; private int lastCooled;
public TileEntityRBMKCooler() { public TileEntityRBMKCooler() {
super(); super();
this.tank = new FluidTank(Fluids.CRYOGEL, 8000, 0); this.tank = new FluidTank(Fluids.CRYOGEL, 8000, 0);
} }
@Override @Override
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if (!worldObj.isRemote) {
if(this.worldObj.getTotalWorldTime() % 20 == 0) if (this.worldObj.getTotalWorldTime() % 20 == 0)
this.trySubscribe(tank.getTankType(), worldObj, xCoord, yCoord - 1, zCoord, Library.NEG_Y); this.trySubscribe(tank.getTankType(), worldObj, xCoord, yCoord - 1, zCoord, Library.NEG_Y);
if((int)(this.heat) > 750) { if ((int) (this.heat) > 750) {
int heatProvided = (int)(this.heat - 750D); int heatProvided = (int) (this.heat - 750D);
int cooling = Math.min(heatProvided, tank.getFill()); int cooling = Math.min(heatProvided, tank.getFill());
this.heat -= cooling; this.heat -= cooling;
this.tank.setFill(this.tank.getFill() - cooling); this.tank.setFill(this.tank.getFill() - cooling);
this.lastCooled = cooling; this.lastCooled = cooling;
if(lastCooled > 0) { if (lastCooled > 0) {
List<Entity> entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 4, zCoord, xCoord + 1, yCoord + 8, zCoord + 1)); List<Entity> entities = worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 4, zCoord, xCoord + 1, yCoord + 8, zCoord + 1));
for(Entity e : entities) { for (Entity e : entities) {
e.setFire(5); e.setFire(5);
e.attackEntityFrom(DamageSource.inFire, 10); e.attackEntityFrom(DamageSource.inFire, 10);
} }
@ -55,44 +62,44 @@ public class TileEntityRBMKCooler extends TileEntityRBMKBase implements IFluidAc
} else { } else {
this.lastCooled = 0; this.lastCooled = 0;
} }
} else { } else {
if(this.lastCooled > 100) { if (this.lastCooled > 100) {
for(int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
worldObj.spawnParticle("flame", xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 4.5, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, 0, 0.2, 0); worldObj.spawnParticle("flame", xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 4.5, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, 0, 0.2, 0);
worldObj.spawnParticle("smoke", xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 4.5, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, 0, 0.2, 0); worldObj.spawnParticle("smoke", xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 4.5, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, 0, 0.2, 0);
} }
if(worldObj.rand.nextInt(20) == 0) if (worldObj.rand.nextInt(20) == 0)
worldObj.spawnParticle("lava", xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 4.5, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, 0, 0.0, 0); worldObj.spawnParticle("lava", xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 4.5, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, 0, 0.0, 0);
} else if(this.lastCooled > 50) { } else if (this.lastCooled > 50) {
for(int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
worldObj.spawnParticle("cloud", xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 4.5, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, worldObj.rand.nextGaussian() * 0.05, 0.2, worldObj.rand.nextGaussian() * 0.05); worldObj.spawnParticle("cloud", xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 4.5, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, worldObj.rand.nextGaussian() * 0.05, 0.2, worldObj.rand.nextGaussian() * 0.05);
} }
} else if(this.lastCooled > 0) { } else if (this.lastCooled > 0) {
if(worldObj.getTotalWorldTime() % 2 == 0) if (worldObj.getTotalWorldTime() % 2 == 0)
worldObj.spawnParticle("cloud", xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 4.5, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, 0, 0.2, 0); worldObj.spawnParticle("cloud", xCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, yCoord + 4.5, zCoord + 0.25 + worldObj.rand.nextDouble() * 0.5, 0, 0.2, 0);
} }
} }
super.updateEntity(); super.updateEntity();
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
tank.readFromNBT(nbt, "cryo"); tank.readFromNBT(nbt, "cryo");
this.lastCooled = nbt.getInteger("cooled"); this.lastCooled = nbt.getInteger("cooled");
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
tank.writeToNBT(nbt, "cryo"); tank.writeToNBT(nbt, "cryo");
nbt.setInteger("cooled", this.lastCooled); nbt.setInteger("cooled", this.lastCooled);
} }
@ -109,7 +116,7 @@ public class TileEntityRBMKCooler extends TileEntityRBMKBase implements IFluidAc
@Override @Override
public void setFluidFill(int fill, FluidType type) { public void setFluidFill(int fill, FluidType type) {
if(type == tank.getTankType()) if (type == tank.getTankType())
tank.setFill(fill); tank.setFill(fill);
} }
@ -130,12 +137,23 @@ public class TileEntityRBMKCooler extends TileEntityRBMKBase implements IFluidAc
@Override @Override
public FluidTank[] getAllTanks() { public FluidTank[] getAllTanks() {
return new FluidTank[] {tank}; return new FluidTank[]{tank};
} }
@Override @Override
public FluidTank[] getReceivingTanks() { public FluidTank[] getReceivingTanks() {
return new FluidTank[] {tank}; return new FluidTank[]{tank};
} }
//do some opencomputers stuff
public String getComponentName() {
return "rbmk_cooler";
}
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getInfo(Context context, Arguments args) {
return new Object[]{heat, tank.getMaxFill(), tank.getFill()};
}
} }

View File

@ -14,8 +14,13 @@ import com.hbm.util.Tuple.Pair;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.fluid.IFluidStandardSender; import api.hbm.fluid.IFluidStandardSender;
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.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
@ -23,7 +28,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implements IRBMKFluxReceiver, IFluidStandardSender { @Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implements IRBMKFluxReceiver, IFluidStandardSender, SimpleComponent {
public FluidTank gas; public FluidTank gas;
public double progress; public double progress;
@ -215,6 +221,17 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement
return new FluidTank[] {gas}; return new FluidTank[] {gas};
} }
//do some opencomputers stuff
@Override
public String getComponentName() {
return "rbmk_outgasser";
}
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getInfo(Context context, Arguments args) {
return new Object[] {gas.getFill(), gas.getMaxFill(), progress};
}
@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 ContainerRBMKOutgasser(player.inventory, this); return new ContainerRBMKOutgasser(player.inventory, this);

View File

@ -420,6 +420,20 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM
} }
return new Object[] {"N/A"}; return new Object[] {"N/A"};
} }
@Callback
@Optional.Method(modid = "OpenComputers")
public Object[] getInfo(Context context, Arguments args) {
Object OC_enrich_buf;
Object OC_poison_buf;
if(slots[0] != null && slots[0].getItem() instanceof ItemRBMKRod) {
OC_enrich_buf = ItemRBMKRod.getEnrichment(slots[0]);
OC_poison_buf = ItemRBMKRod.getPoison(slots[0]);
} else {
OC_enrich_buf = "N/A";
OC_poison_buf = "N/A";
}
return new Object[] {heat, fluxSlow, fluxFast, OC_enrich_buf, OC_poison_buf};
}
@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) {