From ebd7ffc8270ad3bfb2d79396657bf8fc9d1ad5a6 Mon Sep 17 00:00:00 2001 From: Kellen Hurrey Date: Fri, 19 Sep 2025 10:51:32 -0600 Subject: [PATCH 1/3] Make RBMK slotted elements have OC accessible inventories, and added a OC outgasser function that allows seeing the item that is being processed. --- .../machine/rbmk/TileEntityRBMKOutgasser.java | 71 +++++++++++-------- .../rbmk/TileEntityRBMKSlottedBase.java | 22 ++++-- 2 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKOutgasser.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKOutgasser.java index e89f89680..37a6594b0 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKOutgasser.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKOutgasser.java @@ -46,26 +46,26 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement public String getName() { return "container.rbmkOutgasser"; } - + @Override public void updateEntity() { - + if(!worldObj.isRemote) { - + if(!canProcess()) { this.progress = 0; } - + for(DirPos pos : getOutputPos()) { if(this.gas.getFill() > 0) this.sendFluid(gas, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); } } - + super.updateEntity(); } - + protected DirPos[] getOutputPos() { - + if(worldObj.getBlock(xCoord, yCoord - 1, zCoord) == ModBlocks.rbmk_loader) { return new DirPos[] { new DirPos(this.xCoord, this.yCoord + RBMKDials.getColumnHeight(worldObj) + 1, this.zCoord, Library.POS_Y), @@ -94,30 +94,30 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement @Override public void receiveFlux(NeutronStream stream) { - + if(canProcess()) { double efficiency = Math.min(1 - stream.fluxRatio * 0.8, 1); progress += stream.fluxQuantity * efficiency * RBMKDials.getOutgasserMod(worldObj); - + if(progress > duration) { process(); this.markDirty(); } } } - + public boolean canProcess() { - + if(slots[0] == null) return false; - + Pair output = OutgasserRecipes.getOutput(slots[0]); - + if(output == null) return false; - + FluidStack fluid = output.getValue(); if(fluid != null) { @@ -125,27 +125,27 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement gas.setTankType(fluid.type); if(gas.getFill() + fluid.fill > gas.getMaxFill()) return false; } - + ItemStack out = output.getKey(); - + if(slots[1] == null || out == null) return true; - + return slots[1].getItem() == out.getItem() && slots[1].getItemDamage() == out.getItemDamage() && slots[1].stackSize + out.stackSize <= slots[1].getMaxStackSize(); } - + private void process() { - + Pair output = OutgasserRecipes.getOutput(slots[0]); this.decrStackSize(0, 1); this.progress = 0; - + if(output.getValue() != null) { gas.setFill(gas.getFill() + output.getValue().fill); } - + ItemStack out = output.getKey(); - + if(out != null) { if(slots[1] == null) { slots[1] = out.copy(); @@ -154,16 +154,16 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement } } } - + @Override public void onMelt(int reduce) { - + int count = 4 + worldObj.rand.nextInt(2); - + for(int i = 0; i < count; i++) { spawnDebris(DebrisType.BLANK); } - + super.onMelt(reduce); } @@ -186,19 +186,19 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement data.setDouble("progress", this.progress); return data; } - + @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - + this.progress = nbt.getDouble("progress"); this.gas.readFromNBT(nbt, "gas"); } - + @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - + nbt.setDouble("progress", this.progress); this.gas.writeToNBT(nbt, "gas"); } @@ -260,7 +260,7 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement public Object[] getGasMax(Context context, Arguments args) { return new Object[] {gas.getMaxFill()}; } - + @Callback(direct = true) @Optional.Method(modid = "OpenComputers") public Object[] getGasType(Context context, Arguments args) { @@ -273,6 +273,15 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement return new Object[] {progress}; } + @Callback(direct = true, doc = "Returns the unlocalized name and size of the stack that the outgasser is crafting (the input), or nil, nil if there is no stack") + @Optional.Method(modid = "OpenComputers") + public Object[] getCrafting(Context context, Arguments args) { + if (slots[0] == null) + return new Object[] { null, null }; + else + return new Object[]{slots[0].getUnlocalizedName(), slots[0].stackSize}; + } + @Callback(direct = true) @Optional.Method(modid = "OpenComputers") public Object[] getCoordinates(Context context, Arguments args) { diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKSlottedBase.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKSlottedBase.java index 27702f37a..579631439 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKSlottedBase.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKSlottedBase.java @@ -2,6 +2,7 @@ package com.hbm.tileentity.machine.rbmk; import com.hbm.tileentity.IGUIProvider; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -11,7 +12,7 @@ import net.minecraft.nbt.NBTTagList; * Base class for RBMK components that have GUI slots and thus have to handle * those things Yes it's a copy pasted MachineBase class, thank the lack of * multiple inheritance for that - * + * * @author hbm * */ @@ -87,6 +88,15 @@ public abstract class TileEntityRBMKSlottedBase extends TileEntityRBMKActiveBase return false; } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { + return false; + } else { + return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 128; + } + } + @Override public ItemStack decrStackSize(int slot, int amount) { if(slots[slot] != null) { @@ -124,10 +134,10 @@ public abstract class TileEntityRBMKSlottedBase extends TileEntityRBMKActiveBase @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - + if(!diag) { NBTTagList list = nbt.getTagList("items", 10); - + for(int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbt1 = list.getCompoundTagAt(i); byte b0 = nbt1.getByte("slot"); @@ -143,10 +153,10 @@ public abstract class TileEntityRBMKSlottedBase extends TileEntityRBMKActiveBase @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); - + if(!diag) { NBTTagList list = new NBTTagList(); - + for(int i = 0; i < slots.length; i++) { if(slots[i] != null) { NBTTagCompound nbt1 = new NBTTagCompound(); @@ -156,7 +166,7 @@ public abstract class TileEntityRBMKSlottedBase extends TileEntityRBMKActiveBase } } nbt.setTag("items", list); - + if (customName != null) { nbt.setString("name", customName); } From cf5bf4be8c0f2773f8b50579f698ffb0bce0c017 Mon Sep 17 00:00:00 2001 From: Kellen Hurrey Date: Fri, 19 Sep 2025 11:25:11 -0600 Subject: [PATCH 2/3] Added crafting data to getData and getColumnData, and made the OC pressAZ5 function play the cool sound --- .../machine/rbmk/TileEntityRBMKConsole.java | 17 +++++++++++++---- .../machine/rbmk/TileEntityRBMKOutgasser.java | 10 +++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKConsole.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKConsole.java index db38eed4b..6e5227b65 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKConsole.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKConsole.java @@ -23,14 +23,13 @@ import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; +import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; +import net.minecraft.util.*; import net.minecraft.world.World; import li.cil.oc.api.machine.Arguments; @@ -631,6 +630,15 @@ public class TileEntityRBMKConsole extends TileEntityMachineBase implements ICon TileEntityRBMKOutgasser irradiationChannel = (TileEntityRBMKOutgasser)te; data_table.put("fluxProgress", irradiationChannel.progress); data_table.put("requiredFlux", irradiationChannel.duration); + ItemStack input = irradiationChannel.getStackInSlot(0); + if (input != null){ + data_table.put("craftingName", input.getUnlocalizedName()); + data_table.put("craftingNumber", input.stackSize); + } + else { + data_table.put("craftingName", ""); + data_table.put("craftingNumber", 0); + } } if(te instanceof TileEntityRBMKHeater){ @@ -760,6 +768,7 @@ public class TileEntityRBMKConsole extends TileEntityMachineBase implements ICon @Callback(direct = true) @Optional.Method(modid = "OpenComputers") public Object[] pressAZ5(Context context, Arguments args) { + worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5,"hbm:block.shutdown",1.0F, 1.0F); boolean hasRods = false; for(int i = -7; i <= 7; i++) { for(int j = -7; j <= 7; j++) { diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKOutgasser.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKOutgasser.java index 37a6594b0..7dd0814db 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKOutgasser.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKOutgasser.java @@ -277,9 +277,9 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement @Optional.Method(modid = "OpenComputers") public Object[] getCrafting(Context context, Arguments args) { if (slots[0] == null) - return new Object[] { null, null }; + return new Object[] { "", 0 }; else - return new Object[]{slots[0].getUnlocalizedName(), slots[0].stackSize}; + return new Object[]{slots[0].getUnlocalizedName(), slots[0].stackSize }; } @Callback(direct = true) @@ -291,7 +291,11 @@ public class TileEntityRBMKOutgasser extends TileEntityRBMKSlottedBase implement @Callback(direct = true) @Optional.Method(modid = "OpenComputers") public Object[] getInfo(Context context, Arguments args) { - return new Object[] {gas.getFill(), gas.getMaxFill(), progress, gas.getTankType().getID(), xCoord, yCoord, zCoord}; + ItemStack input = slots[0]; + if (input != null) + return new Object[] {gas.getFill(), gas.getMaxFill(), progress, gas.getTankType().getID(), xCoord, yCoord, zCoord, input.getUnlocalizedName(), input.stackSize }; + else + return new Object[] {gas.getFill(), gas.getMaxFill(), progress, gas.getTankType().getID(), xCoord, yCoord, zCoord, "", 0 }; } @Override From 9f849e8c2d4043ac520b102880cb56dd3dd22e04 Mon Sep 17 00:00:00 2001 From: Kellen Hurrey Date: Fri, 19 Sep 2025 11:28:19 -0600 Subject: [PATCH 3/3] Removed unused import --- .../com/hbm/tileentity/machine/rbmk/TileEntityRBMKConsole.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKConsole.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKConsole.java index 6e5227b65..8770be8e4 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKConsole.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKConsole.java @@ -23,7 +23,6 @@ import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; -import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack;