Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
Migrate dissolution tank & digester to processingLogic (#86)
Browse files Browse the repository at this point in the history
* dissolution tank

* digester

* update

* address review

* make dissolution tank void and stop if the input ratio is wrong

* update

---------

Co-authored-by: Martin Robertz <dream-master@gmx.net>
  • Loading branch information
GDCloudstrike and Dream-Master committed Feb 18, 2024
1 parent d47bfec commit 2a7811c
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 58 deletions.
6 changes: 3 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Add your dependencies here

dependencies {
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.43:dev')
implementation('com.github.GTNewHorizons:GTplusplus:1.11.19:dev')
implementation('com.github.GTNewHorizons:GoodGenerator:0.8.4:dev')
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.71:dev')
implementation('com.github.GTNewHorizons:GTplusplus:1.11.25:dev')
implementation('com.github.GTNewHorizons:GoodGenerator:0.8.10:dev')
}
10 changes: 6 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
gtnh.settings.blowdryerTag = 0.2.0

# Human-readable mod name, available for mcmod.info population.
modName = GTNH: Lanthanides
modName = GTNH\: Lanthanides

# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
Expand Down Expand Up @@ -33,7 +33,7 @@ channel = stable
mappingsVersion = 12

# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/

# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
Expand Down Expand Up @@ -61,6 +61,9 @@ gradleTokenModId = GRADLETOKEN_MODID
# [DEPRECATED] Mod name replacement token.
gradleTokenModName = GRADLETOKEN_MODNAME

# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName = GRADLETOKEN_GROUPNAME

# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
Expand Down Expand Up @@ -123,7 +126,7 @@ includeWellKnownRepositories = true
usesMavenPublishing = true

# Maven repository to publish the mod to.
# mavenPublishUrl = https://nexus.gtnewhorizons.com/repository/releases/
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/

# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
Expand Down Expand Up @@ -188,6 +191,5 @@ curseForgeRelations =
# ideaCheckSpotlessOnBuild = true

# Non-GTNH properties
gradleTokenGroupName = GRADLETOKEN_GROUPNAME
systemProp.org.gradle.internal.http.connectionTimeout = 180000
systemProp.org.gradle.internal.http.socketTimeout = 180000
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.8'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14'
}


60 changes: 34 additions & 26 deletions src/main/java/com/elisis/gtnhlanth/common/tileentity/Digester.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
import static gregtech.api.util.GT_StructureUtility.buildHatchAdder;
import static gregtech.api.util.GT_StructureUtility.ofCoil;

import java.util.ArrayList;
import javax.annotation.Nonnull;

import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

import com.elisis.gtnhlanth.api.recipe.LanthanidesRecipeMaps;
import com.elisis.gtnhlanth.util.DescTextLocalization;
Expand All @@ -36,10 +35,14 @@
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase;
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.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_OverclockCalculator;
import gregtech.api.util.GT_Recipe;

public class Digester extends GT_MetaTileEntity_EnhancedMultiBlockBase<Digester> implements ISurvivalConstructable {
Expand Down Expand Up @@ -101,37 +104,42 @@ public RecipeMap<?> getRecipeMap() {
}

@Override
public boolean checkRecipe(ItemStack itemStack) {
// GT_Log.out.print("Digester: in checkRecipe\n");
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {

ArrayList<FluidStack> tFluidInputs = this.getStoredFluids();
FluidStack[] tFluidInputArray = tFluidInputs.toArray(new FluidStack[0]);
ItemStack[] tItems = this.getStoredInputs().toArray(new ItemStack[0]);
long tVoltage = this.getMaxInputVoltage();
@Nonnull
@Override
protected GT_OverclockCalculator createOverclockCalculator(@Nonnull GT_Recipe recipe) {
return super.createOverclockCalculator(recipe).enablePerfectOC();
}

// GT_Log.out.print("Digester: " + Arrays.toString(mInventory));
@Override
protected @Nonnull CheckRecipeResult validateRecipe(@Nonnull GT_Recipe recipe) {
return recipe.mSpecialValue <= Digester.this.getCoilLevel().getHeat()
? CheckRecipeResultRegistry.SUCCESSFUL
: CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue);
}

GT_Recipe tRecipe = LanthanidesRecipeMaps.digesterRecipes
.findRecipe(getBaseMetaTileEntity(), false, tVoltage, tFluidInputArray, tItems);

if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluidInputArray, tItems)) return false;
// GT_Log.out.print("Recipe not null\n");
};
}

this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;
this.calculateOverclockedNessMultiInternal(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage, true);
@Override
public boolean supportsVoidProtection() {
return true;
}

if (mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false;
@Override
public boolean supportsInputSeparation() {
return true;
}

if (this.mEUt > 0) this.mEUt = (-this.mEUt);
// GT_Log.out.print("valid values");
@Override
public boolean supportsBatchMode() {
return true;
}

if (tRecipe.mSpecialValue > this.getCoilLevel().getHeat()) return false;
// GT_Log.out.print("Coils good\n");
// GT_Log.out.print(tRecipe.getFluidOutput(0).getLocalizedName());
this.mOutputFluids = tRecipe.mFluidOutputs;
this.mOutputItems = tRecipe.mOutputs;
this.updateSlots();
@Override
public boolean supportsSingleRecipeLocking() {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@
import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages;
import static gregtech.api.util.GT_StructureUtility.buildHatchAdder;

import java.util.Arrays;
import java.util.List;

import javax.annotation.Nonnull;

import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

import org.jetbrains.annotations.NotNull;

import com.elisis.gtnhlanth.api.recipe.LanthanidesRecipeMaps;
import com.elisis.gtnhlanth.util.DescTextLocalization;
import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry;
Expand All @@ -37,8 +42,12 @@
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.recipe.check.SimpleCheckRecipeResult;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
Expand Down Expand Up @@ -96,36 +105,39 @@ public RecipeMap<?> getRecipeMap() {
}

@Override
public boolean checkRecipe(ItemStack itemStack) {
// GT_Log.out.print("in checkRecipe");

List<FluidStack> tFluidInputs = this.getStoredFluids();
FluidStack[] tFluidInputArray = tFluidInputs.toArray(new FluidStack[0]);
ItemStack[] tItems = this.getStoredInputs().toArray(new ItemStack[0]);
long tVoltage = this.getMaxInputVoltage();

GT_Recipe tRecipe = LanthanidesRecipeMaps.dissolutionTankRecipes
.findRecipe(getBaseMetaTileEntity(), false, tVoltage, tFluidInputArray, tItems);
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {

if (tRecipe == null || !tRecipe.isRecipeInputEqual(true, tFluidInputArray, tItems)) return false;
// GT_Log.out.print("Recipe not null\n");
@NotNull
@Override
protected CheckRecipeResult onRecipeStart(@Nonnull GT_Recipe recipe) {
if (!checkRatio(recipe, Arrays.asList(inputFluids))) {
criticalStopMachine();
return SimpleCheckRecipeResult.ofFailurePersistOnShutdown("dissolution_ratio");
}
return CheckRecipeResultRegistry.SUCCESSFUL;
}

this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;
this.calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage);
};
}

if (mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false;
if (this.mEUt > 0) this.mEUt = (-this.mEUt);
@Override
public boolean supportsVoidProtection() {
return true;
}

this.updateSlots();
@Override
public boolean supportsInputSeparation() {
return true;
}

if (!checkRatio(tRecipe, tFluidInputs)) {
stopMachine();
return false;
}
@Override
public boolean supportsBatchMode() {
return true;
}

this.mOutputFluids = new FluidStack[] { tRecipe.getFluidOutput(0) };
this.mOutputItems = tRecipe.mOutputs;
@Override
public boolean supportsSingleRecipeLocking() {
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/gtnhlanth/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ fluid.Dinitrotoluene=Dinitrotoluene
fluid.Diaminotoluene=Diaminotoluene
fluid.Toluene Tetramethyl Diisocyanate=Toluene Tetramethyl Diisocyanate
fluid.Diluted Acetone=Diluted Acetone

GT5U.gui.text.dissolution_ratio=§7Wrong fluid input ratio

0 comments on commit 2a7811c

Please sign in to comment.