From 93ced1b4ca5cb1c226de68d27a90cdb631c988cb Mon Sep 17 00:00:00 2001 From: screret <68943070+screret@users.noreply.github.com> Date: Tue, 18 Jul 2023 17:09:08 +0300 Subject: [PATCH] Update to KJS 6.1 (#146) * best update ever ong * almost there * DONE! * revert this * fix a couple crashes * added *new* machine builder stuffs and such, updated KJS * missed sum files * ....and more. * fix pipe models * fix element builder * fix being able to set auto output side to front * almost there * DONE! * revert this * holy hell * fix some recipes failing because they were provided BlockEntrys and only checked for ItemEntry instead of ItemProviderEntry * DONE! * revert this * ....and more. * DONE! * revert this * holy hell * same stuff * fix a crash with data, and rename Cetane-boosted Diesel to actually be Cetane-boosted diesel * finish the (very much optional) bedrock ore system * fix a crash if flawed/chipped gems are disabled * change ProspectorMode to fix stuff * changes to bedrock ore vein edge stuff * Revert "change ProspectorMode to fix stuff" This reverts commit b378f4c90438d40c39411b253715386c2301e847. * bump version * update kjs * IT WORKS FUCK YESSSS... except replacing. * replacing almost works * IT WORKS FUCK YESSSS * fix ores not dropping materials without raw ores * piss off loom * lat broke replacing :trolley: * fix prospector tooltips * tier chance boost * fix solder multiplier defaulting to 0 * update some deps * run data * fix cleanroom --------- Co-authored-by: KilaBash --- build.gradle | 4 +- .../gregtechceu/gtceu/api/addon/IGTAddon.java | 6 + .../api/addon/events/KJSRecipeKeyEvent.java | 34 + .../recipe/IRecipeCapabilityHolder.java | 7 + .../api/data/chemical/material/Material.java | 3 +- .../material/info/MaterialIconType.java | 1 + .../gtceu/api/data/tag/TagPrefix.java | 10 +- .../gtceu/api/data/worldgen/GTOreFeature.java | 14 +- .../worldgen/GTOreFeatureConfiguration.java | 4 +- .../api/data/worldgen/GTOreFeatureEntry.java | 148 ++++- .../api/data/worldgen/VeinGenerators.java | 11 +- .../bedrockfluid/BedrockFluidDefinition.java | 161 ++--- ...ta.java => BedrockFluidVeinSavedData.java} | 16 +- .../bedrockfluid/FluidVeinWorldEntry.java | 2 +- .../bedrockore/BedrockOreVeinSavedData.java | 247 ++++++++ .../bedrockore/OreVeinWorldEntry.java | 70 +++ .../data/worldgen/generator/BiomeFilter.java | 2 +- .../worldgen/generator/VeinCountFilter.java | 6 +- .../generator/WorldGeneratorUtils.java | 9 +- .../gtceu/api/gui/misc/ProspectorMode.java | 111 +++- .../gui/widget/AutoOutputConfigurator.java | 4 +- .../api/gui/widget/ProspectingMapWidget.java | 7 +- .../gtceu/api/machine/MetaMachine.java | 4 + .../machine/feature/IRecipeLogicMachine.java | 5 + ...eredWorkableElectricMultiblockMachine.java | 74 +++ .../gtceu/api/pattern/BlockPattern.java | 2 +- .../api/pattern/TraceabilityPredicate.java | 4 + .../gtceu/api/recipe/GTRecipe.java | 2 +- .../gtceu/api/recipe/GTRecipeSerializer.java | 1 - .../gtceu/api/recipe/content/Content.java | 4 +- .../recipe/content/IContentSerializer.java | 9 +- .../recipe/content/SerializerBigInteger.java | 7 +- .../recipe/content/SerializerBlockState.java | 5 + .../api/recipe/content/SerializerDouble.java | 7 +- .../api/recipe/content/SerializerFloat.java | 7 +- .../recipe/content/SerializerFluidStack.java | 5 + .../recipe/content/SerializerIngredient.java | 10 +- .../api/recipe/content/SerializerInteger.java | 7 +- .../api/recipe/content/SerializerLong.java | 9 +- .../recipe/ingredient/SizedIngredient.java | 5 + .../gtceu/api/registry/GTRegistries.java | 2 + .../registry/registrate/MachineBuilder.java | 17 +- .../gtceu/client/model/PipeModel.java | 52 +- .../renderer/block/PipeBlockRenderer.java | 3 + .../gtceu/common/block/CableBlock.java | 2 +- .../gtceu/common/data/GTBedrockFluids.java | 28 +- .../gtceu/common/data/GTItems.java | 5 +- .../gtceu/common/data/GTMachines.java | 40 +- .../gregtechceu/gtceu/common/data/GTOres.java | 13 +- .../gtceu/common/data/GTRecipeModifiers.java | 2 +- .../gtceu/common/data/GTRecipeTypes.java | 3 +- .../UnknownCompositionMaterials.java | 4 +- .../item/ProspectorScannerBehavior.java | 4 +- .../electric/BedrockOreMinerMachine.java | 109 ++++ .../multiblock/electric/CleanroomMachine.java | 33 +- .../LargeCombustionEngineMachine.java | 2 +- .../generator/LargeTurbineMachine.java | 2 +- .../PrimitiveFancyUIWorkableMachine.java | 11 + .../steam/SteamParallelMultiblockMachine.java | 2 +- .../machine/trait/BedrockOreMinerLogic.java | 156 +++++ .../common/machine/trait/FluidDrillLogic.java | 10 +- .../common/pipelike/cable/Insulation.java | 10 +- .../pipelike/fluidpipe/FluidPipeType.java | 4 +- .../gtceu/common/recipe/BiomeCondition.java | 4 +- .../gtceu/config/ConfigHolder.java | 10 +- .../gtceu/core/mixins/LootTablesMixin.java | 6 +- .../gtceu/data/lang/LangHandler.java | 3 +- .../gtceu/data/lang/MachineLang.java | 4 + .../gtceu/data/loader/FluidVeinLoader.java | 78 +++ .../gtceu/data/loader/OreDataLoader.java | 20 +- .../gtceu/data/recipe/CustomTags.java | 1 + .../data/recipe/VanillaRecipeHelper.java | 3 +- .../data/recipe/builder/GTRecipeBuilder.java | 65 +- .../recipe/generated/OreRecipeHandler.java | 2 +- .../recipe/generated/ToolRecipeHandler.java | 5 - .../recipe/generated/WireRecipeHandler.java | 2 +- .../data/recipe/misc/CreateRecipeLoader.java | 4 +- .../recipe/misc/MetaTileEntityLoader.java | 3 +- .../gtceu/data/tags/IBiomeTagsProvider.java | 3 + .../gtceu/integration/GTRecipeWidget.java | 20 +- .../integration/kjs/GTCEuServerEvents.java | 2 + .../kjs/GTRegistryObjectBuilderTypes.java | 9 +- .../integration/kjs/GregTechKubeJSPlugin.java | 43 +- .../kjs/builders/CoilBlockBuilder.java | 2 +- .../kjs/builders/ElementBuilder.java | 5 +- .../kjs/builders/FluidVeinBuilderJS.java | 91 +++ .../kjs/builders/OreVeinBuilderJS.java | 11 + .../machine/CustomMultiblockBuilder.java | 72 +++ .../machine/CustomTieredMachineBuilder.java | 44 ++ .../builders/machine/GeneratorBuilder.java | 61 +- .../machine/KineticMachineBuilder.java | 105 +++- .../kjs/builders/machine/MachineBuilder.java | 29 - .../machine/MachineFunctionPresets.java | 323 ++++++++++ .../builders/machine/MultiblockBuilder.java | 214 ------- .../machine/SimpleMachineBuilder.java | 84 ++- .../builders/machine/SteamMachineBuilder.java | 60 +- .../kjs/events/GTFluidVeinEventJS.java | 30 + .../kjs/events/GTOreVeinEventJS.java | 9 +- .../kjs/events/GTRegistryEventJS.java | 20 + .../kjs/recipe/GTRecipeBuilderJS.java | 585 ------------------ .../kjs/recipe/GTRecipeSchema.java | 538 ++++++++++++++++ .../kjs/recipe/components/CapabilityMap.java | 128 ++++ .../components/CapabilityMapComponent.java | 86 +++ .../kjs/recipe/components/ContentJS.java | 76 +++ .../recipe/components/GTRecipeComponents.java | 171 +++++ .../bedrock_ore_miner/overlay_front.png | Bin 0 -> 5718 bytes .../overlay_front_active.png | Bin 0 -> 10058 bytes .../overlay_front_active.png.mcmeta | 10 + .../overlay_front_active_emissive.png | Bin 0 -> 312 bytes .../overlay_front_active_emissive.png.mcmeta | 10 + .../overlay_front_emissive.png | Bin 0 -> 219 bytes .../overlay_front_paused.png | Bin 0 -> 571 bytes .../overlay_front_paused_emissive.png | Bin 0 -> 569 bytes fabric/build.gradle | 6 +- .../resources/assets/gtceu/lang/en_ud.json | 29 +- .../resources/assets/gtceu/lang/en_us.json | 29 +- .../gtceu/tags/worldgen/biome/is_sandy.json | 10 + .../fabric/SizedIngredientImpl.java | 13 +- .../common/data/fabric/GTFeaturesImpl.java | 3 +- .../data/fabric/BiomeTagsProviderImpl.java | 7 + .../loader/fabric/FluidVeinLoaderImpl.java | 29 + .../data/loader/fabric/OreDataLoaderImpl.java | 4 +- .../gregtechceu/gtceu/fabric/GTCEuFabric.java | 2 + .../gtceu/utils/fabric/GTUtilImpl.java | 3 +- forge/build.gradle | 6 +- .../resources/assets/gtceu/lang/en_ud.json | 34 +- .../resources/assets/gtceu/lang/en_us.json | 32 +- .../gtceu/tags/worldgen/biome/is_sandy.json | 9 + .../ingredient/forge/SizedIngredientImpl.java | 4 + .../common/data/forge/GTFeaturesImpl.java | 4 +- .../gtceu/common/data/forge/GTItemsImpl.java | 2 +- .../data/forge/BiomeTagsProviderImpl.java | 7 + .../loader/forge/FluidVeinLoaderImpl.java | 11 + .../gtceu/forge/ForgeCommonEventListener.java | 2 + .../gtceu/utils/forge/GTUtilImpl.java | 3 +- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 18 +- 138 files changed, 3592 insertions(+), 1288 deletions(-) create mode 100644 common/src/main/java/com/gregtechceu/gtceu/api/addon/events/KJSRecipeKeyEvent.java rename common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/{BedrockFluidVeinSaveData.java => BedrockFluidVeinSavedData.java} (91%) create mode 100644 common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/BedrockOreVeinSavedData.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/OreVeinWorldEntry.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/TieredWorkableElectricMultiblockMachine.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/BedrockOreMinerMachine.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveFancyUIWorkableMachine.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/common/machine/trait/BedrockOreMinerLogic.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/data/loader/FluidVeinLoader.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/FluidVeinBuilderJS.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/CustomMultiblockBuilder.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/CustomTieredMachineBuilder.java delete mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MachineBuilder.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MachineFunctionPresets.java delete mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MultiblockBuilder.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTFluidVeinEventJS.java delete mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeBuilderJS.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/CapabilityMap.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/CapabilityMapComponent.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/ContentJS.java create mode 100644 common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/GTRecipeComponents.java create mode 100644 common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front.png create mode 100644 common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_active.png create mode 100644 common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_active.png.mcmeta create mode 100644 common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_active_emissive.png create mode 100644 common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_active_emissive.png.mcmeta create mode 100644 common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_emissive.png create mode 100644 common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_paused.png create mode 100644 common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_paused_emissive.png create mode 100644 fabric/src/generated/resources/data/gtceu/tags/worldgen/biome/is_sandy.json create mode 100644 fabric/src/main/java/com/gregtechceu/gtceu/data/loader/fabric/FluidVeinLoaderImpl.java create mode 100644 forge/src/generated/resources/data/gtceu/tags/worldgen/biome/is_sandy.json create mode 100644 forge/src/main/java/com/gregtechceu/gtceu/data/loader/forge/FluidVeinLoaderImpl.java diff --git a/build.gradle b/build.gradle index 0ce8a48cb4..6dc3842ac9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { alias libs.plugins.architectury alias libs.plugins.architectury.loom apply false - alias libs.plugins.quiltFlower apply false // Quiltflower, a better decompiler + alias libs.plugins.vineFlower apply false // VineFlower, a better decompiler alias libs.plugins.machete // automatic jar compressing on build } @@ -13,7 +13,7 @@ architectury { subprojects { apply plugin: "dev.architectury.loom" - apply plugin: "io.github.juuxel.loom-quiltflower" + apply plugin: "io.github.juuxel.loom-vineflower" loom { silentMojangMappingsLicense() diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java b/common/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java index 932da1f3de..2c7df0f6a5 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java @@ -1,5 +1,7 @@ package com.gregtechceu.gtceu.api.addon; +import com.gregtechceu.gtceu.api.addon.events.KJSRecipeKeyEvent; + import com.gregtechceu.gtceu.api.addon.events.MaterialCasingCollectionEvent; import net.minecraft.data.recipes.FinishedRecipe; @@ -85,4 +87,8 @@ default void initializeRecipes(Consumer provider) { default void collectMaterialCasings(MaterialCasingCollectionEvent event) { } + + default void registerRecipeKeys(KJSRecipeKeyEvent event) { + + } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/addon/events/KJSRecipeKeyEvent.java b/common/src/main/java/com/gregtechceu/gtceu/api/addon/events/KJSRecipeKeyEvent.java new file mode 100644 index 0000000000..c08b67f8e9 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/api/addon/events/KJSRecipeKeyEvent.java @@ -0,0 +1,34 @@ +package com.gregtechceu.gtceu.api.addon.events; + +import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; +import com.gregtechceu.gtceu.integration.kjs.recipe.components.ContentJS; +import com.gregtechceu.gtceu.integration.kjs.recipe.components.GTRecipeComponents; +import com.mojang.datafixers.util.Pair; +import dev.latvian.mods.kubejs.recipe.component.ItemComponents; +import dev.latvian.mods.kubejs.recipe.component.NumberComponent; +import dev.latvian.mods.kubejs.recipe.component.RecipeComponent; +import lombok.Getter; + +import java.util.*; + +/** + * @author screret + * @date 2023/7/5 + * @implNote An event for adding KJS recipe keys + */ +@SuppressWarnings("unused") +public class KJSRecipeKeyEvent { + @Getter + private final Map, Pair, ContentJS>> registeredKeys = new HashMap<>(); + + /** + * Use this to register new components for KJS to use! + * @param cap the recipe capability you're adding a KJS binding for. + * @param key the components, like {@link GTRecipeComponents#ITEM_IN} and {@link GTRecipeComponents#ITEM_OUT}, as a {@link Pair} + */ + public void registerKey(RecipeCapability cap, Pair, ContentJS> key) { + if (registeredKeys.put(cap, key) != null) { + throw new IllegalStateException("Can't have multiple Recipe keys with same value!"); + } + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/IRecipeCapabilityHolder.java b/common/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/IRecipeCapabilityHolder.java index 9eb74770e9..7136d634c7 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/IRecipeCapabilityHolder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/IRecipeCapabilityHolder.java @@ -15,4 +15,11 @@ default boolean hasProxies() { @Nonnull Table, List>> getCapabilitiesProxy(); + /** + * get Tier for chance boost. + */ + default int getChanceTier() { + return 0; + } + } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java index 5e850e8e58..02ea511b1f 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java @@ -22,6 +22,7 @@ import dev.latvian.mods.rhino.util.HideFromJS; import dev.latvian.mods.rhino.util.RemapPrefixForJS; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.item.enchantment.Enchantment; @@ -315,7 +316,7 @@ public String getUnlocalizedName() { return "material." + materialInfo.name; } - public Component getLocalizedName() { + public MutableComponent getLocalizedName() { return Component.translatable(getUnlocalizedName()); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java index 3d5e00a18e..15f06f0d38 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java @@ -91,6 +91,7 @@ public record MaterialIconType(String name) { public static final MaterialIconType ore = new MaterialIconType("ore"); public static final MaterialIconType oreSmall = new MaterialIconType("oreSmall"); public static final MaterialIconType frameGt = new MaterialIconType("frameGt"); + public static final MaterialIconType wire = new MaterialIconType("wire"); // USED FOR GREGIFICATION ADDON public static final MaterialIconType seed = new MaterialIconType("seed"); diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java index 7d3022af2e..1e29843676 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java @@ -711,11 +711,11 @@ public static TagPrefix get(String name) { //public static final TagPrefix pipeHugeRestrictive = new TagPrefix("pipeHugeRestrictive").itemTable(() -> GTBlocks.ITEM_PIPE_BLOCKS).langValue("Huge Restrictive %s Item Pipe").miningToolTag(GTToolType.WRENCH.harvestTag).materialAmount(GTValues.M * 12).unificationEnabled(true); // Wires and cables - public static final TagPrefix wireGtHex = new TagPrefix("wireGtHex").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("16x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 8).unificationEnabled(true); - public static final TagPrefix wireGtOctal = new TagPrefix("wireGtOctal").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("8x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 4).unificationEnabled(true); - public static final TagPrefix wireGtQuadruple = new TagPrefix("wireGtQuadruple").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("4x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 2).unificationEnabled(true); - public static final TagPrefix wireGtDouble = new TagPrefix("wireGtDouble").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("2x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M).unificationEnabled(true); - public static final TagPrefix wireGtSingle = new TagPrefix("wireGtSingle").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("1x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M / 2).unificationEnabled(true); + public static final TagPrefix wireGtHex = new TagPrefix("wireGtHex").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("16x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 8).materialIconType(MaterialIconType.wire).unificationEnabled(true); + public static final TagPrefix wireGtOctal = new TagPrefix("wireGtOctal").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("8x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 4).materialIconType(MaterialIconType.wire).unificationEnabled(true); + public static final TagPrefix wireGtQuadruple = new TagPrefix("wireGtQuadruple").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("4x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 2).materialIconType(MaterialIconType.wire).unificationEnabled(true); + public static final TagPrefix wireGtDouble = new TagPrefix("wireGtDouble").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("2x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M).materialIconType(MaterialIconType.wire).unificationEnabled(true); + public static final TagPrefix wireGtSingle = new TagPrefix("wireGtSingle").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("1x %s Wire").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M / 2).materialIconType(MaterialIconType.wire).unificationEnabled(true); public static final TagPrefix cableGtHex = new TagPrefix("cableGtHex").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("16x %s Cable").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 8).unificationEnabled(true); public static final TagPrefix cableGtOctal = new TagPrefix("cableGtOctal").itemTable(() -> GTBlocks.CABLE_BLOCKS).langValue("8x %s Cable").miningToolTag(GTToolType.WIRE_CUTTER.harvestTag).materialAmount(GTValues.M * 4).unificationEnabled(true); diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeature.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeature.java index 06b462dc53..27c96ae083 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeature.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeature.java @@ -2,12 +2,15 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.Material; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreVeinSavedData; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.config.ConfigHolder; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.RandomSource; +import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.state.BlockState; @@ -51,10 +54,13 @@ public boolean place(FeaturePlaceContext context) { if (ConfigHolder.INSTANCE.worldgen.debugWorldgen) GTCEu.LOGGER.debug("failed to place vein " + entry.id + " in biome " + biome + ". Trying with another..."); }*/ - ResourceLocation id = GTOreFeatureEntry.ALL.inverse().get(entry); + ResourceLocation id = GTRegistries.ORE_VEINS.getKey(entry); if (ConfigHolder.INSTANCE.worldgen.debugWorldgen) GTCEu.LOGGER.debug("trying to place vein " + id + " at " + origin); if (entry.getVeinGenerator() != null && entry.getVeinGenerator().generate(level, random, entry, origin)) { logPlaced(id, true); + if (ConfigHolder.INSTANCE.machines.doBedrockOres) { + BedrockOreVeinSavedData.getOrCreate(level.getLevel()).createVein(new ChunkPos(origin), entry); + } return true; } @@ -67,7 +73,7 @@ public static boolean canPlaceOre(BlockState pState, Function pAdjacentStateAccessor, RandomSource pRandom, GTOreFeatureEntry entry, Material pTargetState, BlockPos.MutableBlockPos pMatablePos) { - if (!entry.layer.getTarget().test(pState, pRandom)) + if (!entry.getLayer().getTarget().test(pState, pRandom)) return false; - if (shouldSkipAirCheck(pRandom, entry.discardChanceOnAirExposure)) + if (shouldSkipAirCheck(pRandom, entry.getDiscardChanceOnAirExposure())) return true; return !isAdjacentToAir(pAdjacentStateAccessor, pMatablePos); diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeatureConfiguration.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeatureConfiguration.java index 79165d8317..f231fe9035 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeatureConfiguration.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeatureConfiguration.java @@ -13,6 +13,8 @@ import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; import org.jetbrains.annotations.Nullable; +import java.util.function.Function; + /** * @author Screret * @date 2023/6/9 @@ -21,7 +23,7 @@ public class GTOreFeatureConfiguration implements FeatureConfiguration { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.either(GTOreFeatureEntry.CODEC, GTOreFeatureEntry.FULL_CODEC) - .xmap(either -> either.map(entry -> entry, entry -> entry), Either::left) + .xmap(either -> either.map(Function.identity(), Function.identity()), Either::left) .optionalFieldOf("entry", null) .forGetter(config -> config.entry) ).apply(instance, GTOreFeatureConfiguration::new) diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeatureEntry.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeatureEntry.java index 651f31b4e5..9722b22b8a 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeatureEntry.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreFeatureEntry.java @@ -1,18 +1,21 @@ package com.gregtechceu.gtceu.api.data.worldgen; -import com.google.common.collect.HashBiMap; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.chemical.material.Material; +import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.api.data.worldgen.generator.BiomeFilter; import com.gregtechceu.gtceu.api.data.worldgen.generator.VeinCountFilter; import com.gregtechceu.gtceu.api.data.worldgen.generator.WorldGeneratorUtils; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTFeatures; +import com.gregtechceu.gtceu.config.ConfigHolder; +import com.gregtechceu.gtceu.utils.GTUtil; import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; import com.mojang.serialization.codecs.RecordCodecBuilder; import com.tterrag.registrate.util.nullness.NonNullSupplier; +import dev.latvian.mods.rhino.util.HideFromJS; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @@ -34,7 +37,9 @@ import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; -import net.minecraft.world.level.levelgen.placement.*; +import net.minecraft.world.level.levelgen.placement.HeightRangePlacement; +import net.minecraft.world.level.levelgen.placement.InSquarePlacement; +import net.minecraft.world.level.levelgen.placement.PlacementModifier; import org.apache.commons.lang3.mutable.MutableInt; import org.jetbrains.annotations.Nullable; @@ -43,6 +48,7 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author Screret @@ -53,14 +59,11 @@ @ParametersAreNonnullByDefault @Accessors(chain = true) public class GTOreFeatureEntry { - public static final HashBiMap ALL = HashBiMap.create(); - - public static final Codec CODEC = ResourceLocation.CODEC - .flatXmap(rl -> Optional.ofNullable(ALL.get(rl)) + .flatXmap(rl -> Optional.ofNullable(GTRegistries.ORE_VEINS.get(rl)) .map(DataResult::success) .orElseGet(() -> DataResult.error("No GTOreFeatureEntry with id " + rl + " registered")), - obj -> Optional.ofNullable(ALL.inverse().get(obj)) + obj -> Optional.ofNullable(GTRegistries.ORE_VEINS.getKey(obj)) .map(DataResult::success) .orElseGet(() -> DataResult.error("GTOreFeatureEntry " + obj + " not registered"))); public static final Codec FULL_CODEC = RecordCodecBuilder.create( @@ -78,16 +81,24 @@ public class GTOreFeatureEntry { ).apply(instance, GTOreFeatureEntry::new) ); - public int clusterSize; - public float density; - public int weight; - public IWorldGenLayer layer; - public HolderSet dimensionFilter; - @Getter - protected HeightRangePlacement range; - public float discardChanceOnAirExposure; - public HolderSet biomes; - public BiomeWeightModifier biomeWeightModifier; + @Getter @Setter + private int clusterSize; + @Getter @Setter + private float density; + @Getter @Setter + private int weight; + @Getter @Setter + private IWorldGenLayer layer; + @Getter @Setter + private HolderSet dimensionFilter; + @Getter @Setter + private HeightRangePlacement range; + @Getter @Setter + private float discardChanceOnAirExposure; + @Getter @Setter + private HolderSet biomes; + @Getter @Setter + private BiomeWeightModifier biomeWeightModifier; @Getter private List modifiers; @@ -95,9 +106,18 @@ public class GTOreFeatureEntry { @Getter @Setter private VeinGenerator veinGenerator; + @Getter @Setter + private int minimumYield, maximumYield, depletedYield, depletionChance, depletionAmount = 1; + @Setter + private List> bedrockVeinMaterial; + public GTOreFeatureEntry(ResourceLocation id, int clusterSize, float density, int weight, IWorldGenLayer layer, HolderSet dimensionFilter, HeightRangePlacement range, float discardChanceOnAirExposure, @Nullable HolderSet biomes, @Nullable BiomeWeightModifier biomeWeightModifier, @Nullable GTOreFeatureEntry.VeinGenerator veinGenerator) { this(clusterSize, density, weight, layer, dimensionFilter, range, discardChanceOnAirExposure, biomes, biomeWeightModifier, veinGenerator); - ALL.put(id, this); + if (GTRegistries.ORE_VEINS.containKey(id)) { + GTRegistries.ORE_VEINS.replace(id, this); + } else { + GTRegistries.ORE_VEINS.register(id, this); + } } public GTOreFeatureEntry(int clusterSize, float density, int weight, IWorldGenLayer layer, HolderSet dimensionFilter, HeightRangePlacement range, float discardChanceOnAirExposure, @Nullable HolderSet biomes, @Nullable BiomeWeightModifier biomeWeightModifier, @Nullable GTOreFeatureEntry.VeinGenerator veinGenerator) { @@ -118,6 +138,11 @@ public GTOreFeatureEntry(int clusterSize, float density, int weight, IWorldGenLa InSquarePlacement.spread(), this.range ); + + this.maximumYield = (int) (density * 100) * clusterSize; + this.minimumYield = this.maximumYield / 7; + this.depletedYield = (int) (clusterSize / density / 10); + this.depletionChance = (int) (weight * density / 5); } public GTOreFeatureEntry biomes(TagKey biomes) { @@ -141,6 +166,16 @@ public GTOreFeatureEntry range(HeightRangePlacement range) { return this; } + public List> getBedrockVeinMaterials() { + if (ConfigHolder.INSTANCE.machines.doBedrockOres) { + if (bedrockVeinMaterial != null) return bedrockVeinMaterial; + //List> entries = this.getVeinGenerator().getValidMaterialsChances().entrySet().stream().collect(ArrayList::new, (list, b) -> list.add(Map.entry(b.getValue(), b.getKey())), ArrayList::addAll); + return bedrockVeinMaterial = this.getVeinGenerator().getValidMaterialsChances(); + } else { + return List.of(); + } + } + public StandardVeinGenerator standardVeinGenerator() { if (this.veinGenerator == null) { this.veinGenerator = new StandardVeinGenerator(this); @@ -155,6 +190,14 @@ public LayeredVeinGenerator layeredVeinGenerator() { return (LayeredVeinGenerator) veinGenerator; } + @Nullable + public VeinGenerator generator(ResourceLocation id) { + if (veinGenerator == null) { + veinGenerator = WorldGeneratorUtils.VEIN_GENERATOR_FUNCTIONS.containsKey(id) ? WorldGeneratorUtils.VEIN_GENERATOR_FUNCTIONS.get(id).apply(this) : null; + } + return veinGenerator; + } + public static abstract class VeinGenerator { public static final Codec> REGISTRY_CODEC = ResourceLocation.CODEC .flatXmap(rl -> Optional.ofNullable(WorldGeneratorUtils.VEIN_GENERATORS.get(rl)) @@ -180,21 +223,41 @@ public VeinGenerator(GTOreFeatureEntry entry) { return new ConfiguredFeature<>(GTFeatures.ORE, config); } - /*public PlacedFeature createPlacedFeature(RegistryAccess registryAccess) { - Registry> featureRegistry = registryAccess.registryOrThrow(Registry.CONFIGURED_FEATURE_REGISTRY); - Holder> featureHolder = featureRegistry.getOrCreateHolderOrThrow(ResourceKey.create(Registry.CONFIGURED_FEATURE_REGISTRY, GTOreFeatureEntry.this.id)); - return new PlacedFeature(featureHolder, List.of( - this.count, - new FrequencyModifier(this.frequency), - InSquarePlacement.spread() - this.range - )); - }*/ + /** + * @return Map of [block|material, chance] + */ + public abstract Map, Integer> getAllEntries(); + public List getAllBlocks() { + return getAllEntries().keySet().stream().map(either -> either.map(Function.identity(), material -> ChemicalHelper.getBlock(TagPrefix.ore, material).defaultBlockState())).toList(); + } + + public List getAllMaterials() { + return getAllEntries().entrySet().stream() + .sorted(Comparator.comparingInt(Map.Entry::getValue)) + .map(Map.Entry::getKey) + .map(either -> either.map(state -> ChemicalHelper.getMaterial(state.getBlock()) != null ? ChemicalHelper.getMaterial(state.getBlock()).material() : null, Function.identity())).filter(Objects::nonNull) + .toList(); + } + + public List getAllChances() { + return getAllEntries().values().stream().toList(); + } + + public List> getValidMaterialsChances() { + return getAllEntries().entrySet().stream() + .filter(entry -> entry.getKey().map(state -> ChemicalHelper.getMaterial(state.getBlock()) != null ? ChemicalHelper.getMaterial(state.getBlock()).material() : null, Function.identity()) != null) + .map(entry -> Map.entry(entry.getValue(), entry.getKey().map(state -> ChemicalHelper.getMaterial(state.getBlock()) != null ? ChemicalHelper.getMaterial(state.getBlock()).material() : null, Function.identity()))) + .collect(ArrayList::new, ArrayList::add, ArrayList::addAll); + } + + @HideFromJS public abstract boolean generate(WorldGenLevel level, RandomSource random, GTOreFeatureEntry entry, BlockPos origin); + @HideFromJS public abstract VeinGenerator build(); + @HideFromJS public GTOreFeatureEntry parent() { return entry; } @@ -206,6 +269,11 @@ public static class NoopVeinGenerator extends VeinGenerator { public static final NoopVeinGenerator INSTANCE = new NoopVeinGenerator(); public static final Codec CODEC = Codec.unit(() -> INSTANCE); + @Override + public Map, Integer> getAllEntries() { + return Map.of(); + } + @Override public boolean generate(WorldGenLevel level, RandomSource random, GTOreFeatureEntry entry, BlockPos origin) { return true; @@ -269,6 +337,12 @@ public StandardVeinGenerator withMaterial(Material material) { return this; } + @Override + public Map, Integer> getAllEntries() { + if (this.blocks != null) return this.blocks.map(blockStates -> blockStates.stream().map(state -> Either.left(state.state)).collect(Collectors.toMap(Function.identity(), value -> 1)), material -> Map.of(Either.right(material), 1)); + return Map.of(Either.left(block.get().defaultBlockState()), 1, Either.left(deepBlock.get().defaultBlockState()), 1, Either.left(netherBlock.get().defaultBlockState()), 1); + } + public VeinGenerator build() { if (this.blocks != null) return this; // if (this.blocks.left().isPresent() && !this.blocks.left().get().isEmpty()) return this; @@ -460,12 +534,30 @@ public static class LayeredVeinGenerator extends VeinGenerator { private final List> bakingLayerPatterns = new ArrayList<>(); + @HideFromJS public List layerPatterns; public LayeredVeinGenerator(GTOreFeatureEntry entry) { super(entry); } + @Override + public Map, Integer> getAllEntries() { + return layerPatterns.stream() + .flatMap(pattern -> pattern.layers.stream()) + .map(layer -> Map.entry(layer.targets.stream().flatMap(entry -> + entry.map(blockStates -> blockStates.stream().map(state -> Either.left(state.state)), + material -> Stream.of(Either.right(material)))).toList(), + layer.weight)) + .flatMap(entry -> { + var iterator = entry.getKey().iterator(); + return Stream.generate(() -> Map.entry(iterator.next(), entry.getValue())).limit(entry.getKey().size()); + }) + .distinct() + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + + @HideFromJS @Override public boolean generate(WorldGenLevel level, RandomSource random, GTOreFeatureEntry entry, BlockPos origin) { var patternPool = this.layerPatterns; diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/VeinGenerators.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/VeinGenerators.java index ce50a781f1..b2eeafeec9 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/VeinGenerators.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/VeinGenerators.java @@ -7,13 +7,16 @@ import com.mojang.serialization.Codec; import net.minecraft.resources.ResourceLocation; +import java.util.function.Function; + public class VeinGenerators { - public static Codec NO_OP = register(GTCEu.id("no_op"), GTOreFeatureEntry.NoopVeinGenerator.CODEC); - public static Codec STANDARD = register(GTCEu.id("standard"), GTOreFeatureEntry.StandardVeinGenerator.CODEC); - public static Codec LAYER = register(GTCEu.id("layer"), GTOreFeatureEntry.LayeredVeinGenerator.CODEC); + public static Codec NO_OP = register(GTCEu.id("no_op"), GTOreFeatureEntry.NoopVeinGenerator.CODEC, entry -> GTOreFeatureEntry.NoopVeinGenerator.INSTANCE); + public static Codec STANDARD = register(GTCEu.id("standard"), GTOreFeatureEntry.StandardVeinGenerator.CODEC, GTOreFeatureEntry.StandardVeinGenerator::new); + public static Codec LAYER = register(GTCEu.id("layer"), GTOreFeatureEntry.LayeredVeinGenerator.CODEC, GTOreFeatureEntry.LayeredVeinGenerator::new); - public static Codec register(ResourceLocation id, Codec codec) { + public static Codec register(ResourceLocation id, Codec codec, Function function) { WorldGeneratorUtils.VEIN_GENERATORS.put(id, codec); + WorldGeneratorUtils.VEIN_GENERATOR_FUNCTIONS.put(id, function); return codec; } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/BedrockFluidDefinition.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/BedrockFluidDefinition.java index 465b567203..6f14409129 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/BedrockFluidDefinition.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/BedrockFluidDefinition.java @@ -1,44 +1,69 @@ package com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid; +import com.gregtechceu.gtceu.api.data.worldgen.BiomeWeightModifier; import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.mojang.datafixers.util.Pair; +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import net.minecraft.core.Holder; +import net.minecraft.core.HolderSet; +import net.minecraft.core.Registry; +import net.minecraft.core.RegistryCodecs; +import net.minecraft.data.BuiltinRegistries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; -import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.material.Fluid; import java.util.*; -import java.util.function.Function; -import java.util.function.Predicate; import java.util.function.Supplier; public class BedrockFluidDefinition { + public static final MapCodec> YIELD = Codec.mapPair(Codec.INT.fieldOf("min"), Codec.INT.fieldOf("max")); + + public static final Codec FULL_CODEC = RecordCodecBuilder.create( + instance -> instance.group( + Codec.INT.fieldOf("weight").forGetter(ft -> ft.weight), + YIELD.fieldOf("yield").forGetter(ft -> Pair.of(ft.minimumYield, ft.maximumYield)), + Codec.INT.fieldOf("depletion_amount").forGetter(ft -> ft.depletionAmount), + Codec.INT.fieldOf("depletion_chance").forGetter(ft -> ft.depletionChance), + Codec.INT.fieldOf("depleted_yield").forGetter(ft -> ft.depletedYield), + Registry.FLUID.byNameCodec().fieldOf("fluid").forGetter(ft -> ft.storedFluid.get()), + BiomeWeightModifier.CODEC.listOf().optionalFieldOf("weight_modifier", null).forGetter(ft -> ft.originalModifiers), + RegistryCodecs.homogeneousList(Registry.DIMENSION_TYPE_REGISTRY).fieldOf("dimension_filter").forGetter(ft -> ft.dimensionFilter) + ).apply(instance, (weight, yield, depletionAmount, depletionChance, depletedYield, storedFluid, biomeWeightModifier, dimensionFilter) -> new BedrockFluidDefinition(weight, yield.getFirst(), yield.getSecond(), depletionAmount, depletionChance, depletedYield, () -> storedFluid, biomeWeightModifier, dimensionFilter)) + ); + + @Getter @Setter + private int weight; // weight value for determining which vein will appear + @Getter @Setter + private int minimumYield, maximumYield;// the [minimum, maximum) yields + @Getter @Setter + private int depletionAmount; // amount of fluid the vein gets drained by + @Getter @Setter + private int depletionChance; // the chance [0, 100] that the vein will deplete by 1 + @Getter @Setter + private int depletedYield; // yield after the vein is depleted + @Getter @Setter + private Supplier storedFluid; // the fluid which the vein contains @Getter - private final ResourceLocation name; - @Getter - private final int weight; // weight value for determining which vein will appear - @Getter - private final int minimumYield, maximumYield;// the [minimum, maximum) yields - @Getter - private final int depletionAmount; // amount of fluid the vein gets drained by - @Getter - private final int depletionChance; // the chance [0, 100] that the vein will deplete by 1 - @Getter - private final int depletedYield; // yield after the vein is depleted - @Getter - private final Supplier storedFluid; // the fluid which the vein contains - @Getter - private final Function, Integer> biomeWeightModifier; // weighting of biomes - @Getter - private final Predicate> dimensionFilter; // filtering of dimensions + private BiomeWeightModifier biomeWeightModifier; // weighting of biomes + private List originalModifiers; // weighting of biomes + @Getter @Setter + public HolderSet dimensionFilter; // filtering of dimensions + + public BedrockFluidDefinition(ResourceLocation name, int weight, int minimumYield, int maximumYield, int depletionAmount, int depletionChance, int depletedYield, Supplier storedFluid, List originalModifiers, HolderSet dimensionFilter) { + this(weight, minimumYield, maximumYield, depletionAmount, depletionChance, depletedYield, storedFluid, originalModifiers, dimensionFilter); + GTRegistries.BEDROCK_FLUID_DEFINITIONS.register(name, this); + } - public BedrockFluidDefinition(ResourceLocation name, int weight, int minimumYield, int maximumYield, int depletionAmount, int depletionChance, int depletedYield, Supplier storedFluid, Function, Integer> biomeWeightModifier, Predicate> dimensionFilter) { - this.name = name; + public BedrockFluidDefinition(int weight, int minimumYield, int maximumYield, int depletionAmount, int depletionChance, int depletedYield, Supplier storedFluid, List originalModifiers, HolderSet dimensionFilter) { this.weight = weight; this.minimumYield = minimumYield; this.maximumYield = maximumYield; @@ -46,10 +71,42 @@ public BedrockFluidDefinition(ResourceLocation name, int weight, int minimumYiel this.depletionChance = depletionChance; this.depletedYield = depletedYield; this.storedFluid = storedFluid; - this.biomeWeightModifier = biomeWeightModifier; + this.originalModifiers = originalModifiers; + this.biomeWeightModifier = new BiomeWeightModifier(HolderSet.direct(originalModifiers.stream().flatMap(mod -> mod.biomes.stream()).toList()), originalModifiers.stream().mapToInt(mod -> mod.addedWeight).sum()) { + @Override + public Integer apply(Holder biome) { + int mod = 0; + for (var modifier : originalModifiers) { + if (modifier.biomes.contains(biome)) { + mod += modifier.apply(biome); + } + } + return mod; + } + }; this.dimensionFilter = dimensionFilter; } + public void setOriginalModifiers(List modifiers) { + this.originalModifiers = modifiers; + this.biomeWeightModifier = new BiomeWeightModifier(HolderSet.direct(originalModifiers.stream().flatMap(mod -> mod.biomes.stream()).toList()), originalModifiers.stream().mapToInt(mod -> mod.addedWeight).sum()) { + @Override + public Integer apply(Holder biome) { + int mod = 0; + for (var modifier : originalModifiers) { + if (modifier.biomes.contains(biome)) { + mod += modifier.apply(biome); + } + } + return mod; + } + }; + } + + public static Builder builder(ResourceLocation name) { + return new Builder(name); + } + @Accessors(chain = true, fluent = true) public static class Builder { private final ResourceLocation name; @@ -65,18 +122,14 @@ public static class Builder { private int depletedYield; // yield after the vein is depleted @Setter private Supplier fluid; // the fluid which the vein contains - private final Set dimensions = new HashSet<>(); - private final Map biomes = new HashMap<>(); - private final Map, Integer> biomeTags = new HashMap<>(); + @Setter + private HolderSet dimensions; + private final List biomes = new LinkedList<>(); private Builder(ResourceLocation name) { this.name = name; } - public static Builder create(ResourceLocation name) { - return new Builder(name); - } - public Builder copy(ResourceLocation name) { var copied = new Builder(name); copied.weight = weight; @@ -93,59 +146,25 @@ public Builder yield(int min, int max) { return minimumYield(min).maximumYield(max); } - @SafeVarargs - public final Builder dimensions(ResourceKey... levels) { - for (ResourceKey level : levels) { - dimensions.add(level.location()); - } - return this; - } - - public final Builder dimensions(ResourceLocation... levels) { - dimensions.addAll(Arrays.asList(levels)); - return this; - } - - @SafeVarargs - public final Builder biomes(int weight, TagKey... biomes) { - for (var biome : biomes) { - this.biomeTags.put(biome, weight); - } + public Builder biomes(int weight, TagKey biomes) { + this.biomes.add(new BiomeWeightModifier(BuiltinRegistries.BIOME.getOrCreateTag(biomes), weight)); return this; } @SafeVarargs public final Builder biomes(int weight, ResourceKey... biomes) { - for (var biome : biomes) { - this.biomes.put(biome.location(), weight); - } + this.biomes.add(new BiomeWeightModifier(HolderSet.direct(BuiltinRegistries.BIOME::getHolderOrThrow, biomes), weight)); return this; } - public final Builder biomes(int weight, ResourceLocation... biomes) { - for (var biome : biomes) { - this.biomes.put(biome, weight); - } + public Builder biomes(int weight, HolderSet biomes) { + this.biomes.add(new BiomeWeightModifier(biomes, weight)); return this; } public BedrockFluidDefinition register() { - var definition = new BedrockFluidDefinition(name, weight, minimumYield, maximumYield, depletionAmount, depletionChance, depletedYield, fluid, - biomeHolder -> { - for (var biome : biomes.entrySet()) { - if (biomeHolder.is(biome.getKey())) { - return biome.getValue(); - } - } - for (var biome : biomeTags.entrySet()) { - if (biomeHolder.is(biome.getKey())) { - return biome.getValue(); - } - } - return 0; - }, - dimension -> dimensions.isEmpty() || dimensions.contains(dimension.location())); - GTRegistries.BEDROCK_FLUID_DEFINITIONS.register(definition.name, definition); + var definition = new BedrockFluidDefinition(weight, minimumYield, maximumYield, depletionAmount, depletionChance, depletedYield, fluid, biomes, dimensions); + GTRegistries.BEDROCK_FLUID_DEFINITIONS.register(name, definition); return definition; } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/BedrockFluidVeinSaveData.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/BedrockFluidVeinSavedData.java similarity index 91% rename from common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/BedrockFluidVeinSaveData.java rename to common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/BedrockFluidVeinSavedData.java index 25cbfef995..17c136cc65 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/BedrockFluidVeinSaveData.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/BedrockFluidVeinSavedData.java @@ -23,11 +23,11 @@ /** * @author KilaBash * @date 2023/7/11 - * @implNote BedrockFluidVeinSaveData + * @implNote BedrockFluidVeinSavedData */ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -public class BedrockFluidVeinSaveData extends SavedData { +public class BedrockFluidVeinSavedData extends SavedData { public static final int VEIN_CHUNK_SIZE = 8; // veins are 8x8 chunk squares public static final int MAXIMUM_VEIN_OPERATIONS = 100_000; public final HashMap veinFluids = new HashMap<>(); @@ -37,15 +37,15 @@ public class BedrockFluidVeinSaveData extends SavedData { private final ServerLevel serverLevel; - public static BedrockFluidVeinSaveData getOrCreate(ServerLevel serverLevel) { - return serverLevel.getDataStorage().computeIfAbsent(tag -> new BedrockFluidVeinSaveData(serverLevel, tag), () -> new BedrockFluidVeinSaveData(serverLevel), "gtceu_bedrock_fluid"); + public static BedrockFluidVeinSavedData getOrCreate(ServerLevel serverLevel) { + return serverLevel.getDataStorage().computeIfAbsent(tag -> new BedrockFluidVeinSavedData(serverLevel, tag), () -> new BedrockFluidVeinSavedData(serverLevel), "gtceu_bedrock_fluid"); } - public BedrockFluidVeinSaveData(ServerLevel serverLevel) { + public BedrockFluidVeinSavedData(ServerLevel serverLevel) { this.serverLevel = serverLevel; } - public BedrockFluidVeinSaveData(ServerLevel serverLevel, CompoundTag nbt) { + public BedrockFluidVeinSavedData(ServerLevel serverLevel, CompoundTag nbt) { this(serverLevel); var list = nbt.getList("veinInfo", Tag.TAG_COMPOUND); for (Tag tag : list) { @@ -86,7 +86,7 @@ public FluidVeinWorldEntry getFluidVeinWorldEntry(int chunkX, int chunkZ) { int weight = Math.abs(query % totalWeight); for (var fluidDefinition : GTRegistries.BEDROCK_FLUID_DEFINITIONS) { int veinWeight = fluidDefinition.getWeight() + fluidDefinition.getBiomeWeightModifier().apply(biome); - if (veinWeight > 0 && fluidDefinition.getDimensionFilter().test(serverLevel.dimension())) { + if (veinWeight > 0 && (fluidDefinition.getDimensionFilter() == null || fluidDefinition.getDimensionFilter().contains(serverLevel.dimensionTypeRegistration()))) { weight -= veinWeight; if (weight < 0) { definition = fluidDefinition; @@ -123,7 +123,7 @@ public int getTotalWeight(Holder biome) { return biomeWeights.computeIfAbsent(biome, b -> { int totalWeight = 0; for (var definition : GTRegistries.BEDROCK_FLUID_DEFINITIONS) { - if (definition.getDimensionFilter().test(serverLevel.dimension())) { + if (definition.getDimensionFilter() == null || definition.getDimensionFilter().contains(serverLevel.dimensionTypeRegistration())) { totalWeight += definition.getBiomeWeightModifier().apply(biome); totalWeight += definition.getWeight(); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/FluidVeinWorldEntry.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/FluidVeinWorldEntry.java index 40a21acd0b..deb3470613 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/FluidVeinWorldEntry.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockfluid/FluidVeinWorldEntry.java @@ -50,7 +50,7 @@ public CompoundTag writeToNBT() { tag.putInt("fluidYield", fluidYield); tag.putInt("operationsRemaining", operationsRemaining); if (vein != null) { - tag.putString("vein", vein.getName().toString()); + tag.putString("vein", GTRegistries.BEDROCK_FLUID_DEFINITIONS.getKey(vein).toString()); } return tag; } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/BedrockOreVeinSavedData.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/BedrockOreVeinSavedData.java new file mode 100644 index 0000000000..d39546c16c --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/BedrockOreVeinSavedData.java @@ -0,0 +1,247 @@ +package com.gregtechceu.gtceu.api.data.worldgen.bedrockore; + +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.data.chemical.material.Material; +import com.gregtechceu.gtceu.api.data.worldgen.GTOreFeatureEntry; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.SectionPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.Tag; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.saveddata.SavedData; + +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.*; + +/** + * @author KilaBash + * @date 2023/7/11 + * @implNote BedrockFluidVeinSavedData + */ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class BedrockOreVeinSavedData extends SavedData { + public static final int VEIN_CHUNK_SIZE = 3; // veins are 3x3 chunk squares + public static final int MAXIMUM_VEIN_OPERATIONS = 100_000; + public final HashMap veinOres = new HashMap<>(); + + // runtime + private final HashMap, Integer> biomeWeights = new HashMap<>(); + + private final ServerLevel serverLevel; + + public static BedrockOreVeinSavedData getOrCreate(ServerLevel serverLevel) { + return serverLevel.getDataStorage().computeIfAbsent(tag -> new BedrockOreVeinSavedData(serverLevel, tag), () -> new BedrockOreVeinSavedData(serverLevel), "gtceu_bedrock_ore"); + } + + public BedrockOreVeinSavedData(ServerLevel serverLevel) { + this.serverLevel = serverLevel; + } + + public BedrockOreVeinSavedData(ServerLevel serverLevel, CompoundTag nbt) { + this(serverLevel); + var list = nbt.getList("veinInfo", Tag.TAG_COMPOUND); + for (Tag tag : list) { + if (tag instanceof CompoundTag compoundTag) { + var chunkPos = new ChunkPos(compoundTag.getLong("pos")); + veinOres.put(chunkPos, OreVeinWorldEntry.readFromNBT(compoundTag.getCompound("data"))); + } + } + } + + @Override + public CompoundTag save(CompoundTag nbt) { + var oreList = new ListTag(); + for (var entry : veinOres.entrySet()) { + var tag = new CompoundTag(); + tag.putLong("pos", entry.getKey().toLong()); + tag.put("data", entry.getValue().writeToNBT()); + oreList.add(tag); + } + nbt.put("veinInfo", oreList); + return nbt; + } + + /** + * Gets the FluidVeinWorldInfo object associated with the given chunk + * + * @param chunkX X coordinate of desired chunk + * @param chunkZ Z coordinate of desired chunk + * @return The FluidVeinWorldInfo corresponding with the given chunk + */ + public OreVeinWorldEntry getOreVeinWorldEntry(int chunkX, int chunkZ) { + ChunkPos pos = new ChunkPos(chunkX, chunkZ); + if (!veinOres.containsKey(pos)) { + GTOreFeatureEntry definition = null; + int query = RandomSource.create(Objects.hash(96548, chunkX / VEIN_CHUNK_SIZE, chunkZ / VEIN_CHUNK_SIZE)).nextInt(); + var biome = serverLevel.getBiome(new BlockPos(chunkX << 4, 64, chunkZ << 4)); + int totalWeight = getTotalWeight(biome); + if (totalWeight > 0) { + int weight = Math.abs(query % totalWeight); + for (var oreDefinition : GTRegistries.ORE_VEINS) { + int veinWeight = oreDefinition.getWeight() + oreDefinition.getBiomeWeightModifier().apply(biome); + if (veinWeight > 0 && oreDefinition.getDimensionFilter().contains(serverLevel.dimensionTypeRegistration())) { + weight -= veinWeight; + if (weight < 0) { + definition = oreDefinition; + break; + } + } + } + } + + var random = RandomSource.create(31L * 31 * chunkX + chunkZ * 31L + Long.hashCode(serverLevel.getSeed())); + + int maximumYield = 0; + if (definition != null) { + if (definition.getMaximumYield() - definition.getMinimumYield() <= 0) { + maximumYield = definition.getMinimumYield(); + } else { + maximumYield = random.nextInt(definition.getMaximumYield() - definition.getMinimumYield()) + definition.getMinimumYield(); + } + maximumYield = Math.min(maximumYield, definition.getMaximumYield()); + } + veinOres.put(new ChunkPos(chunkX, chunkZ), new OreVeinWorldEntry(definition, maximumYield, MAXIMUM_VEIN_OPERATIONS)); + setDirty(); + } + return veinOres.get(pos); + } + + public void createVein(ChunkPos pos, GTOreFeatureEntry definition) { + if (definition != null) { + int radius = SectionPos.blockToSectionCoord(definition.getClusterSize() / 2f); + for (int x = pos.x - radius; x <= pos.x + radius; ++x) { + for (int z = pos.z - radius; z <= pos.z + radius; ++z) { + ChunkPos pos2 = new ChunkPos(x, z); + if (!veinOres.containsKey(pos2)) { + float distanceFromOriginal = Math.abs(pos.x - x) + Math.abs(pos.z - z); + distanceFromOriginal = distanceFromOriginal == 0 ? 1 : distanceFromOriginal; + distanceFromOriginal = (float) Math.pow(distanceFromOriginal, 2); + + var random = RandomSource.create(31L * 31 * pos2.x + pos2.z * 31L + Long.hashCode(serverLevel.getSeed())); + + int maximumYield = 0; + if ((definition.getMaximumYield() - definition.getMinimumYield()) / distanceFromOriginal <= 0) { + maximumYield = definition.getMinimumYield(); + } else { + maximumYield = (int) (random.nextInt((definition.getMaximumYield() - definition.getMinimumYield()) + definition.getMinimumYield()) / distanceFromOriginal); + maximumYield = Math.max(maximumYield, definition.getMinimumYield()); + } + maximumYield = Math.min(maximumYield, definition.getMaximumYield()); + + veinOres.put(pos2, new OreVeinWorldEntry(definition, maximumYield, MAXIMUM_VEIN_OPERATIONS)); + } + + } + } + } + } + + /** + * Gets the total weight of all veins for the given dimension ID and biome type + * + * @param biome The biome type to check + * @return The total weight associated with the dimension/biome pair + */ + public int getTotalWeight(Holder biome) { + return biomeWeights.computeIfAbsent(biome, b -> { + int totalWeight = 0; + for (var definition : GTRegistries.ORE_VEINS) { + if (definition.getDimensionFilter().contains(serverLevel.dimensionTypeRegistration())) { + totalWeight += definition.getBiomeWeightModifier().apply(biome); + totalWeight += definition.getWeight(); + } + } + return totalWeight; + }); + } + + /** + * gets the fluid yield in a specific chunk + * + * @param chunkX X coordinate of desired chunk + * @param chunkZ Z coordinate of desired chunk + * @return yield in the vein + */ + public int getOreYield(int chunkX, int chunkZ) { + return getOreVeinWorldEntry(chunkX, chunkZ).getOreYield(); + } + + /** + * Gets the yield of fluid in the chunk after the vein is completely depleted + * + * @param chunkX X coordinate of desired chunk + * @param chunkZ Z coordinate of desired chunk + * @return yield of fluid post depletion + */ + public int getDepletedOreYield(int chunkX, int chunkZ) { + OreVeinWorldEntry info = getOreVeinWorldEntry(chunkX, chunkZ); + if (info.getDefinition() == null) return 0; + return info.getDefinition().getDepletedYield(); + } + + /** + * Gets the current operations remaining in a specific chunk's vein + * + * @param chunkX X coordinate of desired chunk + * @param chunkZ Z coordinate of desired chunk + * @return amount of operations in the given chunk + */ + public int getOperationsRemaining(int chunkX, int chunkZ) { + return getOreVeinWorldEntry(chunkX, chunkZ).getOperationsRemaining(); + } + + /** + * Gets the Fluid in a specific chunk's vein + * + * @param chunkX X coordinate of desired chunk + * @param chunkZ Z coordinate of desired chunk + * @return Fluid in given chunk + */ + @Nullable + public List> getOreInChunk(int chunkX, int chunkZ) { + OreVeinWorldEntry info = getOreVeinWorldEntry(chunkX, chunkZ); + if (info.getDefinition() == null) return null; + return info.getDefinition().getBedrockVeinMaterials(); + } + + /** + * Depletes fluid from a given chunk + * + * @param chunkX Chunk x + * @param chunkZ Chunk z + * @param amount the amount of fluid to deplete the vein by + * @param ignoreVeinStats whether to ignore the vein's depletion data, if false ignores amount + */ + public void depleteVein(int chunkX, int chunkZ, int amount, boolean ignoreVeinStats) { + OreVeinWorldEntry info = getOreVeinWorldEntry(chunkX, chunkZ); + + if (ignoreVeinStats) { + info.decreaseOperations(amount); + if (amount != 0) { + setDirty(); + } + return; + } + + GTOreFeatureEntry definition = info.getDefinition(); + + // prevent division by zero, veins that never deplete don't need updating + if (definition == null || definition.getDepletionChance() == 0) + return; + + if (definition.getDepletionChance() == 100 || GTValues.RNG.nextInt(100) <= definition.getDepletionChance()) { + info.decreaseOperations(definition.getDepletionAmount()); + setDirty(); + } + } + +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/OreVeinWorldEntry.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/OreVeinWorldEntry.java new file mode 100644 index 0000000000..3c75362d3e --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/OreVeinWorldEntry.java @@ -0,0 +1,70 @@ +package com.gregtechceu.gtceu.api.data.worldgen.bedrockore; + +import com.gregtechceu.gtceu.api.data.worldgen.GTOreFeatureEntry; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import lombok.Getter; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * @author KilaBash + * @date 2023/7/11 + * @implNote FluidVeinWorldEntry + */ +public class OreVeinWorldEntry { + @Nullable + @Getter + private GTOreFeatureEntry vein; + @Getter + private int oreYield; + @Getter + private int operationsRemaining; + + public OreVeinWorldEntry(@Nullable GTOreFeatureEntry vein, int oreYield, int operationsRemaining) { + this.vein = vein; + this.oreYield = oreYield; + this.operationsRemaining = operationsRemaining; + } + + private OreVeinWorldEntry() { + + } + + public GTOreFeatureEntry getDefinition() { + return this.vein; + } + + @SuppressWarnings("unused") + public void setOperationsRemaining(int amount) { + this.operationsRemaining = amount; + } + + public void decreaseOperations(int amount) { + operationsRemaining = Math.max(0, operationsRemaining - amount); + } + + public CompoundTag writeToNBT() { + var tag = new CompoundTag(); + tag.putInt("oreYield", oreYield); + tag.putInt("operationsRemaining", operationsRemaining); + if (vein != null) { + tag.putString("vein", GTRegistries.ORE_VEINS.getKey(vein).toString()); + } + return tag; + } + + @Nonnull + public static OreVeinWorldEntry readFromNBT(@Nonnull CompoundTag tag) { + OreVeinWorldEntry info = new OreVeinWorldEntry(); + info.oreYield = tag.getInt("oreYield"); + info.operationsRemaining = tag.getInt("operationsRemaining"); + + if (tag.contains("vein")) { + info.vein = GTRegistries.ORE_VEINS.get(new ResourceLocation(tag.getString("vein"))); + } + return info; + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/BiomeFilter.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/BiomeFilter.java index e47617d6e8..20be6bf648 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/BiomeFilter.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/BiomeFilter.java @@ -30,7 +30,7 @@ protected boolean shouldPlace(PlacementContext context, RandomSource random, Blo if (placedFeature.feature().value().config() instanceof GTOreFeatureConfiguration configuration) { GTOreFeatureEntry entry = configuration.getEntry(context.getLevel(), context.getLevel().getBiome(pos), random); if (entry == null) return false; - HolderSet checkingBiomes = entry.biomes; + HolderSet checkingBiomes = entry.getBiomes(); Holder holder = context.getLevel().getBiome(pos); if (checkingBiomes != null && !checkingBiomes.contains(holder)) { // VeinCountFilter.didNotPlace(context.getLevel(), pos, entry); diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/VeinCountFilter.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/VeinCountFilter.java index 63aa3978c8..106d996ac9 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/VeinCountFilter.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/VeinCountFilter.java @@ -34,13 +34,13 @@ protected boolean shouldPlace(PlacementContext context, RandomSource random, Blo ChunkPos chunkPos = new ChunkPos(pos); GTOreFeatureEntry entry = configuration.getEntry(context.getLevel(), context.getLevel().getBiome(pos), random); if (entry == null) return false; - Cell startCell = new Cell(context.getLevel().getLevel(), entry.layer, chunkPos); + Cell startCell = new Cell(context.getLevel().getLevel(), entry.getLayer(), chunkPos); // Search for a radius of (default 3) chunks for other veins, to avoid veins getting too close to eachother (they may originate in weird places) int radius = ConfigHolder.INSTANCE.worldgen.oreVeinScanRadius; for (int x = -radius; x <= radius; ++x) { for (int z = -radius; z <= radius; ++z) { ChunkPos chunkPos2 = new ChunkPos(chunkPos.x + x, chunkPos.z + z); - Cell mapCell = new Cell(context.getLevel().getLevel(), entry.layer, chunkPos2); + Cell mapCell = new Cell(context.getLevel().getLevel(), entry.getLayer(), chunkPos2); if (GENERATED.containsKey(mapCell)) { //GTCEu.LOGGER.info("CAN NOT place vein " + entry.id + " at chunk " + chunkPos + ", as there is already a vein nearby."); configuration.setEntry(null); @@ -56,7 +56,7 @@ protected boolean shouldPlace(PlacementContext context, RandomSource random, Blo } public static void didNotPlace(WorldGenLevel level, BlockPos pos, GTOreFeatureEntry entry) { - GENERATED.remove(new Cell(level.getLevel().getLevel(), entry.layer, new ChunkPos(pos))); + GENERATED.remove(new Cell(level.getLevel().getLevel(), entry.getLayer(), new ChunkPos(pos))); } public static VeinCountFilter count() { diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/WorldGeneratorUtils.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/WorldGeneratorUtils.java index 66285dd4b4..c7ba029b0f 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/WorldGeneratorUtils.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/WorldGeneratorUtils.java @@ -3,6 +3,7 @@ import com.google.common.collect.HashBiMap; import com.gregtechceu.gtceu.api.data.worldgen.GTOreFeatureEntry; import com.gregtechceu.gtceu.api.data.worldgen.IWorldGenLayer; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.data.recipe.CustomTags; import com.mojang.serialization.Codec; import net.minecraft.core.Holder; @@ -15,6 +16,7 @@ import java.util.*; import java.util.Map.Entry; +import java.util.function.Function; import java.util.stream.Collectors; public class WorldGeneratorUtils { @@ -24,6 +26,7 @@ public class WorldGeneratorUtils { public static final Map WORLD_GEN_LAYERS = new HashMap<>(); public static final HashBiMap> VEIN_GENERATORS = HashBiMap.create(); + public static final HashBiMap> VEIN_GENERATOR_FUNCTIONS = HashBiMap.create(); private static class WorldOreVeinCache { @@ -31,8 +34,8 @@ private static class WorldOreVeinCache { private final List> veins = new LinkedList<>(); public WorldOreVeinCache(WorldGenLevel level) { - this.worldVeins = GTOreFeatureEntry.ALL.values().stream() - .filter(entry -> entry.dimensionFilter.stream().anyMatch(filter -> filter.is(level.getLevel().dimensionTypeId()))) + this.worldVeins = GTRegistries.ORE_VEINS.values().stream() + .filter(entry -> entry.getDimensionFilter().stream().anyMatch(filter -> filter.is(level.getLevel().dimensionTypeId()))) .collect(Collectors.toList()); } @@ -44,7 +47,7 @@ private List> getEntry(Holder biome) { HolderSet checkingBiomes = entry.datagenExt().biomes.map(left -> left, right -> BuiltinRegistries.BIOME.getTag(right).orElse(null)); return checkingBiomes != null && checkingBiomes.contains(context); })*/ - .map(vein -> new AbstractMap.SimpleEntry<>(vein.weight + (vein.biomeWeightModifier == null ? 0 : vein.biomeWeightModifier.apply(biome)), vein)) + .map(vein -> new AbstractMap.SimpleEntry<>(vein.getWeight() + (vein.getBiomeWeightModifier() == null ? 0 : vein.getBiomeWeightModifier().apply(biome)), vein)) .filter(entry -> entry.getKey() > 0) .collect(Collectors.toList()); veins.addAll(result); diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/gui/misc/ProspectorMode.java b/common/src/main/java/com/gregtechceu/gtceu/api/gui/misc/ProspectorMode.java index 3b7ef0dbf0..2eb8ce409a 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/gui/misc/ProspectorMode.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/gui/misc/ProspectorMode.java @@ -1,12 +1,16 @@ package com.gregtechceu.gtceu.api.gui.misc; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; +import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.stack.UnificationEntry; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.api.data.tag.TagUtil; -import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidVeinSaveData; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidVeinSavedData; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreVeinSavedData; import com.gregtechceu.gtceu.api.gui.texture.ProspectingTexture; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTMaterials; +import com.gregtechceu.gtceu.config.ConfigHolder; import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture; import com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture; import com.lowdragmc.lowdraglib.side.fluid.FluidHelper; @@ -24,10 +28,8 @@ import org.apache.commons.lang3.ArrayUtils; import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Stream; /** * @author KilaBash @@ -126,11 +128,13 @@ public Class getItemClass() { } @Override - public void appendTooltips(String[] items, List tooltips, String selected) { + public void appendTooltips(List items, List tooltips, String selected) { Map counter = new HashMap<>(); - for (var item : items) { - if (ProspectingTexture.SELECTED_ALL.equals(selected) || selected.equals(getUniqueID(item))) { - counter.put(item, counter.getOrDefault(item, 0) + 1); + for (var array : items) { + for (String item : array) { + if (ProspectingTexture.SELECTED_ALL.equals(selected) || selected.equals(getUniqueID(item))) { + counter.put(item, counter.getOrDefault(item, 0) + 1); + } } } counter.forEach((item, count) -> tooltips.add(Component.translatable(getDescriptionId(item)).append(" --- " + count))); @@ -145,9 +149,9 @@ public record FluidInfo(Fluid fluid, int left, int yield) { @Override public void scan(FluidInfo[][][] storage, LevelChunk chunk) { if (chunk.getLevel() instanceof ServerLevel serverLevel) { - var fluidVein = BedrockFluidVeinSaveData.getOrCreate(serverLevel).getFluidVeinWorldEntry(chunk.getPos().x, chunk.getPos().z); + var fluidVein = BedrockFluidVeinSavedData.getOrCreate(serverLevel).getFluidVeinWorldEntry(chunk.getPos().x, chunk.getPos().z); if (fluidVein.getDefinition() != null) { - var left = 100 * fluidVein.getOperationsRemaining() / BedrockFluidVeinSaveData.MAXIMUM_VEIN_OPERATIONS; + var left = 100 * fluidVein.getOperationsRemaining() / BedrockFluidVeinSavedData.MAXIMUM_VEIN_OPERATIONS; storage[0][0] = new FluidInfo[] { new FluidInfo(fluidVein.getDefinition().getStoredFluid().get(), left, fluidVein.getFluidYield()), }; @@ -193,9 +197,86 @@ public Class getItemClass() { } @Override - public void appendTooltips(FluidInfo[] items, List tooltips, String selected) { - for (FluidInfo item : items) { - tooltips.add(Component.translatable(getDescriptionId(item)).append(" --- %s (%s%%)".formatted(item.yield, item.left))); + public void appendTooltips(List items, List tooltips, String selected) { + for (var array : items) { + for (FluidInfo item : array) { + tooltips.add(Component.translatable(getDescriptionId(item)).append(" --- %s (%s%%)".formatted(item.yield, item.left))); + } + } + } + + }; + + public record OreInfo(Material material, int weight, int left, int yield) { + + } + + public static ProspectorMode BEDROCK_ORE = new ProspectorMode<>("metaitem.prospector.mode.bedrock_ore", 1) { + @Override + public void scan(OreInfo[][][] storage, LevelChunk chunk) { + if (chunk.getLevel() instanceof ServerLevel serverLevel) { + var oreVein = BedrockOreVeinSavedData.getOrCreate(serverLevel).getOreVeinWorldEntry(chunk.getPos().x, chunk.getPos().z); + if (oreVein.getDefinition() != null) { + var left = 100 * oreVein.getOperationsRemaining() / BedrockOreVeinSavedData.MAXIMUM_VEIN_OPERATIONS; + for (var entry : oreVein.getDefinition().getBedrockVeinMaterials()) { + storage[0][0] = ArrayUtils.add(storage[0][0], new OreInfo(entry.getValue(), entry.getKey(), left, oreVein.getOreYield())); + } + } + } + } + + @Override + public int getItemColor(OreInfo item) { + return item.material.getMaterialRGB(); + } + + + @Override + public IGuiTexture getItemIcon(OreInfo item) { + Material material = item.material; + ItemStack stack = ChemicalHelper.get(TagPrefix.get(ConfigHolder.INSTANCE.machines.bedrockOreDropTagPrefix), material); + if (stack.isEmpty()) stack = ChemicalHelper.get(TagPrefix.crushed, material); // backup 1: crushed; if raw ore doesn't exist + if (stack.isEmpty()) stack = ChemicalHelper.get(TagPrefix.gem, material); // backup 2: gem; if crushed ore doesn't exist + if (stack.isEmpty()) stack = ChemicalHelper.get(TagPrefix.ore, material); // backup 3: just fallback to normal ore... + return new ItemStackTexture(stack).scale(0.8f); + } + + @Override + public String getDescriptionId(OreInfo item) { + return item.material.getUnlocalizedName(); + } + + @Override + public String getUniqueID(OreInfo item) { + return item.material.getName(); + } + + @Override + public void serialize(OreInfo item, FriendlyByteBuf buf) { + buf.writeUtf(GTRegistries.MATERIALS.getKey(item.material)); + buf.writeVarInt(item.weight); + buf.writeVarInt(item.left); + buf.writeVarInt(item.yield); + } + + @Override + public OreInfo deserialize(FriendlyByteBuf buf) { + return new OreInfo(GTRegistries.MATERIALS.get(buf.readUtf()), buf.readVarInt(), buf.readVarInt(), buf.readVarInt()); + } + + @Override + public Class getItemClass() { + return OreInfo.class; + } + + @Override + public void appendTooltips(List items, List tooltips, String selected) { + for (var array : items) { + int totalWeight = Arrays.stream(array).mapToInt(OreInfo::weight).sum(); + for (OreInfo item : array) { + float chance = (float) item.weight / totalWeight * 100; + tooltips.add(Component.translatable(getDescriptionId(item)).append(" (").append(Component.translatable("gtceu.gui.content.chance_1", String.format("%.1f", chance) + "%")).append(") --- %s (%s%%)".formatted(item.yield, item.left))); + } } } @@ -217,5 +298,5 @@ public void appendTooltips(FluidInfo[] items, List tooltips, String s public abstract void serialize(T item, FriendlyByteBuf buf); public abstract T deserialize(FriendlyByteBuf buf); public abstract Class getItemClass(); - public abstract void appendTooltips(T[] items, List tooltips, String selected); + public abstract void appendTooltips(List items, List tooltips, String selected); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/AutoOutputConfigurator.java b/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/AutoOutputConfigurator.java index 5ecdd007f3..4d8eacbf4c 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/AutoOutputConfigurator.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/AutoOutputConfigurator.java @@ -123,8 +123,8 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { var lastSide = this.side; var result = super.mouseClicked(mouseX, mouseY, button); if (isMouseOverElement(mouseX, mouseY) && this.side == lastSide && this.side != null) { - var hover= sceneWidget.getHoverPosFace(); - if (hover != null && hover.pos.equals(machine.getPos()) && hover.facing == this.side) { + var hover = sceneWidget.getHoverPosFace(); + if (hover != null && hover.pos.equals(machine.getPos()) && hover.facing == this.side && machine.canSetIoOnSide(side)) { val cd = new ClickData(); writeClientAction(0, buf -> { cd.writeToBuf(buf); diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ProspectingMapWidget.java b/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ProspectingMapWidget.java index a4a8df7d7a..444689f9cd 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ProspectingMapWidget.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ProspectingMapWidget.java @@ -112,7 +112,7 @@ private void addNewItem(String uniqueID, String renderingName, IGuiTexture icon, var selectableWidgetGroup = new SelectableWidgetGroup(0, index * 15, itemList.getSize().width - 4, 15); var size = selectableWidgetGroup.getSize(); selectableWidgetGroup.addWidget(new ImageWidget(0, 0, 15, 15, icon)); - selectableWidgetGroup.addWidget(new ImageWidget(15, 0, size.width - 15, 15, new TextTexture(renderingName).setColor(color).setDropShadow(false).setWidth(size.width - 15).setType(TextTexture.TextType.LEFT_HIDE))); + selectableWidgetGroup.addWidget(new ImageWidget(15, 0, size.width - 15, 15, new TextTexture(renderingName).setWidth(size.width - 15).setType(TextTexture.TextType.LEFT_HIDE))); selectableWidgetGroup.setOnSelected(s -> { if (isRemote()) { texture.setSelected(uniqueID); @@ -217,15 +217,16 @@ public void drawInForeground(@NotNull PoseStack poseStack, int mouseX, int mouse // draw hover layer List tooltips = new ArrayList<>(); tooltips.add(Component.translatable(mode.unlocalizedName)); + List items = new ArrayList<>(); for (int i = 0; i < mode.cellSize; i++) { for (int j = 0; j < mode.cellSize; j++) { assert texture != null; if (texture.data[cX * mode.cellSize + i][cZ * mode.cellSize + j] != null) { - var items = texture.data[cX * mode.cellSize + i][cZ * mode.cellSize + j]; - mode.appendTooltips(items, tooltips, texture.getSelected()); + items.add(texture.data[cX * mode.cellSize + i][cZ * mode.cellSize + j]); } } } + mode.appendTooltips(items, tooltips, texture.getSelected()); gui.getModularUIGui().setHoverTooltip(tooltips, ItemStack.EMPTY, null, null); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java index de192f2f97..360a8f7b99 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java @@ -404,6 +404,10 @@ public void addCollisionBoundingBox(List collisionList) { collisionList.add(Shapes.block()); } + public boolean canSetIoOnSide(@Nullable Direction direction) { + return !hasFrontFacing() || getFrontFacing() != direction; + } + public Direction getFrontFacing() { var blockState = getBlockState(); if (blockState.getBlock() instanceof MetaMachineBlock machineBlock) { diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IRecipeLogicMachine.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IRecipeLogicMachine.java index 743228498d..1e3b8b6ec4 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IRecipeLogicMachine.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/feature/IRecipeLogicMachine.java @@ -19,6 +19,11 @@ */ public interface IRecipeLogicMachine extends IRecipeCapabilityHolder, IMachineFeature, IWorkable, ICleanroomReceiver { + @Override + default int getChanceTier() { + return self() instanceof ITieredMachine tieredMachine ? tieredMachine.getTier() : self().getDefinition().getTier(); + } + /** * RecipeType held */ diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/TieredWorkableElectricMultiblockMachine.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/TieredWorkableElectricMultiblockMachine.java new file mode 100644 index 0000000000..42aca58822 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/multiblock/TieredWorkableElectricMultiblockMachine.java @@ -0,0 +1,74 @@ +package com.gregtechceu.gtceu.api.machine.multiblock; + +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; +import com.gregtechceu.gtceu.api.machine.feature.ITieredMachine; +import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted; +import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; +import lombok.Getter; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; + +/** + * @author screret + * @date 2023/7/11 + * @implNote TieredWorkableElectricMultiblockMachine + */ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class TieredWorkableElectricMultiblockMachine extends WorkableElectricMultiblockMachine implements ITieredMachine { + protected static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(TieredWorkableElectricMultiblockMachine.class, WorkableElectricMultiblockMachine.MANAGED_FIELD_HOLDER); + + private final int tier; + @Persisted + @Getter + protected int overclockTier; + + public TieredWorkableElectricMultiblockMachine(IMachineBlockEntity holder, int tier) { + super(holder); + this.tier = tier; + } + + ////////////////////////////////////// + //***** Initialization ******// + ////////////////////////////////////// + @Override + public ManagedFieldHolder getFieldHolder() { + return MANAGED_FIELD_HOLDER; + } + + ////////////////////////////////////// + //******** OVERCLOCK *********// + ////////////////////////////////////// + @Override + public int getMinOverclockTier() { + return 0; + } + + @Override + public void setOverclockTier(int tier) { + if (!isRemote() && tier >= getMinOverclockTier() && tier <= getMaxOverclockTier()) { + this.overclockTier = tier; + this.recipeLogic.markLastRecipeDirty(); + } + } + + @Override + public long getOverclockVoltage() { + return Math.min(GTValues.V[getOverclockTier()], super.getOverclockVoltage()); + } + + ////////////////////////////////////// + //****** RECIPE LOGIC *******// + ////////////////////////////////////// + @Override + public int getTier() { + return Math.min(tier, super.getTier()); + } + + @Override + public long getMaxVoltage() { + return Math.min(GTValues.V[tier], super.getMaxVoltage()); + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/pattern/BlockPattern.java b/common/src/main/java/com/gregtechceu/gtceu/api/pattern/BlockPattern.java index 3318aa9b28..105f7b3be4 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/pattern/BlockPattern.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/pattern/BlockPattern.java @@ -109,7 +109,7 @@ public boolean checkPatternAt(MultiblockState worldState, BlockPos centerPos, Di if (!worldState.update(pos, predicate)) { return false; } - if (!predicate.isAny()) { + if (predicate.addCache()) { worldState.addPosCache(pos); if (savePredicate) { matchContext.getOrCreate("predicates", HashMap::new).put(pos, predicate); diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/pattern/TraceabilityPredicate.java b/common/src/main/java/com/gregtechceu/gtceu/api/pattern/TraceabilityPredicate.java index b42da426ab..8e305aef93 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/pattern/TraceabilityPredicate.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/pattern/TraceabilityPredicate.java @@ -215,6 +215,10 @@ public boolean isAny() { return this.common.size() == 1 && this.limited.isEmpty() && this.common.get(0) == SimplePredicate.ANY; } + public boolean addCache() { + return !isAny(); + } + public boolean isAir() { return this.common.size() == 1 && this.limited.isEmpty() && this.common.get(0) == SimplePredicate.AIR; } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipe.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipe.java index f401ce5d94..ddf98c6809 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipe.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipe.java @@ -253,7 +253,7 @@ public boolean handleRecipe(IO io, IRecipeCapabilityHolder holder, Map(); Map contentSlot = new HashMap<>(); for (Content cont : entry.getValue()) { - if (cont.chance == 1 || GTValues.RNG.nextFloat() < cont.chance) { // chance input + if (cont.chance >= 1 || GTValues.RNG.nextFloat() < (cont.chance + holder.getChanceTier() * cont.tierChanceBoost)) { // chance input if (cont.slotName == null) { content.add(cont.content); } else { diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java index bd83185088..bb437bd94b 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java @@ -51,7 +51,6 @@ public Map, List> capabilitiesFromJson(JsonObject j public @NotNull GTRecipe fromJson(@NotNull ResourceLocation id, @NotNull JsonObject json) { String recipeType = GsonHelper.getAsString(json, "type"); int duration = json.has("duration") ? GsonHelper.getAsInt(json, "duration") : 100; - Component component = json.has("text") ? Component.translatable(GsonHelper.getAsString(json, "text")) : null; CompoundTag data = new CompoundTag(); try { if (json.has("data")) diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/Content.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/Content.java index 12b7e6b4e9..481f835536 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/Content.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/Content.java @@ -14,14 +14,16 @@ public class Content { public Object content; public float chance; + public float tierChanceBoost; @Nullable public String slotName; @Nullable public String uiName; - public Content(Object content, float chance, @Nullable String slotName, @Nullable String uiName) { + public Content(Object content, float chance, float tierChanceBoost, @Nullable String slotName, @Nullable String uiName) { this.content = content; this.chance = chance; + this.tierChanceBoost = tierChanceBoost; this.slotName = slotName; this.uiName = uiName; } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java index 41ea44ca0a..92722abf7d 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/IContentSerializer.java @@ -21,12 +21,14 @@ default T fromNetwork(FriendlyByteBuf buf) { T of(Object o); + T defaultValue(); @SuppressWarnings("unchecked") default void toNetworkContent(FriendlyByteBuf buf, Content content) { T inner = (T) content.getContent(); toNetwork(buf, inner); buf.writeFloat(content.chance); + buf.writeFloat(content.tierChanceBoost); buf.writeBoolean(content.slotName != null); if (content.slotName != null) { buf.writeUtf(content.slotName); @@ -40,6 +42,7 @@ default void toNetworkContent(FriendlyByteBuf buf, Content content) { default Content fromNetworkContent(FriendlyByteBuf buf) { T inner = fromNetwork(buf); float chance = buf.readFloat(); + float tierChanceBoost = buf.readFloat(); String slotName = null; if (buf.readBoolean()) { slotName = buf.readUtf(); @@ -48,7 +51,7 @@ default Content fromNetworkContent(FriendlyByteBuf buf) { if (buf.readBoolean()) { uiName = buf.readUtf(); } - return new Content(inner, chance, slotName, uiName); + return new Content(inner, chance, tierChanceBoost, slotName, uiName); } @SuppressWarnings("unchecked") @@ -56,6 +59,7 @@ default JsonElement toJsonContent(Content content) { JsonObject json = new JsonObject(); json.add("content", toJson((T) content.getContent())); json.addProperty("chance", content.chance); + json.addProperty("tierChanceBoost", content.tierChanceBoost); if (content.slotName != null) json.addProperty("slotName", content.slotName); if (content.uiName != null) @@ -67,8 +71,9 @@ default Content fromJsonContent(JsonElement json) { JsonObject jsonObject = json.getAsJsonObject(); T inner = fromJson(jsonObject.get("content")); float chance = jsonObject.has("chance") ? jsonObject.get("chance").getAsFloat() : 1; + float tierChanceBoost = jsonObject.has("tierChanceBoost") ? jsonObject.get("tierChanceBoost").getAsFloat() : 0; String slotName = jsonObject.has("slotName") ? jsonObject.get("slotName").getAsString() : null; String uiName = jsonObject.has("uiName") ? jsonObject.get("uiName").getAsString() : null; - return new Content(inner, chance, slotName, uiName); + return new Content(inner, chance, tierChanceBoost, slotName, uiName); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerBigInteger.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerBigInteger.java index 994550c13f..198e70f367 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerBigInteger.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerBigInteger.java @@ -46,7 +46,12 @@ public BigInteger of(Object o) { } else if (o instanceof CharSequence) { return new BigInteger(o.toString()); } - return BigInteger.ONE; + return BigInteger.ZERO; + } + + @Override + public BigInteger defaultValue() { + return BigInteger.ZERO; } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerBlockState.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerBlockState.java index 8f0dcb622e..8bec1f7031 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerBlockState.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerBlockState.java @@ -82,4 +82,9 @@ public BlockState of(Object o) { } return Blocks.AIR.defaultBlockState(); } + + @Override + public BlockState defaultValue() { + return Blocks.AIR.defaultBlockState(); + } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerDouble.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerDouble.java index a368d13122..854c1bab3c 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerDouble.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerDouble.java @@ -40,6 +40,11 @@ public Double of(Object o) { } else if (o instanceof CharSequence) { return NumberUtils.toDouble(o.toString(), 1); } - return 1d; + return 0d; + } + + @Override + public Double defaultValue() { + return 0d; } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerFloat.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerFloat.java index 2dbf2a33d1..5185afd61a 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerFloat.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerFloat.java @@ -40,6 +40,11 @@ public Float of(Object o) { } else if (o instanceof CharSequence) { return NumberUtils.toFloat(o.toString(), 1); } - return 1f; + return 0f; + } + + @Override + public Float defaultValue() { + return 0f; } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerFluidStack.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerFluidStack.java index 0dc0cd1977..12c9d7cb3f 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerFluidStack.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerFluidStack.java @@ -70,4 +70,9 @@ public FluidStack of(Object o) { } return FluidStack.empty(); } + + @Override + public FluidStack defaultValue() { + return FluidStack.empty(); + } } \ No newline at end of file diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerIngredient.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerIngredient.java index 611ddd2db0..40ecfb1a0b 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerIngredient.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerIngredient.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.api.recipe.content; import com.google.gson.JsonElement; +import com.gregtechceu.gtceu.api.recipe.ingredient.SizedIngredient; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.tags.TagKey; import net.minecraft.world.item.ItemStack; @@ -34,12 +35,12 @@ public JsonElement toJson(Ingredient content) { } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public Ingredient of(Object o) { if (o instanceof Ingredient ingredient) { return ingredient; } else if (o instanceof ItemStack itemStack) { - return Ingredient.of(itemStack); + return SizedIngredient.create(itemStack); } else if (o instanceof ItemLike itemLike) { return Ingredient.of(itemLike); } else if (o instanceof TagKey tag) { @@ -48,4 +49,9 @@ public Ingredient of(Object o) { return Ingredient.EMPTY; } + @Override + public Ingredient defaultValue() { + return Ingredient.EMPTY; + } + } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerInteger.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerInteger.java index 35ff8766c4..d17903f1d2 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerInteger.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerInteger.java @@ -40,6 +40,11 @@ public Integer of(Object o) { } else if (o instanceof CharSequence) { return NumberUtils.toInt(o.toString(), 1); } - return 1; + return 0; + } + + @Override + public Integer defaultValue() { + return 0; } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerLong.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerLong.java index 248a22a5f2..3b24ac67a2 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerLong.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/content/SerializerLong.java @@ -10,7 +10,7 @@ * @date 2022/06/22 * @implNote SerializerLong */ -public class SerializerLong implements IContentSerializer{ +public class SerializerLong implements IContentSerializer { public static SerializerLong INSTANCE = new SerializerLong(); @@ -45,7 +45,12 @@ public Long of(Object o) { } else if (o instanceof CharSequence) { return NumberUtils.toLong(o.toString(), 1); } - return 1L; + return 0L; + } + + @Override + public Long defaultValue() { + return 0L; } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/SizedIngredient.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/SizedIngredient.java index 505d614a24..fa429be8b6 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/SizedIngredient.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/SizedIngredient.java @@ -73,6 +73,11 @@ public Ingredient getInner() { return inner; } + @ExpectPlatform + public static SizedIngredient fromJson(JsonObject json) { + throw new AssertionError(); + } + @Override public @NotNull JsonElement toJson() { JsonObject json = new JsonObject(); diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java b/common/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java index 974d15262e..74379ec78b 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java @@ -4,6 +4,7 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; import com.gregtechceu.gtceu.api.cover.CoverDefinition; +import com.gregtechceu.gtceu.api.data.worldgen.GTOreFeatureEntry; import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; @@ -39,6 +40,7 @@ public final class GTRegistries { public static final GTRegistry.String> RECIPE_CONDITIONS = new GTRegistry.String<>(GTCEu.id("recipe_condition")); public static final GTRegistry.RL SOUNDS = new GTRegistry.RL<>(GTCEu.id("sound")); public static final GTRegistry.RL BEDROCK_FLUID_DEFINITIONS = new GTRegistry.RL<>(GTCEu.id("bedrock_fluid")); + public static final GTRegistry.RL ORE_VEINS = new GTRegistry.RL<>(GTCEu.id("ore_vein")); @ExpectPlatform public static T register(Registry registry, ResourceLocation name, T value) { diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java index 86f87a0da7..0d9dc8b608 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java @@ -63,15 +63,17 @@ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault @Accessors(chain = true, fluent = true) -public class MachineBuilder { +public class MachineBuilder extends BuilderBase { protected final Registrate registrate; protected final String name; protected final BiFunction blockFactory; protected final BiFunction itemFactory; protected final TriFunction, BlockPos, BlockState, IMachineBlockEntity> blockEntityFactory; - protected final Function metaMachine; - protected final Function definitionFactory; + @Setter + protected Function definitionFactory; // non-final for KJS + @Setter + protected Function metaMachine; // non-final for KJS @Nullable @Setter private Supplier renderer; @@ -93,7 +95,7 @@ public class MachineBuilder { private NonNullConsumer> onBlockEntityRegister = MetaMachineBlockEntity::onBlockEntityRegister; @Setter private GTRecipeType recipeType; - @Setter + @Getter @Setter // getter for KJS private int tier; @Setter private int paintingColor = ConfigHolder.INSTANCE.client.defaultPaintingColor; @@ -107,6 +109,7 @@ public class MachineBuilder { private BiFunction recipeModifier = (machine, recipe) -> recipe; @Setter private boolean alwaysTryModifyRecipe; + @Setter private Supplier appearance; @Setter @Nullable private EditableMachineUI editableUI; @@ -119,6 +122,7 @@ protected MachineBuilder(Registrate registrate, String name, BiFunction blockFactory, BiFunction itemFactory, TriFunction, BlockPos, BlockState, IMachineBlockEntity> blockEntityFactory) { + super(new ResourceLocation(registrate.getModid(), name)); this.registrate = registrate; this.name = name; this.metaMachine = metaMachine; @@ -179,11 +183,6 @@ public MachineBuilder appearanceBlock(Supplier bloc return this; } - public MachineBuilder appearance(Supplier state) { - appearance = state; - return this; - } - public MachineBuilder tooltips(Component... components) { tooltips.addAll(Arrays.stream(components).filter(Objects::nonNull).toList()); return this; diff --git a/common/src/main/java/com/gregtechceu/gtceu/client/model/PipeModel.java b/common/src/main/java/com/gregtechceu/gtceu/client/model/PipeModel.java index da603b11e0..ce49a83545 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/client/model/PipeModel.java +++ b/common/src/main/java/com/gregtechceu/gtceu/client/model/PipeModel.java @@ -4,6 +4,7 @@ import com.lowdragmc.lowdraglib.client.model.ModelFactory; import com.lowdragmc.lowdraglib.client.renderer.IItemRendererProvider; import com.mojang.blaze3d.vertex.PoseStack; +import lombok.Setter; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; @@ -23,6 +24,7 @@ import java.util.*; import java.util.function.Consumer; +import java.util.function.Supplier; /** * @author KilaBash @@ -35,13 +37,16 @@ public class PipeModel { public final AABB coreCube; public final Map sideCubes; - public ResourceLocation coreTexture; + public Supplier sideTexture, endTexture; + @Setter + public ResourceLocation endOverlayTexture; @Environment(EnvType.CLIENT) - TextureAtlasSprite coreSprite; + TextureAtlasSprite sideSprite, endSprite, endOverlaySprite; - public PipeModel(float thickness, ResourceLocation coreTexture) { - this.coreTexture = coreTexture; + public PipeModel(float thickness, Supplier sideTexture, Supplier endTexture) { + this.sideTexture = sideTexture; + this.endTexture = endTexture; this.thickness = thickness; double min = (1d - thickness) / 2; double max = min + thickness; @@ -76,17 +81,27 @@ public boolean isConnected(int connections, Direction side) { @Environment(EnvType.CLIENT) public List bakeQuads(@Nullable Direction side, int connections) { - if (coreSprite == null) { - coreSprite = ModelFactory.getBlockSprite(coreTexture); + if (sideSprite == null) { + sideSprite = ModelFactory.getBlockSprite(sideTexture.get()); + } + if (endSprite == null) { + endSprite = ModelFactory.getBlockSprite(endTexture.get()); + } + if (endOverlayTexture != null && endOverlaySprite == null) { + endOverlaySprite = ModelFactory.getBlockSprite(endOverlayTexture); } if (side != null) { if (thickness == 1) { // full block - return List.of(FaceQuad.builder(side, coreSprite).cube(coreCube).cubeUV().tintIndex(0).bake()); + return List.of(FaceQuad.builder(side, sideSprite).cube(coreCube).cubeUV().tintIndex(0).bake()); } if (isConnected(connections, side)) { // side connected - return List.of(FaceQuad.builder(side, coreSprite).cube(sideCubes.get(side).inflate(-0.001)).cubeUV().tintIndex(0).bake()); + BakedQuad base = FaceQuad.builder(side, endSprite).cube(sideCubes.get(side).inflate(-0.001)).cubeUV().tintIndex(1).bake(); + if (endOverlaySprite != null) { + return List.of(base, FaceQuad.builder(side, endOverlaySprite).cube(sideCubes.get(side).inflate(-0.000)).cubeUV().tintIndex(0).bake()); + } + return List.of(base); } return Collections.emptyList(); @@ -97,13 +112,16 @@ public List bakeQuads(@Nullable Direction side, int connections) { // render core cube for (Direction face : Direction.values()) { if (!isConnected(connections, face)) { - quads.add(FaceQuad.builder(face, coreSprite).cube(coreCube).cubeUV().tintIndex(0).bake()); + quads.add(FaceQuad.builder(face, sideSprite).cube(coreCube).cubeUV().tintIndex(0).bake()); } // render each connected side for (Direction facing : Direction.values()) { if (facing.getAxis() != face.getAxis()) { if (isConnected(connections, facing)) { - quads.add(FaceQuad.builder(face, coreSprite).cube(sideCubes.get(facing)).cubeUV().tintIndex(0).bake()); + quads.add(FaceQuad.builder(face, sideSprite).cube(sideCubes.get(facing)).cubeUV().tintIndex(0).bake()); + //if (endSpriteOverlay != null) { + // quads.add(FaceQuad.builder(face, endSpriteOverlay).cube(sideCubes.get(facing).inflate(0.01)).cubeUV().tintIndex(0).bake()); + //} } } } @@ -115,10 +133,10 @@ public List bakeQuads(@Nullable Direction side, int connections) { @NotNull @Environment(EnvType.CLIENT) public TextureAtlasSprite getParticleTexture() { - if (coreSprite == null) { - coreSprite = ModelFactory.getBlockSprite(coreTexture); + if (sideSprite == null) { + sideSprite = ModelFactory.getBlockSprite(sideTexture.get()); } - return coreSprite; + return sideSprite; } @Environment(EnvType.CLIENT) @@ -131,7 +149,11 @@ public void renderItem(ItemStack stack, ItemTransforms.TransformType transformTy @Environment(EnvType.CLIENT) public void registerTextureAtlas(Consumer register) { - register.accept(coreTexture); - coreSprite = null; + register.accept(sideTexture.get()); + register.accept(endTexture.get()); + if (endOverlayTexture != null) register.accept(endOverlayTexture); + sideSprite = null; + endSprite = null; + endOverlaySprite = null; } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java b/common/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java index 2dd1ae7267..36a05291fe 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java +++ b/common/src/main/java/com/gregtechceu/gtceu/client/renderer/block/PipeBlockRenderer.java @@ -7,6 +7,8 @@ import com.lowdragmc.lowdraglib.client.model.ModelFactory; import com.lowdragmc.lowdraglib.client.renderer.IRenderer; import com.mojang.blaze3d.vertex.PoseStack; +import lombok.Getter; +import lombok.Setter; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.renderer.MultiBufferSource; @@ -36,6 +38,7 @@ */ public class PipeBlockRenderer implements IRenderer, ICoverableRenderer { + @Getter PipeModel pipeModel; public PipeBlockRenderer(PipeModel pipeModel) { diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/block/CableBlock.java b/common/src/main/java/com/gregtechceu/gtceu/common/block/CableBlock.java index 1fa1630739..26003b0b5d 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/block/CableBlock.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/block/CableBlock.java @@ -50,7 +50,7 @@ public CableBlock(Properties properties, Insulation insulation, Material materia @Override public int tinted(BlockState blockState, @Nullable BlockAndTintGetter blockAndTintGetter, @Nullable BlockPos blockPos, int index) { - if (pipeType.isCable) { + if (pipeType.isCable && index == 0) { return 0x404040; } return material.getMaterialRGB(); diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBedrockFluids.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBedrockFluids.java index 5750343dbc..2bfdb3ced2 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBedrockFluids.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTBedrockFluids.java @@ -2,8 +2,10 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; +import com.gregtechceu.gtceu.data.recipe.CustomTags; +import net.minecraft.core.HolderSet; +import net.minecraft.data.BuiltinRegistries; import net.minecraft.tags.BiomeTags; -import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.Biomes; /** @@ -15,7 +17,7 @@ public class GTBedrockFluids { ////////////////////////////////////// //******** OVERWORLD ********// ////////////////////////////////////// - public static BedrockFluidDefinition HEAVY_OIL = BedrockFluidDefinition.Builder.create(GTCEu.id("heavy_oil_deposit")) + public static BedrockFluidDefinition HEAVY_OIL = BedrockFluidDefinition.builder(GTCEu.id("heavy_oil_deposit")) .fluid(GTMaterials.OilHeavy::getFluid) .weight(15) .yield(100, 200) @@ -23,10 +25,10 @@ public class GTBedrockFluids { .depletionChance(100) .depletedYield(20) .biomes(5, BiomeTags.IS_OCEAN) - .biomes(10, BiomeTags.IS_BEACH) + .biomes(10, CustomTags.IS_SANDY) .register(); - public static BedrockFluidDefinition LIGHT_OIL = BedrockFluidDefinition.Builder.create(GTCEu.id("light_oil_deposit")) + public static BedrockFluidDefinition LIGHT_OIL = BedrockFluidDefinition.builder(GTCEu.id("light_oil_deposit")) .fluid(GTMaterials.OilLight::getFluid) .weight(25) .yield(175, 300) @@ -35,7 +37,7 @@ public class GTBedrockFluids { .depletedYield(25) .register(); - public static BedrockFluidDefinition NATURAL_GAS = BedrockFluidDefinition.Builder.create(GTCEu.id("natural_gas_deposit")) + public static BedrockFluidDefinition NATURAL_GAS = BedrockFluidDefinition.builder(GTCEu.id("natural_gas_deposit")) .fluid(GTMaterials.NaturalGas::getFluid) .weight(15) .yield(100, 175) @@ -44,7 +46,7 @@ public class GTBedrockFluids { .depletedYield(20) .register(); - public static BedrockFluidDefinition OIL = BedrockFluidDefinition.Builder.create(GTCEu.id("oil_deposit")) + public static BedrockFluidDefinition OIL = BedrockFluidDefinition.builder(GTCEu.id("oil_deposit")) .fluid(GTMaterials.Oil::getFluid) .weight(20) .yield(175, 300) @@ -52,10 +54,10 @@ public class GTBedrockFluids { .depletionChance(100) .depletedYield(25) .biomes(5, BiomeTags.IS_OCEAN) - .biomes(5, BiomeTags.IS_BEACH) + .biomes(5, CustomTags.IS_SANDY) .register(); - public static BedrockFluidDefinition RAW_OIL = BedrockFluidDefinition.Builder.create(GTCEu.id("raw_oil_deposit")) + public static BedrockFluidDefinition RAW_OIL = BedrockFluidDefinition.builder(GTCEu.id("raw_oil_deposit")) .fluid(GTMaterials.RawOil::getFluid) .weight(20) .yield(200, 300) @@ -64,7 +66,7 @@ public class GTBedrockFluids { .depletedYield(25) .register(); - public static BedrockFluidDefinition SALT_WATER = BedrockFluidDefinition.Builder.create(GTCEu.id("salt_water_deposit")) + public static BedrockFluidDefinition SALT_WATER = BedrockFluidDefinition.builder(GTCEu.id("salt_water_deposit")) .fluid(GTMaterials.SaltWater::getFluid) .weight(0) .yield(50, 100) @@ -78,24 +80,24 @@ public class GTBedrockFluids { ////////////////////////////////////// //******** OVERWORLD ********// ////////////////////////////////////// - public static BedrockFluidDefinition LAVA = BedrockFluidDefinition.Builder.create(GTCEu.id("lava_deposit")) + public static BedrockFluidDefinition LAVA = BedrockFluidDefinition.builder(GTCEu.id("lava_deposit")) .fluid(GTMaterials.Lava::getFluid) .weight(65) .yield(125, 250) .depletionAmount(1) .depletionChance(100) .depletedYield(30) - .dimensions(Level.NETHER) + .dimensions(GTOres.nether()) .register(); - public static BedrockFluidDefinition NETHER_NATURAL_GAS = BedrockFluidDefinition.Builder.create(GTCEu.id("nether_natural_gas_deposit")) + public static BedrockFluidDefinition NETHER_NATURAL_GAS = BedrockFluidDefinition.builder(GTCEu.id("nether_natural_gas_deposit")) .fluid(GTMaterials.NaturalGas::getFluid) .weight(35) .yield(150, 300) .depletionAmount(1) .depletionChance(100) .depletedYield(40) - .dimensions(Level.NETHER) + .dimensions(GTOres.nether()) .register(); public static void init() { diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java index 896cd27148..b8fb4f6df3 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java @@ -26,6 +26,7 @@ import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.api.data.tag.TagUtil; +import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.lang.LangHandler; import com.gregtechceu.gtceu.data.recipe.CustomTags; import com.lowdragmc.lowdraglib.side.fluid.FluidHelper; @@ -1045,11 +1046,11 @@ public static ICustomDescriptionId cellName() { public static ItemEntry PROSPECTOR_HV = REGISTRATE.item("prospector.hv", ComponentItem::create) .lang("Advanced Prospector (HV)") .properties(p -> p.stacksTo(1)) - .onRegister(attach(ElectricStats.createElectricItem(1_600_000L, GTValues.HV), new ProspectorScannerBehavior(3, GTValues.V[GTValues.HV] / 16L, ProspectorMode.ORE, ProspectorMode.FLUID))).register(); + .onRegister(attach(ElectricStats.createElectricItem(1_600_000L, GTValues.HV), new ProspectorScannerBehavior(3, GTValues.V[GTValues.HV] / 16L, ProspectorMode.ORE, ProspectorMode.FLUID, ConfigHolder.INSTANCE.machines.doBedrockOres ? ProspectorMode.BEDROCK_ORE : null))).register(); public static ItemEntry PROSPECTOR_LUV = REGISTRATE.item("prospector.luv", ComponentItem::create) .lang("Super Prospector (LuV)") .properties(p -> p.stacksTo(1)) - .onRegister(attach(ElectricStats.createElectricItem(1_000_000_000L, GTValues.LuV), new ProspectorScannerBehavior(5, GTValues.V[GTValues.LuV] / 16L, ProspectorMode.ORE, ProspectorMode.FLUID))).register(); + .onRegister(attach(ElectricStats.createElectricItem(1_000_000_000L, GTValues.LuV), new ProspectorScannerBehavior(5, GTValues.V[GTValues.LuV] / 16L, ProspectorMode.ORE, ProspectorMode.FLUID, ConfigHolder.INSTANCE.machines.doBedrockOres ? ProspectorMode.BEDROCK_ORE : null))).register(); public static ItemEntry TRICORDER_SCANNER; public static ItemEntry DEBUG_SCANNER; diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java index b9bdb364a0..a901fa0ff9 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java @@ -1,5 +1,7 @@ package com.gregtechceu.gtceu.common.data; +import appeng.api.networking.pathing.ChannelMode; +import appeng.core.AEConfig; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.addon.AddonFinder; @@ -275,6 +277,7 @@ public class GTMachines { public static final MachineDefinition[] MINER = registerTieredMachines("miner", (holder, tier) -> new MinerMachine(holder, tier, 320 / (tier * 2), tier * 8, tier), (tier, builder) -> builder .rotationState(RotationState.NON_Y_AXIS) + .langValue("%s Miner %s".formatted(VLVH[tier], VLVT[tier])) .recipeType(GTRecipeTypes.DUMMY_RECIPES) .editableUI(MinerMachine.EDITABLE_UI_CREATOR.apply(GTCEu.id("miner"), (tier + 1) * (tier + 1))) .renderer(() -> new MinerRenderer(tier, GTCEu.id("block/machines/miner"))) @@ -1120,7 +1123,7 @@ public static BiConsumer> createTankTooltips(String n public static final MultiblockMachineDefinition[] FLUID_DRILLING_RIG = registerTieredMultis("fluid_drilling_rig", FluidDrillMachine::new, (tier, builder) -> builder .rotationState(RotationState.NON_Y_AXIS) - .langValue("%s Fusion Drilling Rig".formatted(VLVH[tier])) + .langValue("%s Fluid Drilling Rig".formatted(VLVH[tier])) .recipeType(GTRecipeTypes.DUMMY_RECIPES) .tooltips( Component.translatable("gtceu.machine.fluid_drilling_rig.description"), @@ -1147,6 +1150,7 @@ public static BiConsumer> createTankTooltips(String n public static final MultiblockMachineDefinition[] LARGE_MINER = registerTieredMultis("large_miner", (holder, tier) -> new LargeMinerMachine(holder, tier, 64 / tier, 2 * tier - 5, tier, 8 - (tier - 5)), (tier, builder) -> builder .rotationState(RotationState.NON_Y_AXIS) + .langValue("%s Large Miner".formatted(VLVH[tier])) .recipeType(GTRecipeTypes.MACERATOR_RECIPES) .appearanceBlock(() -> LargeMinerMachine.getCasingState(tier)) .pattern((definition) -> FactoryBlockPattern.start() @@ -1177,6 +1181,8 @@ public static BiConsumer> createTankTooltips(String n .register(), EV, IV, LuV); + public static MultiblockMachineDefinition[] BEDROCK_ORE_MINER; + public static final MultiblockMachineDefinition CLEANROOM = REGISTRATE.multiblock("cleanroom", CleanroomMachine::new) .rotationState(RotationState.NONE) .recipeType(GTRecipeTypes.DUMMY_RECIPES) @@ -1194,8 +1200,7 @@ public static BiConsumer> createTankTooltips(String n tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.7")); //tooltip.add(Component.translatable("gtceu.machine.cleanroom.tooltip.8")); if (LDLib.isModLoaded(GTValues.MODID_APPENG)) { - // TODO ae2 compat - //tooltip.add(Component.translatable(AEConfig.instance().isFeatureEnabled(AEFeature.CHANNELS) ? "gtceu.machine.cleanroom.tooltip.ae2.channels" : "gtceu.machine.cleanroom.tooltip.ae2.no_channels")); + tooltip.add(Component.translatable(AEConfig.instance().getChannelMode() == ChannelMode.INFINITE ? "gtceu.machine.cleanroom.tooltip.ae2.no_channels" : "gtceu.machine.cleanroom.tooltip.ae2.channels")); } tooltip.add(Component.empty()); } else { @@ -1212,7 +1217,7 @@ public static BiConsumer> createTankTooltips(String n .or(blocks(GTBlocks.CLEANROOM_GLASS.get())) .or(abilities(PartAbility.PASSTHROUGH_HATCH).setMaxGlobalLimited(30, 3)) .or(abilities(PartAbility.INPUT_ENERGY).setMinGlobalLimited(1).setMaxGlobalLimited(3, 2)) - .or(blocks(ConfigHolder.INSTANCE.machines.enableMaintenance ? GTMachines.MAINTENANCE_HATCH.getBlock() : PLASTCRETE.get()).setMinGlobalLimited(1).setMaxGlobalLimited(1)) + .or(blocks(ConfigHolder.INSTANCE.machines.enableMaintenance ? GTMachines.MAINTENANCE_HATCH.getBlock() : PLASTCRETE.get()).setExactLimit(1)) .or(blocks(Blocks.IRON_DOOR).setMaxGlobalLimited(8))) .where('S', controller(blocks(definition.getBlock()))) .where(' ', any()) @@ -1573,6 +1578,33 @@ public static void init() { if (GTCEu.isCreateLoaded()) { new GTCreateMachines(); } + if (ConfigHolder.INSTANCE.machines.doBedrockOres) { + BEDROCK_ORE_MINER = registerTieredMultis("bedrock_ore_miner", BedrockOreMinerMachine::new, (tier, builder) -> builder + .rotationState(RotationState.NON_Y_AXIS) + .langValue("%s Bedrock Ore Miner".formatted(VLVH[tier])) + .recipeType(new GTRecipeType(GTCEu.id("drilling_rig"), "dummy")) + .tooltips( + Component.translatable("gtceu.machine.bedrock_ore_miner.description"), + Component.translatable("gtceu.machine.bedrock_ore_miner.depletion", FormattingUtil.formatNumbers(100.0 / BedrockOreMinerMachine.getDepletionChance(tier))), + Component.translatable("gtceu.universal.tooltip.energy_tier_range", GTValues.VNF[tier], GTValues.VNF[tier + 1]), + Component.translatable("gtceu.machine.bedrock_ore_miner.production", BedrockOreMinerMachine.getRigMultiplier(tier), FormattingUtil.formatNumbers(BedrockOreMinerMachine.getRigMultiplier(tier) * 1.5))) + .appearanceBlock(() -> BedrockOreMinerMachine.getCasingState(tier)) + .pattern((definition) -> FactoryBlockPattern.start() + .aisle("XXX", "#F#", "#F#", "#F#", "###", "###", "###") + .aisle("XXX", "FCF", "FCF", "FCF", "#F#", "#F#", "#F#") + .aisle("XSX", "#F#", "#F#", "#F#", "###", "###", "###") + .where('S', controller(blocks(definition.get()))) + .where('X', blocks(BedrockOreMinerMachine.getCasingState(tier)).setMinGlobalLimited(3) + .or(abilities(PartAbility.INPUT_ENERGY).setMinGlobalLimited(1).setMaxGlobalLimited(3)) + .or(abilities(PartAbility.EXPORT_FLUIDS).setMaxGlobalLimited(1))) + .where('C', blocks(BedrockOreMinerMachine.getCasingState(tier))) + .where('F', blocks(BedrockOreMinerMachine.getFrameState(tier))) + .where('#', any()) + .build()) + .workableCasingRenderer(BedrockOreMinerMachine.getBaseTexture(tier), GTCEu.id("block/multiblock/bedrock_ore_miner"), false) + .register(), + MV, HV, EV); + } AddonFinder.getAddons().forEach(IGTAddon::registerMachines); if (GTCEu.isKubeJSLoaded()) { GTRegistryObjectBuilderTypes.registerFor(GTRegistries.MACHINES.getRegistryName()); diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTOres.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTOres.java index b2769d16ad..2a82625b43 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTOres.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTOres.java @@ -117,13 +117,6 @@ public class GTOres { .build()) .parent(); - public static final GTOreFeatureEntry PISS_VEIN = - create("piss_vein", 25, 0.2f, 10, WorldGenLayers.ENDSTONE, end(), HeightRangePlacement.uniform(VerticalAnchor.absolute(5), VerticalAnchor.absolute(50))) - .biomes(BiomeTags.IS_END) - .standardVeinGenerator() - .withMaterial(Cooperite) - .parent(); - ////////////////////////////////////// //****** Nether Vein *******// ////////////////////////////////////// @@ -576,15 +569,15 @@ private static Supplier ore(TagPrefix oreTag, Material material return block; } - private static HolderSet overworld() { + public static HolderSet overworld() { return HolderSet.direct(BuiltinRegistries.DIMENSION_TYPE.getHolderOrThrow(BuiltinDimensionTypes.OVERWORLD)); } - private static HolderSet nether() { + public static HolderSet nether() { return HolderSet.direct(BuiltinRegistries.DIMENSION_TYPE.getHolderOrThrow(BuiltinDimensionTypes.NETHER)); } - private static HolderSet end() { + public static HolderSet end() { return HolderSet.direct(BuiltinRegistries.DIMENSION_TYPE.getHolderOrThrow(BuiltinDimensionTypes.END)); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeModifiers.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeModifiers.java index 16ce279d58..39049910ea 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeModifiers.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeModifiers.java @@ -165,7 +165,7 @@ public static GTRecipe multiSmelterOverclock(MetaMachine machine, @Nonnull GTRec int parallelValue = result.getB(); recipe.duration = Math.max(1, 256 * parallelValue / maxParallel); long eut = parallelValue * energyCost; - recipe.tickInputs.put(EURecipeCapability.CAP, List.of(new Content(eut, 1.0f, null, null))); + recipe.tickInputs.put(EURecipeCapability.CAP, List.of(new Content(eut, 1.0f, 0.0f, null, null))); return recipe; } return null; diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index 3c298fbcf0..5d36e26d45 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -170,6 +170,7 @@ public class GTRecipeTypes { .setSlotOverlay(true, true, GuiTextures.VIAL_OVERLAY_2) .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, LEFT_TO_RIGHT) .setSound(GTValues.FOOLS.get() ? GTSoundEntries.SCIENCE : GTSoundEntries.CHEMICAL) + .setMaxTooltips(4) // TODO consider allowing LCR to just read these recipes? instead of generating new (minimize extra jsons) .onRecipeBuild((recipeBuilder, provider) -> GTRecipeTypes.LARGE_CHEMICAL_RECIPES.copyFrom(recipeBuilder).save(provider)); @@ -348,7 +349,7 @@ public class GTRecipeTypes { .setMaxTooltips(4) .onRecipeBuild((recipeBuilder, provider) -> { if (recipeBuilder.input.getOrDefault(FluidRecipeCapability.CAP, Collections.emptyList()).isEmpty() && recipeBuilder.tickInput.getOrDefault(FluidRecipeCapability.CAP, Collections.emptyList()).isEmpty()) { - recipeBuilder.copy(new ResourceLocation(recipeBuilder.id.toString() + "_soldering_allory")) + recipeBuilder.copy(new ResourceLocation(recipeBuilder.id.toString() + "_soldering_alloy")) .inputFluids(GTMaterials.SolderingAlloy.getFluid(Math.max(1, (GTValues.L / 2) * recipeBuilder.getSolderMultiplier()))) .save(provider); diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java index 650319760c..234d0d6c32 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java @@ -264,7 +264,7 @@ public static void register() { Gasoline = new Material.Builder("gasoline") .fluid().color(0xFAA500).flags(FLAMMABLE, EXPLOSIVE).buildAndRegister(); - HighOctaneGasoline = new Material.Builder("gasoline_premium") + HighOctaneGasoline = new Material.Builder("high_octane_gasoline") .fluid().color(0xFFA500).flags(FLAMMABLE, EXPLOSIVE).buildAndRegister(); // free id: 1593 @@ -326,7 +326,7 @@ public static void register() { .flags(NO_SMASHING, FLAMMABLE) .buildAndRegister(); - CetaneBoostedDiesel = new Material.Builder("nitro_fuel") + CetaneBoostedDiesel = new Material.Builder("cetane_boosted_diesel") .fluid().fluidCustomTexture() .color(0xC8FF00) .flags(FLAMMABLE, EXPLOSIVE) diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/item/ProspectorScannerBehavior.java b/common/src/main/java/com/gregtechceu/gtceu/common/item/ProspectorScannerBehavior.java index cae426f806..3956b20348 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/item/ProspectorScannerBehavior.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/item/ProspectorScannerBehavior.java @@ -26,7 +26,9 @@ import org.jetbrains.annotations.Nullable; import javax.annotation.Nonnull; +import java.util.Arrays; import java.util.List; +import java.util.Objects; /** * @author KilaBash @@ -40,7 +42,7 @@ public class ProspectorScannerBehavior implements IItemUIFactory, IInteractionIt public ProspectorScannerBehavior(int radius, long cost, ProspectorMode... modes) { this.radius = radius + 1; - this.modes = modes; + this.modes = Arrays.stream(modes).filter(Objects::nonNull).toArray(ProspectorMode[]::new); this.cost = cost; } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/BedrockOreMinerMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/BedrockOreMinerMachine.java new file mode 100644 index 0000000000..0719dd121b --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/BedrockOreMinerMachine.java @@ -0,0 +1,109 @@ +package com.gregtechceu.gtceu.common.machine.multiblock.electric; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; +import com.gregtechceu.gtceu.api.machine.feature.ITieredMachine; +import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine; +import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; +import com.gregtechceu.gtceu.common.data.GTBlocks; +import com.gregtechceu.gtceu.common.data.GTMaterials; +import com.gregtechceu.gtceu.common.machine.trait.BedrockOreMinerLogic; +import com.gregtechceu.gtceu.common.machine.trait.FluidDrillLogic; +import lombok.Getter; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.List; + +/** + * @author Screret + * @date 2023/7/12 + * @implNote BedrockOreMinerMachine + */ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class BedrockOreMinerMachine extends WorkableElectricMultiblockMachine implements ITieredMachine { + + @Getter + private final int tier; + + public BedrockOreMinerMachine(IMachineBlockEntity holder, int tier) { + super(holder); + this.tier = tier; + } + + @Override + protected RecipeLogic createRecipeLogic(Object... args) { + return new BedrockOreMinerLogic(this); + } + + public int getEnergyTier() { + return Math.min(this.tier + 1 , Math.max(this.tier, getOverclockTier())); + } + + @Override + public void addDisplayText(List textList) { + super.addDisplayText(textList); + if (isFormed()) { + int energyContainer = getEnergyTier(); + long maxVoltage = GTValues.V[energyContainer]; + String voltageName = GTValues.VNF[energyContainer]; + textList.add(Component.translatable("gtceu.multiblock.max_energy_per_tick", maxVoltage, voltageName)); + } + } + + public static int getDepletionChance(int tier) { + if (tier == GTValues.MV) + return 1; + if (tier == GTValues.HV) + return 2; + if (tier == GTValues.EV) + return 8; + return 1; + } + + public static int getRigMultiplier(int tier) { + if (tier == GTValues.MV) + return 1; + if (tier == GTValues.HV) + return 16; + if (tier == GTValues.EV) + return 64; + return 1; + } + + public static Block getCasingState(int tier) { + if (tier == GTValues.MV) + return GTBlocks.CASING_STEEL_SOLID.get(); + if (tier == GTValues.HV) + return GTBlocks.CASING_TITANIUM_STABLE.get(); + if (tier == GTValues.EV) + return GTBlocks.CASING_TUNGSTENSTEEL_ROBUST.get(); + return GTBlocks.CASING_STEEL_SOLID.get(); + } + + public static Block getFrameState(int tier) { + if (tier == GTValues.MV) + return GTBlocks.MATERIAL_BLOCKS.get(TagPrefix.frameGt, GTMaterials.Steel).get(); + if (tier == GTValues.HV) + return GTBlocks.MATERIAL_BLOCKS.get(TagPrefix.frameGt, GTMaterials.Titanium).get(); + if (tier == GTValues.EV) + return GTBlocks.MATERIAL_BLOCKS.get(TagPrefix.frameGt, GTMaterials.TungstenSteel).get(); + return GTBlocks.MATERIAL_BLOCKS.get(TagPrefix.frameGt, GTMaterials.Steel).get(); + } + + public static ResourceLocation getBaseTexture(int tier) { + if (tier == GTValues.MV) + return GTCEu.id("block/casings/solid/machine_casing_solid_steel"); + if (tier == GTValues.HV) + return GTCEu.id("block/casings/solid/machine_casing_stable_titanium"); + if (tier == GTValues.EV) + return GTCEu.id("block/casings/solid/machine_casing_robust_tungstensteel"); + return GTCEu.id("block/casings/solid/machine_casing_solid_steel"); + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/CleanroomMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/CleanroomMachine.java index 0028d6ce57..72c7403eb0 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/CleanroomMachine.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/CleanroomMachine.java @@ -144,8 +144,13 @@ public void onStructureInvalid() { @Override public boolean shouldAddPartToController(IMultiPart part) { - Set receivers = getMultiblockState().getMatchContext().getOrCreate("cleanroomReceiver", Sets::newHashSet); - return !receivers.contains(part); + var cache = getMultiblockState().getCache(); + for (Direction side : Direction.values()) { + if (!cache.contains(part.self().getPos().relative(side))) { + return true; + } + } + return false; } protected void initializeAbilities() { @@ -378,20 +383,30 @@ protected TraceabilityPredicate innerPredicate() { Set receivers = blockWorldState.getMatchContext().getOrCreate("cleanroomReceiver", Sets::newHashSet); // all non-GTMachines are allowed inside by default BlockEntity blockEntity = blockWorldState.getTileEntity(); + if (blockEntity instanceof IMachineBlockEntity machineBlockEntity) { + var machine = machineBlockEntity.getMetaMachine(); + if (isMachineBanned(machine)) { + return false; + } + } if (blockEntity != null) { var receiver = GTCapabilityHelper.getCleanroomReceiver(blockWorldState.getWorld(), blockWorldState.getPos(), null); if (receiver != null) { - if (blockEntity instanceof IMachineBlockEntity machineBlockEntity) { - var machine = machineBlockEntity.getMetaMachine(); - if (isMachineBanned(machine)) { - return false; - } - } receivers.add(receiver); } } return true; - }, null); + }, null) { + @Override + public boolean isAny() { + return true; + } + + @Override + public boolean addCache() { + return true; + } + }; } protected boolean isMachineBanned(MetaMachine metaTileEntity) { diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeCombustionEngineMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeCombustionEngineMachine.java index d3eb6894ad..b4e19e6b04 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeCombustionEngineMachine.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeCombustionEngineMachine.java @@ -110,7 +110,7 @@ public static GTRecipe recipeModifier(MetaMachine machine, @Nonnull GTRecipe rec if (engineMachine.isOxygenBoosted) { // boost production recipe = parallelResult.getA() == recipe ? recipe.copy() : parallelResult.getA(); long eut = (long) (EUt * parallelResult.getB() * (engineMachine.isExtreme() ? 2 : 1.5)); - recipe.tickOutputs.put(EURecipeCapability.CAP, List.of(new Content(eut, 1.0f, null, null))); + recipe.tickOutputs.put(EURecipeCapability.CAP, List.of(new Content(eut, 1.0f, 0.0f, null, null))); } else { recipe = parallelResult.getA(); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeTurbineMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeTurbineMachine.java index 600417ca72..7a935cc94c 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeTurbineMachine.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeTurbineMachine.java @@ -97,7 +97,7 @@ public static GTRecipe recipeModifier(MetaMachine machine, @Nonnull GTRecipe rec var parallelResult = GTRecipeModifiers.fastParallel(turbineMachine, recipe, Math.max(1, maxParallel), false); recipe = parallelResult.getA() == recipe ? recipe.copy() : parallelResult.getA(); long eut = turbineMachine.boostProduction(EUt * parallelResult.getB()); - recipe.tickOutputs.put(EURecipeCapability.CAP, List.of(new Content(eut, 1.0f, null, null))); + recipe.tickOutputs.put(EURecipeCapability.CAP, List.of(new Content(eut, 1.0f, 0.0f, null, null))); return recipe; } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveFancyUIWorkableMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveFancyUIWorkableMachine.java new file mode 100644 index 0000000000..923e239445 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/primitive/PrimitiveFancyUIWorkableMachine.java @@ -0,0 +1,11 @@ +package com.gregtechceu.gtceu.common.machine.multiblock.primitive; + +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; +import com.gregtechceu.gtceu.api.machine.feature.IFancyUIMachine; + +public class PrimitiveFancyUIWorkableMachine extends PrimitiveWorkableMachine implements IFancyUIMachine { + + public PrimitiveFancyUIWorkableMachine(IMachineBlockEntity holder, Object... args) { + super(holder, args); + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/SteamParallelMultiblockMachine.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/SteamParallelMultiblockMachine.java index 4e52a3a06f..9057c47fd2 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/SteamParallelMultiblockMachine.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/SteamParallelMultiblockMachine.java @@ -78,7 +78,7 @@ public static GTRecipe recipeModifier(MetaMachine machine, @Nonnull GTRecipe rec // also set the duration to just 1.5x the original, instead of fully multiplied recipe.duration = (int) (duration * 1.5); eut = (long) Math.min(32, Math.ceil(eut * 1.33)); - recipe.tickInputs.put(EURecipeCapability.CAP, List.of(new Content(eut, 1.0f, null, null))); + recipe.tickInputs.put(EURecipeCapability.CAP, List.of(new Content(eut, 1.0f, 0.0f, null, null))); return recipe; } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/trait/BedrockOreMinerLogic.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/trait/BedrockOreMinerLogic.java new file mode 100644 index 0000000000..d691e19d12 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/trait/BedrockOreMinerLogic.java @@ -0,0 +1,156 @@ +package com.gregtechceu.gtceu.common.machine.trait; + +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.capability.recipe.IO; +import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; +import com.gregtechceu.gtceu.api.data.chemical.material.Material; +import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreVeinSavedData; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.OreVeinWorldEntry; +import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; +import com.gregtechceu.gtceu.api.recipe.GTRecipe; +import com.gregtechceu.gtceu.api.recipe.content.ContentModifier; +import com.gregtechceu.gtceu.common.machine.multiblock.electric.BedrockOreMinerMachine; +import com.gregtechceu.gtceu.config.ConfigHolder; +import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; +import com.gregtechceu.gtceu.utils.GTUtil; +import lombok.Getter; +import net.minecraft.core.SectionPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.item.ItemStack; + +import javax.annotation.Nullable; +import java.util.List; +import java.util.Map; + +/** + * @author KilaBash + * @date 2023/7/12 + * @implNote FluidDrillLogic + */ +public class BedrockOreMinerLogic extends RecipeLogic { + public static final int MAX_PROGRESS = 20; + + @Getter @Nullable + private List> veinMaterials; + + public BedrockOreMinerLogic(BedrockOreMinerMachine machine) { + super(machine); + } + + @Override + public BedrockOreMinerMachine getMachine() { + return (BedrockOreMinerMachine)super.getMachine(); + } + + @Override + public void findAndHandleRecipe() { + if (getMachine().getLevel() instanceof ServerLevel serverLevel) { + lastRecipe = null; + var data = BedrockOreVeinSavedData.getOrCreate(serverLevel); + if (veinMaterials == null) { + this.veinMaterials = data.getOreInChunk(getChunkX(), getChunkZ()); + if (this.veinMaterials == null) { + if (subscription != null) { + subscription.unsubscribe(); + subscription = null; + } + return; + } + } + var match = getOreMinerRecipe(); + if (match != null) { + var copied = match.copy(new ContentModifier(match.duration, 0)); + if (match.matchRecipe(this.machine).isSuccess() && copied.matchTickRecipe(this.machine).isSuccess()) { + setupRecipe(match); + } + } + } + } + + @Nullable + private GTRecipe getOreMinerRecipe() { + if (getMachine().getLevel() instanceof ServerLevel serverLevel && veinMaterials != null) { + var data = BedrockOreVeinSavedData.getOrCreate(serverLevel); + Material material = veinMaterials.get(GTUtil.getRandomItem(veinMaterials, veinMaterials.size())).getValue(); + ItemStack stack = ChemicalHelper.get(TagPrefix.get(ConfigHolder.INSTANCE.machines.bedrockOreDropTagPrefix), material, getOreToProduce(data.getOreVeinWorldEntry(getChunkX(), getChunkZ()))); + if (stack.isEmpty()) stack = ChemicalHelper.get(TagPrefix.crushed, material, getOreToProduce(data.getOreVeinWorldEntry(getChunkX(), getChunkZ()))); // backup 1: crushed; if raw ore doesn't exist + if (stack.isEmpty()) stack = ChemicalHelper.get(TagPrefix.gem, material, getOreToProduce(data.getOreVeinWorldEntry(getChunkX(), getChunkZ()))); // backup 2: gem; if crushed ore doesn't exist + if (stack.isEmpty()) stack = ChemicalHelper.get(TagPrefix.ore, material, getOreToProduce(data.getOreVeinWorldEntry(getChunkX(), getChunkZ()))); // backup 3: just fallback to normal ore... + var recipe = GTRecipeBuilder.ofRaw() + .duration(MAX_PROGRESS) + .EUt(GTValues.VA[getMachine().getEnergyTier()]) + .outputItems(stack) + .buildRawRecipe(); + if (recipe.matchRecipe(getMachine()).isSuccess() && recipe.matchTickRecipe(getMachine()).isSuccess()) { + return recipe; + } + } + return null; + } + + private int getOreToProduce(OreVeinWorldEntry entry) { + var definition = entry.getDefinition(); + if (definition != null) { + int depletedYield = definition.getDepletedYield(); + int regularYield = entry.getOreYield(); + int remainingOperations = entry.getOperationsRemaining(); + + int produced = Math.max(depletedYield, regularYield * remainingOperations / BedrockOreVeinSavedData.MAXIMUM_VEIN_OPERATIONS); + produced *= BedrockOreMinerMachine.getRigMultiplier(getMachine().getTier()); + + // Overclocks produce 50% more fluid + if (isOverclocked()) { + produced = produced * 3 / 2; + } + return produced; + } + return 0; + } + + @Override + public void onRecipeFinish() { + machine.afterWorking(); + if (lastRecipe != null) { + lastRecipe.postWorking(this.machine); + lastRecipe.handleRecipeIO(IO.OUT, this.machine); + } + depleteVein(); + // try it again + var match = getOreMinerRecipe(); + if (match != null) { + var copied = match.copy(new ContentModifier(match.duration, 0)); + if (match.matchRecipe(this.machine).isSuccess() && copied.matchTickRecipe(this.machine).isSuccess()) { + setupRecipe(match); + return; + } + } + setStatus(Status.IDLE); + progress = 0; + duration = 0; + } + + protected void depleteVein() { + if (getMachine().getLevel() instanceof ServerLevel serverLevel) { + int chance = BedrockOreMinerMachine.getDepletionChance(getMachine().getTier()); + var data = BedrockOreVeinSavedData.getOrCreate(serverLevel); + // chance to deplete based on the rig + if (chance == 1 || GTValues.RNG.nextInt(chance) == 0) { + data.depleteVein(getChunkX(), getChunkZ(), 0, false); + } + } + } + + protected boolean isOverclocked() { + return getMachine().getEnergyTier() > getMachine().getTier(); + } + + private int getChunkX() { + return SectionPos.blockToSectionCoord(getMachine().getPos().getX()); + } + + private int getChunkZ() { + return SectionPos.blockToSectionCoord(getMachine().getPos().getZ()); + } + +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/machine/trait/FluidDrillLogic.java b/common/src/main/java/com/gregtechceu/gtceu/common/machine/trait/FluidDrillLogic.java index 9d67ce3543..209794e0fa 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/machine/trait/FluidDrillLogic.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/machine/trait/FluidDrillLogic.java @@ -2,7 +2,7 @@ import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.recipe.IO; -import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidVeinSaveData; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidVeinSavedData; import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.FluidVeinWorldEntry; import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.recipe.GTRecipe; @@ -42,7 +42,7 @@ public FluidDrillMachine getMachine() { public void findAndHandleRecipe() { if (getMachine().getLevel() instanceof ServerLevel serverLevel) { lastRecipe = null; - var data = BedrockFluidVeinSaveData.getOrCreate(serverLevel); + var data = BedrockFluidVeinSavedData.getOrCreate(serverLevel); if (veinFluid == null) { this.veinFluid = data.getFluidInChunk(getChunkX(), getChunkZ()); if (this.veinFluid == null) { @@ -66,7 +66,7 @@ public void findAndHandleRecipe() { @Nullable private GTRecipe getFluidDrillRecipe() { if (getMachine().getLevel() instanceof ServerLevel serverLevel && veinFluid != null) { - var data = BedrockFluidVeinSaveData.getOrCreate(serverLevel); + var data = BedrockFluidVeinSavedData.getOrCreate(serverLevel); var recipe = GTRecipeBuilder.ofRaw() .duration(MAX_PROGRESS) .EUt(GTValues.VA[getMachine().getEnergyTier()]) @@ -86,7 +86,7 @@ private long getFluidToProduce(FluidVeinWorldEntry entry) { int regularYield = entry.getFluidYield(); int remainingOperations = entry.getOperationsRemaining(); - int produced = Math.max(depletedYield, regularYield * remainingOperations / BedrockFluidVeinSaveData.MAXIMUM_VEIN_OPERATIONS); + int produced = Math.max(depletedYield, regularYield * remainingOperations / BedrockFluidVeinSavedData.MAXIMUM_VEIN_OPERATIONS); produced *= FluidDrillMachine.getRigMultiplier(getMachine().getTier()); // Overclocks produce 50% more fluid @@ -123,7 +123,7 @@ public void onRecipeFinish() { protected void depleteVein() { if (getMachine().getLevel() instanceof ServerLevel serverLevel) { int chance = FluidDrillMachine.getDepletionChance(getMachine().getTier()); - var data = BedrockFluidVeinSaveData.getOrCreate(serverLevel); + var data = BedrockFluidVeinSavedData.getOrCreate(serverLevel); // chance to deplete based on the rig if (chance == 1 || GTValues.RNG.nextInt(chance) == 0) { data.depleteVein(getChunkX(), getChunkZ(), 0, false); diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/cable/Insulation.java b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/cable/Insulation.java index 66c60c3194..4e770f14e3 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/cable/Insulation.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/cable/Insulation.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.common.pipelike.cable; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; import com.gregtechceu.gtceu.api.pipenet.IMaterialPipeType; import com.gregtechceu.gtceu.client.model.PipeModel; import com.gregtechceu.gtceu.api.data.chemical.material.Material; @@ -9,6 +10,8 @@ import lombok.Getter; import net.minecraft.resources.ResourceLocation; +import java.util.function.Supplier; + import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.*; public enum Insulation implements IMaterialPipeType { @@ -75,7 +78,12 @@ public ResourceLocation type() { } public PipeModel createPipeModel(Material material) { - return new PipeModel(thickness, isCable ? GTCEu.id("block/cable/insulation_5") : GTCEu.id("block/cable/wire")); + Supplier wireTexturePath = () -> MaterialIconType.wire.getBlockTexturePath(material.getMaterialIconSet(), true); + PipeModel model = new PipeModel(thickness, isCable ? () -> GTCEu.id("block/cable/insulation_5") : wireTexturePath, wireTexturePath); + if (isCable) { + model.setEndOverlayTexture(GTCEu.id("block/cable/insulation_%s".formatted(insulationLevel))); + } + return model; } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/fluidpipe/FluidPipeType.java b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/fluidpipe/FluidPipeType.java index 01a86c14d9..150a573524 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/fluidpipe/FluidPipeType.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/pipelike/fluidpipe/FluidPipeType.java @@ -74,8 +74,8 @@ public ResourceLocation type() { public PipeModel createPipeModel(Material material) { if (material.hasProperty(PropertyKey.WOOD)) { - return new PipeModel(thickness, GTCEu.id("block/pipe/pipe_side_wood")); + return new PipeModel(thickness, () -> GTCEu.id("block/pipe/pipe_side_wood"), () -> GTCEu.id("block/pipe/pipe_%s_in_wood".formatted(name))); } - return new PipeModel(thickness, GTCEu.id("block/pipe/pipe_side")); + return new PipeModel(thickness, () -> GTCEu.id("block/pipe/pipe_side"), () -> GTCEu.id("block/pipe/pipe_%s_in".formatted(name))); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/recipe/BiomeCondition.java b/common/src/main/java/com/gregtechceu/gtceu/common/recipe/BiomeCondition.java index a42a807dcd..e4c0914afe 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/recipe/BiomeCondition.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/recipe/BiomeCondition.java @@ -4,8 +4,8 @@ import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.RecipeCondition; import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; +import com.lowdragmc.lowdraglib.utils.LocalizationUtils; import lombok.NoArgsConstructor; -import net.fabricmc.loader.impl.util.Localization; import net.minecraft.core.Holder; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; @@ -43,7 +43,7 @@ public boolean isOr() { @Override public Component getTooltips() { - return Component.translatable("recipe.condition.biome.tooltip", Localization.format("biome.%s.%s", biome.getNamespace(), biome.getPath())); + return Component.translatable("recipe.condition.biome.tooltip", LocalizationUtils.format("biome.%s.%s", biome.getNamespace(), biome.getPath())); } public ResourceLocation getBiome() { diff --git a/common/src/main/java/com/gregtechceu/gtceu/config/ConfigHolder.java b/common/src/main/java/com/gregtechceu/gtceu/config/ConfigHolder.java index 025b5c0172..63682a27eb 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/config/ConfigHolder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/config/ConfigHolder.java @@ -189,6 +189,12 @@ public static class MachineConfigs { @Configurable @Configurable.Comment({"Whether the machine's circuit slot need to be inserted a real circuit."}) public boolean ghostCircuit = true; + @Configurable + @Configurable.Comment({"Wether to add a \"Bedrock Ore Miner\" (also enables bedrock ore generation)", "Default: false"}) + public boolean doBedrockOres = false; + @Configurable + @Configurable.Comment({"What Kind of material should the bedrock ore miner output?", "Default: \"raw\""}) + public String bedrockOreDropTagPrefix = "raw"; } public static class ClientConfigs { @@ -196,8 +202,8 @@ public static class ClientConfigs { @Configurable.Comment({"Whether or not to enable Emissive Textures for GregTech Machines.", "Default: true"}) public boolean machinesEmissiveTextures = true; @Configurable - @Configurable.Comment({"The default color to overlay onto machines.", "16777215 (0xFFFFFF in decimal) is no coloring (like GTCE).", - "13819135 (0xD2DCFF in decimal) is the classic blue from GT5 (default)."}) + @Configurable.Comment({"The default color to overlay onto machines.", "16777215 (0xFFFFFF in decimal) is no coloring (default).", + "13819135 (0xD2DCFF in decimal) is the classic blue from GT5."}) @Configurable.Range(min = 0, max = 0xFFFFFF) @Configurable.Gui.ColorValue public int defaultPaintingColor = 0xFFFFFF; diff --git a/common/src/main/java/com/gregtechceu/gtceu/core/mixins/LootTablesMixin.java b/common/src/main/java/com/gregtechceu/gtceu/core/mixins/LootTablesMixin.java index 331d4c88a3..4843398faa 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/core/mixins/LootTablesMixin.java +++ b/common/src/main/java/com/gregtechceu/gtceu/core/mixins/LootTablesMixin.java @@ -17,6 +17,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.storage.loot.IntRange; @@ -57,10 +58,13 @@ public abstract class LootTablesMixin { block = ChemicalHelper.getBlock(orePrefix, material); } + ItemStack dropItem = ChemicalHelper.get(TagPrefix.rawOre, material); + if (dropItem.isEmpty()) dropItem = ChemicalHelper.get(TagPrefix.gem, material); + if (dropItem.isEmpty()) dropItem = ChemicalHelper.get(TagPrefix.dust, material); int oreMultiplier = TagPrefix.ORES.get(prefix).isNether() ? 2 : 1; LootTable.Builder builder = BlockLoot.createSilkTouchDispatchTable(block, BlockLoot.applyExplosionDecay(block, - LootItem.lootTableItem(ChemicalHelper.get(TagPrefix.rawOre, material).getItem()) + LootItem.lootTableItem(dropItem.getItem()) .apply(SetItemCountFunction.setCount(UniformGenerator.between(1, Math.max(1, material.getProperty(PropertyKey.ORE).getOreMultiplier() * oreMultiplier)))) .apply(ApplyBonusCount.addOreBonusCount(Enchantments.BLOCK_FORTUNE)))); diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/lang/LangHandler.java b/common/src/main/java/com/gregtechceu/gtceu/data/lang/LangHandler.java index ae7de5153f..ee9cca1c40 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/lang/LangHandler.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/lang/LangHandler.java @@ -377,7 +377,6 @@ public static void init(RegistrateLangProvider provider) { replace(provider, GTMaterials.OilLight.getUnlocalizedName(), "Light Oil"); replace(provider, GTMaterials.RawOil.getUnlocalizedName(), "Raw Oil"); - // TODO all individual material item overrides do not work provider.add("item.gunpowder_tiny_dust", "Tiny Pile of Gunpowder"); provider.add("item.gunpowder_small_dust", "Small Pile of Gunpowder"); provider.add("item.paper_tiny_dust", "Tiny Pile of Chad"); @@ -535,6 +534,7 @@ public static void init(RegistrateLangProvider provider) { multilineLang(provider, "tile.brittle_charcoal.tooltip", "Produced by the Charcoal Pile Igniter.\nMine this to get Charcoal."); provider.add("metaitem.prospector.mode.ores", "§aOre Prospection Mode§r"); provider.add("metaitem.prospector.mode.fluid", "§bFluid Prospection Mode§r"); + provider.add("metaitem.prospector.mode.bedrock_ore", "§bBedrock Ore Prospection Mode§r"); provider.add("metaitem.prospector.tooltip.radius", "Scans range in a %s Chunk Radius"); provider.add("metaitem.prospector.tooltip.modes", "Available Modes:"); provider.add("behavior.prospector.not_enough_energy", "Not Enough Energy!"); @@ -1068,6 +1068,7 @@ public static void init(RegistrateLangProvider provider) { provider.add("gtceu.gui.content.chance_0", "§cNot Consumed§r"); provider.add("gtceu.gui.content.chance_0_short", "§cNC§r"); provider.add("gtceu.gui.content.chance_1", "§eChance: %s§r"); + provider.add("gtceu.gui.content.tier_boost", "§eTier Chance: +%s/tier§r"); provider.add("gtceu.gui.content.per_tick", "§aConsumed/Produced Per Tick§r"); provider.add("gtceu.gui.content.tips.per_tick_short", "§a/tick§r"); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/lang/MachineLang.java b/common/src/main/java/com/gregtechceu/gtceu/data/lang/MachineLang.java index 3c91e11747..9638b4dd68 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/lang/MachineLang.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/lang/MachineLang.java @@ -377,6 +377,10 @@ protected static void init(RegistrateLangProvider provider) { provider.add("gtceu.machine.fluid_drilling_rig.production", "§eProduction Multiplier: §f%dx, %fx overclocked"); provider.add("gtceu.machine.fluid_drilling_rig.depletion", "§bDepletion Rate: §f%s%%"); + provider.add("gtceu.machine.bedrock_ore_miner.description", "Drills ores from veins under bedrock."); + provider.add("gtceu.machine.bedrock_ore_miner.production", "§eProduction Multiplier: §f%dx, %fx overclocked"); + provider.add("gtceu.machine.bedrock_ore_miner.depletion", "§bDepletion Rate: §f%s%%"); + multiLang(provider, "gtceu.machine.cleanroom.tooltip", "Place machines inside to run cleanroom recipes.", "Uses §f30 EU/t§7 when dirty, §f4 EU/t§7 when clean.", diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/loader/FluidVeinLoader.java b/common/src/main/java/com/gregtechceu/gtceu/data/loader/FluidVeinLoader.java new file mode 100644 index 0000000000..56625d6880 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/data/loader/FluidVeinLoader.java @@ -0,0 +1,78 @@ +package com.gregtechceu.gtceu.data.loader; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.integration.kjs.GTCEuServerEvents; +import com.gregtechceu.gtceu.integration.kjs.events.GTFluidVeinEventJS; +import com.mojang.datafixers.util.Pair; +import com.mojang.serialization.JsonOps; +import dev.latvian.mods.kubejs.script.ScriptType; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.RegistryOps; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; +import net.minecraft.util.GsonHelper; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.level.storage.loot.Deserializers; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Map; + +public class FluidVeinLoader extends SimpleJsonResourceReloadListener { + public static FluidVeinLoader INSTANCE; + public static final Gson GSON_INSTANCE = Deserializers.createFunctionSerializer().create(); + private static final String FOLDER = "gtceu/fluid_veins"; + protected static final Logger LOGGER = LogManager.getLogger(); + + public FluidVeinLoader() { + super(GSON_INSTANCE, FOLDER); + } + + @Override + protected void apply(Map resourceList, ResourceManager resourceManager, ProfilerFiller profiler) { + RegistryOps ops = RegistryOps.create(JsonOps.INSTANCE, RegistryAccess.BUILTIN.get()); + for(Map.Entry entry : resourceList.entrySet()) { + ResourceLocation location = entry.getKey(); + + try { + BedrockFluidDefinition fluid = fromJson(location, GsonHelper.convertToJsonObject(entry.getValue(), "top element"), ops); + if (fluid == null) { + LOGGER.info("Skipping loading fluid vein {} as it's serializer returned null", location); + } /*else if(fluid.getVeinGenerator() instanceof GTOreFeatureEntry.NoopVeinGenerator) { + LOGGER.info("Removing fluid vein {} as it's generator was marked as no-operation", location); + GTRegistries.BEDROCK_FLUID_DEFINITIONS.remove(location); + }*/else if (GTRegistries.BEDROCK_FLUID_DEFINITIONS.containKey(location)) { + GTRegistries.BEDROCK_FLUID_DEFINITIONS.replace(location, fluid); + } else { + GTRegistries.BEDROCK_FLUID_DEFINITIONS.register(location, fluid); + } + } catch (IllegalArgumentException | JsonParseException jsonParseException) { + LOGGER.error("Parsing error loading ore vein {}", location, jsonParseException); + } + } + if (GTCEu.isKubeJSLoaded()) { + RunKJSEventInSeparateClassBecauseForgeIsDumb.fireKJSEvent(); + } + } + + public static BedrockFluidDefinition fromJson(ResourceLocation id, JsonObject json, RegistryOps ops) { + return BedrockFluidDefinition.FULL_CODEC.decode(ops, json).map(Pair::getFirst).getOrThrow(false, LOGGER::error); + } + + /** + * Holy shit this is dumb, thanks forge for trying to classload things that are never called! + */ + public static final class RunKJSEventInSeparateClassBecauseForgeIsDumb { + public static void fireKJSEvent() { + GTCEuServerEvents.FLUID_VEIN_MODIFICATION.post(ScriptType.SERVER, new GTFluidVeinEventJS()); + } + } +} + diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java b/common/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java index faed673865..52271af77d 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/loader/OreDataLoader.java @@ -6,10 +6,12 @@ import com.google.gson.JsonParseException; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.GTOreFeatureEntry; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.integration.kjs.GTCEuServerEvents; import com.gregtechceu.gtceu.integration.kjs.events.GTOreVeinEventJS; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.JsonOps; +import dev.latvian.mods.kubejs.script.ScriptType; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceLocation; @@ -43,11 +45,13 @@ protected void apply(Map resourceList, ResourceMa GTOreFeatureEntry ore = fromJson(location, GsonHelper.convertToJsonObject(entry.getValue(), "top element"), ops); if (ore == null) { LOGGER.info("Skipping loading ore vein {} as it's serializer returned null", location); - } else if(ore.getVeinGenerator() instanceof GTOreFeatureEntry.NoopVeinGenerator) { + } else if (ore.getVeinGenerator() instanceof GTOreFeatureEntry.NoopVeinGenerator) { LOGGER.info("Removing ore vein {} as it's generator was marked as no-operation", location); - GTOreFeatureEntry.ALL.remove(location); + GTRegistries.ORE_VEINS.remove(location); + } else if (GTRegistries.ORE_VEINS.containKey(location)) { + GTRegistries.ORE_VEINS.replace(location, ore); } else { - GTOreFeatureEntry.ALL.put(location, ore); + GTRegistries.ORE_VEINS.register(location, ore); } } catch (IllegalArgumentException | JsonParseException jsonParseException) { LOGGER.error("Parsing error loading ore vein {}", location, jsonParseException); @@ -56,8 +60,12 @@ protected void apply(Map resourceList, ResourceMa if (GTCEu.isKubeJSLoaded()) { RunKJSEventInSeparateClassBecauseForgeIsDumb.fireKJSEvent(); } - for (GTOreFeatureEntry entry : GTOreFeatureEntry.ALL.values()) { - entry.getVeinGenerator().build(); + for (GTOreFeatureEntry entry : GTRegistries.ORE_VEINS) { + if (entry.getVeinGenerator() != null) { + entry.getVeinGenerator().build(); + } else { + GTRegistries.ORE_VEINS.remove(GTRegistries.ORE_VEINS.getKey(entry)); + } } } @@ -70,7 +78,7 @@ public static GTOreFeatureEntry fromJson(ResourceLocation id, JsonObject json, R */ public static final class RunKJSEventInSeparateClassBecauseForgeIsDumb { public static void fireKJSEvent() { - GTCEuServerEvents.ORE_VEIN_MODIFICATION.post(new GTOreVeinEventJS()); + GTCEuServerEvents.ORE_VEIN_MODIFICATION.post(ScriptType.SERVER, new GTOreVeinEventJS()); } } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/CustomTags.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/CustomTags.java index 7e64141e15..c75ac163b4 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/CustomTags.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/CustomTags.java @@ -79,5 +79,6 @@ public class CustomTags { public static final TagKey IS_SWAMP = TagUtil.createTag(BuiltinRegistries.BIOME, "is_swamp", false); + public static final TagKey IS_SANDY = TagUtil.createModTag(BuiltinRegistries.BIOME, "is_sandy"); public static final TagKey HAS_RUBBER_TREE = TagUtil.createModTag(BuiltinRegistries.BIOME, "has_rubber_tree"); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java index 00409e0241..7892761efa 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java @@ -11,6 +11,7 @@ import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.data.recipe.builder.*; import com.tterrag.registrate.util.entry.ItemEntry; +import com.tterrag.registrate.util.entry.ItemProviderEntry; import it.unimi.dsi.fastutil.chars.*; import it.unimi.dsi.fastutil.objects.Object2LongMap; import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; @@ -129,7 +130,7 @@ public static void addShapedRecipe(Consumer provider, boolean wi if (tag != null) { builder.define(sign, tag); } else builder.define(sign, ChemicalHelper.get(entry.tagPrefix, entry.material)); - } else if (content instanceof ItemEntry entry) { + } else if (content instanceof ItemProviderEntry entry) { builder.define(sign, entry.asStack()); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java index a94142db2e..6831234484 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java @@ -69,6 +69,8 @@ public class GTRecipeBuilder { @Setter public float chance = 1; @Setter + public float tierChanceBoost = 0; + @Setter public boolean isFuel = false; @Setter public BiConsumer> onSave; @@ -115,28 +117,28 @@ public GTRecipeBuilder copyFrom(GTRecipeBuilder builder) { public GTRecipeBuilder input(RecipeCapability capability, T... obj) { (perTick ? tickInput : input).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj) .map(capability::of) - .map(o -> new Content(o, chance, slotName, uiName)).toList()); + .map(o -> new Content(o, chance, tierChanceBoost, slotName, uiName)).toList()); return this; } public GTRecipeBuilder output(RecipeCapability capability, T... obj) { (perTick ? tickOutput : output).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj) .map(capability::of) - .map(o -> new Content(o, chance, slotName, uiName)).toList()); + .map(o -> new Content(o, chance, tierChanceBoost, slotName, uiName)).toList()); return this; } public GTRecipeBuilder inputs(RecipeCapability capability, Object... obj) { (perTick ? tickInput : input).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj) .map(capability::of) - .map(o -> new Content(o, chance, slotName, uiName)).toList()); + .map(o -> new Content(o, chance, tierChanceBoost, slotName, uiName)).toList()); return this; } public GTRecipeBuilder outputs(RecipeCapability capability, Object... obj) { (perTick ? tickOutput : output).computeIfAbsent(capability, c -> new ArrayList<>()).addAll(Arrays.stream(obj) .map(capability::of) - .map(o -> new Content(o, chance, slotName, uiName)).toList()); + .map(o -> new Content(o, chance, tierChanceBoost, slotName, uiName)).toList()); return this; } @@ -337,12 +339,47 @@ public GTRecipeBuilder circuitMeta(int configuration) { return notConsumable(IntCircuitBehaviour.stack(configuration)); } + public GTRecipeBuilder chancedInput(ItemStack stack, int chance, int tierChanceBoost) { + float lastChance = this.chance; + float lastTierChanceBoost = this.tierChanceBoost; + this.chance = chance / 10000f; + this.tierChanceBoost = tierChanceBoost / 10000f; + inputItems(stack); + this.chance = lastChance; + this.tierChanceBoost = lastTierChanceBoost; + return this; + } + + public GTRecipeBuilder chancedInput(FluidStack stack, int chance, int tierChanceBoost) { + float lastChance = this.chance; + float lastTierChanceBoost = this.tierChanceBoost; + this.chance = chance / 10000f; + this.tierChanceBoost = tierChanceBoost / 10000f; + inputFluids(stack); + this.chance = lastChance; + this.tierChanceBoost = lastTierChanceBoost; + return this; + } + public GTRecipeBuilder chancedOutput(ItemStack stack, int chance, int tierChanceBoost) { - // todo tier chance boost float lastChance = this.chance; + float lastTierChanceBoost = this.tierChanceBoost; this.chance = chance / 10000f; + this.tierChanceBoost = tierChanceBoost / 10000f; outputItems(stack); this.chance = lastChance; + this.tierChanceBoost = lastTierChanceBoost; + return this; + } + + public GTRecipeBuilder chancedOutput(FluidStack stack, int chance, int tierChanceBoost) { + float lastChance = this.chance; + float lastTierChanceBoost = this.tierChanceBoost; + this.chance = chance / 10000f; + this.tierChanceBoost = tierChanceBoost / 10000f; + outputFluids(stack); + this.chance = lastChance; + this.tierChanceBoost = lastTierChanceBoost; return this; } @@ -489,18 +526,10 @@ public void toJson(JsonObject json) { if (data != null && !data.isEmpty()) { json.add("data", NBTToJsonConverter.getObject(data)); } - if (!input.isEmpty()) { - json.add("inputs", capabilitiesToJson(input)); - } - if (!output.isEmpty()) { - json.add("outputs", capabilitiesToJson(output)); - } - if (!tickInput.isEmpty()) { - json.add("tickInputs", capabilitiesToJson(tickInput)); - } - if (!tickOutput.isEmpty()) { - json.add("tickOutputs", capabilitiesToJson(tickOutput)); - } + json.add("inputs", capabilitiesToJson(input)); + json.add("outputs", capabilitiesToJson(output)); + json.add("tickInputs", capabilitiesToJson(tickInput)); + json.add("tickOutputs", capabilitiesToJson(tickOutput)); if (!conditions.isEmpty()) { JsonArray array = new JsonArray(); for (RecipeCondition condition : conditions) { @@ -580,7 +609,7 @@ public long EUt() { } public int getSolderMultiplier() { - return data.getInt("solderMultiplier"); + return Math.max(1, data.getInt("solderMultiplier")); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/OreRecipeHandler.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/OreRecipeHandler.java index 58f4b8bdf9..38c5d94232 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/OreRecipeHandler.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/OreRecipeHandler.java @@ -329,7 +329,7 @@ public static void processCrushedPurified(TagPrefix purifiedPrefix, Material mat if (!flawedStack.isEmpty()) builder.chancedOutput(flawedStack, 2500, 300); - if (!exquisiteStack.isEmpty()) + if (!chippedStack.isEmpty()) builder.chancedOutput(chippedStack, 3500, 400); builder.save(provider); diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/ToolRecipeHandler.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/ToolRecipeHandler.java index 733e20b881..ad1944ef29 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/ToolRecipeHandler.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/ToolRecipeHandler.java @@ -164,11 +164,6 @@ private static void processTool(TagPrefix prefix, Material material, ToolPropert 'I', ingot, 'S', stick); - addToolRecipe(provider, material, GTToolType.HARD_HAMMER, true, - "PPf", "PPS", "PPh", - 'P', plate, - 'S', stick); - addToolRecipe(provider, material, GTToolType.FILE, true, " P ", " P " , " S ", 'P', plate, diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireRecipeHandler.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireRecipeHandler.java index 034ee0d81d..a93f8d88e3 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireRecipeHandler.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireRecipeHandler.java @@ -95,7 +95,7 @@ public static void generateCableCovering(TagPrefix wirePrefix, Material material if (property.isSuperconductor()) return; int cableAmount = (int) (wirePrefix.getMaterialAmount(material) * 2 / M); - TagPrefix cablePrefix = TagPrefix.getPrefix("cable" + wirePrefix.name().substring(4)); + TagPrefix cablePrefix = TagPrefix.get("cable" + wirePrefix.name().substring(4)); int voltageTier = GTUtil.getTierByVoltage(property.getVoltage()); int insulationAmount = INSULATION_AMOUNT.get(cablePrefix); diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CreateRecipeLoader.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CreateRecipeLoader.java index aefd3ba138..2cbab8f9f4 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CreateRecipeLoader.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CreateRecipeLoader.java @@ -23,7 +23,7 @@ public static void init(Consumer provider) { registerMachineRecipe(provider, false, GTCreateMachines.ELECTRIC_GEAR_BOX_8A, "WMW", "RER", "CHC", 'H', HULL, 'C', CIRCUIT, 'E', AllBlocks.SHAFT.asStack(), 'W', CABLE_QUAD, 'M', MOTOR, 'R', ROTOR); registerMachineRecipe(provider, false, GTCreateMachines.ELECTRIC_GEAR_BOX_16A, "WMW", "RER", "CHC", 'H', HULL, 'C', CIRCUIT, 'E', AllBlocks.SHAFT.asStack(), 'W', CABLE_OCT, 'M', MOTOR, 'R', ROTOR); registerMachineRecipe(provider, false, GTCreateMachines.ELECTRIC_GEAR_BOX_32A, "WMW", "RER", "CHC", 'H', HULL, 'C', CIRCUIT, 'E', AllBlocks.SHAFT.asStack(), 'W', CABLE_HEX, 'M', MOTOR, 'R', ROTOR); - registerMachineRecipe(provider, false, GTCreateMachines.KINETIC_INPUT_BOX, " S ", " H ", " ", "S", AllBlocks.SHAFT, "H", HULL); - registerMachineRecipe(provider, false, GTCreateMachines.KINETIC_OUTPUT_BOX, " ", " H ", " S ", "S", AllBlocks.SHAFT, "H", HULL); + registerMachineRecipe(provider, false, GTCreateMachines.KINETIC_INPUT_BOX, " S ", " H ", " ", 'S', AllBlocks.SHAFT, 'H', HULL); + registerMachineRecipe(provider, false, GTCreateMachines.KINETIC_OUTPUT_BOX, " ", " H ", " S ", 'S', AllBlocks.SHAFT, 'H', HULL); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityLoader.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityLoader.java index f145f42931..14006971ea 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityLoader.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/MetaTileEntityLoader.java @@ -12,6 +12,7 @@ import com.gregtechceu.gtceu.data.recipe.CraftingComponent; import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper; import com.tterrag.registrate.util.entry.ItemEntry; +import com.tterrag.registrate.util.entry.ItemProviderEntry; import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.Item; @@ -421,7 +422,7 @@ private static Object[] prepareRecipe(int tier, Object... recipe) { recipe[i] = new ItemStack(item); } else if (recipe[i] instanceof Block block) { recipe[i] = new ItemStack(block); - } else if (recipe[i] instanceof ItemEntry itemEntry) { + } else if (recipe[i] instanceof ItemProviderEntry itemEntry) { recipe[i] = itemEntry.asStack(); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/tags/IBiomeTagsProvider.java b/common/src/main/java/com/gregtechceu/gtceu/data/tags/IBiomeTagsProvider.java index db94cd8973..e382e7b2b0 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/tags/IBiomeTagsProvider.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/tags/IBiomeTagsProvider.java @@ -12,10 +12,13 @@ public interface IBiomeTagsProvider> { default void generateTags() { tag(CustomTags.IS_SWAMP, Biomes.SWAMP, Biomes.MANGROVE_SWAMP); addRubberTreeTag(); + addSandyTag(); } void addRubberTreeTag(); + void addSandyTag(); + @SafeVarargs private void tag(ResourceKey biome, TagKey... tags) { for (TagKey key : tags) { diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/GTRecipeWidget.java b/common/src/main/java/com/gregtechceu/gtceu/integration/GTRecipeWidget.java index 48f6e0d5c7..f76331b764 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/GTRecipeWidget.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/GTRecipeWidget.java @@ -87,10 +87,13 @@ public GTRecipeWidget(GTRecipe recipe) { slot.setOverlay(content.createOverlay(index >= recipe.getInputContents(ItemRecipeCapability.CAP).size())); slot.setOnAddedTooltips((w, tooltips) -> { var chance = content.chance; - if (content.chance < 1) { + if (chance < 1) { tooltips.add(chance == 0 ? Component.translatable("gtceu.gui.content.chance_0") : Component.translatable("gtceu.gui.content.chance_1", String.format("%.1f", chance * 100) + "%")); + if (content.tierChanceBoost > 0) { + tooltips.add(Component.translatable("gtceu.gui.content.tier_boost", String.format("%.1f", content.tierChanceBoost * 100) + "%")); + } } if (index >= recipe.getInputContents(ItemRecipeCapability.CAP).size()) { tooltips.add(Component.translatable("gtceu.gui.content.per_tick")); @@ -106,10 +109,13 @@ public GTRecipeWidget(GTRecipe recipe) { slot.setOverlay(content.createOverlay(index >= recipe.getOutputContents(ItemRecipeCapability.CAP).size())); slot.setOnAddedTooltips((w, tooltips) -> { var chance = content.chance; - if (content.chance < 1) { + if (chance < 1) { tooltips.add(chance == 0 ? Component.translatable("gtceu.gui.content.chance_0") : Component.translatable("gtceu.gui.content.chance_1", String.format("%.1f", chance * 100) + "%")); + if (content.tierChanceBoost > 0) { + tooltips.add(Component.translatable("gtceu.gui.content.tier_boost", String.format("%.1f", content.tierChanceBoost * 100) + "%")); + } } if (index >= recipe.getOutputContents(ItemRecipeCapability.CAP).size()) { tooltips.add(Component.translatable("gtceu.gui.content.per_tick")); @@ -125,10 +131,13 @@ public GTRecipeWidget(GTRecipe recipe) { tank.setOverlay(content.createOverlay(index >= recipe.getInputContents(FluidRecipeCapability.CAP).size())); tank.setOnAddedTooltips((w, tooltips) -> { var chance = content.chance; - if (content.chance < 1) { + if (chance < 1) { tooltips.add(chance == 0 ? Component.translatable("gtceu.gui.content.chance_0") : Component.translatable("gtceu.gui.content.chance_1", String.format("%.1f", chance * 100) + "%")); + if (content.tierChanceBoost > 0) { + tooltips.add(Component.translatable("gtceu.gui.content.tier_boost", String.format("%.1f", content.tierChanceBoost * 100) + "%")); + } } if (index >= recipe.getInputContents(FluidRecipeCapability.CAP).size()) { tooltips.add(Component.translatable("gtceu.gui.content.per_tick")); @@ -144,10 +153,13 @@ public GTRecipeWidget(GTRecipe recipe) { tank.setOverlay(content.createOverlay(index >= recipe.getOutputContents(FluidRecipeCapability.CAP).size())); tank.setOnAddedTooltips((w, tooltips) -> { var chance = content.chance; - if (content.chance < 1) { + if (chance < 1) { tooltips.add(chance == 0 ? Component.translatable("gtceu.gui.content.chance_0") : Component.translatable("gtceu.gui.content.chance_1", String.format("%.1f", chance * 100) + "%")); + if (content.tierChanceBoost > 0) { + tooltips.add(Component.translatable("gtceu.gui.content.tier_boost", String.format("%.1f", content.tierChanceBoost * 100) + "%")); + } } if (index >= recipe.getOutputContents(FluidRecipeCapability.CAP).size()) { tooltips.add(Component.translatable("gtceu.gui.content.per_tick")); diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTCEuServerEvents.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTCEuServerEvents.java index a77d4d5709..9ca4bc8f7c 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTCEuServerEvents.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTCEuServerEvents.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.integration.kjs; +import com.gregtechceu.gtceu.integration.kjs.events.GTFluidVeinEventJS; import com.gregtechceu.gtceu.integration.kjs.events.GTOreVeinEventJS; import dev.latvian.mods.kubejs.event.EventGroup; import dev.latvian.mods.kubejs.event.EventHandler; @@ -8,4 +9,5 @@ public interface GTCEuServerEvents { EventGroup GROUP = EventGroup.of("GTCEuServerEvents"); EventHandler ORE_VEIN_MODIFICATION = GROUP.server("oreVeins", () -> GTOreVeinEventJS.class); + EventHandler FLUID_VEIN_MODIFICATION = GROUP.server("fluidVeins", () -> GTFluidVeinEventJS.class); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTRegistryObjectBuilderTypes.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTRegistryObjectBuilderTypes.java index 3bb6e9bb54..cf09dbb41b 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTRegistryObjectBuilderTypes.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTRegistryObjectBuilderTypes.java @@ -16,7 +16,8 @@ import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; import com.gregtechceu.gtceu.integration.kjs.built.KJSTagPrefix; import com.gregtechceu.gtceu.integration.kjs.events.GTRegistryEventJS; -import dev.latvian.mods.kubejs.CommonProperties; +import dev.latvian.mods.kubejs.DevProperties; +import dev.latvian.mods.kubejs.script.ScriptType; import dev.latvian.mods.kubejs.util.ConsoleJS; import dev.latvian.mods.kubejs.util.UtilsJS; import net.minecraft.resources.ResourceLocation; @@ -111,7 +112,7 @@ public void addBuilder(BuilderBase builder) { throw new IllegalArgumentException("Can't add null builder in registry '" + registryKey + "'!"); } - if (CommonProperties.get().debugInfo) { + if (DevProperties.get().debugInfo) { ConsoleJS.STARTUP.info("~ " + registryKey + " | " + builder.id); } @@ -134,7 +135,7 @@ public BuilderType getDefaultType() { } public void postEvent() { - GTCEuStartupEvents.REGISTRY.post(registryKey, new GTRegistryEventJS<>(this)); + GTCEuStartupEvents.REGISTRY.post(ScriptType.STARTUP, registryKey, new GTRegistryEventJS<>(this)); } public static void registerFor(ResourceLocation registry) { @@ -142,7 +143,7 @@ public static void registerFor(ResourceLocation registry) { type.postEvent(); for (var builder : type.objects.values()) { - if (CommonProperties.get().debugInfo) { + if (DevProperties.get().debugInfo) { ConsoleJS.STARTUP.info("+ " + registry + " | " + builder.id); } builder.register(); diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java index 32c0744c96..c4d7d8135b 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java @@ -13,13 +13,11 @@ import com.gregtechceu.gtceu.api.data.chemical.material.stack.MaterialStack; import com.gregtechceu.gtceu.api.data.chemical.material.stack.UnificationEntry; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; -import com.gregtechceu.gtceu.api.data.worldgen.BiomeWeightModifier; -import com.gregtechceu.gtceu.api.data.worldgen.GTOreFeatureEntry; -import com.gregtechceu.gtceu.api.data.worldgen.IWorldGenLayer; -import com.gregtechceu.gtceu.api.data.worldgen.WorldGenLayers; +import com.gregtechceu.gtceu.api.data.worldgen.*; import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.api.item.tool.GTToolType; import com.gregtechceu.gtceu.api.machine.MachineDefinition; +import com.gregtechceu.gtceu.api.machine.multiblock.CleanroomType; import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility; import com.gregtechceu.gtceu.api.pattern.FactoryBlockPattern; import com.gregtechceu.gtceu.api.pattern.MultiblockShapeInfo; @@ -32,11 +30,11 @@ import com.gregtechceu.gtceu.integration.kjs.builders.prefix.BasicTagPrefixBuilder; import com.gregtechceu.gtceu.integration.kjs.builders.prefix.OreTagPrefixBuilder; import com.gregtechceu.gtceu.integration.kjs.helpers.MaterialStackWrapper; -import com.gregtechceu.gtceu.integration.kjs.recipe.GTRecipeBuilderJS; +import com.gregtechceu.gtceu.integration.kjs.recipe.GTRecipeSchema; import com.mojang.serialization.DataResult; import dev.latvian.mods.kubejs.KubeJSPlugin; -import dev.latvian.mods.kubejs.RegistryObjectBuilderTypes; -import dev.latvian.mods.kubejs.recipe.RegisterRecipeTypesEvent; +import dev.latvian.mods.kubejs.recipe.schema.RegisterRecipeSchemasEvent; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import dev.latvian.mods.kubejs.script.BindingsEvent; import dev.latvian.mods.kubejs.script.ScriptType; import dev.latvian.mods.kubejs.util.ClassFilter; @@ -69,18 +67,20 @@ public void init() { GTRegistryObjectBuilderTypes.RECIPE_TYPE.addType("basic", GTRecipeTypeBuilder.class, GTRecipeTypeBuilder::new, true); - GTRegistryObjectBuilderTypes.MACHINE.addType("simple", SimpleMachineBuilder.class, SimpleMachineBuilder::new, true); - GTRegistryObjectBuilderTypes.MACHINE.addType("steam", SteamMachineBuilder.class, SteamMachineBuilder::new, false); - GTRegistryObjectBuilderTypes.MACHINE.addType("generator", GeneratorBuilder.class, GeneratorBuilder::new, false); - GTRegistryObjectBuilderTypes.MACHINE.addType("multiblock", MultiblockBuilder.class, MultiblockBuilder::new, false); - GTRegistryObjectBuilderTypes.MACHINE.addType("kinetic", KineticMachineBuilder.class, KineticMachineBuilder::new, false); + GTRegistryObjectBuilderTypes.MACHINE.addType("simple", SimpleMachineBuilder.class, (id, args) -> SimpleMachineBuilder.createAll(id.getPath(), args), true); + GTRegistryObjectBuilderTypes.MACHINE.addType("custom", CustomTieredMachineBuilder.class, (id, args) -> CustomTieredMachineBuilder.createAll(id.getPath(), args), false); + GTRegistryObjectBuilderTypes.MACHINE.addType("steam", SteamMachineBuilder.class, (id, args) -> SteamMachineBuilder.createBoth(id.getPath(), args), false); + GTRegistryObjectBuilderTypes.MACHINE.addType("generator", GeneratorBuilder.class, (id, args) -> GeneratorBuilder.createAll(id.getPath(), args), false); + GTRegistryObjectBuilderTypes.MACHINE.addType("multiblock", CustomMultiblockBuilder.class, (id, args) -> CustomMultiblockBuilder.createMultiblock(id.getPath(), args), false); + GTRegistryObjectBuilderTypes.MACHINE.addType("primitive", CustomMultiblockBuilder.class, (id, args) -> CustomMultiblockBuilder.createPrimitiveMultiblock(id.getPath(), args), false); + GTRegistryObjectBuilderTypes.MACHINE.addType("kinetic", KineticMachineBuilder.class, (id, args) -> KineticMachineBuilder.createAll(id.getPath(), args), false); GTRegistryObjectBuilderTypes.WORLD_GEN_LAYER.addType("basic", WorldGenLayerBuilder.class, WorldGenLayerBuilder::new, true); GTRegistryObjectBuilderTypes.TAG_PREFIX.addType("basic", BasicTagPrefixBuilder.class, BasicTagPrefixBuilder::new, true); GTRegistryObjectBuilderTypes.TAG_PREFIX.addType("ore", OreTagPrefixBuilder.class, OreTagPrefixBuilder::new, false); - RegistryObjectBuilderTypes.BLOCK.addType("gtceu:coil", CoilBlockBuilder.class, CoilBlockBuilder::new); + RegistryInfo.BLOCK.addType("gtceu:coil", CoilBlockBuilder.class, CoilBlockBuilder::new); } @Override @@ -98,12 +98,11 @@ public void registerClasses(ScriptType type, ClassFilter filter) { } @Override - public void registerRecipeTypes(RegisterRecipeTypesEvent event) { - super.registerRecipeTypes(event); + public void registerRecipeSchemas(RegisterRecipeSchemasEvent event) { + super.registerRecipeSchemas(event); - event.register(GTCEu.id("gt_recipe_serializer"), GTRecipeBuilderJS::new); for (var entry : GTRegistries.RECIPE_TYPES.entries()) { - event.register(entry.getKey(), GTRecipeBuilderJS::new); + event.register(entry.getKey(), GTRecipeSchema.SCHEMA); } } @@ -124,6 +123,7 @@ public void registerBindings(BindingsEvent event) { event.add("UnificationEntry", UnificationEntry.class); event.add("RecipeCapability", RecipeCapability.class); event.add("GTFluidTypes", FluidTypes.class); + event.add("CleanroomType", CleanroomType.class); event.add("GTValues", GTValues.class); event.add("GTMaterialIconSet", MaterialIconSet.class); @@ -143,6 +143,9 @@ public void registerBindings(BindingsEvent event) { event.add("MaterialColor", MaterialColor.class); event.add("SoundType", SoundType.class); + event.add("GTOreVein", GTOreFeatureEntry.class); + event.add("GTLayerPattern", GTLayerPattern.class); + event.add("GTOres", GTOres.class); // ....TODO add global refs. for convenience, ppl do not need to import the java package themselves. } @@ -176,7 +179,7 @@ public void registerTypeWrappers(ScriptType type, TypeWrappers typeWrappers) { typeWrappers.register(TagPrefix.class, (ctx, o) -> { if (o instanceof TagPrefix tagPrefix) return tagPrefix; - if (o instanceof CharSequence chars) return TagPrefix.getPrefix(chars.toString()); + if (o instanceof CharSequence chars) return TagPrefix.get(chars.toString()); return null; }); typeWrappers.register(UnificationEntry.class, (ctx, o) -> { @@ -184,10 +187,10 @@ public void registerTypeWrappers(ScriptType type, TypeWrappers typeWrappers) { if (o instanceof CharSequence chars) { var values = chars.toString().split(":"); if (values.length == 1) { - return new UnificationEntry(TagPrefix.getPrefix(values[0])); + return new UnificationEntry(TagPrefix.get(values[0])); } if (values.length >= 2) { - return new UnificationEntry(TagPrefix.getPrefix(values[0]), GTMaterials.get(values[1])); + return new UnificationEntry(TagPrefix.get(values[0]), GTMaterials.get(values[1])); } } return null; diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/CoilBlockBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/CoilBlockBuilder.java index 6a475713b8..b65c3c1316 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/CoilBlockBuilder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/CoilBlockBuilder.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.Block; public class CoilBlockBuilder extends BlockBuilder { - public transient int temperature = 0, level = 0, energyDiscount = 0, tier = 0; + public transient int temperature = 0, level = 0, energyDiscount = 1, tier = 0; public transient Material material = GTMaterials.Air; public transient ResourceLocation texture = MissingTextureAtlasSprite.getLocation(); diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/ElementBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/ElementBuilder.java index 8f0c486c38..86f82feb3b 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/ElementBuilder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/ElementBuilder.java @@ -1,11 +1,8 @@ package com.gregtechceu.gtceu.integration.kjs.builders; import com.gregtechceu.gtceu.api.data.chemical.Element; -import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; import com.gregtechceu.gtceu.common.data.GTElements; -import com.gregtechceu.gtceu.integration.kjs.GregTechKubeJSPlugin; -import dev.latvian.mods.kubejs.RegistryObjectBuilderTypes; import net.minecraft.resources.ResourceLocation; public class ElementBuilder extends BuilderBase { @@ -15,7 +12,7 @@ public class ElementBuilder extends BuilderBase { public ElementBuilder(ResourceLocation i, Object... args) { super(i); - protons = ((Number)args[0]).intValue(); + protons = args[0] instanceof Number number ? number.intValue() : Double.valueOf(args[0].toString()).intValue(); // special handling if somehow called from create(name, type, args...) (it does that) neutrons = ((Number)args[1]).intValue(); halfLifeSeconds = ((Number)args[2]).intValue(); decayTo = args[3] == null ? null : args[3].toString(); diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/FluidVeinBuilderJS.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/FluidVeinBuilderJS.java new file mode 100644 index 0000000000..c1254acf3e --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/FluidVeinBuilderJS.java @@ -0,0 +1,91 @@ +package com.gregtechceu.gtceu.integration.kjs.builders; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.data.worldgen.BiomeWeightModifier; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; +import com.mojang.datafixers.util.Pair; +import com.mojang.serialization.JsonOps; +import dev.latvian.mods.rhino.util.HideFromJS; +import lombok.Setter; +import lombok.experimental.Accessors; +import net.minecraft.core.*; +import net.minecraft.data.BuiltinRegistries; +import net.minecraft.resources.RegistryOps; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.material.Fluid; + +import java.util.LinkedList; +import java.util.List; +import java.util.function.Supplier; + +@Accessors(chain = true, fluent = true) +public class FluidVeinBuilderJS { + private final ResourceLocation id; + @Setter + private int weight; // weight value for determining which vein will appear + @Setter + private int minimumYield, maximumYield;// the [minimum, maximum) yields + @Setter + private int depletionAmount; // amount of fluid the vein gets drained by + @Setter + private int depletionChance = 1; // the chance [0, 100] that the vein will deplete by 1 + @Setter + private int depletedYield; // yield after the vein is depleted + @Setter + private Supplier fluid; // the fluid which the vein contains + private final List biomes = new LinkedList<>(); + + private final transient JsonArray dimensions = new JsonArray(); + + public FluidVeinBuilderJS(ResourceLocation id) { + this.id = id; + } + + public FluidVeinBuilderJS yield(int min, int max) { + return minimumYield(min).maximumYield(max); + } + + + public FluidVeinBuilderJS addSpawnDimension(ResourceLocation... dimensions) { + for (ResourceLocation dimension : dimensions) { + this.dimensions.add(dimension.toString()); + } + return this; + } + + public FluidVeinBuilderJS biomes(int weight, String biomes) { + this.biomes.add( + new BiomeWeightModifier(biomes.startsWith("#") ? + BuiltinRegistries.BIOME.getOrCreateTag(TagKey.create(Registry.BIOME_REGISTRY, new ResourceLocation(biomes.substring(1)))) : + HolderSet.direct(BuiltinRegistries.BIOME.getHolderOrThrow(ResourceKey.create(Registry.BIOME_REGISTRY, new ResourceLocation(biomes)))), + weight)); + return this; + } + + public FluidVeinBuilderJS biomes(int weight, String... biomes) { + List> biomeKeys = new LinkedList<>(); + for (String biome : biomes) { + biomeKeys.add(biome.startsWith("#") ? + BuiltinRegistries.BIOME.getOrCreateTag(TagKey.create(Registry.BIOME_REGISTRY, new ResourceLocation(biome.substring(1)))) : + HolderSet.direct(BuiltinRegistries.BIOME.getHolderOrThrow(ResourceKey.create(Registry.BIOME_REGISTRY, new ResourceLocation(biome)))) + ); + } + HolderSet holders = HolderSet.direct(biomeKeys.stream().flatMap(HolderSet::stream).toList()); + this.biomes.add(new BiomeWeightModifier(holders, weight)); + return this; + } + + @HideFromJS + public BedrockFluidDefinition build() { + RegistryOps registryOps = RegistryOps.create(JsonOps.INSTANCE, RegistryAccess.BUILTIN.get()); + HolderSet dimensions = RegistryCodecs.homogeneousList(Registry.DIMENSION_TYPE_REGISTRY) + .decode(registryOps, this.dimensions.size() == 1 ? this.dimensions.get(0) : this.dimensions).map(Pair::getFirst).getOrThrow(false, GTCEu.LOGGER::error); + return new BedrockFluidDefinition(id, weight, minimumYield, maximumYield, depletionAmount, depletionChance, depletedYield, fluid, biomes, dimensions); + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/OreVeinBuilderJS.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/OreVeinBuilderJS.java index 285611786c..3310ec1e94 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/OreVeinBuilderJS.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/OreVeinBuilderJS.java @@ -8,6 +8,8 @@ import com.gregtechceu.gtceu.api.data.worldgen.IWorldGenLayer; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.JsonOps; +import dev.latvian.mods.rhino.util.HideFromJS; +import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; import net.minecraft.core.HolderSet; @@ -21,6 +23,7 @@ import net.minecraft.world.level.levelgen.placement.HeightRangePlacement; @SuppressWarnings("unused") +@Accessors(chain = true, fluent = true) public class OreVeinBuilderJS { private final ResourceLocation id; @Setter @@ -38,6 +41,8 @@ public class OreVeinBuilderJS { private final transient JsonArray dimensionFilter = new JsonArray(); private final transient JsonArray biomeFilter = new JsonArray(); + @Getter + private boolean isBuilt = false; public OreVeinBuilderJS(ResourceLocation id) { this.id = id; @@ -53,12 +58,18 @@ public OreVeinBuilderJS addSpawnBiome(String biome) { return this; } + public GTOreFeatureEntry.VeinGenerator generatorBuilder(ResourceLocation id) { + return build().generator(id); + } + + @HideFromJS public GTOreFeatureEntry build() { RegistryOps registryOps = RegistryOps.create(JsonOps.INSTANCE, RegistryAccess.BUILTIN.get()); HolderSet dimensions = RegistryCodecs.homogeneousList(Registry.DIMENSION_TYPE_REGISTRY) .decode(registryOps, dimensionFilter.size() == 1 ? dimensionFilter.get(0) : dimensionFilter).map(Pair::getFirst).getOrThrow(false, GTCEu.LOGGER::error); HolderSet biomes = RegistryCodecs.homogeneousList(Registry.BIOME_REGISTRY) .decode(registryOps, biomeFilter.size() == 1 ? biomeFilter.get(0) : biomeFilter).map(Pair::getFirst).getOrThrow(false, GTCEu.LOGGER::error); + isBuilt = true; return new GTOreFeatureEntry(id, clusterSize, density, weight, layer, dimensions, heightRange, discardChanceOnAirExposure, biomes, biomeWeightModifier, generator); } diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/CustomMultiblockBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/CustomMultiblockBuilder.java new file mode 100644 index 0000000000..dea20d5748 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/CustomMultiblockBuilder.java @@ -0,0 +1,72 @@ +package com.gregtechceu.gtceu.integration.kjs.builders.machine; + +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.block.MetaMachineBlock; +import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; +import com.gregtechceu.gtceu.api.item.MetaMachineItem; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; +import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; +import com.gregtechceu.gtceu.api.machine.multiblock.MultiblockControllerMachine; +import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; +import com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder; +import com.gregtechceu.gtceu.api.machine.multiblock.TieredWorkableElectricMultiblockMachine; +import com.gregtechceu.gtceu.common.machine.multiblock.primitive.PrimitiveFancyUIWorkableMachine; + +import java.util.function.BiFunction; +import java.util.function.Function; + +public class CustomMultiblockBuilder extends MultiblockMachineBuilder { + protected CustomMultiblockBuilder(String name, Function metaMachine) { + super(GTRegistries.REGISTRATE, name, metaMachine, MetaMachineBlock::new, MetaMachineItem::new, MetaMachineBlockEntity::createBlockEntity); + } + + public static CustomMultiblockBuilder[] tieredMultis(String name, + BiFunction factory, + Integer... tiers) { + CustomMultiblockBuilder[] builders = new CustomMultiblockBuilder[tiers.length]; + for (int i = 0; i < tiers.length; i++) { + int tier = tiers[i]; + var builder = new CustomMultiblockBuilder(GTValues.VN[tier].toLowerCase() + "_" + name, holder -> factory.apply(holder, tier)) + .tier(tier); + builders[i] = builder; + } + return builders; + } + + @Override + public CustomMultiblockBuilder tier(int tier) { + return (CustomMultiblockBuilder) super.tier(tier); + } + + + @SuppressWarnings("unchecked") + public static MachineBuilder createMultiblock(String name, Object... args) { + CustomMultiblockBuilder[] builders; + int start = 0; + while (start < args.length && (!(args[start] instanceof Number) || !(args[start] instanceof Number[]) || !(args[start] instanceof int[]))) { + ++start; + } + Object[] tierObjects = MachineFunctionPresets.copyArgs(args, start); + Integer[] tiers = MachineFunctionPresets.mapTierArray(tierObjects); + if (tiers.length > 0) { + if (args.length > 0 && args[0] instanceof BiFunction machineFunction) { + builders = tieredMultis(name, (BiFunction) machineFunction, tiers); + } else { + builders = tieredMultis(name, TieredWorkableElectricMultiblockMachine::new, tiers); + } + } else { + if (args.length > 0 && args[0] instanceof Function machineFunction) { + return new CustomMultiblockBuilder(name, (Function)machineFunction); + } else { + return new CustomMultiblockBuilder(name, WorkableElectricMultiblockMachine::new); + } + } + return MachineFunctionPresets.builder(name, builders, CustomMultiblockBuilder.class, MultiblockMachineDefinition::createDefinition, MetaMachineBlock::new, MetaMachineBlockEntity::createBlockEntity); + } + + public static MachineBuilder createPrimitiveMultiblock(String name, Object... args) { + return new CustomMultiblockBuilder(name, (holder) -> new PrimitiveFancyUIWorkableMachine(holder, args)); + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/CustomTieredMachineBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/CustomTieredMachineBuilder.java new file mode 100644 index 0000000000..df44f12749 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/CustomTieredMachineBuilder.java @@ -0,0 +1,44 @@ +package com.gregtechceu.gtceu.integration.kjs.builders.machine; + +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.block.MetaMachineBlock; +import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; +import com.gregtechceu.gtceu.api.machine.MachineDefinition; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; + +import java.util.function.BiFunction; +import java.util.function.Function; + +public class CustomTieredMachineBuilder extends SimpleMachineBuilder { + public CustomTieredMachineBuilder(String name, Function machineConstructor) { + super(name, machineConstructor); + } + + @Override + public CustomTieredMachineBuilder tier(int tier) { + return (CustomTieredMachineBuilder) super.tier(tier); + } + + private static CustomTieredMachineBuilder[] customTiered(String name, + BiFunction machineConstructor, + Integer... tiers) { + CustomTieredMachineBuilder[] builders = new CustomTieredMachineBuilder[tiers.length]; + for (int tier : tiers) { + CustomTieredMachineBuilder register = new CustomTieredMachineBuilder(GTValues.VN[tier].toLowerCase() + "_" + name, holder -> machineConstructor.apply(holder, tier)).tier(tier); + builders[tier] = register; + } + return builders; + } + + @SuppressWarnings("unchecked") + public static MachineBuilder createAll(String name, Object... args) { + CustomTieredMachineBuilder[] builders = new CustomTieredMachineBuilder[0]; + if (args.length > 1 && args[1] instanceof BiFunction machineFunction) { + Object[] tiers = MachineFunctionPresets.copyArgs(args, 1); + builders = customTiered(name, (BiFunction) machineFunction, MachineFunctionPresets.mapTierArray(tiers)); + } + return MachineFunctionPresets.builder(name, builders, CustomTieredMachineBuilder.class, MachineDefinition::createDefinition, MetaMachineBlock::new, MetaMachineBlockEntity::createBlockEntity); + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/GeneratorBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/GeneratorBuilder.java index 2f01e4be6f..bad65bc112 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/GeneratorBuilder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/GeneratorBuilder.java @@ -1,9 +1,26 @@ package com.gregtechceu.gtceu.integration.kjs.builders.machine; +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.block.MetaMachineBlock; +import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; +import com.gregtechceu.gtceu.api.data.RotationState; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.api.machine.MachineDefinition; -import com.gregtechceu.gtceu.common.data.GTMachines; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.machine.SimpleGeneratorMachine; +import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; +import com.gregtechceu.gtceu.client.renderer.machine.SimpleGeneratorMachineRenderer; + +import java.util.Arrays; +import java.util.function.BiConsumer; +import java.util.function.Function; + +import static com.gregtechceu.gtceu.api.GTValues.VLVH; +import static com.gregtechceu.gtceu.api.GTValues.VLVT; +import static com.gregtechceu.gtceu.common.data.GTMachines.defaultTankSizeFunction; +import static com.gregtechceu.gtceu.common.data.GTMachines.explosion; +import static com.gregtechceu.gtceu.utils.FormattingUtil.toEnglishName; /** * @author Screret @@ -11,13 +28,41 @@ * @implNote MachineBuilder */ public class GeneratorBuilder extends SimpleMachineBuilder { - public GeneratorBuilder(ResourceLocation i, Object... args) { - super(i, args); + public GeneratorBuilder(String name, Function machineConstructor) { + super(name, machineConstructor); } @Override - public MachineDefinition register() { - value = GTMachines.registerSimpleGenerator(name, recipeType, tier -> tankScalingFunction.apply(tier), tiers)[0]; - return value; + public GeneratorBuilder tier(int tier) { + return (GeneratorBuilder) super.tier(tier); + } + + private static GeneratorBuilder[] tieredMachines(String name, + BiConsumer builderConsumer, + Integer... tiers) { + GeneratorBuilder[] builders = new GeneratorBuilder[tiers.length]; + for (int i = 0; i < tiers.length; i++) { + int tier = tiers[i]; + var register = new GeneratorBuilder(GTValues.VN[tier].toLowerCase() + "_" + name, holder -> new SimpleGeneratorMachine(holder, tier, defaultTankSizeFunction)).tier(tier); + builderConsumer.accept(register, tier); + builders[i] = register; + } + return builders; + } + + private static void simple(GeneratorBuilder builder, int tier) { + builder.langValue("%s %s Generator %s".formatted(VLVH[tier], toEnglishName(builder.id.getPath()), VLVT[tier])) + //.editableUI(SimpleGeneratorMachine.EDITABLE_UI_CREATOR.apply(GTCEu.id(builder.id.getPath()), recipeType)) + .rotationState(RotationState.NON_Y_AXIS) + //.recipeType(recipeType) + .recipeModifier(SimpleGeneratorMachine::recipeModifier, true) + .renderer(() -> new SimpleGeneratorMachineRenderer(tier, GTCEu.id("block/generators/" + builder.id.getPath()))) + .tooltips(explosion()); + //.tooltips(workableTiered(tier, GTValues.V[tier], GTValues.V[tier] * 64, recipeType, tankScalingFunction.apply(tier), false)) + } + + public static MachineBuilder createAll(String name, Object... args) { + GeneratorBuilder[] builders = tieredMachines(name, GeneratorBuilder::simple, MachineFunctionPresets.mapTierArray(args)); + return MachineFunctionPresets.builder(name, builders, GeneratorBuilder.class, MachineDefinition::createDefinition, MetaMachineBlock::new, MetaMachineBlockEntity::createBlockEntity); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KineticMachineBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KineticMachineBuilder.java index 7f207512b0..bea49da355 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KineticMachineBuilder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KineticMachineBuilder.java @@ -1,32 +1,109 @@ package com.gregtechceu.gtceu.integration.kjs.builders.machine; -import com.gregtechceu.gtceu.api.machine.MachineDefinition; -import com.gregtechceu.gtceu.common.data.GTCreateMachines; +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.block.MetaMachineBlock; +import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; +import com.gregtechceu.gtceu.api.data.RotationState; +import com.gregtechceu.gtceu.api.item.MetaMachineItem; +import com.gregtechceu.gtceu.api.recipe.OverclockingLogic; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; +import com.gregtechceu.gtceu.client.instance.SplitShaftInstance; +import com.gregtechceu.gtceu.client.renderer.machine.KineticWorkableTieredHullMachineRenderer; +import com.gregtechceu.gtceu.common.block.KineticMachineBlock; +import com.gregtechceu.gtceu.common.blockentity.KineticMachineBlockEntity; import com.gregtechceu.gtceu.common.data.GTMachines; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; +import com.gregtechceu.gtceu.common.data.GTRecipeModifiers; +import com.gregtechceu.gtceu.common.machine.KineticMachineDefinition; +import com.gregtechceu.gtceu.common.machine.kinetic.SimpleKineticElectricWorkableMachine; +import com.tterrag.registrate.util.nullness.NonNullConsumer; +import it.unimi.dsi.fastutil.ints.Int2LongFunction; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockBehaviour; + +import java.util.Arrays; +import java.util.function.BiConsumer; +import java.util.function.Function; + +import static com.gregtechceu.gtceu.api.GTValues.VLVH; +import static com.gregtechceu.gtceu.api.GTValues.VLVT; +import static com.gregtechceu.gtceu.common.data.GTMachines.explosion; +import static com.gregtechceu.gtceu.utils.FormattingUtil.toEnglishName; /** * @author Screret * @date 2023/4/01 * @implNote MachineBuilder */ -public class KineticMachineBuilder extends MachineBuilder { - public transient int[] tiers; +public class KineticMachineBuilder extends MachineBuilder { + public transient Int2LongFunction tankScalingFunction; // reflected in MachineFunctionPresets. DO NOT CHANGE! + private final Object[] passedArguments; - public KineticMachineBuilder(ResourceLocation i, Object... args) { - super(i); - this.tiers = GTMachines.ELECTRIC_TIERS; + public KineticMachineBuilder(String name, boolean isSource, int tier, Object... args) { + super(GTRegistries.REGISTRATE, name, (id) -> new KineticMachineDefinition(id, isSource, GTValues.V[tier]), (holder) -> new SimpleKineticElectricWorkableMachine(holder, tier, GTMachines.defaultTankSizeFunction, args), KineticMachineBlock::new, MetaMachineItem::new, KineticMachineBlockEntity::create); + this.tankScalingFunction = GTMachines.defaultTankSizeFunction; + this.passedArguments = args; + } + + public KineticMachineBuilder isSource(boolean isSource) { + this.definitionFactory((id) -> new KineticMachineDefinition(id, isSource, GTValues.V[this.tier()])); + return this; } - public KineticMachineBuilder tiers(int... tiers) { - this.tiers = tiers; + @SuppressWarnings("unused") // Accessed via reflection + public KineticMachineBuilder tankScalingFunction(Function tankScalingFunction) { + this.tankScalingFunction = tier -> tankScalingFunction.apply(tier).longValue(); + this.metaMachine((holder) -> new SimpleKineticElectricWorkableMachine(holder, tier(), this.tankScalingFunction, passedArguments)); return this; } @Override - public MachineDefinition register() { - value = GTCreateMachines.registerSimpleKineticElectricMachine(name, recipeType, tiers)[0]; - return value; + public KineticMachineBuilder tier(int tier) { + return (KineticMachineBuilder) super.tier(tier); + } + + @Override + public KineticMachineBuilder hasTESR(boolean hasTESR) { + return (KineticMachineBuilder) super.hasTESR(hasTESR); + } + + @Override + public KineticMachineBuilder onBlockEntityRegister(NonNullConsumer> onBlockEntityRegister) { + return (KineticMachineBuilder) super.onBlockEntityRegister(onBlockEntityRegister); + } + + private static KineticMachineBuilder[] tieredMachines(String name, + BiConsumer, Integer> builderConsumer, + Integer... tiers) { + KineticMachineBuilder[] builders = new KineticMachineBuilder[tiers.length]; + for (int i = 0; i < tiers.length; i++) { + int tier = tiers[i]; + var register = new KineticMachineBuilder(GTValues.VN[tier].toLowerCase() + "_" + name, false, tier) + .tier(tier) + .hasTESR(true) + .onBlockEntityRegister(type -> KineticMachineBlockEntity.onBlockEntityRegister(type, () -> SplitShaftInstance::new, false)); + builderConsumer.accept(register, tier); + builders[i] = register; + } + return builders; + } + + private static void simple(MachineBuilder builder, int tier) { + builder.langValue("%s %s %s".formatted(VLVH[tier], toEnglishName(builder.id.getPath()), VLVT[tier])) + .rotationState(RotationState.NON_Y_AXIS) + //.editableUI(SimpleTieredMachine.EDITABLE_UI_CREATOR.apply(GTCEu.id(builder.id.getPath()), recipeType)) + .blockProp(BlockBehaviour.Properties::dynamicShape) + .blockProp(BlockBehaviour.Properties::noOcclusion) + .recipeModifier(GTRecipeModifiers.ELECTRIC_OVERCLOCK.apply(OverclockingLogic.NON_PERFECT_OVERCLOCK)) + .renderer(() -> new KineticWorkableTieredHullMachineRenderer(tier, GTCEu.id("block/machine/kinetic_electric_machine"), GTCEu.id("block/machines/" + builder.id.getPath()))) + .tooltips(explosion()); + //.tooltips(workableTiered(tier, GTValues.V[tier], GTValues.V[tier] * 64, recipeType, defaultTankSizeFunction.apply(tier), true)); + } + + public static MachineBuilder createAll(String name, Object... args) { + KineticMachineBuilder[] builders = tieredMachines(name, KineticMachineBuilder::simple, MachineFunctionPresets.mapTierArray(args)); + return MachineFunctionPresets.builder(name, builders, KineticMachineBuilder.class, (id) -> new KineticMachineDefinition(id, false, 0), MetaMachineBlock::new, MetaMachineBlockEntity::createBlockEntity); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MachineBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MachineBuilder.java deleted file mode 100644 index 03299d8e29..0000000000 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MachineBuilder.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.gregtechceu.gtceu.integration.kjs.builders.machine; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.machine.MachineDefinition; -import com.gregtechceu.gtceu.api.recipe.GTRecipeType; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; -import com.gregtechceu.gtceu.common.data.GTRecipeTypes; -import net.minecraft.resources.ResourceLocation; - -/** - * @author Screret - * @date 2023/4/01 - * @implNote MachineBuilder - */ -public abstract class MachineBuilder extends BuilderBase { - public transient String name; - public transient GTRecipeType recipeType; - - public MachineBuilder(ResourceLocation i, Object... args) { - super(new ResourceLocation(GTCEu.MOD_ID, i.getPath())); - this.name = i.getPath(); - this.recipeType = null /*GTRecipeTypes.get(args[0].toString())*/; - } - - public MachineBuilder recipeType(GTRecipeType type) { - this.recipeType = type; - return this; - } -} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MachineFunctionPresets.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MachineFunctionPresets.java new file mode 100644 index 0000000000..1d2eba25a8 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MachineFunctionPresets.java @@ -0,0 +1,323 @@ +package com.gregtechceu.gtceu.integration.kjs.builders.machine; + +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.block.IMachineBlock; +import com.gregtechceu.gtceu.api.data.RotationState; +import com.gregtechceu.gtceu.api.gui.editor.EditableMachineUI; +import com.gregtechceu.gtceu.api.item.MetaMachineItem; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; +import com.gregtechceu.gtceu.api.machine.MachineDefinition; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.machine.SimpleTieredMachine; +import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility; +import com.gregtechceu.gtceu.api.recipe.GTRecipe; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; +import com.gregtechceu.gtceu.common.data.GTMachines; +import com.lowdragmc.lowdraglib.client.renderer.IRenderer; +import com.tterrag.registrate.builders.BlockBuilder; +import com.tterrag.registrate.builders.ItemBuilder; +import com.tterrag.registrate.util.nullness.NonNullConsumer; +import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.apache.commons.lang3.function.TriFunction; +import org.jetbrains.annotations.Nullable; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; +import java.util.function.*; +import java.util.stream.Stream; + +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +@SuppressWarnings({"unused"}) +public class MachineFunctionPresets { + @FunctionalInterface + public interface MachineConstructorFunction extends BiFunction { + @Override + MetaMachine apply(IMachineBlockEntity machineBlockEntity, Integer integer); + } + + public static Integer[] mapTierArray(Object[] tiers) { + return Arrays.stream(tiers) + .flatMap(object -> object.getClass().isArray() ? object.getClass().componentType().isPrimitive() ? Arrays.stream((int[]) object).boxed() : Arrays.stream((Object[])object) : Stream.of(object)) + .filter(Number.class::isInstance) + .map(Number.class::cast) + .map(Number::intValue) + .toArray(Integer[]::new); + } + + public static Object[] copyArgs(Object[] original, int offset) { + Object[] copy = new Object[original.length - offset]; + System.arraycopy(original, offset, copy, 0, original.length - offset); + return copy; + } + + public static > MachineBuilder builder(String name, B[] builders, Class builderClass, + Function definitionFactory, + BiFunction blockFactory, + TriFunction, BlockPos, BlockState, IMachineBlockEntity> blockEntityFactory) { + return new MachineBuilder(GTRegistries.REGISTRATE, name, definitionFactory, holder -> null, blockFactory, MetaMachineItem::new, blockEntityFactory) { + public MachineBuilder renderer(@Nullable Supplier renderer) { + for (var builder : builders) { + builder.renderer(renderer); + } + return this; + } + + @Override + public MachineBuilder shape(VoxelShape shape) { + for (var builder : builders) { + builder.shape(shape); + } + return this; + } + + @Override + public MachineBuilder rotationState(RotationState rotationState) { + for (var builder : builders) { + builder.rotationState(rotationState); + } + return this; + } + + @Override + public MachineBuilder hasTESR(boolean hasTESR) { + for (var builder : builders) { + builder.hasTESR(hasTESR); + } + return this; + } + + @Override + public MachineBuilder blockProp(NonNullUnaryOperator blockProp) { + for (var builder : builders) { + builder.blockProp(blockProp); + } + return this; + } + + @Override + public MachineBuilder itemProp(NonNullUnaryOperator itemProp) { + for (var builder : builders) { + builder.itemProp(itemProp); + } + return this; + } + + @Override + public MachineBuilder blockBuilder(Consumer> blockBuilder) { + for (var builder : builders) { + builder.blockBuilder(blockBuilder); + } + return this; + } + + @Override + public MachineBuilder itemBuilder(Consumer> itemBuilder) { + for (var builder : builders) { + builder.itemBuilder(itemBuilder); + } + return this; + } + + @Override + public MachineBuilder onBlockEntityRegister(NonNullConsumer> onBlockEntityRegister) { + for (var builder : builders) { + builder.onBlockEntityRegister(onBlockEntityRegister); + } + return this; + } + + @Override + public MachineBuilder recipeType(GTRecipeType recipeType) { + for (var builder : builders) { + builder.recipeType(recipeType); + } + return this; + } + + @Override + public MachineBuilder tier(int tier) { + for (var builder : builders) { + builder.tier(tier); + } + return this; + } + + @Override + public MachineBuilder paintingColor(int paintingColor) { + for (var builder : builders) { + builder.paintingColor(paintingColor); + } + return this; + } + + @Override + public MachineBuilder itemColor(BiFunction itemColor) { + for (var builder : builders) { + builder.itemColor(itemColor); + } + return this; + } + + @Override + public MachineBuilder abilities(PartAbility... abilities) { + for (var builder : builders) { + builder.abilities(abilities); + } + return this; + } + + public MachineBuilder tooltips(Component... tooltips) { + for (var builder : builders) { + builder.tooltips(tooltips); + } + return this; + } + + @Override + public MachineBuilder tooltipBuilder(BiConsumer> tooltipBuilder) { + for (var builder : builders) { + builder.tooltipBuilder(tooltipBuilder); + } + return this; + } + + @Override + public MachineBuilder recipeModifier(BiFunction recipeModifier) { + for (var builder : builders) { + builder.recipeModifier(recipeModifier); + } + return this; + } + + @Override + public MachineBuilder alwaysTryModifyRecipe(boolean alwaysTryModifyRecipe) { + for (var builder : builders) { + builder.alwaysTryModifyRecipe(alwaysTryModifyRecipe); + } + return this; + } + + @Override + public MachineBuilder appearance(Supplier appearance) { + for (var builder : builders) { + builder.appearance(appearance); + } + return this; + } + + @Override + public MachineBuilder editableUI(@Nullable EditableMachineUI editableUI) { + for (var builder : builders) { + builder.editableUI(editableUI); + } + return this; + } + + @Override + public MachineBuilder langValue(String langValue) { + for (var builder : builders) { + builder.langValue(langValue); + } + return this; + } + + public MachineBuilder recipeModifier(BiFunction recipeModifier, boolean alwaysTryModifyRecipe) { + recipeModifier(recipeModifier); + alwaysTryModifyRecipe(alwaysTryModifyRecipe); + return this; + } + + // reflect the tankScalingFunction method because I'm a little bitch teehee (and because it's not a common method, but in both SimpleMachineBuilder and KineticMachineBuilder, which can't inherit from each other) + // does nothing if not found, or errors otherwise + public MachineBuilder tankScalingFunction(Function tankScalingFunction) { + try { + Method method = builderClass.getDeclaredMethod("tankScalingFunction", Function.class); + + for (var builder : builders) { + method.invoke(builder, tankScalingFunction); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { + + } + + return this; + } + + @SuppressWarnings("unchecked") + @Nullable + public Function getTankScalingFunction(B builder) { + try { + Field field = builderClass.getField("tankScalingFunction"); + + return (Function) field.get(builder); + } catch (NoSuchFieldException | IllegalAccessException exception) { + return null; + } + } + + public MachineBuilder workableTooltip(GTRecipeType recipeType) { + for (var builder : builders) { + int tier = builder.tier(); + Function tankScalingFunction = getTankScalingFunction(builder); + builder.tooltips(GTMachines.workableTiered(tier, GTValues.V[tier], GTValues.V[tier] * 64, recipeType, tankScalingFunction != null ? tankScalingFunction.apply(tier) : GTMachines.defaultTankSizeFunction.apply(tier), true)); + } + return this; + } + + public MachineBuilder recipeType(GTRecipeType recipeType, boolean applyWorkableTooltip) { + this.recipeType(recipeType); + if (applyWorkableTooltip) { + workableTooltip(recipeType); + } + return this; + } + + public MachineBuilder recipeType(GTRecipeType recipeType, boolean applyWorkableTooltip, boolean applyDefaultGUIFunction) { + this.recipeType(recipeType); + if (applyWorkableTooltip) { + workableTooltip(recipeType); + } + if (applyDefaultGUIFunction) { + editableUI(SimpleTieredMachine.EDITABLE_UI_CREATOR.apply(this.id, recipeType)); + } + return this; + } + + public MachineBuilder isSource(boolean isSource) { + if (KineticMachineBuilder.class.isAssignableFrom(builderClass)) { + for (var builder : builders) { + ((KineticMachineBuilder) builder).isSource(isSource); + } + } + return this; + } + + @Override + public D register() { + for (var builder : builders) { + value = builder.register(); + } + return value; + } + }; + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MultiblockBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MultiblockBuilder.java deleted file mode 100644 index 29d6627cca..0000000000 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MultiblockBuilder.java +++ /dev/null @@ -1,214 +0,0 @@ -package com.gregtechceu.gtceu.integration.kjs.builders.machine; - -import com.gregtechceu.gtceu.api.data.RotationState; -import com.gregtechceu.gtceu.api.item.MetaMachineItem; -import com.gregtechceu.gtceu.api.machine.MachineDefinition; -import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; -import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility; -import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine; -import com.gregtechceu.gtceu.api.pattern.BlockPattern; -import com.gregtechceu.gtceu.api.pattern.MultiblockShapeInfo; -import com.gregtechceu.gtceu.api.recipe.GTRecipeType; -import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder; -import com.lowdragmc.lowdraglib.client.renderer.IRenderer; -import com.tterrag.registrate.builders.BlockBuilder; -import com.tterrag.registrate.builders.ItemBuilder; -import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.ItemLike; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.shapes.VoxelShape; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.function.*; - -/** - * @author Screret - * @date 2023/4/01 - * @implNote MachineBuilder - */ -@SuppressWarnings("unused") -public class MultiblockBuilder extends MachineBuilder { - public transient MultiblockMachineBuilder builder; - - public MultiblockBuilder(ResourceLocation i, Object... args) { - super(i); - this.builder = GTRegistries.REGISTRATE.multiblock(name, WorkableElectricMultiblockMachine::new); - } - - public MultiblockBuilder shapeInfo(Function shape) { - builder.shapeInfo(shape); - return this; - } - - public MultiblockBuilder shapeInfos(Function> shapes) { - builder.shapeInfos(shapes); - return this; - } - - public MultiblockBuilder recoveryItems(Supplier items) { - builder.recoveryItems(items); - return this; - } - - public MultiblockBuilder recoveryStacks(Supplier items) { - builder.recoveryStacks(items); - return this; - } - - public MultiblockBuilder renderer(@Nullable Supplier renderer) { - builder.renderer(renderer); - return this; - } - - public MultiblockBuilder shape(VoxelShape shape) { - builder.shape(shape); - return this; - } - - public MultiblockBuilder rotationState(RotationState rotationState) { - builder.rotationState(rotationState); - return this; - } - - public MultiblockBuilder hasTESR(boolean hasTESR) { - builder.hasTESR(hasTESR); - return this; - } - - public MultiblockBuilder blockProp(NonNullUnaryOperator blockProp) { - builder.blockProp(blockProp); - return this; - } - - public MultiblockBuilder itemProp(NonNullUnaryOperator itemProp) { - builder.itemProp(itemProp); - return this; - } - - public MultiblockBuilder blockBuilder(Consumer> blockBuilder) { - builder.blockBuilder(blockBuilder); - return this; - } - - public MultiblockBuilder itemBuilder(Consumer> itemBuilder) { - builder.itemBuilder(itemBuilder); - return this; - } - - @Override - public MultiblockBuilder recipeType(GTRecipeType recipeType) { - builder.recipeType(recipeType); - return this; - } - - public MultiblockBuilder tier(int tier) { - builder.tier(tier); - return this; - } - - public MultiblockBuilder itemColor(BiFunction itemColor) { - builder.itemColor(itemColor); - return this; - } - - public MultiblockBuilder modelRenderer(Supplier model) { - builder.modelRenderer(model); - return this; - } - - public MultiblockBuilder defaultModelRenderer() { - builder.defaultModelRenderer(); - return this; - } - - public MultiblockBuilder overlayTieredHullRenderer(String name) { - builder.overlayTieredHullRenderer(name); - return this; - } - - public MultiblockBuilder workableTieredHullRenderer(ResourceLocation workableModel) { - builder.workableTieredHullRenderer(workableModel); - return this; - } - - public MultiblockBuilder workableCasingRenderer(ResourceLocation baseCasing, ResourceLocation overlayModel) { - builder.workableCasingRenderer(baseCasing, overlayModel); - return this; - } - - public MultiblockBuilder workableCasingRenderer(ResourceLocation baseCasing, ResourceLocation overlayModel, boolean tint) { - builder.workableCasingRenderer(baseCasing, overlayModel, tint); - return this; - } - - public MultiblockBuilder tooltipBuilder(BiConsumer> tooltipBuilder) { - builder.tooltipBuilder(tooltipBuilder); - return this; - } - - public MultiblockBuilder appearance(Supplier state) { - builder.appearance(state); - return this; - } - - public MultiblockBuilder appearanceBlock(Supplier block) { - builder.appearanceBlock(block); - return this; - } - - public MultiblockBuilder langValue(String langValue) { - builder.langValue(langValue); - return this; - } - - public MultiblockBuilder overlaySteamHullRenderer(String name) { - builder.overlaySteamHullRenderer(name); - return this; - } - - public MultiblockBuilder workableSteamHullRenderer(boolean isHighPressure, ResourceLocation workableModel) { - builder.workableSteamHullRenderer(isHighPressure, workableModel); - return this; - } - - public MultiblockBuilder tooltips(Component... components) { - builder.tooltips(components); - return this; - } - - public MultiblockBuilder abilities(PartAbility... abilities) { - builder.abilities(abilities); - return this; - } - - public MultiblockBuilder paintingColor(int paintingColor) { - builder.paintingColor(paintingColor); - return this; - } - - public MultiblockBuilder pattern(Function patternFunction) { - builder.pattern(patternFunction); - return this; - } - - private MachineDefinition value; - - @Override - public MachineDefinition register() { - value = this.builder.register(); - return value; - } - - @Override - public MachineDefinition get() { - return value; - } -} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/SimpleMachineBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/SimpleMachineBuilder.java index c2c0d72c58..0241888780 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/SimpleMachineBuilder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/SimpleMachineBuilder.java @@ -1,47 +1,85 @@ package com.gregtechceu.gtceu.integration.kjs.builders.machine; +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.GTValues; +import com.gregtechceu.gtceu.api.block.MetaMachineBlock; +import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; +import com.gregtechceu.gtceu.api.data.RotationState; +import com.gregtechceu.gtceu.api.item.MetaMachineItem; +import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity; import com.gregtechceu.gtceu.api.machine.MachineDefinition; +import com.gregtechceu.gtceu.api.machine.MetaMachine; +import com.gregtechceu.gtceu.api.machine.SimpleTieredMachine; +import com.gregtechceu.gtceu.api.recipe.OverclockingLogic; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; import com.gregtechceu.gtceu.common.data.GTMachines; -import it.unimi.dsi.fastutil.Function; +import com.gregtechceu.gtceu.common.data.GTRecipeModifiers; import it.unimi.dsi.fastutil.ints.Int2LongFunction; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; + +import java.util.Arrays; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.stream.Stream; + +import static com.gregtechceu.gtceu.api.GTValues.VLVH; +import static com.gregtechceu.gtceu.api.GTValues.VLVT; +import static com.gregtechceu.gtceu.common.data.GTMachines.defaultTankSizeFunction; +import static com.gregtechceu.gtceu.common.data.GTMachines.explosion; +import static com.gregtechceu.gtceu.utils.FormattingUtil.toEnglishName; /** * @author Screret * @date 2023/4/01 * @implNote MachineBuilder */ -public class SimpleMachineBuilder extends MachineBuilder { - public transient Int2LongFunction tankScalingFunction; - public transient int[] tiers; - - protected MachineDefinition value = null; +public class SimpleMachineBuilder extends MachineBuilder { + public transient Int2LongFunction tankScalingFunction; // reflected in MachineFunctionPresets. DO NOT CHANGE! - public SimpleMachineBuilder(ResourceLocation i, Object... args) { - super(i); + public SimpleMachineBuilder(String name, Function machineConstructor) { + super(GTRegistries.REGISTRATE, name, MachineDefinition::createDefinition, machineConstructor, MetaMachineBlock::new, MetaMachineItem::new, MetaMachineBlockEntity::createBlockEntity); this.tankScalingFunction = GTMachines.defaultTankSizeFunction; - this.tiers = GTMachines.ELECTRIC_TIERS; - } - - public SimpleMachineBuilder tiers(int... tiers) { - this.tiers = tiers; - return this; } - public SimpleMachineBuilder tankScalingFunction(Function tankScalingFunction) { + @SuppressWarnings("unused") // Accessed via reflection + public SimpleMachineBuilder tankScalingFunction(Function tankScalingFunction) { this.tankScalingFunction = tier -> tankScalingFunction.apply(tier).longValue(); + this.metaMachine((holder) -> new SimpleTieredMachine(holder, tier(), this.tankScalingFunction)); return this; } @Override - public MachineDefinition register() { - value = GTMachines.registerSimpleMachines(name, recipeType, tier -> tankScalingFunction.apply(tier), tiers)[0]; - return value; + public SimpleMachineBuilder tier(int tier) { + return (SimpleMachineBuilder) super.tier(tier); } - @Override - public MachineDefinition get() { - return value; + private static SimpleMachineBuilder[] tieredMachines(String name, + BiConsumer builderConsumer, + Integer... tiers) { + SimpleMachineBuilder[] builders = new SimpleMachineBuilder[tiers.length]; + for (int i = 0; i < tiers.length; i++) { + int tier = tiers[i]; + SimpleMachineBuilder register = new SimpleMachineBuilder(GTValues.VN[tier].toLowerCase() + "_" + name, holder -> new SimpleTieredMachine(holder, tier, defaultTankSizeFunction)).tier(tier); + builderConsumer.accept(register, tier); + builders[i] = register; + } + return builders; + } + + public static > void simple(T builder, int tier) { + builder.langValue("%s %s %s".formatted(VLVH[tier], toEnglishName(builder.id.getPath()), VLVT[tier])) + //.editableUI(SimpleTieredMachine.EDITABLE_UI_CREATOR.apply(GTCEu.id(builder.id.getPath()), recipeType)) + .rotationState(RotationState.NON_Y_AXIS) + //.recipeType(recipeType) + .recipeModifier(GTRecipeModifiers.ELECTRIC_OVERCLOCK.apply(OverclockingLogic.NON_PERFECT_OVERCLOCK)) + .workableTieredHullRenderer(GTCEu.id("block/machines/" + builder.id.getPath())) + .tooltips(explosion()); + //.tooltips(workableTiered(tier, GTValues.V[tier], GTValues.V[tier] * 64, recipeType, tankScalingFunction.apply(tier), true)) + } + + public static MachineBuilder createAll(String name, Object... args) { + SimpleMachineBuilder[] builders = tieredMachines(name, SimpleMachineBuilder::simple, MachineFunctionPresets.mapTierArray(args)); + return MachineFunctionPresets.builder(name, builders, SimpleMachineBuilder.class, MachineDefinition::createDefinition, MetaMachineBlock::new, MetaMachineBlockEntity::createBlockEntity); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/SteamMachineBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/SteamMachineBuilder.java index 3fb936e8cd..25522125ad 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/SteamMachineBuilder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/SteamMachineBuilder.java @@ -1,31 +1,61 @@ package com.gregtechceu.gtceu.integration.kjs.builders.machine; +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.block.MetaMachineBlock; +import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity; +import com.gregtechceu.gtceu.api.data.RotationState; +import com.gregtechceu.gtceu.api.item.MetaMachineItem; import com.gregtechceu.gtceu.api.machine.MachineDefinition; -import com.gregtechceu.gtceu.common.data.GTMachines; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.block.Block; +import com.gregtechceu.gtceu.api.machine.steam.SimpleSteamMachine; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; +import com.gregtechceu.gtceu.client.renderer.machine.WorkableSteamMachineRenderer; + +import static com.gregtechceu.gtceu.api.GTValues.VLVH; +import static com.gregtechceu.gtceu.api.GTValues.VLVT; +import static com.gregtechceu.gtceu.utils.FormattingUtil.toEnglishName; /** * @author Screret * @date 2023/4/01 * @implNote MachineBuilder */ -public class SteamMachineBuilder extends MachineBuilder { - private MachineDefinition value; +public class SteamMachineBuilder extends MachineBuilder { + + public SteamMachineBuilder(String id, boolean isHighPressure, Object... args) { + super(GTRegistries.REGISTRATE, id, MachineDefinition::createDefinition, holder -> new SimpleSteamMachine(holder, isHighPressure, args), MetaMachineBlock::new, MetaMachineItem::new, MetaMachineBlockEntity::createBlockEntity); + } - public SteamMachineBuilder(ResourceLocation i, Object... args) { - super(i); + public static > void simple(T builder, int tier) { + builder.langValue("%s %s %s".formatted(VLVH[tier], toEnglishName(builder.id.getPath()), VLVT[tier])) + .rotationState(RotationState.NON_Y_AXIS) + //.recipeType(recipeType) + .recipeModifier(SimpleSteamMachine::recipeModifier) + .renderer(() -> new WorkableSteamMachineRenderer(tier > 0, GTCEu.id("block/machines/" + builder.id.getPath()))); } - @Override - public MachineDefinition register() { - var pair = GTMachines.registerSimpleSteamMachines(name, recipeType); - value = pair.first(); - return value; + private static SteamMachineBuilder[] createBuilder(String name, boolean hasHighPressure, Object... args) { + SteamMachineBuilder lp = new SteamMachineBuilder("lp_" + name, false, args); + return hasHighPressure ? new SteamMachineBuilder[] { lp, new SteamMachineBuilder("hp_" + name, true, args) } : new SteamMachineBuilder[] { lp }; } - @Override - public MachineDefinition get() { - return value; + public static MachineBuilder createBoth(String name, Object... args) { + SteamMachineBuilder[] builders; + if (args.length > 0) { + Object[] argsCopy; + boolean hasHighPressure; + if (args[0] instanceof Boolean hasHP) { + argsCopy = MachineFunctionPresets.copyArgs(args, 1); + hasHighPressure = hasHP; + } else { + argsCopy = args; + hasHighPressure = true; + } + builders = createBuilder(name, hasHighPressure, argsCopy); + } else { + builders = createBuilder(name, true, args); + } + + return MachineFunctionPresets.builder(name, builders, SteamMachineBuilder.class, MachineDefinition::createDefinition, MetaMachineBlock::new, MetaMachineBlockEntity::createBlockEntity); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTFluidVeinEventJS.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTFluidVeinEventJS.java new file mode 100644 index 0000000000..3945e103f8 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTFluidVeinEventJS.java @@ -0,0 +1,30 @@ +package com.gregtechceu.gtceu.integration.kjs.events; + +import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.integration.kjs.builders.FluidVeinBuilderJS; +import dev.latvian.mods.kubejs.event.EventJS; +import net.minecraft.resources.ResourceLocation; + +import java.util.function.Consumer; + +public class GTFluidVeinEventJS extends EventJS { + + public GTFluidVeinEventJS() { + + } + + public void add(ResourceLocation id, Consumer consumer) { + FluidVeinBuilderJS builder = new FluidVeinBuilderJS(id); + consumer.accept(builder); + builder.build(); + } + + public void remove(ResourceLocation id) { + GTRegistries.BEDROCK_FLUID_DEFINITIONS.remove(id); + } + + public void modify(ResourceLocation id, Consumer consumer) { + consumer.accept(GTRegistries.BEDROCK_FLUID_DEFINITIONS.get(id)); + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTOreVeinEventJS.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTOreVeinEventJS.java index 484c077b40..04c7688eba 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTOreVeinEventJS.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTOreVeinEventJS.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.integration.kjs.events; import com.gregtechceu.gtceu.api.data.worldgen.GTOreFeatureEntry; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.integration.kjs.builders.OreVeinBuilderJS; import dev.latvian.mods.kubejs.event.EventJS; import net.minecraft.resources.ResourceLocation; @@ -16,14 +17,16 @@ public GTOreVeinEventJS() { public void add(ResourceLocation id, Consumer consumer) { OreVeinBuilderJS builder = new OreVeinBuilderJS(id); consumer.accept(builder); - builder.build(); + if (!builder.isBuilt()) { + builder.build(); + } } public void remove(ResourceLocation id) { - GTOreFeatureEntry.ALL.remove(id); + GTRegistries.ORE_VEINS.remove(id); } public void modify(ResourceLocation id, Consumer consumer) { - consumer.accept(GTOreFeatureEntry.ALL.get(id)); + consumer.accept(GTRegistries.ORE_VEINS.get(id)); } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTRegistryEventJS.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTRegistryEventJS.java index 42fe8d4832..bd9179aec7 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTRegistryEventJS.java +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTRegistryEventJS.java @@ -7,6 +7,8 @@ import dev.latvian.mods.kubejs.script.ScriptType; import dev.latvian.mods.kubejs.util.UtilsJS; +import java.util.stream.Stream; + public class GTRegistryEventJS extends StartupEventJS { private final GTRegistryObjectBuilderTypes registry; @@ -32,6 +34,24 @@ public BuilderBase create(String id, String type) { return b; } + public BuilderBase create(String id, String type, Object... args) { + var t = registry.types.get(type); + + if (t == null) { + return create(id, Stream.of(type, args).flatMap(arg -> arg instanceof Object[] array ? Stream.of(array) : Stream.of(arg)).map(Object.class::cast).toArray()); + } + + var b = t.factory().createBuilder(UtilsJS.getMCID(ScriptType.STARTUP.manager.get().context, GTCEu.appendId(id)), args); + + if (b == null) { + throw new IllegalArgumentException("Unknown type '" + type + "' for object '" + id + "'!"); + } else { + registry.addBuilder(b); + } + + return b; + } + public BuilderBase create(String id) { var t = registry.getDefaultType(); diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeBuilderJS.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeBuilderJS.java deleted file mode 100644 index bd086dfca6..0000000000 --- a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeBuilderJS.java +++ /dev/null @@ -1,585 +0,0 @@ -package com.gregtechceu.gtceu.integration.kjs.recipe; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.capability.recipe.*; -import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.gregtechceu.gtceu.api.data.chemical.material.stack.UnificationEntry; -import com.gregtechceu.gtceu.api.data.tag.TagPrefix; -import com.gregtechceu.gtceu.api.machine.MachineDefinition; -import com.gregtechceu.gtceu.api.machine.multiblock.CleanroomType; -import com.gregtechceu.gtceu.api.recipe.GTRecipeSerializer; -import com.gregtechceu.gtceu.api.recipe.GTRecipeType; -import com.gregtechceu.gtceu.api.recipe.RecipeCondition; -import com.gregtechceu.gtceu.api.recipe.content.Content; -import com.gregtechceu.gtceu.api.recipe.ingredient.SizedIngredient; -import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.common.data.GTRecipeTypes; -import com.gregtechceu.gtceu.common.item.IntCircuitBehaviour; -import com.gregtechceu.gtceu.common.recipe.*; -import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; -import com.lowdragmc.lowdraglib.LDLib; -import com.lowdragmc.lowdraglib.side.fluid.FluidStack; -import com.lowdragmc.lowdraglib.utils.NBTToJsonConverter; -import dev.latvian.mods.kubejs.recipe.*; -import dev.latvian.mods.rhino.util.HideFromJS; -import net.minecraft.core.Registry; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.nbt.TagParser; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; -import net.minecraft.util.GsonHelper; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.function.Supplier; - -@SuppressWarnings("unused") -public class GTRecipeBuilderJS extends RecipeJS { - private GTRecipeBuilder backingBuilder; - - @Override - public void create(RecipeArguments args) { - this.id = ResourceLocation.tryParse(args.getString(0, this.type.getMod() + ":kjs_" + this.getUniqueId())); - this.id = new ResourceLocation(this.getOrCreateId().getNamespace(), this.type.getId().getPath() + "/" + this.id.getPath()); - backingBuilder = GTRecipeTypes.get(this.type.toString()).recipeBuilder(this.id); - } - - @HideFromJS - @Override - public RecipeJS id(ResourceLocation _id) { - return super.id(_id); - } - - @Override - public void deserialize() { - String recipeType = GsonHelper.getAsString(json, "type"); - int duration = json.has("duration") ? GsonHelper.getAsInt(json, "duration") : 100; - Component component = json.has("text") ? Component.translatable(GsonHelper.getAsString(json, "text")) : null; - CompoundTag data = new CompoundTag(); - try { - if (json.has("data")) - data = TagParser.parseTag(json.get("data").toString()); - } catch (Exception e) { - e.printStackTrace(); - } - Map, List> inputs = GTRecipeSerializer.SERIALIZER.capabilitiesFromJson(json.has("inputs") ? json.getAsJsonObject("inputs") : new JsonObject()); - Map, List> tickInputs = GTRecipeSerializer.SERIALIZER.capabilitiesFromJson(json.has("tickInputs") ? json.getAsJsonObject("tickInputs") : new JsonObject()); - Map, List> outputs = GTRecipeSerializer.SERIALIZER.capabilitiesFromJson(json.has("outputs") ? json.getAsJsonObject("outputs") : new JsonObject()); - Map, List> tickOutputs = GTRecipeSerializer.SERIALIZER.capabilitiesFromJson(json.has("tickOutputs") ? json.getAsJsonObject("tickOutputs") : new JsonObject()); - List conditions = new ArrayList<>(); - JsonArray conditionsJson = json.has("recipeConditions") ? json.getAsJsonArray("recipeConditions") : new JsonArray(); - for (JsonElement jsonElement : conditionsJson) { - if (jsonElement instanceof JsonObject jsonObject) { - var conditionKey = GsonHelper.getAsString(jsonObject, "type", ""); - var clazz = GTRegistries.RECIPE_CONDITIONS.get(conditionKey); - if (clazz != null) { - RecipeCondition condition = RecipeCondition.create(clazz); - if (condition != null) { - conditions.add(condition.deserialize(GsonHelper.getAsJsonObject(jsonObject, "data", new JsonObject()))); - } - } - } - } - boolean isFuel = GsonHelper.getAsBoolean(json, "isFuel", false); - backingBuilder = new GTRecipeBuilder(id, (GTRecipeType) Registry.RECIPE_TYPE.get(GTCEu.appendId(recipeType))) - .duration(duration) - .isFuel(isFuel); - backingBuilder.data = data; - backingBuilder.input.putAll(inputs); - backingBuilder.tickInput.putAll(tickInputs); - backingBuilder.output.putAll(outputs); - backingBuilder.tickOutput.putAll(tickOutputs); - backingBuilder.conditions.addAll(conditions); - } - - @Override - public void serialize() { - json.addProperty("duration", Math.abs(backingBuilder.duration)); - if (backingBuilder.data != null && !backingBuilder.data.isEmpty()) { - json.add("data", NBTToJsonConverter.getObject(backingBuilder.data)); - } - if (serializeInputs) { - if (!backingBuilder.input.isEmpty()) { - json.add("inputs", backingBuilder.capabilitiesToJson(backingBuilder.input)); - } - if (!backingBuilder.tickInput.isEmpty()) { - json.add("tickInputs", backingBuilder.capabilitiesToJson(backingBuilder.tickInput)); - } - } - if (serializeOutputs) { - if (!backingBuilder.output.isEmpty()) { - json.add("outputs", backingBuilder.capabilitiesToJson(backingBuilder.output)); - } - if (!backingBuilder.tickOutput.isEmpty()) { - json.add("tickOutputs", backingBuilder.capabilitiesToJson(backingBuilder.tickOutput)); - } - } - - if (!backingBuilder.conditions.isEmpty()) { - JsonArray array = new JsonArray(); - for (RecipeCondition condition : backingBuilder.conditions) { - JsonObject cond = new JsonObject(); - cond.addProperty("type", GTRegistries.RECIPE_CONDITIONS.getKey(condition.getClass())); - cond.add("data", condition.serialize()); - array.add(cond); - } - json.add("recipeConditions", array); - } - if (backingBuilder.isFuel) { - json.addProperty("isFuel", true); - } - } - - public GTRecipeBuilderJS duration(int duration) { - backingBuilder.duration(duration); - return this; - } - - public GTRecipeBuilderJS perTick(boolean perTick) { - backingBuilder.perTick(perTick); - return this; - } - - public GTRecipeBuilderJS slotName(String slotName) { - backingBuilder.slotName(slotName); - return this; - } - - public GTRecipeBuilderJS uiName(String uiName) { - backingBuilder.uiName(uiName); - return this; - } - - public GTRecipeBuilderJS chance(float chance) { - backingBuilder.chance(chance); - return this; - } - - public GTRecipeBuilderJS input(RecipeCapability capability, T... obj) { - backingBuilder.input(capability, obj); - return this; - } - - public GTRecipeBuilderJS output(RecipeCapability capability, T... obj) { - backingBuilder.output(capability, obj); - return this; - } - - public GTRecipeBuilderJS inputs(RecipeCapability capability, Object... obj) { - backingBuilder.inputs(capability, obj); - return this; - } - - public GTRecipeBuilderJS outputs(RecipeCapability capability, Object... obj) { - backingBuilder.outputs(capability, obj); - return this; - } - - public GTRecipeBuilderJS addCondition(RecipeCondition condition) { - backingBuilder.addCondition(condition); - return this; - } - - public GTRecipeBuilderJS inputEU(long eu) { - return input(EURecipeCapability.CAP, eu); - } - - public GTRecipeBuilderJS EUt(long eu) { - backingBuilder.EUt(eu); - return this; - } - - public GTRecipeBuilderJS outputEU(long eu) { - return output(EURecipeCapability.CAP, eu); - } - - // for kjs - public GTRecipeBuilderJS itemInputs(Ingredient... inputs) { - return input(ItemRecipeCapability.CAP, inputs); - } - - public GTRecipeBuilderJS itemInput(UnificationEntry input) { - return inputItems(input); - } - - public GTRecipeBuilderJS itemInput(UnificationEntry input, int count) { - return inputItems(input, count); - } - - public GTRecipeBuilderJS inputItems(Ingredient... inputs) { - return input(ItemRecipeCapability.CAP, inputs); - } - - public GTRecipeBuilderJS inputItems(ItemStack... inputs) { - for (ItemStack itemStack : inputs) { - if (itemStack.isEmpty()) { - LDLib.LOGGER.error("gt recipe {} input items is empty", id); - throw new IllegalArgumentException(id + ": input items is empty"); - } - } - return input(ItemRecipeCapability.CAP, Arrays.stream(inputs).map(SizedIngredient::create).toArray(Ingredient[]::new)); - } - - public GTRecipeBuilderJS inputItems(TagKey tag, int amount) { - return inputItems(SizedIngredient.create(tag, amount)); - } - - public GTRecipeBuilderJS inputItems(TagKey tag) { - return inputItems(SizedIngredient.create(tag, 1)); - } - - public GTRecipeBuilderJS inputItems(Item input, int amount) { - return inputItems(new ItemStack(input, amount)); - } - - public GTRecipeBuilderJS inputItems(Item input) { - return inputItems(Ingredient.of(input)); - } - - public GTRecipeBuilderJS inputItems(Supplier input) { - return inputItems(Ingredient.of(input.get())); - } - - public GTRecipeBuilderJS inputItems(Supplier input, int amount) { - return inputItems(new ItemStack(input.get(), amount)); - } - - public GTRecipeBuilderJS inputItems(TagPrefix orePrefix, Material material) { - return inputItems(orePrefix, material, 1); - } - - public GTRecipeBuilderJS inputItems(UnificationEntry input) { - return inputItems(input.tagPrefix, input.material, 1); - } - - public GTRecipeBuilderJS inputItems(UnificationEntry input, int count) { - return inputItems(input.tagPrefix, input.material, count); - } - - public GTRecipeBuilderJS inputItems(TagPrefix orePrefix, @Nullable Material material, int count) { - return inputItems(ChemicalHelper.getTag(orePrefix, material), count); - } - - public GTRecipeBuilderJS inputItems(MachineDefinition machine) { - return inputItems(machine, 1); - } - - public GTRecipeBuilderJS inputItems(MachineDefinition machine, int count) { - return inputItems(machine.asStack(count)); - } - - // for kjs - public GTRecipeBuilderJS itemOutputs(ItemStack... outputs) { - return outputItems(outputs); - } - - public GTRecipeBuilderJS itemOutput(UnificationEntry unificationEntry) { - return outputItems(unificationEntry.tagPrefix, unificationEntry.material); - } - - public GTRecipeBuilderJS itemOutput(UnificationEntry unificationEntry, int count) { - return outputItems(unificationEntry.tagPrefix, unificationEntry.material, count); - } - - public GTRecipeBuilderJS outputItems(ItemStack... outputs) { - for (ItemStack itemStack : outputs) { - if (itemStack.isEmpty()) { - LDLib.LOGGER.error("gt recipe {} output items is empty", id); - throw new IllegalArgumentException(id + ": output items is empty"); - } - } - return output(ItemRecipeCapability.CAP, Arrays.stream(outputs).map(SizedIngredient::create).toArray(Ingredient[]::new)); - } - - public GTRecipeBuilderJS outputItems(Item input, int amount) { - return outputItems(new ItemStack(input, amount)); - } - - public GTRecipeBuilderJS outputItems(Item input) { - return outputItems(new ItemStack(input)); - } - - public GTRecipeBuilderJS outputItems(Supplier input) { - return outputItems(new ItemStack(input.get())); - } - - public GTRecipeBuilderJS outputItems(Supplier input, int amount) { - return outputItems(new ItemStack(input.get(), amount)); - } - - public GTRecipeBuilderJS outputItems(TagPrefix orePrefix, Material material) { - return outputItems(orePrefix, material, 1); - } - - public GTRecipeBuilderJS outputItems(TagPrefix orePrefix, Material material, int count) { - return outputItems(ChemicalHelper.get(orePrefix, material, count)); - } - - public GTRecipeBuilderJS outputItems(MachineDefinition machine) { - return outputItems(machine, 1); - } - - public GTRecipeBuilderJS outputItems(MachineDefinition machine, int count) { - return outputItems(machine.asStack(count)); - } - - public GTRecipeBuilderJS notConsumable(ItemStack itemStack) { - backingBuilder.notConsumable(itemStack); - return this; - } - - public GTRecipeBuilderJS notConsumable(Item item) { - backingBuilder.notConsumable(item); - return this; - } - - public GTRecipeBuilderJS notConsumable(Supplier item) { - backingBuilder.notConsumable(item); - return this; - } - - public GTRecipeBuilderJS notConsumable(TagPrefix orePrefix, Material material) { - backingBuilder.notConsumable(orePrefix, material); - return this; - } - - public GTRecipeBuilderJS circuitMeta(int configuration) { - return notConsumable(IntCircuitBehaviour.stack(configuration)); - } - - public GTRecipeBuilderJS chancedOutput(ItemStack stack, int chance, int tierChanceBoost) { - backingBuilder.chancedOutput(stack, chance, tierChanceBoost); - return this; - } - - public GTRecipeBuilderJS chancedOutput(TagPrefix tag, Material mat, int chance, int tierChanceBoost) { - return chancedOutput(ChemicalHelper.get(tag, mat), chance, tierChanceBoost); - } - - public GTRecipeBuilderJS chancedOutput(TagPrefix tag, Material mat, int count, int chance, int tierChanceBoost) { - return chancedOutput(ChemicalHelper.get(tag, mat, count), chance, tierChanceBoost); - } - - public GTRecipeBuilderJS inputFluids(FluidStack... inputs) { - return input(FluidRecipeCapability.CAP, inputs); - } - - public GTRecipeBuilderJS outputFluids(FluidStack... outputs) { - return output(FluidRecipeCapability.CAP, outputs); - } - - public GTRecipeBuilderJS inputStress(float stress) { - return input(StressRecipeCapability.CAP, stress); - } - - public GTRecipeBuilderJS outputStress(float stress) { - return output(StressRecipeCapability.CAP, stress); - } - - ////////////////////////////////////// - //********** DATA ***********// - ////////////////////////////////////// - public GTRecipeBuilderJS addData(String key, Tag data) { - backingBuilder.addData(key, data); - return this; - } - - public GTRecipeBuilderJS addData(String key, int data) { - backingBuilder.addData(key, data); - return this; - } - - public GTRecipeBuilderJS addData(String key, String data) { - backingBuilder.addData(key, data); - return this; - } - - public GTRecipeBuilderJS addData(String key, Float data) { - backingBuilder.addData(key, data); - return this; - } - - public GTRecipeBuilderJS addData(String key, boolean data) { - backingBuilder.addData(key, data); - return this; - } - - public GTRecipeBuilderJS blastFurnaceTemp(int blastTemp) { - return addData("ebf_temp", blastTemp); - } - - public GTRecipeBuilderJS explosivesAmount(int explosivesAmount) { - return addData("explosives_amount", explosivesAmount); - } - - public GTRecipeBuilderJS explosivesType(ItemStack explosivesType) { - return addData("explosives_type", explosivesType.save(new CompoundTag())); - } - - public GTRecipeBuilderJS solderMultiplier(int multiplier) { - return addData("solderMultiplier", multiplier); - } - - ////////////////////////////////////// - //******* CONDITIONS ********// - ////////////////////////////////////// - - public GTRecipeBuilderJS cleanroom(CleanroomType sterileCleanroom) { - return this; - } - - public GTRecipeBuilderJS dimension(ResourceLocation dimension, boolean reverse) { - return addCondition(new DimensionCondition(dimension).setReverse(reverse)); - } - - public GTRecipeBuilderJS dimension(ResourceLocation dimension) { - return dimension(dimension, false); - } - - public GTRecipeBuilderJS biome(ResourceLocation biome, boolean reverse) { - return addCondition(new BiomeCondition(biome).setReverse(reverse)); - } - - public GTRecipeBuilderJS biome(ResourceLocation biome) { - return biome(biome, false); - } - - public GTRecipeBuilderJS rain(float level, boolean reverse) { - return addCondition(new RainingCondition(level).setReverse(reverse)); - } - - public GTRecipeBuilderJS rain(float level) { - return rain(level, false); - } - - public GTRecipeBuilderJS thunder(float level, boolean reverse) { - return addCondition(new ThunderCondition(level).setReverse(reverse)); - } - - public GTRecipeBuilderJS thunder(float level) { - return thunder(level, false); - } - - public GTRecipeBuilderJS posY(int min, int max, boolean reverse) { - return addCondition(new PositionYCondition(min, max).setReverse(reverse)); - } - - public GTRecipeBuilderJS posY(int min, int max) { - return posY(min, max, false); - } - - public GTRecipeBuilderJS rpm(float rpm, boolean reverse) { - return addCondition(new RPMCondition(rpm).setReverse(reverse)); - } - - public GTRecipeBuilderJS rpm(float rpm) { - return rpm(rpm, false); - } - - @Override - public boolean hasInput(IngredientMatch match) { - if (backingBuilder.input.containsKey(ItemRecipeCapability.CAP)) { - for (Content item : backingBuilder.input.get(ItemRecipeCapability.CAP)) { - Ingredient in = ItemRecipeCapability.CAP.of(item.content); - if (match.contains(in)) { - return true; - } - } - } - if (backingBuilder.tickInput.containsKey(ItemRecipeCapability.CAP)) { - for (Content item : backingBuilder.tickInput.get(ItemRecipeCapability.CAP)) { - Ingredient in = ItemRecipeCapability.CAP.of(item.content); - if (match.contains(in)) { - return true; - } - } - } - return false; - } - - @Override - public boolean replaceInput(IngredientMatch match, Ingredient with, ItemInputTransformer transformer) { - boolean changed = false; - - var itemInputs = backingBuilder.input.get(ItemRecipeCapability.CAP); - if (itemInputs != null && replaceInputScan(match, with, transformer, itemInputs)) { - return true; - } - itemInputs = backingBuilder.tickInput.get(ItemRecipeCapability.CAP); - if (itemInputs != null && replaceInputScan(match, with, transformer, itemInputs)) { - return true; - } - - return false; - } - - public boolean replaceInputScan(IngredientMatch match, Ingredient with, ItemInputTransformer transformer, List stuff) { - for (Content content : stuff) { - Ingredient in = ItemRecipeCapability.CAP.of(content.content); - if (match.contains(in)) { - content.content = transformer.transform(this, match, in, with); - return true; - } - } - return false; - } - - @Override - public boolean hasOutput(IngredientMatch match) { - if (backingBuilder.output.containsKey(ItemRecipeCapability.CAP)) { - for (Content item : backingBuilder.output.get(ItemRecipeCapability.CAP)) { - Ingredient in = ItemRecipeCapability.CAP.of(item.content); - if (match.contains(in)) { - return true; - } - } - } - if (backingBuilder.tickOutput.containsKey(ItemRecipeCapability.CAP)) { - for (Content item : backingBuilder.tickOutput.get(ItemRecipeCapability.CAP)) { - Ingredient in = ItemRecipeCapability.CAP.of(item.content); - if (match.contains(in)) { - return true; - } - } - } - return false; - } - - @Override - public boolean replaceOutput(IngredientMatch match, ItemStack with, ItemOutputTransformer transformer) { - var itemOutputs = backingBuilder.output.get(ItemRecipeCapability.CAP); - if (itemOutputs != null && replaceOutputScan(match, with, transformer, itemOutputs)) { - return true; - } - itemOutputs = backingBuilder.tickOutput.get(ItemRecipeCapability.CAP); - if (itemOutputs != null && replaceOutputScan(match, with, transformer, itemOutputs)) { - return true; - } - - return false; - } - - public boolean replaceOutputScan(IngredientMatch match, ItemStack with, ItemOutputTransformer transformer, List stuff) { - for (Content content : stuff) { - Ingredient in = ItemRecipeCapability.CAP.of(content.content); - if (match.contains(in)) { - content.content = transformer.transform(this, match, in.getItems()[0], with); - return true; - } - } - return false; - } - -} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java new file mode 100644 index 0000000000..0fa9c1ab2d --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java @@ -0,0 +1,538 @@ +package com.gregtechceu.gtceu.integration.kjs.recipe; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.capability.recipe.*; +import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; +import com.gregtechceu.gtceu.api.data.chemical.material.Material; +import com.gregtechceu.gtceu.api.data.chemical.material.stack.UnificationEntry; +import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.machine.MachineDefinition; +import com.gregtechceu.gtceu.api.machine.multiblock.CleanroomType; +import com.gregtechceu.gtceu.api.recipe.RecipeCondition; +import com.gregtechceu.gtceu.api.recipe.content.Content; +import com.gregtechceu.gtceu.api.recipe.ingredient.NBTIngredient; +import com.gregtechceu.gtceu.api.recipe.ingredient.SizedIngredient; +import com.gregtechceu.gtceu.common.item.IntCircuitBehaviour; +import com.gregtechceu.gtceu.common.recipe.*; +import com.gregtechceu.gtceu.integration.kjs.recipe.components.CapabilityMap; +import com.gregtechceu.gtceu.integration.kjs.recipe.components.CapabilityMapComponent; +import com.gregtechceu.gtceu.integration.kjs.recipe.components.ContentJS; +import com.gregtechceu.gtceu.integration.kjs.recipe.components.GTRecipeComponents; +import com.lowdragmc.lowdraglib.LDLib; +import dev.latvian.mods.kubejs.fluid.FluidStackJS; +import dev.latvian.mods.kubejs.item.InputItem; +import dev.latvian.mods.kubejs.item.OutputItem; +import dev.latvian.mods.kubejs.recipe.RecipeJS; +import dev.latvian.mods.kubejs.recipe.RecipeKey; +import dev.latvian.mods.kubejs.recipe.component.BooleanComponent; +import dev.latvian.mods.kubejs.recipe.component.RecipeComponentBuilder; +import dev.latvian.mods.kubejs.recipe.component.TimeComponent; +import dev.latvian.mods.kubejs.recipe.schema.RecipeSchema; +import dev.latvian.mods.rhino.util.HideFromJS; +import lombok.Setter; +import lombok.experimental.Accessors; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import org.apache.commons.lang3.ArrayUtils; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.Map; +import java.util.function.Supplier; + +public interface GTRecipeSchema { + + @SuppressWarnings({"unused", "UnusedReturnValue"}) + @Accessors(chain = true, fluent = true) + class GTRecipeJS extends RecipeJS { + @Setter + public boolean perTick; + @Setter + public float chance = 1; + @Setter + public float tierChanceBoost = 0; + + @HideFromJS + @Override + public GTRecipeJS id(ResourceLocation _id) { + this.id = new ResourceLocation(_id.getNamespace().equals("minecraft") ? this.type.id.getNamespace() : _id.getNamespace(), "%s/%s".formatted(this.type.id.getPath(), _id.getPath())); + return this; + } + + public GTRecipeJS input(RecipeCapability capability, Object... obj) { + CapabilityMap map; + if (perTick) { + if (getValue(ALL_TICK_INPUTS) == null) setValue(ALL_TICK_INPUTS, new CapabilityMap()); + map = getValue(ALL_TICK_INPUTS); + } else { + if (getValue(ALL_INPUTS) == null) setValue(ALL_INPUTS, new CapabilityMap()); + map = getValue(ALL_INPUTS); + } + if (map != null) { + for (Object object : obj) { + map.add(capability, new Content(object, chance, tierChanceBoost, null, null)); + } + } + save(); + return this; + } + + public GTRecipeJS output(RecipeCapability capability, Object... obj) { + CapabilityMap map; + if (perTick) { + if (getValue(ALL_TICK_OUTPUTS) == null) setValue(ALL_TICK_OUTPUTS, new CapabilityMap()); + map = getValue(ALL_TICK_OUTPUTS); + } else { + if (getValue(ALL_OUTPUTS) == null) setValue(ALL_OUTPUTS, new CapabilityMap()); + map = getValue(ALL_OUTPUTS); + } + if (map != null) { + for (Object object : obj) { + map.add(capability, new Content(object, chance, tierChanceBoost, null, null)); + } + } + save(); + return this; + } + + public GTRecipeJS addCondition(RecipeCondition condition) { + if (getValue(CONDITIONS) == null) setValue(CONDITIONS, new RecipeCondition[0]); + setValue(CONDITIONS, ArrayUtils.add(getValue(CONDITIONS), condition)); + save(); + return this; + } + + public GTRecipeJS inputEU(long eu) { + input(EURecipeCapability.CAP, eu); + return this; + } + + public GTRecipeJS EUt(long eu) { + var lastPerTick = perTick; + perTick = true; + if (eu > 0) { + inputEU(eu); + } else if (eu < 0) { + outputEU(-eu); + } + perTick = lastPerTick; + return this; + } + + public GTRecipeJS outputEU(long eu) { + return output(EURecipeCapability.CAP, eu); + } + + public GTRecipeJS itemInputs(InputItem... inputs) { + return inputItems(inputs); + } + + public GTRecipeJS itemInput(UnificationEntry input) { + return inputItems(input); + } + + public GTRecipeJS itemInput(UnificationEntry input, int count) { + return inputItems(input, count); + } + + public GTRecipeJS inputItems(InputItem... inputs) { + return input(ItemRecipeCapability.CAP, (Object[]) inputs); + } + + public GTRecipeJS inputItems(ItemStack... inputs) { + for (ItemStack itemStack : inputs) { + if (itemStack.isEmpty()) { + GTCEu.LOGGER.error("gt recipe {} input items is empty", id); + throw new IllegalArgumentException(id + ": input items is empty"); + } + } + return input(ItemRecipeCapability.CAP, Arrays.stream(inputs).map(stack -> InputItem.of(SizedIngredient.create(stack.hasTag() ? NBTIngredient.createNBTIngredient(stack) : Ingredient.of(stack), stack.getCount()), stack.getCount())).toArray()); + } + + public GTRecipeJS inputItems(TagKey tag, int amount) { + return inputItems(InputItem.of(SizedIngredient.create(Ingredient.of(tag), amount), amount)); + } + + public GTRecipeJS inputItems(TagKey tag) { + return inputItems(InputItem.of(Ingredient.of(tag), 1)); + } + + public GTRecipeJS inputItems(Item input, int amount) { + return inputItems(new ItemStack(input, amount)); + } + + public GTRecipeJS inputItems(Item input) { + return inputItems(InputItem.of(Ingredient.of(input), 1)); + } + + public GTRecipeJS inputItems(Supplier input) { + return inputItems(InputItem.of(Ingredient.of(input.get()), 1)); + } + + public GTRecipeJS inputItems(Supplier input, int amount) { + return inputItems(new ItemStack(input.get(), amount)); + } + + public GTRecipeJS inputItems(TagPrefix orePrefix, Material material) { + return inputItems(orePrefix, material, 1); + } + + public GTRecipeJS inputItems(UnificationEntry input) { + return inputItems(input.tagPrefix, input.material, 1); + } + + public GTRecipeJS inputItems(UnificationEntry input, int count) { + return inputItems(input.tagPrefix, input.material, count); + } + + public GTRecipeJS inputItems(TagPrefix orePrefix, Material material, int count) { + return inputItems(ChemicalHelper.getTag(orePrefix, material), count); + } + + public GTRecipeJS inputItems(MachineDefinition machine) { + return inputItems(machine, 1); + } + + public GTRecipeJS inputItems(MachineDefinition machine, int count) { + return inputItems(machine.asStack(count)); + } + + public GTRecipeJS itemOutputs(ItemStack... outputs) { + return outputItems(outputs); + } + + public GTRecipeJS itemOutput(UnificationEntry unificationEntry) { + return outputItems(unificationEntry.tagPrefix, unificationEntry.material); + } + + public GTRecipeJS itemOutput(UnificationEntry unificationEntry, int count) { + return outputItems(unificationEntry.tagPrefix, unificationEntry.material, count); + } + + public GTRecipeJS outputItems(ItemStack... outputs) { + for (ItemStack itemStack : outputs) { + if (itemStack.isEmpty()) { + LDLib.LOGGER.error("gt recipe {} output items is empty", id); + throw new IllegalArgumentException(id + ": output items is empty"); + } + } + return output(ItemRecipeCapability.CAP, Arrays.stream(outputs).map(stack -> OutputItem.of(stack, chance)).toArray()); + } + + public GTRecipeJS outputItems(Item input, int amount) { + return outputItems(new ItemStack(input, amount)); + } + + public GTRecipeJS outputItems(Item input) { + return outputItems(new ItemStack(input)); + } + + public GTRecipeJS outputItems(Supplier input) { + return outputItems(new ItemStack(input.get())); + } + + public GTRecipeJS outputItems(Supplier input, int amount) { + return outputItems(new ItemStack(input.get(), amount)); + } + + public GTRecipeJS outputItems(TagPrefix orePrefix, Material material) { + return outputItems(orePrefix, material, 1); + } + + public GTRecipeJS outputItems(TagPrefix orePrefix, Material material, int count) { + return outputItems(ChemicalHelper.get(orePrefix, material, count)); + } + + public GTRecipeJS outputItems(MachineDefinition machine) { + return outputItems(machine, 1); + } + + public GTRecipeJS outputItems(MachineDefinition machine, int count) { + return outputItems(machine.asStack(count)); + } + + public GTRecipeJS notConsumable(ItemStack itemStack) { + float lastChance = this.chance; + this.chance = 0; + inputItems(itemStack); + this.chance = lastChance; + return this; + } + + public GTRecipeJS notConsumable(Item item) { + float lastChance = this.chance; + this.chance = 0; + inputItems(item); + this.chance = lastChance; + return this; + } + + public GTRecipeJS notConsumable(Supplier item) { + float lastChance = this.chance; + this.chance = 0; + inputItems(item); + this.chance = lastChance; + return this; + } + + public GTRecipeJS notConsumable(TagPrefix orePrefix, Material material) { + float lastChance = this.chance; + this.chance = 0; + inputItems(orePrefix, material); + this.chance = lastChance; + return this; + } + + public GTRecipeJS circuit(int configuration) { + return notConsumable(IntCircuitBehaviour.stack(configuration)); + } + + public GTRecipeJS chancedInput(ItemStack stack, int chance, int tierChanceBoost) { + // todo finish tier chance boost, make it actually used in places + float lastChance = this.chance; + float lastTierChanceBoost = this.tierChanceBoost; + this.chance = chance / 10000f; + this.tierChanceBoost = tierChanceBoost / 10000f; + inputItems(stack); + this.chance = lastChance; + this.tierChanceBoost = lastTierChanceBoost; + return this; + } + + public GTRecipeJS chancedInput(FluidStackJS stack, int chance, int tierChanceBoost) { + float lastChance = this.chance; + float lastTierChanceBoost = this.tierChanceBoost; + this.chance = chance / 10000f; + this.tierChanceBoost = tierChanceBoost / 10000f; + inputFluids(stack); + this.chance = lastChance; + this.tierChanceBoost = lastTierChanceBoost; + return this; + } + + public GTRecipeJS chancedOutput(ItemStack stack, int chance, int tierChanceBoost) { + float lastChance = this.chance; + float lastTierChanceBoost = this.tierChanceBoost; + this.chance = chance / 10000f; + this.tierChanceBoost = tierChanceBoost / 10000f; + outputItems(stack); + this.chance = lastChance; + this.tierChanceBoost = lastTierChanceBoost; + return this; + } + + public GTRecipeJS chancedOutput(FluidStackJS stack, int chance, int tierChanceBoost) { + float lastChance = this.chance; + float lastTierChanceBoost = this.tierChanceBoost; + this.chance = chance / 10000f; + this.tierChanceBoost = tierChanceBoost / 10000f; + outputFluids(stack); + this.chance = lastChance; + this.tierChanceBoost = lastTierChanceBoost; + return this; + } + + public GTRecipeJS chancedOutput(TagPrefix tag, Material mat, int chance, int tierChanceBoost) { + return chancedOutput(ChemicalHelper.get(tag, mat), chance, tierChanceBoost); + } + + public GTRecipeJS chancedOutput(TagPrefix tag, Material mat, int count, int chance, int tierChanceBoost) { + return chancedOutput(ChemicalHelper.get(tag, mat, count), chance, tierChanceBoost); + } + + public GTRecipeJS inputFluids(FluidStackJS... inputs) { + return input(FluidRecipeCapability.CAP, (Object[]) inputs); + } + + public GTRecipeJS outputFluids(FluidStackJS... outputs) { + return output(FluidRecipeCapability.CAP, (Object[]) outputs); + } + + public GTRecipeJS inputStress(float stress) { + return input(StressRecipeCapability.CAP, stress); + } + + public GTRecipeJS outputStress(float stress) { + return output(StressRecipeCapability.CAP, stress); + } + + ////////////////////////////////////// + //********** DATA ***********// + ////////////////////////////////////// + public GTRecipeJS addData(String key, Tag data) { + if (getValue(DATA) == null) setValue(DATA, new CompoundTag()); + getValue(DATA).put(key, data); + save(); + return this; + } + + public GTRecipeJS addData(String key, int data) { + if (getValue(DATA) == null) setValue(DATA, new CompoundTag()); + getValue(DATA).putInt(key, data); + save(); + return this; + } + + public GTRecipeJS addData(String key, String data) { + if (getValue(DATA) == null) setValue(DATA, new CompoundTag()); + getValue(DATA).putString(key, data); + save(); + return this; + } + + public GTRecipeJS addData(String key, Float data) { + if (getValue(DATA) == null) setValue(DATA, new CompoundTag()); + getValue(DATA).putFloat(key, data); + save(); + return this; + } + + public GTRecipeJS addData(String key, boolean data) { + if (getValue(DATA) == null) setValue(DATA, new CompoundTag()); + getValue(DATA).putBoolean(key, data); + save(); + return this; + } + + public GTRecipeJS blastFurnaceTemp(int blastTemp) { + return addData("ebf_temp", blastTemp); + } + + public GTRecipeJS explosivesAmount(int explosivesAmount) { + return addData("explosives_amount", explosivesAmount); + } + + public GTRecipeJS explosivesType(ItemStack explosivesType) { + return addData("explosives_type", explosivesType.save(new CompoundTag())); + } + + public GTRecipeJS solderMultiplier(int multiplier) { + return addData("solderMultiplier", multiplier); + } + + ////////////////////////////////////// + //******* CONDITIONS ********// + ////////////////////////////////////// + + public GTRecipeJS cleanroom(CleanroomType cleanroomType) { + return addCondition(new CleanroomCondition(cleanroomType)); + } + + public GTRecipeJS dimension(ResourceLocation dimension, boolean reverse) { + return addCondition(new DimensionCondition(dimension).setReverse(reverse)); + } + + public GTRecipeJS dimension(ResourceLocation dimension) { + return dimension(dimension, false); + } + + public GTRecipeJS biome(ResourceLocation biome, boolean reverse) { + return addCondition(new BiomeCondition(biome).setReverse(reverse)); + } + + public GTRecipeJS biome(ResourceLocation biome) { + return biome(biome, false); + } + + public GTRecipeJS rain(float level, boolean reverse) { + return addCondition(new RainingCondition(level).setReverse(reverse)); + } + + public GTRecipeJS rain(float level) { + return rain(level, false); + } + + public GTRecipeJS thunder(float level, boolean reverse) { + return addCondition(new ThunderCondition(level).setReverse(reverse)); + } + + public GTRecipeJS thunder(float level) { + return thunder(level, false); + } + + public GTRecipeJS posY(int min, int max, boolean reverse) { + return addCondition(new PositionYCondition(min, max).setReverse(reverse)); + } + + public GTRecipeJS posY(int min, int max) { + return posY(min, max, false); + } + + public GTRecipeJS rpm(float rpm, boolean reverse) { + return addCondition(new RPMCondition(rpm).setReverse(reverse)); + } + + public GTRecipeJS rpm(float rpm) { + return rpm(rpm, false); + } + + /* + * KubeJS overrides + */ + + public InputItem readInputItem(Object from) { + if(from instanceof SizedIngredient ingr) { + return InputItem.of(ingr.getInner(), ingr.getAmount()); + } else if(from instanceof JsonObject jsonObject) { + if (!jsonObject.has("type") || !jsonObject.get("type").getAsString().equals(SizedIngredient.TYPE.toString())) { + return InputItem.of(from); + } + var sizedIngredient = SizedIngredient.fromJson(jsonObject); + return InputItem.of(sizedIngredient.getInner(), sizedIngredient.getAmount()); + } + return InputItem.of(from); + } + + public JsonElement writeInputItem(InputItem value) { + return SizedIngredient.create(value.ingredient, value.count).toJson(); + } + + @Override + public OutputItem readOutputItem(Object from) { + if(from instanceof SizedIngredient ingredient) { + return OutputItem.of(ingredient.getInner().getItems()[0], Double.NaN); + } else if(from instanceof JsonObject jsonObject) { + float chance = 1.0f; + if (jsonObject.has("chance")) { + chance = jsonObject.get("chance").getAsFloat(); + } + if (jsonObject.has("content")) { + jsonObject = jsonObject.getAsJsonObject("content"); + } + var ingredient = Ingredient.fromJson(jsonObject); + return OutputItem.of(ingredient.getItems()[0], chance); + } + return OutputItem.of(from); + } + + @Override + public JsonElement writeOutputItem(OutputItem value) { + return SizedIngredient.create(value.item).toJson(); + } + } + + RecipeKey ID = GTRecipeComponents.RESOURCE_LOCATION.key("id"); + RecipeKey DURATION = TimeComponent.TICKS.key("duration").optional(100L); + RecipeKey DATA = GTRecipeComponents.TAG.key("data").optional((CompoundTag) null); + RecipeKey CONDITIONS = GTRecipeComponents.RECIPE_CONDITION.asArray().key("recipeConditions").defaultOptional(); + RecipeKey IS_FUEL = BooleanComponent.BOOLEAN.key("isFuel").optional(false); + + RecipeKey ALL_INPUTS = GTRecipeComponents.IN.key("inputs").defaultOptional(); + RecipeKey ALL_TICK_INPUTS = GTRecipeComponents.TICK_IN.key("tickInputs").defaultOptional(); + + RecipeKey ALL_OUTPUTS = GTRecipeComponents.OUT.key("outputs").defaultOptional(); + RecipeKey ALL_TICK_OUTPUTS = GTRecipeComponents.TICK_OUT.key("tickOutputs").defaultOptional(); + + RecipeSchema SCHEMA = new RecipeSchema(GTRecipeJS.class, GTRecipeJS::new, DURATION, DATA, CONDITIONS, ALL_INPUTS, ALL_TICK_INPUTS, ALL_OUTPUTS, ALL_TICK_OUTPUTS, IS_FUEL) + .constructor((recipe, schemaType, keys, from) -> recipe.id(from.getValue(recipe, ID)), ID) + .constructor(DURATION, CONDITIONS, ALL_INPUTS, ALL_OUTPUTS, ALL_TICK_OUTPUTS, ALL_TICK_OUTPUTS); + +} + diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/CapabilityMap.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/CapabilityMap.java new file mode 100644 index 0000000000..0e6fe7b727 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/CapabilityMap.java @@ -0,0 +1,128 @@ +package com.gregtechceu.gtceu.integration.kjs.recipe.components; + +import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; +import com.gregtechceu.gtceu.api.recipe.content.Content; +import dev.latvian.mods.kubejs.recipe.InputReplacement; +import dev.latvian.mods.kubejs.recipe.OutputReplacement; +import dev.latvian.mods.kubejs.recipe.RecipeJS; +import dev.latvian.mods.kubejs.recipe.ReplacementMatch; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.ArrayUtils; + +import java.util.IdentityHashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; + +@NoArgsConstructor +public class CapabilityMap extends IdentityHashMap, Content[]> implements InputReplacement, OutputReplacement { + + public CapabilityMap(Map, Content[]> m) { + super(m); + } + + public void add(RecipeCapability capability, Content value) { + this.put(capability, ArrayUtils.add(this.get(capability), value)); + } + + public boolean isInput(RecipeJS recipe, ReplacementMatch match) { + AtomicBoolean returnValue = new AtomicBoolean(false); + this.forEach((key, values) -> { + var pair = GTRecipeComponents.VALID_CAPS.get(key); + if (!pair.getFirst().isOutput()) { + for (Content value : values) { + if (pair.getFirst().isInput(recipe, value, match)) { + returnValue.set(true); + return; + } + } + } else if (!pair.getSecond().isOutput()) { + for (Content value : values) { + if (pair.getSecond().isInput(recipe, value, match)) { + returnValue.set(true); + return; + } + } + } + }); + return returnValue.get(); + } + + public boolean isOutput(RecipeJS recipe, ReplacementMatch match) { + AtomicBoolean returnValue = new AtomicBoolean(false); + this.forEach((key, values) -> { + var pair = GTRecipeComponents.VALID_CAPS.get(key); + if (pair.getFirst().isOutput()) { + for (Content value : values) { + if (pair.getFirst().isOutput(recipe, value, match)) { + returnValue.set(true); + return; + } + } + } else if (pair.getSecond().isOutput()) { + for (Content value : values) { + if (pair.getSecond().isOutput(recipe, value, match)) { + returnValue.set(true); + return; + } + } + } + }); + return returnValue.get(); + } + + @Override + public CapabilityMap replaceInput(RecipeJS recipe, ReplacementMatch match, InputReplacement with) { + AtomicBoolean changed = new AtomicBoolean(false); + this.forEach((key, values) -> { + var pair = GTRecipeComponents.VALID_CAPS.get(key); + if (!pair.getFirst().isOutput()) { + for (int i = 0; i < values.length; ++i) { + Content value = values[i]; + Content result = pair.getFirst().replaceInput(recipe, value, match, with); + if (result != value) { + changed.set(true); + values[i] = result; + } + } + } else if (!pair.getSecond().isOutput()) { + for (int i = 0; i < values.length; ++i) { + Content value = values[i]; + Content result = pair.getSecond().replaceInput(recipe, value, match, with); + if (result != value) { + changed.set(true); + values[i] = result; + } + } + } + }); + return changed.get() ? new CapabilityMap(this) : this; + } + + @Override + public CapabilityMap replaceOutput(RecipeJS recipe, ReplacementMatch match, OutputReplacement with) { + AtomicBoolean changed = new AtomicBoolean(false); + this.forEach((key, values) -> { + var pair = GTRecipeComponents.VALID_CAPS.get(key); + if (pair.getFirst().isOutput()) { + for (int i = 0; i < values.length; ++i) { + Content value = values[i]; + Content result = pair.getFirst().replaceOutput(recipe, value, match, with); + if (result != value) { + changed.set(true); + values[i] = result; + } + } + } else if (pair.getSecond().isOutput()) { + for (int i = 0; i < values.length; ++i) { + Content value = values[i]; + Content result = pair.getSecond().replaceOutput(recipe, value, match, with); + if (result != value) { + changed.set(true); + values[i] = result; + } + } + } + }); + return changed.get() ? new CapabilityMap(this) : this; + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/CapabilityMapComponent.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/CapabilityMapComponent.java new file mode 100644 index 0000000000..3b8b9bba19 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/CapabilityMapComponent.java @@ -0,0 +1,86 @@ +package com.gregtechceu.gtceu.integration.kjs.recipe.components; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; +import com.gregtechceu.gtceu.api.recipe.content.Content; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import dev.latvian.mods.kubejs.recipe.InputReplacement; +import dev.latvian.mods.kubejs.recipe.OutputReplacement; +import dev.latvian.mods.kubejs.recipe.RecipeJS; +import dev.latvian.mods.kubejs.recipe.ReplacementMatch; +import dev.latvian.mods.kubejs.recipe.component.ComponentRole; +import dev.latvian.mods.kubejs.recipe.component.RecipeComponent; +import net.minecraft.util.GsonHelper; + +import java.util.HashSet; +import java.util.Set; + +public record CapabilityMapComponent(boolean isOutput) implements RecipeComponent { + @Override + public ComponentRole role() { + return isOutput ? ComponentRole.OUTPUT : ComponentRole.INPUT; + } + + + @Override + public boolean isOutput(RecipeJS recipe, CapabilityMap value, ReplacementMatch match) { + return isOutput && value.isOutput(recipe, match); + } + + @Override + public boolean isInput(RecipeJS recipe, CapabilityMap value, ReplacementMatch match) { + return !isOutput && value.isInput(recipe, match); + } + + @Override + public Class componentClass() { + return CapabilityMap.class; + } + + @Override + public CapabilityMap replaceInput(RecipeJS recipe, CapabilityMap original, ReplacementMatch match, InputReplacement with) { + return isInput(recipe, original, match) ? read(recipe, original.replaceInput(recipe, match, with)) : original; + } + + @Override + public CapabilityMap replaceOutput(RecipeJS recipe, CapabilityMap original, ReplacementMatch match, OutputReplacement with) { + return isOutput(recipe, original, match) ? read(recipe, original.replaceOutput(recipe, match, with)) : original; + } + + @Override + public JsonElement write(RecipeJS recipe, CapabilityMap map) { + JsonObject json = new JsonObject(); + map.forEach((key, value) -> { + JsonArray array = new JsonArray(); + var pair = GTRecipeComponents.VALID_CAPS.get(key); + for (Content content : value) { + array.add((isOutput ? pair.getSecond() : pair.getFirst()).write(recipe, content)); + } + json.add(key.name, array); + }); + return json; + } + + @Override + public CapabilityMap read(RecipeJS recipe, Object from) { + if (from instanceof CapabilityMap map) return map; + CapabilityMap map = new CapabilityMap(); + if (from instanceof JsonObject json) { + for (String key : json.keySet()) { + if (GTRegistries.RECIPE_CAPABILITIES.containKey(key) && GTRegistries.RECIPE_CAPABILITIES.get(key) != null) { + RecipeCapability cap = GTRegistries.RECIPE_CAPABILITIES.get(key); + var pair = GTRecipeComponents.VALID_CAPS.get(cap); + Set result = new HashSet<>(); + JsonArray value = GsonHelper.getAsJsonArray(json, key, new JsonArray()); + for (int i = 0; i < value.size(); ++i) { + result.add((isOutput ? pair.getSecond() : pair.getFirst()).read(recipe, value.get(i))); + } + map.put(cap, result.toArray(Content[]::new)); + } + } + } + return map; + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/ContentJS.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/ContentJS.java new file mode 100644 index 0000000000..a4bfc374ec --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/ContentJS.java @@ -0,0 +1,76 @@ +package com.gregtechceu.gtceu.integration.kjs.recipe.components; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; +import com.gregtechceu.gtceu.api.recipe.content.Content; +import dev.latvian.mods.kubejs.recipe.InputReplacement; +import dev.latvian.mods.kubejs.recipe.OutputReplacement; +import dev.latvian.mods.kubejs.recipe.RecipeJS; +import dev.latvian.mods.kubejs.recipe.ReplacementMatch; +import dev.latvian.mods.kubejs.recipe.component.ComponentRole; +import dev.latvian.mods.kubejs.recipe.component.RecipeComponent; +import dev.latvian.mods.kubejs.util.UtilsJS; +import net.minecraft.util.GsonHelper; + +public record ContentJS(RecipeComponent baseComponent, RecipeCapability capability, boolean isOutput) implements RecipeComponent { + + @Override + public ComponentRole role() { + return isOutput ? ComponentRole.OUTPUT : ComponentRole.INPUT; + } + + @Override + public Class componentClass() { + return Content.class; + } + + @Override + public JsonElement write(RecipeJS recipe, Content value) { + JsonObject object = new JsonObject(); + object.add("content", baseComponent.write(recipe, UtilsJS.cast(value.content))); + object.addProperty("chance", value.chance); + object.addProperty("tierChanceBoost", value.tierChanceBoost); + if (value.slotName != null) { + object.addProperty("slotName", value.slotName); + } + if (value.uiName != null) { + object.addProperty("uiName", value.uiName); + } + return object; + } + + @Override + public Content read(RecipeJS recipe, Object from) { + if (from instanceof Content) return (Content) from; + else if (from instanceof JsonObject json) { + Object content = baseComponent.read(recipe, json.get("content")); + float chance = GsonHelper.getAsFloat(json, "chance", 1.0f); + float tierChanceBoost = GsonHelper.getAsFloat(json, "tierChanceBoost", 0.0f); + String slotName = GsonHelper.getAsString(json, "slotName", null); + String uiName = GsonHelper.getAsString(json, "uiName", null); + return new Content(content, chance, tierChanceBoost, slotName, uiName); + } + return null; + } + + @Override + public boolean isInput(RecipeJS recipe, Content value, ReplacementMatch match) { + return !isOutput && baseComponent.isInput(recipe, baseComponent.read(recipe, value.content), match); + } + + @Override + public boolean isOutput(RecipeJS recipe, Content value, ReplacementMatch match) { + return isOutput && baseComponent.isOutput(recipe, baseComponent.read(recipe, value.content), match); + } + + @Override + public Content replaceInput(RecipeJS recipe, Content original, ReplacementMatch match, InputReplacement with) { + return isInput(recipe, original, match) ? new Content(baseComponent.replaceInput(recipe, baseComponent.read(recipe, original.content), match, with), original.chance, original.tierChanceBoost, original.slotName, original.uiName) : original; + } + + @Override + public Content replaceOutput(RecipeJS recipe, Content original, ReplacementMatch match, OutputReplacement with) { + return isOutput(recipe, original, match) ? new Content(with.replaceOutput(recipe, match, with), original.chance, original.tierChanceBoost, original.slotName, original.uiName) : original; + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/GTRecipeComponents.java b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/GTRecipeComponents.java new file mode 100644 index 0000000000..7ebfa90dc8 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/components/GTRecipeComponents.java @@ -0,0 +1,171 @@ +package com.gregtechceu.gtceu.integration.kjs.recipe.components; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import com.gregtechceu.gtceu.api.addon.AddonFinder; +import com.gregtechceu.gtceu.api.addon.events.KJSRecipeKeyEvent; +import com.gregtechceu.gtceu.api.capability.recipe.*; +import com.gregtechceu.gtceu.api.recipe.RecipeCondition; +import com.gregtechceu.gtceu.api.recipe.content.Content; +import com.gregtechceu.gtceu.api.registry.GTRegistries; +import com.gregtechceu.gtceu.common.data.GTRecipeCapabilities; +import com.mojang.datafixers.util.Pair; +import dev.latvian.mods.kubejs.fluid.InputFluid; +import dev.latvian.mods.kubejs.fluid.OutputFluid; +import dev.latvian.mods.kubejs.item.InputItem; +import dev.latvian.mods.kubejs.item.OutputItem; +import dev.latvian.mods.kubejs.recipe.*; +import dev.latvian.mods.kubejs.recipe.component.*; +import dev.latvian.mods.kubejs.typings.desc.DescriptionContext; +import dev.latvian.mods.kubejs.typings.desc.TypeDescJS; +import dev.latvian.mods.rhino.mod.util.NBTUtils; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.GsonHelper; +import net.minecraft.world.item.ItemStack; + +import java.util.*; + +public class GTRecipeComponents { + public static final RecipeComponent TAG = new RecipeComponent<>() { + @Override + public String componentType() { + return "nbt"; + } + + @Override + public Class componentClass() { + return CompoundTag.class; + } + + @Override + public JsonElement write(RecipeJS recipe, CompoundTag value) { + return NBTUtils.toJson(value); + } + + @Override + public CompoundTag read(RecipeJS recipe, Object from) { + return NBTUtils.toTagCompound(from); + } + }; + public static final RecipeComponent RESOURCE_LOCATION = new RecipeComponent<>() { + @Override + public String componentType() { + return "resource_location"; + } + + @Override + public Class componentClass() { + return ResourceLocation.class; + } + + @Override + public TypeDescJS constructorDescription(DescriptionContext ctx) { + return TypeDescJS.STRING; + } + + @Override + public JsonElement write(RecipeJS recipe, ResourceLocation value) { + return new JsonPrimitive(value.toString()); + } + + @Override + public ResourceLocation read(RecipeJS recipe, Object from) { + return from instanceof CharSequence c ? ResourceLocation.tryParse(c.toString()) : ResourceLocation.tryParse(String.valueOf(from)); + } + + @Override + public String toString() { + return componentType(); + } + }; + + public static final RecipeComponent RECIPE_CONDITION = new RecipeComponent<>() { + @Override + public String componentType() { + return "recipe_condition"; + } + + @Override + public Class componentClass() { + return RecipeCondition.class; + } + + @Override + public JsonElement write(RecipeJS recipe, RecipeCondition value) { + JsonObject object = new JsonObject(); + object.addProperty("type", GTRegistries.RECIPE_CONDITIONS.getKey(value.getClass())); + object.add("data", value.serialize()); + return object; + } + + @Override + public RecipeCondition read(RecipeJS recipe, Object from) { + if (from instanceof CharSequence) { + var conditionKey = from.toString(); + var clazz = GTRegistries.RECIPE_CONDITIONS.get(conditionKey); + if (clazz != null) { + return RecipeCondition.create(clazz); + } + } if (from instanceof JsonPrimitive primitive) { + var conditionKey = primitive.getAsString(); + var clazz = GTRegistries.RECIPE_CONDITIONS.get(conditionKey); + if (clazz != null) { + return RecipeCondition.create(clazz); + } + } else if (from instanceof JsonObject jsonObject) { + var conditionKey = GsonHelper.getAsString(jsonObject, "type", ""); + var clazz = GTRegistries.RECIPE_CONDITIONS.get(conditionKey); + if (clazz != null) { + RecipeCondition condition = RecipeCondition.create(clazz); + if (condition != null) { + return condition.deserialize(GsonHelper.getAsJsonObject(jsonObject, "data", new JsonObject())); + } + } + } else if (from instanceof Tag tag) { + return read(recipe, NBTUtils.toJson(tag)); + } + return null; + } + + @Override + public String toString() { + return componentType(); + } + }; + + + public static final ContentJS ITEM_IN = new ContentJS<>(ItemComponents.INPUT, GTRecipeCapabilities.ITEM, false); + public static final ContentJS ITEM_OUT = new ContentJS<>(ItemComponents.OUTPUT, GTRecipeCapabilities.ITEM, true); + public static final ContentJS FLUID_IN = new ContentJS<>(FluidComponents.INPUT, GTRecipeCapabilities.FLUID, false); + public static final ContentJS FLUID_OUT = new ContentJS<>(FluidComponents.OUTPUT, GTRecipeCapabilities.FLUID, true); + public static final ContentJS EU_IN = new ContentJS<>(NumberComponent.ANY_LONG, GTRecipeCapabilities.EU, false); + public static final ContentJS EU_OUT = new ContentJS<>(NumberComponent.ANY_LONG, GTRecipeCapabilities.EU, true); + public static final ContentJS SU_IN = new ContentJS<>(NumberComponent.ANY_FLOAT, GTRecipeCapabilities.SU, false); + public static final ContentJS SU_OUT = new ContentJS<>(NumberComponent.ANY_FLOAT, GTRecipeCapabilities.SU, true); + + + public static final CapabilityMapComponent IN = new CapabilityMapComponent(false); + public static final CapabilityMapComponent TICK_IN = new CapabilityMapComponent(false); + public static final CapabilityMapComponent OUT = new CapabilityMapComponent(true); + public static final CapabilityMapComponent TICK_OUT = new CapabilityMapComponent(true); + + public static final Map, Pair, ContentJS>> VALID_CAPS = new IdentityHashMap<>(); + + static { + VALID_CAPS.put(GTRecipeCapabilities.ITEM, Pair.of(ITEM_IN, ITEM_OUT)); + VALID_CAPS.put(GTRecipeCapabilities.FLUID, Pair.of(FLUID_IN, FLUID_OUT)); + VALID_CAPS.put(GTRecipeCapabilities.EU, Pair.of(EU_IN, EU_OUT)); + VALID_CAPS.put(GTRecipeCapabilities.SU, Pair.of(SU_IN, SU_OUT)); + + KJSRecipeKeyEvent event = new KJSRecipeKeyEvent(); + AddonFinder.getAddons().forEach(addon -> addon.registerRecipeKeys(event)); + VALID_CAPS.putAll(event.getRegisteredKeys()); + Set> addedCaps = event.getRegisteredKeys().keySet(); + Set> registeredCaps = GTRegistries.RECIPE_CAPABILITIES.values(); + registeredCaps.removeAll(addedCaps); + } + +} diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front.png b/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front.png new file mode 100644 index 0000000000000000000000000000000000000000..729e656da0188cc3dcbf8dc0590175a2636a4972 GIT binary patch literal 5718 zcmeH~dpuO>AIFCxxs^*QQq$-nHTPjI48{=3wM3Y3%$zY3b1^f_ps`YHuBl&9Dwo>Y z%`Ndti(*k*Otvkgh*pYj>r%_6rG95dwe|Y#KfPYR{jYhw&YW|e=li_B-|y%7p68q= z&Bx1CPuo-*27~FjyE$)x&I^@?mL~MS;?+9<2Ga*)#ztXj2JcY4^^UfocuDSErbt~o0nxT|$3o)hueM^{K)0&W!woG-%_*k62%KJb;}C)GnqhdVPX}!!1B~; z@9gltIgexDQ@=Yjkb8`3)Arrs^!oN>FFU8!qyI7}S8v_3SB9HHZ^rr?c6Z+h_E?n6MGT3eBcG&b?xk5j7$ai+<(^)R|@U|L*tmkHyrA(pfB(OKU!w3&GSlB6fK)el=4w9Xe9UgYSQ zJ4t2^Xwx!O?GWO1X;F7^o?wHd{aD3QD;JOZTDcy=jj}!MmuAwQ2fH#oT8-|>u4(@$ z+hmMcBYvg7excLg6SoRj;qw`MTuhix1;%v)rnib=TwGp$)hyRdd=~ zs}Xj6x0>1Y`5IMiWzPGUa~+muBMzqOSi%kXj;;MGgAZBUtR2t34Jw*T&8&5t_vv`i zJVi?xamF@JT;+RHt4QMrL+90-4lZMi(VVnQ+2e|5ouwR~t{>dRl3T86D|cqDIdjBl z?Y9pt*RArzo<4+M(>`{5JT{f~OG?K22DkYxn>U<&q&?*qdOEelIzN9W|2~6$f>X@R zKwh|imcFS^`m{K5KXt+meqkVW1+Mv516R{2cGiuP6N-uFWw(GV^qDio{bd8&x(1Wk zyT|bi7`KPdWWfQ_-~>*qffe=M@e$HjI5E?o>Rr zYSoFO&9nvNfl|{%;>ZCzWNSdLJbR76dq8HTFuDq+wm3GVs@wiB*45q7!O#mp1$*T_ zi}vZotv_2+QfhR}H`uc1R_SWq$Wml_pk~gim&ON7^0xY2Tr&{1E@F2@Y2&b6NaKQ7 z!Djd6+`2UtLPzm}e1|&6jO$0h5auZ3MoM5#jeno^{-GlCv(`4Tx;`-xFZ-Lbj=Y9X zHbv>)UG9K*t0}Zknu6IFoe!-P?lrAlIgBnfsefGeB7CR$VNea_U%$WDLBlMmJ>W{> zoJmVF9Vacx_UC+~uygw7hq)vA+j@fR;?+{_N>Rr8yF*Hos;irWa_wKv4R8BJa_HhY z^_){KBd!G(7#%|77k-*(2C+L)*8EJzKxCVnuOuzj-f zH|KA0<@0v+>M|GKlJcvUGd2j^8WAhZ$mI;hj>@AKD}gJ|D)sv<xBs=jn{hWzI6$yQjQqg{)n1rf5=iyuT8mOr#Cb<-Xvj~}5eUX}Q$ z?!`;9;i{Izf~D4?d*p|f=Y2-PYcm3``lNloZ!o>Yx4~hwsyQyBI;gaIk~*c+;=+qd zdrtWFz|ZO?E1i-uDJ4HNIVJmN85;%mc*nhFW{0lI^Qf>|LLNG=w&>vCymxyZ^yQy! zoljhMTs;|GGlNy%8@t=TrKWK|uRcb7Zo%&L<%176>K%pO5h+2_T1)O~qAG0jFU@0& z!06s}EVpdqqNnJ?Nq^$soKas`tMSIaufOLnk{l-L+%}|1BF){XICObve58M*|1Gs+ zWOUv!qUd7Di)kM8Ml|I@Z@%rG9u%g4hXPoFa1bTq386P53})vb69UXgPy!DJBe;Aj zVzj;y0q3%)hyZI(jHi$ea=32sB5-TGmmf1el1XME9PG92WE2R%10?`l#*5;MDKaWT z#ic;k%4ReIt}>BCQW4udec*I~2!s<*1QZ78BICy55cb+|I}wXb+2XwMJp#I;A~+I> zkb*`_rBaj>j}nL?&{#5=jK<*5I2;nPK#Jq|5F$sn4n86$d_1rig0!J^!Z3orWC>D2~|l!;(g|f#r$X|j1fhtY*|X8|)t>D1ksicrQ&VF{RA7DaVQ zAhQ4_NMa%JI6MJK0LU05fWzA$+0Z=*kg#kliTnx5oiCOEd?u(wL2wio;;;!=5{X45 zAqfN`gdkyvNB|p-Ly|~DA`!Gu_XBD_Uhs49V|Poq+zSP;q@a>*hB;Yf10G8!8w zkZ>FeMB+%+Y>W+_fXCU)qLlMMq4~H|5jYe^6`!ibCkl|T1tK05;lbs{$o}r|$)&_^eSd*=>1n6u-#Q$yN4~oQ4!6}(o3<^h3^{|+fjSvxl3Wv)BB0#i|AED|{ zP74J}1`-xf)+t0*wL`g3=pqo12t&N~H#;eATrp%3r>yw*HNO>% zp1qrW1fsaAE;w9OwiJLl>qHF1f-IFIXxwZUlLPQ0K5;QfwTxHQz#p#fK=JQEmaz?`#csY z2UH4(!C{dYYb4Ib4~wT@tSMLm5<{e5FbMSfgwe{U`a{Nc=>O5gPG#`PG60R6ZG)B< zXthFrT&~`0rj+qt{Jo!xf6)Vk{_5n5^!+N=SGm4OfiE)tT3uh|`XU9s$oOk@{omx$ z{(Hj%@}aLFDYTu5{KM*JXe*={zS-4TwJCy4(d)l~uI3Bf0>vb_ zxO=+Hd#qt?2H>c~*ci)TI2ivXD>|Uo8XOxqY zWxPBoTVavJS*U?{gnd$!W^C%LgVgJEyX!XDM)fLz-v}B9<$c9z&a_j<$H%vY5KLG&pQh_qRCIL{OF@@G36( z=S|gm$GVB*@=&~2zO8iBcZ12jdvW#wVeFI=(c{d@Zqru-!s{dZvFjCZ#48@KWJ|ff zk;#kyzzkNdSnp}z?`L3h=BRQ@3*Vsxx(c369Q~pNmQ|Hx4p$DjO0HGe!)}%(|~Hckols zX(e^$)~LOner?e4^w2r)1@5O!DmP?Qnj6;8gUas|B1vARiYi0BmH{mVZV7X!?Ig$X ea>(Mh8Lu_CDdkV`gh`pQ0Nh=?oGYBdlK%_h_Tn1= literal 0 HcmV?d00001 diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_active.png b/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_active.png new file mode 100644 index 0000000000000000000000000000000000000000..cad1bcaa2bb1df1a41c393c86b0c3c2682ec45b4 GIT binary patch literal 10058 zcmeHsXH=6}*LJ9(BUQRIrAQzNB@n6*dXX+gfe->jI)vV&7paO0BGROa^dh}U8>&c` zB1M{10i}s=aOQbtW_|CUS?hcMP1d?|-}l+qx%S@I+2^dBlNencRZ21zG5`QTsji05 z$K9{sE-(o(?wiT-^bP>P;OJ*)g4IWQbGo{_*kT;foLFC1G$+~zV+#QI%)EJyac7fy z6!CMJ-h&X3a3pCmxJvACe!}s{M!k5m7Lv}W$@_#k2JmTkA(Y?yVy(68Oypuk_n~He z?WpGdxw`C;af z_5Q>1md`k-`z?Qpg@Z9Fv0uTf{8gDNs>b;v%aM7?q>uQ;!1boHZ{CdzEU@{I zn<%UDHolw>bwA%twz92T+>#?)kUJw3O1(1{DN1Rivrr!!8h#d^doFQ&_GMVU__bd9 zd2M|~+v1vCbXw=t+HfBK2npeV^YcTq!ZQazZM45Zz_(DcV_Kmo+JN|q$Tm5NO;M)8 z_hN4Pp-CRI1JE0}=Jy@-zORakH#wjZGM_C9ktM$|$rGC+uF<%{dR$Z#lAR1Hc;V3} zUN?KdZ>-;!mtuwp$~Ds#pVW77s+oLWlK0dcQzJg<$13X;#^xc?{B6SjT39-j3P*sS zYde#uPC91Q)HcKEn-t@oDdw}0@x8$}E!_zpC1fi4OB=UadPsr%8Q8A^1uwl$nXeY! zYus2hcW&PPCLL7FIP1{3S6BAaf4swceCc(HaEZLpa&Ao!H4TE#R6N%jLL_Kmga=?Z z5?xT#cwdAqPTNf`?M*hdWv~Mp#gXOHS+^_}cm*5n)HT$nTv&QOTzKLkI2WAbu9J6m z^~st4+(q_%^ZQjz^>?^xvL(h@w|j^R;w23hgCIlg^ILP%-GfmEjRG$+WJGdCi#igr z2fmbUo9tv1xIG@2khn>pgP1nXoa~U@voO(h$`2{+m8Sl27v|Ppuk_63>Q=SIgk(zV zWG1x)>cd)Xm50n)IFel>_nE^zgD{;^$D^%sQ_aLJyf^(S&!X%!`&Big0_tb`tXRGL9c?0$pj9r*`uQ3%;!;GKwk#hsX7=_ z)~ZQwRc&O?OV2VNksV~!a25JyR(z>Xx?(6lL>NOOq-;4dr;)e?y(RcoHWx|$Ta0F% z>)O!Q9fp3j5|#tkDb%J}Psv!K?{0<*3&|jJ6MIKVt*}WEsJc<`j+xi94wW562lF1+ zkm2NyZzIy*8k(JP(swG;Q;I_^#LZe8~doz{5UV2Vj?>GSeotUBgk5Qp? zz3*0bE=zA1(=zo&e|wsdhUw9-VVsyMOJQV6NEaORbC=tmvECeb3=usZUK|VZ2L=cM zAL!`1IN4o+`{t?-4tx5RjY7b=;PLm1*w-!&zuj%j2M&7eHo~lOp-wLXCDt{Z9FIv( zj`AAb3xn#fEQs;j3D(}($?4UC_0$TkJ7vWR?pEEW|Cjq<7#Wz9I?-FZyxhg1RM_d;%s?jJ_Tl_d1$YK z(-n?4tO!~U-c^8vz3+qv8<(EGs$i&6;(IVL6a#i(%d$0%?rxbAUv02TZcSF%04j=L zEORH5Zm_MxZ>u=f-E}Tg)vZe%G7&0&I+xhS9`WTlnCC%+7lji2EK|wbV?2QftIE1< zcdIG!C49oWA&@6$+r6^ZM`%|_ahYmYY)X-<_HzPL__z@gu*J9lWK*hGumsVWb7zLFu`b*s+c~4RM z%EA1Vm1izWK_QI3);;Sz+Gdz3lrgXEqXJEWVFb_U4Paq0RS60Bj`r@WWPrvi%uI$Z z|J!EzDysQMqS|W2v5FZqy{0U@j2&4AJ@byDGm>eLnC0ZV?Q>i4?Sch#0Vk4ysz9u! z=7BsA__&flG_^#zY(G2B7w@@bZa1$Ct4gC6Mam3GNLP{*_F;FO?&J*lV?_fdv#qy1 zI=Kj?XBH<{j1A?%A1axrnZSdL!mLvG*TsxAT=>dErrrVd)EI`G<=6M>+1LiHH4-N{ zgTo>`NX04^{O8=wy7zY>{51Z=Zl>YBf`$*1H0r0UZ6(tr$GhbOMgMv>`ubOOD1hGZdxzF3+Qn5jtuH;Tch^IM&f{L>+bVvSKU#26$t=nmL`-;1&@fbfjEx7ddxf#$&t6e* zw$v2tx8W)ck?*(z(*N3H3Z{7{no#knq=sh)YzkaFgr!x>*NmwTECe+KA9b(sIg&nk zM)BcI{@gh?yXD2#@RQ^Oe^+NYebKQNFGpGX^!qFd*b2eaP&|@-L<4r^i?5yl{$v`w zd-_^5tCZk;G@LwOX=rs7--Pto7r~DureqRp>vdiRr;fL&4gi$UMA7Q%r}vy4quF*G z{MoHF`H$CAclxOPB2D86AFeOjD}vyY2}6?j98<3fOj@0>G&i`dGF62MWLpKCWB>ys zzI1mvVJXB2c3rY_k)34$`(6%)D1Vlbr2IBj@W>#L2w8)d<)ckq>hn`f&CXnpWphgd zZ@eLHg4x*-oMsMbM^?14H0k?(!DtFWP>%+&PU*BoIIX+YO`N~4szVc4CIabrkIY} zyA_38%0LKQ*pIgJ2}9UE3iov#(_WXrSDAQytr9~>Yg!*k2TW~LZ8M)$LG-t`o<1Ou zt|?R}D^6I*W+F}^j>W)bU)wdCIwPEohC%9lyo`<;Uhsa?pooaH+}2d(h-IE{BtI*` zSs{-!X+pN=n}&&>ghx>Ik}h+08WL^02$ICKBywjVrCnLdSt*S_lP29Yx%S}za1ZU0 z+;<%awHUJ&eN(Gd=F9oLmSGdm;vEbw=RK3M6KYn0A-SE@JqccP=6_=IF8I}6OxycX zjFe4<$;?5thst}h|$SC_4wf&#@$I!-e zz2}dKBxUBCd6MNduQHIumfN9T8Hxy)IYxM9nXn5rGHpG|FE1Bir_bjI(^1TtK?NzA zv2J&&Vmt6kDDXDU!)9!AKG~Q9&Paz4GWQr)-d|Lu`}n^~{HEme2_Qy`J{l(>CRA0R zZoj?PieSCZjURo}!YOSE{l0qWAX-6pna}2ea^EngLL-4S_uK?t{3;t+#qm{ z7JC@`Bd5F2q%+N`=CowdtGWj}lej$RZZPKM*~G}0%0Ht(d0(yLL0>i=!R^`t&^H2v z_HWln%pdO|3}4vrSc#XragBPp0cB~U4`=kXgt6{ZnVoc_!K;}juZ>u;BVJq^6`#Is zlDygDbkpidMH-g6uZ4$Lcv$IzuSuwTTMz?`7KAH?%})xoO4Y=>3(>`?NMj27G`~ES^hp z98?e3(-_Q>wN)L3oF`Dnd?Cog1{ zaoHa-`urVPv}S4T(_=P2pBx!L`ZkGyW9(70*=_l&zBGd&s0O^!zI9$uy#bv6WA641 zIz*87M+5sX{*iCgDwrWzl4Cwq<{_caoaLj+D%R6E+xU&i`ACwuZ_*U0J9J)}rjKA& z+HFzmU^aoGMN<7^!?MEC!q;}Bj;6YI8(41;WvLgi!&#KR@FP_)@Ij5zNDF(a@<42L zL6Ryt!JDiLDLr9!VkAvENqfKzcKAKMZN>>o?d)m9rU7CU1P!JY5)7@BUkm@-5vfQP z!Wq%7m9&+WYjT5aWvW3-e)&q|>9BWS_0R*AQ4CRhD03?7OYYe(y>XBSi>YohydnJ! z;kiR2SrpE3o^2gAiS36Y+?8Cb4CB)Wql%CXpXlzJgp@K6Qhc-AH-@^wcdvhR^l4q* z_4ET!ycVp{eC~&c{QjV(5uZ}x#fyEJ6&KpuygHK=1A;#_Uu5Hf7r{!`N4#g{*29I} z+ZT9p;ae>5KIWe`&U3BeHS(*BQh{H=V{^N=K0zu!_h{Tiv?t}fl-PgJ`JucCpOw3heUj8S_5?Zz$3Dh9aaES2 zsb=|Nk)06Bb4!Bg>Z7zZ;@+ur%7ls}rq2}L!i{&7&bu`0j|t^Ag-Fd~;2%g#f~h|n zCe4P$U44*6PGUH~Y@TS4o&DJ&|DrFd-|JPgvR8D$*`sorq%l93D&czFF2{kW+~hbc zE?)A=(^{>!mHCgR+OK_HGf!8J=!}*&A+1%Yvwcg9TGUv$Hmm`Ac z+rtS$6iU92{IqyLvKXWw;dRA;Y6~Ex6{ad<8bWBd=~+l=oS#5d=fy!z?_~qEx>BGS zz;nmjr!9u0m}9pj(GPi)y>g(_e&l*HT&WI0pD@07O}{?;ZOp-at|jf6(KKuMYf>{` z1Gi|syQn*F=kq;JbSt(Z%)RZ zPYsx&T-KwI$b3{nZm%j!nM}QN&k1%U=CCBHzLDvpv$adYNi>l?s{FC^W%kpuMDd_S z)Tv?7tF+A9Qq>H+O^IAVaOSZDLK#UN=t#^`GI3Xq9bKT^Z9~OV;PM^)=o&7SCxaHn zd@m*`DOSVUpZRa`B~h2J9eRuwaM>^I=Fq5L`OO-EadcNb1s)3vi?WZO;8m?-gA0nT zC(|E_eO6Bxz9syrZAF=H8_s3J8(;&OO0?Z9y&L`!(aWqx$xg9O%9&1e)r#k9NZQ^P zKCU^svYlH^zzLI7s=65`5I3#8{8k+{H2IJMFeBHPd~Vvc7D8xqmDI3)<2+qRtu`&X zU)F|0fdX~gT~?32;6c2#oe2+sd*kRVfp&k!ZwTyJ+7^!OrMRkl<>X~+!fY$m>^;N4 z$NI!1PrO>J%y~(X3On(OSz{%+ZU`E3A~g5gR6A^C*_t%xHPs`mRwE`y3%`Gsc04yD ziT*ihtE=bP>9lfSG!Zha%g!?DfTO?9HtJh_WD~)?Tfw@U(qU(B=Q6NQe@yBz``96a zr9P|u-u`YdtEV=3hMTq#?#XA ze*4iasW>$&wyJ?Gb@}`#@er6vw+O)1|0e*jDxgO#J@O&px4W{uZQS_vvFmgbT+%Do zq7n(l$Ch(D0OikaPFbD{wL3ly&$iebm*x!~tup}ecI6v?RGaRDA2o>ci$DIRDWDhC z;p$~hHdatk898e~Tv~5&-8+?T7%wDwC4Byc=T>+_MQE*Dm%JonetH4Hp#phX+`WPt znD`NUpy~bEud*;A9}SuycZ&Fz7|o0mCTzC?KPW?WWA`c1okcsy*s-`vS+BI-24%P7 z{E6OZw%dYV1H+esi4Tn*4%Z(&AOPK|VQt~c8>U)py}_B0k-WMF37KDt54GYu*686! zjxu#_tn7()lwEyJRUG4c*q+{%o^mdOO?0@$m`Ftws~4EBGvZjGWu@ME&mjEw#HA0k1mpA1v99Y6p8UN}ZcNmpG-=|AVLxYO1bfyuIJoeFGS zmgbtug52AjU0h0@m7IcIdarfE$+C^@$JhF~`&Mo!rX_njFmQnS>Bba9FUJ<^waD*QcKAN5GJ9S1P4G({|2D*e0(cy|Y& zbi2VuErC93L*&VW@1m#q_*d$QPL1d0XU-%80q$c)tHhF$gev_h&8z!6^E>kwvLAMK zf$1>!y5g;KC*1is3kG)%ZlbLPN4Yo&BW+x)(ZW7XuDEk@06<3G#}$ckKw~+r(RLVT zS?=A&R&Gv=jV$*aac!`+s}kBCqvq$1Ht^FiMEN2N&JzqA9aC82GU>#(+O|*46m0aA>oMOUa!eEfH55^11El0*F<8EUM*GH)Q zL4kXd<+jISUEv}k-rnBA-lD=T?sg&&DJdxtFjNEz1>q1N4_{|2(g)=1!E;IRI|l;o zfpW*VVlghxoR^$PYZp(fEH^jK&iSACoLsfF|4Z-e@rMdHJw$wvt|Aa&u!xhB$X|PS zV3oaaB!2|-zxMDj#QmKhqL21)@pMO_mA%l;Sf0O9sH$u0{+Ho0B|D6h>#wA6;{DB; z4eGx*S5J4xUl<#d2-*?tgd_F9#RvHt9*eR4Q>?$mc4_&Q&R+w;x%)5w-_ZZb{TCRA z($ayHWVep?Vx{gS!t&6*pEVmZM+0*AwgCWKVZGc5yiUyH@Lc!uv;-XLq zF)0`r@+Zg`?e2jqxJyn5SQsky%VL9qtKb-sxWd6WA??s2uFiJ9441|#of@w#Zi{~GFHw@%3tNpDf9cFs9`*C2;a+!|D)y&&~CrK{XPX8 zF~3ZloWIHzjzs*ZP!Jdf2ZOmq{zzEla#sH*V;PbEM-!P}fWIsQxPHI4 z;g%QNY9;dDZ)ey0RWKGUS4>k zb3y00Mj%#QTN(J7h=rbrlT)Ne8UVmAQb*h}RO{JJ8Frw%Mc*SY+Ndru7yrgcj}W6w zRKXrhKO^Y3w>kb(K~^9(hh%B`wW>%gUvu#%?OXet(eit$lN=1ex}p>okmi0GhvSMv@(M!&#VqEK=RTfE#91=06AczI$IKye}{p+=E%RFAXP$l7;Ee}OaJ8}Wd` zrER7y`jRZUps)~1CKT@-4^wsu+7qi23j)OCGyUsZt(Hh?5>p0HZ_@j+n(q57*1+_+zEw1gaO^D%KmqNfI8vk<)!fl zAEJ1uI2L--cxn=AEH2uknUfX!RP90;gDgrWSyv9E?oM`@J)C&XUks6zeZ%OPL<_!i zgfYFA5*9sjKTkfK-n`BkHP>+DxX|)gUtqm9X>~$Z+AWix+{gWp$@J;|`Iz0;6Sjn9 z-6G>c!<#AnpBK!hWT3)DjjBY-g2hW&q6`mR_kZour&i>JML4ANAUm z;b)ZXX!k%|&#bF+f$TE)_#l#U2fO>_ z%)r1c48n{Iv*t(u1=&kHeO=j~F>wiNasSVKxd|wA)YHW=#N+teDI2*C8A!C~Z#;V; zP2lCc@&bXHpo8Tb&MRzfZl0Wf;poAY&3tQb6>G41u1t^#IiqXe@>~DEuKb7eTMY_7 zeyHU72V`|Q1*UcFZD4M=^Xc|HHMS#i3tq|_#GVy6Dp<5;K1++b;T46IY8MvDt=r*y zyY5?!=Sw3+2AOic(|3c!FP)XYRN;8&^k;^KGa^r2cYkhRlbG8$Tbn;4tI+jr<%i0R zpJG1PEYJ{X4%+?MLBzqhzM1{)^{vkjPA@q4hgtmH-tEm_ZsqhI2YQIX)78&qol`;+ E07zAP)c^nh literal 0 HcmV?d00001 diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_active_emissive.png.mcmeta b/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_active_emissive.png.mcmeta new file mode 100644 index 0000000000..cfcef74876 --- /dev/null +++ b/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_active_emissive.png.mcmeta @@ -0,0 +1,10 @@ +{ + "animation": { + "frametime": 16, + "frames": [ + 0, + 1, + 2 + ] + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_emissive.png b/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_emissive.png new file mode 100644 index 0000000000000000000000000000000000000000..0486a073200cbdd7ea5c25aafd12fc79ca526154 GIT binary patch literal 219 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4rY@E?b97f^(=z$3Dl zfq`2Xgc%uT&5-~KvX^-Jy0SlG;u6*t|5VEak-aXL9cB67j%)vy2G+gtr# zx!Z7|w$+g{U;Z;HKmOnBz2*cGYtUs6IsB5tmtv$2ox8374fE;efhhAutrfPV*`zXICH;OXk; Jvd$@?2>^hePFw&0 literal 0 HcmV?d00001 diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_paused.png b/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_paused.png new file mode 100644 index 0000000000000000000000000000000000000000..901e9e1e126f760029b545ab5778d0651e726e6f GIT binary patch literal 571 zcmV-B0>u4^P)6FA;xuGr6h*vv+++Sof$dE=yinxj zlX#WqdCCt$IzQWdX?Lr8Vxn& zKx>Wf2Pmb`S|cJ12E*S%isj{#q{mrpS_=gda1ZHwCc1^};btTP^u*}3(NbUKA$ z7<6_!bap$m+wDI`u&fM*VN3zSaDZWGwAP6;-w&wQ>x%!PegX1csdutq75e}H002ov JPDHLkV1kRp^iu!; literal 0 HcmV?d00001 diff --git a/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_paused_emissive.png b/common/src/main/resources/assets/gtceu/textures/block/multiblock/bedrock_ore_miner/overlay_front_paused_emissive.png new file mode 100644 index 0000000000000000000000000000000000000000..f18b9aa38996663d172c29d334a3e325a2dc0d2f GIT binary patch literal 569 zcmV-90>=G`P)6FbX(FBmV#Z0mey0 zK~y-)&5}QF(@+$}fA85zY~mJ*K#CZmq+Kc$r+`EPl!<-=R+vCt5CftUGeaj9R2C|x zsuB}?0$5={MTwOGAqoT*Kp~aV#CHDpG8l)32#F2u^3HoY=iGCo2mg9h0!pP4j*|so zI2>Y{CIH=T56|;Be+FzT=K2A=*om>37&uOrdacGnJ^&yD-oDSUbb1Nbb+Ijv$M=!r zM`7jauf<~n5n&-8u(^)R=V7-At9L@Bl*02oE?tPpCtML+}(goD#lX= zT5EPcXIZ(@9mjjuv?$Mk>$;4L4A?nRjzjqE4e&bFCFCfIc(&D**&_uu*O9|>MV@a5 z0^oTbeh||B-cp~MAJt$mobFPsR#>hUc=GU=Ts&9g>nmirTA)%n3&bf7p5x>PFHawQ zkb93Db^BUJF5fJwwd?z$wf?(*;JPl^>>)%15g`%wdOqoN3ez-+q6n=uoz6auMq@I8 z)*9arP)eb-MnvfM2S1Gzi;E}8QT7Rx!Ss4t&m>`5 implements IBiomeTagsProvider.FabricTagBuilder> { @@ -25,6 +27,11 @@ public void addRubberTreeTag() { tag(CustomTags.HAS_RUBBER_TREE).forceAddTag(CustomTags.IS_SWAMP).forceAddTag(BiomeTags.IS_FOREST).forceAddTag(BiomeTags.IS_JUNGLE); } + @Override + public void addSandyTag() { + tag(CustomTags.IS_SANDY).forceAddTag(ConventionalBiomeTags.CLIMATE_DRY).add(Biomes.DESERT, Biomes.BEACH, Biomes.BADLANDS, Biomes.WOODED_BADLANDS); + } + @Override public FabricTagProvider.FabricTagBuilder tag(TagKey tag) { return this.getOrCreateTagBuilder(tag); diff --git a/fabric/src/main/java/com/gregtechceu/gtceu/data/loader/fabric/FluidVeinLoaderImpl.java b/fabric/src/main/java/com/gregtechceu/gtceu/data/loader/fabric/FluidVeinLoaderImpl.java new file mode 100644 index 0000000000..dab43541ec --- /dev/null +++ b/fabric/src/main/java/com/gregtechceu/gtceu/data/loader/fabric/FluidVeinLoaderImpl.java @@ -0,0 +1,29 @@ +package com.gregtechceu.gtceu.data.loader.fabric; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.data.loader.FluidVeinLoader; +import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; +import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys; +import net.minecraft.resources.ResourceLocation; + +import java.util.Collection; +import java.util.List; + +public class FluidVeinLoaderImpl extends FluidVeinLoader implements IdentifiableResourceReloadListener { + + public static final ResourceLocation ID = GTCEu.id("fluid_veins"); + + public FluidVeinLoaderImpl() { + super(); + FluidVeinLoader.INSTANCE = this; + } + @Override + public ResourceLocation getFabricId() { + return ID; + } + + @Override + public Collection getFabricDependencies() { + return List.of(ResourceReloadListenerKeys.TAGS); + } +} diff --git a/fabric/src/main/java/com/gregtechceu/gtceu/data/loader/fabric/OreDataLoaderImpl.java b/fabric/src/main/java/com/gregtechceu/gtceu/data/loader/fabric/OreDataLoaderImpl.java index 9a543d1185..2e4561d59f 100644 --- a/fabric/src/main/java/com/gregtechceu/gtceu/data/loader/fabric/OreDataLoaderImpl.java +++ b/fabric/src/main/java/com/gregtechceu/gtceu/data/loader/fabric/OreDataLoaderImpl.java @@ -6,8 +6,8 @@ import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys; import net.minecraft.resources.ResourceLocation; -import java.util.Arrays; import java.util.Collection; +import java.util.List; public class OreDataLoaderImpl extends OreDataLoader implements IdentifiableResourceReloadListener { public static final ResourceLocation ID = GTCEu.id("ore_veins"); @@ -24,6 +24,6 @@ public ResourceLocation getFabricId() { @Override public Collection getFabricDependencies() { - return Arrays.asList(ResourceReloadListenerKeys.TAGS); + return List.of(ResourceReloadListenerKeys.TAGS); } } diff --git a/fabric/src/main/java/com/gregtechceu/gtceu/fabric/GTCEuFabric.java b/fabric/src/main/java/com/gregtechceu/gtceu/fabric/GTCEuFabric.java index a724298ee8..4656c35e21 100644 --- a/fabric/src/main/java/com/gregtechceu/gtceu/fabric/GTCEuFabric.java +++ b/fabric/src/main/java/com/gregtechceu/gtceu/fabric/GTCEuFabric.java @@ -8,6 +8,7 @@ import com.gregtechceu.gtceu.api.recipe.ingredient.fabric.SizedIngredientImpl; import com.gregtechceu.gtceu.common.ServerCommands; import com.gregtechceu.gtceu.common.fabric.CommonProxyImpl; +import com.gregtechceu.gtceu.data.loader.fabric.FluidVeinLoaderImpl; import com.gregtechceu.gtceu.data.loader.fabric.OreDataLoaderImpl; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; @@ -39,6 +40,7 @@ public void onInitialize() { CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> ServerCommands.createServerCommands().forEach(dispatcher::register)); ResourceManagerHelper.get(PackType.SERVER_DATA).registerReloadListener(new OreDataLoaderImpl()); + ResourceManagerHelper.get(PackType.SERVER_DATA).registerReloadListener(new FluidVeinLoaderImpl()); if (GTCEu.isRebornEnergyLoaded()) { GTCapability.CAPABILITY_ENERGY.registerFallback(new EUToREProvider(EnergyStorage.SIDED::find)); diff --git a/fabric/src/main/java/com/gregtechceu/gtceu/utils/fabric/GTUtilImpl.java b/fabric/src/main/java/com/gregtechceu/gtceu/utils/fabric/GTUtilImpl.java index ad0b2a763a..c309e66171 100644 --- a/fabric/src/main/java/com/gregtechceu/gtceu/utils/fabric/GTUtilImpl.java +++ b/fabric/src/main/java/com/gregtechceu/gtceu/utils/fabric/GTUtilImpl.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.utils.fabric; +import com.gregtechceu.gtceu.data.recipe.CustomTags; import com.lowdragmc.lowdraglib.side.fluid.FluidHelper; import net.fabricmc.fabric.api.registry.FuelRegistry; import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags; @@ -41,7 +42,7 @@ public static long getPumpBiomeModifier(Holder biome) { return FluidHelper.getBucket() / 4; } else if (biome.is(ConventionalBiomeTags.CLIMATE_COLD)) { return FluidHelper.getBucket() * 175 / 1000; - } else if (biome.is(BiomeTags.IS_BEACH)) { + } else if (biome.is(CustomTags.IS_SANDY)) { return FluidHelper.getBucket() * 170 / 1000; } return FluidHelper.getBucket() / 10; diff --git a/forge/build.gradle b/forge/build.gradle index ec0b2873e4..cce3aea02a 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -169,17 +169,17 @@ shadowJar { exclude "architectury.common.json" configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" + archiveClassifier = "dev-shadow" } remapJar { input.set shadowJar.archiveFile dependsOn shadowJar - classifier null + archiveClassifier = null } jar { - classifier "dev" + archiveClassifier = "dev" } sourcesJar { diff --git a/forge/src/generated/resources/assets/gtceu/lang/en_ud.json b/forge/src/generated/resources/assets/gtceu/lang/en_ud.json index 8373c3f5eb..297ea96beb 100644 --- a/forge/src/generated/resources/assets/gtceu/lang/en_ud.json +++ b/forge/src/generated/resources/assets/gtceu/lang/en_ud.json @@ -146,6 +146,7 @@ "block.gtceu.ev_battery_buffer_16x": "ɹǝɟɟnᗺ ʎɹǝʇʇɐᗺ x9Ɩ ǝbɐʇןoΛ ǝɯǝɹʇxƎ", "block.gtceu.ev_battery_buffer_4x": "ɹǝɟɟnᗺ ʎɹǝʇʇɐᗺ xㄣ ǝbɐʇןoΛ ǝɯǝɹʇxƎ", "block.gtceu.ev_battery_buffer_8x": "ɹǝɟɟnᗺ ʎɹǝʇʇɐᗺ x8 ǝbɐʇןoΛ ǝɯǝɹʇxƎ", + "block.gtceu.ev_bedrock_ore_miner": "ɹǝuıW ǝɹO ʞɔoɹpǝᗺ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_bender": "ɹ§III ɹǝpuǝᗺ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_block_breaker": "ɹ§III ɹǝʞɐǝɹᗺ ʞɔoןᗺ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_brewery": "ɹ§III ʎɹǝʍǝɹᗺ pǝɔuɐʌpⱯϛ§", @@ -176,7 +177,7 @@ "block.gtceu.ev_extruder": "ɹ§III ɹǝpnɹʇxƎ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_fermenter": "ɹ§III ɹǝʇuǝɯɹǝℲ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_fisher": "ɹ§III ɹǝɥsıℲ pǝɔuɐʌpⱯϛ§", - "block.gtceu.ev_fluid_drilling_rig": "bıᴚ buıןןıɹᗡ uoısnℲ pǝɔuɐʌpⱯϛ§", + "block.gtceu.ev_fluid_drilling_rig": "bıᴚ buıןןıɹᗡ pınןℲ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_fluid_heater": "ɹ§III ɹǝʇɐǝH pınןℲ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_fluid_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ pınןℲ ΛƎϛ§", "block.gtceu.ev_fluid_solidifier": "ɹ§III ɹǝıɟıpıןoS pınןℲ pǝɔuɐʌpⱯϛ§", @@ -190,7 +191,7 @@ "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_large_miner": "ɹǝuıW ǝbɹɐꞀ ʌƎ", + "block.gtceu.ev_large_miner": "ɹǝuıW ǝbɹɐꞀ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_laser_engraver": "ɹ§III ɹǝʌɐɹbuƎ ɹǝsɐꞀ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_lathe": "ɹ§III ǝɥʇɐꞀ pǝɔuɐʌpⱯϛ§", "block.gtceu.ev_macerator": "ɹ§III ɹoʇɐɹǝɔɐW pǝɔuɐʌpⱯϛ§", @@ -249,6 +250,7 @@ "block.gtceu.hv_battery_buffer_16x": "ɹǝɟɟnᗺ ʎɹǝʇʇɐᗺ x9Ɩ ǝbɐʇןoΛ ɥbıH", "block.gtceu.hv_battery_buffer_4x": "ɹǝɟɟnᗺ ʎɹǝʇʇɐᗺ xㄣ ǝbɐʇןoΛ ɥbıH", "block.gtceu.hv_battery_buffer_8x": "ɹǝɟɟnᗺ ʎɹǝʇʇɐᗺ x8 ǝbɐʇןoΛ ɥbıH", + "block.gtceu.hv_bedrock_ore_miner": "ɹǝuıW ǝɹO ʞɔoɹpǝᗺ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_bender": "ɹ§II ɹǝpuǝᗺ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_block_breaker": "ɹ§II ɹǝʞɐǝɹᗺ ʞɔoןᗺ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_brewery": "ɹ§II ʎɹǝʍǝɹᗺ pǝɔuɐʌpⱯ9§", @@ -276,7 +278,7 @@ "block.gtceu.hv_extruder": "ɹ§II ɹǝpnɹʇxƎ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_fermenter": "ɹ§II ɹǝʇuǝɯɹǝℲ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_fisher": "ɹ§II ɹǝɥsıℲ pǝɔuɐʌpⱯ9§", - "block.gtceu.hv_fluid_drilling_rig": "bıᴚ buıןןıɹᗡ uoısnℲ pǝɔuɐʌpⱯ9§", + "block.gtceu.hv_fluid_drilling_rig": "bıᴚ buıןןıɹᗡ pınןℲ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_fluid_heater": "ɹ§II ɹǝʇɐǝH pınןℲ pǝɔuɐʌpⱯ9§", "block.gtceu.hv_fluid_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ pınןℲ ΛH9§", "block.gtceu.hv_fluid_solidifier": "ɹ§II ɹǝıɟıpıןoS pınןℲ pǝɔuɐʌpⱯ9§", @@ -296,7 +298,7 @@ "block.gtceu.hv_macerator": "ɹ§II ɹoʇɐɹǝɔɐW pǝɔuɐʌpⱯ9§", "block.gtceu.hv_machine_casing": "buısɐƆ ǝuıɥɔɐW ΛH", "block.gtceu.hv_machine_hull": "ןןnH ǝuıɥɔɐW ΛH", - "block.gtceu.hv_miner": "ɹǝuıW ʌH", + "block.gtceu.hv_miner": "ɹ§II ɹǝuıW pǝɔuɐʌpⱯ9§", "block.gtceu.hv_mixer": "ɹ§II ɹǝxıW pǝɔuɐʌpⱯ9§", "block.gtceu.hv_muffler_hatch": "ΛH9§ ɥɔʇɐH ɹǝןɟɟnW", "block.gtceu.hv_ore_washer": "ɹ§II ɹǝɥsɐM ǝɹO pǝɔuɐʌpⱯ9§", @@ -367,7 +369,7 @@ "block.gtceu.iv_item_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ ɯǝʇI ΛIƖ§", "block.gtceu.iv_kinetic_input_box": "ɹ§ xoᗺ ʇnduI ɔıʇǝuıʞ ǝʇıןƎƖ§", "block.gtceu.iv_kinetic_output_box": "ɹ§ xoᗺ ʇndʇnO ɔıʇǝuıʞ ǝʇıןƎƖ§", - "block.gtceu.iv_large_miner": "ɹǝuıW ǝbɹɐꞀ ʌI", + "block.gtceu.iv_large_miner": "ɹǝuıW ǝbɹɐꞀ ǝʇıןƎƖ§", "block.gtceu.iv_laser_engraver": "ɹ§ ɹǝʌɐɹbuƎ ɹǝsɐꞀ ǝʇıןƎƖ§", "block.gtceu.iv_lathe": "ɹ§ ǝɥʇɐꞀ ǝʇıןƎƖ§", "block.gtceu.iv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW ǝʇıןƎƖ§", @@ -452,7 +454,7 @@ "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_large_miner": "ɹǝuıW ǝbɹɐꞀ ʌnꞀ", + "block.gtceu.luv_large_miner": "ɹǝuıW ǝbɹɐꞀ ǝʇıןƎp§", "block.gtceu.luv_laser_engraver": "ɹ§II ɹǝʌɐɹbuƎ ɹǝsɐꞀ ǝʇıןƎp§", "block.gtceu.luv_lathe": "ɹ§II ǝɥʇɐꞀ ǝʇıןƎp§", "block.gtceu.luv_macerator": "ɹ§II ɹoʇɐɹǝɔɐW ǝʇıןƎp§", @@ -533,7 +535,7 @@ "block.gtceu.lv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW ɔısɐᗺ", "block.gtceu.lv_machine_casing": "buısɐƆ ǝuıɥɔɐW ΛꞀ", "block.gtceu.lv_machine_hull": "ןןnH ǝuıɥɔɐW ΛꞀ", - "block.gtceu.lv_miner": "ɹǝuıW ʌꞀ", + "block.gtceu.lv_miner": "ɹ§ ɹǝuıW ɔısɐᗺ", "block.gtceu.lv_mixer": "ɹ§ ɹǝxıW ɔısɐᗺ", "block.gtceu.lv_muffler_hatch": "ΛꞀㄥ§ ɥɔʇɐH ɹǝןɟɟnW", "block.gtceu.lv_ore_washer": "ɹ§ ɹǝɥsɐM ǝɹO ɔısɐᗺ", @@ -567,6 +569,7 @@ "block.gtceu.mv_battery_buffer_16x": "ɹǝɟɟnᗺ ʎɹǝʇʇɐᗺ x9Ɩ ǝbɐʇןoΛ ɯnıpǝW", "block.gtceu.mv_battery_buffer_4x": "ɹǝɟɟnᗺ ʎɹǝʇʇɐᗺ xㄣ ǝbɐʇןoΛ ɯnıpǝW", "block.gtceu.mv_battery_buffer_8x": "ɹǝɟɟnᗺ ʎɹǝʇʇɐᗺ x8 ǝbɐʇןoΛ ɯnıpǝW", + "block.gtceu.mv_bedrock_ore_miner": "ɹǝuıW ǝɹO ʞɔoɹpǝᗺ pǝɔuɐʌpⱯq§", "block.gtceu.mv_bender": "ɹ§ ɹǝpuǝᗺ pǝɔuɐʌpⱯq§", "block.gtceu.mv_block_breaker": "ɹ§ ɹǝʞɐǝɹᗺ ʞɔoןᗺ pǝɔuɐʌpⱯq§", "block.gtceu.mv_brewery": "ɹ§ ʎɹǝʍǝɹᗺ pǝɔuɐʌpⱯq§", @@ -594,7 +597,7 @@ "block.gtceu.mv_extruder": "ɹ§ ɹǝpnɹʇxƎ pǝɔuɐʌpⱯq§", "block.gtceu.mv_fermenter": "ɹ§ ɹǝʇuǝɯɹǝℲ pǝɔuɐʌpⱯq§", "block.gtceu.mv_fisher": "ɹ§ ɹǝɥsıℲ pǝɔuɐʌpⱯq§", - "block.gtceu.mv_fluid_drilling_rig": "bıᴚ buıןןıɹᗡ uoısnℲ pǝɔuɐʌpⱯq§", + "block.gtceu.mv_fluid_drilling_rig": "bıᴚ buıןןıɹᗡ pınןℲ pǝɔuɐʌpⱯq§", "block.gtceu.mv_fluid_heater": "ɹ§ ɹǝʇɐǝH pınןℲ pǝɔuɐʌpⱯq§", "block.gtceu.mv_fluid_passthrough_hatch": "ɥɔʇɐH ɥbnoɹɥʇssɐԀ pınןℲ ΛWq§", "block.gtceu.mv_fluid_solidifier": "ɹ§ ɹǝıɟıpıןoS pınןℲ pǝɔuɐʌpⱯq§", @@ -614,7 +617,7 @@ "block.gtceu.mv_macerator": "ɹ§ ɹoʇɐɹǝɔɐW pǝɔuɐʌpⱯq§", "block.gtceu.mv_machine_casing": "buısɐƆ ǝuıɥɔɐW ΛW", "block.gtceu.mv_machine_hull": "ןןnH ǝuıɥɔɐW ΛW", - "block.gtceu.mv_miner": "ɹǝuıW ʌW", + "block.gtceu.mv_miner": "ɹ§ ɹǝuıW pǝɔuɐʌpⱯq§", "block.gtceu.mv_mixer": "ɹ§ ɹǝxıW pǝɔuɐʌpⱯq§", "block.gtceu.mv_muffler_hatch": "ΛWq§ ɥɔʇɐH ɹǝןɟɟnW", "block.gtceu.mv_ore_washer": "ɹ§ ɹǝɥsɐM ǝɹO pǝɔuɐʌpⱯq§", @@ -914,12 +917,14 @@ "block.gtceu.zpm_wiremill": "ɹ§III ןןıɯǝɹıM ǝʇıןƎɔ§", "block.superconducting_coil": "ʞɔoןᗺ ןıoƆ buıʇɔnpuoɔɹǝdnS", "config.gtceu.option.allUniqueStoneTypes": "sǝdʎ⟘ǝuoʇSǝnbıu∩ןןɐ", + "config.gtceu.option.bedrockOreDropTagPrefix": "xıɟǝɹԀbɐ⟘doɹᗡǝɹOʞɔoɹpǝq", "config.gtceu.option.cleanMultiblocks": "sʞɔoןqıʇןnWuɐǝןɔ", "config.gtceu.option.client": "ʇuǝıןɔ", "config.gtceu.option.compat": "ʇɐdɯoɔ", "config.gtceu.option.debugWorldgen": "uǝbpןɹoMbnqǝp", "config.gtceu.option.defaultPaintingColor": "ɹoןoƆbuıʇuıɐԀʇןnɐɟǝp", "config.gtceu.option.disableManualCompression": "uoıssǝɹdɯoƆןɐnuɐWǝןqɐsıp", + "config.gtceu.option.doBedrockOres": "sǝɹOʞɔoɹpǝᗺop", "config.gtceu.option.doTerrainExplosion": "uoısoןdxƎuıɐɹɹǝ⟘op", "config.gtceu.option.doesExplosionDamagesTerrain": "uıɐɹɹǝ⟘sǝbɐɯɐᗡuoısoןdxƎsǝop", "config.gtceu.option.enableCleanroom": "ɯooɹuɐǝןƆǝןqɐuǝ", @@ -1285,6 +1290,7 @@ "gtceu.gui.content.chance_0_short": "ɹ§ƆNɔ§", "gtceu.gui.content.chance_1": "ɹ§%s :ǝɔuɐɥƆǝ§", "gtceu.gui.content.per_tick": "ɹ§ʞɔı⟘ ɹǝԀ pǝɔnpoɹԀ/pǝɯnsuoƆɐ§", + "gtceu.gui.content.tier_boost": "ɹ§ɹǝıʇ/%s+ :ǝɔuɐɥƆ ɹǝı⟘ǝ§", "gtceu.gui.content.tips.per_tick_short": "ɹ§ʞɔıʇ/ɐ§", "gtceu.gui.cover_setting.title": "sbuıʇʇǝS ɹǝʌoƆ", "gtceu.gui.editor.group.recipe_type": "dɐɔ", @@ -1419,6 +1425,9 @@ "gtceu.machine.autoclave.zpm.tooltip": "ɹǝʞooƆ ǝɹnssǝɹԀㄥ§", "gtceu.machine.basic.input_from_output_side.allow": " :ǝpıS ʇndʇnO ɯoɹɟ ʇnduI ʍoןןⱯ", "gtceu.machine.basic.input_from_output_side.disallow": " :ǝpıS ʇndʇnO ɯoɹɟ ʇnduI ʍoןןɐsıᗡ", + "gtceu.machine.bedrock_ore_miner.depletion": "%s%%ɟ§ :ǝʇɐᴚ uoıʇǝןdǝᗡq§", + "gtceu.machine.bedrock_ore_miner.description": "˙ʞɔoɹpǝq ɹǝpun suıǝʌ ɯoɹɟ sǝɹo sןןıɹᗡ", + "gtceu.machine.bedrock_ore_miner.production": "pǝʞɔoןɔɹǝʌo xɟ% 'x%dɟ§ :ɹǝıןdıʇןnW uoıʇɔnpoɹԀǝ§", "gtceu.machine.bender.ev.tooltip": "¡¡¡ᴚƎᗡNƎᗺ ʇuɐʍ ǝM ¡pɐq s,ǝɥ 'ooᗺㄥ§", "gtceu.machine.bender.hv.tooltip": "¡¡¡ᴚƎᗡNƎᗺ ʇuɐʍ ǝM ¡pɐq s,ǝɥ 'ooᗺㄥ§", "gtceu.machine.bender.iv.tooltip": "ɹǝʇɹoʇsıᗡ ǝdɐɥSㄥ§", @@ -3179,6 +3188,7 @@ "material.cassiterite_sand": "puɐS ǝʇıɹǝʇıssɐƆ", "material.cerium": "ɯnıɹǝƆ", "material.certus_quartz": "zʇɹɐnὉ snʇɹǝƆ", + "material.cetane_boosted_diesel": "ןǝsǝıᗡ pǝʇsooᗺ ǝuɐʇǝƆ", "material.chalcocite": "ǝʇıɔoɔןɐɥƆ", "material.chalcopyrite": "ǝʇıɹʎdoɔןɐɥƆ", "material.charcoal": "ןɐoɔɹɐɥƆ", @@ -3208,6 +3218,7 @@ "material.copernicium": "ɯnıɔıuɹǝdoƆ", "material.copper": "ɹǝddoƆ", "material.creosote": "ǝʇosoǝɹƆ", + "material.crystal_matrix": "xıɹʇɐW ןɐʇsʎɹƆ", "material.cumene": "ǝuǝɯnƆ", "material.cupric_oxide": "ǝpıxO ɔıɹdnƆ", "material.cupronickel": "ןǝʞɔıuoɹdnƆ", @@ -3287,7 +3298,6 @@ "material.garnet_sand": "puɐS ʇǝuɹɐ⅁", "material.garnierite": "ǝʇıɹǝıuɹɐ⅁", "material.gasoline": "ǝuıןosɐ⅁", - "material.gasoline_premium": "ɯnıɯǝɹԀ ǝuıןosɐ⅁", "material.gelatin": "uıʇɐןǝ⅁", "material.gelatin_mixture": "ǝɹnʇxıW uıʇɐןǝ⅁", "material.germanium": "ɯnıuɐɯɹǝ⅁", @@ -3317,6 +3327,7 @@ "material.helium": "ɯnıןǝH", "material.helium_3": "Ɛ ɯnıןǝH", "material.hematite": "ǝʇıʇɐɯǝH", + "material.high_octane_gasoline": "ǝuıןosɐ⅁ ǝuɐʇɔO ɥbıH", "material.holmium": "ɯnıɯןoH", "material.hsse": "Ǝ-SSH", "material.hssg": "⅁-SSH", @@ -3343,6 +3354,7 @@ "material.indium_phosphide": "ǝpıɥdsoɥԀ ɯnıpuI", "material.indium_tin_barium_titanium_cuprate": "ǝʇɐɹdnƆ ɯnıuɐʇı⟘ ɯnıɹɐᗺ uı⟘ ɯnıpuI", "material.inert_metal_mixture": "ǝɹnʇxıW ןɐʇǝW ʇɹǝuI", + "material.infinity": "ʎʇıuıɟuI", "material.invar": "ɹɐʌuI", "material.iodine": "ǝuıpoI", "material.iridium": "ɯnıpıɹI", @@ -3449,7 +3461,6 @@ "material.nitration_mixture": "ǝɹnʇxıW uoıʇɐɹʇıN", "material.nitric_acid": "pıɔⱯ ɔıɹʇıN", "material.nitric_oxide": "ǝpıxO ɔıɹʇıN", - "material.nitro_fuel": "ןǝnℲ oɹʇıN", "material.nitrobenzene": "ǝuǝzuǝqoɹʇıN", "material.nitrochlorobenzene": "ǝuǝzuǝqoɹoןɥɔoɹʇıN", "material.nitrogen": "uǝboɹʇıN", @@ -3761,6 +3772,7 @@ "metaitem.nan.certificate.tooltip": "¡pǝʇdǝɔɔⱯ ǝbuǝןןɐɥƆ", "metaitem.plugin.proxy.tooltips.1": ")uǝǝɹɔs ǝɥʇ uı ǝpoɯ ʎxoɹd oʇ ʇsnظpɐ ǝsɐǝןԀ(", "metaitem.plugin.tooltips.1": "˙ʎʇıןɐuoıʇɔunɟ ǝɹoɯ ɹoɟ uǝǝɹɔs ǝɥʇ oʇ pǝppɐ ǝq uɐɔ suıbnןԀ", + "metaitem.prospector.mode.bedrock_ore": "ɹ§ǝpoW uoıʇɔǝdsoɹԀ ǝɹO ʞɔoɹpǝᗺq§", "metaitem.prospector.mode.fluid": "ɹ§ǝpoW uoıʇɔǝdsoɹԀ pınןℲq§", "metaitem.prospector.mode.ores": "ɹ§ǝpoW uoıʇɔǝdsoɹԀ ǝɹOɐ§", "metaitem.prospector.tooltip.modes": ":sǝpoW ǝןqɐןıɐʌⱯ", diff --git a/forge/src/generated/resources/assets/gtceu/lang/en_us.json b/forge/src/generated/resources/assets/gtceu/lang/en_us.json index 75ded3c7d5..5e3424bc81 100644 --- a/forge/src/generated/resources/assets/gtceu/lang/en_us.json +++ b/forge/src/generated/resources/assets/gtceu/lang/en_us.json @@ -146,6 +146,7 @@ "block.gtceu.ev_battery_buffer_16x": "Extreme Voltage 16x Battery Buffer", "block.gtceu.ev_battery_buffer_4x": "Extreme Voltage 4x Battery Buffer", "block.gtceu.ev_battery_buffer_8x": "Extreme Voltage 8x Battery Buffer", + "block.gtceu.ev_bedrock_ore_miner": "§5Advanced Bedrock Ore Miner", "block.gtceu.ev_bender": "§5Advanced Bender III§r", "block.gtceu.ev_block_breaker": "§5Advanced Block Breaker III§r", "block.gtceu.ev_brewery": "§5Advanced Brewery III§r", @@ -176,7 +177,7 @@ "block.gtceu.ev_extruder": "§5Advanced Extruder III§r", "block.gtceu.ev_fermenter": "§5Advanced Fermenter III§r", "block.gtceu.ev_fisher": "§5Advanced Fisher III§r", - "block.gtceu.ev_fluid_drilling_rig": "§5Advanced Fusion Drilling Rig", + "block.gtceu.ev_fluid_drilling_rig": "§5Advanced Fluid Drilling Rig", "block.gtceu.ev_fluid_heater": "§5Advanced Fluid Heater III§r", "block.gtceu.ev_fluid_passthrough_hatch": "§5EV Fluid Passthrough Hatch", "block.gtceu.ev_fluid_solidifier": "§5Advanced Fluid Solidifier III§r", @@ -190,7 +191,7 @@ "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_large_miner": "Ev Large Miner", + "block.gtceu.ev_large_miner": "§5Advanced Large Miner", "block.gtceu.ev_laser_engraver": "§5Advanced Laser Engraver III§r", "block.gtceu.ev_lathe": "§5Advanced Lathe III§r", "block.gtceu.ev_macerator": "§5Advanced Macerator III§r", @@ -249,6 +250,7 @@ "block.gtceu.hv_battery_buffer_16x": "High Voltage 16x Battery Buffer", "block.gtceu.hv_battery_buffer_4x": "High Voltage 4x Battery Buffer", "block.gtceu.hv_battery_buffer_8x": "High Voltage 8x Battery Buffer", + "block.gtceu.hv_bedrock_ore_miner": "§6Advanced Bedrock Ore Miner", "block.gtceu.hv_bender": "§6Advanced Bender II§r", "block.gtceu.hv_block_breaker": "§6Advanced Block Breaker II§r", "block.gtceu.hv_brewery": "§6Advanced Brewery II§r", @@ -276,7 +278,7 @@ "block.gtceu.hv_extruder": "§6Advanced Extruder II§r", "block.gtceu.hv_fermenter": "§6Advanced Fermenter II§r", "block.gtceu.hv_fisher": "§6Advanced Fisher II§r", - "block.gtceu.hv_fluid_drilling_rig": "§6Advanced Fusion Drilling Rig", + "block.gtceu.hv_fluid_drilling_rig": "§6Advanced Fluid Drilling Rig", "block.gtceu.hv_fluid_heater": "§6Advanced Fluid Heater II§r", "block.gtceu.hv_fluid_passthrough_hatch": "§6HV Fluid Passthrough Hatch", "block.gtceu.hv_fluid_solidifier": "§6Advanced Fluid Solidifier II§r", @@ -296,7 +298,7 @@ "block.gtceu.hv_macerator": "§6Advanced Macerator II§r", "block.gtceu.hv_machine_casing": "HV Machine Casing", "block.gtceu.hv_machine_hull": "HV Machine Hull", - "block.gtceu.hv_miner": "Hv Miner", + "block.gtceu.hv_miner": "§6Advanced Miner II§r", "block.gtceu.hv_mixer": "§6Advanced Mixer II§r", "block.gtceu.hv_muffler_hatch": "Muffler Hatch §6HV", "block.gtceu.hv_ore_washer": "§6Advanced Ore Washer II§r", @@ -367,7 +369,7 @@ "block.gtceu.iv_item_passthrough_hatch": "§1IV Item Passthrough Hatch", "block.gtceu.iv_kinetic_input_box": "§1Elite Kinetic Input Box §r", "block.gtceu.iv_kinetic_output_box": "§1Elite Kinetic Output Box §r", - "block.gtceu.iv_large_miner": "Iv Large Miner", + "block.gtceu.iv_large_miner": "§1Elite Large Miner", "block.gtceu.iv_laser_engraver": "§1Elite Laser Engraver §r", "block.gtceu.iv_lathe": "§1Elite Lathe §r", "block.gtceu.iv_macerator": "§1Elite Macerator §r", @@ -452,7 +454,7 @@ "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_large_miner": "Luv Large Miner", + "block.gtceu.luv_large_miner": "§dElite Large Miner", "block.gtceu.luv_laser_engraver": "§dElite Laser Engraver II§r", "block.gtceu.luv_lathe": "§dElite Lathe II§r", "block.gtceu.luv_macerator": "§dElite Macerator II§r", @@ -533,7 +535,7 @@ "block.gtceu.lv_macerator": "Basic Macerator §r", "block.gtceu.lv_machine_casing": "LV Machine Casing", "block.gtceu.lv_machine_hull": "LV Machine Hull", - "block.gtceu.lv_miner": "Lv Miner", + "block.gtceu.lv_miner": "Basic Miner §r", "block.gtceu.lv_mixer": "Basic Mixer §r", "block.gtceu.lv_muffler_hatch": "Muffler Hatch §7LV", "block.gtceu.lv_ore_washer": "Basic Ore Washer §r", @@ -567,6 +569,7 @@ "block.gtceu.mv_battery_buffer_16x": "Medium Voltage 16x Battery Buffer", "block.gtceu.mv_battery_buffer_4x": "Medium Voltage 4x Battery Buffer", "block.gtceu.mv_battery_buffer_8x": "Medium Voltage 8x Battery Buffer", + "block.gtceu.mv_bedrock_ore_miner": "§bAdvanced Bedrock Ore Miner", "block.gtceu.mv_bender": "§bAdvanced Bender §r", "block.gtceu.mv_block_breaker": "§bAdvanced Block Breaker §r", "block.gtceu.mv_brewery": "§bAdvanced Brewery §r", @@ -594,7 +597,7 @@ "block.gtceu.mv_extruder": "§bAdvanced Extruder §r", "block.gtceu.mv_fermenter": "§bAdvanced Fermenter §r", "block.gtceu.mv_fisher": "§bAdvanced Fisher §r", - "block.gtceu.mv_fluid_drilling_rig": "§bAdvanced Fusion Drilling Rig", + "block.gtceu.mv_fluid_drilling_rig": "§bAdvanced Fluid Drilling Rig", "block.gtceu.mv_fluid_heater": "§bAdvanced Fluid Heater §r", "block.gtceu.mv_fluid_passthrough_hatch": "§bMV Fluid Passthrough Hatch", "block.gtceu.mv_fluid_solidifier": "§bAdvanced Fluid Solidifier §r", @@ -614,7 +617,7 @@ "block.gtceu.mv_macerator": "§bAdvanced Macerator §r", "block.gtceu.mv_machine_casing": "MV Machine Casing", "block.gtceu.mv_machine_hull": "MV Machine Hull", - "block.gtceu.mv_miner": "Mv Miner", + "block.gtceu.mv_miner": "§bAdvanced Miner §r", "block.gtceu.mv_mixer": "§bAdvanced Mixer §r", "block.gtceu.mv_muffler_hatch": "Muffler Hatch §bMV", "block.gtceu.mv_ore_washer": "§bAdvanced Ore Washer §r", @@ -914,12 +917,14 @@ "block.gtceu.zpm_wiremill": "§cElite Wiremill III§r", "block.superconducting_coil": "Superconducting Coil Block", "config.gtceu.option.allUniqueStoneTypes": "allUniqueStoneTypes", + "config.gtceu.option.bedrockOreDropTagPrefix": "bedrockOreDropTagPrefix", "config.gtceu.option.cleanMultiblocks": "cleanMultiblocks", "config.gtceu.option.client": "client", "config.gtceu.option.compat": "compat", "config.gtceu.option.debugWorldgen": "debugWorldgen", "config.gtceu.option.defaultPaintingColor": "defaultPaintingColor", "config.gtceu.option.disableManualCompression": "disableManualCompression", + "config.gtceu.option.doBedrockOres": "doBedrockOres", "config.gtceu.option.doTerrainExplosion": "doTerrainExplosion", "config.gtceu.option.doesExplosionDamagesTerrain": "doesExplosionDamagesTerrain", "config.gtceu.option.enableCleanroom": "enableCleanroom", @@ -1285,6 +1290,7 @@ "gtceu.gui.content.chance_0_short": "§cNC§r", "gtceu.gui.content.chance_1": "§eChance: %s§r", "gtceu.gui.content.per_tick": "§aConsumed/Produced Per Tick§r", + "gtceu.gui.content.tier_boost": "§eTier Chance: +%s/tier§r", "gtceu.gui.content.tips.per_tick_short": "§a/tick§r", "gtceu.gui.cover_setting.title": "Cover Settings", "gtceu.gui.editor.group.recipe_type": "cap", @@ -1419,6 +1425,9 @@ "gtceu.machine.autoclave.zpm.tooltip": "§7Pressure Cooker", "gtceu.machine.basic.input_from_output_side.allow": "Allow Input from Output Side: ", "gtceu.machine.basic.input_from_output_side.disallow": "Disallow Input from Output Side: ", + "gtceu.machine.bedrock_ore_miner.depletion": "§bDepletion Rate: §f%s%%", + "gtceu.machine.bedrock_ore_miner.description": "Drills ores from veins under bedrock.", + "gtceu.machine.bedrock_ore_miner.production": "§eProduction Multiplier: §f%dx, %fx overclocked", "gtceu.machine.bender.ev.tooltip": "§7Boo, he's bad! We want BENDER!!!", "gtceu.machine.bender.hv.tooltip": "§7Boo, he's bad! We want BENDER!!!", "gtceu.machine.bender.iv.tooltip": "§7Shape Distorter", @@ -3179,6 +3188,7 @@ "material.cassiterite_sand": "Cassiterite Sand", "material.cerium": "Cerium", "material.certus_quartz": "Certus Quartz", + "material.cetane_boosted_diesel": "Cetane Boosted Diesel", "material.chalcocite": "Chalcocite", "material.chalcopyrite": "Chalcopyrite", "material.charcoal": "Charcoal", @@ -3287,7 +3297,6 @@ "material.garnet_sand": "Garnet Sand", "material.garnierite": "Garnierite", "material.gasoline": "Gasoline", - "material.gasoline_premium": "Gasoline Premium", "material.gelatin": "Gelatin", "material.gelatin_mixture": "Gelatin Mixture", "material.germanium": "Germanium", @@ -3317,6 +3326,7 @@ "material.helium": "Helium", "material.helium_3": "Helium 3", "material.hematite": "Hematite", + "material.high_octane_gasoline": "High Octane Gasoline", "material.holmium": "Holmium", "material.hsse": "HSS-E", "material.hssg": "HSS-G", @@ -3449,7 +3459,6 @@ "material.nitration_mixture": "Nitration Mixture", "material.nitric_acid": "Nitric Acid", "material.nitric_oxide": "Nitric Oxide", - "material.nitro_fuel": "Nitro Fuel", "material.nitrobenzene": "Nitrobenzene", "material.nitrochlorobenzene": "Nitrochlorobenzene", "material.nitrogen": "Nitrogen", @@ -3761,6 +3770,7 @@ "metaitem.nan.certificate.tooltip": "Challenge Accepted!", "metaitem.plugin.proxy.tooltips.1": "(Please adjust to proxy mode in the screen)", "metaitem.plugin.tooltips.1": "Plugins can be added to the screen for more functionality.", + "metaitem.prospector.mode.bedrock_ore": "§bBedrock Ore Prospection Mode§r", "metaitem.prospector.mode.fluid": "§bFluid Prospection Mode§r", "metaitem.prospector.mode.ores": "§aOre Prospection Mode§r", "metaitem.prospector.tooltip.modes": "Available Modes:", diff --git a/forge/src/generated/resources/data/gtceu/tags/worldgen/biome/is_sandy.json b/forge/src/generated/resources/data/gtceu/tags/worldgen/biome/is_sandy.json new file mode 100644 index 0000000000..fbd2becc69 --- /dev/null +++ b/forge/src/generated/resources/data/gtceu/tags/worldgen/biome/is_sandy.json @@ -0,0 +1,9 @@ +{ + "values": [ + "#forge:is_sandy", + "minecraft:desert", + "minecraft:beach", + "minecraft:badlands", + "minecraft:wooded_badlands" + ] +} \ No newline at end of file diff --git a/forge/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/forge/SizedIngredientImpl.java b/forge/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/forge/SizedIngredientImpl.java index 1870552f08..93b85bff18 100644 --- a/forge/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/forge/SizedIngredientImpl.java +++ b/forge/src/main/java/com/gregtechceu/gtceu/api/recipe/ingredient/forge/SizedIngredientImpl.java @@ -57,6 +57,10 @@ public IIngredientSerializer getSerializer() { return SERIALIZER; } + public static SizedIngredient fromJson(JsonObject json) { + return SERIALIZER.parse(json); + } + public static final IIngredientSerializer SERIALIZER = new IIngredientSerializer<>() { @Override public @NotNull SizedIngredientImpl parse(FriendlyByteBuf buffer) { diff --git a/forge/src/main/java/com/gregtechceu/gtceu/common/data/forge/GTFeaturesImpl.java b/forge/src/main/java/com/gregtechceu/gtceu/common/data/forge/GTFeaturesImpl.java index 899dd4e6a8..0268824d6e 100644 --- a/forge/src/main/java/com/gregtechceu/gtceu/common/data/forge/GTFeaturesImpl.java +++ b/forge/src/main/java/com/gregtechceu/gtceu/common/data/forge/GTFeaturesImpl.java @@ -2,8 +2,8 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.BiomeWeightModifier; -import com.gregtechceu.gtceu.api.data.worldgen.GTOreFeatureEntry; import com.gregtechceu.gtceu.api.data.worldgen.generator.BiomePlacement; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTBlocks; import com.gregtechceu.gtceu.common.data.GTPlacements; import com.gregtechceu.gtceu.data.recipe.CustomTags; @@ -52,7 +52,7 @@ public static void init(IEventBus modEventBus) { } public static void register() { - for (var entry : GTOreFeatureEntry.ALL.entrySet()) { + for (var entry : GTRegistries.ORE_VEINS.entries()) { ResourceLocation id = entry.getKey(); var datagenExt = entry.getValue().getVeinGenerator(); if (datagenExt != null) { diff --git a/forge/src/main/java/com/gregtechceu/gtceu/common/data/forge/GTItemsImpl.java b/forge/src/main/java/com/gregtechceu/gtceu/common/data/forge/GTItemsImpl.java index 489e51d1bd..f6c521d672 100644 --- a/forge/src/main/java/com/gregtechceu/gtceu/common/data/forge/GTItemsImpl.java +++ b/forge/src/main/java/com/gregtechceu/gtceu/common/data/forge/GTItemsImpl.java @@ -36,7 +36,7 @@ public static NonNullConsumer modelPredicate(ResourceLocatio } public static void registerToolTier(MaterialToolTier tier, ResourceLocation id, Collection before, Collection after) { - TierSortingRegistry.registerTier(tier, id, Arrays.asList(before.toArray(Tier[]::new)), Arrays.asList(after.toArray(Tier[]::new))); + TierSortingRegistry.registerTier(tier, id, Arrays.asList((Object[]) before.toArray(Tier[]::new)), Arrays.asList((Object[]) after.toArray(Tier[]::new))); } public static List getAllToolTiers() { diff --git a/forge/src/main/java/com/gregtechceu/gtceu/data/forge/BiomeTagsProviderImpl.java b/forge/src/main/java/com/gregtechceu/gtceu/data/forge/BiomeTagsProviderImpl.java index 19ee7347db..c71e07f02a 100644 --- a/forge/src/main/java/com/gregtechceu/gtceu/data/forge/BiomeTagsProviderImpl.java +++ b/forge/src/main/java/com/gregtechceu/gtceu/data/forge/BiomeTagsProviderImpl.java @@ -8,6 +8,8 @@ import net.minecraft.tags.BiomeTags; import net.minecraft.tags.TagKey; import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.Biomes; +import net.minecraftforge.common.Tags; import net.minecraftforge.common.data.ExistingFileHelper; public class BiomeTagsProviderImpl extends BiomeTagsProvider implements IBiomeTagsProvider> { @@ -32,6 +34,11 @@ public void addRubberTreeTag() { tag(CustomTags.HAS_RUBBER_TREE).addTags(CustomTags.IS_SWAMP, BiomeTags.IS_FOREST, BiomeTags.IS_JUNGLE); } + @Override + public void addSandyTag() { + tag(CustomTags.IS_SANDY).addTag(Tags.Biomes.IS_SANDY).add(Biomes.DESERT, Biomes.BEACH, Biomes.BADLANDS, Biomes.WOODED_BADLANDS); + } + @Override public TagAppender tag(TagKey tag) { return super.tag(tag); diff --git a/forge/src/main/java/com/gregtechceu/gtceu/data/loader/forge/FluidVeinLoaderImpl.java b/forge/src/main/java/com/gregtechceu/gtceu/data/loader/forge/FluidVeinLoaderImpl.java new file mode 100644 index 0000000000..087a906244 --- /dev/null +++ b/forge/src/main/java/com/gregtechceu/gtceu/data/loader/forge/FluidVeinLoaderImpl.java @@ -0,0 +1,11 @@ +package com.gregtechceu.gtceu.data.loader.forge; + +import com.gregtechceu.gtceu.data.loader.FluidVeinLoader; + +public class FluidVeinLoaderImpl extends FluidVeinLoader { + + public FluidVeinLoaderImpl() { + super(); + FluidVeinLoader.INSTANCE = this; + } +} diff --git a/forge/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java b/forge/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java index 0312d6b083..4a6be86db1 100644 --- a/forge/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java +++ b/forge/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java @@ -7,6 +7,7 @@ import com.gregtechceu.gtceu.api.item.forge.DrumMachineItemImpl; import com.gregtechceu.gtceu.api.machine.feature.IInteractedMachine; import com.gregtechceu.gtceu.common.ServerCommands; +import com.gregtechceu.gtceu.data.loader.forge.FluidVeinLoaderImpl; import com.gregtechceu.gtceu.data.loader.forge.OreDataLoaderImpl; import net.minecraft.core.Direction; import net.minecraft.world.item.ItemStack; @@ -74,6 +75,7 @@ public static void registerCommand(RegisterCommandsEvent event) { @SubscribeEvent public static void registerReloadListeners(AddReloadListenerEvent event) { event.addListener(new OreDataLoaderImpl()); + event.addListener(new FluidVeinLoaderImpl()); } @SubscribeEvent diff --git a/forge/src/main/java/com/gregtechceu/gtceu/utils/forge/GTUtilImpl.java b/forge/src/main/java/com/gregtechceu/gtceu/utils/forge/GTUtilImpl.java index d864ba94d9..c6fae1edad 100644 --- a/forge/src/main/java/com/gregtechceu/gtceu/utils/forge/GTUtilImpl.java +++ b/forge/src/main/java/com/gregtechceu/gtceu/utils/forge/GTUtilImpl.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.utils.forge; +import com.gregtechceu.gtceu.data.recipe.CustomTags; import com.lowdragmc.lowdraglib.side.fluid.FluidHelper; import net.minecraft.core.Holder; import net.minecraft.tags.BiomeTags; @@ -41,7 +42,7 @@ public static long getPumpBiomeModifier(Holder biome) { return FluidHelper.getBucket() / 4; } else if (biome.is(Tags.Biomes.IS_COLD)) { return FluidHelper.getBucket() * 175 / 1000; - } else if (biome.is(BiomeTags.IS_BEACH)) { + } else if (biome.is(CustomTags.IS_SANDY)) { return FluidHelper.getBucket() * 170 / 1000; } return FluidHelper.getBucket() / 10; diff --git a/gradle.properties b/gradle.properties index 99cd1f5497..eb46bdf893 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx6G # Mod Info mod_id = gtceu mod_name = GregTech -mod_version = 1.0.6 +mod_version = 1.0.7 mod_description = GregTech CE Unofficial, ported from 1.12.2 mod_license = LGPL-3.0 license mod_url = https://https://github.com/GregTechCEu/GregTechCEu-1.19/ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb87909..84a0b92f9a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 66b671f63c..65822d23fb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -22,17 +22,17 @@ dependencyResolutionManagement { def reiVersion = "9.1.619" def emiVersion = "1.0.5+1.19.2" def ae2Version = "12.9.5" + def kjsVersion = "1902.6.1-build.287" // Fabric - def fabricLoaderVersion = "0.14.11" // https://fabricmc.net/develop/ - def fabricApiVersion = "0.73.2" // https://fabricmc.net/develop/ + def fabricLoaderVersion = "0.14.21" // https://fabricmc.net/develop/ + def fabricApiVersion = "0.76.0" // https://fabricmc.net/develop/ def createVersion = "0.5.1-b-build.1079" def lazyDfuVersion = "0.1.3" def modMenuVersion = "4.1.2" def topFabricVersion = "1.19-6.0.0" def jadeFabricVersion = "8.7.3" - def registrateFabricVersion = "1.1.50-MC1.19.2" - def kjsVersion = "1902.6.0-build.142" + def registrateFabricVersion = "1.1.58-MC1.19.2" def forgeConfigApiVersion = "4.2.11" def nightConfigVersion = "3.6.5" def teamRebornEnergyVersion = "2.3.0" @@ -40,7 +40,7 @@ dependencyResolutionManagement { def worldStripperFabricFile = "3921629" // Forge - def forgeVersion = "43.2.3" + def forgeVersion = "43.2.19" def registrateForgeVersion = "MC1.19-1.1.5" def createForgeVersion = "0.5.1.b-30" def flywheelForgeVersion = "0.6.8.a-14" @@ -55,9 +55,9 @@ dependencyResolutionManagement { def shadowVersion = "7.1.2" def architecturyPluginVersion = "3.4-SNAPSHOT" def architecturyLoomVersion = "1.0-SNAPSHOT" - def quiltFlowerVersion = "1.+" + def vineFlowerVersion = "1.+" def macheteVersion = "1.+" - def ldLibVersion = "1.0.12" + def ldLibVersion = "1.0.13" fabric { def parchment = version("parchment", parchmentVersion) @@ -193,8 +193,8 @@ dependencyResolutionManagement { def architecturyLoom = version("architectury-loom", architecturyLoomVersion) plugin("architectury-loom", "dev.architectury.loom").versionRef(architecturyLoom) - def quiltFlower = version("quiltFlower", quiltFlowerVersion) - plugin("quiltFlower", "io.github.juuxel.loom-quiltflower").versionRef(quiltFlower) + def vineFlower = version("vineFlower", vineFlowerVersion) + plugin("vineFlower", "io.github.juuxel.loom-vineflower").versionRef(vineFlower) def machete = version("machete", macheteVersion) plugin("machete", "io.github.p03w.machete").versionRef(machete)