Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beamline fixes 5 #3822

Merged
merged 10 commits into from
Jan 18, 2025
29 changes: 13 additions & 16 deletions src/main/java/gtnhlanth/common/tileentity/MTELINAC.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gtnhlanth.common.tileentity;

import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel;
import static gregtech.api.enums.GTValues.VN;
import static gregtech.api.enums.HatchElement.Energy;
import static gregtech.api.enums.HatchElement.InputHatch;
Expand Down Expand Up @@ -116,12 +117,14 @@ public class MTELINAC extends MTEEnhancedMultiBlockBase<MTELINAC> implements ISu
.addElement('g', ofBlock(GregTechAPI.sBlockCasings3, 10)) // Grate Machine Casing
.addElement(
'b',
BorosilicateGlass.ofBoroGlass(
(byte) 0,
MIN_GLASS_TIER,
Byte.MAX_VALUE,
(te, t) -> te.glassTier = t,
te -> te.glassTier))
withChannel(
"glass",
BorosilicateGlass.ofBoroGlass(
(byte) 0,
MIN_GLASS_TIER,
Byte.MAX_VALUE,
(te, t) -> te.glassTier = t,
te -> te.glassTier)))
.addElement(
'i',
buildHatchAdder(MTELINAC.class).hatchClass(MTEHatchInputBeamline.class)
Expand Down Expand Up @@ -323,16 +326,10 @@ public CheckRecipeResult checkProcessing() {
// Particle stays the same with this multiblock
outputParticle = particleId;

if (primFluid.isFluidEqual(new FluidStack(FluidRegistry.getFluid("ic2coolant"), 1))) {
tempFactor = calculateTemperatureFactor(60); // Default temp of 300 is unreasonable
machineTemp = 60; // Solely for tricorder use
} else {
tempFactor = calculateTemperatureFactor(
primFluid.getFluid()
.getTemperature());
machineTemp = primFluid.getFluid()
.getTemperature(); // Solely for tricorder use
}
int coolantTemperature = Util.coolantFluidTemperature(primFluid);

tempFactor = calculateTemperatureFactor(coolantTemperature);
machineTemp = coolantTemperature; // Solely for tricorder use

machineFocus = Math.max(((-0.9f) * this.length * tempFactor) + 110, 5); // Min of 5
if (machineFocus > 90) { // Max of 90
Expand Down
55 changes: 27 additions & 28 deletions src/main/java/gtnhlanth/common/tileentity/MTESynchrotron.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gtnhlanth.common.tileentity;

import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAdder;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel;
import static gregtech.api.enums.GTValues.VN;
import static gregtech.api.enums.HatchElement.Energy;
import static gregtech.api.enums.HatchElement.ExoticEnergy;
Expand All @@ -17,6 +17,7 @@
import static gtnhlanth.util.DescTextLocalization.addDotText;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Objects;

import net.minecraft.block.Block;
Expand All @@ -28,13 +29,16 @@
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;

import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import com.gtnewhorizon.structurelib.structure.StructureUtility;

import bartworks.API.BorosilicateGlass;
import gregtech.api.GregTechAPI;
Expand Down Expand Up @@ -80,6 +84,8 @@ public class MTESynchrotron extends MTEExtendedPowerMultiBlockBase<MTESynchrotro

public ArrayList<BlockAntennaCasing> mAntennaCasings = new ArrayList<>();

private static HashMap<Block, Integer> allowedAntennas = new HashMap<>(2);

private static final int CASING_INDEX = GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings5, 14);

private static final byte MIN_GLASS_TIER = 6;
Expand All @@ -99,6 +105,9 @@ public class MTESynchrotron extends MTEExtendedPowerMultiBlockBase<MTESynchrotro
// TODO: E > 1200eV for x-ray lithography
// spotless:off
static {

allowedAntennas.put(LanthItemList.ANTENNA_CASING_T1, 0);
allowedAntennas.put(LanthItemList.ANTENNA_CASING_T2, 0);

STRUCTURE_DEFINITION = StructureDefinition.<MTESynchrotron>builder().addShape(
STRUCTURE_PIECE_ENTRANCE,
Expand Down Expand Up @@ -453,18 +462,23 @@ public class MTESynchrotron extends MTEExtendedPowerMultiBlockBase<MTESynchrotro
// Adder overriden due to ExoticEnergy originally calling its own adder, giving false positives
.addElement('e', buildHatchAdder(MTESynchrotron.class).atLeast(ImmutableMap.of(Energy.or(ExoticEnergy), 4)).adder(MTESynchrotron::addEnergyInputToMachineList).dot(6).casingIndex(CASING_INDEX).build())
.addElement('n', ofBlock(LanthItemList.NIOBIUM_CAVITY_CASING, 0))
.addElement('a', ofBlockAdder(MTESynchrotron::addAntenna, LanthItemList.ANTENNA_CASING_T1, 0)) //Antenna Casings
.addElement('a', withChannel("antenna", StructureUtility.ofBlocksTiered(
(Block block, int meta) -> (block == LanthItemList.ANTENNA_CASING_T1 ? 1 : block == LanthItemList.ANTENNA_CASING_T2 ? 2 : -1),
ImmutableList.of(
Pair.of(LanthItemList.ANTENNA_CASING_T1, 0),
Pair.of(LanthItemList.ANTENNA_CASING_T2, 0)),
-2, MTESynchrotron::setAntennaTier, MTESynchrotron::getAntennaTier)))
.addElement('i', buildHatchAdder(MTESynchrotron.class).atLeast(ImmutableMap.of(InputHatch, 2)).dot(4).casingIndex(CASING_INDEX).build())
.addElement('o', buildHatchAdder(MTESynchrotron.class).atLeast(ImmutableMap.of(OutputHatch, 2)).dot(5).casingIndex(CASING_INDEX).build())
.addElement('v', buildHatchAdder(MTESynchrotron.class).hatchClass(MTEHatchInputBeamline.class).casingIndex(CASING_INDEX)
.dot(1).adder(MTESynchrotron::addBeamlineInputHatch).build())
.addElement('b', buildHatchAdder(MTESynchrotron.class).hatchClass(MTEHatchOutputBeamline.class).casingIndex(CASING_INDEX)
.dot(2).adder(MTESynchrotron::addBeamlineOutputHatch).build())
.addElement('g', BorosilicateGlass.ofBoroGlass((byte) 0, MIN_GLASS_TIER, Byte.MAX_VALUE, (te, t) -> te.glassTier = t, te -> te.glassTier))
.addElement('g', withChannel("glass", BorosilicateGlass.ofBoroGlass((byte) 0, MIN_GLASS_TIER, Byte.MAX_VALUE, (te, t) -> te.glassTier = t, te -> te.glassTier)))
.addElement('j',
buildHatchAdder(MTESynchrotron.class).atLeast(Maintenance).dot(3).casingIndex(CASING_INDEX)
.buildAndChain(LanthItemList.SHIELDED_ACCELERATOR_CASING, 0))

.build();


Expand Down Expand Up @@ -693,21 +707,12 @@ public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int
*/
}

private boolean addAntenna(Block block, int meta) {

if (block == null) return false;

if (!(block instanceof BlockAntennaCasing antennaBlock)) return false;

int antennaTier = antennaBlock.getTier();

// First antenna casing added
if (this.mAntennaCasings.isEmpty()) this.antennaeTier = antennaTier;

if (antennaTier != this.antennaeTier) return false;

return mAntennaCasings.add(antennaBlock);
public void setAntennaTier(int t) {
this.antennaeTier = t;
}

public int getAntennaTier() {
return this.antennaeTier;
}

@Override
Expand Down Expand Up @@ -784,14 +789,7 @@ public CheckRecipeResult checkProcessing() {

FluidStack primaryFluid = fluidList.get(0);

int fluidTemperature;

if (primaryFluid.isFluidEqual(new FluidStack(FluidRegistry.getFluid("ic2coolant"), 1))) {
fluidTemperature = 60; // Default temp of 300 is unreasonable
} else {
fluidTemperature = primaryFluid.getFluid()
.getTemperature();
}
int fluidTemperature = Util.coolantFluidTemperature(primaryFluid);

machineTemp = fluidTemperature; // Solely for tricorder info

Expand Down Expand Up @@ -1024,7 +1022,7 @@ public String[] getInfoData() {
+ " K", // e.g. "137 K"
StatCollector.translateToLocal("beamline.coolusage") + ": " // Coolant Usage:
+ EnumChatFormatting.AQUA
+ 32_000
+ 32
+ EnumChatFormatting.RESET
+ " kL/s", // 32 kL/s

Expand Down Expand Up @@ -1087,7 +1085,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a
this.energyHatchAmperage = 0;
this.usingExotic = false;

this.antennaeTier = 0;
this.antennaeTier = -2;

this.glassTier = 0;

Expand All @@ -1100,6 +1098,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a
if (!checkPiece(STRUCTURE_PIECE_BASE, 16, 3, 0)) return false;

return this.mInputBeamline.size() == 1 && this.mOutputBeamline.size() == 1
&& this.antennaeTier > 0
&& this.mMaintenanceHatches.size() == 1
&& (this.mEnergyHatches.size() == 4 || this.mExoticEnergyHatches.size() == 4)
&& this.glassTier >= MIN_GLASS_TIER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import bartworks.common.loaders.ItemRegistry;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.GTValues;
import gregtech.api.enums.TickTime;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
Expand Down Expand Up @@ -255,15 +256,15 @@ public CheckRecipeResult checkProcessing() {
tItemsWithFocusItem.add(tFocusItemZeroDamage);
tItemsWithFocusItem.addAll(tItems);

long tVoltage = this.getMaxInputVoltage();
long tVoltageActual = GTValues.VP[(int) this.getInputVoltageTier()];

ItemStack[] tItemsArray = tItems.toArray(new ItemStack[0]);

ItemStack[] tItemsWithFocusItemArray = tItemsWithFocusItem.toArray(new ItemStack[0]);

RecipeTC tRecipe = (RecipeTC) BeamlineRecipeAdder2.instance.TargetChamberRecipes.findRecipeQuery()
.items(tItemsWithFocusItemArray)
.voltage(tVoltage)
.voltage(tVoltageActual)
.filter((GTRecipe recipe) -> {

RecipeTC recipeTc = (RecipeTC) recipe;
Expand Down Expand Up @@ -357,7 +358,7 @@ public CheckRecipeResult checkProcessing() {
this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;

mEUt = (int) -tVoltage;
mEUt = (int) -tVoltageActual;
if (this.mEUt > 0) this.mEUt = (-this.mEUt);

this.mOutputItems = itemOutputArray;
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/gtnhlanth/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,17 @@ public static boolean coolantFluidCheck(FluidStack inStack, int fluidToConsume)
|| (!inStack.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1)) && inStack.getFluid()
.getTemperature() > 200));
}

public static int coolantFluidTemperature(FluidStack inStack) {
int fluidTemperature = 300;

if (inStack.isFluidEqual(new FluidStack(FluidRegistry.getFluid("ic2coolant"), 1))) {
fluidTemperature = 60; // Default temp of 300 is unreasonable
} else {
fluidTemperature = inStack.getFluid()
.getTemperature();
}

return fluidTemperature;
}
}
Loading