Skip to content

Commit

Permalink
cherrypick 1.2.0.a to 1.19 (#1094)
Browse files Browse the repository at this point in the history
* Fix logic errors in createMultiblock (#1093)

* fix various research bugs that popped up (#1091)

* fix assline recipes with no research not working

* add some missing recipes (WHY DID LIKE 3 PEOPLE TOTAL REPORT ISSUES)

* more recipes

* fix errors

* fix UIs

* changelog

* update LDLib

* update changelog

* reviews

---------

Co-authored-by: SmallY <[email protected]>
  • Loading branch information
screret and iamSmallY authored Apr 11, 2024
1 parent 7f95600 commit 8317c88
Show file tree
Hide file tree
Showing 19 changed files with 1,619 additions and 1,446 deletions.
25 changes: 5 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
# ChangeLog

Version: 1.2.0
Version: 1.2.0.a

### ADDITIONS:
- Ported the new Research System for Late Game from 1.12:
- Assembly lines now require "Research Data" to run recipes. Data is provided by Data Sticks in Hatches or Data Banks.
- Later tier Research Data requires more complex means of computation. Introducing the HPCA and Research Station.
- Added Portable Scanner
- Added Multiblock Fluid Tanks

### CHANGES:
- Improved recipe viewer widgets
- Updated Power Substation UI to show separate values for input and output
- Removed the recipes for Processing Arrays
- **IMPORTANT:** Your existing PAs will only continue to work until 1.3.0, at which point we will remove them entirely.
Please replace them with the appropriate specialized multiblocks until then!
- Updated Russian and Chinese translations

### FIXES:
- Fixed Multiblocks with only 1 Energy/Dynamo Hatch not overclocking
- Fixed Energy Hatch amounts in Multiblocks
- Fixed high-tier Emitters not existing
- Fixed surface rock descriptions
- Fixed plungers not working
- Fixed ME Input Hatch and ME Output Bus
- Fixed number formatting in certain places
- Fixed Large Boilers requiring a Maintenance Hatch when maintenance is disabled in the config
- Fixed some components not requiring data
- Fixed assembly line recipes with no data not working
- Fixed data module recipe being missing
- Fixed tiered multiblock builders not working
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx6G
# Mod Info
mod_id = gtceu
mod_name = GregTech
mod_version = 1.2.0
mod_version = 1.2.0.a
mod_description = GregTech CE Unofficial, ported from 1.12.2
mod_license = LGPL-3.0 license
mod_url = https://github.com/GregTechCEu/GregTech-Modern/
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencyResolutionManagement {
def architecturyPluginVersion = "3.4-SNAPSHOT"
def architecturyLoomVersion = "1.5-SNAPSHOT"
def macheteVersion = "1.+"
def ldLibVersion = "1.0.25.c"
def ldLibVersion = "1.0.25.d"
def mixinextrasVersion = "0.2.0"

forge {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public Integer copyWithModifier(Integer content, ContentModifier modifier) {
public void addXEIInfo(WidgetGroup group, int xOffset, List<Content> contents, boolean perTick, boolean isInput, MutableInt yOffset) {
if (perTick && isInput) {
int cwu = contents.stream().map(Content::getContent).mapToInt(CWURecipeCapability.CAP::of).sum();
group.addWidget(new LabelWidget(3 - xOffset, yOffset.getAndAdd(10), LocalizationUtils.format("gtceu.recipe.computation_per_tick", cwu)));
group.addWidget(new LabelWidget(3 - xOffset, yOffset.addAndGet(10), LocalizationUtils.format("gtceu.recipe.computation_per_tick", cwu)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import org.jetbrains.annotations.NotNull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Collections;
import java.util.List;
import java.util.function.BiFunction;

/**
Expand Down Expand Up @@ -117,6 +119,7 @@ public boolean canVoidRecipeOutputs(RecipeCapability<?> capability) {
generatorMachine.importFluids,
generatorMachine.exportFluids,
new CompoundTag(),
Collections.emptyList(),
false, false));
createEnergyBar().setupUI(template, generatorMachine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.jetbrains.annotations.Nullable;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.BiFunction;
Expand Down Expand Up @@ -379,6 +380,7 @@ public void attachConfigurators(ConfiguratorPanel configuratorPanel) {
tieredMachine.importFluids,
tieredMachine.exportFluids,
new CompoundTag(),
Collections.emptyList(),
false, false));
createBatterySlot().setupUI(template, tieredMachine);
// createCircuitConfigurator().setupUI(template, tieredMachine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import org.jetbrains.annotations.NotNull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Collections;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -156,7 +157,7 @@ public void afterWorking() {

@Override
public ModularUI createUI(Player entityPlayer) {
var group = getRecipeType().getRecipeUI().createUITemplate(recipeLogic::getProgressPercent, importItems.storage, exportItems.storage, IFluidTransfer.EMPTY, IFluidTransfer.EMPTY, new CompoundTag(), true, isHighPressure);
var group = getRecipeType().getRecipeUI().createUITemplate(recipeLogic::getProgressPercent, importItems.storage, exportItems.storage, IFluidTransfer.EMPTY, IFluidTransfer.EMPTY, new CompoundTag(), Collections.emptyList(), true, isHighPressure);
Position pos = new Position((Math.max(group.getSize().width + 4 + 8, 176) - 4 - group.getSize().width) / 2 + 4, 32);
group.setSelfPosition(pos);
return new ModularUI(176, 166, this, entityPlayer)
Expand Down
40 changes: 23 additions & 17 deletions src/main/java/com/gregtechceu/gtceu/api/recipe/ResearchData.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.gregtechceu.gtceu.api.recipe;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.gregtechceu.gtceu.GTCEu;
import com.mojang.serialization.JsonOps;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.world.item.ItemStack;

import org.jetbrains.annotations.NotNull;
import java.util.*;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

@AllArgsConstructor
public final class ResearchData implements Iterable<ResearchData.ResearchEntry> {
Expand All @@ -31,18 +37,18 @@ public Iterator<ResearchEntry> iterator() {
return this.entries.iterator();
}

public static ResearchData fromNBT(ListTag tag) {
public static ResearchData fromJson(JsonArray array) {
List<ResearchEntry> entries = new ArrayList<>();
for (int i = 0; i < tag.size(); ++i) {
entries.add(ResearchEntry.fromNBT(tag.getCompound(i)));
for (int i = 0; i < array.size(); ++i) {
entries.add(ResearchEntry.fromJson(array.get(i).getAsJsonObject()));
}
return new ResearchData(entries);
}

public ListTag toNBT() {
ListTag tag = new ListTag();
this.entries.forEach(entry -> tag.add(entry.toNBT()));
return tag;
public JsonArray toJson() {
JsonArray json = new JsonArray();
this.entries.forEach(entry -> json.add(entry.toJson()));
return json;
}

/**
Expand All @@ -68,15 +74,15 @@ public ResearchEntry(@NotNull String researchId, @NotNull ItemStack dataItem) {
this.dataItem = dataItem;
}

public static ResearchEntry fromNBT(CompoundTag tag) {
return new ResearchEntry(tag.getString("researchId"), ItemStack.of(tag.getCompound("dataItem")));
public static ResearchEntry fromJson(JsonObject tag) {
return new ResearchEntry(tag.get("researchId").getAsString(), ItemStack.CODEC.parse(JsonOps.INSTANCE, tag.get("dataItem")).getOrThrow(false, GTCEu.LOGGER::error));
}

public CompoundTag toNBT() {
CompoundTag tag = new CompoundTag();
tag.putString("researchId", researchId);
tag.put("dataItem", dataItem.save(new CompoundTag()));
return tag;
public JsonObject toJson() {
JsonObject json = new JsonObject();
json.addProperty("researchId", researchId);
json.add("dataItem", ItemStack.CODEC.encodeStart(JsonOps.INSTANCE, dataItem).getOrThrow(false, GTCEu.LOGGER::error));
return json;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import com.gregtechceu.gtceu.api.gui.widget.DualProgressWidget;
import com.gregtechceu.gtceu.api.recipe.GTRecipe;
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.api.recipe.RecipeCondition;
import com.gregtechceu.gtceu.api.recipe.ResearchData;
import com.gregtechceu.gtceu.common.recipe.ResearchCondition;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.integration.emi.recipe.GTRecipeTypeEmiCategory;
import com.gregtechceu.gtceu.integration.jei.recipe.GTRecipeTypeCategory;
Expand Down Expand Up @@ -148,21 +150,21 @@ public Size getJEISize() {
return size;
}

public record RecipeHolder(DoubleSupplier progressSupplier, IItemTransfer importItems, IItemTransfer exportItems, IFluidTransfer importFluids, IFluidTransfer exportFluids, CompoundTag data, boolean isSteam, boolean isHighPressure) {}
public record RecipeHolder(DoubleSupplier progressSupplier, IItemTransfer importItems, IItemTransfer exportItems, IFluidTransfer importFluids, IFluidTransfer exportFluids, CompoundTag data, List<RecipeCondition> conditions, boolean isSteam, boolean isHighPressure) {}

/**
* Auto layout UI template for recipes.
* @param progressSupplier progress. To create a JEI / REI UI, use the para {@link ProgressWidget#JEIProgress}.
*/
public WidgetGroup createUITemplate(DoubleSupplier progressSupplier, IItemTransfer importItems, IItemTransfer exportItems, IFluidTransfer importFluids, IFluidTransfer exportFluids, CompoundTag data, boolean isSteam, boolean isHighPressure) {
public WidgetGroup createUITemplate(DoubleSupplier progressSupplier, IItemTransfer importItems, IItemTransfer exportItems, IFluidTransfer importFluids, IFluidTransfer exportFluids, CompoundTag data, List<RecipeCondition> conditions, boolean isSteam, boolean isHighPressure) {
var template = createEditableUITemplate(isSteam, isHighPressure);
var group = template.createDefault();
template.setupUI(group, new RecipeHolder(progressSupplier, importItems, exportItems, importFluids, exportFluids, data, isSteam, isHighPressure));
template.setupUI(group, new RecipeHolder(progressSupplier, importItems, exportItems, importFluids, exportFluids, data, conditions, isSteam, isHighPressure));
return group;
}

public WidgetGroup createUITemplate(DoubleSupplier progressSupplier, IItemTransfer importItems, IItemTransfer exportItems, IFluidTransfer importFluids, IFluidTransfer exportFluids, CompoundTag data) {
return createUITemplate(progressSupplier, importItems, exportItems, importFluids, exportFluids, data, false, false);
public WidgetGroup createUITemplate(DoubleSupplier progressSupplier, IItemTransfer importItems, IItemTransfer exportItems, IFluidTransfer importFluids, IFluidTransfer exportFluids, CompoundTag data, List<RecipeCondition> conditions) {
return createUITemplate(progressSupplier, importItems, exportItems, importFluids, exportFluids, data, conditions, false, false);
}

/**
Expand Down Expand Up @@ -244,10 +246,13 @@ public IEditableUI<WidgetGroup, RecipeHolder> createEditableUITemplate(final boo
// 1 over container size.
// If in a recipe viewer and a research slot can be added, add it.
if (isJEI && recipeType.isHasResearchSlot() && index == recipeHolder.importItems.getSlots()) {
if (ConfigHolder.INSTANCE.machines.enableResearch && recipeHolder.data.contains("research", Tag.TAG_LIST)) {
ResearchData data = ResearchData.fromNBT(recipeHolder.data.getList("research", Tag.TAG_COMPOUND));
if (ConfigHolder.INSTANCE.machines.enableResearch) {
ResearchCondition condition = recipeHolder.conditions.stream().filter(ResearchCondition.class::isInstance).findAny().map(ResearchCondition.class::cast).orElse(null);
if (condition == null) {
return;
}
List<ItemStack> dataItems = new ArrayList<>();
for (ResearchData.ResearchEntry entry : data) {
for (ResearchData.ResearchEntry entry : condition.data) {
ItemStack dataStick = entry.getDataItem().copy();
ResearchManager.writeResearchToNBT(dataStick.getOrCreateTag(), entry.getResearchId(), this.recipeType);
dataItems.add(dataStick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void init() {
GTRegistries.RECIPE_CONDITIONS.register(ThunderCondition.INSTANCE.getType(), ThunderCondition.class);
GTRegistries.RECIPE_CONDITIONS.register(VentCondition.INSTANCE.getType(), VentCondition.class);
GTRegistries.RECIPE_CONDITIONS.register(CleanroomCondition.INSTANCE.getType(), CleanroomCondition.class);
GTRegistries.RECIPE_CONDITIONS.register(ResearchCondition.INSTANCE.getType(), ResearchCondition.class);
if (GTCEu.isCreateLoaded()) {
GTRegistries.RECIPE_CONDITIONS.register(RPMCondition.INSTANCE.getType(), RPMCondition.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.common.item.PortableScannerBehavior;
import com.gregtechceu.gtceu.common.machine.multiblock.electric.research.DataBankMachine;
import com.gregtechceu.gtceu.common.recipe.ResearchCondition;
import com.gregtechceu.gtceu.utils.ResearchManager;
import com.gregtechceu.gtceu.utils.ItemStackHashStrategy;
import com.lowdragmc.lowdraglib.gui.widget.SlotWidget;
Expand Down Expand Up @@ -129,7 +130,7 @@ private void rebuildData(boolean isDataBank) {
@Override
public boolean isRecipeAvailable(@NotNull GTRecipe recipe, @NotNull Collection<IDataAccessHatch> seen) {
seen.add(this);
return recipes.contains(recipe);
return recipe.conditions.stream().noneMatch(ResearchCondition.class::isInstance) || recipes.contains(recipe);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.gregtechceu.gtceu.common.recipe;

import com.google.gson.JsonObject;
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;
import com.gregtechceu.gtceu.api.recipe.GTRecipe;
import com.gregtechceu.gtceu.api.recipe.RecipeCondition;
import com.gregtechceu.gtceu.api.recipe.ResearchData;
import lombok.AllArgsConstructor;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;

@AllArgsConstructor
public class ResearchCondition extends RecipeCondition {
public final static ResearchCondition INSTANCE = new ResearchCondition();
public ResearchData data;

public ResearchCondition() {
this.data = new ResearchData();
}

@Override
public String getType() {
return "reseach";
}

@Override
public Component getTooltips() {
return Component.translatable("gtceu.recipe.research");
}

@NotNull
@Override
public JsonObject serialize() {
JsonObject value = super.serialize();
value.add("research", this.data.toJson());
return value;
}

@Override
public RecipeCondition deserialize(@NotNull JsonObject config) {
super.deserialize(config);
this.data = ResearchData.fromJson(config.getAsJsonArray("research"));
return this;
}

@Override
public boolean test(@NotNull GTRecipe recipe, @NotNull RecipeLogic recipeLogic) {
return true;
}

@Override
public RecipeCondition createTemplate() {
return new ResearchCondition();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -608,17 +608,15 @@ private boolean applyResearchProperty(ResearchData.ResearchEntry researchEntry)
return false;
}

if (this.data.contains("research", Tag.TAG_LIST)) {
ResearchData property = ResearchData.fromNBT(data.getList("research", Tag.TAG_COMPOUND));
property.add(researchEntry);
this.data.put("research", property.toNBT());
return true;
ResearchCondition condition = this.conditions.stream().filter(ResearchCondition.class::isInstance).findAny().map(ResearchCondition.class::cast).orElse(null);
if (condition != null) {
condition.data.add(researchEntry);
} else {
ResearchData property = new ResearchData();
property.add(researchEntry);
this.data.put("research", property.toNBT());
return true;
condition = new ResearchCondition();
condition.data.add(researchEntry);
this.addCondition(condition);
}
return true;
}

/**
Expand Down Expand Up @@ -748,9 +746,9 @@ public void save(Consumer<FinishedRecipe> consumer) {
if (onSave != null) {
onSave.accept(this, consumer);
}
if (this.data.contains("research", Tag.TAG_LIST)) {
ResearchData data = ResearchData.fromNBT(this.data.getList("research", Tag.TAG_COMPOUND));
for (ResearchData.ResearchEntry entry : data) {
ResearchCondition condition = this.conditions.stream().filter(ResearchCondition.class::isInstance).findAny().map(ResearchCondition.class::cast).orElse(null);
if (condition != null) {
for (ResearchData.ResearchEntry entry : condition.data) {
this.recipeType.addDataStickEntry(entry.getResearchId(), buildRawRecipe());
}
}
Expand Down
Loading

0 comments on commit 8317c88

Please sign in to comment.