mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #2443 from KellenHurrey/master
Some RBMK OC integration
This commit is contained in:
commit
7285867856
@ -25,12 +25,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
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 +629,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 +767,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++) {
|
||||
|
||||
@ -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<ItemStack, FluidStack> 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<ItemStack, FluidStack> 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[] { "", 0 };
|
||||
else
|
||||
return new Object[]{slots[0].getUnlocalizedName(), slots[0].stackSize };
|
||||
}
|
||||
|
||||
@Callback(direct = true)
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] getCoordinates(Context context, Arguments args) {
|
||||
@ -282,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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user