Skip to content

Commit

Permalink
Add Demo DME Sim Chamber Recipes (In Groovy), Cap Counts to Max Int V…
Browse files Browse the repository at this point in the history
…alue
  • Loading branch information
IntegerLimit committed Apr 22, 2024
1 parent bc138df commit 47c24ed
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ enable_chisel = false
enable_ae2 = false

# Whether to enable DME in runtime. Enables the DME Dat Hatch.
enable_dme = false
enable_dme = true

# Whether to enable Extended Crafting in runtime. Enables Extended Crafting Blocks in DME Sim Chamber and Naq Reactors.
# If this is set to false, those blocks will be set to air.
Expand Down
41 changes: 41 additions & 0 deletions src/main/groovy-tests/dmeSimChamberTests.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import com.nomiceu.nomilabs.LabsValues
import mustapelto.deepmoblearning.common.metadata.MetadataDataModel
import mustapelto.deepmoblearning.common.metadata.MetadataManager
import net.minecraftforge.fml.common.Loader

// Demonstration of Dynamically Generated DME Sim Chamber Recipes. (Goes in Post Init)
// DOES NOT WORK IF DME IS NOT INCLUDED IN LOAD!

def models = MetadataManager.dataModelMetadataList
for (var model : models) {
if (!Loader.isModLoaded(model.modID)) continue

int tier = MetadataManager.minDataModelTier
while (!MetadataManager.isMaxDataModelTier(tier)){
addDMERecipe(model, tier)
tier = MetadataManager.getNextDataModelTier(tier)
}
// Since this does not include maximum tier...
addDMERecipe(model, MetadataManager.getNextDataModelTier(tier))
}

void addDMERecipe(MetadataDataModel model, int tier) {
def tierData = MetadataManager.getDataModelTierData(tier)
if (!tierData.present || !tierData.get().canSimulate) return

def modelPath = model.dataModelRegistryID
def living = model.livingMatter
def pristine = model.pristineMatter
def eut = model.simulationRFCost / 4

int chance = tierData.get().pristineChance

mods.gregtech.dme_sim_chamber.recipeBuilder()
.dataItem(item("${LabsValues.DME_MODID}:${modelPath}"), tier)
.input(item('deepmoblearning:polymer_clay').item)
.output(living.item)
.chancedOutput(pristine, chance * 100, 0) // Chanced Outputs are In Per 100 (100 = 1%)
.EUt(eut as int)
.duration(300)
.buildAndRegister()
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.nomiceu.nomilabs.gregtech.metatileentity.registry;

import net.minecraftforge.fml.common.Loader;

import com.nomiceu.nomilabs.LabsValues;
import com.nomiceu.nomilabs.config.LabsConfig;
import com.nomiceu.nomilabs.gregtech.metatileentity.multiblock.*;
import com.nomiceu.nomilabs.util.LabsNames;

import gregtech.common.metatileentities.MetaTileEntities;
import net.minecraftforge.fml.common.Loader;

/**
* Meta Tile Entities all start at 31000, as colliding metas with old Meta Tile Entities usually causes problems.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.ArrayList;
import java.util.List;

import net.minecraftforge.fml.common.Loader;

import com.nomiceu.nomilabs.LabsValues;
import com.nomiceu.nomilabs.config.LabsConfig;
import com.nomiceu.nomilabs.gregtech.LabsSounds;
Expand All @@ -15,7 +17,6 @@
import gregtech.api.recipes.builders.FuelRecipeBuilder;
import gregtech.api.recipes.builders.SimpleRecipeBuilder;
import gregtech.core.sound.GTSoundEvents;
import net.minecraftforge.fml.common.Loader;

public class LabsRecipeMaps {

Expand Down Expand Up @@ -63,7 +64,8 @@ public static void preInit() {
!(oldMultis() || LabsModeHelper.isNormal()))
.setSlotOverlay(false, false, GuiTextures.RESEARCH_STATION_OVERLAY)
.setSlotOverlay(true, false, GuiTextures.RESEARCH_STATION_OVERLAY)
.setProgressBar(GuiTextures.PROGRESS_BAR_CIRCUIT_ASSEMBLER, ProgressWidget.MoveType.VERTICAL)
.setProgressBar(GuiTextures.PROGRESS_BAR_CIRCUIT_ASSEMBLER,
ProgressWidget.MoveType.VERTICAL)
.setSound(GTSoundEvents.COMPUTATION);

GROWTH_CHAMBER_RECIPES = new RecipeMap<>("growth_chamber", 4, 9, 1, 0, new SimpleRecipeBuilder(), !newMultis())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
for (var stack : list) {
if (stack.getItem() == searchItem && DataModelHelper.getTier(stack) == searchTier) {
DataModelHelper.setCurrentTierDataCount(stack,
DataModelHelper.getCurrentTierDataCount(stack) + property.getAddition());
Math.min(Integer.MAX_VALUE, DataModelHelper.getCurrentTierDataCount(stack) + property.getAddition()));
DataModelHelper.setTotalSimulationCount(stack,
DataModelHelper.getTotalSimulationCount(stack) + property.getAddition());
Math.min(Integer.MAX_VALUE, DataModelHelper.getTotalSimulationCount(stack) + property.getAddition()));
var increase = true;
while (increase) {
increase = DataModelHelperAccessor.tryIncreaseTier(stack);
Expand Down

0 comments on commit 47c24ed

Please sign in to comment.