From 31fcf2939515a8bfadacf7f044004fd5bdf1533d Mon Sep 17 00:00:00 2001 From: screret <68943070+screret@users.noreply.github.com> Date: Fri, 6 Dec 2024 23:19:32 +0200 Subject: [PATCH 1/4] give breweries the ability to make potions and add potion fluids to go along with them --- .../resources/assets/gtceu/lang/en_ud.json | 50 +---- .../resources/assets/gtceu/lang/en_us.json | 50 +---- .../data/forge/tags/fluids/potion.json | 6 + .../recipe/FluidRecipeCapability.java | 15 +- .../recipe/ItemRecipeCapability.java | 55 +++-- .../api/fluids/store/FluidStorageKeys.java | 2 +- .../gtceu/api/gui/widget/SlotWidget.java | 102 +++++++-- .../gtceu/api/gui/widget/TankWidget.java | 49 +++-- .../api/item/component/ThermalFluidStats.java | 2 +- .../fluid/TagOrCycleFluidHandler.java | 14 +- .../item/TagOrCycleItemStackHandler.java | 19 +- .../gtceu/client/TooltipsHandler.java | 19 +- .../gregtechceu/gtceu/common/CommonProxy.java | 2 - .../gtceu/common/data/GTFluids.java | 13 ++ .../gtceu/common/data/GTRecipeTypes.java | 2 + .../common/fluid/potion/PotionFluid.java | 122 +++++++++++ .../fluid/potion/PotionFluidHelper.java | 207 ++++++++++++++++++ .../trait/customlogic/BreweryLogic.java | 197 +++++++++++++++++ .../core/mixins/PotionBrewingAccessor.java | 18 ++ .../core/mixins/emi/FluidEmiStackMixin.java | 11 +- .../core/mixins/jei/FluidHelperMixin.java | 2 +- .../mixins/rei/FluidEntryRendererMixin.java | 5 +- .../gtceu/data/lang/IntegrationLang.java | 2 + .../gtceu/data/recipe/CustomTags.java | 1 + .../data/recipe/builder/GTRecipeBuilder.java | 5 +- .../gtceu/forge/ForgeCommonEventListener.java | 55 ++++- .../gui/widget/list/AEFluidDisplayWidget.java | 3 +- .../gtceu/integration/emi/GTEMIPlugin.java | 18 ++ .../gtceu/integration/jei/GTJEIPlugin.java | 29 +++ .../PotionFluidSubtypeInterpreter.java | 39 ++++ .../gtceu/integration/rei/GTREIPlugin.java | 46 +++- .../xei/widgets/GTOreByProduct.java | 27 ++- .../xei/widgets/GTOreByProductWidget.java | 8 +- .../gtceu/utils/ResearchManager.java | 18 +- .../textures/block/fluids/fluid.potion.png | Bin 0 -> 33496 bytes .../block/fluids/fluid.potion.png.mcmeta | 5 + src/main/resources/gtceu.mixins.json | 1 + 37 files changed, 999 insertions(+), 220 deletions(-) create mode 100644 src/generated/resources/data/forge/tags/fluids/potion.json create mode 100644 src/main/java/com/gregtechceu/gtceu/common/fluid/potion/PotionFluid.java create mode 100644 src/main/java/com/gregtechceu/gtceu/common/fluid/potion/PotionFluidHelper.java create mode 100644 src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/BreweryLogic.java create mode 100644 src/main/java/com/gregtechceu/gtceu/core/mixins/PotionBrewingAccessor.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/jei/subtype/PotionFluidSubtypeInterpreter.java create mode 100644 src/main/resources/assets/gtceu/textures/block/fluids/fluid.potion.png create mode 100644 src/main/resources/assets/gtceu/textures/block/fluids/fluid.potion.png.mcmeta diff --git a/src/generated/resources/assets/gtceu/lang/en_ud.json b/src/generated/resources/assets/gtceu/lang/en_ud.json index 30317b09da..d51bd14264 100644 --- a/src/generated/resources/assets/gtceu/lang/en_ud.json +++ b/src/generated/resources/assets/gtceu/lang/en_ud.json @@ -218,10 +218,6 @@ "block.gtceu.ev_diode": "ǝpoıᗡ ΛƎϛ§", "block.gtceu.ev_distillery": "ɹ§III ʎɹǝןןıʇsıᗡ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_electric_furnace": "ɹ§III ǝɔɐuɹnℲ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", - "block.gtceu.ev_electric_gear_box_16a": "ɹ§III Ɐ9Ɩ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", - "block.gtceu.ev_electric_gear_box_2a": "ɹ§III Ɐᄅ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", - "block.gtceu.ev_electric_gear_box_32a": "ɹ§III ⱯᄅƐ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", - "block.gtceu.ev_electric_gear_box_8a": "ɹ§III Ɐ8 xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_electrolyzer": "ɹ§III ɹǝzʎןoɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_electromagnetic_separator": "ɹ§III ɹoʇɐɹɐdǝS ɔıʇǝubɐɯoɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_energy_input_hatch": "ɥɔʇɐH ʎbɹǝuƎ ΛƎϛ§", @@ -248,9 +244,6 @@ "block.gtceu.ev_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛƎϛ§", "block.gtceu.ev_item_collector": "ɹ§III ɹoʇɔǝןןoƆ ɯǝʇI pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛƎϛ§", - "block.gtceu.ev_kinetic_input_box": "ɹ§III xoᗺ ʇnduI ɔıʇǝuıʞ pǝɔuɐʌpⱯϛ§", - "block.gtceu.ev_kinetic_mixer": "ɹ§III ɹǝxıW ɔıʇǝuıʞ pǝɔuɐʌpⱯϛ§", - "block.gtceu.ev_kinetic_output_box": "ɹ§III xoᗺ ʇndʇnO ɔıʇǝuıʞ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_lapotronic_battery": "ɹoʇıɔɐdɐƆ ɔıuoɹʇodɐꞀ ΛƎ", "block.gtceu.ev_large_miner": "ɹ§III ɹǝuıW ǝbɹɐꞀ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_laser_engraver": "ɹ§III ɹǝʌɐɹbuƎ ɹǝsɐꞀ pǝɔuɐʌpⱯϛ§", @@ -369,10 +362,6 @@ "block.gtceu.hv_diode": "ǝpoıᗡ ΛH9§", "block.gtceu.hv_distillery": "ɹ§II ʎɹǝןןıʇsıᗡ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_electric_furnace": "ɹ§II ǝɔɐuɹnℲ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", - "block.gtceu.hv_electric_gear_box_16a": "ɹ§II Ɐ9Ɩ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", - "block.gtceu.hv_electric_gear_box_2a": "ɹ§II Ɐᄅ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", - "block.gtceu.hv_electric_gear_box_32a": "ɹ§II ⱯᄅƐ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", - "block.gtceu.hv_electric_gear_box_8a": "ɹ§II Ɐ8 xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_electrolyzer": "ɹ§II ɹǝzʎןoɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_electromagnetic_separator": "ɹ§II ɹoʇɐɹɐdǝS ɔıʇǝubɐɯoɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_energy_input_hatch": "ɥɔʇɐH ʎbɹǝuƎ ΛH9§", @@ -394,9 +383,6 @@ "block.gtceu.hv_input_hatch": "ɥɔʇɐH ʇnduI ΛH9§", "block.gtceu.hv_item_collector": "ɹ§II ɹoʇɔǝןןoƆ ɯǝʇI pǝɔuɐʌpⱯ9§", "block.gtceu.hv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛH9§", - "block.gtceu.hv_kinetic_input_box": "ɹ§II xoᗺ ʇnduI ɔıʇǝuıʞ pǝɔuɐʌpⱯ9§", - "block.gtceu.hv_kinetic_mixer": "ɹ§II ɹǝxıW ɔıʇǝuıʞ pǝɔuɐʌpⱯ9§", - "block.gtceu.hv_kinetic_output_box": "ɹ§II xoᗺ ʇndʇnO ɔıʇǝuıʞ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_laser_engraver": "ɹ§II ɹǝʌɐɹbuƎ ɹǝsɐꞀ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_lathe": "ɹ§II ǝɥʇɐꞀ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_macerator": "ɹ§II ɹoʇɐɹǝɔɐW pǝɔuɐʌpⱯ9§", @@ -484,8 +470,6 @@ "block.gtceu.iv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛI6§", "block.gtceu.iv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛI6§", "block.gtceu.iv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛI6§", - "block.gtceu.iv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ǝʇıןƎ6§", - "block.gtceu.iv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ǝʇıןƎ6§", "block.gtceu.iv_lapotronic_battery": "ɹoʇıɔɐdɐƆ ɔıuoɹʇodɐꞀ ΛI", "block.gtceu.iv_large_miner": "ɹ§ ɹǝuıW ǝbɹɐꞀ ǝʇıןƎ6§", "block.gtceu.iv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ǝʇıןƎ6§", @@ -650,8 +634,6 @@ "block.gtceu.luv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛnꞀp§", "block.gtceu.luv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛnꞀp§", "block.gtceu.luv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛnꞀp§", - "block.gtceu.luv_kinetic_input_box": "ɹ§II xoᗺ ʇnduI ɔıʇǝuıʞ ǝʇıןƎp§", - "block.gtceu.luv_kinetic_output_box": "ɹ§II xoᗺ ʇndʇnO ɔıʇǝuıʞ ǝʇıןƎp§", "block.gtceu.luv_lapotronic_battery": "ɹoʇıɔɐdɐƆ ɔıuoɹʇodɐꞀ ΛnꞀ", "block.gtceu.luv_large_miner": "ɹ§II ɹǝuıW ǝbɹɐꞀ ǝʇıןƎp§", "block.gtceu.luv_laser_engraver": "ɹ§II ɹǝʌɐɹbuƎ ɹǝsɐꞀ ǝʇıןƎp§", @@ -712,10 +694,6 @@ "block.gtceu.lv_diode": "ǝpoıᗡ ΛꞀㄥ§", "block.gtceu.lv_distillery": "ɹ§ ʎɹǝןןıʇsıᗡ ɔısɐᗺ", "block.gtceu.lv_electric_furnace": "ɹ§ ǝɔɐuɹnℲ ɔıɹʇɔǝןƎ ɔısɐᗺ", - "block.gtceu.lv_electric_gear_box_16a": "ɹ§ Ɐ9Ɩ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ ɔısɐᗺ", - "block.gtceu.lv_electric_gear_box_2a": "ɹ§ Ɐᄅ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ ɔısɐᗺ", - "block.gtceu.lv_electric_gear_box_32a": "ɹ§ ⱯᄅƐ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ ɔısɐᗺ", - "block.gtceu.lv_electric_gear_box_8a": "ɹ§ Ɐ8 xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ ɔısɐᗺ", "block.gtceu.lv_electrolyzer": "ɹ§ ɹǝzʎןoɹʇɔǝןƎ ɔısɐᗺ", "block.gtceu.lv_electromagnetic_separator": "ɹ§ ɹoʇɐɹɐdǝS ɔıʇǝubɐɯoɹʇɔǝןƎ ɔısɐᗺ", "block.gtceu.lv_energy_input_hatch": "ɥɔʇɐH ʎbɹǝuƎ ΛꞀㄥ§", @@ -736,9 +714,6 @@ "block.gtceu.lv_input_hatch": "ɥɔʇɐH ʇnduI ΛꞀㄥ§", "block.gtceu.lv_item_collector": "ɹ§ ɹoʇɔǝןןoƆ ɯǝʇI ɔısɐᗺ", "block.gtceu.lv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛꞀㄥ§", - "block.gtceu.lv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ɔısɐᗺ", - "block.gtceu.lv_kinetic_mixer": "ɹ§ ɹǝxıW ɔıʇǝuıʞ ɔısɐᗺ", - "block.gtceu.lv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ɔısɐᗺ", "block.gtceu.lv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ɔısɐᗺ", "block.gtceu.lv_lathe": "ɹ§ ǝɥʇɐꞀ ɔısɐᗺ", "block.gtceu.lv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW ɔısɐᗺ", @@ -861,10 +836,6 @@ "block.gtceu.mv_diode": "ǝpoıᗡ ΛWq§", "block.gtceu.mv_distillery": "ɹ§ ʎɹǝןןıʇsıᗡ pǝɔuɐʌpⱯq§", "block.gtceu.mv_electric_furnace": "ɹ§ ǝɔɐuɹnℲ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯq§", - "block.gtceu.mv_electric_gear_box_16a": "ɹ§ Ɐ9Ɩ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯq§", - "block.gtceu.mv_electric_gear_box_2a": "ɹ§ Ɐᄅ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯq§", - "block.gtceu.mv_electric_gear_box_32a": "ɹ§ ⱯᄅƐ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯq§", - "block.gtceu.mv_electric_gear_box_8a": "ɹ§ Ɐ8 xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯq§", "block.gtceu.mv_electrolyzer": "ɹ§ ɹǝzʎןoɹʇɔǝןƎ pǝɔuɐʌpⱯq§", "block.gtceu.mv_electromagnetic_separator": "ɹ§ ɹoʇɐɹɐdǝS ɔıʇǝubɐɯoɹʇɔǝןƎ pǝɔuɐʌpⱯq§", "block.gtceu.mv_energy_input_hatch": "ɥɔʇɐH ʎbɹǝuƎ ΛWq§", @@ -886,9 +857,6 @@ "block.gtceu.mv_input_hatch": "ɥɔʇɐH ʇnduI ΛWq§", "block.gtceu.mv_item_collector": "ɹ§ ɹoʇɔǝןןoƆ ɯǝʇI pǝɔuɐʌpⱯq§", "block.gtceu.mv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛWq§", - "block.gtceu.mv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ pǝɔuɐʌpⱯq§", - "block.gtceu.mv_kinetic_mixer": "ɹ§ ɹǝxıW ɔıʇǝuıʞ pǝɔuɐʌpⱯq§", - "block.gtceu.mv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ pǝɔuɐʌpⱯq§", "block.gtceu.mv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ pǝɔuɐʌpⱯq§", "block.gtceu.mv_lathe": "ɹ§ ǝɥʇɐꞀ pǝɔuɐʌpⱯq§", "block.gtceu.mv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW pǝɔuɐʌpⱯq§", @@ -984,8 +952,6 @@ "block.gtceu.opv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛdOן§6§", "block.gtceu.opv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛdOן§6§", "block.gtceu.opv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛdOן§6§", - "block.gtceu.opv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ʎɹɐpuǝbǝꞀן§6§", - "block.gtceu.opv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ʎɹɐpuǝbǝꞀן§6§", "block.gtceu.opv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ʎɹɐpuǝbǝꞀן§6§", "block.gtceu.opv_lathe": "ɹ§ ǝɥʇɐꞀ ʎɹɐpuǝbǝꞀן§6§", "block.gtceu.opv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW ʎɹɐpuǝbǝꞀן§6§", @@ -1230,8 +1196,6 @@ "block.gtceu.uev_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛƎ∩ɐ§", "block.gtceu.uev_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛƎ∩ɐ§", "block.gtceu.uev_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛƎ∩ɐ§", - "block.gtceu.uev_kinetic_input_box": "ɹ§II xoᗺ ʇnduI ɔıʇǝuıʞ ɔıdƎɐ§", - "block.gtceu.uev_kinetic_output_box": "ɹ§II xoᗺ ʇndʇnO ɔıʇǝuıʞ ɔıdƎɐ§", "block.gtceu.uev_laser_engraver": "ɹ§II ɹǝʌɐɹbuƎ ɹǝsɐꞀ ɔıdƎɐ§", "block.gtceu.uev_lathe": "ɹ§II ǝɥʇɐꞀ ɔıdƎɐ§", "block.gtceu.uev_macerator": "ɹ§II ɹoʇɐɹǝɔɐW ɔıdƎɐ§", @@ -1315,8 +1279,6 @@ "block.gtceu.uhv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛH∩ㄣ§", "block.gtceu.uhv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛH∩ㄣ§", "block.gtceu.uhv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛH∩ㄣ§", - "block.gtceu.uhv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ɔıdƎㄣ§", - "block.gtceu.uhv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ɔıdƎㄣ§", "block.gtceu.uhv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ɔıdƎㄣ§", "block.gtceu.uhv_lathe": "ɹ§ ǝɥʇɐꞀ ɔıdƎㄣ§", "block.gtceu.uhv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW ɔıdƎㄣ§", @@ -1400,8 +1362,6 @@ "block.gtceu.uiv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛI∩ᄅ§", "block.gtceu.uiv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛI∩ᄅ§", "block.gtceu.uiv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛI∩ᄅ§", - "block.gtceu.uiv_kinetic_input_box": "ɹ§III xoᗺ ʇnduI ɔıʇǝuıʞ ɔıdƎᄅ§", - "block.gtceu.uiv_kinetic_output_box": "ɹ§III xoᗺ ʇndʇnO ɔıʇǝuıʞ ɔıdƎᄅ§", "block.gtceu.uiv_laser_engraver": "ɹ§III ɹǝʌɐɹbuƎ ɹǝsɐꞀ ɔıdƎᄅ§", "block.gtceu.uiv_lathe": "ɹ§III ǝɥʇɐꞀ ɔıdƎᄅ§", "block.gtceu.uiv_macerator": "ɹ§III ɹoʇɐɹǝɔɐW ɔıdƎᄅ§", @@ -1506,8 +1466,6 @@ "block.gtceu.uv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ Λ∩Ɛ§", "block.gtceu.uv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN Λ∩Ɛ§", "block.gtceu.uv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI Λ∩Ɛ§", - "block.gtceu.uv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ǝʇɐɯıʇן∩Ɛ§", - "block.gtceu.uv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ǝʇɐɯıʇן∩Ɛ§", "block.gtceu.uv_lapotronic_battery": "ɹoʇıɔɐdɐƆ ɔıuoɹʇodɐꞀ Λ∩", "block.gtceu.uv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ǝʇɐɯıʇן∩Ɛ§", "block.gtceu.uv_lathe": "ɹ§ ǝɥʇɐꞀ ǝʇɐɯıʇן∩Ɛ§", @@ -1593,8 +1551,6 @@ "block.gtceu.uxv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛX∩ǝ§", "block.gtceu.uxv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛX∩ǝ§", "block.gtceu.uxv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛX∩ǝ§", - "block.gtceu.uxv_kinetic_input_box": "ɹ§ΛI xoᗺ ʇnduI ɔıʇǝuıʞ ɔıdƎǝ§", - "block.gtceu.uxv_kinetic_output_box": "ɹ§ΛI xoᗺ ʇndʇnO ɔıʇǝuıʞ ɔıdƎǝ§", "block.gtceu.uxv_laser_engraver": "ɹ§ΛI ɹǝʌɐɹbuƎ ɹǝsɐꞀ ɔıdƎǝ§", "block.gtceu.uxv_lathe": "ɹ§ΛI ǝɥʇɐꞀ ɔıdƎǝ§", "block.gtceu.uxv_macerator": "ɹ§ΛI ɹoʇɐɹǝɔɐW ɔıdƎǝ§", @@ -1713,8 +1669,6 @@ "block.gtceu.zpm_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ WԀZɔ§", "block.gtceu.zpm_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN WԀZɔ§", "block.gtceu.zpm_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI WԀZɔ§", - "block.gtceu.zpm_kinetic_input_box": "ɹ§III xoᗺ ʇnduI ɔıʇǝuıʞ ǝʇıןƎɔ§", - "block.gtceu.zpm_kinetic_output_box": "ɹ§III xoᗺ ʇndʇnO ɔıʇǝuıʞ ǝʇıןƎɔ§", "block.gtceu.zpm_lapotronic_battery": "ɹoʇıɔɐdɐƆ ɔıuoɹʇodɐꞀ WԀZ", "block.gtceu.zpm_laser_engraver": "ɹ§III ɹǝʌɐɹbuƎ ɹǝsɐꞀ ǝʇıןƎɔ§", "block.gtceu.zpm_lathe": "ɹ§III ǝɥʇɐꞀ ǝʇıןƎɔ§", @@ -2159,6 +2113,7 @@ "entity.gtceu.industrial_tnt": "⟘N⟘ ןɐıɹʇsnpuI", "entity.gtceu.powderbarrel": "ןǝɹɹɐqɹǝpʍoԀ", "fluid.empty": "ʎʇdɯƎ", + "fluid.gtceu.potion": "uoıʇoԀ", "fluid.spawnlocation.name": "uoıʇɐɯɹoɟuI uıǝΛ pınןℲ", "fluid.tile.lava": "ɐʌɐꞀ", "fluid.tile.water": "ɹǝʇɐM", @@ -2233,7 +2188,6 @@ "gtceu.cover.item_detector.message_item_storage_inverted": "ǝbɐɹoʇS ɯǝʇI pǝʇɹǝʌuI buıɹoʇıuoW", "gtceu.cover.item_detector.message_item_storage_normal": "ǝbɐɹoʇS ɯǝʇI ןɐɯɹoN buıɹoʇıuoW", "gtceu.cracker": "ɹǝʞɔɐɹƆ", - "gtceu.create_mixer": "ɹǝxıW ǝʇɐǝɹƆ", "gtceu.creative.activity.off": "ǝʌıʇɔɐ ʇoN", "gtceu.creative.activity.on": "ǝʌıʇɔⱯ", "gtceu.creative.chest.ipc": "ǝןɔʎƆ ɹǝd sɯǝʇI", @@ -3445,6 +3399,7 @@ "gtceu.recipe_memory_widget.tooltip.0": "pıɹb buıʇɟɐɹɔ ǝɥʇ oʇuı ǝdıɔǝɹ sıɥʇ ʇnduı ʎןןɐɔıʇɐɯoʇnɐ oʇ ʞɔıןɔ ʇɟǝꞀㄥ§", "gtceu.recipe_memory_widget.tooltip.1": "ǝdıɔǝɹ sıɥʇ ʞɔoןun/ʞɔoן oʇ ʞɔıןɔ ʇɟıɥSㄥ§", "gtceu.recipe_type.show_recipes": "sǝdıɔǝᴚ ʍoɥS", + "gtceu.rei.group.potion_fluids": "spınןℲ uoıʇoԀ", "gtceu.research_station": "uoıʇɐʇS ɥɔɹɐǝsǝᴚ", "gtceu.rock_breaker": "ɹǝʞɐǝɹᗺ ʞɔoᴚ", "gtceu.scanner": "ɹǝuuɐɔS", @@ -5063,6 +5018,7 @@ "material.gtceu.nether_air": "ɹıⱯ ɹǝɥʇǝN", "material.gtceu.nether_quartz": "zʇɹɐnὉ ɹǝɥʇǝN", "material.gtceu.nether_star": "ɹɐʇS ɹǝɥʇǝN", + "material.gtceu.netherite": "ǝʇıɹǝɥʇǝN", "material.gtceu.netherrack": "ʞɔɐɹɹǝɥʇǝN", "material.gtceu.neutronium": "ɯnıuoɹʇnǝN", "material.gtceu.nichrome": "ǝɯoɹɥɔıN", diff --git a/src/generated/resources/assets/gtceu/lang/en_us.json b/src/generated/resources/assets/gtceu/lang/en_us.json index 3e67fe9ca1..3989cff287 100644 --- a/src/generated/resources/assets/gtceu/lang/en_us.json +++ b/src/generated/resources/assets/gtceu/lang/en_us.json @@ -218,10 +218,6 @@ "block.gtceu.ev_diode": "§5EV Diode", "block.gtceu.ev_distillery": "§5Advanced Distillery III§r", "block.gtceu.ev_electric_furnace": "§5Advanced Electric Furnace III§r", - "block.gtceu.ev_electric_gear_box_16a": "§5Advanced Electric Gearbox 16A III§r", - "block.gtceu.ev_electric_gear_box_2a": "§5Advanced Electric Gearbox 2A III§r", - "block.gtceu.ev_electric_gear_box_32a": "§5Advanced Electric Gearbox 32A III§r", - "block.gtceu.ev_electric_gear_box_8a": "§5Advanced Electric Gearbox 8A III§r", "block.gtceu.ev_electrolyzer": "§5Advanced Electrolyzer III§r", "block.gtceu.ev_electromagnetic_separator": "§5Advanced Electromagnetic Separator III§r", "block.gtceu.ev_energy_input_hatch": "§5EV Energy Hatch", @@ -248,9 +244,6 @@ "block.gtceu.ev_input_hatch_9x": "§5EV Nonuple Input Hatch", "block.gtceu.ev_item_collector": "§5Advanced Item Collector III§r", "block.gtceu.ev_item_passthrough_hatch": "§5EV Item Passthrough Hatch", - "block.gtceu.ev_kinetic_input_box": "§5Advanced Kinetic Input Box III§r", - "block.gtceu.ev_kinetic_mixer": "§5Advanced Kinetic Mixer III§r", - "block.gtceu.ev_kinetic_output_box": "§5Advanced Kinetic Output Box III§r", "block.gtceu.ev_lapotronic_battery": "EV Lapotronic Capacitor", "block.gtceu.ev_large_miner": "§5Advanced Large Miner III§r", "block.gtceu.ev_laser_engraver": "§5Advanced Laser Engraver III§r", @@ -369,10 +362,6 @@ "block.gtceu.hv_diode": "§6HV Diode", "block.gtceu.hv_distillery": "§6Advanced Distillery II§r", "block.gtceu.hv_electric_furnace": "§6Advanced Electric Furnace II§r", - "block.gtceu.hv_electric_gear_box_16a": "§6Advanced Electric Gearbox 16A II§r", - "block.gtceu.hv_electric_gear_box_2a": "§6Advanced Electric Gearbox 2A II§r", - "block.gtceu.hv_electric_gear_box_32a": "§6Advanced Electric Gearbox 32A II§r", - "block.gtceu.hv_electric_gear_box_8a": "§6Advanced Electric Gearbox 8A II§r", "block.gtceu.hv_electrolyzer": "§6Advanced Electrolyzer II§r", "block.gtceu.hv_electromagnetic_separator": "§6Advanced Electromagnetic Separator II§r", "block.gtceu.hv_energy_input_hatch": "§6HV Energy Hatch", @@ -394,9 +383,6 @@ "block.gtceu.hv_input_hatch": "§6HV Input Hatch", "block.gtceu.hv_item_collector": "§6Advanced Item Collector II§r", "block.gtceu.hv_item_passthrough_hatch": "§6HV Item Passthrough Hatch", - "block.gtceu.hv_kinetic_input_box": "§6Advanced Kinetic Input Box II§r", - "block.gtceu.hv_kinetic_mixer": "§6Advanced Kinetic Mixer II§r", - "block.gtceu.hv_kinetic_output_box": "§6Advanced Kinetic Output Box II§r", "block.gtceu.hv_laser_engraver": "§6Advanced Laser Engraver II§r", "block.gtceu.hv_lathe": "§6Advanced Lathe II§r", "block.gtceu.hv_macerator": "§6Advanced Macerator II§r", @@ -484,8 +470,6 @@ "block.gtceu.iv_input_hatch_4x": "§9IV Quadruple Input Hatch", "block.gtceu.iv_input_hatch_9x": "§9IV Nonuple Input Hatch", "block.gtceu.iv_item_passthrough_hatch": "§9IV Item Passthrough Hatch", - "block.gtceu.iv_kinetic_input_box": "§9Elite Kinetic Input Box §r", - "block.gtceu.iv_kinetic_output_box": "§9Elite Kinetic Output Box §r", "block.gtceu.iv_lapotronic_battery": "IV Lapotronic Capacitor", "block.gtceu.iv_large_miner": "§9Elite Large Miner §r", "block.gtceu.iv_laser_engraver": "§9Elite Laser Engraver §r", @@ -650,8 +634,6 @@ "block.gtceu.luv_input_hatch_4x": "§dLuV Quadruple Input Hatch", "block.gtceu.luv_input_hatch_9x": "§dLuV Nonuple Input Hatch", "block.gtceu.luv_item_passthrough_hatch": "§dLuV Item Passthrough Hatch", - "block.gtceu.luv_kinetic_input_box": "§dElite Kinetic Input Box II§r", - "block.gtceu.luv_kinetic_output_box": "§dElite Kinetic Output Box II§r", "block.gtceu.luv_lapotronic_battery": "LuV Lapotronic Capacitor", "block.gtceu.luv_large_miner": "§dElite Large Miner II§r", "block.gtceu.luv_laser_engraver": "§dElite Laser Engraver II§r", @@ -712,10 +694,6 @@ "block.gtceu.lv_diode": "§7LV Diode", "block.gtceu.lv_distillery": "Basic Distillery §r", "block.gtceu.lv_electric_furnace": "Basic Electric Furnace §r", - "block.gtceu.lv_electric_gear_box_16a": "Basic Electric Gearbox 16A §r", - "block.gtceu.lv_electric_gear_box_2a": "Basic Electric Gearbox 2A §r", - "block.gtceu.lv_electric_gear_box_32a": "Basic Electric Gearbox 32A §r", - "block.gtceu.lv_electric_gear_box_8a": "Basic Electric Gearbox 8A §r", "block.gtceu.lv_electrolyzer": "Basic Electrolyzer §r", "block.gtceu.lv_electromagnetic_separator": "Basic Electromagnetic Separator §r", "block.gtceu.lv_energy_input_hatch": "§7LV Energy Hatch", @@ -736,9 +714,6 @@ "block.gtceu.lv_input_hatch": "§7LV Input Hatch", "block.gtceu.lv_item_collector": "Basic Item Collector §r", "block.gtceu.lv_item_passthrough_hatch": "§7LV Item Passthrough Hatch", - "block.gtceu.lv_kinetic_input_box": "Basic Kinetic Input Box §r", - "block.gtceu.lv_kinetic_mixer": "Basic Kinetic Mixer §r", - "block.gtceu.lv_kinetic_output_box": "Basic Kinetic Output Box §r", "block.gtceu.lv_laser_engraver": "Basic Laser Engraver §r", "block.gtceu.lv_lathe": "Basic Lathe §r", "block.gtceu.lv_macerator": "Basic Macerator §r", @@ -861,10 +836,6 @@ "block.gtceu.mv_diode": "§bMV Diode", "block.gtceu.mv_distillery": "§bAdvanced Distillery §r", "block.gtceu.mv_electric_furnace": "§bAdvanced Electric Furnace §r", - "block.gtceu.mv_electric_gear_box_16a": "§bAdvanced Electric Gearbox 16A §r", - "block.gtceu.mv_electric_gear_box_2a": "§bAdvanced Electric Gearbox 2A §r", - "block.gtceu.mv_electric_gear_box_32a": "§bAdvanced Electric Gearbox 32A §r", - "block.gtceu.mv_electric_gear_box_8a": "§bAdvanced Electric Gearbox 8A §r", "block.gtceu.mv_electrolyzer": "§bAdvanced Electrolyzer §r", "block.gtceu.mv_electromagnetic_separator": "§bAdvanced Electromagnetic Separator §r", "block.gtceu.mv_energy_input_hatch": "§bMV Energy Hatch", @@ -886,9 +857,6 @@ "block.gtceu.mv_input_hatch": "§bMV Input Hatch", "block.gtceu.mv_item_collector": "§bAdvanced Item Collector §r", "block.gtceu.mv_item_passthrough_hatch": "§bMV Item Passthrough Hatch", - "block.gtceu.mv_kinetic_input_box": "§bAdvanced Kinetic Input Box §r", - "block.gtceu.mv_kinetic_mixer": "§bAdvanced Kinetic Mixer §r", - "block.gtceu.mv_kinetic_output_box": "§bAdvanced Kinetic Output Box §r", "block.gtceu.mv_laser_engraver": "§bAdvanced Laser Engraver §r", "block.gtceu.mv_lathe": "§bAdvanced Lathe §r", "block.gtceu.mv_macerator": "§bAdvanced Macerator §r", @@ -984,8 +952,6 @@ "block.gtceu.opv_input_hatch_4x": "§9§lOpV Quadruple Input Hatch", "block.gtceu.opv_input_hatch_9x": "§9§lOpV Nonuple Input Hatch", "block.gtceu.opv_item_passthrough_hatch": "§9§lOpV Item Passthrough Hatch", - "block.gtceu.opv_kinetic_input_box": "§9§lLegendary Kinetic Input Box §r", - "block.gtceu.opv_kinetic_output_box": "§9§lLegendary Kinetic Output Box §r", "block.gtceu.opv_laser_engraver": "§9§lLegendary Laser Engraver §r", "block.gtceu.opv_lathe": "§9§lLegendary Lathe §r", "block.gtceu.opv_macerator": "§9§lLegendary Macerator §r", @@ -1230,8 +1196,6 @@ "block.gtceu.uev_input_hatch_4x": "§aUEV Quadruple Input Hatch", "block.gtceu.uev_input_hatch_9x": "§aUEV Nonuple Input Hatch", "block.gtceu.uev_item_passthrough_hatch": "§aUEV Item Passthrough Hatch", - "block.gtceu.uev_kinetic_input_box": "§aEpic Kinetic Input Box II§r", - "block.gtceu.uev_kinetic_output_box": "§aEpic Kinetic Output Box II§r", "block.gtceu.uev_laser_engraver": "§aEpic Laser Engraver II§r", "block.gtceu.uev_lathe": "§aEpic Lathe II§r", "block.gtceu.uev_macerator": "§aEpic Macerator II§r", @@ -1315,8 +1279,6 @@ "block.gtceu.uhv_input_hatch_4x": "§4UHV Quadruple Input Hatch", "block.gtceu.uhv_input_hatch_9x": "§4UHV Nonuple Input Hatch", "block.gtceu.uhv_item_passthrough_hatch": "§4UHV Item Passthrough Hatch", - "block.gtceu.uhv_kinetic_input_box": "§4Epic Kinetic Input Box §r", - "block.gtceu.uhv_kinetic_output_box": "§4Epic Kinetic Output Box §r", "block.gtceu.uhv_laser_engraver": "§4Epic Laser Engraver §r", "block.gtceu.uhv_lathe": "§4Epic Lathe §r", "block.gtceu.uhv_macerator": "§4Epic Macerator §r", @@ -1400,8 +1362,6 @@ "block.gtceu.uiv_input_hatch_4x": "§2UIV Quadruple Input Hatch", "block.gtceu.uiv_input_hatch_9x": "§2UIV Nonuple Input Hatch", "block.gtceu.uiv_item_passthrough_hatch": "§2UIV Item Passthrough Hatch", - "block.gtceu.uiv_kinetic_input_box": "§2Epic Kinetic Input Box III§r", - "block.gtceu.uiv_kinetic_output_box": "§2Epic Kinetic Output Box III§r", "block.gtceu.uiv_laser_engraver": "§2Epic Laser Engraver III§r", "block.gtceu.uiv_lathe": "§2Epic Lathe III§r", "block.gtceu.uiv_macerator": "§2Epic Macerator III§r", @@ -1506,8 +1466,6 @@ "block.gtceu.uv_input_hatch_4x": "§3UV Quadruple Input Hatch", "block.gtceu.uv_input_hatch_9x": "§3UV Nonuple Input Hatch", "block.gtceu.uv_item_passthrough_hatch": "§3UV Item Passthrough Hatch", - "block.gtceu.uv_kinetic_input_box": "§3Ultimate Kinetic Input Box §r", - "block.gtceu.uv_kinetic_output_box": "§3Ultimate Kinetic Output Box §r", "block.gtceu.uv_lapotronic_battery": "UV Lapotronic Capacitor", "block.gtceu.uv_laser_engraver": "§3Ultimate Laser Engraver §r", "block.gtceu.uv_lathe": "§3Ultimate Lathe §r", @@ -1593,8 +1551,6 @@ "block.gtceu.uxv_input_hatch_4x": "§eUXV Quadruple Input Hatch", "block.gtceu.uxv_input_hatch_9x": "§eUXV Nonuple Input Hatch", "block.gtceu.uxv_item_passthrough_hatch": "§eUXV Item Passthrough Hatch", - "block.gtceu.uxv_kinetic_input_box": "§eEpic Kinetic Input Box IV§r", - "block.gtceu.uxv_kinetic_output_box": "§eEpic Kinetic Output Box IV§r", "block.gtceu.uxv_laser_engraver": "§eEpic Laser Engraver IV§r", "block.gtceu.uxv_lathe": "§eEpic Lathe IV§r", "block.gtceu.uxv_macerator": "§eEpic Macerator IV§r", @@ -1713,8 +1669,6 @@ "block.gtceu.zpm_input_hatch_4x": "§cZPM Quadruple Input Hatch", "block.gtceu.zpm_input_hatch_9x": "§cZPM Nonuple Input Hatch", "block.gtceu.zpm_item_passthrough_hatch": "§cZPM Item Passthrough Hatch", - "block.gtceu.zpm_kinetic_input_box": "§cElite Kinetic Input Box III§r", - "block.gtceu.zpm_kinetic_output_box": "§cElite Kinetic Output Box III§r", "block.gtceu.zpm_lapotronic_battery": "ZPM Lapotronic Capacitor", "block.gtceu.zpm_laser_engraver": "§cElite Laser Engraver III§r", "block.gtceu.zpm_lathe": "§cElite Lathe III§r", @@ -2159,6 +2113,7 @@ "entity.gtceu.industrial_tnt": "Industrial TNT", "entity.gtceu.powderbarrel": "Powderbarrel", "fluid.empty": "Empty", + "fluid.gtceu.potion": "Potion", "fluid.spawnlocation.name": "Fluid Vein Information", "fluid.tile.lava": "Lava", "fluid.tile.water": "Water", @@ -2233,7 +2188,6 @@ "gtceu.cover.item_detector.message_item_storage_inverted": "Monitoring Inverted Item Storage", "gtceu.cover.item_detector.message_item_storage_normal": "Monitoring Normal Item Storage", "gtceu.cracker": "Cracker", - "gtceu.create_mixer": "Create Mixer", "gtceu.creative.activity.off": "Not active", "gtceu.creative.activity.on": "Active", "gtceu.creative.chest.ipc": "Items per Cycle", @@ -3445,6 +3399,7 @@ "gtceu.recipe_memory_widget.tooltip.0": "§7Left click to automatically input this recipe into the crafting grid", "gtceu.recipe_memory_widget.tooltip.1": "§7Shift click to lock/unlock this recipe", "gtceu.recipe_type.show_recipes": "Show Recipes", + "gtceu.rei.group.potion_fluids": "Potion Fluids", "gtceu.research_station": "Research Station", "gtceu.rock_breaker": "Rock Breaker", "gtceu.scanner": "Scanner", @@ -5063,6 +5018,7 @@ "material.gtceu.nether_air": "Nether Air", "material.gtceu.nether_quartz": "Nether Quartz", "material.gtceu.nether_star": "Nether Star", + "material.gtceu.netherite": "Netherite", "material.gtceu.netherrack": "Netherrack", "material.gtceu.neutronium": "Neutronium", "material.gtceu.nichrome": "Nichrome", diff --git a/src/generated/resources/data/forge/tags/fluids/potion.json b/src/generated/resources/data/forge/tags/fluids/potion.json new file mode 100644 index 0000000000..a99661c023 --- /dev/null +++ b/src/generated/resources/data/forge/tags/fluids/potion.json @@ -0,0 +1,6 @@ +{ + "values": [ + "gtceu:flowing_potion", + "gtceu:potion" + ] +} \ No newline at end of file diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java index af4421acd2..c0b77fa8e2 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java @@ -34,10 +34,10 @@ import net.minecraftforge.fluids.FluidStack; import com.mojang.datafixers.util.Either; -import com.mojang.datafixers.util.Pair; import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.UnknownNullability; @@ -305,7 +305,7 @@ public Object createXEIContainer(List contents) { // cast is safe if you don't pass the wrong thing. // noinspection unchecked return new TagOrCycleFluidHandler( - (List, Integer>>, List>>) contents); + (List, Integer, @Nullable CompoundTag>>, List>>) contents); } @NotNull @@ -350,10 +350,7 @@ public void applyWidgetInfo(@NotNull Widget widget, FluidIngredient ingredient = FluidRecipeCapability.CAP.of(content.content); if (!isXEI && ingredient.getStacks().length > 0) { FluidStack stack = ingredient.getStacks()[0]; - TooltipsHandler.appendFluidTooltips(stack.getFluid(), - stack.getAmount(), - tooltips::add, - TooltipFlag.NORMAL); + TooltipsHandler.appendFluidTooltips(stack, tooltips::add, TooltipFlag.NORMAL); } GTRecipeWidget.setConsumedChance(content, @@ -371,15 +368,15 @@ public void applyWidgetInfo(@NotNull Widget widget, } // Maps fluids to Either<(tag with count), FluidStack>s - public static Either, Integer>>, List> mapFluid(FluidIngredient ingredient) { + public static Either, Integer, @Nullable CompoundTag>>, List> mapFluid(FluidIngredient ingredient) { int amount = ingredient.getAmount(); CompoundTag tag = ingredient.getNbt(); - List, Integer>> tags = new ArrayList<>(); + List, Integer, @Nullable CompoundTag>> tags = new ArrayList<>(); List fluids = new ArrayList<>(); for (FluidIngredient.Value value : ingredient.values) { if (value instanceof FluidIngredient.TagValue tagValue) { - tags.add(Pair.of(tagValue.getTag(), amount)); + tags.add(Triple.of(tagValue.getTag(), amount, ingredient.getNbt())); } else { fluids.addAll(value.getFluids().stream().map(fluid -> new FluidStack(fluid, amount, tag)).toList()); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java index f8ac38a7a9..965c7cdf9e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java @@ -36,6 +36,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.tags.TagKey; import net.minecraft.util.valueproviders.ConstantFloat; @@ -55,6 +56,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.UnknownNullability; @@ -420,7 +422,7 @@ private Object2IntMap getIngredientStacks(IRecipeCapabilityHolder hol .map(ItemRecipeCapability::mapItem) .collect(Collectors.toList()); - List, Integer>>, List>> scannerPossibilities = null; + List, Integer, @Nullable CompoundTag>>, List>> scannerPossibilities = null; if (io == IO.OUT && recipe.recipeType.isScanner()) { scannerPossibilities = new ArrayList<>(); // Scanner Output replacing, used for cycling research outputs @@ -439,11 +441,11 @@ private Object2IntMap getIngredientStacks(IRecipeCapabilityHolder hol researchItem = researchItem.copy(); researchItem.setCount(1); boolean didMatch = false; - for (Either, Integer>>, List> stacks : scannerPossibilities) { + for (Either, Integer, @Nullable CompoundTag>>, List> stacks : scannerPossibilities) { for (ItemStack stack : stacks.map( tag -> tag .stream() - .flatMap(key -> BuiltInRegistries.ITEM.getTag(key.getFirst()).stream()) + .flatMap(key -> BuiltInRegistries.ITEM.getTag(key.getLeft()).stream()) .flatMap(holders -> holders.stream() .map(holder -> new ItemStack(holder.get()))) .collect(Collectors.toList()), @@ -473,7 +475,7 @@ public Object createXEIContainer(List contents) { // cast is safe if you don't pass the wrong thing. // noinspection unchecked return new TagOrCycleItemStackHandler( - (List, Integer>>, List>>) contents); + (List, Integer, @Nullable CompoundTag>>, List>>) contents); } @NotNull @@ -567,7 +569,7 @@ public void applyWidgetInfo(@NotNull Widget widget, // Maps ingredients to Either <(Tag with count), ItemStack>s @SuppressWarnings("deprecation") - private static Either, Integer>>, List> mapItem(final Ingredient ingredient) { + private static Either, Integer, @Nullable CompoundTag>>, List> mapItem(final Ingredient ingredient) { if (ingredient instanceof SizedIngredient sizedIngredient) { final int amount = sizedIngredient.getAmount(); if (sizedIngredient.getInner() instanceof IntersectionIngredient intersection) { @@ -578,10 +580,14 @@ private static Either, Integer>>, List> mapIte var childEither = mapItem(children.get(0)); return Either.right(childEither.map(tags -> { List tagItems = tags.stream() - .map(pair -> Pair.of(BuiltInRegistries.ITEM.getTag(pair.getFirst()).stream(), - pair.getSecond())) - .flatMap(pair -> pair.getFirst().flatMap( - tag -> tag.stream().map(holder -> new ItemStack(holder.value(), pair.getSecond())))) + .map(pair -> Triple.of(BuiltInRegistries.ITEM.getTag(pair.getLeft()).stream(), + pair.getMiddle(), pair.getRight())) + .flatMap(pair -> pair.getLeft().flatMap( + tag -> tag.stream().map(holder -> { + ItemStack stack = new ItemStack(holder.value(), pair.getMiddle()); + stack.setTag(pair.getRight()); + return stack; + }))) .collect(Collectors.toList()); ListIterator iterator = tagItems.listIterator(); iteratorLoop: @@ -615,7 +621,8 @@ private static Either, Integer>>, List> mapIte } else if (((IngredientAccessor) sizedIngredient.getInner()).getValues().length > 0 && ((IngredientAccessor) sizedIngredient.getInner()) .getValues()[0] instanceof Ingredient.TagValue tagValue) { - return Either.left(List.of(Pair.of(((TagValueAccessor) tagValue).getTag(), amount))); + return Either + .left(List.of(Triple.of(((TagValueAccessor) tagValue).getTag(), amount, null))); } } else if (ingredient instanceof IntersectionIngredient intersection) { // Map intersection ingredients to the items inside, as recipe viewers don't support them. @@ -626,9 +633,14 @@ private static Either, Integer>>, List> mapIte var childEither = mapItem(children.get(0)); return Either.right(childEither.map(tags -> { List tagItems = tags.stream() - .map(pair -> Pair.of(BuiltInRegistries.ITEM.getTag(pair.getFirst()).stream(), pair.getSecond())) - .flatMap(pair -> pair.getFirst().flatMap( - tag -> tag.stream().map(holder -> new ItemStack(holder.value(), pair.getSecond())))) + .map(pair -> Triple.of(BuiltInRegistries.ITEM.getTag(pair.getLeft()).stream(), pair.getMiddle(), + pair.getRight())) + .flatMap(pair -> pair.getLeft().flatMap( + tag -> tag.stream().map(holder -> { + ItemStack stack = new ItemStack(holder.value(), pair.getMiddle()); + stack.setTag(pair.getRight()); + return stack; + }))) .collect(Collectors.toList()); ListIterator iterator = tagItems.listIterator(); while (iterator.hasNext()) { @@ -665,10 +677,14 @@ private static Either, Integer>>, List> mapIte var childEither = mapItem(children.get(0)); return Either.right(childEither.map(tags -> { List tagItems = tags.stream() - .map(pair -> Pair.of(BuiltInRegistries.ITEM.getTag(pair.getFirst()).stream(), - pair.getSecond())) - .flatMap(pair -> pair.getFirst().flatMap( - tag -> tag.stream().map(holder -> new ItemStack(holder.value(), pair.getSecond())))) + .map(pair -> Triple.of(BuiltInRegistries.ITEM.getTag(pair.getLeft()).stream(), + pair.getMiddle(), pair.getRight())) + .flatMap(pair -> pair.getLeft().flatMap( + tag -> tag.stream().map(holder -> { + ItemStack stack = new ItemStack(holder.value(), pair.getMiddle()); + stack.setTag(pair.getRight()); + return stack; + }))) .collect(Collectors.toList()); ListIterator iterator = tagItems.listIterator(); iteratorLoop: @@ -702,12 +718,13 @@ private static Either, Integer>>, List> mapIte } else if (((IngredientAccessor) intProvider.getInner()).getValues().length > 0 && ((IngredientAccessor) intProvider.getInner()) .getValues()[0] instanceof Ingredient.TagValue tagValue) { - return Either.left(List.of(Pair.of(((TagValueAccessor) tagValue).getTag(), amount))); + return Either + .left(List.of(Triple.of(((TagValueAccessor) tagValue).getTag(), amount, null))); } } else if (((IngredientAccessor) ingredient).getValues().length > 0 && ((IngredientAccessor) ingredient).getValues()[0] instanceof Ingredient.TagValue tagValue) { - return Either.left(List.of(Pair.of(((TagValueAccessor) tagValue).getTag(), 1))); + return Either.left(List.of(Triple.of(((TagValueAccessor) tagValue).getTag(), 1, null))); } return Either.right(Arrays.stream(ingredient.getItems()).map(stack -> { //@formatter:off diff --git a/src/main/java/com/gregtechceu/gtceu/api/fluids/store/FluidStorageKeys.java b/src/main/java/com/gregtechceu/gtceu/api/fluids/store/FluidStorageKeys.java index ba6717dde3..72ade027fb 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/fluids/store/FluidStorageKeys.java +++ b/src/main/java/com/gregtechceu/gtceu/api/fluids/store/FluidStorageKeys.java @@ -44,7 +44,7 @@ public final class FluidStorageKeys { FluidState.PLASMA, -1); public static final FluidStorageKey MOLTEN = new FluidStorageKey(GTCEu.id("molten"), - "moltens", + "molten", MaterialIconType.molten, m -> "molten_" + m.getName(), m -> "gtceu.fluid.molten", diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java index 89bb79fecf..3d1dfc3e40 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java @@ -15,6 +15,7 @@ import net.minecraft.core.HolderSet; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.tags.TagKey; import net.minecraft.world.Container; @@ -28,19 +29,26 @@ import net.minecraftforge.items.ItemStackHandler; import com.mojang.datafixers.util.Either; -import com.mojang.datafixers.util.Pair; +import dev.emi.emi.api.stack.EmiIngredient; +import dev.emi.emi.api.stack.EmiRegistryAdapter; +import dev.emi.emi.api.stack.EmiStack; +import dev.emi.emi.registry.EmiTags; import lombok.Getter; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; +import me.shedaniel.rei.api.common.util.EntryStacks; +import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.function.BiConsumer; import java.util.function.Function; +import java.util.function.UnaryOperator; import java.util.stream.Collectors; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import java.util.stream.Stream; @LDLRegister(name = "item_slot", group = "widget.container", priority = 50) public class SlotWidget extends com.lowdragmc.lowdraglib.gui.widget.SlotWidget { @@ -269,7 +277,7 @@ private List getXEIIngredientsFromCycleHandlerClickable(CycleItemStackHa } private List getXEIIngredientsFromTagOrCycleHandler(TagOrCycleItemStackHandler handler, int index) { - Either, Integer>>, List> either = handler + Either, Integer, @Nullable CompoundTag>>, List> either = handler .getStacks() .get(index); var ref = new Object() { @@ -280,10 +288,14 @@ private List getXEIIngredientsFromTagOrCycleHandler(TagOrCycleItemStackH if (LDLib.isJeiLoaded()) { ref.returnValue = list.stream() .flatMap(pair -> BuiltInRegistries.ITEM - .getTag(pair.getFirst()) + .getTag(pair.getLeft()) .stream() .flatMap(HolderSet.ListBacked::stream) - .map(item -> getRealStack(new ItemStack(item.value(), pair.getSecond())))) + .map(item -> { + ItemStack stack = new ItemStack(item.value(), pair.getMiddle()); + stack.setTag(pair.getRight()); + return getRealStack(stack); + })) .collect(Collectors.toList()); } else if (LDLib.isReiLoaded()) { ref.returnValue = REICallWrapper.getReiIngredients(this::getRealStack, list); @@ -307,7 +319,7 @@ private List getXEIIngredientsFromTagOrCycleHandler(TagOrCycleItemStackH private List getXEIIngredientsFromTagOrCycleHandlerClickable(TagOrCycleItemStackHandler handler, int index) { - Either, Integer>>, List> either = handler + Either, Integer, @Nullable CompoundTag>>, List> either = handler .getStacks() .get(index); var ref = new Object() { @@ -318,12 +330,15 @@ private List getXEIIngredientsFromTagOrCycleHandlerClickable(TagOrCycleI if (LDLib.isJeiLoaded()) { ref.returnValue = list.stream() .flatMap(pair -> BuiltInRegistries.ITEM - .getTag(pair.getFirst()) + .getTag(pair.getLeft()) .stream() .flatMap(HolderSet.ListBacked::stream) - .map(item -> JEIPlugin.getItemIngredient( - getRealStack(new ItemStack(item.value(), pair.getSecond())), - getPosition().x, getPosition().y, getSize().width, getSize().height))) + .map(item -> { + ItemStack stack = new ItemStack(item.value(), pair.getMiddle()); + stack.setTag(pair.getRight()); + return JEIPlugin.getItemIngredient(getRealStack(stack), + getPosition().x, getPosition().y, getSize().width, getSize().height); + })) .collect(Collectors.toList()); } else if (LDLib.isReiLoaded()) { ref.returnValue = REICallWrapper.getReiIngredients(this::getRealStack, list); @@ -361,7 +376,7 @@ public WidgetSlotItemHandler(IItemHandlerModifiable itemHandler, int index, int } @Override - public boolean mayPlace(@Nonnull ItemStack stack) { + public boolean mayPlace(@NotNull ItemStack stack) { return SlotWidget.this.canPutStack(stack) && (!stack.isEmpty() && this.itemHandler.isItemValid(this.index, stack)); } @@ -372,24 +387,24 @@ public boolean mayPickup(@Nullable Player playerIn) { } @Override - @Nonnull + @NotNull public ItemStack getItem() { return this.itemHandler.getStackInSlot(index); } @Override - public void setByPlayer(ItemStack stack) { + public void setByPlayer(@NotNull ItemStack stack) { this.itemHandler.setStackInSlot(index, stack); } @Override - public void set(@Nonnull ItemStack stack) { + public void set(@NotNull ItemStack stack) { this.itemHandler.setStackInSlot(index, stack); this.setChanged(); } @Override - public void onQuickCraft(@Nonnull ItemStack oldStackIn, @Nonnull ItemStack newStackIn) {} + public void onQuickCraft(@NotNull ItemStack oldStackIn, @NotNull ItemStack newStackIn) {} @Override public int getMaxStackSize() { @@ -397,7 +412,7 @@ public int getMaxStackSize() { } @Override - public int getMaxStackSize(@Nonnull ItemStack stack) { + public int getMaxStackSize(@NotNull ItemStack stack) { ItemStack maxAdd = stack.copy(); int maxInput = stack.getMaxStackSize(); maxAdd.setCount(maxInput); @@ -431,4 +446,55 @@ public boolean isActive() { return SlotWidget.this.isEnabled() && (HOVER_SLOT == null || HOVER_SLOT == this); } } + + public static final class REICallWrapper { + + public static List getReiIngredients(Stream stream) { + return List.of(EntryIngredient.of(stream.map(EntryStacks::of).toList())); + } + + public static List getReiIngredients(UnaryOperator realStack, + List, Integer, @Nullable CompoundTag>> list) { + return list.stream() + .map(pair -> EntryIngredients.ofTag(pair.getLeft(), + holder -> { + ItemStack stack = new ItemStack(holder.value(), pair.getMiddle()); + stack.setTag(pair.getRight()); + return EntryStacks.of(realStack.apply(stack)); + })) + .collect(Collectors.toList()); + } + + public static List getReiIngredients(ItemStack stack) { + return List.of(EntryStacks.of(stack)); + } + } + + public static final class EMICallWrapper { + + public static List getEmiIngredients(Stream stream, float xeiChance) { + return List.of(EmiIngredient.of(stream.map(EmiStack::of).toList()).setChance(xeiChance)); + } + + // ignore generics, repeat, ignore @ApiStatus.Experimental, ignore forge deprecations + @SuppressWarnings({ "unchecked", "rawtypes", "UnstableApiUsage", "deprecation" }) + public static List getEmiIngredients(List, Integer, @Nullable CompoundTag>> list, + float xeiChance) { + return list.stream() + .map(pair -> { + // slight trickery to get the NBT onto all the stacks in the tag. + EmiRegistryAdapter adapter = EmiTags.ADAPTERS_BY_REGISTRY.get(BuiltInRegistries.ITEM); + var stacks = BuiltInRegistries.ITEM.getTag(pair.getLeft()).stream() + .flatMap(HolderSet.ListBacked::stream) + .map(holder -> adapter.of(holder.value(), pair.getRight(), pair.getMiddle())) + .toList(); + return EmiIngredient.of(stacks).setAmount(pair.getMiddle()).setChance(xeiChance); + }) + .collect(Collectors.toList()); + } + + public static List getEmiIngredients(ItemStack stack, float xeiChance) { + return List.of(EmiStack.of(stack).setChance(xeiChance)); + } + } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java index 24e16b268e..31fb27e279 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java @@ -52,9 +52,10 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.datafixers.util.Either; -import com.mojang.datafixers.util.Pair; import dev.emi.emi.api.stack.EmiIngredient; +import dev.emi.emi.api.stack.EmiRegistryAdapter; import dev.emi.emi.api.stack.EmiStack; +import dev.emi.emi.registry.EmiTags; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @@ -62,6 +63,9 @@ import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; import mezz.jei.api.helpers.IPlatformFluidHelper; +import org.apache.commons.lang3.tuple.Triple; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; @@ -70,9 +74,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - @SuppressWarnings("unused") @LDLRegister(name = "fluid_slot", group = "widget.container", priority = 50) @Accessors(chain = true) @@ -277,7 +278,7 @@ private List getXEIIngredientsFromCycleHandlerClickable(CycleFluidHandle } private List getXEIIngredientsFromTagOrCycleHandler(TagOrCycleFluidHandler handler, int index) { - Either, Integer>>, List> either = handler + Either, Integer, @Nullable CompoundTag>>, List> either = handler .getStacks() .get(index); var ref = new Object() { @@ -288,10 +289,10 @@ private List getXEIIngredientsFromTagOrCycleHandler(TagOrCycleFluidHandl if (LDLib.isJeiLoaded()) { ref.returnValue = list.stream() .flatMap(pair -> BuiltInRegistries.FLUID - .getTag(pair.getFirst()) + .getTag(pair.getLeft()) .stream() .flatMap(HolderSet.ListBacked::stream) - .map(fluid -> new FluidStack(fluid.value(), pair.getSecond())) + .map(fluid -> new FluidStack(fluid.value(), pair.getMiddle(), pair.getRight())) .map(JEICallWrapper::getPlatformFluidTypeForJEI)) .collect(Collectors.toList()); } else if (LDLib.isReiLoaded()) { @@ -315,7 +316,7 @@ private List getXEIIngredientsFromTagOrCycleHandler(TagOrCycleFluidHandl } private List getXEIIngredientsFromTagOrCycleHandlerClickable(TagOrCycleFluidHandler handler, int index) { - Either, Integer>>, List> either = handler + Either, Integer, @Nullable CompoundTag>>, List> either = handler .getStacks() .get(index); var ref = new Object() { @@ -326,10 +327,10 @@ private List getXEIIngredientsFromTagOrCycleHandlerClickable(TagOrCycleF if (LDLib.isJeiLoaded()) { ref.returnValue = list.stream() .flatMap(pair -> BuiltInRegistries.FLUID - .getTag(pair.getFirst()) + .getTag(pair.getLeft()) .stream() .flatMap(HolderSet.ListBacked::stream) - .map(fluid -> new FluidStack(fluid.value(), pair.getSecond())) + .map(fluid -> new FluidStack(fluid.value(), pair.getMiddle(), pair.getRight())) .map(fluidStack -> JEICallWrapper.getPlatformFluidTypeForJEIClickable( fluidStack, getPosition(), getSize()))) .collect(Collectors.toList()); @@ -382,7 +383,7 @@ public List getFullTooltipTexts() { .append(" mB")); } if (ChemicalHelper.getMaterial(stack.getFluid()) != null) { - TooltipsHandler.appendFluidTooltips(stack.getFluid(), stack.getAmount(), tooltips::add, null); + TooltipsHandler.appendFluidTooltips(stack, tooltips::add, null); } else { tooltips.add(Component.translatable("ldlib.fluid.temperature", stack.getFluid().getFluidType().getTemperature(stack))); @@ -410,7 +411,7 @@ public void setCurrentJEIRenderedIngredient(Object ingredient) { @Override @OnlyIn(Dist.CLIENT) - public void drawInBackground(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { + public void drawInBackground(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { super.drawInBackground(graphics, mouseX, mouseY, partialTicks); if (isClientSideWidget && fluidTank != null) { FluidStack fluidStack = fluidTank.getFluidInTank(tank); @@ -470,7 +471,7 @@ public void drawInBackground(@Nonnull GuiGraphics graphics, int mouseX, int mous @Override @OnlyIn(Dist.CLIENT) - public void drawInForeground(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { + public void drawInForeground(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { if (drawHoverTips && isMouseOverElement(mouseX, mouseY) && getHoverElement(mouseX, mouseY) == this) { if (gui != null) { gui.getModularUIGui().setHoverTooltip(getFullTooltipTexts(), ItemStack.EMPTY, null, null); @@ -738,11 +739,12 @@ public static List getReiIngredients(Stream stream) { .toList())); } - public static List getReiIngredients(List, Integer>> list) { + public static List getReiIngredients(List, Integer, @Nullable CompoundTag>> list) { return list.stream() - .map(pair -> EntryIngredients.ofTag(pair.getFirst(), + .map(pair -> EntryIngredients.ofTag(pair.getLeft(), holder -> EntryStacks - .of(dev.architectury.fluid.FluidStack.create(holder.value(), pair.getSecond())))) + .of(dev.architectury.fluid.FluidStack.create(holder.value(), pair.getMiddle(), + pair.getRight())))) .collect(Collectors.toList()); } } @@ -754,9 +756,20 @@ public static List getEmiIngredients(Stream stream, float xe fluidStack.getTag(), fluidStack.getAmount())).toList()).setChance(xeiChance)); } - public static List getEmiIngredients(List, Integer>> list, float xeiChance) { + // ignore generics, repeat, ignore @ApiStatus.Experimental, ignore forge deprecations + @SuppressWarnings({ "unchecked", "rawtypes", "UnstableApiUsage", "deprecation" }) + public static List getEmiIngredients(List, Integer, @Nullable CompoundTag>> list, + float xeiChance) { return list.stream() - .map(pair -> EmiIngredient.of(pair.getFirst()).setAmount(pair.getSecond()).setChance(xeiChance)) + .map(pair -> { + // slight trickery to get the NBT onto all the stacks in the tag. + EmiRegistryAdapter adapter = EmiTags.ADAPTERS_BY_REGISTRY.get(BuiltInRegistries.FLUID); + var stacks = BuiltInRegistries.FLUID.getTag(pair.getLeft()).stream() + .flatMap(HolderSet.ListBacked::stream) + .map(holder -> adapter.of(holder.value(), pair.getRight(), pair.getMiddle())) + .toList(); + return EmiIngredient.of(stacks).setAmount(pair.getMiddle()).setChance(xeiChance); + }) .collect(Collectors.toList()); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/component/ThermalFluidStats.java b/src/main/java/com/gregtechceu/gtceu/api/item/component/ThermalFluidStats.java index 031e1bac16..a427a9f918 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/component/ThermalFluidStats.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/component/ThermalFluidStats.java @@ -75,7 +75,7 @@ public void appendHoverText(ItemStack stack, @Nullable Level level, List, Integer>>, List>> stacks; + private List, Integer, @Nullable CompoundTag>>, List>> stacks; private List> unwrapped = null; - public TagOrCycleFluidHandler(List, Integer>>, List>> stacks) { + public TagOrCycleFluidHandler(List, Integer, @Nullable CompoundTag>>, List>> stacks) { updateStacks(stacks); } - public void updateStacks(List, Integer>>, List>> stacks) { + public void updateStacks(List, Integer, @Nullable CompoundTag>>, List>> stacks) { this.stacks = new ArrayList<>(stacks); this.unwrapped = null; } @@ -42,10 +44,10 @@ public List> getUnwrapped() { return tagOrFluid.map( tagList -> tagList .stream() - .flatMap(pair -> BuiltInRegistries.FLUID.getTag(pair.getFirst()) + .flatMap(pair -> BuiltInRegistries.FLUID.getTag(pair.getLeft()) .map(holderSet -> holderSet.stream() .map(holder -> new FluidStack(holder.value(), - pair.getSecond()))) + pair.getMiddle(), pair.getRight()))) .orElseGet(Stream::empty)) .toList(), Function.identity()); diff --git a/src/main/java/com/gregtechceu/gtceu/api/transfer/item/TagOrCycleItemStackHandler.java b/src/main/java/com/gregtechceu/gtceu/api/transfer/item/TagOrCycleItemStackHandler.java index 02a91bec19..3aeb6bb31b 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/transfer/item/TagOrCycleItemStackHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/api/transfer/item/TagOrCycleItemStackHandler.java @@ -1,15 +1,17 @@ package com.gregtechceu.gtceu.api.transfer.item; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; import com.mojang.datafixers.util.Either; -import com.mojang.datafixers.util.Pair; import lombok.Getter; +import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -20,15 +22,15 @@ public class TagOrCycleItemStackHandler implements IItemHandlerModifiable { @Getter - private List, Integer>>, List>> stacks; + private List, Integer, @Nullable CompoundTag>>, List>> stacks; private List> unwrapped = null; - public TagOrCycleItemStackHandler(List, Integer>>, List>> stacks) { + public TagOrCycleItemStackHandler(List, Integer, @Nullable CompoundTag>>, List>> stacks) { updateStacks(stacks); } - public void updateStacks(List, Integer>>, List>> stacks) { + public void updateStacks(List, Integer, @Nullable CompoundTag>>, List>> stacks) { this.stacks = new ArrayList<>(stacks); this.unwrapped = null; } @@ -43,9 +45,14 @@ public List> getUnwrapped() { return tagOrItem.map( tagList -> tagList .stream() - .flatMap(pair -> BuiltInRegistries.ITEM.getTag(pair.getFirst()) + .flatMap(pair -> BuiltInRegistries.ITEM.getTag(pair.getLeft()) .map(holderSet -> holderSet.stream() - .map(holder -> new ItemStack(holder.value(), pair.getSecond()))) + .map(holder -> { + ItemStack stack = new ItemStack(holder.value(), + pair.getMiddle()); + stack.setTag(pair.getRight()); + return stack; + })) .orElseGet(Stream::empty)) .toList(), Function.identity()); diff --git a/src/main/java/com/gregtechceu/gtceu/client/TooltipsHandler.java b/src/main/java/com/gregtechceu/gtceu/client/TooltipsHandler.java index 2a025704df..302accae49 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/TooltipsHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/client/TooltipsHandler.java @@ -9,6 +9,8 @@ import com.gregtechceu.gtceu.api.fluids.FluidConstants; import com.gregtechceu.gtceu.api.fluids.FluidState; import com.gregtechceu.gtceu.api.fluids.GTFluid; +import com.gregtechceu.gtceu.common.data.GTFluids; +import com.gregtechceu.gtceu.common.fluid.potion.PotionFluidHelper; import com.gregtechceu.gtceu.data.lang.LangHandler; import com.gregtechceu.gtceu.utils.GTUtil; @@ -16,12 +18,14 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.tags.FluidTags; import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.material.Fluid; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidType; import java.util.List; @@ -48,7 +52,7 @@ public static void appendTooltips(ItemStack stack, TooltipFlag flag, List tooltips, TooltipFlag flag) { + public static void appendFluidTooltips(FluidStack fluidStack, Consumer tooltips, TooltipFlag flag) { + Fluid fluid = fluidStack.getFluid(); + int amount = fluidStack.getAmount(); FluidType fluidType = fluid.getFluidType(); + + if (fluidType == GTFluids.POTION.getType()) { + if (fluid.is(FluidTags.WATER)) { + return; + } + PotionFluidHelper.addPotionTooltip(fluidStack, tooltips); + return; + } + var material = ChemicalHelper.getMaterial(fluid); if (material != null) { if (material.getChemicalFormula() != null && !material.getChemicalFormula().isEmpty()) diff --git a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java index 98e4d6e57f..4504eac441 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java @@ -56,7 +56,6 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.repository.Pack; -import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.event.AddPackFindersEvent; @@ -122,7 +121,6 @@ public static void init() { GTSoundEntries.init(); GTDamageTypes.init(); GTCovers.init(); - ForgeMod.enableMilkFluid(); GTFluids.init(); GTCreativeModeTabs.init(); GTBlocks.init(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTFluids.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTFluids.java index 49047bfb2d..b9e208ae28 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTFluids.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTFluids.java @@ -1,16 +1,20 @@ package com.gregtechceu.gtceu.common.data; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey; import com.gregtechceu.gtceu.api.data.chemical.material.registry.MaterialRegistry; import com.gregtechceu.gtceu.api.fluids.store.FluidStorageKeys; import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate; +import com.gregtechceu.gtceu.common.fluid.potion.PotionFluid; +import com.gregtechceu.gtceu.data.recipe.CustomTags; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; import net.minecraftforge.common.ForgeMod; +import com.tterrag.registrate.util.entry.FluidEntry; import org.jetbrains.annotations.NotNull; import java.util.function.Supplier; @@ -24,10 +28,19 @@ */ public class GTFluids { + public static final FluidEntry POTION = REGISTRATE + .fluid("potion", GTCEu.id("block/fluids/fluid.potion"), GTCEu.id("block/fluids/fluid.potion"), + PotionFluid.PotionFluidType::new, PotionFluid::new) + .lang("Potion") + .source(PotionFluid::new).noBlock().noBucket() + .tag(CustomTags.POTION_FLUIDS) + .register(); + public static void init() { handleNonMaterialFluids(GTMaterials.Water, Fluids.WATER); handleNonMaterialFluids(GTMaterials.Lava, Fluids.LAVA); handleNonMaterialFluids(GTMaterials.Milk, ForgeMod.MILK); + ForgeMod.enableMilkFluid(); REGISTRATE.creativeModeTab(() -> GTCreativeModeTabs.MATERIAL_FLUID); // register fluids for materials for (MaterialRegistry registry : GTCEuAPI.materialManager.getRegistries()) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index d22b9b37a9..3565f2a70b 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -20,6 +20,7 @@ import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler; import com.gregtechceu.gtceu.api.transfer.item.CycleItemStackHandler; import com.gregtechceu.gtceu.common.machine.multiblock.electric.FusionReactorMachine; +import com.gregtechceu.gtceu.common.machine.trait.customlogic.BreweryLogic; import com.gregtechceu.gtceu.common.machine.trait.customlogic.CannerLogic; import com.gregtechceu.gtceu.common.machine.trait.customlogic.FormingPressLogic; import com.gregtechceu.gtceu.common.recipe.condition.RPMCondition; @@ -143,6 +144,7 @@ public class GTRecipeTypes { .prepareBuilder(recipeBuilder -> recipeBuilder.duration(128).EUt(4)) .setSlotOverlay(false, false, GuiTextures.BREWER_OVERLAY) .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, LEFT_TO_RIGHT) + .addCustomRecipeLogic(new BreweryLogic()) .setSound(GTSoundEntries.CHEMICAL); public final static GTRecipeType MACERATOR_RECIPES = register("macerator", ELECTRIC).setMaxIOSize(1, 4, 0, 0) diff --git a/src/main/java/com/gregtechceu/gtceu/common/fluid/potion/PotionFluid.java b/src/main/java/com/gregtechceu/gtceu/common/fluid/potion/PotionFluid.java new file mode 100644 index 0000000000..1c509b2af8 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/common/fluid/potion/PotionFluid.java @@ -0,0 +1,122 @@ +package com.gregtechceu.gtceu.common.fluid.potion; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.common.data.GTFluids; + +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.material.FluidState; +import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidType; +import net.minecraftforge.fluids.ForgeFlowingFluid; + +import java.util.Collection; +import java.util.List; +import java.util.function.Consumer; + +public class PotionFluid extends ForgeFlowingFluid { + + public PotionFluid(Properties properties) { + super(properties + .bucket(() -> Items.AIR) + .block(() -> (LiquidBlock) Blocks.WATER)); + } + + public static FluidStack of(int amount, Potion potion) { + FluidStack fluidStack = new FluidStack(GTFluids.POTION.get() + .getSource(), amount); + addPotionToFluidStack(fluidStack, potion); + return fluidStack; + } + + public static FluidStack withEffects(int amount, Potion potion, List customEffects) { + FluidStack fluidStack = of(amount, potion); + appendEffects(fluidStack, customEffects); + return fluidStack; + } + + public static FluidStack addPotionToFluidStack(FluidStack fluidStack, Potion potion) { + ResourceLocation resourcelocation = BuiltInRegistries.POTION.getKey(potion); + if (potion == Potions.EMPTY) { + fluidStack.removeChildTag("Potion"); + return fluidStack; + } + fluidStack.getOrCreateTag() + .putString("Potion", resourcelocation.toString()); + return fluidStack; + } + + public static FluidStack appendEffects(FluidStack fluidStack, Collection customEffects) { + if (customEffects.isEmpty()) + return fluidStack; + CompoundTag tag = fluidStack.getOrCreateTag(); + ListTag effects = tag.getList("CustomPotionEffects", 9); + for (MobEffectInstance effect : customEffects) + effects.add(effect.save(new CompoundTag())); + tag.put("CustomPotionEffects", effects); + return fluidStack; + } + + @Override + public boolean isSource(FluidState state) { + return this == GTFluids.POTION.get().getSource(); + } + + @Override + public int getAmount(FluidState state) { + return 0; + } + + public static class PotionFluidType extends FluidType { + + private static final ResourceLocation texture = GTCEu.id("block/fluids/fluid.potion"); + + /** + * Default constructor. + * + * @param properties the general properties of the fluid type + */ + public PotionFluidType(Properties properties, ResourceLocation still, ResourceLocation flow) { + super(properties); + } + + @Override + public void initializeClient(Consumer consumer) { + consumer.accept(new IClientFluidTypeExtensions() { + + @Override + public ResourceLocation getStillTexture() { + return texture; + } + + @Override + public ResourceLocation getFlowingTexture() { + return texture; + } + + @Override + public int getTintColor(FluidStack stack) { + CompoundTag tag = stack.getOrCreateTag(); + return PotionUtils.getColor(PotionUtils.getAllEffects(tag)) | 0xff000000; + } + }); + } + + @Override + public String getDescriptionId(FluidStack stack) { + CompoundTag tag = stack.getOrCreateTag(); + return PotionUtils.getPotion(tag) + .getName(Items.POTION.getDescriptionId() + ".effect."); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/common/fluid/potion/PotionFluidHelper.java b/src/main/java/com/gregtechceu/gtceu/common/fluid/potion/PotionFluidHelper.java new file mode 100644 index 0000000000..57fe115bb5 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/common/fluid/potion/PotionFluidHelper.java @@ -0,0 +1,207 @@ +package com.gregtechceu.gtceu.common.fluid.potion; + +import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient; +import com.gregtechceu.gtceu.common.data.GTFluids; +import com.gregtechceu.gtceu.core.mixins.StrictNBTIngredientAccessor; +import com.gregtechceu.gtceu.utils.FormattingUtil; +import com.gregtechceu.gtceu.utils.GTMath; + +import net.minecraft.ChatFormatting; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.util.Tuple; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffectUtil; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.material.Fluids; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidType; + +import com.google.common.collect.Lists; +import com.mojang.datafixers.util.Pair; + +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Stream; + +public class PotionFluidHelper { + + public static final int BOTTLE_AMOUNT = FluidType.BUCKET_VOLUME / 4; + public static final int MB_PER_RECIPE = BOTTLE_AMOUNT * 3; + + public static Pair emptyPotion(ItemStack stack, boolean simulate) { + FluidStack fluid = getFluidFromPotionItem(stack, BOTTLE_AMOUNT); + if (!simulate) + stack.shrink(1); + return Pair.of(fluid, new ItemStack(Items.GLASS_BOTTLE)); + } + + public static FluidIngredient potionIngredient(Potion potion, int amount) { + FluidStack stack = PotionFluidHelper + .getFluidFromPotionItem(PotionUtils.setPotion(new ItemStack(Items.POTION), potion), amount); + stack.setAmount(amount); + return FluidIngredient.of(stack); + } + + public static FluidIngredient getPotionFluidIngredientFrom(Ingredient potion, int amount) { + if (potion instanceof StrictNBTIngredientAccessor strict) { + return FluidIngredient.of(Stream.of(GTFluids.POTION.get()), amount, strict.getStack().getTag()); + } + + List fluids = new ArrayList<>(); + for (ItemStack stack : potion.getItems()) { + FluidStack fluidStack = getFluidFromPotionItem(stack, amount); + if (!fluidStack.isEmpty()) { + fluids.add(fluidStack); + } + } + return FluidIngredient.of(fluids.toArray(FluidStack[]::new)); + } + + public static FluidStack getFluidFromPotionItem(ItemStack stack, int amount) { + Potion potion = PotionUtils.getPotion(stack); + if (potion == Potions.EMPTY) { + return FluidStack.EMPTY; + } + List list = PotionUtils.getCustomEffects(stack); + if (potion == Potions.WATER && list.isEmpty()) + return new FluidStack(Fluids.WATER, amount); + return PotionFluid.withEffects(amount, potion, list); + } + + public static FluidStack getFluidFromPotion(Potion potion, int amount) { + if (potion == Potions.WATER) + return new FluidStack(Fluids.WATER, amount); + return PotionFluid.of(amount, potion); + } + + public static ItemStack fillBottle(ItemStack stack, FluidStack availableFluid) { + CompoundTag tag = availableFluid.getOrCreateTag(); + if (stack.is(Items.GLASS_BOTTLE)) { + int count = stack.getCount(); + CompoundTag stackTag = stack.getTag(); + stack = new ItemStack(Items.POTION); + stack.setCount(count); + stack.setTag(stackTag); + } + PotionUtils.setPotion(stack, PotionUtils.getPotion(tag)); + PotionUtils.setCustomEffects(stack, PotionUtils.getCustomEffects(tag)); + return stack; + } + + // Modified version of PotionUtils#addPotionTooltip + @OnlyIn(Dist.CLIENT) + public static void addPotionTooltip(FluidStack fs, Consumer tooltip) { + List list = PotionUtils.getAllEffects(fs.getOrCreateTag()); + List> modifiers = Lists.newArrayList(); + if (list.isEmpty()) { + tooltip.accept(Component.translatable("effect.none").withStyle(ChatFormatting.GRAY)); + } else { + for (MobEffectInstance effectInstance : list) { + MutableComponent name = Component.translatable(effectInstance.getDescriptionId()); + MobEffect effect = effectInstance.getEffect(); + Map map = effect.getAttributeModifiers(); + if (!map.isEmpty()) { + for (Map.Entry entry : map.entrySet()) { + AttributeModifier modifier = entry.getValue(); + AttributeModifier mutated = new AttributeModifier(modifier.getName(), + effect.getAttributeModifierValue(effectInstance.getAmplifier(), modifier), + modifier.getOperation()); + modifiers.add(new Tuple<>( + entry.getKey().getDescriptionId(), + mutated)); + } + } + + if (effectInstance.getAmplifier() > 0) { + name = Component.translatable("potion.withAmplifier", name, + Component.translatable("potion.potency." + effectInstance.getAmplifier()));; + } + + if (!effectInstance.endsWithin(20)) { + name = Component.translatable("potion.withDuration", name, + MobEffectUtil.formatDuration(effectInstance, 1.0f)); + + } + + tooltip.accept(name.withStyle(effect.getCategory() + .getTooltipFormatting())); + } + } + + if (!modifiers.isEmpty()) { + tooltip.accept(Component.empty()); + tooltip.accept(Component.translatable("potion.whenDrank").withStyle(ChatFormatting.DARK_PURPLE)); + + for (Tuple tuple : modifiers) { + AttributeModifier modifier2 = tuple.getB(); + double d0 = modifier2.getAmount(); + double d1; + if (modifier2.getOperation() != AttributeModifier.Operation.MULTIPLY_BASE && + modifier2.getOperation() != AttributeModifier.Operation.MULTIPLY_TOTAL) { + d1 = modifier2.getAmount(); + } else { + d1 = modifier2.getAmount() * 100.0D; + } + + if (d0 > 0.0D) { + tooltip.accept(Component.translatable( + "attribute.modifier.plus." + modifier2.getOperation() + .toValue(), + ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1), + Component.translatable(tuple.getA())) + .withStyle(ChatFormatting.BLUE)); + } else if (d0 < 0.0D) { + d1 = d1 * -1.0D; + tooltip.accept(Component.translatable( + "attribute.modifier.take." + modifier2.getOperation() + .toValue(), + ItemStack.ATTRIBUTE_MODIFIER_FORMAT.format(d1), + Component.translatable(tuple.getA())) + .withStyle(ChatFormatting.RED)); + } + } + } + } + + public static Component formatDuration(MobEffectInstance effect) { + if (effect.isInfiniteDuration()) { + return Component.translatable("effect.duration.infinite"); + } else { + int time = effect.getDuration(); + Instant start = Instant.now(); + Instant max = Instant.now().plusSeconds(time / 20); + Duration durationMax = Duration.between(start, max); + + Component unit; + + if (durationMax.getSeconds() <= 60) { + time = GTMath.saturatedCast(durationMax.getSeconds()); + unit = Component.translatable("item.gtceu.battery.charge_unit.second"); + } else if (durationMax.toMinutes() <= 60) { + time = GTMath.saturatedCast(durationMax.toMinutes()); + unit = Component.translatable("item.gtceu.battery.charge_unit.minute"); + } else { + time = GTMath.saturatedCast(durationMax.toHours()); + unit = Component.translatable("item.gtceu.battery.charge_unit.hour"); + } + + return Component.literal(FormattingUtil.formatNumbers(time)).append(unit); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/BreweryLogic.java b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/BreweryLogic.java new file mode 100644 index 0000000000..5c05d7bdb3 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/BreweryLogic.java @@ -0,0 +1,197 @@ +package com.gregtechceu.gtceu.common.machine.trait.customlogic; + +import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; +import com.gregtechceu.gtceu.api.capability.recipe.IO; +import com.gregtechceu.gtceu.api.capability.recipe.IRecipeCapabilityHolder; +import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; +import com.gregtechceu.gtceu.api.data.tag.TagUtil; +import com.gregtechceu.gtceu.api.recipe.GTRecipe; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; +import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient; +import com.gregtechceu.gtceu.api.transfer.fluid.FluidHandlerList; +import com.gregtechceu.gtceu.common.data.GTRecipeTypes; +import com.gregtechceu.gtceu.common.fluid.potion.PotionFluidHelper; +import com.gregtechceu.gtceu.core.mixins.PotionBrewingAccessor; + +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionBrewing; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraftforge.common.brewing.BrewingRecipe; +import net.minecraftforge.common.brewing.BrewingRecipeRegistry; +import net.minecraftforge.common.brewing.IBrewingRecipe; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.wrapper.CombinedInvWrapper; + +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import static com.gregtechceu.gtceu.api.GTValues.*; + +@SuppressWarnings("deprecation") +public class BreweryLogic implements GTRecipeType.ICustomRecipeLogic { + + @Override + public @Nullable GTRecipe createCustomRecipe(IRecipeCapabilityHolder holder) { + var itemInputs = Objects + .requireNonNullElseGet(holder.getCapabilitiesProxy().get(IO.IN, ItemRecipeCapability.CAP), + ArrayList::new) + .stream() + .filter(IItemHandlerModifiable.class::isInstance) + .map(IItemHandlerModifiable.class::cast) + .toArray(IItemHandlerModifiable[]::new); + + var fluidInputs = Objects + .requireNonNullElseGet(holder.getCapabilitiesProxy().get(IO.IN, FluidRecipeCapability.CAP), + ArrayList::new) + .stream() + .filter(IFluidHandler.class::isInstance).map(IFluidHandler.class::cast) + .toArray(IFluidHandler[]::new); + + var combinedItemInputs = new CombinedInvWrapper(itemInputs); + var combinedFluidInputs = new FluidHandlerList(fluidInputs); + for (int i = 0; i < combinedItemInputs.getSlots(); i++) { + ItemStack item = combinedItemInputs.getStackInSlot(i); + if (!item.isEmpty()) { + for (PotionBrewing.Mix mix : PotionBrewingAccessor.getPotionMixes()) { + // test item ingredient first + if (!mix.ingredient.test(item)) { + continue; + } + FluidStack fromFluid = PotionFluidHelper.getFluidFromPotion(mix.from.get(), + PotionFluidHelper.MB_PER_RECIPE); + var fromTag = TagUtil + .createFluidTag(BuiltInRegistries.FLUID.getKey(fromFluid.getFluid()).getPath()); + + // then match fluid input + boolean found = false; + for (int j = 0; j < combinedFluidInputs.getTanks(); ++j) { + FluidStack contained = combinedFluidInputs.getFluidInTank(j); + if (!contained.isEmpty() && + contained.getFluid().is(fromTag) && + Objects.equals(fromFluid.getTag(), contained.getTag())) { + found = true; + break; + } + } + if (!found) { + continue; + } + + FluidStack toFluid = PotionFluidHelper.getFluidFromPotion(mix.to.get(), + PotionFluidHelper.MB_PER_RECIPE); + + return GTRecipeTypes.BREWING_RECIPES.recipeBuilder("potion_vanilla_" + mix.to.get().getName("")) + .inputItems(mix.ingredient) + .inputFluids(fromFluid) + .outputFluids(toFluid) + .duration(400) + // is this a good voltage? + .EUt(VHA[MV]) + .buildRawRecipe(); + } + + for (IBrewingRecipe recipe : BrewingRecipeRegistry.getRecipes()) { + if (!(recipe instanceof BrewingRecipe impl)) { + continue; + } + + FluidIngredient fromFluid = PotionFluidHelper.getPotionFluidIngredientFrom(impl.getInput(), + PotionFluidHelper.MB_PER_RECIPE); + + boolean found = false; + for (int j = 0; j < combinedFluidInputs.getTanks(); ++j) { + FluidStack contained = combinedFluidInputs.getFluidInTank(j); + if (!contained.isEmpty() && !fromFluid.test(contained)) { + found = true; + break; + } + } + if (!found) { + continue; + } + + FluidStack toFluid = PotionFluidHelper.getFluidFromPotionItem(impl.getOutput(), + PotionFluidHelper.MB_PER_RECIPE); + + String name = toFluid.getFluid().builtInRegistryHolder().key().location().getPath(); + Potion output = PotionUtils.getPotion(impl.getOutput()); + if (output != null) { + name = output.getName(""); + } + + return GTRecipeTypes.BREWING_RECIPES.recipeBuilder("potion_forge_" + name) + .inputItems(impl.getIngredient()) + .inputFluids(fromFluid) + .outputFluids(toFluid) + .duration(400) + .EUt(VHA[MV]) + .buildRawRecipe(); + + } + } + } + return null; + } + + @Override + public @Nullable List getRepresentativeRecipes() { + List list = new ArrayList<>(BuiltInRegistries.POTION.size()); + int index = 0; + + for (PotionBrewing.Mix mix : PotionBrewingAccessor.getPotionMixes()) { + FluidStack fromFluid = PotionFluidHelper.getFluidFromPotion(mix.from.get(), + PotionFluidHelper.MB_PER_RECIPE); + FluidStack toFluid = PotionFluidHelper.getFluidFromPotion(mix.to.get(), PotionFluidHelper.MB_PER_RECIPE); + + GTRecipe recipe = GTRecipeTypes.BREWING_RECIPES + .recipeBuilder("potion_vanilla_" + mix.to.get().getName("") + "_" + index++) + .inputItems(mix.ingredient) + .inputFluids(fromFluid) + .outputFluids(toFluid) + .duration(400) + // is this a good voltage? + .EUt(VHA[MV]) + .buildRawRecipe(); + // for EMI to detect it's a synthetic recipe (not ever in JSON) + recipe.setId(recipe.getId().withPrefix("/")); + list.add(recipe); + } + + for (IBrewingRecipe brewingRecipe : BrewingRecipeRegistry.getRecipes()) { + if (!(brewingRecipe instanceof BrewingRecipe impl)) { + continue; + } + + FluidIngredient fromFluid = PotionFluidHelper.getPotionFluidIngredientFrom(impl.getInput(), + PotionFluidHelper.MB_PER_RECIPE); + FluidStack toFluid = PotionFluidHelper.getFluidFromPotionItem(impl.getOutput(), + PotionFluidHelper.MB_PER_RECIPE); + + String name = toFluid.getFluid().builtInRegistryHolder().key().location().getPath(); + Potion output = PotionUtils.getPotion(impl.getOutput()); + if (output != null) { + name = output.getName(""); + } + + GTRecipe recipe = GTRecipeTypes.BREWING_RECIPES.recipeBuilder("potion_forge_" + name + "_" + index++) + .inputItems(impl.getIngredient()) + .inputFluids(fromFluid) + .outputFluids(toFluid) + .duration(400) + .EUt(VHA[MV]) + .buildRawRecipe(); + // for EMI to detect it's a synthetic recipe (not ever in JSON) + recipe.setId(recipe.getId().withPrefix("/")); + list.add(recipe); + } + + return list; + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/PotionBrewingAccessor.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/PotionBrewingAccessor.java new file mode 100644 index 0000000000..417afd387e --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/PotionBrewingAccessor.java @@ -0,0 +1,18 @@ +package com.gregtechceu.gtceu.core.mixins; + +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionBrewing; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.List; + +@Mixin(PotionBrewing.class) +public interface PotionBrewingAccessor { + + @Accessor("POTION_MIXES") + public static List> getPotionMixes() { + throw new AssertionError(); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/emi/FluidEmiStackMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/emi/FluidEmiStackMixin.java index b4b0f82908..05d2e8f6c0 100644 --- a/src/main/java/com/gregtechceu/gtceu/core/mixins/emi/FluidEmiStackMixin.java +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/emi/FluidEmiStackMixin.java @@ -1,10 +1,13 @@ package com.gregtechceu.gtceu.core.mixins.emi; import com.gregtechceu.gtceu.client.TooltipsHandler; +import com.gregtechceu.gtceu.utils.GTMath; import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.material.Fluid; +import net.minecraftforge.fluids.FluidStack; import com.llamalad7.mixinextras.sugar.Local; import dev.emi.emi.api.render.EmiTooltipComponents; @@ -25,6 +28,9 @@ public class FluidEmiStackMixin { @Shadow @Final private Fluid fluid; + @Shadow + @Final + private CompoundTag nbt; @Inject(method = "getTooltip", at = @At(value = "INVOKE", target = "Ldev/emi/emi/EmiPort;getFluidRegistry()Lnet/minecraft/core/Registry;"), @@ -32,8 +38,9 @@ public class FluidEmiStackMixin { require = 0) private void gtceu$addFluidTooltip(CallbackInfoReturnable> cir, @Local List list) { - TooltipsHandler.appendFluidTooltips(this.fluid, - ((EmiStack) (Object) this).getAmount(), + TooltipsHandler.appendFluidTooltips(new FluidStack(this.fluid, + Math.max(GTMath.saturatedCast(((EmiStack) (Object) this).getAmount()), 1), + nbt), text -> list.add(EmiTooltipComponents.of(text)), TooltipFlag.NORMAL); } diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/jei/FluidHelperMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/jei/FluidHelperMixin.java index d69a8dca13..747d71d711 100644 --- a/src/main/java/com/gregtechceu/gtceu/core/mixins/jei/FluidHelperMixin.java +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/jei/FluidHelperMixin.java @@ -21,6 +21,6 @@ public class FluidHelperMixin { require = 0) private void gtceu$injectFluidTooltips(ITooltipBuilder tooltip, FluidStack ingredient, TooltipFlag tooltipFlag, CallbackInfo ci) { - TooltipsHandler.appendFluidTooltips(ingredient.getFluid(), ingredient.getAmount(), tooltip::add, tooltipFlag); + TooltipsHandler.appendFluidTooltips(ingredient, tooltip::add, tooltipFlag); } } diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/rei/FluidEntryRendererMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/rei/FluidEntryRendererMixin.java index 1795f3f438..c9e34e48b0 100644 --- a/src/main/java/com/gregtechceu/gtceu/core/mixins/rei/FluidEntryRendererMixin.java +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/rei/FluidEntryRendererMixin.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.core.mixins.rei; import com.gregtechceu.gtceu.client.TooltipsHandler; +import com.gregtechceu.gtceu.utils.GTMath; import dev.architectury.fluid.FluidStack; import me.shedaniel.rei.api.client.gui.widgets.Tooltip; @@ -21,7 +22,9 @@ public class FluidEntryRendererMixin { require = 0) private void gtceu$addMaterialTooltip(EntryStack entry, TooltipContext context, CallbackInfoReturnable cir) { - TooltipsHandler.appendFluidTooltips(entry.getValue().getFluid(), entry.getValue().getAmount(), + FluidStack stack = entry.getValue(); + TooltipsHandler.appendFluidTooltips(new net.minecraftforge.fluids.FluidStack(stack.getFluid(), + GTMath.saturatedCast(stack.getAmount()), stack.getTag()), cir.getReturnValue()::add, context.getFlag()); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java b/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java index 3a18359b67..72acbdbc3a 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java +++ b/src/main/java/com/gregtechceu/gtceu/data/lang/IntegrationLang.java @@ -40,6 +40,8 @@ private static void initRecipeViewerLang(RegistrateLangProvider provider) { String name = GTRegistries.BEDROCK_FLUID_DEFINITIONS.getKey(fluid).getPath(); provider.add("gtceu.jei.bedrock_fluid." + name, RegistrateLangProvider.toEnglishName(name)); } + + provider.add("gtceu.rei.group.potion_fluids", "Potion Fluids"); } /** Jade, TheOneProbe, WTHIT */ diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/CustomTags.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/CustomTags.java index d3a8e9855a..f262be66ba 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/CustomTags.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/CustomTags.java @@ -138,4 +138,5 @@ public class CustomTags { public static final TagKey LIGHTER_FLUIDS = TagUtil.createFluidTag("lighter_fluid"); public static final TagKey MOLTEN_FLUIDS = TagUtil.createFluidTag("molten"); + public static final TagKey POTION_FLUIDS = TagUtil.createFluidTag("potion"); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java index 867fd8528b..2a7ddb7cfe 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java @@ -824,13 +824,14 @@ public GTRecipeBuilder chancedTickInputLogic(RecipeCapability cap, ChanceLogi public GTRecipeBuilder inputFluids(FluidStack input) { return input(FluidRecipeCapability.CAP, FluidIngredient.of( - TagUtil.createFluidTag(BuiltInRegistries.FLUID.getKey(input.getFluid()).getPath()), input.getAmount())); + TagUtil.createFluidTag(BuiltInRegistries.FLUID.getKey(input.getFluid()).getPath()), + input.getAmount(), input.getTag())); } public GTRecipeBuilder inputFluids(FluidStack... inputs) { return input(FluidRecipeCapability.CAP, Arrays.stream(inputs).map(fluid -> FluidIngredient.of( TagUtil.createFluidTag(BuiltInRegistries.FLUID.getKey(fluid.getFluid()).getPath()), - fluid.getAmount())).toArray(FluidIngredient[]::new)); + fluid.getAmount(), fluid.getTag())).toArray(FluidIngredient[]::new)); } public GTRecipeBuilder inputFluids(FluidIngredient... inputs) { diff --git a/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java b/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java index af70b7c113..0660903260 100644 --- a/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java +++ b/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java @@ -20,6 +20,7 @@ import com.gregtechceu.gtceu.api.item.armor.ArmorComponentItem; import com.gregtechceu.gtceu.api.machine.MetaMachine; import com.gregtechceu.gtceu.api.machine.feature.IInteractedMachine; +import com.gregtechceu.gtceu.api.misc.forge.FilteredFluidHandlerItemStack; import com.gregtechceu.gtceu.api.pattern.MultiblockWorldSavedData; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.capability.EnvironmentalHazardSavedData; @@ -33,6 +34,7 @@ import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.common.data.GTMachines; import com.gregtechceu.gtceu.common.data.machines.GTAEMachines; +import com.gregtechceu.gtceu.common.fluid.potion.PotionFluidHelper; import com.gregtechceu.gtceu.common.item.ToggleEnergyConsumerBehavior; import com.gregtechceu.gtceu.common.item.armor.IJetpack; import com.gregtechceu.gtceu.common.network.GTNetwork; @@ -63,6 +65,9 @@ import net.minecraft.world.entity.monster.Zombie; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.PotionItem; +import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.common.capabilities.Capability; @@ -85,6 +90,10 @@ import net.minecraftforge.event.server.ServerStoppingEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.fluids.capability.IFluidHandlerItem; +import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.items.IItemHandler; @@ -110,8 +119,8 @@ public class ForgeCommonEventListener { @SubscribeEvent public static void registerItemStackCapabilities(AttachCapabilitiesEvent event) { - if (event.getObject().getItem() instanceof IComponentItem componentItem) { - final ItemStack itemStack = event.getObject(); + final ItemStack itemStack = event.getObject(); + if (itemStack.getItem() instanceof IComponentItem componentItem) { event.addCapability(GTCEu.id("capability"), new ICapabilityProvider() { @NotNull @@ -120,9 +129,7 @@ public LazyOptional getCapability(@NotNull Capability cap, @Nullable D return componentItem.getCapability(itemStack, cap); } }); - } - if (event.getObject().getItem() instanceof DrumMachineItem drumMachineItem) { - final ItemStack itemStack = event.getObject(); + } else if (itemStack.getItem() instanceof DrumMachineItem drumMachineItem) { event.addCapability(GTCEu.id("fluid"), new ICapabilityProvider() { @Override @@ -131,6 +138,44 @@ public LazyOptional getCapability(@NotNull Capability cap, @Nullable D return drumMachineItem.getCapability(itemStack, capability); } }); + } else if (itemStack.getItem() instanceof PotionItem) { + LazyOptional handler = LazyOptional.of(() -> { + var fluidHandler = new FluidHandlerItemStack.SwapEmpty(itemStack, new ItemStack(Items.GLASS_BOTTLE), + PotionFluidHelper.BOTTLE_AMOUNT); + fluidHandler.fill(PotionFluidHelper.getFluidFromPotionItem(itemStack, PotionFluidHelper.BOTTLE_AMOUNT), + IFluidHandler.FluidAction.EXECUTE); + return fluidHandler; + }); + event.addCapability(GTCEu.id("potion_item_handler"), new ICapabilityProvider() { + + @Override + public @NotNull LazyOptional getCapability(@NotNull Capability cap, + @Nullable Direction side) { + return ForgeCapabilities.FLUID_HANDLER_ITEM.orEmpty(cap, handler); + } + }); + } else if (itemStack.is(Items.GLASS_BOTTLE)) { + LazyOptional handler = LazyOptional.of(() -> new FilteredFluidHandlerItemStack(itemStack, + 250, s -> s.getFluid().is(CustomTags.POTION_FLUIDS)) { + + @Override + protected void setFluid(FluidStack fluid) { + super.setFluid(fluid); + if (!fluid.isEmpty()) { + container = PotionUtils.setPotion(new ItemStack(Items.POTION), + PotionUtils.getPotion(fluid.getTag())); + } + } + }); + event.addCapability(GTCEu.id("bottle_item_handler"), new ICapabilityProvider() { + + @Override + public @NotNull LazyOptional getCapability(@NotNull Capability cap, + @Nullable Direction side) { + return ForgeCapabilities.FLUID_HANDLER_ITEM.orEmpty(cap, handler); + } + }); + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/list/AEFluidDisplayWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/list/AEFluidDisplayWidget.java index 53f2e7dea7..cc1e11d916 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/list/AEFluidDisplayWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/gui/widget/list/AEFluidDisplayWidget.java @@ -77,8 +77,7 @@ public void drawInForeground(@NotNull GuiGraphics graphics, int mouseX, int mous List tooltips = new ArrayList<>(); tooltips.add(fluidStack.getDisplayName()); tooltips.add(Component.literal(String.format("%,d mB", fluid.amount()))); - TooltipsHandler.appendFluidTooltips(fluidStack.getFluid(), fluidStack.getAmount(), tooltips::add, - TooltipFlag.NORMAL); + TooltipsHandler.appendFluidTooltips(fluidStack, tooltips::add, TooltipFlag.NORMAL); graphics.renderTooltip(Minecraft.getInstance().font, tooltips, Optional.empty(), mouseX, mouseY); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java index 5e63424960..d731cb9377 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/emi/GTEMIPlugin.java @@ -4,9 +4,12 @@ import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.common.data.GTFluids; import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.common.data.GTMachines; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; +import com.gregtechceu.gtceu.common.fluid.potion.PotionFluid; +import com.gregtechceu.gtceu.common.fluid.potion.PotionFluidHelper; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.integration.emi.circuit.GTProgrammedCircuitCategory; import com.gregtechceu.gtceu.integration.emi.multipage.MultiblockInfoEmiCategory; @@ -22,6 +25,11 @@ import com.lowdragmc.lowdraglib.Platform; import com.lowdragmc.lowdraglib.gui.modular.ModularUIContainer; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraftforge.fluids.FluidStack; + import appeng.menu.me.items.PatternEncodingTermMenu; import de.mari_023.ae2wtlib.wet.WETMenu; import dev.emi.emi.api.EmiEntrypoint; @@ -88,5 +96,15 @@ public void register(EmiRegistry registry) { // Comparators registry.setDefaultComparison(GTItems.PROGRAMMED_CIRCUIT.asItem(), Comparison.compareNbt()); + + Comparison potionComparison = Comparison.compareData(stack -> PotionUtils.getPotion(stack.getNbt())); + PotionFluid potionFluid = GTFluids.POTION.get(); + registry.setDefaultComparison(potionFluid.getSource(), potionComparison); + registry.setDefaultComparison(potionFluid.getFlowing(), potionComparison); + + for (Potion potion : BuiltInRegistries.POTION) { + FluidStack stack = PotionFluidHelper.getFluidFromPotion(potion, PotionFluidHelper.BOTTLE_AMOUNT); + registry.addEmiStack(EmiStack.of(stack.getFluid(), stack.getTag())); + } } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java index f5c71b1837..6916cd0010 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/jei/GTJEIPlugin.java @@ -3,9 +3,11 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.common.data.GTFluids; import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.common.data.GTMachines; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; +import com.gregtechceu.gtceu.common.fluid.potion.PotionFluid; import com.gregtechceu.gtceu.common.item.IntCircuitBehaviour; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.integration.jei.circuit.GTProgrammedCircuitCategory; @@ -15,19 +17,27 @@ import com.gregtechceu.gtceu.integration.jei.orevein.GTBedrockOreInfoCategory; import com.gregtechceu.gtceu.integration.jei.orevein.GTOreVeinInfoCategory; import com.gregtechceu.gtceu.integration.jei.recipe.GTRecipeJEICategory; +import com.gregtechceu.gtceu.integration.jei.subtype.PotionFluidSubtypeInterpreter; import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.Platform; import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraftforge.fluids.FluidStack; import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; +import mezz.jei.api.forge.ForgeTypes; import mezz.jei.api.helpers.IJeiHelpers; +import mezz.jei.api.helpers.IPlatformFluidHelper; import mezz.jei.api.registration.*; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; import javax.annotation.ParametersAreNonnullByDefault; @@ -108,4 +118,23 @@ public void registerIngredients(@NotNull IModIngredientRegistration registry) { public void registerItemSubtypes(ISubtypeRegistration registration) { registration.useNbtForSubtypes(GTItems.PROGRAMMED_CIRCUIT.asItem()); } + + @Override + public void registerFluidSubtypes(ISubtypeRegistration registration, + IPlatformFluidHelper platformFluidHelper) { + PotionFluidSubtypeInterpreter interpreter = new PotionFluidSubtypeInterpreter(); + PotionFluid potionFluid = GTFluids.POTION.get(); + registration.registerSubtypeInterpreter(ForgeTypes.FLUID_STACK, potionFluid.getSource(), interpreter); + registration.registerSubtypeInterpreter(ForgeTypes.FLUID_STACK, potionFluid.getFlowing(), interpreter); + } + + @Override + public void registerExtraIngredients(IExtraIngredientRegistration registration) { + Collection potionFluids = new ArrayList<>(BuiltInRegistries.POTION.size()); + for (Potion potion : BuiltInRegistries.POTION) { + FluidStack potionFluid = PotionFluid.of(1000, potion); + potionFluids.add(potionFluid); + } + registration.addExtraIngredients(ForgeTypes.FLUID_STACK, potionFluids); + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/jei/subtype/PotionFluidSubtypeInterpreter.java b/src/main/java/com/gregtechceu/gtceu/integration/jei/subtype/PotionFluidSubtypeInterpreter.java new file mode 100644 index 0000000000..0313ac87aa --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/jei/subtype/PotionFluidSubtypeInterpreter.java @@ -0,0 +1,39 @@ +package com.gregtechceu.gtceu.integration.jei.subtype; + +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.item.alchemy.Potion; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraftforge.fluids.FluidStack; + +import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter; +import mezz.jei.api.ingredients.subtypes.UidContext; + +import java.util.List; + +/* From JEI's Potion item subtype interpreter */ +public class PotionFluidSubtypeInterpreter implements IIngredientSubtypeInterpreter { + + @Override + public String apply(FluidStack ingredient, UidContext context) { + if (!ingredient.hasTag()) + return IIngredientSubtypeInterpreter.NONE; + + CompoundTag tag = ingredient.getOrCreateTag(); + Potion potionType = PotionUtils.getPotion(tag); + String potionTypeString = potionType.getName(""); + + StringBuilder stringBuilder = new StringBuilder(potionTypeString); + List effects = PotionUtils.getCustomEffects(tag); + + for (MobEffectInstance effect : potionType.getEffects()) { + stringBuilder.append(";") + .append(effect); + } + for (MobEffectInstance effect : effects) { + stringBuilder.append(";") + .append(effect); + } + return stringBuilder.toString(); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java index 0e65588518..49a5975b52 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/rei/GTREIPlugin.java @@ -5,10 +5,9 @@ import com.gregtechceu.gtceu.api.item.tool.GTToolType; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.common.data.GTBlocks; -import com.gregtechceu.gtceu.common.data.GTItems; -import com.gregtechceu.gtceu.common.data.GTMachines; -import com.gregtechceu.gtceu.common.data.GTRecipeTypes; +import com.gregtechceu.gtceu.common.data.*; +import com.gregtechceu.gtceu.common.fluid.potion.PotionFluid; +import com.gregtechceu.gtceu.common.fluid.potion.PotionFluidHelper; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.integration.rei.circuit.GTProgrammedCircuitCategory; import com.gregtechceu.gtceu.integration.rei.multipage.MultiblockInfoDisplayCategory; @@ -20,13 +19,19 @@ import com.lowdragmc.lowdraglib.Platform; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; +import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.level.ItemLike; +import net.minecraftforge.fluids.FluidStack; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; import me.shedaniel.rei.api.client.registry.entry.CollapsibleEntryRegistry; +import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.entry.comparison.FluidComparatorRegistry; import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry; import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; @@ -34,7 +39,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Objects; /** * @author KilaBash @@ -103,10 +107,10 @@ public void registerCollapsibleEntries(CollapsibleEntryRegistry registry) { var material = cell.getKey(); List items = new ArrayList<>(); for (var t : value.entrySet()) { - var name = t.getKey().name; - if (Objects.equals(name, TagPrefix.frameGt.name) || - Objects.equals(name, TagPrefix.block.name) || - Objects.equals(name, TagPrefix.rawOreBlock.name)) + var prefix = t.getKey(); + if (prefix == TagPrefix.frameGt || + prefix == TagPrefix.block || + prefix == TagPrefix.rawOreBlock) continue; items.add(t.getValue()); @@ -117,6 +121,14 @@ public void registerCollapsibleEntries(CollapsibleEntryRegistry registry) { registry.group(GTCEu.id("ore/" + name), Component.translatable("tagprefix.stone", label), EntryIngredients.ofItems(items)); } + + List> stacks = new ArrayList<>(BuiltInRegistries.POTION.size()); + for (Potion potion : BuiltInRegistries.POTION) { + FluidStack stack = PotionFluidHelper.getFluidFromPotion(potion, PotionFluidHelper.BOTTLE_AMOUNT); + stacks.add(EntryStacks + .of(dev.architectury.fluid.FluidStack.create(stack.getFluid(), stack.getAmount(), stack.getTag()))); + } + registry.group(GTCEu.id("potion_fluids"), Component.translatable("gtceu.rei.group.potion_fluids"), stacks); } @Override @@ -124,6 +136,22 @@ public void registerItemComparators(ItemComparatorRegistry registry) { registry.registerNbt(GTItems.PROGRAMMED_CIRCUIT.asItem()); } + @Override + public void registerFluidComparators(FluidComparatorRegistry registry) { + PotionFluid potionFluid = GTFluids.POTION.get(); + registry.registerNbt(potionFluid.getSource()); + registry.registerNbt(potionFluid.getFlowing()); + } + + @Override + public void registerEntries(EntryRegistry registry) { + for (Potion potion : BuiltInRegistries.POTION) { + FluidStack stack = PotionFluidHelper.getFluidFromPotion(potion, PotionFluidHelper.BOTTLE_AMOUNT); + registry.addEntry(EntryStacks.of( + dev.architectury.fluid.FluidStack.create(stack.getFluid(), stack.getAmount(), stack.getTag()))); + } + } + private static String toUpperAllWords(String text) { StringBuilder result = new StringBuilder(); result.append(text.substring(0, 1).toUpperCase()); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProduct.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProduct.java index 6801ba44dd..175ad93458 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProduct.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProduct.java @@ -14,6 +14,7 @@ import com.gregtechceu.gtceu.utils.FormattingUtil; import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; @@ -28,6 +29,8 @@ import com.mojang.datafixers.util.Pair; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import org.apache.commons.lang3.tuple.Triple; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -47,9 +50,9 @@ public static void addOreByProductPrefix(TagPrefix orePrefix) { private static ImmutableList ALWAYS_MACHINES; private final Int2ObjectMap chances = new Int2ObjectOpenHashMap<>(); - protected final List, Integer>>, List>> itemInputs = new ArrayList<>(); + protected final List, Integer, @Nullable CompoundTag>>, List>> itemInputs = new ArrayList<>(); protected final NonNullList itemOutputs = NonNullList.create(); - protected final List, Integer>>, List>> fluidInputs = new ArrayList<>(); + protected final List, Integer, @Nullable CompoundTag>>, List>> fluidInputs = new ArrayList<>(); private boolean hasDirectSmelt = false; private boolean hasChemBath = false; private boolean hasSeparator = false; @@ -92,12 +95,12 @@ public GTOreByProduct(Material material) { Pair washedIn = property.getWashedIn(); List separatedInto = property.getSeparatedInto(); - List, Integer>> oreStacks = new ArrayList<>(); + List, Integer, @Nullable CompoundTag>> oreStacks = new ArrayList<>(); for (TagPrefix prefix : ORES) { // get all ores with the relevant oredicts instead of just the first unified ore - oreStacks.add(Pair.of(ChemicalHelper.getTag(prefix, material), 1)); + oreStacks.add(Triple.of(ChemicalHelper.getTag(prefix, material), 1, null)); } - oreStacks.add(Pair.of(ChemicalHelper.getTag(TagPrefix.rawOre, material), 1)); + oreStacks.add(Triple.of(ChemicalHelper.getTag(TagPrefix.rawOre, material), 1, null)); itemInputs.add(Either.left(oreStacks)); // set up machines as inputs @@ -141,8 +144,8 @@ public GTOreByProduct(Material material) { // add prefixes that should count as inputs to input lists (they will not be displayed in actual page) for (TagPrefix prefix : IN_PROCESSING_STEPS) { - List, Integer>> tempList = new ArrayList<>(); - tempList.add(Pair.of(ChemicalHelper.getTag(prefix, material), 1)); + List, Integer, @Nullable CompoundTag>> tempList = new ArrayList<>(); + tempList.add(Triple.of(ChemicalHelper.getTag(prefix, material), 1, null)); itemInputs.add(Either.left(tempList)); } @@ -193,9 +196,9 @@ public GTOreByProduct(Material material) { addToOutputs(material, TagPrefix.crushedPurified, 1); addToOutputs(byproducts[0], TagPrefix.dust, 1); addChance(3333, 0); - List, Integer>> fluidStacks = new ArrayList<>(); - fluidStacks.add(Pair.of(GTMaterials.Water.getFluidTag(), 1000)); - fluidStacks.add(Pair.of(GTMaterials.DistilledWater.getFluidTag(), 100)); + List, Integer, @Nullable CompoundTag>> fluidStacks = new ArrayList<>(); + fluidStacks.add(Triple.of(GTMaterials.Water.getFluidTag(), 1000, null)); + fluidStacks.add(Triple.of(GTMaterials.DistilledWater.getFluidTag(), 100, null)); fluidInputs.add(Either.left(fluidStacks)); // TC crushed/crushed purified -> centrifuged @@ -233,9 +236,9 @@ public GTOreByProduct(Material material) { addToOutputs(material, TagPrefix.crushedPurified, 1); addToOutputs(byproducts[3], TagPrefix.dust, byproductMultiplier); addChance(7000, 580); - List, Integer>> washedFluid = new ArrayList<>(); + List, Integer, @Nullable CompoundTag>> washedFluid = new ArrayList<>(); // noinspection DataFlowIssue - washedFluid.add(Pair.of(washedIn.getFirst().getFluidTag(), washedIn.getSecond())); + washedFluid.add(Triple.of(washedIn.getFirst().getFluidTag(), washedIn.getSecond(), null)); fluidInputs.add(Either.left(washedFluid)); } else { addEmptyOutputs(2); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProductWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProductWidget.java index 072f4b2543..3ac9ef8b36 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProductWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProductWidget.java @@ -16,6 +16,7 @@ import com.lowdragmc.lowdraglib.jei.IngredientIO; import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -24,7 +25,8 @@ import com.google.common.collect.ImmutableList; import com.mojang.datafixers.util.Either; -import com.mojang.datafixers.util.Pair; +import org.apache.commons.lang3.tuple.Triple; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -120,7 +122,7 @@ public void setRecipe(GTOreByProduct recipeWrapper) { addWidget(new ImageWidget(0, 0, 176, 166, GuiTextures.OREBY_SIFT)); } - List, Integer>>, List>> itemInputs = recipeWrapper.itemInputs; + List, Integer, @Nullable CompoundTag>>, List>> itemInputs = recipeWrapper.itemInputs; TagOrCycleItemStackHandler itemInputsHandler = new TagOrCycleItemStackHandler(itemInputs); WidgetGroup itemStackGroup = new WidgetGroup(); for (int i = 0; i < ITEM_INPUT_LOCATIONS.size(); i += 2) { @@ -162,7 +164,7 @@ public void setRecipe(GTOreByProduct recipeWrapper) { itemOutputExists.add(true); } - List, Integer>>, List>> fluidInputs = recipeWrapper.fluidInputs; + List, Integer, @Nullable CompoundTag>>, List>> fluidInputs = recipeWrapper.fluidInputs; TagOrCycleFluidHandler fluidInputsHandler = new TagOrCycleFluidHandler(fluidInputs); WidgetGroup fluidStackGroup = new WidgetGroup(); for (int i = 0; i < FLUID_LOCATIONS.size(); i += 2) { diff --git a/src/main/java/com/gregtechceu/gtceu/utils/ResearchManager.java b/src/main/java/com/gregtechceu/gtceu/utils/ResearchManager.java index ead4ed2c93..b06ce8fbdc 100644 --- a/src/main/java/com/gregtechceu/gtceu/utils/ResearchManager.java +++ b/src/main/java/com/gregtechceu/gtceu/utils/ResearchManager.java @@ -206,13 +206,17 @@ public List getRepresentativeRecipes() { emptyStick.setHoverName(Component.translatable("gtceu.scanner.copy_stick_empty")); ItemStack resultStick = GTItems.TOOL_DATA_STICK.asStack(); resultStick.setHoverName(Component.translatable("gtceu.scanner.copy_stick_to")); - return Collections.singletonList( - GTRecipeTypes.SCANNER_RECIPES.recipeBuilder("copy_" + GTStringUtils.itemStackToString(copiedStick)) - .inputItems(emptyStick) - .notConsumable(copiedStick) - .outputItems(resultStick) - .duration(DURATION).EUt(EUT) - .buildRawRecipe()); + + GTRecipe recipe = GTRecipeTypes.SCANNER_RECIPES + .recipeBuilder("copy_" + GTStringUtils.itemStackToString(copiedStick)) + .inputItems(emptyStick) + .notConsumable(copiedStick) + .outputItems(resultStick) + .duration(DURATION).EUt(EUT) + .buildRawRecipe(); + // for EMI to detect it's a synthetic recipe (not ever in JSON) + recipe.setId(recipe.getId().withPrefix("/")); + return Collections.singletonList(recipe); } } } diff --git a/src/main/resources/assets/gtceu/textures/block/fluids/fluid.potion.png b/src/main/resources/assets/gtceu/textures/block/fluids/fluid.potion.png new file mode 100644 index 0000000000000000000000000000000000000000..8acccc3df0601bae7a3ed0fe40895ec1c6ec0b97 GIT binary patch literal 33496 zcmaLgJFlh5RmSnt$J;&k8ArB24lEHsL<~X#4Q|WRLbfbq2@nY&MuNcR)&fgN+#)Uk zAAyL3fQX2I5F#Ro92y4>7~3=Uc*b*U-rqX=UtMSSF-xjbRjbx|*0WaCTl+n`&)9$S zr7wQ|rRRVA`Kzm|mma?M;Fpj76IWN)SI^!*Mt}FO|NCD@cmKD3>GKbc{$H*hfAW*p zKYxs#`~BB`?T@ame)=c0dtdv%b)u6e?EBh>Y@6vN1yxE zN1y$@uYBe8uRgl^>>s}Vn~z@q?a%zl?>_pS&wT#j7ryi>fBEvKuC6|F_3*)~U;f&? ztDpUgfB*A)U;p~oAAj({2Z!&~)rTK`c=gdoAI;d0d-v{Lold9Gn}6(MADi~^kAM8? z{{8ziKE3nKJJyzCMgajOf@s&**H=II!4IaVKT#0T9zT9O(Q>kefi+Q+_uhMNhU`y9 zqG>ri^UO0d2gF$`5EfV_r>Ih9`0l&!4jV=R6qODbdtd_)Ixw_2VG#pP9NvHb{Z;5# zpPqg8*_8rE07OKATWav_>Zyn^KJVNsgh{U*-*<8UO(- zx_%B)%AEx#^FYmGw1dr2W>nOS6pK_uRR?J63dm=j#IZhp1XL72ob8Ua=bwN6>g~7R zo?5UuYH=C^69$Z(3u8|zy~5dldDCMFSet{?f>bibXo_?M;KT;?aXNGu%@{I6MgSK08gHM(L^Xe&H>PIsE`=i?$dX^^PSnI42#A%LDxEGwDs6c5lv9bNY9yW?=gsl zwGP|d2O{kZ&;z6=jYTykq6=`HV+$4=*Qdia;fKk=>a?Qg0GU1}oKUvjAuIKDkQhN_ z1Q|tQ?r7Uqz}*L(i(yc-BKIt)I2M2#n~T1R$XIbiwFvq9-~av?1qdK^v-d}O7|qyy zkTAj~^gR{eL`nrQf9gH}!cij}G!bI~fNlcHM+%7r3;-}la^9I(Tlax{2|y8IKnHXW zB28^Rof(iEY+sajr|Lo{fJRO&%w8EXNat39az2SC`IiZ+_#2e1lO{(6z=oj!ncV{3t!XaPo(2NiGyqmWC8MWEv>SB>aj zdF7P>19~p#%|*e0a<=ANpzZ*A;tAA5XEy;lvL;fA5hoF)BvMD0Gku>>Pu&MOwa+30 zAkw4zagLfE3rqoE0EC!d%SD75Cl2(+fwUW(Icnq-TDeLAi)b?fl4EQz znNMd1B}1kaWDqVF_~+fl7UDW*+No^z)1H2rgI;Nq(B_@bh;1Z9%#`815D;t z<}5lOO$zC%1qV?%I}>w=j`^H}@`T8t%9|5T04uI}2X79!hzT$T0qGmF3y{Ohb13*O2WBP zJ)P)*-umTxcizWD>oCaBSuvp{KG#>DRIr*G7Xgf;>7$XcYVv_*qee&dnp&&V# z0~BpfD**a+A21F;6bwW~pS0e6fK_#~KHC^=3M>F|41}H&V9YA=)T{$xqHzSkD5;oq zY_RA7ocn;1QHDTJ#;j*aLa$ zKFBx_J(Ks=1 zSUU5-fDri$);%&`jh9c0kP~Z~XFw2Z`|+MvUDP;>OpHmXaFjpi*7Vlb?+X@lh%S(Q z42X?g@GxOA3@m7|z(g$=(B-HnYM?&s)_q{1$C@E$(R*wGnLl+OppMdB2WNo}h-gI? z?V3KR9#3QZVe;4sc2n?JnU&*b=E> zBE5C+qr|{sPIt{)JEwi~noEhknv^$2^t;18W;ffIG8T{ty>aPfCzT`6pMCk)kMCb^ z{uW?@uDc<_fPlqJRO<@+(n~L`?X-UAZmzdd0HEazhz)TPD`sbA?uHJJJ^|hhK!qa%iyReD3V~YpRzt^rzjWq($>BhcAt?$b zoPcwRnE>tHsRxI%Vzt0AXKTg@fS%$hZ;^@&s44^GoJ}mM&AJ;ba0H@dP*DRn$AIm8 zmw;aAMPkID?cM1EvgY<8bG;b=(oh$jbASQ>jg5i=Vt_AWyW#4}w z^qfQ%B%xpTfkj)|b~4&Q%biXEV>z$AoTEIn4j@LNiNa|ImL@y0zLc7Zo*xnwFC9Rn z08iZq7CCcZ6p$VRyFp?AyrNFpeh~Rb9}s88fLh0fjiSeBYG4xO76RssHYNZk>Jg0H zu&q!Pg%X%KW7Ihk`gGP6b8e&-$LjcDF-COz+!$c%^Sv5WOo)h#Y78^J1e$ax<-?I- zMi$GntqiC-2{`WuZ52h*wwVLtY^VAzq1xQK4;Uz-Rw|tB0`WY!53po2DYy^XB2hwS z(6eD3ZH+VWregfm`$3lor=EEZ8#DOFfivI9NWIqQP}E(NxwUEd(S}%1ggdXn7-Wgm-m4n>vsp}+AhF|UP?d-pp~}V zqL>4tz%GF+uIRRQeMQVE*@5WLuc)!ecD`4GrdY}3cCLO7Kx361-Mpz*una7eRz(DA zU2hGe3Diq7CoKuU90+H{^GxtD*KTbi#G!T2x5!abIO5=N&W>*059BWmPSNAob`^~c zJplK?q~L}zAfo${0f_AtZBKo54iZ#OMMAedw??m( zyE+um`t^R9h-7i!4Mrp;H?t?-wXEM_EyP0cG$~4Uq$@E*>DxPu&L`NsKs>>VZYTSOVv>z8XXs8;%we09v)62gU~A zyrpHV-<_M&0TDzmh<^UT>(YUf#q`FgVn>GwNq6i0fRV-tP2(KK>+EP8@SFoim&WF# zgVlPD(!pX*qN*~msF5O%(K!uU*QYYQlpqC4=s=u0R5j7G z!2P}ebiE(UL%Kf%RMf!D0uD@%nuMx+n}eYFGdgO;k>OvkOcu z=F?eZk`srb0n8b|Q};o+Srkpy9RVP`FtbhGtEXUyqRIFUfv6l6}R=fGl-E&;41 zyN&2`A3!w8u!x*WfnzDrRVz00T^a)wwMfjX4P$B26-ZB}CY(gq2VjvSVU#0~eQtfe z<>qKnOFC4XbJBa*`Y2>GzdNIA!hq<3>N}OdeLnWt7~A!4k0?tex|})LB{~5(8Ebye zAnR|FC^7MI4@h(BN`-MC#@LYAg`O-s(IpZ^M!-D-bnZp0I#5sD2OM_i=76Py6{Z+s zH2-;4G(|FIXiOOHb9y>88UQ~o4MortmSNGdWiJIX-=Ua@!pWG!GB|X$l1^&9A7G*u z>yKWci)caAQUIhCz54(toAnzD^!8q~Xk*2BjE}M2yt=I4nE;4nfisE4OpYJ)f@o~# zJ}}^{5&iDS2`Ih30Bk%Hs|K8-%4iqHfhgQAa}pUig#gMAJ(9x?5|~ux8w^f+3ORDB zh^0oyQEIa;GDH(VN#j7OfoH*10#Lsrz|Dsf2V;gs6^Vmh5RUGHSWF5|7AI&>i7^L2 zF%%%$*7%Y2Fi|R;`yepSe7TSH@uMKk=PeCQ3o34J0icH`4i~$C0jP-1R!R{y$dY(>(T15;zu*3G|3A4Zn7`hrK>mFTc z2%=tegl?WjhPC!M$^f<2tAQN@I1HenM4%gUBIS&oR;sa>Hx$aEpcNPZP9!EGW5-Tv z^Eh+Zoj9P(FeY@s*wJgZ?t>h5%8b(MV*xCg&qhvtHd+t~z4UaP12-q^)<0rjrU8)T zgbm@;7^`)qRsFF#ev~T*g);|+nXMFH0Cq%+41rm+)_q{CXg%K9ObrFFat(!H`c?HQN73vG0D*yrzL;;2mkXA>u&*$beuNEPGpgQs65%Xu)@>x zVYj{xX%S6}y`eL%xE!z~FWJ zM571DSc=5Xn6Gt?oQN6_x|rn1M&sD}>>NZ3vEax_W0)9osOLxKZs4RafK(h7>Q)ORt*N(xg*hBC zC8|_orXPUrgN~?={tD-}cc3wh9UW2Zxer9LC<4HWI#$OI(EzhyizOSt_rCFsZ#+g* zQ7A*txszzlnWO_S|4IL7&p#~A!jZQ~0rreoFGVi%Z%!FeFepOv(lg&hYIA$!P-Pi$ zqE8o_KC!F|JQqrbA|_JcXx_GR(Au?m5>u74b2vkbzKA@DFqY9uXK!Nw&qEy%lOzwU2o8Nql z9tU)Dw1{GYBVzH{O^OqM4JZbl8mHQ3nh$(i2SPKFFCN0}C+$XuYkgJ^f%1=Q^x7q(K%y9P{yu#y15U=;{2l=v8vjf_c^9?g01_Y{kA|j(}}2;)+IZ^ZXWi- zfnjZOJ4cW|ktP<+*$6W42TiJYKn$V_#JG7infm}e=zz%X$S_8L30noFpJ#yr#XZNy zoPboD0ck_e;;hg=t59|bEv@b=z zq?80m{@?o`qd?U~3VWdSKZC}&Nc)&By~w2(_|(7zswRr&IgqpMYfJCE575*0D1h7t zij@S6LHhCY!=kG0l997-ov=-x?XAxRAXONnQo+b`;M4l@d0F2vR|Ckqv!_lidLcJv zi-`cUjV9d(9S}NS;-gLKfj6d~`+#u_RQz(Q(Czvz`_Lx&? zTlc|K^_(Yk_abJc2Ee#r#_PXjphUHZ9E*hIejl*W_{=XHeJaT>^zlCbpzl7&G4T05 z5na)V94n%EdSk4tOO*gyyD*yb4}gh0fs_&_LO;8Z!A#BtWME4+QAE=UGrR?1;h^pn&srAjCv8^{_=gPzhstz%i;0lY)i) zKFCRriS@*Iuh%+>B8o!lZQK5(eD?uHr7}-rIhKkjv2rH@)UylRK{B4dO)^0>0}(X$ zL7=5zF1mHH{*{Nb1qBqnhlin5_WQuj*b!j!et;h5KsXl}O`z@rz{czVo1fl%^Ua|W zB@Ub|CKXIn=~`zG?9TTCjtur(O9_1<5SuxPQR->qC=$WMdO7z7%Vror(nO#joO7ra zF>*SM0S|+6=9Ce1faV$*Lr?1 zF!l<+e*Nig$RJ}69Gx`A;TY#^zJ7}p74?{K0^$%6DfQiAfb?@Wa1ud_E+f$$G?5%< zcGfk30?c;_83Qm*+(w)^=mA)dzOa}H4loQ#)+DDI0HS>I2pIXnHlbTYhj6p^Sy zYo*v+KMV{)pB!q5{H zWjzt3-Z}*0uec|`3GDM z7A?de$Iga)Idu~GkaZF*iUOpqEET;i^AI^Ngbw3*@eV!IA_1~SPe%%ZneqJY0IjR5 z=+G-5R@G-vjvw8ZlLC50DHV}9YNGi}jG2!&>yv`T=ur@h#2kR#U}NlvXKy}NniNd* zS^$CQ>9R8?bdv&S(Lz=St*9}R=6*JYf&3XlS4c_?07vU0**<#rfi?CDd92_3_9nNe zGvsXkquviXQ0qUOj5g%*Yiw>@WWdrf9{>gvHS=89B*K@dHpjwr}ka6#8?`BUtm*8Y$t^-$(*EMG0L2X z=-6=5v%~h*>wbXPA46^xeuH!#!|`9B4GIfA@!Ul z@;Sgf&Q)HufdQZsskG8tqr=Af{HbB+`W~JMd;U=xA`?AZAj7}_GTFyD6u`Q%W^Dir za&8<5s+Yo+U2XmPPZ2GYH3e1+K&26bSRA#vxwiLc7VQX~v8Wor?C6InL(&;wXn|m5 zXGEvt-j)61a4c;7cAaft|fN-#l0CJ?$Fy%I%sC?f#>7|v?*{;lr6T320Y!!6!~q})v=n0*_|(EalN@(8vvB?a zOansL4WpfIwCEIx1H*PG5De(qO${tiN@r&xTC_2><}lF#nEQZ}3)2LUdN5#Ye0k-u zJ4c>W=2IjkN7aU2L^>%HwUjWXTmRz{P$~EOAY*;Z%3qK1dKxK61q+Zf(bEyO#%$+V zfRsTFj2K)>=~!34VX!-KfUb4=VijO)rL}%zX%SckiW{JUbvCjc=1mxAgf5U>Z>?S8 zJVg|-6c})j8>#Zf^meGP&a#>B6B$Ay#`~Rs2}YMp-C%Pk^v#r_F{a#|09u=T54L~= zP#@#jM)Zo{39FERjIH~(hEf6m5b&)p>T{4Ez(5&`2+TM;DbHJ4^!1`)!6>1pBS31m z?gK`I(pZsDW=!Zr#|pSHIoRG@&nAomGPYKIV&ELmX*OWqk$k}-M-i(!1LJBTs>V(b zyG7>2wC^Hz(%c6?IPGcBl?way-@}(9OMdB<z`$Ze zrw;7aQKl3vL;HToEJp0KNnyW4p>om}Evi^>>S?97rE?!BkV(`#6FFfgI`Lf+=T7Ea zsvL>P-8hrqv8AP^7%*U0J4tNY@>yqyjaw5$0M3Bt&#R&q0}DiyiWhCRu^Z-$2(+BO*CUH zoE3i=FaQ-XBR%RCiS)o1)w?Xe_F6J%EaP zdh6f*>C;EdPdt3^>X$i*#E_9wM+cZ-g$2=LOb2`b|Kr}zeDu_RLAqBIGOu#1FDKF0 zp9(Q1d)QGNKY%EPzTAKe6-GJdP(_PK&p6>+mDjH@7We3))pD!{7Wg$Ia_L;2*4U`7 zDjQqNZ!v(FNC`zonnzJ1erNQZK&NaDM*GRY{xAmO!$Xg<-O*PIcI4+i`0t Date: Wed, 11 Dec 2024 21:43:20 -0500 Subject: [PATCH 2/4] She Either on my Triple til I List --- .../recipe/FluidRecipeCapability.java | 29 +- .../recipe/ItemRecipeCapability.java | 274 +++++------------ .../api/gui/widget/PatternPreviewWidget.java | 2 +- .../gtceu/api/gui/widget/SlotWidget.java | 267 +++++++---------- .../gtceu/api/gui/widget/TankWidget.java | 282 ++++++++---------- .../fluid/TagOrCycleFluidHandler.java | 116 ------- .../item/TagOrCycleItemStackHandler.java | 107 ------- .../gtceu/common/data/GCYMRecipeTypes.java | 2 +- .../gtceu/common/data/GTRecipeTypes.java | 2 +- .../xei/entry/fluid/FluidEntryList.java | 12 + .../xei/entry/fluid/FluidStackList.java | 51 ++++ .../xei/entry/fluid/FluidTagList.java | 56 ++++ .../xei/entry/item/ItemEntryList.java | 12 + .../xei/entry/item/ItemStackList.java | 55 ++++ .../xei/entry/item/ItemTagList.java | 63 ++++ .../fluid/CycleFluidEntryHandler.java | 101 +++++++ .../fluid/CycleFluidStackHandler.java} | 27 +- .../handlers/item/CycleItemEntryHandler.java | 86 ++++++ .../handlers}/item/CycleItemStackHandler.java | 24 +- .../xei/widgets/GTOreByProduct.java | 56 ++-- .../xei/widgets/GTOreByProductWidget.java | 25 +- .../gtceu/utils/ItemStackHashStrategy.java | 5 + 22 files changed, 814 insertions(+), 840 deletions(-) delete mode 100644 src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/TagOrCycleFluidHandler.java delete mode 100644 src/main/java/com/gregtechceu/gtceu/api/transfer/item/TagOrCycleItemStackHandler.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidEntryList.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidStackList.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidTagList.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemEntryList.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemStackList.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemTagList.java create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/fluid/CycleFluidEntryHandler.java rename src/main/java/com/gregtechceu/gtceu/{api/transfer/fluid/CycleFluidHandler.java => integration/xei/handlers/fluid/CycleFluidStackHandler.java} (66%) create mode 100644 src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/item/CycleItemEntryHandler.java rename src/main/java/com/gregtechceu/gtceu/{api/transfer => integration/xei/handlers}/item/CycleItemStackHandler.java (68%) diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java index c0b77fa8e2..0459a0e986 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java @@ -14,8 +14,11 @@ import com.gregtechceu.gtceu.api.recipe.modifier.ParallelLogic; import com.gregtechceu.gtceu.api.recipe.ui.GTRecipeTypeUI; import com.gregtechceu.gtceu.api.transfer.fluid.IFluidHandlerModifiable; -import com.gregtechceu.gtceu.api.transfer.fluid.TagOrCycleFluidHandler; import com.gregtechceu.gtceu.client.TooltipsHandler; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidEntryList; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidStackList; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidTagList; +import com.gregtechceu.gtceu.integration.xei.handlers.fluid.CycleFluidEntryHandler; import com.gregtechceu.gtceu.integration.xei.widgets.GTRecipeWidget; import com.gregtechceu.gtceu.utils.FluidKey; import com.gregtechceu.gtceu.utils.GTHashMaps; @@ -28,16 +31,13 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.tags.TagKey; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.material.Fluid; import net.minecraftforge.fluids.FluidStack; -import com.mojang.datafixers.util.Either; import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.UnknownNullability; @@ -304,8 +304,7 @@ public int getMaxParallelRatio(IRecipeCapabilityHolder holder, GTRecipe recipe, public Object createXEIContainer(List contents) { // cast is safe if you don't pass the wrong thing. // noinspection unchecked - return new TagOrCycleFluidHandler( - (List, Integer, @Nullable CompoundTag>>, List>>) contents); + return new CycleFluidEntryHandler((List) contents); } @NotNull @@ -334,8 +333,8 @@ public void applyWidgetInfo(@NotNull Widget widget, @Nullable Content content, @Nullable Object storage, int recipeTier, int chanceTier) { if (widget instanceof TankWidget tank) { - if (storage instanceof TagOrCycleFluidHandler fluidHandler) { - tank.setFluidTank(fluidHandler, index); + if (storage instanceof CycleFluidEntryHandler cycleHandler) { + tank.setFluidTank(cycleHandler, index); } else if (storage instanceof IFluidHandlerModifiable fluidHandler) { tank.setFluidTank(new OverlayingFluidStorage(fluidHandler, index)); } @@ -367,24 +366,24 @@ public void applyWidgetInfo(@NotNull Widget widget, } } - // Maps fluids to Either<(tag with count), FluidStack>s - public static Either, Integer, @Nullable CompoundTag>>, List> mapFluid(FluidIngredient ingredient) { + // Maps fluids to a FluidEntryList for XEI: either a FluidTagList or a FluidStackList + public static FluidEntryList mapFluid(FluidIngredient ingredient) { int amount = ingredient.getAmount(); CompoundTag tag = ingredient.getNbt(); - List, Integer, @Nullable CompoundTag>> tags = new ArrayList<>(); - List fluids = new ArrayList<>(); + FluidTagList tags = new FluidTagList(); + FluidStackList fluids = new FluidStackList(); for (FluidIngredient.Value value : ingredient.values) { if (value instanceof FluidIngredient.TagValue tagValue) { - tags.add(Triple.of(tagValue.getTag(), amount, ingredient.getNbt())); + tags.add(tagValue.getTag(), amount, ingredient.getNbt()); } else { fluids.addAll(value.getFluids().stream().map(fluid -> new FluidStack(fluid, amount, tag)).toList()); } } if (!tags.isEmpty()) { - return Either.left(tags); + return tags; } else { - return Either.right(fluids); + return fluids; } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java index 965c7cdf9e..cc91703be7 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/ItemRecipeCapability.java @@ -17,8 +17,6 @@ import com.gregtechceu.gtceu.api.recipe.lookup.*; import com.gregtechceu.gtceu.api.recipe.modifier.ParallelLogic; import com.gregtechceu.gtceu.api.recipe.ui.GTRecipeTypeUI; -import com.gregtechceu.gtceu.api.transfer.item.CycleItemStackHandler; -import com.gregtechceu.gtceu.api.transfer.item.TagOrCycleItemStackHandler; import com.gregtechceu.gtceu.common.recipe.condition.ResearchCondition; import com.gregtechceu.gtceu.common.valueprovider.AddedFloat; import com.gregtechceu.gtceu.common.valueprovider.CastedFloat; @@ -28,6 +26,11 @@ import com.gregtechceu.gtceu.core.mixins.IngredientAccessor; import com.gregtechceu.gtceu.core.mixins.IntersectionIngredientAccessor; import com.gregtechceu.gtceu.core.mixins.TagValueAccessor; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemEntryList; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemStackList; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemTagList; +import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemEntryHandler; +import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemStackHandler; import com.gregtechceu.gtceu.integration.xei.widgets.GTRecipeWidget; import com.gregtechceu.gtceu.utils.*; @@ -35,13 +38,9 @@ import com.lowdragmc.lowdraglib.jei.IngredientIO; import net.minecraft.ChatFormatting; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.tags.TagKey; import net.minecraft.util.valueproviders.ConstantFloat; import net.minecraft.util.valueproviders.IntProvider; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.common.crafting.IntersectionIngredient; @@ -50,19 +49,14 @@ import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.wrapper.CombinedInvWrapper; -import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Pair; -import it.unimi.dsi.fastutil.objects.Object2IntMap; -import it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import org.apache.commons.lang3.tuple.Triple; +import it.unimi.dsi.fastutil.objects.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.UnknownNullability; import java.util.*; -import java.util.function.Function; +import java.util.function.UnaryOperator; import java.util.stream.Collectors; /** @@ -417,12 +411,13 @@ private Object2IntMap getIngredientStacks(IRecipeCapabilityHolder hol @Override public @NotNull List createXEIContainerContents(List contents, GTRecipe recipe, IO io) { - var outputStacks = contents.stream().map(content -> content.content) + var entryLists = contents.stream() + .map(Content::getContent) .map(this::of) .map(ItemRecipeCapability::mapItem) .collect(Collectors.toList()); - List, Integer, @Nullable CompoundTag>>, List>> scannerPossibilities = null; + List scannerPossibilities = null; if (io == IO.OUT && recipe.recipeType.isScanner()) { scannerPossibilities = new ArrayList<>(); // Scanner Output replacing, used for cycling research outputs @@ -434,48 +429,33 @@ private Object2IntMap getIngredientStacks(IRecipeCapabilityHolder hol if (researchData != null) { Collection possibleRecipes = researchData.getFirst() .getDataStickEntry(researchData.getSecond()); + Set cache = new ObjectOpenCustomHashSet<>(ItemStackHashStrategy.comparingItem()); if (possibleRecipes != null) { for (GTRecipe r : possibleRecipes) { - ItemStack researchItem = ItemRecipeCapability.CAP - .of(r.getOutputContents(ItemRecipeCapability.CAP).get(0).content).getItems()[0]; - researchItem = researchItem.copy(); - researchItem.setCount(1); - boolean didMatch = false; - for (Either, Integer, @Nullable CompoundTag>>, List> stacks : scannerPossibilities) { - for (ItemStack stack : stacks.map( - tag -> tag - .stream() - .flatMap(key -> BuiltInRegistries.ITEM.getTag(key.getLeft()).stream()) - .flatMap(holders -> holders.stream() - .map(holder -> new ItemStack(holder.get()))) - .collect(Collectors.toList()), - Function.identity())) { - if (ItemStack.isSameItem(stack, researchItem)) { - didMatch = true; - break; - } - } + Content outputContent = r.getOutputContents(ItemRecipeCapability.CAP).get(0); + ItemStack researchStack = ItemRecipeCapability.CAP.of(outputContent.content).getItems()[0]; + if (!cache.contains(researchStack)) { + cache.add(researchStack); + scannerPossibilities.add(ItemStackList.of(researchStack.copyWithCount(1))); } - if (!didMatch) scannerPossibilities.add(Either.right(List.of(researchItem))); } } - scannerPossibilities.add(outputStacks.get(0)); + scannerPossibilities.add(entryLists.get(0)); } } if (scannerPossibilities != null && !scannerPossibilities.isEmpty()) { - outputStacks = scannerPossibilities; + entryLists = scannerPossibilities; } - while (outputStacks.size() < recipe.recipeType.getMaxOutputs(ItemRecipeCapability.CAP)) outputStacks.add(null); + while (entryLists.size() < recipe.recipeType.getMaxOutputs(ItemRecipeCapability.CAP)) entryLists.add(null); - return new ArrayList<>(outputStacks); + return new ArrayList<>(entryLists); } public Object createXEIContainer(List contents) { // cast is safe if you don't pass the wrong thing. // noinspection unchecked - return new TagOrCycleItemStackHandler( - (List, Integer, @Nullable CompoundTag>>, List>>) contents); + return new CycleItemEntryHandler((List) contents); } @NotNull @@ -567,176 +547,60 @@ public void applyWidgetInfo(@NotNull Widget widget, } } - // Maps ingredients to Either <(Tag with count), ItemStack>s - @SuppressWarnings("deprecation") - private static Either, Integer, @Nullable CompoundTag>>, List> mapItem(final Ingredient ingredient) { + // Maps ingredients to an ItemEntryList for XEI: either an ItemTagList or an ItemStackList + private static ItemEntryList mapItem(final Ingredient ingredient) { if (ingredient instanceof SizedIngredient sizedIngredient) { final int amount = sizedIngredient.getAmount(); - if (sizedIngredient.getInner() instanceof IntersectionIngredient intersection) { - List children = ((IntersectionIngredientAccessor) intersection).getChildren(); - if (children.isEmpty()) { - return Either.right(null); - } - var childEither = mapItem(children.get(0)); - return Either.right(childEither.map(tags -> { - List tagItems = tags.stream() - .map(pair -> Triple.of(BuiltInRegistries.ITEM.getTag(pair.getLeft()).stream(), - pair.getMiddle(), pair.getRight())) - .flatMap(pair -> pair.getLeft().flatMap( - tag -> tag.stream().map(holder -> { - ItemStack stack = new ItemStack(holder.value(), pair.getMiddle()); - stack.setTag(pair.getRight()); - return stack; - }))) - .collect(Collectors.toList()); - ListIterator iterator = tagItems.listIterator(); - iteratorLoop: - while (iterator.hasNext()) { - var item = iterator.next(); - for (int i = 1; i < children.size(); ++i) { - if (!children.get(i).test(item)) { - iterator.remove(); - continue iteratorLoop; - } - } - iterator.set(item.copyWithCount(amount)); - } - return tagItems; - }, items -> { - items = new ArrayList<>(items); - ListIterator iterator = items.listIterator(); - iteratorLoop: - while (iterator.hasNext()) { - var item = iterator.next(); - for (int i = 1; i < children.size(); ++i) { - if (!children.get(i).test(item)) { - iterator.remove(); - continue iteratorLoop; - } - } - iterator.set(item.copyWithCount(amount)); - } - return items; - })); - } else if (((IngredientAccessor) sizedIngredient.getInner()).getValues().length > 0 && - ((IngredientAccessor) sizedIngredient.getInner()) - .getValues()[0] instanceof Ingredient.TagValue tagValue) { - return Either - .left(List.of(Triple.of(((TagValueAccessor) tagValue).getTag(), amount, null))); - } - } else if (ingredient instanceof IntersectionIngredient intersection) { - // Map intersection ingredients to the items inside, as recipe viewers don't support them. - List children = ((IntersectionIngredientAccessor) intersection).getChildren(); - if (children.isEmpty()) { - return Either.right(null); - } - var childEither = mapItem(children.get(0)); - return Either.right(childEither.map(tags -> { - List tagItems = tags.stream() - .map(pair -> Triple.of(BuiltInRegistries.ITEM.getTag(pair.getLeft()).stream(), pair.getMiddle(), - pair.getRight())) - .flatMap(pair -> pair.getLeft().flatMap( - tag -> tag.stream().map(holder -> { - ItemStack stack = new ItemStack(holder.value(), pair.getMiddle()); - stack.setTag(pair.getRight()); - return stack; - }))) - .collect(Collectors.toList()); - ListIterator iterator = tagItems.listIterator(); - while (iterator.hasNext()) { - var item = iterator.next(); - for (int i = 1; i < children.size(); ++i) { - if (!children.get(i).test(item)) { - iterator.remove(); - break; - } - } - } - return tagItems; - }, items -> { - items = new ArrayList<>(items); - ListIterator iterator = items.listIterator(); - while (iterator.hasNext()) { - var item = iterator.next(); - for (int i = 1; i < children.size(); ++i) { - if (!children.get(i).test(item)) { - iterator.remove(); - break; - } - } - } - return items; - })); + var mapped = tryMapInner(sizedIngredient.getInner(), amount); + if (mapped != null) return mapped; } else if (ingredient instanceof IntProviderIngredient intProvider) { final int amount = 1; - if (intProvider.getInner() instanceof IntersectionIngredient intersection) { - List children = ((IntersectionIngredientAccessor) intersection).getChildren(); - if (children.isEmpty()) { - return Either.right(null); - } - var childEither = mapItem(children.get(0)); - return Either.right(childEither.map(tags -> { - List tagItems = tags.stream() - .map(pair -> Triple.of(BuiltInRegistries.ITEM.getTag(pair.getLeft()).stream(), - pair.getMiddle(), pair.getRight())) - .flatMap(pair -> pair.getLeft().flatMap( - tag -> tag.stream().map(holder -> { - ItemStack stack = new ItemStack(holder.value(), pair.getMiddle()); - stack.setTag(pair.getRight()); - return stack; - }))) - .collect(Collectors.toList()); - ListIterator iterator = tagItems.listIterator(); - iteratorLoop: - while (iterator.hasNext()) { - var item = iterator.next(); - for (int i = 1; i < children.size(); ++i) { - if (!children.get(i).test(item)) { - iterator.remove(); - continue iteratorLoop; - } - } - iterator.set(item.copyWithCount(amount)); - } - return tagItems; - }, items -> { - items = new ArrayList<>(items); - ListIterator iterator = items.listIterator(); - iteratorLoop: - while (iterator.hasNext()) { - var item = iterator.next(); - for (int i = 1; i < children.size(); ++i) { - if (!children.get(i).test(item)) { - iterator.remove(); - continue iteratorLoop; - } - } - iterator.set(item.copyWithCount(amount)); - } - return items; - })); - } else if (((IngredientAccessor) intProvider.getInner()).getValues().length > 0 && - ((IngredientAccessor) intProvider.getInner()) - .getValues()[0] instanceof Ingredient.TagValue tagValue) { - return Either - .left(List.of(Triple.of(((TagValueAccessor) tagValue).getTag(), amount, null))); - } + var mapped = tryMapInner(intProvider.getInner(), amount); + if (mapped != null) return mapped; + } else if (ingredient instanceof IntersectionIngredient intersection) { + return mapIntersection(intersection, -1); + } else { + var tagList = tryMapTag(ingredient, 1); + if (tagList != null) return tagList; + } + ItemStackList stackList = new ItemStackList(); + boolean isIntProvider = ingredient instanceof IntProviderIngredient || + (ingredient instanceof SizedIngredient sized && sized.getInner() instanceof IntProviderIngredient); + + UnaryOperator setCount = stack -> isIntProvider ? stack.copyWithCount(1) : stack; + Arrays.stream(ingredient.getItems()) + .map(setCount) + .forEach(stackList::add); + return stackList; + } - } else if (((IngredientAccessor) ingredient).getValues().length > 0 && - ((IngredientAccessor) ingredient).getValues()[0] instanceof Ingredient.TagValue tagValue) { - return Either.left(List.of(Triple.of(((TagValueAccessor) tagValue).getTag(), 1, null))); - } - return Either.right(Arrays.stream(ingredient.getItems()).map(stack -> { - //@formatter:off - if (ingredient instanceof IntProviderIngredient) { - stack.setCount(1); - } else if (ingredient instanceof SizedIngredient sized && - sized.getInner() instanceof IntProviderIngredient) { - stack.setCount(1); + private static @Nullable ItemEntryList tryMapInner(final Ingredient inner, int amount) { + if (inner instanceof IntersectionIngredient intersection) return mapIntersection(intersection, amount); + return tryMapTag(inner, amount); + } + + // Map intersection ingredients to the items inside, as recipe viewers don't support them. + private static ItemEntryList mapIntersection(final IntersectionIngredient intersection, int amount) { + List children = ((IntersectionIngredientAccessor) intersection).getChildren(); + if (children.isEmpty()) return new ItemStackList(); + + var childList = mapItem(children.get(0)); + ItemStackList stackList = new ItemStackList(); + for (var stack : childList.getStacks()) { + if (children.stream().skip(1).allMatch(child -> child.test(stack))) { + if (amount > 0) stackList.add(stack.copyWithCount(amount)); + else stackList.add(stack.copy()); } - //@formatter:on - return stack; - }).toList()); + } + return stackList; + } + + private static @Nullable ItemTagList tryMapTag(final Ingredient ingredient, int amount) { + var values = ((IngredientAccessor) ingredient).getValues(); + if (values.length > 0 && values[0] instanceof Ingredient.TagValue tagValue) { + return ItemTagList.of(((TagValueAccessor) tagValue).getTag(), amount, null); + } + return null; } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java index ef1abf407a..ce329dab36 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java @@ -10,8 +10,8 @@ import com.gregtechceu.gtceu.api.pattern.MultiblockShapeInfo; import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate; import com.gregtechceu.gtceu.api.pattern.predicates.SimplePredicate; -import com.gregtechceu.gtceu.api.transfer.item.CycleItemStackHandler; import com.gregtechceu.gtceu.config.ConfigHolder; +import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemStackHandler; import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.editor.ColorPattern; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java index 3d1dfc3e40..192e5f2c39 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/SlotWidget.java @@ -1,7 +1,10 @@ package com.gregtechceu.gtceu.api.gui.widget; -import com.gregtechceu.gtceu.api.transfer.item.CycleItemStackHandler; -import com.gregtechceu.gtceu.api.transfer.item.TagOrCycleItemStackHandler; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemEntryList; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemStackList; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemTagList; +import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemEntryHandler; +import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemStackHandler; import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.editor.annotation.LDLRegister; @@ -12,32 +15,24 @@ import com.lowdragmc.lowdraglib.jei.IngredientIO; import com.lowdragmc.lowdraglib.jei.JEIPlugin; import com.lowdragmc.lowdraglib.side.item.IItemTransfer; +import com.lowdragmc.lowdraglib.utils.Position; +import com.lowdragmc.lowdraglib.utils.Size; -import net.minecraft.core.HolderSet; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.tags.TagKey; import net.minecraft.world.Container; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.Slot; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Blocks; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemStackHandler; -import com.mojang.datafixers.util.Either; import dev.emi.emi.api.stack.EmiIngredient; -import dev.emi.emi.api.stack.EmiRegistryAdapter; import dev.emi.emi.api.stack.EmiStack; -import dev.emi.emi.registry.EmiTags; import lombok.Getter; import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; -import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -202,20 +197,19 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { if (handler == null) return null; ItemStack realStack = getRealStack(handler.getItem()); if (handler instanceof WidgetSlotItemHandler slotHandler) { - if (slotHandler.itemHandler instanceof CycleItemStackHandler cycleHandler) { - return getXEIIngredientsFromCycleHandlerClickable(cycleHandler, slotHandler.index); - } else if (slotHandler.itemHandler instanceof TagOrCycleItemStackHandler tagHandler) { - return getXEIIngredientsFromTagOrCycleHandlerClickable(tagHandler, slotHandler.index); + if (slotHandler.itemHandler instanceof CycleItemStackHandler stackHandler) { + return getXEIIngredientsClickable(stackHandler, slotHandler.index); + } else if (slotHandler.itemHandler instanceof CycleItemEntryHandler entryHandler) { + return getXEIIngredientsClickable(entryHandler, slotHandler.index); } } if (LDLib.isJeiLoaded() && !realStack.isEmpty()) { - return JEIPlugin.getItemIngredient(realStack, getPositionX(), getPositionY(), getSizeWidth(), - getSizeHeight()); + return JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize()); } else if (LDLib.isReiLoaded()) { - return REICallWrapper.getReiIngredients(realStack); + return EntryStacks.of(realStack); } else if (LDLib.isEmiLoaded()) { - return EMICallWrapper.getEmiIngredients(realStack, getXEIChance()); + return EmiStack.of(realStack).setChance(getXEIChance()); } return realStack; } @@ -229,137 +223,69 @@ public List getXEIIngredients() { if (handler == null) return Collections.emptyList(); ItemStack realStack = getRealStack(handler.getItem()); if (handler instanceof WidgetSlotItemHandler slotHandler) { - if (slotHandler.itemHandler instanceof CycleItemStackHandler cycleHandler) { - return getXEIIngredientsFromCycleHandlerClickable(cycleHandler, slotHandler.index); - } else if (slotHandler.itemHandler instanceof TagOrCycleItemStackHandler tagHandler) { - return getXEIIngredientsFromTagOrCycleHandlerClickable(tagHandler, slotHandler.index); + if (slotHandler.itemHandler instanceof CycleItemStackHandler stackHandler) { + return getXEIIngredientsClickable(stackHandler, slotHandler.index); + } else if (slotHandler.itemHandler instanceof CycleItemEntryHandler entryHandler) { + return getXEIIngredientsClickable(entryHandler, slotHandler.index); } } - if (LDLib.isJeiLoaded()) { - var ingredient = JEIPlugin.getItemIngredient(realStack, getPosition().x, getPosition().y, getSize().width, - getSize().height); - return ingredient == null ? Collections.emptyList() : List.of(ingredient); + if (LDLib.isJeiLoaded() && !realStack.isEmpty()) { + return List.of(JEICallWrapper.getJEIStackClickable(realStack, getPosition(), getSize())); } else if (LDLib.isReiLoaded()) { - return REICallWrapper.getReiIngredients(realStack); + return List.of(EntryStacks.of(realStack)); } else if (LDLib.isEmiLoaded()) { - return EMICallWrapper.getEmiIngredients(realStack, getXEIChance()); + return List.of(EmiStack.of(realStack).setChance(getXEIChance())); } return List.of(realStack); } - private List getXEIIngredientsFromCycleHandler(CycleItemStackHandler handler, int index) { - var stream = handler.getStackList(index).stream().map(this::getRealStack); + private List getXEIIngredients(CycleItemStackHandler handler, int index) { + var stackList = handler.getStackList(index); if (LDLib.isJeiLoaded()) { - return stream.filter(stack -> !stack.isEmpty()).collect(Collectors.toList()); + return JEICallWrapper.getJEIIngredients(stackList, this::getRealStack); } else if (LDLib.isReiLoaded()) { - return REICallWrapper.getReiIngredients(stream); + return REICallWrapper.getREIIngredients(stackList, this::getRealStack); } else if (LDLib.isEmiLoaded()) { - return EMICallWrapper.getEmiIngredients(stream, getXEIChance()); + return EMICallWrapper.getEMIIngredients(stackList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); } - private List getXEIIngredientsFromCycleHandlerClickable(CycleItemStackHandler handler, int index) { - var stream = handler.getStackList(index).stream().map(this::getRealStack); + private List getXEIIngredientsClickable(CycleItemStackHandler handler, int index) { + var stackList = handler.getStackList(index); if (LDLib.isJeiLoaded()) { - return stream - .filter(stack -> !stack.isEmpty()) - .map(item -> JEIPlugin.getItemIngredient(item, getPositionX(), getPositionY(), getSizeWidth(), - getSizeHeight())) - .toList(); + return JEICallWrapper.getJEIIngredientsClickable(stackList, getPosition(), getSize(), this::getRealStack); } else if (LDLib.isReiLoaded()) { - return REICallWrapper.getReiIngredients(stream); + return REICallWrapper.getREIIngredients(stackList, this::getRealStack); } else if (LDLib.isEmiLoaded()) { - return EMICallWrapper.getEmiIngredients(stream, getXEIChance()); + return EMICallWrapper.getEMIIngredients(stackList, getXEIChance(), this::getRealStack); } return Collections.emptyList(); } - private List getXEIIngredientsFromTagOrCycleHandler(TagOrCycleItemStackHandler handler, int index) { - Either, Integer, @Nullable CompoundTag>>, List> either = handler - .getStacks() - .get(index); - var ref = new Object() { - - List returnValue = Collections.emptyList(); - }; - either.ifLeft(list -> { - if (LDLib.isJeiLoaded()) { - ref.returnValue = list.stream() - .flatMap(pair -> BuiltInRegistries.ITEM - .getTag(pair.getLeft()) - .stream() - .flatMap(HolderSet.ListBacked::stream) - .map(item -> { - ItemStack stack = new ItemStack(item.value(), pair.getMiddle()); - stack.setTag(pair.getRight()); - return getRealStack(stack); - })) - .collect(Collectors.toList()); - } else if (LDLib.isReiLoaded()) { - ref.returnValue = REICallWrapper.getReiIngredients(this::getRealStack, list); - } else if (LDLib.isEmiLoaded()) { - ref.returnValue = EMICallWrapper.getEmiIngredients(list, getXEIChance()); - } - }).ifRight(items -> { - var stream = items.stream().map(this::getRealStack); - if (LDLib.isJeiLoaded()) { - ref.returnValue = stream - .filter(stack -> !stack.isEmpty()) - .collect(Collectors.toList()); - } else if (LDLib.isReiLoaded()) { - ref.returnValue = REICallWrapper.getReiIngredients(stream); - } else if (LDLib.isEmiLoaded()) { - ref.returnValue = EMICallWrapper.getEmiIngredients(stream, getXEIChance()); - } - }); - return ref.returnValue; + private List getXEIIngredients(CycleItemEntryHandler handler, int index) { + ItemEntryList entryList = handler.getEntry(index); + if (LDLib.isJeiLoaded()) { + return JEICallWrapper.getJEIIngredients(entryList, this::getRealStack); + } else if (LDLib.isReiLoaded()) { + return REICallWrapper.getREIIngredients(entryList, this::getRealStack); + } else if (LDLib.isEmiLoaded()) { + return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); + } + return Collections.emptyList(); } - private List getXEIIngredientsFromTagOrCycleHandlerClickable(TagOrCycleItemStackHandler handler, - int index) { - Either, Integer, @Nullable CompoundTag>>, List> either = handler - .getStacks() - .get(index); - var ref = new Object() { - - List returnValue = Collections.emptyList(); - }; - either.ifLeft(list -> { - if (LDLib.isJeiLoaded()) { - ref.returnValue = list.stream() - .flatMap(pair -> BuiltInRegistries.ITEM - .getTag(pair.getLeft()) - .stream() - .flatMap(HolderSet.ListBacked::stream) - .map(item -> { - ItemStack stack = new ItemStack(item.value(), pair.getMiddle()); - stack.setTag(pair.getRight()); - return JEIPlugin.getItemIngredient(getRealStack(stack), - getPosition().x, getPosition().y, getSize().width, getSize().height); - })) - .collect(Collectors.toList()); - } else if (LDLib.isReiLoaded()) { - ref.returnValue = REICallWrapper.getReiIngredients(this::getRealStack, list); - } else if (LDLib.isEmiLoaded()) { - ref.returnValue = EMICallWrapper.getEmiIngredients(list, getXEIChance()); - } - }).ifRight(items -> { - var stream = items.stream().map(this::getRealStack); - if (LDLib.isJeiLoaded()) { - ref.returnValue = stream - .filter(stack -> !stack.isEmpty()) - .map(item -> JEIPlugin.getItemIngredient(item, getPosition().x, getPosition().y, - getSize().width, getSize().height)) - .toList(); - } else if (LDLib.isReiLoaded()) { - ref.returnValue = REICallWrapper.getReiIngredients(stream); - } else if (LDLib.isEmiLoaded()) { - ref.returnValue = EMICallWrapper.getEmiIngredients(stream, getXEIChance()); - } - }); - return ref.returnValue; + private List getXEIIngredientsClickable(CycleItemEntryHandler handler, int index) { + ItemEntryList entryList = handler.getEntry(index); + if (LDLib.isJeiLoaded()) { + return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize(), this::getRealStack); + } else if (LDLib.isReiLoaded()) { + return REICallWrapper.getREIIngredients(entryList, this::getRealStack); + } else if (LDLib.isEmiLoaded()) { + return EMICallWrapper.getEMIIngredients(entryList, getXEIChance(), this::getRealStack); + } + return Collections.emptyList(); } public class WidgetSlotItemHandler extends Slot { @@ -447,54 +373,81 @@ public boolean isActive() { } } + public static final class JEICallWrapper { + + public static Object getJEIStackClickable(ItemStack stack, Position pos, Size size) { + return JEIPlugin.getItemIngredient(stack, pos.x, pos.y, size.width, size.height); + } + + public static List getJEIIngredients(ItemEntryList list, UnaryOperator realStack) { + return list.getStacks() + .stream() + .filter(stack -> !stack.isEmpty()) + .map(realStack) + .collect(Collectors.toList()); + } + + public static List getJEIIngredientsClickable(ItemEntryList list, Position pos, Size size, + UnaryOperator realStack) { + return list.getStacks() + .stream() + .filter(stack -> !stack.isEmpty()) + .map(realStack) + .map(stack -> getJEIStackClickable(stack, pos, size)) + .collect(Collectors.toList()); + } + } + public static final class REICallWrapper { - public static List getReiIngredients(Stream stream) { - return List.of(EntryIngredient.of(stream.map(EntryStacks::of).toList())); + private static EntryIngredient toREIIngredient(Stream stream, UnaryOperator realStack) { + return EntryIngredient.of(stream.map(realStack) + .map(EntryStacks::of) + .toList()); + } + + public static List getREIIngredients(ItemStackList list, UnaryOperator realStack) { + return List.of(toREIIngredient(list.stream(), realStack)); } - public static List getReiIngredients(UnaryOperator realStack, - List, Integer, @Nullable CompoundTag>> list) { - return list.stream() - .map(pair -> EntryIngredients.ofTag(pair.getLeft(), - holder -> { - ItemStack stack = new ItemStack(holder.value(), pair.getMiddle()); - stack.setTag(pair.getRight()); - return EntryStacks.of(realStack.apply(stack)); - })) + public static List getREIIngredients(ItemTagList list, UnaryOperator realStack) { + return list.getEntries().stream() + .map(ItemTagList.ItemTagEntry::stacks) + .map(stream -> toREIIngredient(stream, realStack)) .collect(Collectors.toList()); } - public static List getReiIngredients(ItemStack stack) { - return List.of(EntryStacks.of(stack)); + public static List getREIIngredients(ItemEntryList list, UnaryOperator realStack) { + if (list instanceof ItemTagList tagList) return getREIIngredients(tagList, realStack); + if (list instanceof ItemStackList stackList) return getREIIngredients(stackList, realStack); + return Collections.emptyList(); } } public static final class EMICallWrapper { - public static List getEmiIngredients(Stream stream, float xeiChance) { - return List.of(EmiIngredient.of(stream.map(EmiStack::of).toList()).setChance(xeiChance)); + private static EmiIngredient toEMIIngredient(Stream stream, UnaryOperator realStack) { + return EmiIngredient.of(stream.map(realStack).map(EmiStack::of).toList()); + } + + public static List getEMIIngredients(ItemStackList list, float xeiChance, + UnaryOperator realStack) { + return List.of(toEMIIngredient(list.stream(), realStack).setChance(xeiChance)); } - // ignore generics, repeat, ignore @ApiStatus.Experimental, ignore forge deprecations - @SuppressWarnings({ "unchecked", "rawtypes", "UnstableApiUsage", "deprecation" }) - public static List getEmiIngredients(List, Integer, @Nullable CompoundTag>> list, - float xeiChance) { - return list.stream() - .map(pair -> { - // slight trickery to get the NBT onto all the stacks in the tag. - EmiRegistryAdapter adapter = EmiTags.ADAPTERS_BY_REGISTRY.get(BuiltInRegistries.ITEM); - var stacks = BuiltInRegistries.ITEM.getTag(pair.getLeft()).stream() - .flatMap(HolderSet.ListBacked::stream) - .map(holder -> adapter.of(holder.value(), pair.getRight(), pair.getMiddle())) - .toList(); - return EmiIngredient.of(stacks).setAmount(pair.getMiddle()).setChance(xeiChance); - }) + public static List getEMIIngredients(ItemTagList list, float xeiChance, + UnaryOperator realStack) { + return list.getEntries().stream() + .map(ItemTagList.ItemTagEntry::stacks) + .map(stream -> toEMIIngredient(stream, realStack).setChance(xeiChance)) .collect(Collectors.toList()); } - public static List getEmiIngredients(ItemStack stack, float xeiChance) { - return List.of(EmiStack.of(stack).setChance(xeiChance)); + public static List getEMIIngredients(ItemEntryList list, float xeiChance, + UnaryOperator realStack) { + if (list instanceof ItemTagList tagList) return getEMIIngredients(tagList, xeiChance, realStack); + if (list instanceof ItemStackList stackList) return getEMIIngredients(stackList, xeiChance, realStack); + return Collections.emptyList(); } } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java index 31fb27e279..bce4073313 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java @@ -1,9 +1,12 @@ package com.gregtechceu.gtceu.api.gui.widget; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; -import com.gregtechceu.gtceu.api.transfer.fluid.CycleFluidHandler; -import com.gregtechceu.gtceu.api.transfer.fluid.TagOrCycleFluidHandler; import com.gregtechceu.gtceu.client.TooltipsHandler; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidEntryList; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidStackList; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidTagList; +import com.gregtechceu.gtceu.integration.xei.handlers.fluid.CycleFluidEntryHandler; +import com.gregtechceu.gtceu.integration.xei.handlers.fluid.CycleFluidStackHandler; import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.gui.editor.annotation.Configurable; @@ -28,18 +31,14 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.core.HolderSet; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; -import net.minecraft.tags.TagKey; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -51,19 +50,14 @@ import net.minecraftforge.fluids.capability.templates.FluidTank; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.datafixers.util.Either; +import dev.emi.emi.api.forge.ForgeEmiStack; import dev.emi.emi.api.stack.EmiIngredient; -import dev.emi.emi.api.stack.EmiRegistryAdapter; -import dev.emi.emi.api.stack.EmiStack; -import dev.emi.emi.registry.EmiTags; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import me.shedaniel.rei.api.common.entry.EntryIngredient; -import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; import mezz.jei.api.helpers.IPlatformFluidHelper; -import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -203,22 +197,18 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { if (self().isMouseOverElement(mouseX, mouseY)) { if (lastFluidInTank == null || lastFluidInTank.isEmpty()) return null; - if (this.fluidTank instanceof CycleFluidHandler cycleFluidHandler) { - return getXEIIngredientsFromCycleHandlerClickable(cycleFluidHandler, tank).get(0); - } else if (this.fluidTank instanceof TagOrCycleFluidHandler tagOrCycleFluidHandler) { - return getXEIIngredientsFromTagOrCycleHandlerClickable(tagOrCycleFluidHandler, tank).get(0); + if (fluidTank instanceof CycleFluidStackHandler stackHandler) { + return getXEIIngredientsClickable(stackHandler, tank).get(0); + } else if (fluidTank instanceof CycleFluidEntryHandler entryHandler) { + return getXEIIngredientsClickable(entryHandler, tank).get(0); } if (LDLib.isJeiLoaded()) { - return JEICallWrapper.getPlatformFluidTypeForJEIClickable(lastFluidInTank, getPosition(), getSize()); - } - if (LDLib.isReiLoaded()) { - return EntryStacks.of(dev.architectury.fluid.FluidStack.create(lastFluidInTank.getFluid(), - lastFluidInTank.getAmount(), lastFluidInTank.getTag())); - } - if (LDLib.isEmiLoaded()) { - return EmiStack.of(lastFluidInTank.getFluid(), lastFluidInTank.getTag(), lastFluidInTank.getAmount()) - .setChance(XEIChance); + return JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize()); + } else if (LDLib.isReiLoaded()) { + return EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank)); + } else if (LDLib.isEmiLoaded()) { + return ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance); } } return null; @@ -228,132 +218,68 @@ public Object getXEIIngredientOverMouse(double mouseX, double mouseY) { public List getXEIIngredients() { if (lastFluidInTank == null || lastFluidInTank.isEmpty()) return Collections.emptyList(); - if (this.fluidTank instanceof CycleFluidHandler cycleFluidHandler) { - return getXEIIngredientsFromCycleHandlerClickable(cycleFluidHandler, tank); - } else if (this.fluidTank instanceof TagOrCycleFluidHandler tagOrCycleFluidHandler) { - return getXEIIngredientsFromTagOrCycleHandlerClickable(tagOrCycleFluidHandler, tank); + if (fluidTank instanceof CycleFluidStackHandler stackHandler) { + return getXEIIngredientsClickable(stackHandler, tank); + } else if (fluidTank instanceof CycleFluidEntryHandler entryHandler) { + return getXEIIngredientsClickable(entryHandler, tank); } if (LDLib.isJeiLoaded()) { - return List - .of(JEICallWrapper.getPlatformFluidTypeForJEIClickable(lastFluidInTank, getPosition(), getSize())); - } - if (LDLib.isReiLoaded()) { - return List.of(EntryStacks.of(dev.architectury.fluid.FluidStack.create(lastFluidInTank.getFluid(), - lastFluidInTank.getAmount(), lastFluidInTank.getTag()))); - } - if (LDLib.isEmiLoaded()) { - return List - .of(EmiStack.of(lastFluidInTank.getFluid(), lastFluidInTank.getTag(), lastFluidInTank.getAmount()) - .setChance(XEIChance)); + return List.of(JEICallWrapper.getJEIFluidClickable(lastFluidInTank, getPosition(), getSize())); + } else if (LDLib.isReiLoaded()) { + return List.of(EntryStacks.of(REICallWrapper.toREIStack(lastFluidInTank))); + } else if (LDLib.isEmiLoaded()) { + return List.of(ForgeEmiStack.of(lastFluidInTank).setChance(XEIChance)); } return List.of(lastFluidInTank); } - private List getXEIIngredientsFromCycleHandler(CycleFluidHandler handler, int index) { - var stream = handler.getStackList(index).stream(); + private List getXEIIngredients(CycleFluidStackHandler handler, int index) { + FluidStackList stackList = handler.getStackList(index); if (LDLib.isJeiLoaded()) { - return stream.filter(fluid -> !fluid.isEmpty()).map(JEICallWrapper::getPlatformFluidTypeForJEI).toList(); + return JEICallWrapper.getJEIIngredients(stackList); } else if (LDLib.isReiLoaded()) { - return REICallWrapper.getReiIngredients(stream); + return REICallWrapper.getREIIngredients(stackList); } else if (LDLib.isEmiLoaded()) { - return EMICallWrapper.getEmiIngredients(stream, getXEIChance()); + return EMICallWrapper.getEMIIngredients(stackList, getXEIChance()); } return Collections.emptyList(); } - private List getXEIIngredientsFromCycleHandlerClickable(CycleFluidHandler handler, int index) { - var stream = handler.getStackList(index).stream(); + private List getXEIIngredientsClickable(CycleFluidStackHandler handler, int index) { + FluidStackList stackList = handler.getStackList(index); if (LDLib.isJeiLoaded()) { - return stream - .filter(fluid -> !fluid.isEmpty()) - .map(fluid -> JEICallWrapper.getPlatformFluidTypeForJEIClickable(fluid, getPosition(), getSize())) - .toList(); + return JEICallWrapper.getJEIIngredientsClickable(stackList, getPosition(), getSize()); } else if (LDLib.isReiLoaded()) { - return REICallWrapper.getReiIngredients(stream); + return REICallWrapper.getREIIngredients(stackList); } else if (LDLib.isEmiLoaded()) { - return EMICallWrapper.getEmiIngredients(stream, getXEIChance()); + return EMICallWrapper.getEMIIngredients(stackList, getXEIChance()); } return Collections.emptyList(); } - private List getXEIIngredientsFromTagOrCycleHandler(TagOrCycleFluidHandler handler, int index) { - Either, Integer, @Nullable CompoundTag>>, List> either = handler - .getStacks() - .get(index); - var ref = new Object() { - - List returnValue = Collections.emptyList(); - }; - either.ifLeft(list -> { - if (LDLib.isJeiLoaded()) { - ref.returnValue = list.stream() - .flatMap(pair -> BuiltInRegistries.FLUID - .getTag(pair.getLeft()) - .stream() - .flatMap(HolderSet.ListBacked::stream) - .map(fluid -> new FluidStack(fluid.value(), pair.getMiddle(), pair.getRight())) - .map(JEICallWrapper::getPlatformFluidTypeForJEI)) - .collect(Collectors.toList()); - } else if (LDLib.isReiLoaded()) { - ref.returnValue = REICallWrapper.getReiIngredients(list); - } else if (LDLib.isEmiLoaded()) { - ref.returnValue = EMICallWrapper.getEmiIngredients(list, getXEIChance()); - } - }).ifRight(fluids -> { - var stream = fluids.stream(); - if (LDLib.isJeiLoaded()) { - ref.returnValue = stream.filter(fluid -> !fluid.isEmpty()) - .map(JEICallWrapper::getPlatformFluidTypeForJEI) - .toList(); - } else if (LDLib.isReiLoaded()) { - ref.returnValue = REICallWrapper.getReiIngredients(stream); - } else if (LDLib.isEmiLoaded()) { - ref.returnValue = EMICallWrapper.getEmiIngredients(stream, getXEIChance()); - } - }); - return ref.returnValue; + private List getXEIIngredients(CycleFluidEntryHandler handler, int index) { + FluidEntryList entryList = handler.getEntry(index); + if (LDLib.isJeiLoaded()) { + return JEICallWrapper.getJEIIngredients(entryList); + } else if (LDLib.isReiLoaded()) { + return REICallWrapper.getREIIngredients(entryList); + } else if (LDLib.isEmiLoaded()) { + return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); + } + return Collections.emptyList(); } - private List getXEIIngredientsFromTagOrCycleHandlerClickable(TagOrCycleFluidHandler handler, int index) { - Either, Integer, @Nullable CompoundTag>>, List> either = handler - .getStacks() - .get(index); - var ref = new Object() { - - List returnValue = Collections.emptyList(); - }; - either.ifLeft(list -> { - if (LDLib.isJeiLoaded()) { - ref.returnValue = list.stream() - .flatMap(pair -> BuiltInRegistries.FLUID - .getTag(pair.getLeft()) - .stream() - .flatMap(HolderSet.ListBacked::stream) - .map(fluid -> new FluidStack(fluid.value(), pair.getMiddle(), pair.getRight())) - .map(fluidStack -> JEICallWrapper.getPlatformFluidTypeForJEIClickable( - fluidStack, getPosition(), getSize()))) - .collect(Collectors.toList()); - } else if (LDLib.isReiLoaded()) { - ref.returnValue = REICallWrapper.getReiIngredients(list); - } else if (LDLib.isEmiLoaded()) { - ref.returnValue = EMICallWrapper.getEmiIngredients(list, getXEIChance()); - } - }).ifRight(fluids -> { - var stream = fluids.stream(); - if (LDLib.isJeiLoaded()) { - ref.returnValue = stream - .filter(fluid -> !fluid.isEmpty()) - .map(fluid -> JEICallWrapper.getPlatformFluidTypeForJEIClickable(fluid, getPosition(), - getSize())) - .toList(); - } else if (LDLib.isReiLoaded()) { - ref.returnValue = REICallWrapper.getReiIngredients(stream); - } else if (LDLib.isEmiLoaded()) { - ref.returnValue = EMICallWrapper.getEmiIngredients(stream, getXEIChance()); - } - }); - return ref.returnValue; + private List getXEIIngredientsClickable(CycleFluidEntryHandler handler, int index) { + FluidEntryList entryList = handler.getEntry(index); + if (LDLib.isJeiLoaded()) { + return JEICallWrapper.getJEIIngredientsClickable(entryList, getPosition(), getSize()); + } else if (LDLib.isReiLoaded()) { + return REICallWrapper.getREIIngredients(entryList); + } else if (LDLib.isEmiLoaded()) { + return EMICallWrapper.getEMIIngredients(entryList, getXEIChance()); + } + return Collections.emptyList(); } @Override @@ -706,21 +632,37 @@ public void updateScreen() { */ public static final class JEICallWrapper { - public static Object getPlatformFluidTypeForJEI(FluidStack fluidStack) { - return _getPlatformFluidTypeForJEI(JEIPlugin.jeiHelpers.getPlatformFluidHelper(), fluidStack); + public static List getJEIIngredients(FluidEntryList list) { + return list.getStacks() + .stream() + .filter(stack -> !stack.isEmpty()) + .map(JEICallWrapper::getJEIFluid) + .toList(); } - private static Object _getPlatformFluidTypeForJEI(IPlatformFluidHelper helper, FluidStack fluidStack) { + public static List getJEIIngredientsClickable(FluidEntryList list, Position pos, Size size) { + return list.getStacks() + .stream() + .filter(stack -> !stack.isEmpty()) + .map(stack -> getJEIFluidClickable(stack, pos, size)) + .toList(); + } + + public static Object getJEIFluid(FluidStack fluidStack) { + return _getJEIFluid(JEIPlugin.jeiHelpers.getPlatformFluidHelper(), fluidStack); + } + + private static Object _getJEIFluid(IPlatformFluidHelper helper, FluidStack fluidStack) { return helper.create(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); } - public static Object getPlatformFluidTypeForJEIClickable(FluidStack fluidStack, Position pos, Size size) { - return _getPlatformFluidTypeForJEIClickable(JEIPlugin.jeiHelpers.getPlatformFluidHelper(), fluidStack, pos, + public static Object getJEIFluidClickable(FluidStack fluidStack, Position pos, Size size) { + return _getJEIFluidClickable(JEIPlugin.jeiHelpers.getPlatformFluidHelper(), fluidStack, pos, size); } - private static Object _getPlatformFluidTypeForJEIClickable(IPlatformFluidHelper helper, - FluidStack fluidStack, Position pos, Size size) { + private static Object _getJEIFluidClickable(IPlatformFluidHelper helper, + FluidStack fluidStack, Position pos, Size size) { T ingredient = helper.create(fluidStack.getFluid(), fluidStack.getAmount(), fluidStack.getTag()); return JEIPlugin.jeiHelpers.getIngredientManager().createTypedIngredient(ingredient) .map(typedIngredient -> new ClickableIngredient<>(typedIngredient, pos.x, pos.y, size.width, @@ -731,46 +673,56 @@ private static Object _getPlatformFluidTypeForJEIClickable(IPlatformFluidHel public static final class REICallWrapper { - public static List getReiIngredients(Stream stream) { - return List.of(EntryIngredient.of(stream - .map(fluidStack -> dev.architectury.fluid.FluidStack.create(fluidStack.getFluid(), - fluidStack.getAmount(), fluidStack.getTag())) + public static dev.architectury.fluid.FluidStack toREIStack(FluidStack stack) { + return dev.architectury.fluid.FluidStack.create(stack.getFluid(), stack.getAmount(), stack.getTag()); + } + + private static EntryIngredient toREIIngredient(Stream stream) { + return EntryIngredient.of(stream + .map(REICallWrapper::toREIStack) .map(EntryStacks::of) - .toList())); + .toList()); } - public static List getReiIngredients(List, Integer, @Nullable CompoundTag>> list) { - return list.stream() - .map(pair -> EntryIngredients.ofTag(pair.getLeft(), - holder -> EntryStacks - .of(dev.architectury.fluid.FluidStack.create(holder.value(), pair.getMiddle(), - pair.getRight())))) + public static List getREIIngredients(FluidStackList list) { + return List.of(toREIIngredient(list.stream())); + } + + public static List getREIIngredients(FluidTagList list) { + return list.getEntries().stream() + .map(FluidTagList.FluidTagEntry::stacks) + .map(REICallWrapper::toREIIngredient) .collect(Collectors.toList()); } + + public static List getREIIngredients(FluidEntryList list) { + if (list instanceof FluidTagList tagList) return getREIIngredients(tagList); + if (list instanceof FluidStackList stackList) return getREIIngredients(stackList); + return Collections.emptyList(); + } } public static final class EMICallWrapper { - public static List getEmiIngredients(Stream stream, float xeiChance) { - return List.of(EmiIngredient.of(stream.map(fluidStack -> EmiStack.of(fluidStack.getFluid(), - fluidStack.getTag(), fluidStack.getAmount())).toList()).setChance(xeiChance)); - } - - // ignore generics, repeat, ignore @ApiStatus.Experimental, ignore forge deprecations - @SuppressWarnings({ "unchecked", "rawtypes", "UnstableApiUsage", "deprecation" }) - public static List getEmiIngredients(List, Integer, @Nullable CompoundTag>> list, - float xeiChance) { - return list.stream() - .map(pair -> { - // slight trickery to get the NBT onto all the stacks in the tag. - EmiRegistryAdapter adapter = EmiTags.ADAPTERS_BY_REGISTRY.get(BuiltInRegistries.FLUID); - var stacks = BuiltInRegistries.FLUID.getTag(pair.getLeft()).stream() - .flatMap(HolderSet.ListBacked::stream) - .map(holder -> adapter.of(holder.value(), pair.getRight(), pair.getMiddle())) - .toList(); - return EmiIngredient.of(stacks).setAmount(pair.getMiddle()).setChance(xeiChance); - }) + private static EmiIngredient toEMIIngredient(Stream stream) { + return EmiIngredient.of(stream.map(ForgeEmiStack::of).toList()); + } + + public static List getEMIIngredients(FluidStackList list, float xeiChance) { + return List.of(toEMIIngredient(list.stream()).setChance(xeiChance)); + } + + public static List getEMIIngredients(FluidTagList list, float xeiChance) { + return list.getEntries().stream() + .map(FluidTagList.FluidTagEntry::stacks) + .map(stream -> toEMIIngredient(stream).setChance(xeiChance)) .collect(Collectors.toList()); } + + public static List getEMIIngredients(FluidEntryList list, float xeiChance) { + if (list instanceof FluidTagList tagList) return getEMIIngredients(tagList, xeiChance); + if (list instanceof FluidStackList stackList) return getEMIIngredients(stackList, xeiChance); + return Collections.emptyList(); + } } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/TagOrCycleFluidHandler.java b/src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/TagOrCycleFluidHandler.java deleted file mode 100644 index 3828712a1b..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/TagOrCycleFluidHandler.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.gregtechceu.gtceu.api.transfer.fluid; - -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.tags.TagKey; -import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import com.mojang.datafixers.util.Either; -import lombok.Getter; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class TagOrCycleFluidHandler implements IFluidHandlerModifiable { - - @Getter - private List, Integer, @Nullable CompoundTag>>, List>> stacks; - - private List> unwrapped = null; - - public TagOrCycleFluidHandler(List, Integer, @Nullable CompoundTag>>, List>> stacks) { - updateStacks(stacks); - } - - public void updateStacks(List, Integer, @Nullable CompoundTag>>, List>> stacks) { - this.stacks = new ArrayList<>(stacks); - this.unwrapped = null; - } - - public List> getUnwrapped() { - if (unwrapped == null) { - unwrapped = stacks.stream() - .map(tagOrFluid -> { - if (tagOrFluid == null) { - return null; - } - return tagOrFluid.map( - tagList -> tagList - .stream() - .flatMap(pair -> BuiltInRegistries.FLUID.getTag(pair.getLeft()) - .map(holderSet -> holderSet.stream() - .map(holder -> new FluidStack(holder.value(), - pair.getMiddle(), pair.getRight()))) - .orElseGet(Stream::empty)) - .toList(), - Function.identity()); - }) - .collect(Collectors.toList()); - } - return unwrapped; - } - - @Override - public int getTanks() { - return stacks.size(); - } - - @NotNull - @Override - public FluidStack getFluidInTank(int tank) { - List stackList = getUnwrapped().get(tank); - return stackList == null || stackList.isEmpty() ? FluidStack.EMPTY : - stackList.get(Math.abs((int) (System.currentTimeMillis() / 1000) % stackList.size())); - } - - @Override - public void setFluidInTank(int tank, @NotNull FluidStack fluidStack) { - if (tank >= 0 && tank < stacks.size()) { - stacks.set(tank, Either.right(List.of(fluidStack))); - unwrapped = null; - } - } - - @Override - public int getTankCapacity(int tank) { - return getFluidInTank(tank).getAmount(); - } - - @Override - public boolean isFluidValid(int tank, @NotNull FluidStack stack) { - return true; - } - - @Override - public int fill(FluidStack resource, FluidAction action) { - return 0; - } - - @Override - public boolean supportsFill(int tank) { - return false; - } - - @NotNull - @Override - public FluidStack drain(FluidStack resource, FluidAction action) { - return FluidStack.EMPTY; - } - - @Override - public @NotNull FluidStack drain(int maxDrain, FluidAction action) { - return FluidStack.EMPTY; - } - - @Override - public boolean supportsDrain(int tank) { - return false; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/transfer/item/TagOrCycleItemStackHandler.java b/src/main/java/com/gregtechceu/gtceu/api/transfer/item/TagOrCycleItemStackHandler.java deleted file mode 100644 index 3aeb6bb31b..0000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/transfer/item/TagOrCycleItemStackHandler.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.gregtechceu.gtceu.api.transfer.item; - -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.items.IItemHandlerModifiable; - -import com.mojang.datafixers.util.Either; -import lombok.Getter; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class TagOrCycleItemStackHandler implements IItemHandlerModifiable { - - @Getter - private List, Integer, @Nullable CompoundTag>>, List>> stacks; - - private List> unwrapped = null; - - public TagOrCycleItemStackHandler(List, Integer, @Nullable CompoundTag>>, List>> stacks) { - updateStacks(stacks); - } - - public void updateStacks(List, Integer, @Nullable CompoundTag>>, List>> stacks) { - this.stacks = new ArrayList<>(stacks); - this.unwrapped = null; - } - - public List> getUnwrapped() { - if (unwrapped == null) { - unwrapped = stacks.stream() - .map(tagOrItem -> { - if (tagOrItem == null) { - return null; - } - return tagOrItem.map( - tagList -> tagList - .stream() - .flatMap(pair -> BuiltInRegistries.ITEM.getTag(pair.getLeft()) - .map(holderSet -> holderSet.stream() - .map(holder -> { - ItemStack stack = new ItemStack(holder.value(), - pair.getMiddle()); - stack.setTag(pair.getRight()); - return stack; - })) - .orElseGet(Stream::empty)) - .toList(), - Function.identity()); - }) - .collect(Collectors.toCollection(ArrayList::new)); - } - return unwrapped; - } - - @Override - public int getSlots() { - return stacks.size(); - } - - @NotNull - @Override - public ItemStack getStackInSlot(int slot) { - List stackList = getUnwrapped().get(slot); - return stackList == null || stackList.isEmpty() ? ItemStack.EMPTY : - stackList.get(Math.abs((int) (System.currentTimeMillis() / 1000) % stackList.size())); - } - - @Override - public void setStackInSlot(int index, ItemStack stack) { - if (index >= 0 && index < stacks.size()) { - stacks.set(index, Either.right(List.of(stack))); - unwrapped = null; - } - } - - @NotNull - @Override - public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { - return stack; - } - - @NotNull - @Override - public ItemStack extractItem(int slot, int amount, boolean simulate) { - return ItemStack.EMPTY; - } - - @Override - public int getSlotLimit(int slot) { - return Integer.MAX_VALUE; - } - - @Override - public boolean isItemValid(int slot, @NotNull ItemStack stack) { - return true; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java index e7b400cbb9..723ea2a78c 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java @@ -6,7 +6,7 @@ import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; -import com.gregtechceu.gtceu.api.transfer.item.CycleItemStackHandler; +import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemStackHandler; import com.gregtechceu.gtceu.utils.FormattingUtil; import com.lowdragmc.lowdraglib.utils.LocalizationUtils; diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index 3565f2a70b..49733e5382 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -18,7 +18,6 @@ import com.gregtechceu.gtceu.api.sound.ExistingSoundEntry; import com.gregtechceu.gtceu.api.transfer.fluid.CustomFluidTank; import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler; -import com.gregtechceu.gtceu.api.transfer.item.CycleItemStackHandler; import com.gregtechceu.gtceu.common.machine.multiblock.electric.FusionReactorMachine; import com.gregtechceu.gtceu.common.machine.trait.customlogic.BreweryLogic; import com.gregtechceu.gtceu.common.machine.trait.customlogic.CannerLogic; @@ -28,6 +27,7 @@ import com.gregtechceu.gtceu.data.recipe.RecipeHelper; import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; +import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemStackHandler; import com.gregtechceu.gtceu.utils.FormattingUtil; import com.gregtechceu.gtceu.utils.ResearchManager; diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidEntryList.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidEntryList.java new file mode 100644 index 0000000000..a010139668 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidEntryList.java @@ -0,0 +1,12 @@ +package com.gregtechceu.gtceu.integration.xei.entry.fluid; + +import net.minecraftforge.fluids.FluidStack; + +import java.util.List; + +public sealed interface FluidEntryList permits FluidStackList, FluidTagList { + + List getStacks(); + + boolean isEmpty(); +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidStackList.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidStackList.java new file mode 100644 index 0000000000..c24e5ecb76 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidStackList.java @@ -0,0 +1,51 @@ +package com.gregtechceu.gtceu.integration.xei.entry.fluid; + +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; + +public final class FluidStackList implements FluidEntryList { + + private final List stacks; + + public FluidStackList() { + this.stacks = new ArrayList<>(); + } + + public static FluidStackList of(FluidStack stack) { + var list = new FluidStackList(); + list.add(stack); + return list; + } + + public static FluidStackList of(Collection coll) { + var list = new FluidStackList(); + list.addAll(coll); + return list; + } + + public void add(FluidStack stack) { + stacks.add(stack); + } + + public void addAll(Collection list) { + stacks.addAll(list); + } + + @Override + public boolean isEmpty() { + return stacks.isEmpty(); + } + + @Override + public List getStacks() { + return stacks; + } + + public Stream stream() { + return stacks.stream(); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidTagList.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidTagList.java new file mode 100644 index 0000000000..032eead252 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/fluid/FluidTagList.java @@ -0,0 +1,56 @@ +package com.gregtechceu.gtceu.integration.xei.entry.fluid; + +import net.minecraft.core.HolderSet; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.material.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import lombok.Getter; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +public final class FluidTagList implements FluidEntryList { + + @Getter + private final List entries = new ArrayList<>(); + + public static FluidTagList of(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { + var list = new FluidTagList(); + list.add(tag, amount, nbt); + return list; + } + + public void add(FluidTagEntry entry) { + entries.add(entry); + } + + public void add(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { + add(new FluidTagEntry(tag, amount, nbt)); + } + + @Override + public boolean isEmpty() { + return entries.isEmpty(); + } + + @Override + public List getStacks() { + return entries.stream() + .flatMap(FluidTagEntry::stacks) + .toList(); + } + + public record FluidTagEntry(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { + + public Stream stacks() { + return BuiltInRegistries.FLUID.getTag(tag).map(HolderSet.ListBacked::stream).orElseGet(Stream::empty) + .map(holder -> new FluidStack(holder.get(), amount, nbt)); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemEntryList.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemEntryList.java new file mode 100644 index 0000000000..7b4f8f9883 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemEntryList.java @@ -0,0 +1,12 @@ +package com.gregtechceu.gtceu.integration.xei.entry.item; + +import net.minecraft.world.item.ItemStack; + +import java.util.List; + +public sealed interface ItemEntryList permits ItemStackList, ItemTagList { + + List getStacks(); + + boolean isEmpty(); +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemStackList.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemStackList.java new file mode 100644 index 0000000000..f6d336f979 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemStackList.java @@ -0,0 +1,55 @@ +package com.gregtechceu.gtceu.integration.xei.entry.item; + +import net.minecraft.world.item.ItemStack; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; + +public final class ItemStackList implements ItemEntryList { + + private final List stacks; + + public ItemStackList() { + this.stacks = new ArrayList<>(); + } + + public ItemStackList(List list) { + this.stacks = new ArrayList<>(list); + } + + public static ItemStackList of(ItemStack stack) { + var list = new ItemStackList(); + list.add(stack); + return list; + } + + public static ItemStackList of(Collection coll) { + var list = new ItemStackList(); + list.addAll(coll); + return list; + } + + public void add(ItemStack stack) { + stacks.add(stack); + } + + public void addAll(Collection list) { + stacks.addAll(list); + } + + @Override + public boolean isEmpty() { + return stacks.isEmpty(); + } + + @Override + public List getStacks() { + return stacks; + } + + public Stream stream() { + return stacks.stream(); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemTagList.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemTagList.java new file mode 100644 index 0000000000..881c0dd3ab --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/entry/item/ItemTagList.java @@ -0,0 +1,63 @@ +package com.gregtechceu.gtceu.integration.xei.entry.item; + +import net.minecraft.core.Holder; +import net.minecraft.core.HolderSet; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +import lombok.Getter; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +public final class ItemTagList implements ItemEntryList { + + @Getter + private final List entries = new ArrayList<>(); + + public static ItemTagList of(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { + var list = new ItemTagList(); + list.add(tag, amount, nbt); + return list; + } + + public void add(ItemTagEntry entry) { + entries.add(entry); + } + + public void add(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { + add(new ItemTagEntry(tag, amount, nbt)); + } + + @Override + public boolean isEmpty() { + return entries.isEmpty(); + } + + @Override + public List getStacks() { + return entries.stream() + .flatMap(ItemTagEntry::stacks) + .toList(); + } + + public record ItemTagEntry(@NotNull TagKey tag, int amount, @Nullable CompoundTag nbt) { + + public Stream stacks() { + return BuiltInRegistries.ITEM.getTag(tag).map(HolderSet.ListBacked::stream).orElseGet(Stream::empty) + .map(holder -> stackWithTag(holder, amount, nbt)); + } + } + + private static ItemStack stackWithTag(Holder holder, int amount, @Nullable CompoundTag nbt) { + ItemStack stack = new ItemStack(holder.value(), amount); + stack.setTag(nbt); + return stack; + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/fluid/CycleFluidEntryHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/fluid/CycleFluidEntryHandler.java new file mode 100644 index 0000000000..059f60ddc5 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/fluid/CycleFluidEntryHandler.java @@ -0,0 +1,101 @@ +package com.gregtechceu.gtceu.integration.xei.handlers.fluid; + +import com.gregtechceu.gtceu.api.transfer.fluid.IFluidHandlerModifiable; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidEntryList; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidStackList; + +import net.minecraftforge.fluids.FluidStack; + +import lombok.Getter; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class CycleFluidEntryHandler implements IFluidHandlerModifiable { + + @Getter + private final List entries; + + private List> unwrapped = null; + + public CycleFluidEntryHandler(List entries) { + this.entries = new ArrayList<>(entries); + } + + public List> getUnwrapped() { + if (unwrapped == null) { + unwrapped = entries.stream() + .map(CycleFluidEntryHandler::getStacksNullable) + .collect(Collectors.toCollection(ArrayList::new)); + } + return unwrapped; + } + + private static List getStacksNullable(FluidEntryList list) { + if (list == null) return null; + return list.getStacks(); + } + + public FluidEntryList getEntry(int index) { + return entries.get(index); + } + + @Override + public int getTanks() { + return entries.size(); + } + + @NotNull + @Override + public FluidStack getFluidInTank(int tank) { + List stackList = getUnwrapped().get(tank); + return stackList == null || stackList.isEmpty() ? FluidStack.EMPTY : + stackList.get(Math.abs((int) (System.currentTimeMillis() / 1000) % stackList.size())); + } + + @Override + public void setFluidInTank(int tank, @NotNull FluidStack fluidStack) { + if (tank >= 0 && tank < entries.size()) { + entries.set(tank, FluidStackList.of(fluidStack)); + unwrapped = null; + } + } + + @Override + public int getTankCapacity(int tank) { + return getFluidInTank(tank).getAmount(); + } + + @Override + public boolean isFluidValid(int tank, @NotNull FluidStack stack) { + return true; + } + + @Override + public int fill(FluidStack resource, FluidAction action) { + return 0; + } + + @Override + public boolean supportsFill(int tank) { + return false; + } + + @NotNull + @Override + public FluidStack drain(FluidStack resource, FluidAction action) { + return FluidStack.EMPTY; + } + + @Override + public @NotNull FluidStack drain(int maxDrain, FluidAction action) { + return FluidStack.EMPTY; + } + + @Override + public boolean supportsDrain(int tank) { + return false; + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/CycleFluidHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/fluid/CycleFluidStackHandler.java similarity index 66% rename from src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/CycleFluidHandler.java rename to src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/fluid/CycleFluidStackHandler.java index abb57b44ff..bb12e23cc9 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/transfer/fluid/CycleFluidHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/fluid/CycleFluidStackHandler.java @@ -1,21 +1,24 @@ -package com.gregtechceu.gtceu.api.transfer.fluid; +package com.gregtechceu.gtceu.integration.xei.handlers.fluid; + +import com.gregtechceu.gtceu.api.transfer.fluid.IFluidHandlerModifiable; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidStackList; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; import java.util.List; -public class CycleFluidHandler implements IFluidHandlerModifiable { - - private List> stacks; +public class CycleFluidStackHandler implements IFluidHandlerModifiable { - public CycleFluidHandler(List> stacks) { - this.updateStacks(stacks); - } + private final List stacks; - public void updateStacks(List> stacks) { - this.stacks = stacks; + public CycleFluidStackHandler(List> stacks) { + this.stacks = new ArrayList<>(); + for (var list : stacks) { + this.stacks.add(FluidStackList.of(list)); + } } @Override @@ -26,7 +29,7 @@ public int getTanks() { @NotNull @Override public FluidStack getFluidInTank(int tank) { - List stackList = this.stacks.get(tank); + List stackList = stacks.get(tank).getStacks(); return stackList != null && !stackList.isEmpty() ? stackList.get(Math.abs((int) (System.currentTimeMillis() / 1000L) % stackList.size())) : FluidStack.EMPTY; @@ -35,7 +38,7 @@ public FluidStack getFluidInTank(int tank) { @Override public void setFluidInTank(int tank, @NotNull FluidStack fluidStack) { if (tank >= 0 && tank < this.stacks.size()) { - this.stacks.set(tank, List.of(fluidStack)); + this.stacks.set(tank, FluidStackList.of(fluidStack)); } } @@ -75,7 +78,7 @@ public boolean supportsDrain(int tank) { return false; } - public List getStackList(int i) { + public FluidStackList getStackList(int i) { return this.stacks.get(i); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/item/CycleItemEntryHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/item/CycleItemEntryHandler.java new file mode 100644 index 0000000000..5dac3e5391 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/item/CycleItemEntryHandler.java @@ -0,0 +1,86 @@ +package com.gregtechceu.gtceu.integration.xei.handlers.item; + +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemEntryList; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemStackList; + +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.items.IItemHandlerModifiable; + +import lombok.Getter; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class CycleItemEntryHandler implements IItemHandlerModifiable { + + @Getter + private final List entries; + private List> unwrapped = null; + + public CycleItemEntryHandler(List entries) { + this.entries = new ArrayList<>(entries); + } + + public List> getUnwrapped() { + if (unwrapped == null) { + unwrapped = entries.stream() + .map(CycleItemEntryHandler::getStacksNullable) + .collect(Collectors.toCollection(ArrayList::new)); + } + return unwrapped; + } + + private static List getStacksNullable(ItemEntryList list) { + if (list == null) return null; + return list.getStacks(); + } + + public ItemEntryList getEntry(int index) { + return entries.get(index); + } + + @Override + public int getSlots() { + return entries.size(); + } + + @NotNull + @Override + public ItemStack getStackInSlot(int slot) { + List stackList = getUnwrapped().get(slot); + return stackList == null || stackList.isEmpty() ? ItemStack.EMPTY : + stackList.get(Math.abs((int) (System.currentTimeMillis() / 1000) % stackList.size())); + } + + @Override + public void setStackInSlot(int index, ItemStack stack) { + if (index >= 0 && index < entries.size()) { + entries.set(index, ItemStackList.of(stack)); + unwrapped = null; + } + } + + @NotNull + @Override + public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { + return stack; + } + + @NotNull + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) { + return ItemStack.EMPTY; + } + + @Override + public int getSlotLimit(int slot) { + return Integer.MAX_VALUE; + } + + @Override + public boolean isItemValid(int slot, @NotNull ItemStack stack) { + return true; + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/api/transfer/item/CycleItemStackHandler.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/item/CycleItemStackHandler.java similarity index 68% rename from src/main/java/com/gregtechceu/gtceu/api/transfer/item/CycleItemStackHandler.java rename to src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/item/CycleItemStackHandler.java index 1231cb2f04..755bbaa65f 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/transfer/item/CycleItemStackHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/handlers/item/CycleItemStackHandler.java @@ -1,24 +1,26 @@ -package com.gregtechceu.gtceu.api.transfer.item; +package com.gregtechceu.gtceu.integration.xei.handlers.item; + +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemStackList; import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandlerModifiable; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; import java.util.List; import javax.annotation.Nonnull; public class CycleItemStackHandler implements IItemHandlerModifiable { - private List> stacks; + private final List stacks; public CycleItemStackHandler(List> stacks) { - updateStacks(stacks); - } - - public void updateStacks(List> stacks) { - this.stacks = stacks; + this.stacks = new ArrayList<>(); + for (var list : stacks) { + this.stacks.add(ItemStackList.of(list)); + } } @Override @@ -29,19 +31,19 @@ public int getSlots() { @Nonnull @Override public ItemStack getStackInSlot(int i) { - List stackList = stacks.get(i); + List stackList = stacks.get(i).getStacks(); return stackList == null || stackList.isEmpty() ? ItemStack.EMPTY : stackList.get(Math.abs((int) (System.currentTimeMillis() / 1000) % stackList.size())); } @Override - public void setStackInSlot(int index, ItemStack stack) { + public void setStackInSlot(int index, @NotNull ItemStack stack) { if (index >= 0 && index < stacks.size()) { - stacks.set(index, List.of(stack)); + stacks.set(index, ItemStackList.of(stack)); } } - public List getStackList(int i) { + public ItemStackList getStackList(int i) { return stacks.get(i); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProduct.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProduct.java index 175ad93458..c8a2912a8c 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProduct.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProduct.java @@ -11,26 +11,24 @@ import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.common.data.GTMachines; import com.gregtechceu.gtceu.common.data.GTMaterials; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidEntryList; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidStackList; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidTagList; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemEntryList; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemStackList; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemTagList; import com.gregtechceu.gtceu.utils.FormattingUtil; import net.minecraft.core.NonNullList; -import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.fluids.FluidStack; import com.google.common.collect.ImmutableList; -import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Pair; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -50,9 +48,9 @@ public static void addOreByProductPrefix(TagPrefix orePrefix) { private static ImmutableList ALWAYS_MACHINES; private final Int2ObjectMap chances = new Int2ObjectOpenHashMap<>(); - protected final List, Integer, @Nullable CompoundTag>>, List>> itemInputs = new ArrayList<>(); + protected final List itemInputs = new ArrayList<>(); protected final NonNullList itemOutputs = NonNullList.create(); - protected final List, Integer, @Nullable CompoundTag>>, List>> fluidInputs = new ArrayList<>(); + protected final List fluidInputs = new ArrayList<>(); private boolean hasDirectSmelt = false; private boolean hasChemBath = false; private boolean hasSeparator = false; @@ -95,13 +93,13 @@ public GTOreByProduct(Material material) { Pair washedIn = property.getWashedIn(); List separatedInto = property.getSeparatedInto(); - List, Integer, @Nullable CompoundTag>> oreStacks = new ArrayList<>(); + ItemTagList oreStacks = new ItemTagList(); for (TagPrefix prefix : ORES) { // get all ores with the relevant oredicts instead of just the first unified ore - oreStacks.add(Triple.of(ChemicalHelper.getTag(prefix, material), 1, null)); + oreStacks.add(ChemicalHelper.getTag(prefix, material), 1, null); } - oreStacks.add(Triple.of(ChemicalHelper.getTag(TagPrefix.rawOre, material), 1, null)); - itemInputs.add(Either.left(oreStacks)); + oreStacks.add(ChemicalHelper.getTag(TagPrefix.rawOre, material), 1, null); + itemInputs.add(oreStacks); // set up machines as inputs List simpleWashers = new ArrayList<>(); @@ -119,9 +117,9 @@ public GTOreByProduct(Material material) { addToInputs(stack); } // same amount of lines as a for loop :trol: - itemInputs.add(Either.right(simpleWashers)); - itemInputs.add(Either.right(simpleWashers)); - itemInputs.add(Either.right(simpleWashers)); + itemInputs.add(ItemStackList.of(simpleWashers)); + itemInputs.add(ItemStackList.of(simpleWashers)); + itemInputs.add(ItemStackList.of(simpleWashers)); if (washedIn != null && washedIn.getFirst() != null) { hasChemBath = true; @@ -144,9 +142,7 @@ public GTOreByProduct(Material material) { // add prefixes that should count as inputs to input lists (they will not be displayed in actual page) for (TagPrefix prefix : IN_PROCESSING_STEPS) { - List, Integer, @Nullable CompoundTag>> tempList = new ArrayList<>(); - tempList.add(Triple.of(ChemicalHelper.getTag(prefix, material), 1, null)); - itemInputs.add(Either.left(tempList)); + itemInputs.add(ItemTagList.of(ChemicalHelper.getTag(prefix, material), 1, null)); } // total number of inputs added @@ -196,10 +192,10 @@ public GTOreByProduct(Material material) { addToOutputs(material, TagPrefix.crushedPurified, 1); addToOutputs(byproducts[0], TagPrefix.dust, 1); addChance(3333, 0); - List, Integer, @Nullable CompoundTag>> fluidStacks = new ArrayList<>(); - fluidStacks.add(Triple.of(GTMaterials.Water.getFluidTag(), 1000, null)); - fluidStacks.add(Triple.of(GTMaterials.DistilledWater.getFluidTag(), 100, null)); - fluidInputs.add(Either.left(fluidStacks)); + FluidTagList tagList = new FluidTagList(); + tagList.add(GTMaterials.Water.getFluidTag(), 1000, null); + tagList.add(GTMaterials.DistilledWater.getFluidTag(), 100, null); + fluidInputs.add(tagList); // TC crushed/crushed purified -> centrifuged addToOutputs(material, TagPrefix.crushedRefined, 1); @@ -236,14 +232,10 @@ public GTOreByProduct(Material material) { addToOutputs(material, TagPrefix.crushedPurified, 1); addToOutputs(byproducts[3], TagPrefix.dust, byproductMultiplier); addChance(7000, 580); - List, Integer, @Nullable CompoundTag>> washedFluid = new ArrayList<>(); - // noinspection DataFlowIssue - washedFluid.add(Triple.of(washedIn.getFirst().getFluidTag(), washedIn.getSecond(), null)); - fluidInputs.add(Either.left(washedFluid)); + fluidInputs.add(FluidTagList.of(washedIn.getFirst().getFluidTag(), washedIn.getSecond(), null)); } else { addEmptyOutputs(2); - List washedFluid = new ArrayList<>(); - fluidInputs.add(Either.right(washedFluid)); + fluidInputs.add(new FluidStackList()); } // electromagnetic separator @@ -342,9 +334,7 @@ private void addEmptyOutputs(int amount) { } private void addToInputs(ItemStack stack) { - List tempList = new ArrayList<>(); - tempList.add(stack); - itemInputs.add(Either.right(tempList)); + itemInputs.add(ItemStackList.of(stack)); } private void addChance(int base, int tier) { diff --git a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProductWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProductWidget.java index 3ac9ef8b36..0452e7399b 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProductWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/xei/widgets/GTOreByProductWidget.java @@ -6,9 +6,11 @@ import com.gregtechceu.gtceu.api.gui.widget.TankWidget; import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.api.transfer.fluid.CustomFluidTank; -import com.gregtechceu.gtceu.api.transfer.fluid.TagOrCycleFluidHandler; import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler; -import com.gregtechceu.gtceu.api.transfer.item.TagOrCycleItemStackHandler; +import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidEntryList; +import com.gregtechceu.gtceu.integration.xei.entry.item.ItemEntryList; +import com.gregtechceu.gtceu.integration.xei.handlers.fluid.CycleFluidEntryHandler; +import com.gregtechceu.gtceu.integration.xei.handlers.item.CycleItemEntryHandler; import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; import com.lowdragmc.lowdraglib.gui.widget.ImageWidget; @@ -16,21 +18,12 @@ import com.lowdragmc.lowdraglib.jei.IngredientIO; import net.minecraft.core.NonNullList; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.material.Fluid; -import net.minecraftforge.fluids.FluidStack; import com.google.common.collect.ImmutableList; -import com.mojang.datafixers.util.Either; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; -import java.util.function.Function; public class GTOreByProductWidget extends WidgetGroup { @@ -122,8 +115,8 @@ public void setRecipe(GTOreByProduct recipeWrapper) { addWidget(new ImageWidget(0, 0, 176, 166, GuiTextures.OREBY_SIFT)); } - List, Integer, @Nullable CompoundTag>>, List>> itemInputs = recipeWrapper.itemInputs; - TagOrCycleItemStackHandler itemInputsHandler = new TagOrCycleItemStackHandler(itemInputs); + List itemInputs = recipeWrapper.itemInputs; + CycleItemEntryHandler itemInputsHandler = new CycleItemEntryHandler(itemInputs); WidgetGroup itemStackGroup = new WidgetGroup(); for (int i = 0; i < ITEM_INPUT_LOCATIONS.size(); i += 2) { final int finalI = i; @@ -164,12 +157,12 @@ public void setRecipe(GTOreByProduct recipeWrapper) { itemOutputExists.add(true); } - List, Integer, @Nullable CompoundTag>>, List>> fluidInputs = recipeWrapper.fluidInputs; - TagOrCycleFluidHandler fluidInputsHandler = new TagOrCycleFluidHandler(fluidInputs); + List fluidInputs = recipeWrapper.fluidInputs; + CycleFluidEntryHandler fluidInputsHandler = new CycleFluidEntryHandler(fluidInputs); WidgetGroup fluidStackGroup = new WidgetGroup(); for (int i = 0; i < FLUID_LOCATIONS.size(); i += 2) { int slotIndex = i / 2; - if (!fluidInputs.get(slotIndex).map(Function.identity(), Function.identity()).isEmpty()) { + if (!fluidInputs.get(slotIndex).isEmpty()) { var tank = new TankWidget(new CustomFluidTank(fluidInputsHandler.getFluidInTank(slotIndex)), FLUID_LOCATIONS.get(i), FLUID_LOCATIONS.get(i + 1), false, false) .setIngredientIO(IngredientIO.INPUT) diff --git a/src/main/java/com/gregtechceu/gtceu/utils/ItemStackHashStrategy.java b/src/main/java/com/gregtechceu/gtceu/utils/ItemStackHashStrategy.java index cb084b321b..a8f8de1a72 100644 --- a/src/main/java/com/gregtechceu/gtceu/utils/ItemStackHashStrategy.java +++ b/src/main/java/com/gregtechceu/gtceu/utils/ItemStackHashStrategy.java @@ -44,6 +44,11 @@ static ItemStackHashStrategy comparingAllButCount() { .build(); } + static ItemStackHashStrategy comparingItem() { + return builder().compareItem(true) + .build(); + } + /** * Builder pattern class for generating customized ItemStackHashStrategy */ From dc255e25dc112cd604b97a52c2eed63a795d3b97 Mon Sep 17 00:00:00 2001 From: kross <135918757+krossgg@users.noreply.github.com> Date: Wed, 11 Dec 2024 22:30:07 -0500 Subject: [PATCH 3/4] Fix representative potion recipes & tooltips --- .../resources/assets/gtceu/lang/en_ud.json | 47 +++++++++++++++++++ .../resources/assets/gtceu/lang/en_us.json | 47 +++++++++++++++++++ .../gtceu/api/gui/widget/TankWidget.java | 18 ++----- .../gtceu/client/TooltipsHandler.java | 29 +++++++----- .../trait/customlogic/BreweryLogic.java | 11 ++--- .../trait/customlogic/FormingPressLogic.java | 4 +- 6 files changed, 120 insertions(+), 36 deletions(-) diff --git a/src/generated/resources/assets/gtceu/lang/en_ud.json b/src/generated/resources/assets/gtceu/lang/en_ud.json index 597b99ef36..5ece959791 100644 --- a/src/generated/resources/assets/gtceu/lang/en_ud.json +++ b/src/generated/resources/assets/gtceu/lang/en_ud.json @@ -218,6 +218,10 @@ "block.gtceu.ev_diode": "ǝpoıᗡ ΛƎϛ§", "block.gtceu.ev_distillery": "ɹ§III ʎɹǝןןıʇsıᗡ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_electric_furnace": "ɹ§III ǝɔɐuɹnℲ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", + "block.gtceu.ev_electric_gear_box_16a": "ɹ§III Ɐ9Ɩ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", + "block.gtceu.ev_electric_gear_box_2a": "ɹ§III Ɐᄅ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", + "block.gtceu.ev_electric_gear_box_32a": "ɹ§III ⱯᄅƐ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", + "block.gtceu.ev_electric_gear_box_8a": "ɹ§III Ɐ8 xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_electrolyzer": "ɹ§III ɹǝzʎןoɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_electromagnetic_separator": "ɹ§III ɹoʇɐɹɐdǝS ɔıʇǝubɐɯoɹʇɔǝןƎ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_energy_input_hatch": "ɥɔʇɐH ʎbɹǝuƎ ΛƎϛ§", @@ -244,6 +248,9 @@ "block.gtceu.ev_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛƎϛ§", "block.gtceu.ev_item_collector": "ɹ§III ɹoʇɔǝןןoƆ ɯǝʇI pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛƎϛ§", + "block.gtceu.ev_kinetic_input_box": "ɹ§III xoᗺ ʇnduI ɔıʇǝuıʞ pǝɔuɐʌpⱯϛ§", + "block.gtceu.ev_kinetic_mixer": "ɹ§III ɹǝxıW ɔıʇǝuıʞ pǝɔuɐʌpⱯϛ§", + "block.gtceu.ev_kinetic_output_box": "ɹ§III xoᗺ ʇndʇnO ɔıʇǝuıʞ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_lapotronic_battery": "ɹoʇıɔɐdɐƆ ɔıuoɹʇodɐꞀ ΛƎ", "block.gtceu.ev_large_miner": "ɹ§III ɹǝuıW ǝbɹɐꞀ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_laser_engraver": "ɹ§III ɹǝʌɐɹbuƎ ɹǝsɐꞀ pǝɔuɐʌpⱯϛ§", @@ -362,6 +369,10 @@ "block.gtceu.hv_diode": "ǝpoıᗡ ΛH9§", "block.gtceu.hv_distillery": "ɹ§II ʎɹǝןןıʇsıᗡ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_electric_furnace": "ɹ§II ǝɔɐuɹnℲ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", + "block.gtceu.hv_electric_gear_box_16a": "ɹ§II Ɐ9Ɩ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", + "block.gtceu.hv_electric_gear_box_2a": "ɹ§II Ɐᄅ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", + "block.gtceu.hv_electric_gear_box_32a": "ɹ§II ⱯᄅƐ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", + "block.gtceu.hv_electric_gear_box_8a": "ɹ§II Ɐ8 xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_electrolyzer": "ɹ§II ɹǝzʎןoɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_electromagnetic_separator": "ɹ§II ɹoʇɐɹɐdǝS ɔıʇǝubɐɯoɹʇɔǝןƎ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_energy_input_hatch": "ɥɔʇɐH ʎbɹǝuƎ ΛH9§", @@ -383,6 +394,9 @@ "block.gtceu.hv_input_hatch": "ɥɔʇɐH ʇnduI ΛH9§", "block.gtceu.hv_item_collector": "ɹ§II ɹoʇɔǝןןoƆ ɯǝʇI pǝɔuɐʌpⱯ9§", "block.gtceu.hv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛH9§", + "block.gtceu.hv_kinetic_input_box": "ɹ§II xoᗺ ʇnduI ɔıʇǝuıʞ pǝɔuɐʌpⱯ9§", + "block.gtceu.hv_kinetic_mixer": "ɹ§II ɹǝxıW ɔıʇǝuıʞ pǝɔuɐʌpⱯ9§", + "block.gtceu.hv_kinetic_output_box": "ɹ§II xoᗺ ʇndʇnO ɔıʇǝuıʞ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_laser_engraver": "ɹ§II ɹǝʌɐɹbuƎ ɹǝsɐꞀ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_lathe": "ɹ§II ǝɥʇɐꞀ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_macerator": "ɹ§II ɹoʇɐɹǝɔɐW pǝɔuɐʌpⱯ9§", @@ -470,6 +484,8 @@ "block.gtceu.iv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛI6§", "block.gtceu.iv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛI6§", "block.gtceu.iv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛI6§", + "block.gtceu.iv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ǝʇıןƎ6§", + "block.gtceu.iv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ǝʇıןƎ6§", "block.gtceu.iv_lapotronic_battery": "ɹoʇıɔɐdɐƆ ɔıuoɹʇodɐꞀ ΛI", "block.gtceu.iv_large_miner": "ɹ§ ɹǝuıW ǝbɹɐꞀ ǝʇıןƎ6§", "block.gtceu.iv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ǝʇıןƎ6§", @@ -634,6 +650,8 @@ "block.gtceu.luv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛnꞀp§", "block.gtceu.luv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛnꞀp§", "block.gtceu.luv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛnꞀp§", + "block.gtceu.luv_kinetic_input_box": "ɹ§II xoᗺ ʇnduI ɔıʇǝuıʞ ǝʇıןƎp§", + "block.gtceu.luv_kinetic_output_box": "ɹ§II xoᗺ ʇndʇnO ɔıʇǝuıʞ ǝʇıןƎp§", "block.gtceu.luv_lapotronic_battery": "ɹoʇıɔɐdɐƆ ɔıuoɹʇodɐꞀ ΛnꞀ", "block.gtceu.luv_large_miner": "ɹ§II ɹǝuıW ǝbɹɐꞀ ǝʇıןƎp§", "block.gtceu.luv_laser_engraver": "ɹ§II ɹǝʌɐɹbuƎ ɹǝsɐꞀ ǝʇıןƎp§", @@ -694,6 +712,10 @@ "block.gtceu.lv_diode": "ǝpoıᗡ ΛꞀㄥ§", "block.gtceu.lv_distillery": "ɹ§ ʎɹǝןןıʇsıᗡ ɔısɐᗺ", "block.gtceu.lv_electric_furnace": "ɹ§ ǝɔɐuɹnℲ ɔıɹʇɔǝןƎ ɔısɐᗺ", + "block.gtceu.lv_electric_gear_box_16a": "ɹ§ Ɐ9Ɩ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ ɔısɐᗺ", + "block.gtceu.lv_electric_gear_box_2a": "ɹ§ Ɐᄅ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ ɔısɐᗺ", + "block.gtceu.lv_electric_gear_box_32a": "ɹ§ ⱯᄅƐ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ ɔısɐᗺ", + "block.gtceu.lv_electric_gear_box_8a": "ɹ§ Ɐ8 xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ ɔısɐᗺ", "block.gtceu.lv_electrolyzer": "ɹ§ ɹǝzʎןoɹʇɔǝןƎ ɔısɐᗺ", "block.gtceu.lv_electromagnetic_separator": "ɹ§ ɹoʇɐɹɐdǝS ɔıʇǝubɐɯoɹʇɔǝןƎ ɔısɐᗺ", "block.gtceu.lv_energy_input_hatch": "ɥɔʇɐH ʎbɹǝuƎ ΛꞀㄥ§", @@ -714,6 +736,9 @@ "block.gtceu.lv_input_hatch": "ɥɔʇɐH ʇnduI ΛꞀㄥ§", "block.gtceu.lv_item_collector": "ɹ§ ɹoʇɔǝןןoƆ ɯǝʇI ɔısɐᗺ", "block.gtceu.lv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛꞀㄥ§", + "block.gtceu.lv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ɔısɐᗺ", + "block.gtceu.lv_kinetic_mixer": "ɹ§ ɹǝxıW ɔıʇǝuıʞ ɔısɐᗺ", + "block.gtceu.lv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ɔısɐᗺ", "block.gtceu.lv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ɔısɐᗺ", "block.gtceu.lv_lathe": "ɹ§ ǝɥʇɐꞀ ɔısɐᗺ", "block.gtceu.lv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW ɔısɐᗺ", @@ -836,6 +861,10 @@ "block.gtceu.mv_diode": "ǝpoıᗡ ΛWq§", "block.gtceu.mv_distillery": "ɹ§ ʎɹǝןןıʇsıᗡ pǝɔuɐʌpⱯq§", "block.gtceu.mv_electric_furnace": "ɹ§ ǝɔɐuɹnℲ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯq§", + "block.gtceu.mv_electric_gear_box_16a": "ɹ§ Ɐ9Ɩ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯq§", + "block.gtceu.mv_electric_gear_box_2a": "ɹ§ Ɐᄅ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯq§", + "block.gtceu.mv_electric_gear_box_32a": "ɹ§ ⱯᄅƐ xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯq§", + "block.gtceu.mv_electric_gear_box_8a": "ɹ§ Ɐ8 xoqɹɐǝ⅁ ɔıɹʇɔǝןƎ pǝɔuɐʌpⱯq§", "block.gtceu.mv_electrolyzer": "ɹ§ ɹǝzʎןoɹʇɔǝןƎ pǝɔuɐʌpⱯq§", "block.gtceu.mv_electromagnetic_separator": "ɹ§ ɹoʇɐɹɐdǝS ɔıʇǝubɐɯoɹʇɔǝןƎ pǝɔuɐʌpⱯq§", "block.gtceu.mv_energy_input_hatch": "ɥɔʇɐH ʎbɹǝuƎ ΛWq§", @@ -857,6 +886,9 @@ "block.gtceu.mv_input_hatch": "ɥɔʇɐH ʇnduI ΛWq§", "block.gtceu.mv_item_collector": "ɹ§ ɹoʇɔǝןןoƆ ɯǝʇI pǝɔuɐʌpⱯq§", "block.gtceu.mv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛWq§", + "block.gtceu.mv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ pǝɔuɐʌpⱯq§", + "block.gtceu.mv_kinetic_mixer": "ɹ§ ɹǝxıW ɔıʇǝuıʞ pǝɔuɐʌpⱯq§", + "block.gtceu.mv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ pǝɔuɐʌpⱯq§", "block.gtceu.mv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ pǝɔuɐʌpⱯq§", "block.gtceu.mv_lathe": "ɹ§ ǝɥʇɐꞀ pǝɔuɐʌpⱯq§", "block.gtceu.mv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW pǝɔuɐʌpⱯq§", @@ -952,6 +984,8 @@ "block.gtceu.opv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛdOן§6§", "block.gtceu.opv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛdOן§6§", "block.gtceu.opv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛdOן§6§", + "block.gtceu.opv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ʎɹɐpuǝbǝꞀן§6§", + "block.gtceu.opv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ʎɹɐpuǝbǝꞀן§6§", "block.gtceu.opv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ʎɹɐpuǝbǝꞀן§6§", "block.gtceu.opv_lathe": "ɹ§ ǝɥʇɐꞀ ʎɹɐpuǝbǝꞀן§6§", "block.gtceu.opv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW ʎɹɐpuǝbǝꞀן§6§", @@ -1196,6 +1230,8 @@ "block.gtceu.uev_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛƎ∩ɐ§", "block.gtceu.uev_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛƎ∩ɐ§", "block.gtceu.uev_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛƎ∩ɐ§", + "block.gtceu.uev_kinetic_input_box": "ɹ§II xoᗺ ʇnduI ɔıʇǝuıʞ ɔıdƎɐ§", + "block.gtceu.uev_kinetic_output_box": "ɹ§II xoᗺ ʇndʇnO ɔıʇǝuıʞ ɔıdƎɐ§", "block.gtceu.uev_laser_engraver": "ɹ§II ɹǝʌɐɹbuƎ ɹǝsɐꞀ ɔıdƎɐ§", "block.gtceu.uev_lathe": "ɹ§II ǝɥʇɐꞀ ɔıdƎɐ§", "block.gtceu.uev_macerator": "ɹ§II ɹoʇɐɹǝɔɐW ɔıdƎɐ§", @@ -1279,6 +1315,8 @@ "block.gtceu.uhv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛH∩ㄣ§", "block.gtceu.uhv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛH∩ㄣ§", "block.gtceu.uhv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛH∩ㄣ§", + "block.gtceu.uhv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ɔıdƎㄣ§", + "block.gtceu.uhv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ɔıdƎㄣ§", "block.gtceu.uhv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ɔıdƎㄣ§", "block.gtceu.uhv_lathe": "ɹ§ ǝɥʇɐꞀ ɔıdƎㄣ§", "block.gtceu.uhv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW ɔıdƎㄣ§", @@ -1362,6 +1400,8 @@ "block.gtceu.uiv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛI∩ᄅ§", "block.gtceu.uiv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛI∩ᄅ§", "block.gtceu.uiv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛI∩ᄅ§", + "block.gtceu.uiv_kinetic_input_box": "ɹ§III xoᗺ ʇnduI ɔıʇǝuıʞ ɔıdƎᄅ§", + "block.gtceu.uiv_kinetic_output_box": "ɹ§III xoᗺ ʇndʇnO ɔıʇǝuıʞ ɔıdƎᄅ§", "block.gtceu.uiv_laser_engraver": "ɹ§III ɹǝʌɐɹbuƎ ɹǝsɐꞀ ɔıdƎᄅ§", "block.gtceu.uiv_lathe": "ɹ§III ǝɥʇɐꞀ ɔıdƎᄅ§", "block.gtceu.uiv_macerator": "ɹ§III ɹoʇɐɹǝɔɐW ɔıdƎᄅ§", @@ -1466,6 +1506,8 @@ "block.gtceu.uv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ Λ∩Ɛ§", "block.gtceu.uv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN Λ∩Ɛ§", "block.gtceu.uv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI Λ∩Ɛ§", + "block.gtceu.uv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ǝʇɐɯıʇן∩Ɛ§", + "block.gtceu.uv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ǝʇɐɯıʇן∩Ɛ§", "block.gtceu.uv_lapotronic_battery": "ɹoʇıɔɐdɐƆ ɔıuoɹʇodɐꞀ Λ∩", "block.gtceu.uv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ǝʇɐɯıʇן∩Ɛ§", "block.gtceu.uv_lathe": "ɹ§ ǝɥʇɐꞀ ǝʇɐɯıʇן∩Ɛ§", @@ -1551,6 +1593,8 @@ "block.gtceu.uxv_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ ΛX∩ǝ§", "block.gtceu.uxv_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN ΛX∩ǝ§", "block.gtceu.uxv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛX∩ǝ§", + "block.gtceu.uxv_kinetic_input_box": "ɹ§ΛI xoᗺ ʇnduI ɔıʇǝuıʞ ɔıdƎǝ§", + "block.gtceu.uxv_kinetic_output_box": "ɹ§ΛI xoᗺ ʇndʇnO ɔıʇǝuıʞ ɔıdƎǝ§", "block.gtceu.uxv_laser_engraver": "ɹ§ΛI ɹǝʌɐɹbuƎ ɹǝsɐꞀ ɔıdƎǝ§", "block.gtceu.uxv_lathe": "ɹ§ΛI ǝɥʇɐꞀ ɔıdƎǝ§", "block.gtceu.uxv_macerator": "ɹ§ΛI ɹoʇɐɹǝɔɐW ɔıdƎǝ§", @@ -1669,6 +1713,8 @@ "block.gtceu.zpm_input_hatch_4x": "ɥɔʇɐH ʇnduI ǝןdnɹpɐnὉ WԀZɔ§", "block.gtceu.zpm_input_hatch_9x": "ɥɔʇɐH ʇnduI ǝןdnuoN WԀZɔ§", "block.gtceu.zpm_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI WԀZɔ§", + "block.gtceu.zpm_kinetic_input_box": "ɹ§III xoᗺ ʇnduI ɔıʇǝuıʞ ǝʇıןƎɔ§", + "block.gtceu.zpm_kinetic_output_box": "ɹ§III xoᗺ ʇndʇnO ɔıʇǝuıʞ ǝʇıןƎɔ§", "block.gtceu.zpm_lapotronic_battery": "ɹoʇıɔɐdɐƆ ɔıuoɹʇodɐꞀ WԀZ", "block.gtceu.zpm_laser_engraver": "ɹ§III ɹǝʌɐɹbuƎ ɹǝsɐꞀ ǝʇıןƎɔ§", "block.gtceu.zpm_lathe": "ɹ§III ǝɥʇɐꞀ ǝʇıןƎɔ§", @@ -2188,6 +2234,7 @@ "gtceu.cover.item_detector.message_item_storage_inverted": "ǝbɐɹoʇS ɯǝʇI pǝʇɹǝʌuI buıɹoʇıuoW", "gtceu.cover.item_detector.message_item_storage_normal": "ǝbɐɹoʇS ɯǝʇI ןɐɯɹoN buıɹoʇıuoW", "gtceu.cracker": "ɹǝʞɔɐɹƆ", + "gtceu.create_mixer": "ɹǝxıW ǝʇɐǝɹƆ", "gtceu.creative.activity.off": "ǝʌıʇɔɐ ʇoN", "gtceu.creative.activity.on": "ǝʌıʇɔⱯ", "gtceu.creative.chest.ipc": "ǝןɔʎƆ ɹǝd sɯǝʇI", diff --git a/src/generated/resources/assets/gtceu/lang/en_us.json b/src/generated/resources/assets/gtceu/lang/en_us.json index f29ee92ccc..1e0e1e2341 100644 --- a/src/generated/resources/assets/gtceu/lang/en_us.json +++ b/src/generated/resources/assets/gtceu/lang/en_us.json @@ -218,6 +218,10 @@ "block.gtceu.ev_diode": "§5EV Diode", "block.gtceu.ev_distillery": "§5Advanced Distillery III§r", "block.gtceu.ev_electric_furnace": "§5Advanced Electric Furnace III§r", + "block.gtceu.ev_electric_gear_box_16a": "§5Advanced Electric Gearbox 16A III§r", + "block.gtceu.ev_electric_gear_box_2a": "§5Advanced Electric Gearbox 2A III§r", + "block.gtceu.ev_electric_gear_box_32a": "§5Advanced Electric Gearbox 32A III§r", + "block.gtceu.ev_electric_gear_box_8a": "§5Advanced Electric Gearbox 8A III§r", "block.gtceu.ev_electrolyzer": "§5Advanced Electrolyzer III§r", "block.gtceu.ev_electromagnetic_separator": "§5Advanced Electromagnetic Separator III§r", "block.gtceu.ev_energy_input_hatch": "§5EV Energy Hatch", @@ -244,6 +248,9 @@ "block.gtceu.ev_input_hatch_9x": "§5EV Nonuple Input Hatch", "block.gtceu.ev_item_collector": "§5Advanced Item Collector III§r", "block.gtceu.ev_item_passthrough_hatch": "§5EV Item Passthrough Hatch", + "block.gtceu.ev_kinetic_input_box": "§5Advanced Kinetic Input Box III§r", + "block.gtceu.ev_kinetic_mixer": "§5Advanced Kinetic Mixer III§r", + "block.gtceu.ev_kinetic_output_box": "§5Advanced Kinetic Output Box III§r", "block.gtceu.ev_lapotronic_battery": "EV Lapotronic Capacitor", "block.gtceu.ev_large_miner": "§5Advanced Large Miner III§r", "block.gtceu.ev_laser_engraver": "§5Advanced Laser Engraver III§r", @@ -362,6 +369,10 @@ "block.gtceu.hv_diode": "§6HV Diode", "block.gtceu.hv_distillery": "§6Advanced Distillery II§r", "block.gtceu.hv_electric_furnace": "§6Advanced Electric Furnace II§r", + "block.gtceu.hv_electric_gear_box_16a": "§6Advanced Electric Gearbox 16A II§r", + "block.gtceu.hv_electric_gear_box_2a": "§6Advanced Electric Gearbox 2A II§r", + "block.gtceu.hv_electric_gear_box_32a": "§6Advanced Electric Gearbox 32A II§r", + "block.gtceu.hv_electric_gear_box_8a": "§6Advanced Electric Gearbox 8A II§r", "block.gtceu.hv_electrolyzer": "§6Advanced Electrolyzer II§r", "block.gtceu.hv_electromagnetic_separator": "§6Advanced Electromagnetic Separator II§r", "block.gtceu.hv_energy_input_hatch": "§6HV Energy Hatch", @@ -383,6 +394,9 @@ "block.gtceu.hv_input_hatch": "§6HV Input Hatch", "block.gtceu.hv_item_collector": "§6Advanced Item Collector II§r", "block.gtceu.hv_item_passthrough_hatch": "§6HV Item Passthrough Hatch", + "block.gtceu.hv_kinetic_input_box": "§6Advanced Kinetic Input Box II§r", + "block.gtceu.hv_kinetic_mixer": "§6Advanced Kinetic Mixer II§r", + "block.gtceu.hv_kinetic_output_box": "§6Advanced Kinetic Output Box II§r", "block.gtceu.hv_laser_engraver": "§6Advanced Laser Engraver II§r", "block.gtceu.hv_lathe": "§6Advanced Lathe II§r", "block.gtceu.hv_macerator": "§6Advanced Macerator II§r", @@ -470,6 +484,8 @@ "block.gtceu.iv_input_hatch_4x": "§9IV Quadruple Input Hatch", "block.gtceu.iv_input_hatch_9x": "§9IV Nonuple Input Hatch", "block.gtceu.iv_item_passthrough_hatch": "§9IV Item Passthrough Hatch", + "block.gtceu.iv_kinetic_input_box": "§9Elite Kinetic Input Box §r", + "block.gtceu.iv_kinetic_output_box": "§9Elite Kinetic Output Box §r", "block.gtceu.iv_lapotronic_battery": "IV Lapotronic Capacitor", "block.gtceu.iv_large_miner": "§9Elite Large Miner §r", "block.gtceu.iv_laser_engraver": "§9Elite Laser Engraver §r", @@ -634,6 +650,8 @@ "block.gtceu.luv_input_hatch_4x": "§dLuV Quadruple Input Hatch", "block.gtceu.luv_input_hatch_9x": "§dLuV Nonuple Input Hatch", "block.gtceu.luv_item_passthrough_hatch": "§dLuV Item Passthrough Hatch", + "block.gtceu.luv_kinetic_input_box": "§dElite Kinetic Input Box II§r", + "block.gtceu.luv_kinetic_output_box": "§dElite Kinetic Output Box II§r", "block.gtceu.luv_lapotronic_battery": "LuV Lapotronic Capacitor", "block.gtceu.luv_large_miner": "§dElite Large Miner II§r", "block.gtceu.luv_laser_engraver": "§dElite Laser Engraver II§r", @@ -694,6 +712,10 @@ "block.gtceu.lv_diode": "§7LV Diode", "block.gtceu.lv_distillery": "Basic Distillery §r", "block.gtceu.lv_electric_furnace": "Basic Electric Furnace §r", + "block.gtceu.lv_electric_gear_box_16a": "Basic Electric Gearbox 16A §r", + "block.gtceu.lv_electric_gear_box_2a": "Basic Electric Gearbox 2A §r", + "block.gtceu.lv_electric_gear_box_32a": "Basic Electric Gearbox 32A §r", + "block.gtceu.lv_electric_gear_box_8a": "Basic Electric Gearbox 8A §r", "block.gtceu.lv_electrolyzer": "Basic Electrolyzer §r", "block.gtceu.lv_electromagnetic_separator": "Basic Electromagnetic Separator §r", "block.gtceu.lv_energy_input_hatch": "§7LV Energy Hatch", @@ -714,6 +736,9 @@ "block.gtceu.lv_input_hatch": "§7LV Input Hatch", "block.gtceu.lv_item_collector": "Basic Item Collector §r", "block.gtceu.lv_item_passthrough_hatch": "§7LV Item Passthrough Hatch", + "block.gtceu.lv_kinetic_input_box": "Basic Kinetic Input Box §r", + "block.gtceu.lv_kinetic_mixer": "Basic Kinetic Mixer §r", + "block.gtceu.lv_kinetic_output_box": "Basic Kinetic Output Box §r", "block.gtceu.lv_laser_engraver": "Basic Laser Engraver §r", "block.gtceu.lv_lathe": "Basic Lathe §r", "block.gtceu.lv_macerator": "Basic Macerator §r", @@ -836,6 +861,10 @@ "block.gtceu.mv_diode": "§bMV Diode", "block.gtceu.mv_distillery": "§bAdvanced Distillery §r", "block.gtceu.mv_electric_furnace": "§bAdvanced Electric Furnace §r", + "block.gtceu.mv_electric_gear_box_16a": "§bAdvanced Electric Gearbox 16A §r", + "block.gtceu.mv_electric_gear_box_2a": "§bAdvanced Electric Gearbox 2A §r", + "block.gtceu.mv_electric_gear_box_32a": "§bAdvanced Electric Gearbox 32A §r", + "block.gtceu.mv_electric_gear_box_8a": "§bAdvanced Electric Gearbox 8A §r", "block.gtceu.mv_electrolyzer": "§bAdvanced Electrolyzer §r", "block.gtceu.mv_electromagnetic_separator": "§bAdvanced Electromagnetic Separator §r", "block.gtceu.mv_energy_input_hatch": "§bMV Energy Hatch", @@ -857,6 +886,9 @@ "block.gtceu.mv_input_hatch": "§bMV Input Hatch", "block.gtceu.mv_item_collector": "§bAdvanced Item Collector §r", "block.gtceu.mv_item_passthrough_hatch": "§bMV Item Passthrough Hatch", + "block.gtceu.mv_kinetic_input_box": "§bAdvanced Kinetic Input Box §r", + "block.gtceu.mv_kinetic_mixer": "§bAdvanced Kinetic Mixer §r", + "block.gtceu.mv_kinetic_output_box": "§bAdvanced Kinetic Output Box §r", "block.gtceu.mv_laser_engraver": "§bAdvanced Laser Engraver §r", "block.gtceu.mv_lathe": "§bAdvanced Lathe §r", "block.gtceu.mv_macerator": "§bAdvanced Macerator §r", @@ -952,6 +984,8 @@ "block.gtceu.opv_input_hatch_4x": "§9§lOpV Quadruple Input Hatch", "block.gtceu.opv_input_hatch_9x": "§9§lOpV Nonuple Input Hatch", "block.gtceu.opv_item_passthrough_hatch": "§9§lOpV Item Passthrough Hatch", + "block.gtceu.opv_kinetic_input_box": "§9§lLegendary Kinetic Input Box §r", + "block.gtceu.opv_kinetic_output_box": "§9§lLegendary Kinetic Output Box §r", "block.gtceu.opv_laser_engraver": "§9§lLegendary Laser Engraver §r", "block.gtceu.opv_lathe": "§9§lLegendary Lathe §r", "block.gtceu.opv_macerator": "§9§lLegendary Macerator §r", @@ -1196,6 +1230,8 @@ "block.gtceu.uev_input_hatch_4x": "§aUEV Quadruple Input Hatch", "block.gtceu.uev_input_hatch_9x": "§aUEV Nonuple Input Hatch", "block.gtceu.uev_item_passthrough_hatch": "§aUEV Item Passthrough Hatch", + "block.gtceu.uev_kinetic_input_box": "§aEpic Kinetic Input Box II§r", + "block.gtceu.uev_kinetic_output_box": "§aEpic Kinetic Output Box II§r", "block.gtceu.uev_laser_engraver": "§aEpic Laser Engraver II§r", "block.gtceu.uev_lathe": "§aEpic Lathe II§r", "block.gtceu.uev_macerator": "§aEpic Macerator II§r", @@ -1279,6 +1315,8 @@ "block.gtceu.uhv_input_hatch_4x": "§4UHV Quadruple Input Hatch", "block.gtceu.uhv_input_hatch_9x": "§4UHV Nonuple Input Hatch", "block.gtceu.uhv_item_passthrough_hatch": "§4UHV Item Passthrough Hatch", + "block.gtceu.uhv_kinetic_input_box": "§4Epic Kinetic Input Box §r", + "block.gtceu.uhv_kinetic_output_box": "§4Epic Kinetic Output Box §r", "block.gtceu.uhv_laser_engraver": "§4Epic Laser Engraver §r", "block.gtceu.uhv_lathe": "§4Epic Lathe §r", "block.gtceu.uhv_macerator": "§4Epic Macerator §r", @@ -1362,6 +1400,8 @@ "block.gtceu.uiv_input_hatch_4x": "§2UIV Quadruple Input Hatch", "block.gtceu.uiv_input_hatch_9x": "§2UIV Nonuple Input Hatch", "block.gtceu.uiv_item_passthrough_hatch": "§2UIV Item Passthrough Hatch", + "block.gtceu.uiv_kinetic_input_box": "§2Epic Kinetic Input Box III§r", + "block.gtceu.uiv_kinetic_output_box": "§2Epic Kinetic Output Box III§r", "block.gtceu.uiv_laser_engraver": "§2Epic Laser Engraver III§r", "block.gtceu.uiv_lathe": "§2Epic Lathe III§r", "block.gtceu.uiv_macerator": "§2Epic Macerator III§r", @@ -1466,6 +1506,8 @@ "block.gtceu.uv_input_hatch_4x": "§3UV Quadruple Input Hatch", "block.gtceu.uv_input_hatch_9x": "§3UV Nonuple Input Hatch", "block.gtceu.uv_item_passthrough_hatch": "§3UV Item Passthrough Hatch", + "block.gtceu.uv_kinetic_input_box": "§3Ultimate Kinetic Input Box §r", + "block.gtceu.uv_kinetic_output_box": "§3Ultimate Kinetic Output Box §r", "block.gtceu.uv_lapotronic_battery": "UV Lapotronic Capacitor", "block.gtceu.uv_laser_engraver": "§3Ultimate Laser Engraver §r", "block.gtceu.uv_lathe": "§3Ultimate Lathe §r", @@ -1551,6 +1593,8 @@ "block.gtceu.uxv_input_hatch_4x": "§eUXV Quadruple Input Hatch", "block.gtceu.uxv_input_hatch_9x": "§eUXV Nonuple Input Hatch", "block.gtceu.uxv_item_passthrough_hatch": "§eUXV Item Passthrough Hatch", + "block.gtceu.uxv_kinetic_input_box": "§eEpic Kinetic Input Box IV§r", + "block.gtceu.uxv_kinetic_output_box": "§eEpic Kinetic Output Box IV§r", "block.gtceu.uxv_laser_engraver": "§eEpic Laser Engraver IV§r", "block.gtceu.uxv_lathe": "§eEpic Lathe IV§r", "block.gtceu.uxv_macerator": "§eEpic Macerator IV§r", @@ -1669,6 +1713,8 @@ "block.gtceu.zpm_input_hatch_4x": "§cZPM Quadruple Input Hatch", "block.gtceu.zpm_input_hatch_9x": "§cZPM Nonuple Input Hatch", "block.gtceu.zpm_item_passthrough_hatch": "§cZPM Item Passthrough Hatch", + "block.gtceu.zpm_kinetic_input_box": "§cElite Kinetic Input Box III§r", + "block.gtceu.zpm_kinetic_output_box": "§cElite Kinetic Output Box III§r", "block.gtceu.zpm_lapotronic_battery": "ZPM Lapotronic Capacitor", "block.gtceu.zpm_laser_engraver": "§cElite Laser Engraver III§r", "block.gtceu.zpm_lathe": "§cElite Lathe III§r", @@ -2188,6 +2234,7 @@ "gtceu.cover.item_detector.message_item_storage_inverted": "Monitoring Inverted Item Storage", "gtceu.cover.item_detector.message_item_storage_normal": "Monitoring Normal Item Storage", "gtceu.cracker": "Cracker", + "gtceu.create_mixer": "Create Mixer", "gtceu.creative.activity.off": "Not active", "gtceu.creative.activity.on": "Active", "gtceu.creative.chest.ipc": "Items per Cycle", diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java index bce4073313..b896b030e7 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/TankWidget.java @@ -1,6 +1,5 @@ package com.gregtechceu.gtceu.api.gui.widget; -import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.client.TooltipsHandler; import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidEntryList; import com.gregtechceu.gtceu.integration.xei.entry.fluid.FluidStackList; @@ -304,22 +303,13 @@ public List getFullTooltipTexts() { if (stack != null && !stack.isEmpty()) { tooltips.add(stack.getDisplayName()); if (!isPhantom && showAmount) { - tooltips.add( - Component.translatable("ldlib.fluid.amount", stack.getAmount(), lastTankCapacity) - .append(" mB")); - } - if (ChemicalHelper.getMaterial(stack.getFluid()) != null) { - TooltipsHandler.appendFluidTooltips(stack, tooltips::add, null); - } else { - tooltips.add(Component.translatable("ldlib.fluid.temperature", - stack.getFluid().getFluidType().getTemperature(stack))); - tooltips.add(Component.translatable(stack.getFluid().getFluidType().isLighterThanAir() ? - "ldlib.fluid.state_gas" : "ldlib.fluid.state_liquid")); + tooltips.add(Component.translatable("gtceu.fluid.amount", stack.getAmount(), lastTankCapacity)); } + TooltipsHandler.appendFluidTooltips(stack, tooltips::add, null); } else { - tooltips.add(Component.translatable("ldlib.fluid.empty")); + tooltips.add(Component.translatable("gtceu.fluid.empty")); if (!isPhantom && showAmount) { - tooltips.add(Component.translatable("ldlib.fluid.amount", 0, lastTankCapacity).append(" mB")); + tooltips.add(Component.translatable("gtceu.fluid.amount", 0, lastTankCapacity).append(" mB")); } } tooltips.addAll(getTooltipTexts()); diff --git a/src/main/java/com/gregtechceu/gtceu/client/TooltipsHandler.java b/src/main/java/com/gregtechceu/gtceu/client/TooltipsHandler.java index 302accae49..3fe75aeafa 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/TooltipsHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/client/TooltipsHandler.java @@ -106,21 +106,24 @@ public static void appendFluidTooltips(FluidStack fluidStack, Consumer tooltips.accept(Component.translatable("gtceu.fluid.state_liquid")); - case GAS -> tooltips.accept(Component.translatable("gtceu.fluid.state_gas")); - case PLASMA -> tooltips.accept(Component.translatable("gtceu.fluid.state_plasma")); - } - - attributedFluid.getAttributes().forEach(a -> a.appendFluidTooltips(tooltips)); - } - tooltips.accept(Component.translatable("gtceu.fluid.temperature", fluidType.getTemperature())); - if (fluidType.getTemperature() < FluidConstants.CRYOGENIC_FLUID_THRESHOLD) { - tooltips.accept(Component.translatable("gtceu.fluid.temperature.cryogenic")); + if (fluid instanceof GTFluid attributedFluid) { + FluidState state = attributedFluid.getState(); + switch (state) { + case LIQUID -> tooltips.accept(Component.translatable("gtceu.fluid.state_liquid")); + case GAS -> tooltips.accept(Component.translatable("gtceu.fluid.state_gas")); + case PLASMA -> tooltips.accept(Component.translatable("gtceu.fluid.state_plasma")); } + attributedFluid.getAttributes().forEach(a -> a.appendFluidTooltips(tooltips)); + } else { + String key = "gtceu.fluid.state_" + (fluidType.isLighterThanAir() ? "gas" : "liquid"); + tooltips.accept(Component.translatable(key)); + } + + tooltips.accept(Component.translatable("gtceu.fluid.temperature", fluidType.getTemperature())); + if (fluidType.getTemperature() < FluidConstants.CRYOGENIC_FLUID_THRESHOLD) { + tooltips.accept(Component.translatable("gtceu.fluid.temperature.cryogenic")); } } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/BreweryLogic.java b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/BreweryLogic.java index 5c05d7bdb3..2a3ca77a78 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/BreweryLogic.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/BreweryLogic.java @@ -29,7 +29,6 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; -import java.util.List; import java.util.Objects; import static com.gregtechceu.gtceu.api.GTValues.*; @@ -141,10 +140,8 @@ public class BreweryLogic implements GTRecipeType.ICustomRecipeLogic { } @Override - public @Nullable List getRepresentativeRecipes() { - List list = new ArrayList<>(BuiltInRegistries.POTION.size()); + public void buildRepresentativeRecipes() { int index = 0; - for (PotionBrewing.Mix mix : PotionBrewingAccessor.getPotionMixes()) { FluidStack fromFluid = PotionFluidHelper.getFluidFromPotion(mix.from.get(), PotionFluidHelper.MB_PER_RECIPE); @@ -161,7 +158,7 @@ public class BreweryLogic implements GTRecipeType.ICustomRecipeLogic { .buildRawRecipe(); // for EMI to detect it's a synthetic recipe (not ever in JSON) recipe.setId(recipe.getId().withPrefix("/")); - list.add(recipe); + GTRecipeTypes.BREWING_RECIPES.addToMainCategory(recipe); } for (IBrewingRecipe brewingRecipe : BrewingRecipeRegistry.getRecipes()) { @@ -189,9 +186,7 @@ public class BreweryLogic implements GTRecipeType.ICustomRecipeLogic { .buildRawRecipe(); // for EMI to detect it's a synthetic recipe (not ever in JSON) recipe.setId(recipe.getId().withPrefix("/")); - list.add(recipe); + GTRecipeTypes.BREWING_RECIPES.addToMainCategory(recipe); } - - return list; } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/FormingPressLogic.java b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/FormingPressLogic.java index bb7dc1c8c1..e42ece913c 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/FormingPressLogic.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/customlogic/FormingPressLogic.java @@ -90,13 +90,15 @@ public void buildRepresentativeRecipes() { toName.setHoverName(Component.translatable("gtceu.forming_press.naming.to_name")); ItemStack named = new ItemStack(Items.NAME_TAG); named.setHoverName(Component.translatable("gtceu.forming_press.naming.named")); - var recipe = GTRecipeTypes.FORMING_PRESS_RECIPES.recipeBuilder("copy") + GTRecipe recipe = GTRecipeTypes.FORMING_PRESS_RECIPES.recipeBuilder("name_item") .notConsumable(press) .inputItems(toName) .outputItems(named) .duration(40) .EUt(4) .buildRawRecipe(); + // for EMI to detect it's a synthetic recipe (not ever in JSON) + recipe.setId(recipe.getId().withPrefix("/")); GTRecipeTypes.FORMING_PRESS_RECIPES.addToMainCategory(recipe); } } From c006d2a86f870a4d7742e0a10e8a885587a7fa17 Mon Sep 17 00:00:00 2001 From: kross <135918757+krossgg@users.noreply.github.com> Date: Thu, 12 Dec 2024 23:51:05 -0500 Subject: [PATCH 4/4] Fix JEI tank widget --- .../gtceu/api/capability/recipe/FluidRecipeCapability.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java index 0459a0e986..8d94706f29 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/FluidRecipeCapability.java @@ -341,6 +341,7 @@ public void applyWidgetInfo(@NotNull Widget widget, tank.setIngredientIO(io == IO.IN ? IngredientIO.INPUT : IngredientIO.OUTPUT); tank.setAllowClickFilled(!isXEI); tank.setAllowClickDrained(!isXEI && io.support(IO.IN)); + if (isXEI) tank.setShowAmount(false); if (content != null) { float chance = (float) recipeType.getChanceFunction() .getBoostedChance(content, recipeTier, chanceTier) / content.maxChance;