Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/beamline-cleanup' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Dec 23, 2024
2 parents 165ce0f + f842db9 commit 3935afd
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 66 deletions.
36 changes: 15 additions & 21 deletions src/main/java/gtnhlanth/common/tileentity/MTELINAC.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;

import org.jetbrains.annotations.NotNull;

import com.gtnewhorizon.structurelib.StructureLib;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
Expand All @@ -40,6 +42,8 @@
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase;
import gregtech.api.metatileentity.implementations.MTEHatchEnergy;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
Expand Down Expand Up @@ -246,8 +250,9 @@ private boolean addBeamLineOutputHatch(IGregTechTileEntity te, int casingIndex)
return false;
}

@NotNull
@Override
public boolean checkRecipe(ItemStack itemStack) {
public CheckRecipeResult checkProcessing() {

float tempFactor = 0;
// Focus as determined by multi properties
Expand Down Expand Up @@ -277,7 +282,7 @@ public boolean checkRecipe(ItemStack itemStack) {
if (tFluidInputs.isEmpty()) {
this.doRandomMaintenanceDamage(); // Penalise letting coolant run dry
this.stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.nocoolant"));
return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

// Coolant input
Expand All @@ -291,12 +296,12 @@ public boolean checkRecipe(ItemStack itemStack) {
this.mEfficiencyIncrease = 10000;

if (this.getInputInformation() == null) {
return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

if (this.getInputInformation()
.getEnergy() == 0) {
return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

particleId = this.getInputInformation()
Expand All @@ -305,7 +310,7 @@ public boolean checkRecipe(ItemStack itemStack) {

if (!inputParticle.canAccelerate()) {
stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.noaccel"));
return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

mMaxProgresstime = 1 * TickTime.SECOND;
Expand Down Expand Up @@ -364,7 +369,7 @@ public boolean checkRecipe(ItemStack itemStack) {
if (Util.coolantFluidCheck(primFluid, fluidConsumed)) {

this.stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.inscoolant"));
return false;
return CheckRecipeResultRegistry.NO_RECIPE;

}

Expand All @@ -374,17 +379,17 @@ public boolean checkRecipe(ItemStack itemStack) {
primFluid.getFluid()
.getName());

if (Objects.isNull(fluidOutput)) return false;
if (Objects.isNull(fluidOutput)) return CheckRecipeResultRegistry.NO_RECIPE;

FluidStack fluidOutputStack = new FluidStack(fluidOutput, fluidConsumed);

if (Objects.isNull(fluidOutputStack)) return false;
if (Objects.isNull(fluidOutputStack)) return CheckRecipeResultRegistry.NO_RECIPE;

this.addFluidOutputs(new FluidStack[] { fluidOutputStack });

outputAfterRecipe();

return true;
return CheckRecipeResultRegistry.SUCCESSFUL;
}

private void outputAfterRecipe() {
Expand All @@ -402,18 +407,7 @@ private void outputAfterRecipe() {
}

@Override
public void stopMachine() {

outputFocus = 0;
outputEnergy = 0;
outputParticle = 0;
outputRate = 0;
machineTemp = 0;
super.stopMachine();
}

@Override
public void stopMachine(ShutDownReason reason) {
public void stopMachine(@NotNull ShutDownReason reason) {

outputFocus = 0;
outputEnergy = 0;
Expand Down
26 changes: 17 additions & 9 deletions src/main/java/gtnhlanth/common/tileentity/MTESourceChamber.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

import org.jetbrains.annotations.NotNull;

import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
Expand All @@ -35,9 +37,12 @@
import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase;
import gregtech.api.metatileentity.implementations.MTEHatchEnergy;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.shutdown.ShutDownReason;
import gregtech.api.util.shutdown.SimpleShutDownReason;
import gtnhlanth.common.beamline.BeamInformation;
import gtnhlanth.common.beamline.BeamLinePacket;
Expand Down Expand Up @@ -155,8 +160,9 @@ private boolean addBeamLineOutputHatch(IGregTechTileEntity te, int casingIndex)
return false;
}

@NotNull
@Override
public boolean checkRecipe(ItemStack itemStack) {
public CheckRecipeResult checkProcessing() {

// No input particle, so no input quantities

Expand All @@ -176,15 +182,17 @@ public boolean checkRecipe(ItemStack itemStack) {
.voltage(tVoltageActual)
.find();

if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, new FluidStack[] {}, tItems)) return false; // Consumes
// input
// item
if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, new FluidStack[] {}, tItems)) {
return CheckRecipeResultRegistry.NO_RECIPE; // Consumes input item
}

this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;

this.mMaxProgresstime = tRecipe.mDuration;
if (mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false;
if (mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) {
return CheckRecipeResultRegistry.NO_RECIPE;
}

mEUt = (int) -tVoltageActual;
if (this.mEUt > 0) this.mEUt = (-this.mEUt);
Expand All @@ -203,7 +211,7 @@ public boolean checkRecipe(ItemStack itemStack) {

if (outputEnergy <= 0) {
stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.scerror"));
return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

outputFocus = tRecipe.focus;
Expand All @@ -214,7 +222,7 @@ public boolean checkRecipe(ItemStack itemStack) {

outputAfterRecipe();

return true;
return CheckRecipeResultRegistry.SUCCESSFUL;
}

@Override
Expand All @@ -238,12 +246,12 @@ private void outputAfterRecipe() {
}

@Override
public void stopMachine() {
public void stopMachine(@NotNull ShutDownReason reason) {
outputFocus = 0;
outputEnergy = 0;
outputParticle = 0;
outputRate = 0;
super.stopMachine();
super.stopMachine(reason);
}

@Override
Expand Down
44 changes: 18 additions & 26 deletions src/main/java/gtnhlanth/common/tileentity/MTESynchrotron.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;

import org.jetbrains.annotations.NotNull;

import com.google.common.collect.ImmutableMap;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
Expand All @@ -44,6 +46,8 @@
import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase;
import gregtech.api.metatileentity.implementations.MTEHatch;
import gregtech.api.metatileentity.implementations.MTEHatchEnergy;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.ExoticEnergyInputHelper;
import gregtech.api.util.GTUtility;
Expand Down Expand Up @@ -445,7 +449,7 @@ public class MTESynchrotron extends MTEExtendedPowerMultiBlockBase<MTESynchrotro
).addElement('c', ofBlock(LanthItemList.SHIELDED_ACCELERATOR_CASING, 0))
.addElement('k', ofBlock(GregTechAPI.sBlockCasings1, 15)) // Superconducting coils
.addElement('d', ofBlock(LanthItemList.COOLANT_DELIVERY_CASING, 0))

// 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))
Expand Down Expand Up @@ -711,8 +715,9 @@ public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}

@NotNull
@Override
public boolean checkRecipe(ItemStack aStack) {
public CheckRecipeResult checkProcessing() {

float inputEnergy = 0;
float inputFocus = 0;
Expand All @@ -737,24 +742,24 @@ public boolean checkRecipe(ItemStack aStack) {

this.stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.nocoolant"));

return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;

if (this.getInputInformation() == null) {
return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

if (this.getInputInformation()
.getEnergy() == 0) { // Only really applies if there's no input
return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

if (this.getInputInformation()
.getFocus() < MIN_INPUT_FOCUS) {
return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

inputParticleId = this.getInputInformation()
Expand All @@ -764,7 +769,7 @@ public boolean checkRecipe(ItemStack aStack) {

if (!inputParticle.canAccelerate()) {
stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.noaccel"));
return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

mMaxProgresstime = TickTime.SECOND;
Expand Down Expand Up @@ -823,13 +828,13 @@ public boolean checkRecipe(ItemStack aStack) {

if (outputRate == 0) {
stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.low_input_eut"));
return false;
return CheckRecipeResultRegistry.NO_RECIPE;
}

if (Util.coolantFluidCheck(primaryFluid, CONSUMED_FLUID)) {

stopMachine(SimpleShutDownReason.ofCritical("gtnhlanth.inscoolant"));
return false;
return CheckRecipeResultRegistry.NO_RECIPE;

}

Expand All @@ -839,17 +844,17 @@ public boolean checkRecipe(ItemStack aStack) {
primaryFluid.getFluid()
.getName());

if (Objects.isNull(fluidOutput)) return false;
if (Objects.isNull(fluidOutput)) return CheckRecipeResultRegistry.NO_RECIPE;

FluidStack fluidOutputStack = new FluidStack(fluidOutput, CONSUMED_FLUID);

if (Objects.isNull(fluidOutputStack)) return false;
if (Objects.isNull(fluidOutputStack)) return CheckRecipeResultRegistry.NO_RECIPE;

this.addFluidOutputs(new FluidStack[] { fluidOutputStack });

outputAfterRecipe();

return true;
return CheckRecipeResultRegistry.SUCCESSFUL;
}

private void outputAfterRecipe() {
Expand All @@ -867,20 +872,7 @@ private void outputAfterRecipe() {
}

@Override
public void stopMachine() {

outputFocus = 0;
outputEnergy = 0;
outputParticle = 0;
outputRate = 0;
machineFocus = 0;
machineTemp = 0;
super.stopMachine();

}

@Override
public void stopMachine(ShutDownReason reason) {
public void stopMachine(@NotNull ShutDownReason reason) {

outputFocus = 0;
outputEnergy = 0;
Expand Down
Loading

0 comments on commit 3935afd

Please sign in to comment.