diff --git a/docs/content/Modpacks/Changes/v8.0.0.md b/docs/content/Modpacks/Changes/v8.0.0.md index 5fc9d5adbbd..ddc2b4ba601 100644 --- a/docs/content/Modpacks/Changes/v8.0.0.md +++ b/docs/content/Modpacks/Changes/v8.0.0.md @@ -5,6 +5,66 @@ title: "Version 8.0.0" # Updating from `7.4.0` to `8.0.0` +## Registration Changes + +GregTech content is now registered in standard forge/minecraft registries instead of using a custom registry implementation. + +### For KJS + +- Find and replace `GTCEuStartupEvents.registry` with `StartupEvents.registry` +- Register material icon types with `GTCEuStartupEvents.materialIconType` + +### For addons + +**All content should now be registered via either your addon's registrate instance, or via a [deferred register](https://docs.minecraftforge.net/en/1.20.1/concepts/registries/#deferredregister).** + +The `GTCEuAPI.RegisterEvent` event has been removed, as content should now use registrate or deferred registers. + +#### Content registered via registrate. + +The following should be registered via registrate: +- Materials - Use `REGISTRATE.material(String name)` to access the material builder. +- Elements - Use `REGISTRATE.element(...)` to register an element. +- Tag prefixes - Use the following methods: + - `REGISTRATE.tagPrefix(String name)` + - `REGISTRATE.tagPrefix(String name, boolean invertedName)` + - `REGISTRATE.oreTagPrefix(String name, TagKey miningToolTag)` +- Material icon sets - Use the following methods: + - `REGISTRATE.materialIconSet(String id)` + - `REGISTRATE.materialIconSet(String id, MaterialIconSet parent)` + - `REGISTRATE.materialIconSet(String id, @Nullable MaterialIconSet parent, boolean isRoot)` +- Recipe types - Use `REGISTRATE.recipeType(String name, String group, RecipeType... proxyRecipes)` +- Recipe categories - Use `REGISTRATE.recipeCategory(String categoryName, GTRecipeType recipeType)` +- World gen layers - Use `REGISTRATE.simpleWorldGenLayer(...)` +- Medical conditions - Use `REGISTRATE.medicalCondition(...)` + +#### Ore veins, bedrock ores and bedrock fluids + +TODO +~~Ore veins, bedrock ores and bedrock fluids are datapack content. They can be registered in JSON or KubeJS. (Datapack JSON can be generated with datagen, see `com.gregtechceu.gtceu.data.DataGenerators`)~~ + +#### Other content + +All other content should be registered via deferred registers. +Content that can be registered via registrate can also be registered via deferred registers, but registrate is recommended. + +An exmaple of using a deferred register is shown below. +```java +class AddonCovers { + + private static final COVER_REGISTER = DeferredRegister.create(GTRegistries.Keys.COVER, ADDON_MOD_ID); + + public static final RegistryObject CUSTOM_COVER = COVER_REGISTER.create("addon_custom_cover", + () -> new CoverDefinition(ADDON.id("addon_custom_cover"), AddonCustomCover::new)) + + // The init function should be called at some point during your mod's construction (e.g. in your main mod file or mod startup file) + public static void init(IEventBus modBus) { + COVER_REGISTER.register(modBus); + } +} + +``` + ## New Data Save/Sync System A new system for saving and syncing object fields has been added. See [this page](../../Development/Data-Sync-System/Migrating-From-LDLib-SyncData.md) for migration instructions. @@ -156,4 +216,6 @@ As a recipe-matching optimization, input handlers whose `getTotalContentAmount() - Calling the battery buffer constructor with the following args gives the same behaviour as a charger machine: `(info, tier, inventorySize, BatteryBufferMachine.AMPS_PER_BATTERY_CHARGER, 0)` - Refactored Jade provider code. Use the `MachineInfoProvider` class for jade providers for a specific machine type, and `MachineTraitProvider` for providers for a specific machine trait. - `GTUtil.getMoltenFluid(Material)` has been moved to `Material.getHotFluid()`. -- `ICopyable::copyConfig`'s `CompoundTag` argument should now be mutated by reference instead of a new one returned (and thus, the return type has been changed to `void`). \ No newline at end of file +- `ICopyable::copyConfig`'s `CompoundTag` argument should now be mutated by reference instead of a new one returned (and thus, the return type has been changed to `void`). +- World gen layers now store their dimensions as `ResourceKey` rather than `ResourceLocation` +- Dimension markers now store their dimension as a `ResourceKey` rather than `ResourceLocation` \ No newline at end of file diff --git a/docs/content/Modpacks/Examples/Custom-Recipe-Condition.md b/docs/content/Modpacks/Examples/Custom-Recipe-Condition.md index d16c2ee5310..97c8a56cd72 100644 --- a/docs/content/Modpacks/Examples/Custom-Recipe-Condition.md +++ b/docs/content/Modpacks/Examples/Custom-Recipe-Condition.md @@ -15,41 +15,23 @@ They are registered using @Mod(ExampleMod.MOD_ID) public class ExampleMod { - // in 1.20.1 - public static RecipeConditionType EXAMPLE_CONDITION; + private static final DeferredRegister> RECIPE_CONDITION = DeferredRegister + .create(GTRegistries.Keys.RECIPE_CONDITION, ExampleMod.MOD_ID); + + // On 1.21, the registry object has type DeferredHolder, RecipeConditionType> + public static RegistryObject> EXAMPLE_CONDITION = RECIPE_CONDITION.register("example_condition", // (1) + () ->new RecipeConditionType<>(ExampleCondition::new, ExampleCondition.CODEC)); public ExampleMod() { IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); modBus.addGenericListener(RecipeConditionType.class, this::registerConditions); + + // Register the deferred registry to the mod bus, so that the recipe condition is registered during registration. + RECIPE_CONDITION.register(modBus); } - - public void registerConditions(GTCEuAPI.RegisterEvent> event) { - EXAMPLE_CONDITION = GTRegistries.RECIPE_CONDITIONS.register("example_condition", // (1) - new RecipeConditionType<>(ExampleCondition::new, ExampleCondition.CODEC)); - } - // end 1.20.1 - - // in 1.21.1 - public static final RecipeConditionType EXAMPLE_CONDITION = GTRegistries.register(GTRegistries.RECIPE_CONDITIONS, - ResourceLocation.fromNamespaceAndPath(ExampleMod.MOD_ID, "example_condition"), // (2) - new RecipeConditionType<>(ExampleCondition::new, ExampleCondition.CODEC)); - - public ExampleMod(IEventBus modBus, FMLModContainer container) { - modBus.addListener(CommonInit::onRegister); - bus.addListener(RecipeConditionType.class, this::registerConditions); - } - - public void registerConditions(GTCEuAPI.RegisterEvent> event) { - EXAMPLE_CONDITION = GTRegistries.RECIPE_CONDITIONS.register("example_condition", - new RecipeConditionType<>(ExampleCondition::new, ExampleCondition.CODEC)); - } - // end 1.21.1 } ``` -1. The 1.20.1 version doesn't require a namespace, so make sure you don't use the same ID as someone else! -2. You may use a helper method akin to `GTCEu.id` for creating the ResourceLocation, but you **must** use your own namespace for it. - We will set up a condition that requires that the power buffer of the machine is above a certain Y level. ```java public class ExampleCondition extends RecipeCondition { diff --git a/docs/content/Modpacks/Examples/Example_Coil_Multiblock.md b/docs/content/Modpacks/Examples/Example_Coil_Multiblock.md index 09fa577b996..5452fee673e 100644 --- a/docs/content/Modpacks/Examples/Example_Coil_Multiblock.md +++ b/docs/content/Modpacks/Examples/Example_Coil_Multiblock.md @@ -13,7 +13,7 @@ Below is an example of a multiblock using the CoilWorkableElectricMultiblockMach // In order to use multiblock logic extending beyond the normal WorkableElectricMultiblockMachine, (This is the multiblock type used by default for kubejs) you need to load a class. Coil multiblocks such as the Electric Blast Furnace, Pyrolyse Oven, and the Cracker use this class. const CoilWorkableElectricMultiblockMachine = Java.loadClass("com.gregtechceu.gtceu.api.machine.multiblock.CoilWorkableElectricMultiblockMachine") - GTCEuStartupEvents.registry('gtceu:machine', event => { + StartupEvents.registry('gtceu:machine', event => { event.create("superheated_pyrolyzing_oven", "multiblock") .machine((holder) => new CoilWorkableElectricMultiblockMachine(holder)) .rotationState(RotationState.NON_Y_AXIS) diff --git a/docs/content/Modpacks/Examples/Example_Steam_Multiblock.md b/docs/content/Modpacks/Examples/Example_Steam_Multiblock.md index 57b06f47885..527cc6d0ad9 100644 --- a/docs/content/Modpacks/Examples/Example_Steam_Multiblock.md +++ b/docs/content/Modpacks/Examples/Example_Steam_Multiblock.md @@ -15,7 +15,7 @@ Steam multiblocks such as the Steam Grinder and Steam Oven use this class. // In order to use multiblock logic extending beyond the default multiblock type for KJS (WorkableElectricMultiblockMachine), you need to load a class. const $SteamMulti = Java.loadClass('com.gregtechceu.gtceu.common.machine.multiblock.steam.SteamParallelMultiblockMachine'); - GTCEuStartupEvents.registry('gtceu:machine', event => { + StartupEvents.registry('gtceu:machine', event => { event.create('large_steam_compressor', 'multiblock') .machine((holder) => new $SteamMulti(holder, 4)) // The number in holder is the max amount of parallel it can use. diff --git a/docs/content/Modpacks/Examples/Example_Turbine.md b/docs/content/Modpacks/Examples/Example_Turbine.md index 4abdeefe1d5..78d775e963d 100644 --- a/docs/content/Modpacks/Examples/Example_Turbine.md +++ b/docs/content/Modpacks/Examples/Example_Turbine.md @@ -13,7 +13,7 @@ Below is an example of a multiblock using the LargeTurbineMachine class for maki // In order to use multiblock logic extending beyond the normal WorkableElectricMultiblockMachine, (This is the multiblock type used by default for kubejs) you need to load a class. LargeTurbineMachines such as the gas, steam, and plasma turbines use this class. const $LargeTurbineMachine = Java.loadClass("com.gregtechceu.gtceu.common.machine.multiblock.generator.LargeTurbineMachine") - GTCEuStartupEvents.registry('gtceu:machine', event => { + StartupEvents.registry('gtceu:machine', event => { event.create('hyper_gas_turbine', 'multiblock') .machine((holder) => new $LargeTurbineMachine(holder, GTValues.LuV)) // The value shows one rotor holder tier above the recommended minimum rotor holder. The tier of rotor holder provides a boost based on the efficiency stat. .rotationState(RotationState.NON_Y_AXIS) diff --git a/docs/content/Modpacks/Examples/Multiblocks/Example_Coil_Multiblock.md b/docs/content/Modpacks/Examples/Multiblocks/Example_Coil_Multiblock.md index 09fa577b996..5452fee673e 100644 --- a/docs/content/Modpacks/Examples/Multiblocks/Example_Coil_Multiblock.md +++ b/docs/content/Modpacks/Examples/Multiblocks/Example_Coil_Multiblock.md @@ -13,7 +13,7 @@ Below is an example of a multiblock using the CoilWorkableElectricMultiblockMach // In order to use multiblock logic extending beyond the normal WorkableElectricMultiblockMachine, (This is the multiblock type used by default for kubejs) you need to load a class. Coil multiblocks such as the Electric Blast Furnace, Pyrolyse Oven, and the Cracker use this class. const CoilWorkableElectricMultiblockMachine = Java.loadClass("com.gregtechceu.gtceu.api.machine.multiblock.CoilWorkableElectricMultiblockMachine") - GTCEuStartupEvents.registry('gtceu:machine', event => { + StartupEvents.registry('gtceu:machine', event => { event.create("superheated_pyrolyzing_oven", "multiblock") .machine((holder) => new CoilWorkableElectricMultiblockMachine(holder)) .rotationState(RotationState.NON_Y_AXIS) diff --git a/docs/content/Modpacks/Examples/Multiblocks/Example_Steam_Multiblock.md b/docs/content/Modpacks/Examples/Multiblocks/Example_Steam_Multiblock.md index 41adf435a64..ecc55ce68a0 100644 --- a/docs/content/Modpacks/Examples/Multiblocks/Example_Steam_Multiblock.md +++ b/docs/content/Modpacks/Examples/Multiblocks/Example_Steam_Multiblock.md @@ -15,7 +15,7 @@ Steam multiblocks such as the Steam Grinder and Steam Oven use this class. // In order to use multiblock logic extending beyond the default multiblock type for KJS (WorkableElectricMultiblockMachine), you need to load a class. const $SteamMulti = Java.loadClass('com.gregtechceu.gtceu.common.machine.multiblock.steam.SteamParallelMultiblockMachine'); - GTCEuStartupEvents.registry('gtceu:machine', event => { + StartupEvents.registry('gtceu:machine', event => { event.create('large_steam_compressor', 'multiblock') .machine((holder) => new $SteamMulti(holder, 4)) // The number in holder is the max amount of parallel it can use. diff --git a/docs/content/Modpacks/Examples/Multiblocks/Example_Turbine.md b/docs/content/Modpacks/Examples/Multiblocks/Example_Turbine.md index 9807ad21a45..3fbcddb7c34 100644 --- a/docs/content/Modpacks/Examples/Multiblocks/Example_Turbine.md +++ b/docs/content/Modpacks/Examples/Multiblocks/Example_Turbine.md @@ -13,7 +13,7 @@ Below is an example of a multiblock using the LargeTurbineMachine class for maki // In order to use multiblock logic extending beyond the normal WorkableElectricMultiblockMachine, (This is the multiblock type used by default for kubejs) you need to load a class. LargeTurbineMachines such as the gas, steam, and plasma turbines use this class. const $LargeTurbineMachine = Java.loadClass("com.gregtechceu.gtceu.common.machine.multiblock.generator.LargeTurbineMachine") - GTCEuStartupEvents.registry('gtceu:machine', event => { + StartupEvents.registry('gtceu:machine', event => { event.create('hyper_gas_turbine', 'multiblock') .machine((holder) => new $LargeTurbineMachine(holder, GTValues.LuV)) // The value shows one rotor holder tier above the recommended minimum rotor holder. The tier of rotor holder provides a boost based on the efficiency stat. .rotationState(RotationState.NON_Y_AXIS) diff --git a/docs/content/Modpacks/Examples/Multiblocks/Greenhouse.md b/docs/content/Modpacks/Examples/Multiblocks/Greenhouse.md index 76bbe0754b2..6ed920ef33c 100644 --- a/docs/content/Modpacks/Examples/Multiblocks/Greenhouse.md +++ b/docs/content/Modpacks/Examples/Multiblocks/Greenhouse.md @@ -10,7 +10,7 @@ title: "Greenhouse" === "JavaScript" ```js title="greenhouse_recipe_type.js" - GTCEuStartupEvents.registry('gtceu:recipe_type', event => { + StartupEvents.registry('gtceu:recipe_type', event => { event.create('greenhouse') .category('drack') .setEUIO('in') @@ -35,7 +35,7 @@ title: "Greenhouse" const $RecipeLogic = Java.loadClass('com.gregtechceu.gtceu.api.machine.trait.RecipeLogic') const $List = Java.loadClass('java.util.List') - GTCEuStartupEvents.registry('gtceu:machine', event => { + StartupEvents.registry('gtceu:machine', event => { event.create('greenhouse', 'multiblock') .rotationState(RotationState.NON_Y_AXIS) .recipeType('greenhouse') diff --git a/docs/content/Modpacks/Examples/Multiblocks/Ore-Processing-Plant.md b/docs/content/Modpacks/Examples/Multiblocks/Ore-Processing-Plant.md index 7db24432958..9c1c030fc85 100644 --- a/docs/content/Modpacks/Examples/Multiblocks/Ore-Processing-Plant.md +++ b/docs/content/Modpacks/Examples/Multiblocks/Ore-Processing-Plant.md @@ -9,7 +9,7 @@ title: "Ore Processing Plant" === "JavaScript" ```js title="ore_processing_plant.js" - GTCEuStartupEvents.registry('gtceu:recipe_type', event => { + StartupEvents.registry('gtceu:recipe_type', event => { event.create('ore_processing_plant') .category('ore_processing_plant') .setEUIO('in') @@ -30,7 +30,7 @@ title: "Ore Processing Plant" ## Multiblock === "JavaScript" ```js title="ore_processing_plant.js" - GTCEuStartupEvents.registry('gtceu:machine', event => { + StartupEvents.registry('gtceu:machine', event => { event.create('ore_processing_plant', 'multiblock') .rotationState(RotationState.NON_Y_AXIS) .recipeType('ore_processing_plant') diff --git a/docs/content/Modpacks/Examples/Parallel-Hatch-Part.md b/docs/content/Modpacks/Examples/Parallel-Hatch-Part.md index 0b4fab16341..b44fb5e82d1 100644 --- a/docs/content/Modpacks/Examples/Parallel-Hatch-Part.md +++ b/docs/content/Modpacks/Examples/Parallel-Hatch-Part.md @@ -12,7 +12,7 @@ const $ParallelHatchPartMachine = Java.loadClass( "com.gregtechceu.gtceu.common.machine.multiblock.part.ParallelHatchPartMachine" ); // (1) -GTCEuStartupEvents.registry("gtceu:machine", (event) => { +StartupEvents.registry("gtceu:machine", (event) => { event .create("parallel_hatch", "custom") // (2) .tiers(GTValues.UHV, GTValues.UIV, GTValues.UEV, GTValues.UXV) // (3) diff --git a/docs/content/Modpacks/Materials-and-Elements/01-Material-Creation.md b/docs/content/Modpacks/Materials-and-Elements/01-Material-Creation.md index 4d33d67bb4b..8c671e2c8b8 100644 --- a/docs/content/Modpacks/Materials-and-Elements/01-Material-Creation.md +++ b/docs/content/Modpacks/Materials-and-Elements/01-Material-Creation.md @@ -64,7 +64,7 @@ You can change the properties of the material by adding any combination of the f === "JavaScript" ```js title="ingot.js" - GTCEuStartupEvents.registry('gtceu:material', event => { + StartupEvents.registry('gtceu:material', event => { event.create('andesite_alloy') .ingot() .components('1x andesite', '1x iron') @@ -76,8 +76,7 @@ You can change the properties of the material by adding any combination of the f ```java title="Ingot.java" public static Material ANDESITE_ALLOY; public static void register() { - ANDESITE_ALLOY = new Material.Builder( - your_mod_id.id("andesite_alloy")) + ANDESITE_ALLOY = REGISTRATE.material("andesite_alloy") .ingot() .components("1x andesite", "1x iron") .color(0xFF0000).secondaryColor(0x840707).iconSet(GTMaterialIconSet.DULL) @@ -90,7 +89,7 @@ You can change the properties of the material by adding any combination of the f === "JavaScript" ```js title="dust.js" - GTCEuStartupEvents.registry('gtceu:material', event => { + StartupEvents.registry('gtceu:material', event => { event.create('mysterious_dust') .dust() // The harvest level and burn time can be specified in the brackets. Example: `.dust(2, 4000)` .color(0x7D2DDB) @@ -101,8 +100,7 @@ You can change the properties of the material by adding any combination of the f ```java title="Dust.java" public static Material MYSTERIOUS_DUST; public static void register() { - MYSTERIOUS_DUST = new Material.Builder( - your_mod_id.id("mysterious_dust")) + MYSTERIOUS_DUST = REGISTRATE.material("mysterious_dust") .dust() // The harvest level and burn time can be specified in the brackets. Example: `.dust(2, 4000)` .color(0x7D2DDB) .buildAndRegister(); @@ -113,7 +111,7 @@ You can change the properties of the material by adding any combination of the f === "JavaScript" ```js title="gem.js" - GTCEuStartupEvents.registry('gtceu:material', event => { + StartupEvents.registry('gtceu:material', event => { event.create('purple_coal') .gem(2, 4000) .element(GTElements.C) @@ -127,8 +125,7 @@ You can change the properties of the material by adding any combination of the f ```java title="Gem.java" public static Material PURPLE_COAL; public static void register() { - PURPLE_COAL = new Material.Builder( - your_mod_id.id("purple_coal")) + PURPLE_COAL = REGISTRATE.material("purple_coal") .gem(2, 4000) .element(GTElements.C) .ore(2, 3) @@ -142,7 +139,7 @@ You can change the properties of the material by adding any combination of the f === "JavaScript" ```js title="fluid.js" // const $FluidBuilder = Java.loadClass('com.gregtechceu.gtceu.api.fluids.FluidBuilder'); Uncomment if you want to use the Fluid Builder. - GTCEuStartupEvents.registry('gtceu:material', event => { + StartupEvents.registry('gtceu:material', event => { event.create('mysterious_ooze') .fluid() // Or .liquid(Int Temperature) .color(0x500bbf) @@ -153,8 +150,7 @@ You can change the properties of the material by adding any combination of the f ```java title="Fluid.java" public static Material MYSTERIOUS_OOZE; public static void register() { - MYSTERIOUS_OOZE = new Material.Builder( - your_mod_id.id("mysterious_ooze")) + MYSTERIOUS_OOZE = REGISTRATE.material("mysterious_ooze") .fluid() // Or .liquid(Int Temperature) .color(0x500bbf) .buildAndRegister(); diff --git a/docs/content/Modpacks/Materials-and-Elements/02-Element-Creation.md b/docs/content/Modpacks/Materials-and-Elements/02-Element-Creation.md index 87c5625099a..311849015e9 100644 --- a/docs/content/Modpacks/Materials-and-Elements/02-Element-Creation.md +++ b/docs/content/Modpacks/Materials-and-Elements/02-Element-Creation.md @@ -10,7 +10,7 @@ title: Element Creation Elements are the base of GT materials. Registering an element WILL NOT add any items. ```js -GTCEuStartupEvents.registry('gtceu:element', event => { +StartupEvents.registry('gtceu:element', event => { event.create('test_element') .protons(27) .neutrons(177) @@ -21,6 +21,15 @@ GTCEuStartupEvents.registry('gtceu:element', event => { }) ``` +=== "Java" +```java title="AddonElements.java" +public static Element TEST_ELEMENT; +public static void register() { + TEST_ELEMENT = REGISTRATE.element("test_element", 27, 177, -1, null, "test", false); +} +``` + + 1. `.create(String name)` -> The element name. 2. `.protons(int protons)` -> Proton Count. Use `-1` if it is an element that will not get a material. 3. `.neutrons(int neutrons)` -> Neutron Count. Use `-1` if it is an element that will not get a material diff --git a/docs/content/Modpacks/Materials-and-Elements/Material-Flags.md b/docs/content/Modpacks/Materials-and-Elements/Material-Flags.md index 86b161a54c5..de3de3ab1d1 100644 --- a/docs/content/Modpacks/Materials-and-Elements/Material-Flags.md +++ b/docs/content/Modpacks/Materials-and-Elements/Material-Flags.md @@ -10,7 +10,7 @@ can influence how the material behaves, as well as which items are generated for === "Javascript" ```js - GTCEuStartupEvents.registry('gtceu:material', event => { + StartupEvents.registry('gtceu:material', event => { event.create('my_material') // ... .flags(GTMaterialFlags.FLAMMABLE) @@ -20,8 +20,7 @@ can influence how the material behaves, as well as which items are generated for ```java public static Material MY_MATERIAL; public static void register() { - MY_MATERIAL = new Material.Builder( - your_mod_id.id('my_material')) + MY_MATERIAL = REGISTRATE.material('my_material') // ... .flags(GTMaterialFlags.FLAMMABLE) .buildAndRegister(); diff --git a/docs/content/Modpacks/Materials-and-Elements/Material-Icon-Sets.md b/docs/content/Modpacks/Materials-and-Elements/Material-Icon-Sets.md index 28177d31255..67a471e8fc3 100644 --- a/docs/content/Modpacks/Materials-and-Elements/Material-Icon-Sets.md +++ b/docs/content/Modpacks/Materials-and-Elements/Material-Icon-Sets.md @@ -43,7 +43,7 @@ The following icon sets are available by default: Custom iconsets can be specified as well, using the `gtceu:matieral_icon_set` event: ```js title="custom_iconsets.js" -GTCEuStartupEvents.registry('gtceu:material_icon_set', event => { +StartupEvents.registry('gtceu:material_icon_set', event => { event.create('starry') .parent('shiny') }) diff --git a/docs/content/Modpacks/Materials-and-Elements/Material-Properties.md b/docs/content/Modpacks/Materials-and-Elements/Material-Properties.md index 793950efaf2..ef7192ea8d9 100644 --- a/docs/content/Modpacks/Materials-and-Elements/Material-Properties.md +++ b/docs/content/Modpacks/Materials-and-Elements/Material-Properties.md @@ -9,7 +9,7 @@ Properties can be applied to a material to decide how they behave. An example of === "Javascript" ```js - GTCEuStartupEvents.registry('gtceu:material', event => { + StartupEvents.registry('gtceu:material', event => { event.create('my_material') // ... .blastTemp(3700, "mid", GTValues.VA[GTValues.EV], 1600) @@ -19,8 +19,7 @@ Properties can be applied to a material to decide how they behave. An example of ```java public static Material MY_MATERIAL; public static void register() { - MY_MATERIAL = new Material.Builder( - your_mod_id.id('my_material')) + MY_MATERIAL = REGISTRATE.material('my_material') // ... .blastTemp(3700, "mid", GTValues.VA[GTValues.EV], 1600) .buildAndRegister(); diff --git a/docs/content/Modpacks/Materials-and-Elements/Modifying-Existing-Materials.md b/docs/content/Modpacks/Materials-and-Elements/Modifying-Existing-Materials.md index 9ca38447118..19af59f240e 100644 --- a/docs/content/Modpacks/Materials-and-Elements/Modifying-Existing-Materials.md +++ b/docs/content/Modpacks/Materials-and-Elements/Modifying-Existing-Materials.md @@ -8,11 +8,11 @@ title: Modifying Existing Materials All periodic table elements are present in GT, but some of them don't have any properties attached. You can also add a BlastProperty for EBF autogenerated recipes. You can also do this for other materials such as Obsidian. Here is how you can add them: ```js title="periodic_table_elements.js" -const $IngotProperty = Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.IngotProperty'); -const $DustProperty = Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.DustProperty'); -const $BlastProperty = Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty'); - -GTCEuStartupEvents.registry('gtceu:material', event => { + const $IngotProperty = Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.IngotProperty'); + const $DustProperty = Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.DustProperty'); + const $BlastProperty = Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty'); + + StartupEvents.registry('gtceu:material', event => { // Ingot GTMaterials.Zirconium.setProperty(PropertyKey.INGOT, new $IngotProperty()); @@ -41,7 +41,7 @@ let addFluid = (mat, key) => { mat.setProperty(PropertyKey.FLUID, prop); } -GTCEuStartupEvents.registry('gtceu:material', event => { +StartupEvents.registry('gtceu:material', event => { addFluid(GTMaterials.Iodine, $FluidStorageKeys.LIQUID); // Can be LIQUID, GAS, PLASMA or MOLTEN addFluid(GTMaterials.Oganesson, $FluidStorageKeys.GAS); }); @@ -50,7 +50,7 @@ GTCEuStartupEvents.registry('gtceu:material', event => { You can even add an ore to existing materials: ```js title="ore_property.js" -GTCEuStartupEvents.registry('gtceu:material', event => { + StartupEvents.materialModification(event => { const $OreProperty = Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.OreProperty'); @@ -71,7 +71,7 @@ GTCEuStartupEvents.registry('gtceu:material', event => { You can also add flags to existing materials: ```js title="flags.js" -GTCEuStartupEvents.registry('gtceu:material', event => { + GTCEuStartupEvents.materialModification(event => { GTMaterials.Lead.addFlags(GTMaterialFlags.GENERATE_GEAR); // This is for materials already in GTCEU GTMaterials.get('custom_material_name').addFlags(GTMaterialFlags.GENERATE_FOIL); // This only works for materials added by GTCEU addons diff --git a/docs/content/Modpacks/Materials-and-Elements/TagPrefixes-and-the-power-of-.setIgnored().md b/docs/content/Modpacks/Materials-and-Elements/TagPrefixes-and-the-power-of-.setIgnored().md index 5438349be25..e795d6735b9 100644 --- a/docs/content/Modpacks/Materials-and-Elements/TagPrefixes-and-the-power-of-.setIgnored().md +++ b/docs/content/Modpacks/Materials-and-Elements/TagPrefixes-and-the-power-of-.setIgnored().md @@ -75,4 +75,4 @@ GTCEuStartupEvents.materialModification(event => { // (1) generate a duplicate iron ingot. The `Material` for which you are adjusting the TagPrefix must be registered in GTCEu Modern's material registry; if this -material is custom, this is done using `GTCEuStartupEvents.registry()`, as depicted in these docs. +material is custom, this is done using `StartupEvents.registry()`, as depicted in these docs. diff --git a/docs/content/Modpacks/Materials-and-Elements/Tool-Creation.md b/docs/content/Modpacks/Materials-and-Elements/Tool-Creation.md index 55bc0cc865f..0079890ba51 100644 --- a/docs/content/Modpacks/Materials-and-Elements/Tool-Creation.md +++ b/docs/content/Modpacks/Materials-and-Elements/Tool-Creation.md @@ -25,7 +25,7 @@ An example of this being used is included below. // When working with tools in kubejs you will need to load these classes at the top of your file. Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey'); Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.ToolProperty'); - GTCEuStartupEvents.registry('gtceu:material', event => { + StartupEvents.registry('gtceu:material', event => { event.create('aluminfrost') .ingot() .color(0xadd8e6).secondaryColor(0xc0c0c0).iconSet(GTMaterialIconSet.DULL) @@ -40,8 +40,8 @@ An example of this being used is included below. === "Java" ```java title="ExampleToolMaterial.java" public static Material ALUMINFROST; - ALUMINFROST = new Material.Builder( - your_mod_id.id("aluminfrost")) + ALUMINFROST = REGISTRATE.material( + "aluminfrost") .color(0xadd8e6).secondaryColor(0xc0c0c0).iconSet(MaterialIconSet.DULL) .toolStats(new ToolProperty(12.0F, 7.0F, 3072, 6, new GTToolType[] { GTToolType.DRILL_LV, GTToolType.MINING_HAMMER })) @@ -69,7 +69,7 @@ The builder has the same arguments as the constructor, and can have chained meth Here is an example of using the builder in a material: === "JavaScript" ```js title="example_tool_material.js" - GTCEuStartupEvents.registry('gtceu:material', event => { + StartupEvents.registry('gtceu:material', event => { event.create('aluminfrost') .ingot() .color(0xadd8e6).secondaryColor(0xc0c0c0).iconSet(GTMaterialIconSet.DULL) @@ -90,8 +90,8 @@ Here is an example of using the builder in a material: === "Java" ```java title="ExampleToolMaterial.java" public static Material ALUMINFROST; - ALUMINFROST = new Material.Builder( - your_mod_id.id("aluminfrost")) + ALUMINFROST = REGISTRATE.material( + "aluminfrost") .ingot() .color(0xadd8e6).secondaryColor(0xc0c0c0).iconSet(MaterialIconSet.DULL) .toolStats(ToolProperty.Builder.of(1.8F, 1.7F, 700, 3) diff --git a/docs/content/Modpacks/Multiblocks/PatternError.md b/docs/content/Modpacks/Multiblocks/PatternError.md index fb06cc541ce..7ec4f7ddc44 100644 --- a/docs/content/Modpacks/Multiblocks/PatternError.md +++ b/docs/content/Modpacks/Multiblocks/PatternError.md @@ -44,13 +44,15 @@ You also need to register your new PatternErrors statically: ```java public class ExampleMod { + + private static final DeferredRegister PATTERN_ERRORS = DeferredRegister + .create(GTRegistries.Keys.PATTERN_ERROR_TYPE, MY_ADDON.modId); + + public static final RegistryObject MY_PATTERN_ERROR = PATTERN_ERRORS.create("my_pattern_error", MyPatternError.TYPE); + public ExampleMod() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - modEventBus.addGenericListener(PatternError.PatternErrorType.class, this::registerPatternErrors); - } - - private void registerPatternErrors(GTCEuAPI.RegisterEvent event) { - event.register(MyPatternError.TYPE.id(), MyPatternError.TYPE); + PATTERN_ERRORS.register(modEventBus); } } ``` diff --git a/docs/content/Modpacks/Ore-Generation/03-Adding-Stone-Types.md b/docs/content/Modpacks/Ore-Generation/03-Adding-Stone-Types.md index f8fd7dd8808..8eb8a641dba 100644 --- a/docs/content/Modpacks/Ore-Generation/03-Adding-Stone-Types.md +++ b/docs/content/Modpacks/Ore-Generation/03-Adding-Stone-Types.md @@ -16,7 +16,7 @@ For example purposes, this guide uses the block "Blockium" (ID: `my_mod:blockium Replace this with the block you want to add ores for. ```js title="startup_scripts/ore_types.js" -GTCEuStartupEvents.registry('gtceu:tag_prefix', event => { +StartupEvents.registry('gtceu:tag_prefix', event => { event.create('blockium', 'ore') // (1) .stateSupplier(() => Block.getBlock('my_mod:blockium').defaultBlockState()) // (2) .baseModelLocation('my_mod:block/blockium') // (3) @@ -67,7 +67,7 @@ In this case you have to specify the actually generated block state in your ore ```js let UtilsJS = Java.loadClass("dev.latvian.mods.kubejs.util.UtilsJS") -GTCEuStartupEvents.registry('gtceu:tag_prefix', event => { +StartupEvents.registry('gtceu:tag_prefix', event => { event.create(type.path, 'ore') .stateSupplier(() => UtilsJS.parseBlockState("my_mod:blockium[some_blockstate_property=true]")) }) diff --git a/docs/content/Modpacks/Ore-Generation/04-Layers-and-Dimensions.md b/docs/content/Modpacks/Ore-Generation/04-Layers-and-Dimensions.md index ae180ccfe08..a662fadaf22 100644 --- a/docs/content/Modpacks/Ore-Generation/04-Layers-and-Dimensions.md +++ b/docs/content/Modpacks/Ore-Generation/04-Layers-and-Dimensions.md @@ -12,7 +12,7 @@ To create ore veins in another dimension (or just at the location of certain blo You may also need to add a custom stone type for your ores. ```js title="startup_scripts/world_gen_layers.js" -GTCEuStartupEvents.registry('gtceu:world_gen_layer', event => { +StartupEvents.registry('gtceu:world_gen_layer', event => { event.create('my_custom_layer') .targets('#minecraft:stone_ore_replaceables', 'minecraft:endstone') // [*] (1) .dimensions('minecraft:overworld', 'minecraft:the_end') // [*] diff --git a/docs/content/Modpacks/Other-Topics/Ambiguous-Methods.md b/docs/content/Modpacks/Other-Topics/Ambiguous-Methods.md index 53dceeb592b..80e99939238 100644 --- a/docs/content/Modpacks/Other-Topics/Ambiguous-Methods.md +++ b/docs/content/Modpacks/Other-Topics/Ambiguous-Methods.md @@ -9,7 +9,7 @@ This happens when there's multiple overloads (e.g. methods with the same name bu For example, when you do: ```js -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { event.create('unboxinator', 'multiblock') .tooltips(Component.literal("I am a multiblock")) // Rest of the multiblock @@ -18,7 +18,7 @@ GTCEuStartupEvents.registry('gtceu:machine', event => { you'd get the error: ``` -Error in 'GTCEuStartupEvents.registry': The choice of Java method com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder.tooltips matching JavaScript argument types (net.minecraft.network.chat.MutableComponent) is ambiguous; candidate methods are: +Error in 'StartupEvents.registry': The choice of Java method com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder.tooltips matching JavaScript argument types (net.minecraft.network.chat.MutableComponent) is ambiguous; candidate methods are: class com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder tooltips(java.util.List) class com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder tooltips(net.minecraft.network.chat.Component[]) ``` @@ -37,7 +37,7 @@ In this case, there's ambiguity between the following 2 java functions: You would want to select one of the two, and this can be done in the following way: ```js -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { event.create('unboxinator', 'multiblock') ["tooltips(java.util.List)"]([Component.literal("I am a multiblock")]) // Rest of the multiblock @@ -45,7 +45,7 @@ GTCEuStartupEvents.registry('gtceu:machine', event => { ``` or ```js -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { event.create('unboxinator', 'multiblock') ["tooltips(net.minecraft.network.chat.Component[])"]([Component.literal("I am a multiblock")]) // Rest of the multiblock @@ -58,7 +58,7 @@ Because of the way javascript indexing works, `.foo` and `["foo"]` are the same This same problem can occur when trying to call a constructor. For example, when you do ```js -GTCEuStartupEvents.registry("gtceu:recipe_type", event => { +StartupEvents.registry("gtceu:recipe_type", event => { event.create("unboxinator") .setProgressBar( new ResourceTexture("kubejs:textures/gui/progress_bar/progress_bar_stone_oreifier.png"), @@ -76,7 +76,7 @@ dev.latvian.mods.rhino.EvaluatorException: The choice of Java constructor com.lo You would want to select one of the two, and this can be done in the following way: ```js -GTCEuStartupEvents.registry("gtceu:recipe_type", event => { +StartupEvents.registry("gtceu:recipe_type", event => { event.create("unboxinator") .setProgressBar( ResourceTexture["(java.lang.String)"]("kubejs:textures/gui/progress_bar/progress_bar_stone_oreifier.png"), @@ -87,7 +87,7 @@ GTCEuStartupEvents.registry("gtceu:recipe_type", event => { ``` or ```js -GTCEuStartupEvents.registry("gtceu:recipe_type", event => { +StartupEvents.registry("gtceu:recipe_type", event => { event.create("unboxinator") .setProgressBar( ResourceTexture["(net.minecraft.resources.ResourceLocation)"](new ResourceLocation("kubejs:textures/gui/progress_bar/progress_bar_stone_oreifier.png")), diff --git a/docs/content/Modpacks/Other-Topics/Custom-Machines.md b/docs/content/Modpacks/Other-Topics/Custom-Machines.md index 5ec698eda4c..43b6cac55fc 100644 --- a/docs/content/Modpacks/Other-Topics/Custom-Machines.md +++ b/docs/content/Modpacks/Other-Topics/Custom-Machines.md @@ -9,7 +9,7 @@ title: Custom Machines ## Creating Custom Steam Machine ```js title="test_steam_machine.js" -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { event.create('test_simple_steam_machine', 'steam', true) // (1) }) ``` @@ -20,7 +20,7 @@ GTCEuStartupEvents.registry('gtceu:machine', event => { ## Creating Custom Electric Machine ```js title="test_electric_machine.js" -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { event.create('test_electric', 'simple', 0, GTValues.LV, GTValues.MV, GTValues.HV) // (1) .rotationState(RotationState.NON_Y_AXIS) .recipeType('test_recipe_type') @@ -36,7 +36,7 @@ GTCEuStartupEvents.registry('gtceu:machine', event => { ## Creating Custom Kinetic Machine ```js title="test_kinetic_machine.js" -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { event.create('test_kinetic', 'kinetic', GTValues.LV, GTValues.MV, GTValues.HV) .rotationState(RotationState.NON_Y_AXIS) .recipeType('test_kinetic_recipe_type') @@ -48,7 +48,7 @@ GTCEuStartupEvents.registry('gtceu:machine', event => { ## Creating Custom Generator ```js title="test_generator.js" -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { event.create('test_generator', 'generator', GTValues.LV, GTValues.MV, GTValues.HV) // (1) .recipeType('test_generator_recipe_type') .tankScalingFunction(tier => tier * 3200) @@ -59,7 +59,7 @@ GTCEuStartupEvents.registry('gtceu:machine', event => { ## Creating Custom Multiblock ```js title="test_multiblock.js" -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { event.create('test_generator', 'multiblock') .tooltips(Component.translatable('your.langfile.entry.here')) // (1) .rotationState(RotationState.NON_Y_AXIS) @@ -94,7 +94,7 @@ GTCEuStartupEvents.registry('gtceu:machine', event => { Shape Info is used to manually define how your multiblock appears in the JEI/REI/EMI multiblock preview tab. ```js title="shape_info_test.js" -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { event.create('test_generator', 'multiblock') .rotationState(RotationState.NON_Y_AXIS) .appearanceBlock(GTBlocks.CASING_STEEL_SOLID) diff --git a/docs/content/Modpacks/Other-Topics/Custom-Recipe-Types.md b/docs/content/Modpacks/Other-Topics/Custom-Recipe-Types.md index 4b3694f33e5..cbd94d34067 100644 --- a/docs/content/Modpacks/Other-Topics/Custom-Recipe-Types.md +++ b/docs/content/Modpacks/Other-Topics/Custom-Recipe-Types.md @@ -8,7 +8,7 @@ title: Custom Recipe Type !!! important "Recipe Types MUST be registered before the machines or multiblocks" ```js title="test_recipe_type.js" -GTCEuStartupEvents.registry('gtceu:recipe_type', event => { +StartupEvents.registry('gtceu:recipe_type', event => { event.create('test_recipe_type') .category('test') .setEUIO('in') diff --git a/docs/content/Modpacks/Other-Topics/Dimension-Icons.md b/docs/content/Modpacks/Other-Topics/Dimension-Icons.md index 439f59f2041..015b2100722 100644 --- a/docs/content/Modpacks/Other-Topics/Dimension-Icons.md +++ b/docs/content/Modpacks/Other-Topics/Dimension-Icons.md @@ -37,7 +37,7 @@ private void registerDimensionMarkers(GTCEuAPI.RegisterEvent { +StartupEvents.registry("gtceu:dimension_marker", event => { // Edit existing dimension icon, const DimensionMarker = Java.loadClass('com.gregtechceu.gtceu.api.data.DimensionMarker') diff --git a/docs/content/Modpacks/Other-Topics/Modifying-Multiblock-Controller-UI.md b/docs/content/Modpacks/Other-Topics/Modifying-Multiblock-Controller-UI.md index 62bf4e06fa4..31cb774640e 100644 --- a/docs/content/Modpacks/Other-Topics/Modifying-Multiblock-Controller-UI.md +++ b/docs/content/Modpacks/Other-Topics/Modifying-Multiblock-Controller-UI.md @@ -9,7 +9,7 @@ To add text component to the UI, you need to use `.additionalDisplay` in the mul An example of using it would be: ```js title="ui_modified_multiblock.js" -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { event.create('ui_modified_multiblock', 'multiblock') .rotationState(RotationState.NON_Y_AXIS) .recipeType('electrolyzer') diff --git a/docs/content/Modpacks/Recipes/Custom-Recipe-Modifiers.md b/docs/content/Modpacks/Recipes/Custom-Recipe-Modifiers.md index 27d77db8610..d80bc9f5a4f 100644 --- a/docs/content/Modpacks/Recipes/Custom-Recipe-Modifiers.md +++ b/docs/content/Modpacks/Recipes/Custom-Recipe-Modifiers.md @@ -38,7 +38,7 @@ function TemperatureModifier(machine, recipe) { ```js title="example_temperature_multiblock.js" const $CoilWorkableElectricMultiblockMachine = Java.loadClass("com.gregtechceu.gtceu.api.machine.multiblock.CoilWorkableElectricMultiblockMachine"); -GTCEuStartupEvents.registry('gtceu:recipe_type', event => { +StartupEvents.registry('gtceu:recipe_type', event => { event.create('example_smelting') .category('multiblock') .setMaxIOSize(1, 1, 0, 0) @@ -46,7 +46,7 @@ GTCEuStartupEvents.registry('gtceu:recipe_type', event => { .setSound(GTSoundEntries.BATH); }); -GTCEuStartupEvents.registry('gtceu:machine', event => { +StartupEvents.registry('gtceu:machine', event => { GTRecipeTypes.get("example_smelting").addDataInfo((data) => ( `Temperature: ${data.getInt("RequiredTemp")}K` // (4) diff --git a/spotless/spotless.eclipseformat.xml b/spotless/spotless.eclipseformat.xml index 8db01de4299..82f70ea4e37 100644 --- a/spotless/spotless.eclipseformat.xml +++ b/spotless/spotless.eclipseformat.xml @@ -26,7 +26,7 @@ - + @@ -220,7 +220,7 @@ - + diff --git a/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java b/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java index e203cd914d2..8abddf4e149 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java +++ b/src/main/java/com/gregtechceu/gtceu/api/GTCEuAPI.java @@ -51,31 +51,17 @@ public static void initializeHighTier() { else GTCEu.LOGGER.info("High-Tier is Disabled."); } - public static class RegisterEvent extends GenericEvent implements IModBusEvent { + public static class RegisterEvent extends GenericEvent implements IModBusEvent { - private final GTRegistry registry; + private final GTRegistry registry; - public RegisterEvent(GTRegistry registry, Class clazz) { + public RegisterEvent(GTRegistry registry, Class clazz) { super(clazz); this.registry = registry; } - public void register(K key, V value) { + public void register(ResourceLocation key, V value) { if (registry != null) registry.register(key, value); } - - public static class RL extends RegisterEvent { - - public RL(GTRegistry registry, Class clazz) { - super(registry, clazz); - } - } - - public static class String extends RegisterEvent { - - public String(GTRegistry registry, Class clazz) { - super(registry, clazz); - } - } } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java b/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java index 71f1c2699bb..6acaa29b518 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java +++ b/src/main/java/com/gregtechceu/gtceu/api/addon/IGTAddon.java @@ -32,48 +32,6 @@ public interface IGTAddon { */ String addonModId(); - /** - * Call init on your custom TagPrefix class(es) here - * - * @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent} register event instead - */ - @Deprecated(forRemoval = true, since = "8.0.0") - default void registerTagPrefixes() {} - - /** - * Call init on your custom Element class(es) here - * - * @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent} register event instead - */ - @Deprecated(forRemoval = true, since = "8.0.0") - default void registerElements() {} - - /** - * Call init on your custom Sound class(es) here - * - * @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent} register event instead - */ - @Deprecated(forRemoval = true, since = "8.0.0") - default void registerSounds() {} - - /** - * Call init on your custom Cover class(es) here - * - * @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent} register event - * instead - */ - @Deprecated(forRemoval = true, since = "8.0.0") - default void registerCovers() {} - - /** - * Call init on your custom Recipe Capabilities here - * - * @deprecated Subscribe to the {@code GTCEuAPI.RegisterEvent} register event - * instead - */ - @Deprecated(forRemoval = true, since = "8.0.0") - default void registerRecipeCapabilities() {} - /** * Call init on your custom IWorldGenLayer class(es) here * diff --git a/src/main/java/com/gregtechceu/gtceu/api/blockentity/PipeBlockEntity.java b/src/main/java/com/gregtechceu/gtceu/api/blockentity/PipeBlockEntity.java index ee4cbe86a61..5294efc528e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/blockentity/PipeBlockEntity.java +++ b/src/main/java/com/gregtechceu/gtceu/api/blockentity/PipeBlockEntity.java @@ -327,7 +327,7 @@ public UITexture getPipeTexture(boolean isBlock) { @Override public @Nullable UITexture sideTips(Player player, BlockPos pos, BlockState state, Set toolTypes, - Direction side) { + ItemStack held, Direction side) { if (toolTypes.contains(getPipeTuneTool())) { if (player.isShiftKeyDown() && this.canHaveBlockedFaces()) { return getPipeTexture(isBlocked(side)); @@ -337,7 +337,7 @@ public UITexture getPipeTexture(boolean isBlock) { } var cover = coverContainer.getCoverAtSide(side); if (cover != null) { - return cover.sideTips(player, pos, state, toolTypes, side); + return cover.sideTips(player, pos, state, toolTypes, held, side); } return null; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/RecipeCapability.java b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/RecipeCapability.java index 847aa27650e..70408c7d084 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/RecipeCapability.java +++ b/src/main/java/com/gregtechceu/gtceu/api/capability/recipe/RecipeCapability.java @@ -31,7 +31,7 @@ */ public abstract class RecipeCapability { - public static final Codec> DIRECT_CODEC = GTRegistries.RECIPE_CAPABILITIES.codec(); + public static final Codec> DIRECT_CODEC = GTRegistries.RECIPE_CAPABILITIES.byNameCodec(); public static final Codec, List>> CODEC = new DispatchedMapCodec<>( RecipeCapability.DIRECT_CODEC, RecipeCapability::contentCodec); diff --git a/src/main/java/com/gregtechceu/gtceu/api/cover/CoverBehavior.java b/src/main/java/com/gregtechceu/gtceu/api/cover/CoverBehavior.java index 9cbdf8e3cd0..2ab8efef8fb 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/cover/CoverBehavior.java +++ b/src/main/java/com/gregtechceu/gtceu/api/cover/CoverBehavior.java @@ -190,7 +190,7 @@ public boolean shouldRenderGrid(Player player, BlockPos pos, BlockState state, I @Override public @Nullable UITexture sideTips(Player player, BlockPos pos, BlockState state, Set toolTypes, - Direction side) { + ItemStack held, Direction side) { if (toolTypes.contains(GTToolType.CROWBAR)) { return GTGuiTextures.TOOL_REMOVE_COVER; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/cover/CoverDefinition.java b/src/main/java/com/gregtechceu/gtceu/api/cover/CoverDefinition.java index 4e7a847ddd2..7dc5c1c8b49 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/cover/CoverDefinition.java +++ b/src/main/java/com/gregtechceu/gtceu/api/cover/CoverDefinition.java @@ -3,6 +3,7 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.capability.ICoverable; import com.gregtechceu.gtceu.client.renderer.cover.ICoverRenderer; +import com.gregtechceu.gtceu.client.renderer.cover.SimpleCoverRenderer; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; @@ -30,6 +31,10 @@ public interface TieredCoverBehaviourProvider { @Getter private final @Nullable Supplier coverRenderer; + public CoverDefinition(ResourceLocation id, CoverBehaviourProvider behaviorCreator) { + this(id, behaviorCreator, () -> () -> new SimpleCoverRenderer(id.withPath("block/cover/" + id.getPath()))); + } + public CoverDefinition(ResourceLocation id, CoverBehaviourProvider behaviorCreator, Supplier> coverRenderer) { this.behaviorCreator = behaviorCreator; diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/DimensionMarker.java b/src/main/java/com/gregtechceu/gtceu/api/data/DimensionMarker.java index cc8fdc2eefc..6962b4a1e99 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/DimensionMarker.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/DimensionMarker.java @@ -1,23 +1,19 @@ package com.gregtechceu.gtceu.api.data; -import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; -import com.gregtechceu.gtceu.integration.kjs.Validator; import com.gregtechceu.gtceu.utils.memoization.GTMemoizer; import com.gregtechceu.gtceu.utils.memoization.MemoizedSupplier; import net.minecraft.core.Holder; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; 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.Level; import net.minecraftforge.registries.ForgeRegistries; -import dev.latvian.mods.rhino.util.HideFromJS; import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; import org.jetbrains.annotations.Nullable; import java.util.function.Supplier; @@ -26,6 +22,9 @@ public class DimensionMarker { public static final int MAX_TIER = 99; + @Getter + public final ResourceKey dimension; + @Getter public final int tier; // not only used to represent dimension tier, but also for sorting @@ -35,7 +34,11 @@ public class DimensionMarker { private final MemoizedSupplier iconSupplier; - public DimensionMarker(int tier, ResourceLocation itemKey, @Nullable String overrideName) { + public DimensionMarker(ResourceKey dim, int tier, ResourceLocation itemKey, @Nullable String overrideName) { + if (tier < 0 || tier >= MAX_TIER) { + throw new IllegalArgumentException("Tier must be between 0 and " + (MAX_TIER - 1)); + } + this.dimension = dim; this.tier = tier; this.overrideName = overrideName; this.iconSupplier = GTMemoizer.memoize(() -> ForgeRegistries.ITEMS.getDelegate(itemKey) @@ -44,7 +47,12 @@ public DimensionMarker(int tier, ResourceLocation itemKey, @Nullable String over .orElse(ItemStack.EMPTY)); } - public DimensionMarker(int tier, Supplier supplier, @Nullable String overrideName) { + public DimensionMarker(ResourceKey dim, int tier, Supplier supplier, + @Nullable String overrideName) { + if (tier < 0 || tier >= MAX_TIER) { + throw new IllegalArgumentException("Tier must be between 0 and " + (MAX_TIER - 1)); + } + this.dimension = dim; this.tier = tier; this.overrideName = overrideName; this.iconSupplier = GTMemoizer.memoize(() -> getStack(supplier.get().asItem())); @@ -54,13 +62,6 @@ public ItemStack getIcon() { return iconSupplier.get(); } - public void register(ResourceLocation dimKey) { - if (tier < 0 || tier >= MAX_TIER) { - throw new IllegalArgumentException("Tier must be between 0 and " + (MAX_TIER - 1)); - } - GTRegistries.DIMENSION_MARKERS.register(dimKey, this); - } - private ItemStack getStack(Item item) { ItemStack stack = new ItemStack(item); if (overrideName != null) { @@ -68,38 +69,4 @@ private ItemStack getStack(Item item) { } return stack; } - - @Setter - @Accessors(fluent = true, chain = true) - public static class Builder extends BuilderBase { - - private Supplier iconSupplier; - private int tier = 0; - @Nullable - private String overrideName; - - public Builder(ResourceLocation dimKey) { - super(dimKey); - } - - public Builder(ResourceLocation dimKey, Object... args) { - this(dimKey); - } - - @HideFromJS - public DimensionMarker buildAndRegister() { - Validator.validate( - id, - Validator.errorIfNull(iconSupplier, "icon"), - Validator.errorIfOutOfRange(tier, "tier", 0, MAX_TIER - 1)); - DimensionMarker marker = new DimensionMarker(tier, iconSupplier, overrideName); - marker.register(id); - return marker; - } - - @Override - public DimensionMarker register() { - return value = buildAndRegister(); - } - } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/ChemicalHelper.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/ChemicalHelper.java index 1a347c1b08a..b0c559676f5 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/ChemicalHelper.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/ChemicalHelper.java @@ -208,7 +208,7 @@ public static MaterialEntry getMaterialEntry(TagKey tag) { // If the map is empty, resolve all possible tags to their values in an attempt to save time on later // lookups. Set> allItemTags = BuiltInRegistries.ITEM.getTagNames().collect(Collectors.toSet()); - for (TagPrefix prefix : TagPrefix.values()) { + for (TagPrefix prefix : GTRegistries.TAG_PREFIXES) { for (Material material : GTRegistries.MATERIALS) { prefix.getItemTags(material).stream() .filter(allItemTags::contains) diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/Element.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/Element.java index 0a8e1c249de..7106f6f2ef3 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/Element.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/Element.java @@ -3,6 +3,7 @@ import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; +import org.jetbrains.annotations.ApiStatus; /** * This is some kind of Periodic Table, which can be used to determine "Properties" of the Materials. diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/ItemMaterialData.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/ItemMaterialData.java index 158d73a200c..8dfde0b0b80 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/ItemMaterialData.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/ItemMaterialData.java @@ -4,6 +4,7 @@ import com.gregtechceu.gtceu.api.data.chemical.material.stack.MaterialEntry; import com.gregtechceu.gtceu.api.data.chemical.material.stack.MaterialStack; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTMaterialItems; import com.gregtechceu.gtceu.data.recipe.misc.RecyclingRecipes; import com.gregtechceu.gtceu.data.recipe.misc.StoneMachineRecipes; @@ -162,7 +163,7 @@ public static void reinitializeMaterialData() { // Load new data TagsHandler.initExtraUnificationEntries(); - for (TagPrefix prefix : TagPrefix.values()) { + for (TagPrefix prefix : GTRegistries.TAG_PREFIXES) { prefix.getIgnored().forEach((mat, items) -> registerMaterialEntries(items, prefix, mat)); } GTMaterialItems.toUnify diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/MarkerMaterial.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/MarkerMaterial.java index 1c3b773d05f..33a91fa378b 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/MarkerMaterial.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/MarkerMaterial.java @@ -1,5 +1,7 @@ package com.gregtechceu.gtceu.api.data.chemical.material; +import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate; + import net.minecraft.resources.ResourceLocation; /** @@ -21,7 +23,7 @@ public MarkerMaterial(ResourceLocation resourceLocation) { } @Override - protected void registerMaterial() {} + protected void registerMaterial(GTRegistrate registrate) {} @Override public void verifyMaterial() {} diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java index c7c16644185..0ae1f720ff9 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java @@ -16,7 +16,7 @@ import com.gregtechceu.gtceu.api.fluids.store.FluidStorageKeys; import com.gregtechceu.gtceu.api.item.tool.MaterialToolTier; import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; +import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate; import com.gregtechceu.gtceu.common.data.GTMaterials; import com.gregtechceu.gtceu.common.data.GTMedicalConditions; import com.gregtechceu.gtceu.integration.kjs.helpers.MaterialStackWrapper; @@ -34,8 +34,6 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; -import dev.latvian.mods.rhino.util.HideFromJS; -import dev.latvian.mods.rhino.util.RemapPrefixForJS; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import lombok.Getter; @@ -149,8 +147,8 @@ protected Material(ResourceLocation resourceLocation) { flags = new MaterialFlags(); } - protected void registerMaterial() { - GTRegistries.MATERIALS.register(getResourceLocation(), this); + protected void registerMaterial(GTRegistrate registrate) { + registrate.generic(getResourceLocation().getPath(), GTRegistries.Keys.MATERIAL, () -> this).build(); } public String getName() { @@ -176,8 +174,8 @@ public boolean shouldGenerateRecipesFor(@NotNull TagPrefix prefix) { } public void addFlags(MaterialFlag... flags) { - if (!GTRegistries.MATERIALS.canModifyMaterials()) - throw new IllegalStateException("Cannot add flag to material when registry is frozen!"); + // if (!GTRegistries.MATERIALS.canModifyMaterials()) + // throw new IllegalStateException("Cannot add flag to material when registry is frozen!"); this.flags.addFlags(flags).verify(this); } @@ -546,9 +544,9 @@ public void removeProperty(PropertyKey key) { } public void setProperty(PropertyKey key, IMaterialProperty property) { - if (!GTRegistries.MATERIALS.canModifyMaterials()) { - throw new IllegalStateException("Cannot add properties to a Material when registry is frozen!"); - } + // if (!GTRegistries.MATERIALS.canModifyMaterials()) { + // throw new IllegalStateException("Cannot add properties to a Material when registry is frozen!"); + // } properties.setProperty(key, property); properties.verify(); } @@ -572,10 +570,10 @@ public boolean isNull() { return this == GTMaterials.NULL; } - @RemapPrefixForJS("kjs$") @SuppressWarnings("unused") // API, need to treat all of these as used - public static class Builder extends BuilderBase { + public static class Builder { + private final @Nullable GTRegistrate registrate; private final MaterialInfo materialInfo; private final MaterialProperties properties; private final MaterialFlags flags; @@ -608,8 +606,8 @@ public static class Builder extends BuilderBase { * "material." for the Translation Key. * @since GTCEu 2.0.0 */ - public Builder(ResourceLocation resourceLocation) { - super(resourceLocation); + public Builder(@Nullable GTRegistrate registrate, ResourceLocation resourceLocation) { + this.registrate = registrate; String name = resourceLocation.getPath(); if (name.charAt(name.length() - 1) == '_') throw new IllegalArgumentException("Material name cannot end with a '_'!"); @@ -1220,18 +1218,11 @@ public Builder componentStacks(ImmutableList components) { return this; } - /** @see #componentStacks(MaterialStack...) */ public Builder kjs$components(MaterialStackWrapper... components) { compositionSupplier = Arrays.asList(components); return this; } - /** @see #componentStacks(ImmutableList) componentStacks(ImmutableList<MaterialStack>) */ - public Builder kjs$components(ImmutableList components) { - compositionSupplier = components; - return this; - } - /** * Add {@link MaterialFlags} to this Material.
* Dependent Flags (for example, {@link MaterialFlags#GENERATE_LONG_ROD} requiring @@ -1851,8 +1842,9 @@ public Builder addDefaultEnchant(Enchantment enchant, int level) { * * @return The finalized Material. */ - @HideFromJS public Material buildAndRegister() { + Objects.requireNonNull(registrate, "Material.Builder should not be called from KJS"); + materialInfo.componentList = composition.isEmpty() && this.compositionSupplier != null ? ImmutableList.copyOf(compositionSupplier.stream().map(MaterialStackWrapper::toMatStack) .toArray(MaterialStack[]::new)) : @@ -1879,17 +1871,15 @@ public Material buildAndRegister() { mat.setFormula(formula, formatFormula); } materialInfo.verifyInfo(properties, averageRGB); - mat.registerMaterial(); + mat.registerMaterial(registrate); if (ignoredTagPrefixes != null) { ignoredTagPrefixes.forEach(p -> p.setIgnored(mat)); } return mat; } - @Override - @HideFromJS public @NotNull Material register() { - return value = buildAndRegister(); + return buildAndRegister(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java index ca3c107f098..e26a263e93f 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconSet.java @@ -1,46 +1,42 @@ package com.gregtechceu.gtceu.api.data.chemical.material.info; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fml.ModLoader; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class MaterialIconSet { +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; - static { - GTRegistries.MATERIAL_ICON_SETS.unfreeze(); - } +public class MaterialIconSet { - public static final MaterialIconSet DULL = new MaterialIconSet(GTCEu.id("dull"), null, true); - public static final MaterialIconSet METALLIC = new MaterialIconSet(GTCEu.id("metallic")); - public static final MaterialIconSet MAGNETIC = new MaterialIconSet(GTCEu.id("magnetic"), METALLIC); - public static final MaterialIconSet SHINY = new MaterialIconSet(GTCEu.id("shiny"), METALLIC); - public static final MaterialIconSet BRIGHT = new MaterialIconSet(GTCEu.id("bright"), SHINY); - public static final MaterialIconSet DIAMOND = new MaterialIconSet(GTCEu.id("diamond"), SHINY); - public static final MaterialIconSet EMERALD = new MaterialIconSet(GTCEu.id("emerald"), DIAMOND); - public static final MaterialIconSet GEM_HORIZONTAL = new MaterialIconSet(GTCEu.id("gem_horizontal"), EMERALD); - public static final MaterialIconSet GEM_VERTICAL = new MaterialIconSet(GTCEu.id("gem_vertical"), EMERALD); - public static final MaterialIconSet RUBY = new MaterialIconSet(GTCEu.id("ruby"), EMERALD); - public static final MaterialIconSet OPAL = new MaterialIconSet(GTCEu.id("opal"), RUBY); - public static final MaterialIconSet GLASS = new MaterialIconSet(GTCEu.id("glass"), RUBY); - public static final MaterialIconSet NETHERSTAR = new MaterialIconSet(GTCEu.id("netherstar"), GLASS); - public static final MaterialIconSet FINE = new MaterialIconSet(GTCEu.id("fine")); - public static final MaterialIconSet SAND = new MaterialIconSet(GTCEu.id("sand"), FINE); - public static final MaterialIconSet WOOD = new MaterialIconSet(GTCEu.id("wood"), FINE); - public static final MaterialIconSet ROUGH = new MaterialIconSet(GTCEu.id("rough"), FINE); - public static final MaterialIconSet FLINT = new MaterialIconSet(GTCEu.id("flint"), ROUGH); - public static final MaterialIconSet LIGNITE = new MaterialIconSet(GTCEu.id("lignite"), ROUGH); - public static final MaterialIconSet QUARTZ = new MaterialIconSet(GTCEu.id("quartz"), ROUGH); - public static final MaterialIconSet CERTUS = new MaterialIconSet(GTCEu.id("certus"), QUARTZ); - public static final MaterialIconSet LAPIS = new MaterialIconSet(GTCEu.id("lapis"), QUARTZ); - public static final MaterialIconSet FLUID = new MaterialIconSet(GTCEu.id("fluid")); - public static final MaterialIconSet RADIOACTIVE = new MaterialIconSet(GTCEu.id("radioactive"), METALLIC); + public static final MaterialIconSet DULL = REGISTRATE.materialIconSet("dull", null, true); + public static final MaterialIconSet METALLIC = REGISTRATE.materialIconSet("metallic"); + public static final MaterialIconSet MAGNETIC = REGISTRATE.materialIconSet("magnetic", METALLIC); + public static final MaterialIconSet SHINY = REGISTRATE.materialIconSet("shiny", METALLIC); + public static final MaterialIconSet BRIGHT = REGISTRATE.materialIconSet("bright", SHINY); + public static final MaterialIconSet DIAMOND = REGISTRATE.materialIconSet("diamond", SHINY); + public static final MaterialIconSet EMERALD = REGISTRATE.materialIconSet("emerald", DIAMOND); + public static final MaterialIconSet GEM_HORIZONTAL = REGISTRATE.materialIconSet("gem_horizontal", EMERALD); + public static final MaterialIconSet GEM_VERTICAL = REGISTRATE.materialIconSet("gem_vertical", EMERALD); + public static final MaterialIconSet RUBY = REGISTRATE.materialIconSet("ruby", EMERALD); + public static final MaterialIconSet OPAL = REGISTRATE.materialIconSet("opal", RUBY); + public static final MaterialIconSet GLASS = REGISTRATE.materialIconSet("glass", RUBY); + public static final MaterialIconSet NETHERSTAR = REGISTRATE.materialIconSet("netherstar", GLASS); + public static final MaterialIconSet FINE = REGISTRATE.materialIconSet("fine"); + public static final MaterialIconSet SAND = REGISTRATE.materialIconSet("sand", FINE); + public static final MaterialIconSet WOOD = REGISTRATE.materialIconSet("wood", FINE); + public static final MaterialIconSet ROUGH = REGISTRATE.materialIconSet("rough", FINE); + public static final MaterialIconSet FLINT = REGISTRATE.materialIconSet("flint", ROUGH); + public static final MaterialIconSet LIGNITE = REGISTRATE.materialIconSet("lignite", ROUGH); + public static final MaterialIconSet QUARTZ = REGISTRATE.materialIconSet("quartz", ROUGH); + public static final MaterialIconSet CERTUS = REGISTRATE.materialIconSet("certus", QUARTZ); + public static final MaterialIconSet LAPIS = REGISTRATE.materialIconSet("lapis", QUARTZ); + public static final MaterialIconSet FLUID = REGISTRATE.materialIconSet("fluid"); + public static final MaterialIconSet RADIOACTIVE = REGISTRATE.materialIconSet("radioactive", METALLIC); // Implementation ----------------------------------------------------------------------------------------------- @@ -55,59 +51,8 @@ public class MaterialIconSet { @Nullable public final MaterialIconSet parentIconset; - /** - * Create a new MaterialIconSet whose parent is {@link MaterialIconSet#DULL} - * - * @deprecated Use {@link MaterialIconSet#MaterialIconSet(ResourceLocation)} instead - * @param name the name of the iconset - */ - @Deprecated(since = "8.0.0") - public MaterialIconSet(@NotNull String name) { - this(name, MaterialIconSet.DULL); - } - - /** - * Create a new MaterialIconSet whose parent is one of your choosing - * - * @deprecated Use {@link MaterialIconSet#MaterialIconSet(ResourceLocation, MaterialIconSet)} instead - * @param name the name of the iconset - * @param parentIconset the parent iconset - */ - @Deprecated(since = "8.0.0") - public MaterialIconSet(@NotNull String name, @NotNull MaterialIconSet parentIconset) { - this(name, parentIconset, false); - } - - /** - * Create a new MaterialIconSet which is a root - * - * @deprecated Use {@link MaterialIconSet#MaterialIconSet(ResourceLocation, MaterialIconSet, boolean)} instead - * @param name the name of the iconset - * @param parentIconset the parent iconset, should be null if this should be a root iconset - * @param isRootIconset true if this should be a root iconset, otherwise false - */ - @Deprecated(since = "8.0.0") - public MaterialIconSet(@NotNull String name, @Nullable MaterialIconSet parentIconset, boolean isRootIconset) { - this(GTCEu.id(name), parentIconset, isRootIconset); - } - - /** - * Create a new MaterialIconSet whose parent is {@link MaterialIconSet#DULL} - * - * @param id the id of the iconset - */ - public MaterialIconSet(@NotNull ResourceLocation id) { - this(id, MaterialIconSet.DULL); - } - - /** - * Create a new MaterialIconSet whose parent is one of your choosing - * - * @param id the id of the iconset - * @param parentIconset the parent iconset - */ - public MaterialIconSet(@NotNull ResourceLocation id, @NotNull MaterialIconSet parentIconset) { - this(id, parentIconset, false); + public MaterialIconSet(@NotNull ResourceLocation id, @Nullable MaterialIconSet parentIconset) { + this(id, parentIconset, parentIconset == null); } /** @@ -127,8 +72,6 @@ public MaterialIconSet(@NotNull ResourceLocation id, @Nullable MaterialIconSet p this.name = id.getPath(); this.isRootIconset = isRootIconset; this.parentIconset = parentIconset; - - GTRegistries.MATERIAL_ICON_SETS.register(this.id, this); } /** @@ -148,11 +91,5 @@ public String toString() { return id.toString(); } - public static void init() { - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.MATERIAL_ICON_SETS, MaterialIconSet.class)); - if (GTCEu.Mods.isKubeJSLoaded()) { - GTRegistryInfo.registerFor(GTRegistries.MATERIAL_ICON_SETS.getRegistryName()); - } - GTRegistries.MATERIAL_ICON_SETS.freeze(); - } + public static void init() {} } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java index 7fc97341078..1cd6fe73dcd 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/info/MaterialIconType.java @@ -2,7 +2,9 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.common.data.models.GTModels; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; +import com.gregtechceu.gtceu.integration.kjs.GTCEuStartupEvents; +import com.gregtechceu.gtceu.integration.kjs.events.CraftingComponentsEventJS; +import com.gregtechceu.gtceu.integration.kjs.events.MaterialIconTypeEventJS; import com.gregtechceu.gtceu.utils.GTUtil; import net.minecraft.client.Minecraft; @@ -130,7 +132,7 @@ public MaterialIconType(String name) { public static void init() { if (GTCEu.Mods.isKubeJSLoaded()) { - GTRegistryInfo.registerFor(GTRegistryInfo.MATERIAL_ICON_TYPE.registryKey); + KJSCallWrapper.materialIconTypes(); } } @@ -310,4 +312,12 @@ public ResourceLocation getItemTexturePath(@NotNull MaterialIconSet materialIcon public @NotNull String toString() { return this.name; } + + private static final class KJSCallWrapper { + + private static void materialIconTypes() { + GTCEuStartupEvents.MATERIAL_ICON_TYPE.post(new MaterialIconTypeEventJS()); + } + } + } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/registry/MaterialRegistry.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/registry/MaterialRegistry.java index 75123443bcf..cd25adac512 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/registry/MaterialRegistry.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/registry/MaterialRegistry.java @@ -2,46 +2,52 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.gregtechceu.gtceu.api.registry.GTRegistry; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTMaterials; +import net.minecraft.core.Holder; +import net.minecraft.core.MappedRegistry; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import com.mojang.serialization.Lifecycle; import lombok.Getter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.UnmodifiableView; +import java.util.HashSet; import java.util.Set; +import java.util.stream.Collectors; -public class MaterialRegistry extends GTRegistry.RL { +public class MaterialRegistry extends MappedRegistry { @Getter - private final Set usedNamespaces = new ObjectOpenHashSet<>(); + private final Set usedNamespaces = new HashSet<>(); private Phase registrationPhase = Phase.PRE; public MaterialRegistry() { - super(GTCEu.id("material")); + super(GTRegistries.Keys.MATERIAL, Lifecycle.stable()); } - public Material get(java.lang.String name) { + public Material get(String name) { ResourceLocation location = ResourceLocation.tryParse(GTCEu.appendIdString(name)); if (location != null) return get(location); return GTMaterials.NULL; } @Override - public T register(@NotNull ResourceLocation key, @NotNull T value) { + public Holder.@NotNull Reference register(ResourceKey key, Material value, + Lifecycle lifecycle) { if (registrationPhase == Phase.CLOSED || registrationPhase == Phase.FROZEN) { GTCEu.LOGGER.error( "Materials cannot be registered in the PostMaterialEvent (or after)! Must be added in the MaterialEvent. Skipping material {}...", key); return null; } - super.register(key, value); - usedNamespaces.add(key.getNamespace()); - return value; + usedNamespaces.add(key.location().getNamespace()); + return super.register(key, value, lifecycle); } /** @@ -57,7 +63,7 @@ public T register(@NotNull ResourceLocation key, @NotNull T public @UnmodifiableView Set values() { if (registrationPhase == Phase.PRE || registrationPhase == Phase.OPEN) throw new IllegalStateException("Cannot retrieve all materials before registration"); - return super.values(); + return this.stream().collect(Collectors.toSet()); } public void closeRegistry() { @@ -65,14 +71,17 @@ public void closeRegistry() { } @Override - public void freeze() { + public Registry freeze() { super.freeze(); + GTCEu.LOGGER.debug("Freezing material registry"); registrationPhase = Phase.FROZEN; + return this; } @Override public void unfreeze() { super.unfreeze(); + GTCEu.LOGGER.debug("Unfreezing material registry"); registrationPhase = Phase.OPEN; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/stack/MaterialEntry.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/stack/MaterialEntry.java index 9b058565024..e5ae3ae83db 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/stack/MaterialEntry.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/stack/MaterialEntry.java @@ -1,8 +1,10 @@ package com.gregtechceu.gtceu.api.data.chemical.material.stack; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTMaterials; import com.google.common.base.Preconditions; @@ -56,7 +58,7 @@ public String toString() { } var tags = tagPrefix.getItemTags(material); if (tags.isEmpty()) { - return tagPrefix.name + "/" + material.getName(); + return tagPrefix.getName() + "/" + material.getName(); } return tags.get(0).location().toString(); } @@ -70,7 +72,7 @@ public String toString() { var values = str.split(":", 2); if (values.length > 1) { - var prefix = TagPrefix.get(values[0]); + var prefix = GTRegistries.TAG_PREFIXES.get(GTCEu.id(values[0])); if (prefix == null) throw new IllegalArgumentException("Invalid TagPrefix: " + values[0]); cached = new MaterialEntry(prefix, GTMaterials.get(values[1])); PARSE_CACHE.put(str, cached); diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/medicalcondition/MedicalCondition.java b/src/main/java/com/gregtechceu/gtceu/api/data/medicalcondition/MedicalCondition.java index 1affb3ba62d..54aa3433ebf 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/medicalcondition/MedicalCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/medicalcondition/MedicalCondition.java @@ -19,6 +19,7 @@ import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import java.util.*; @@ -27,7 +28,7 @@ @Accessors(chain = true) public class MedicalCondition { - public static final Codec CODEC = GTRegistries.MEDICAL_CONDITIONS.codec(); + public static final Codec CODEC = GTRegistries.MEDICAL_CONDITIONS.byNameCodec(); public static final String AFFECTED_SUFFIX = ".affected"; /** @@ -58,6 +59,7 @@ public class MedicalCondition { @NotNull public Consumer recipeModifier = builder -> {}; + @ApiStatus.Internal public MedicalCondition(ResourceLocation id, int color, int maxProgression, IdleProgressionType progressionType, float progressionRate, boolean canBePermanent, Symptom.ConfiguredSymptom... symptoms) { diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java b/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java index 1a31777c85c..ebea07a21e8 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java @@ -1,12 +1,8 @@ package com.gregtechceu.gtceu.api.data.tag; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; -import com.gregtechceu.gtceu.api.addon.AddonFinder; -import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.api.block.MaterialBlock; -import com.gregtechceu.gtceu.api.block.OreBlock; import com.gregtechceu.gtceu.api.data.chemical.material.ItemMaterialData; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags; @@ -17,14 +13,12 @@ import com.gregtechceu.gtceu.api.item.MaterialBlockItem; import com.gregtechceu.gtceu.api.item.TagPrefixItem; import com.gregtechceu.gtceu.api.item.tool.GTToolType; -import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTBlocks; import com.gregtechceu.gtceu.common.data.GTMaterialBlocks; import com.gregtechceu.gtceu.common.data.GTMaterialItems; import com.gregtechceu.gtceu.common.data.GTMaterials; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.recipe.CustomTags; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.integration.recipeviewer.widgets.GTOreByProduct; import com.gregtechceu.gtceu.utils.FormattingUtil; import com.gregtechceu.gtceu.utils.memoization.GTMemoizer; @@ -47,7 +41,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; import net.minecraft.world.level.material.MapColor; -import net.minecraftforge.fml.ModLoader; import com.google.common.base.Preconditions; import com.google.common.collect.Table; @@ -57,6 +50,7 @@ import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; @@ -65,83 +59,66 @@ import java.util.function.*; import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.Conditions.*; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; @SuppressWarnings("unused") @Accessors(chain = true, fluent = true) public class TagPrefix { - static { - GTRegistries.TAG_PREFIXES.unfreeze(); - } - public static final Map ORES = new Object2ObjectLinkedOpenHashMap<>(); - public static void init() { - AddonFinder.getAddons().forEach(IGTAddon::registerTagPrefixes); - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.TAG_PREFIXES, TagPrefix.class)); - if (GTCEu.Mods.isKubeJSLoaded()) { - GTRegistryInfo.registerFor(GTRegistries.TAG_PREFIXES.getRegistryName()); - } - GTRegistries.TAG_PREFIXES.freeze(); - } - - /** - * @deprecated Use {@code GTRegistries.TAG_PREFIXES.get(name)} - */ - @Deprecated(since = "8.0.0") - public static TagPrefix get(String name) { - return GTRegistries.TAG_PREFIXES.get(GTCEu.id(name)); - } + public static void init() {} public boolean isEmpty() { return this == NULL_PREFIX; } - public static final TagPrefix NULL_PREFIX = new TagPrefix(GTCEu.id("null")); + public static final TagPrefix NULL_PREFIX = REGISTRATE.tagPrefix("null"); - public static final TagPrefix ore = oreTagPrefix(GTCEu.id("stone"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix ore = REGISTRATE.oreTagPrefix("stone", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("%s Ore") .registerOre( Blocks.STONE::defaultBlockState, () -> GTMaterials.Stone, BlockBehaviour.Properties.of() .mapColor(MapColor.STONE).requiresCorrectToolForDrops().strength(3.0F, 3.0F), new ResourceLocation("block/stone"), false, false, true); - public static final TagPrefix oreGranite = oreTagPrefix(GTCEu.id("granite"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreGranite = REGISTRATE.oreTagPrefix("granite", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("Granite %s Ore") .registerOre( Blocks.GRANITE::defaultBlockState, () -> GTMaterials.Granite, BlockBehaviour.Properties.of() .mapColor(MapColor.DIRT).requiresCorrectToolForDrops().strength(3.0F, 3.0F), new ResourceLocation("block/granite")); - public static final TagPrefix oreDiorite = oreTagPrefix(GTCEu.id("diorite"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreDiorite = REGISTRATE.oreTagPrefix("diorite", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("Diorite %s Ore") .registerOre( Blocks.DIORITE::defaultBlockState, () -> GTMaterials.Diorite, BlockBehaviour.Properties.of() .mapColor(MapColor.QUARTZ).requiresCorrectToolForDrops().strength(3.0F, 3.0F), new ResourceLocation("block/diorite")); - public static final TagPrefix oreAndesite = oreTagPrefix(GTCEu.id("andesite"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreAndesite = REGISTRATE.oreTagPrefix("andesite", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("Andesite %s Ore") .registerOre( Blocks.ANDESITE::defaultBlockState, () -> GTMaterials.Andesite, BlockBehaviour.Properties.of() .mapColor(MapColor.DIRT).requiresCorrectToolForDrops().strength(3.0F, 3.0F), new ResourceLocation("block/andesite")); - public static final TagPrefix oreRedGranite = oreTagPrefix("red_granite", BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreRedGranite = REGISTRATE + .oreTagPrefix("red_granite", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("Red Granite %s Ore") .registerOre(() -> GTBlocks.RED_GRANITE.getDefaultState(), () -> GTMaterials.GraniteRed, BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_RED).requiresCorrectToolForDrops() .strength(3.0F, 3.0F), GTCEu.id("block/red_granite")); - public static final TagPrefix oreMarble = oreTagPrefix(GTCEu.id("marble"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreMarble = REGISTRATE.oreTagPrefix("marble", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("Marble %s Ore") .registerOre( () -> GTBlocks.MARBLE.getDefaultState(), () -> GTMaterials.Marble, BlockBehaviour.Properties.of() .mapColor(MapColor.QUARTZ).requiresCorrectToolForDrops().strength(3.0F, 3.0F), GTCEu.id("block/marble")); - public static final TagPrefix oreDeepslate = oreTagPrefix(GTCEu.id("deepslate"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreDeepslate = REGISTRATE.oreTagPrefix("deepslate", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("Deepslate %s Ore") .registerOre( Blocks.DEEPSLATE::defaultBlockState, () -> GTMaterials.Deepslate, BlockBehaviour.Properties.of() @@ -149,7 +126,7 @@ public boolean isEmpty() { .sound(SoundType.DEEPSLATE), new ResourceLocation("block/deepslate"), false, false, true); - public static final TagPrefix oreTuff = oreTagPrefix(GTCEu.id("tuff"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreTuff = REGISTRATE.oreTagPrefix("tuff", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("Tuff %s Ore") .registerOre( Blocks.TUFF::defaultBlockState, () -> GTMaterials.Tuff, BlockBehaviour.Properties.of() @@ -157,28 +134,28 @@ public boolean isEmpty() { .sound(SoundType.TUFF), new ResourceLocation("block/tuff")); - public static final TagPrefix oreSand = oreTagPrefix(GTCEu.id("sand"), BlockTags.MINEABLE_WITH_SHOVEL) + public static final TagPrefix oreSand = REGISTRATE.oreTagPrefix("sand", BlockTags.MINEABLE_WITH_SHOVEL) .langValue("Sand %s Ore") .registerOre(Blocks.SAND::defaultBlockState, () -> GTMaterials.SiliconDioxide, BlockBehaviour.Properties.of().mapColor(MapColor.SAND).instrument(NoteBlockInstrument.SNARE) .strength(0.5F).sound(SoundType.SAND), new ResourceLocation("block/sand"), false, true, false); - public static final TagPrefix oreRedSand = oreTagPrefix(GTCEu.id("redSand"), BlockTags.MINEABLE_WITH_SHOVEL) + public static final TagPrefix oreRedSand = REGISTRATE.oreTagPrefix("red_sand", BlockTags.MINEABLE_WITH_SHOVEL) .langValue("Red Sand %s Ore") .registerOre(Blocks.RED_SAND::defaultBlockState, () -> GTMaterials.SiliconDioxide, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_ORANGE).instrument(NoteBlockInstrument.SNARE) .strength(0.5F).sound(SoundType.SAND), new ResourceLocation("block/red_sand"), false, true, false); - public static final TagPrefix oreGravel = oreTagPrefix(GTCEu.id("gravel"), BlockTags.MINEABLE_WITH_SHOVEL) + public static final TagPrefix oreGravel = REGISTRATE.oreTagPrefix("gravel", BlockTags.MINEABLE_WITH_SHOVEL) .langValue("Gravel %s Ore") .registerOre(Blocks.GRAVEL::defaultBlockState, () -> GTMaterials.Flint, BlockBehaviour.Properties.of().mapColor(MapColor.STONE).instrument(NoteBlockInstrument.SNARE) .strength(0.6F).sound(SoundType.GRAVEL), new ResourceLocation("block/gravel"), false, true, false); - public static final TagPrefix oreBasalt = oreTagPrefix(GTCEu.id("basalt"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreBasalt = REGISTRATE.oreTagPrefix("basalt", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("Basalt %s Ore") .registerOre(Blocks.BASALT::defaultBlockState, () -> GTMaterials.Basalt, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLACK) @@ -186,14 +163,14 @@ public boolean isEmpty() { .sound(SoundType.BASALT), new ResourceLocation("block/basalt"), true); - public static final TagPrefix oreNetherrack = oreTagPrefix(GTCEu.id("netherrack"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreNetherrack = REGISTRATE.oreTagPrefix("netherrack", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("Nether %s Ore") .registerOre(Blocks.NETHERRACK::defaultBlockState, () -> GTMaterials.Netherrack, BlockBehaviour.Properties.of().mapColor(MapColor.NETHER).instrument(NoteBlockInstrument.BASEDRUM) .requiresCorrectToolForDrops().strength(3.0F, 3.0F).sound(SoundType.NETHER_ORE), new ResourceLocation("block/netherrack"), true, false, true); - public static final TagPrefix oreBlackstone = oreTagPrefix(GTCEu.id("blackstone"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreBlackstone = REGISTRATE.oreTagPrefix("blackstone", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("Blackstone %s Ore") .registerOre(Blocks.BLACKSTONE::defaultBlockState, () -> GTMaterials.Blackstone, BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLACK) @@ -201,14 +178,14 @@ public boolean isEmpty() { .strength(3.0F, 3.0F), new ResourceLocation("block/blackstone"), true, false, false); - public static final TagPrefix oreEndstone = oreTagPrefix(GTCEu.id("endstone"), BlockTags.MINEABLE_WITH_PICKAXE) + public static final TagPrefix oreEndstone = REGISTRATE.oreTagPrefix("endstone", BlockTags.MINEABLE_WITH_PICKAXE) .langValue("End %s Ore") .registerOre(Blocks.END_STONE::defaultBlockState, () -> GTMaterials.Endstone, BlockBehaviour.Properties.of().mapColor(MapColor.SAND).instrument(NoteBlockInstrument.BASEDRUM) .requiresCorrectToolForDrops().strength(4.5F, 9.0F), new ResourceLocation("block/end_stone"), true, false, true); - public static final TagPrefix rawOre = new TagPrefix(GTCEu.id("raw"), true) + public static final TagPrefix rawOre = REGISTRATE.tagPrefix("raw", true) .idPattern("raw_%s") .defaultTagPath("raw_materials/%s") .unformattedTagPath("raw_materials") @@ -218,7 +195,7 @@ public boolean isEmpty() { .generateItem(true) .generationCondition(hasOreProperty); - public static final TagPrefix rawOreBlock = new TagPrefix(GTCEu.id("rawOreBlock")) + public static final TagPrefix rawOreBlock = REGISTRATE.tagPrefix("raw_ore_block") .idPattern("raw_%s_block") .defaultTagPath("storage_blocks/raw_%s") .unformattedTagPath("storage_blocks") @@ -229,7 +206,7 @@ public boolean isEmpty() { .generateBlock(true) .generationCondition(hasOreProperty); - public static final TagPrefix crushedRefined = new TagPrefix(GTCEu.id("refinedOre")) + public static final TagPrefix crushedRefined = REGISTRATE.tagPrefix("refined_ore") .idPattern("refined_%s_ore") .defaultTagPath("refined_ores/%s") .defaultTagPath("refined_ores") @@ -239,7 +216,7 @@ public boolean isEmpty() { .generateItem(true) .generationCondition(hasOreProperty); - public static final TagPrefix crushedPurified = new TagPrefix(GTCEu.id("purifiedOre")) + public static final TagPrefix crushedPurified = REGISTRATE.tagPrefix("purified_ore") .idPattern("purified_%s_ore") .defaultTagPath("purified_ores/%s") .defaultTagPath("purified_ores") @@ -250,7 +227,7 @@ public boolean isEmpty() { .generateItem(true) .generationCondition(hasOreProperty); - public static final TagPrefix crushed = new TagPrefix(GTCEu.id("crushedOre")) + public static final TagPrefix crushed = REGISTRATE.tagPrefix("crushed_ore") .idPattern("crushed_%s_ore") .defaultTagPath("crushed_ores/%s") .unformattedTagPath("crushed_ores") @@ -262,7 +239,7 @@ public boolean isEmpty() { .tooltip((mat, tooltips) -> tooltips.add(Component.translatable("metaitem.crushed.tooltip.purify"))); // A hot Ingot, which has to be cooled down by a Vacuum Freezer. - public static final TagPrefix ingotHot = new TagPrefix(GTCEu.id("hotIngot")) + public static final TagPrefix ingotHot = REGISTRATE.tagPrefix("hot_ingot") .idPattern("hot_%s_ingot") .defaultTagPath("hot_ingots/%s") .unformattedTagPath("hot_ingots") @@ -275,7 +252,7 @@ public boolean isEmpty() { hasBlastProperty.and(mat -> mat.getProperty(PropertyKey.BLAST).getBlastTemperature() > 1750)); // A regular Ingot. - public static final TagPrefix ingot = new TagPrefix(GTCEu.id("ingot")) + public static final TagPrefix ingot = REGISTRATE.tagPrefix("ingot") .defaultTagPath("ingots/%s") .unformattedTagPath("ingots") .materialAmount(GTValues.M) @@ -286,7 +263,7 @@ public boolean isEmpty() { .generationCondition(hasIngotProperty); // A regular Gem worth one Dust. - public static final TagPrefix gem = new TagPrefix(GTCEu.id("gem")) + public static final TagPrefix gem = REGISTRATE.tagPrefix("gem") .defaultTagPath("gems/%s") .unformattedTagPath("gems") .langValue("%s") @@ -298,7 +275,7 @@ public boolean isEmpty() { .generationCondition(hasGemProperty); // A regular Gem worth one small Dust. - public static final TagPrefix gemChipped = new TagPrefix(GTCEu.id("chippedGem")) + public static final TagPrefix gemChipped = REGISTRATE.tagPrefix("chipped_gem") .idPattern("chipped_%s_gem") .defaultTagPath("chipped_gems/%s") .unformattedTagPath("chipped_gems") @@ -311,7 +288,7 @@ public boolean isEmpty() { .generationCondition(hasGemProperty.and(unused -> ConfigHolder.INSTANCE.recipes.generateLowQualityGems)); // A regular Gem worth two small Dusts. - public static final TagPrefix gemFlawed = new TagPrefix(GTCEu.id("flawedGem")) + public static final TagPrefix gemFlawed = REGISTRATE.tagPrefix("flawed_gem") .idPattern("flawed_%s_gem") .defaultTagPath("flawed_gems/%s") .unformattedTagPath("flawed_gems") @@ -324,7 +301,7 @@ public boolean isEmpty() { .generationCondition(hasGemProperty.and(unused -> ConfigHolder.INSTANCE.recipes.generateLowQualityGems)); // A regular Gem worth two Dusts. - public static final TagPrefix gemFlawless = new TagPrefix(GTCEu.id("flawlessGem")) + public static final TagPrefix gemFlawless = REGISTRATE.tagPrefix("flawless_gem") .idPattern("flawless_%s_gem") .defaultTagPath("flawless_gems/%s") .unformattedTagPath("flawless_gems") @@ -338,7 +315,7 @@ public boolean isEmpty() { .generationCondition(hasGemProperty); // A regular Gem worth four Dusts. - public static final TagPrefix gemExquisite = new TagPrefix(GTCEu.id("exquisiteGem")) + public static final TagPrefix gemExquisite = REGISTRATE.tagPrefix("exquisite_gem") .idPattern("exquisite_%s_gem") .defaultTagPath("exquisite_gems/%s") .unformattedTagPath("exquisite_gems") @@ -352,7 +329,7 @@ public boolean isEmpty() { .generationCondition(hasGemProperty); // 1/4th of a Dust. - public static final TagPrefix dustSmall = new TagPrefix(GTCEu.id("smallDust")) + public static final TagPrefix dustSmall = REGISTRATE.tagPrefix("small_dust") .idPattern("small_%s_dust") .defaultTagPath("small_dusts/%s") .unformattedTagPath("small_dusts") @@ -364,7 +341,7 @@ public boolean isEmpty() { .generationCondition(hasDustProperty); // 1/9th of a Dust. - public static final TagPrefix dustTiny = new TagPrefix(GTCEu.id("tinyDust")) + public static final TagPrefix dustTiny = REGISTRATE.tagPrefix("tiny_dust") .idPattern("tiny_%s_dust") .defaultTagPath("tiny_dusts/%s") .unformattedTagPath("tiny_dusts") @@ -376,7 +353,7 @@ public boolean isEmpty() { .generationCondition(hasDustProperty); // Dust with impurities. 1 Unit of Main Material and 1/9 - 1/4 Unit of secondary Material - public static final TagPrefix dustImpure = new TagPrefix(GTCEu.id("impureDust")) + public static final TagPrefix dustImpure = REGISTRATE.tagPrefix("impure_dust") .idPattern("impure_%s_dust") .defaultTagPath("impure_dusts/%s") .unformattedTagPath("impure_dusts") @@ -389,7 +366,7 @@ public boolean isEmpty() { .tooltip((mat, tooltips) -> tooltips.add(Component.translatable("metaitem.dust.tooltip.purify"))); // Pure Dust worth of one Ingot or Gem. - public static final TagPrefix dustPure = new TagPrefix(GTCEu.id("pureDust")) + public static final TagPrefix dustPure = REGISTRATE.tagPrefix("pure_dust") .idPattern("pure_%s_dust") .defaultTagPath("pure_dusts/%s") .unformattedTagPath("pure_dusts") @@ -401,7 +378,7 @@ public boolean isEmpty() { .generationCondition(hasOreProperty) .tooltip((mat, tooltips) -> tooltips.add(Component.translatable("metaitem.dust.tooltip.purify"))); - public static final TagPrefix dust = new TagPrefix(GTCEu.id("dust")) + public static final TagPrefix dust = REGISTRATE.tagPrefix("dust") .defaultTagPath("dusts/%s") .unformattedTagPath("dusts") .materialAmount(GTValues.M) @@ -412,7 +389,7 @@ public boolean isEmpty() { .generationCondition(hasDustProperty); // A Nugget. - public static final TagPrefix nugget = new TagPrefix(GTCEu.id("nugget")) + public static final TagPrefix nugget = REGISTRATE.tagPrefix("nugget") .defaultTagPath("nuggets/%s") .unformattedTagPath("nuggets") .materialAmount(GTValues.M / 9) @@ -423,7 +400,7 @@ public boolean isEmpty() { .generationCondition(hasIngotProperty); // 9 Plates combined in one Item. - public static final TagPrefix plateDense = new TagPrefix(GTCEu.id("densePlate")) + public static final TagPrefix plateDense = REGISTRATE.tagPrefix("dense_plate") .idPattern("dense_%s_plate") .defaultTagPath("dense_plates/%s") .unformattedTagPath("dense_plates") @@ -437,7 +414,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_DENSE)); // 2 Plates combined in one Item - public static final TagPrefix plateDouble = new TagPrefix(GTCEu.id("doublePlate")) + public static final TagPrefix plateDouble = REGISTRATE.tagPrefix("double_plate") .idPattern("double_%s_plate") .defaultTagPath("double_plates/%s") .unformattedTagPath("double_plates") @@ -452,7 +429,7 @@ public boolean isEmpty() { .and(mat -> mat.hasFlag(MaterialFlags.GENERATE_PLATE) && !mat.hasFlag(MaterialFlags.NO_SMASHING))); // Regular Plate made of one Ingot/Dust. - public static final TagPrefix plate = new TagPrefix(GTCEu.id("plate")) + public static final TagPrefix plate = REGISTRATE.tagPrefix("plate") .defaultTagPath("plates/%s") .unformattedTagPath("plates") .materialAmount(GTValues.M) @@ -463,7 +440,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_PLATE)); // Round made of 1 Nugget - public static final TagPrefix round = new TagPrefix(GTCEu.id("round")) + public static final TagPrefix round = REGISTRATE.tagPrefix("round") .defaultTagPath("rounds/%s") .unformattedTagPath("rounds") .materialAmount(GTValues.M / 9) @@ -474,7 +451,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_ROUND)); // Foil made of 1/4 Ingot/Dust. - public static final TagPrefix foil = new TagPrefix(GTCEu.id("foil")) + public static final TagPrefix foil = REGISTRATE.tagPrefix("foil") .defaultTagPath("foils/%s") .unformattedTagPath("foils") .materialAmount(GTValues.M / 4) @@ -485,7 +462,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_FOIL)); // Stick made of an Ingot. - public static final TagPrefix rodLong = new TagPrefix(GTCEu.id("longRod")) + public static final TagPrefix rodLong = REGISTRATE.tagPrefix("long_rod") .idPattern("long_%s_rod") .defaultTagPath("rods/long/%s") .unformattedTagPath("rods/long") @@ -498,7 +475,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_LONG_ROD)); // Stick made of half an Ingot. - public static final TagPrefix rod = new TagPrefix(GTCEu.id("rod")) + public static final TagPrefix rod = REGISTRATE.tagPrefix("rod") .defaultTagPath("rods/%s") .unformattedTagPath("rods") .langValue("%s Rod") @@ -510,7 +487,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_ROD)); // consisting out of 1/8 Ingot or 1/4 Stick. - public static final TagPrefix bolt = new TagPrefix(GTCEu.id("bolt")) + public static final TagPrefix bolt = REGISTRATE.tagPrefix("bolt") .defaultTagPath("bolts/%s") .unformattedTagPath("bolts") .materialAmount(GTValues.M / 8) @@ -521,7 +498,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_BOLT_SCREW)); // consisting out of 1/9 Ingot. - public static final TagPrefix screw = new TagPrefix(GTCEu.id("screw")) + public static final TagPrefix screw = REGISTRATE.tagPrefix("screw") .defaultTagPath("screws/%s") .unformattedTagPath("screws") .materialAmount(GTValues.M / 9) @@ -532,7 +509,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_BOLT_SCREW)); // consisting out of 1/2 Stick. - public static final TagPrefix ring = new TagPrefix(GTCEu.id("ring")) + public static final TagPrefix ring = REGISTRATE.tagPrefix("ring") .defaultTagPath("rings/%s") .unformattedTagPath("rings") .materialAmount(GTValues.M / 4) @@ -543,7 +520,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_RING)); // consisting out of 1 Fine Wire. - public static final TagPrefix springSmall = new TagPrefix(GTCEu.id("smallSpring")) + public static final TagPrefix springSmall = REGISTRATE.tagPrefix("small_spring") .idPattern("small_%s_spring") .defaultTagPath("small_springs/%s") .unformattedTagPath("small_springs") @@ -557,7 +534,7 @@ public boolean isEmpty() { mat -> mat.hasFlag(MaterialFlags.GENERATE_SPRING_SMALL) && !mat.hasFlag(MaterialFlags.NO_SMASHING)); // consisting out of 2 Sticks. - public static final TagPrefix spring = new TagPrefix(GTCEu.id("spring")) + public static final TagPrefix spring = REGISTRATE.tagPrefix("spring") .defaultTagPath("springs/%s") .unformattedTagPath("springs") .materialAmount(GTValues.M) @@ -569,7 +546,7 @@ public boolean isEmpty() { mat -> mat.hasFlag(MaterialFlags.GENERATE_SPRING) && !mat.hasFlag(MaterialFlags.NO_SMASHING)); // consisting out of 1/8 Ingot or 1/4 Wire. - public static final TagPrefix wireFine = new TagPrefix(GTCEu.id("fineWire")) + public static final TagPrefix wireFine = REGISTRATE.tagPrefix("fine_wire") .idPattern("fine_%s_wire") .defaultTagPath("fine_wires/%s") .unformattedTagPath("fine_wires") @@ -582,7 +559,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_FINE_WIRE)); // consisting out of 4 Plates, 1 Ring and 1 Screw. - public static final TagPrefix rotor = new TagPrefix(GTCEu.id("rotor")) + public static final TagPrefix rotor = REGISTRATE.tagPrefix("rotor") .defaultTagPath("rotors/%s") .unformattedTagPath("rotors") .materialAmount(GTValues.M * 4) @@ -594,7 +571,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_ROTOR)); // Consisting of 1 Plate. - public static final TagPrefix gearSmall = new TagPrefix(GTCEu.id("smallGear")) + public static final TagPrefix gearSmall = REGISTRATE.tagPrefix("small_gear") .idPattern("small_%s_gear") .defaultTagPath("small_gears/%s") .unformattedTagPath("small_gears") @@ -607,7 +584,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_SMALL_GEAR)); // Consisting of 4 Plates. - public static final TagPrefix gear = new TagPrefix(GTCEu.id("gear")) + public static final TagPrefix gear = REGISTRATE.tagPrefix("gear") .defaultTagPath("gears/%s") .unformattedTagPath("gears") .materialAmount(GTValues.M * 4) @@ -619,7 +596,7 @@ public boolean isEmpty() { .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_GEAR)); // 3/4 of a Plate or Gem used to shape a Lens. Normally only used on Transparent Materials. - public static final TagPrefix lens = new TagPrefix(GTCEu.id("lens")) + public static final TagPrefix lens = REGISTRATE.tagPrefix("lens") .defaultTagPath("lenses/%s") .unformattedTagPath("lenses") .materialAmount((GTValues.M * 3) / 4) @@ -629,13 +606,13 @@ public boolean isEmpty() { .generateItem(true) .generationCondition(mat -> mat.hasFlag(MaterialFlags.GENERATE_LENS)); - public static final TagPrefix dye = new TagPrefix(GTCEu.id("dye")) + public static final TagPrefix dye = REGISTRATE.tagPrefix("dye") .defaultTagPath("dyes/%s") .unformattedTagPath("dyes") .materialAmount(-1); // made of 4 Ingots. - public static final TagPrefix toolHeadBuzzSaw = new TagPrefix(GTCEu.id("buzzSawBlade")) + public static final TagPrefix toolHeadBuzzSaw = REGISTRATE.tagPrefix("buzz_saw_blade") .itemTable(() -> GTMaterialItems.MATERIAL_ITEMS) .langValue("%s Buzzsaw Blade") .materialAmount(GTValues.M * 4) @@ -648,7 +625,7 @@ public boolean isEmpty() { .and(mat -> mat.getProperty(PropertyKey.TOOL).hasType(GTToolType.BUZZSAW))); // made of 1 Ingots. - public static final TagPrefix toolHeadScrewdriver = new TagPrefix(GTCEu.id("screwdriverTip")) + public static final TagPrefix toolHeadScrewdriver = REGISTRATE.tagPrefix("screwdriver_tip") .itemTable(() -> GTMaterialItems.MATERIAL_ITEMS) .langValue("%s Screwdriver Tip") .materialAmount(GTValues.M) @@ -661,7 +638,7 @@ public boolean isEmpty() { .and(mat -> mat.getProperty(PropertyKey.TOOL).hasType(GTToolType.SCREWDRIVER_LV))); // made of 4 Ingots. - public static final TagPrefix toolHeadDrill = new TagPrefix(GTCEu.id("drillHead")) + public static final TagPrefix toolHeadDrill = REGISTRATE.tagPrefix("drill_head") .itemTable(() -> GTMaterialItems.MATERIAL_ITEMS) .langValue("%s Drill Head") .materialAmount(GTValues.M * 4) @@ -674,7 +651,7 @@ public boolean isEmpty() { .and(mat -> mat.getProperty(PropertyKey.TOOL).hasType(GTToolType.DRILL_LV))); // made of 2 Ingots. - public static final TagPrefix toolHeadChainsaw = new TagPrefix(GTCEu.id("chainsawHead")) + public static final TagPrefix toolHeadChainsaw = REGISTRATE.tagPrefix("chainsaw_head") .itemTable(() -> GTMaterialItems.MATERIAL_ITEMS) .langValue("%s Chainsaw Head") .materialAmount(GTValues.M * 2) @@ -687,7 +664,7 @@ public boolean isEmpty() { .and(mat -> mat.getProperty(PropertyKey.TOOL).hasType(GTToolType.CHAINSAW_LV))); // made of 4 Ingots. - public static final TagPrefix toolHeadWrench = new TagPrefix(GTCEu.id("wrenchTip")) + public static final TagPrefix toolHeadWrench = REGISTRATE.tagPrefix("wrench_tip") .itemTable(() -> GTMaterialItems.MATERIAL_ITEMS) .langValue("%s Wrench Tip") .materialAmount(GTValues.M * 4) @@ -699,7 +676,7 @@ public boolean isEmpty() { .generationCondition(hasNoCraftingToolProperty.and(mat -> mat.hasFlag(MaterialFlags.GENERATE_PLATE)) .and(mat -> mat.getProperty(PropertyKey.TOOL).hasType(GTToolType.WRENCH_LV))); - public static final TagPrefix toolHeadWireCutter = new TagPrefix(GTCEu.id("wireCutterHead")) + public static final TagPrefix toolHeadWireCutter = REGISTRATE.tagPrefix("wire_cutter_head") .itemTable(() -> GTMaterialItems.MATERIAL_ITEMS) .langValue("%s Wire Cutter Head") .materialAmount(GTValues.M * 4) @@ -712,7 +689,7 @@ public boolean isEmpty() { .and(mat -> mat.getProperty(PropertyKey.TOOL).hasType(GTToolType.WIRE_CUTTER_LV))); // made of 5 Ingots. - public static final TagPrefix turbineBlade = new TagPrefix(GTCEu.id("turbineBlade")) + public static final TagPrefix turbineBlade = REGISTRATE.tagPrefix("turbine_blade") .itemTable(() -> GTMaterialItems.MATERIAL_ITEMS) .langValue("%s Turbine Blade") .materialAmount(GTValues.M * 10) @@ -725,7 +702,7 @@ public boolean isEmpty() { !m.hasProperty(PropertyKey.GEM))); // Storage Block consisting out of 9 Ingots/Gems/Dusts. - public static final TagPrefix block = new TagPrefix(GTCEu.id("block")) + public static final TagPrefix block = REGISTRATE.tagPrefix("block") .defaultTagPath("storage_blocks/%s") .unformattedTagPath("storage_blocks") .langValue("Block of %s") @@ -738,24 +715,24 @@ public boolean isEmpty() { .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix log = new TagPrefix(GTCEu.id("log")) + public static final TagPrefix log = REGISTRATE.tagPrefix("log") .unformattedTagPath("logs", true); - public static final TagPrefix planks = new TagPrefix(GTCEu.id("planks")) + public static final TagPrefix planks = REGISTRATE.tagPrefix("planks") .unformattedTagPath("planks", true); - public static final TagPrefix slab = new TagPrefix(GTCEu.id("slab")) + public static final TagPrefix slab = REGISTRATE.tagPrefix("slab") .unformattedTagPath("slabs", true); - public static final TagPrefix stairs = new TagPrefix(GTCEu.id("stairs")) + public static final TagPrefix stairs = REGISTRATE.tagPrefix("stairs") .unformattedTagPath("stairs", true); - public static final TagPrefix fence = new TagPrefix(GTCEu.id("fence")) + public static final TagPrefix fence = REGISTRATE.tagPrefix("fence") .unformattedTagPath("fences"); - public static final TagPrefix fenceGate = new TagPrefix(GTCEu.id("fenceGate")) + public static final TagPrefix fenceGate = REGISTRATE.tagPrefix("fenceGate") .unformattedTagPath("fence_gates"); - public static final TagPrefix door = new TagPrefix(GTCEu.id("door")) + public static final TagPrefix door = REGISTRATE.tagPrefix("door") .unformattedTagPath("doors", true); // Prefix to determine which kind of Rock this is. // Also has a base tag path of only the material, for things like obsidian etc. - public static final TagPrefix rock = new TagPrefix(GTCEu.id("rock")) + public static final TagPrefix rock = REGISTRATE.tagPrefix("rock") .defaultTagPath("%s") .langValue("%s") .miningToolTag(BlockTags.MINEABLE_WITH_PICKAXE) @@ -763,7 +740,7 @@ public boolean isEmpty() { .generateBlock(true) // generate a block but not really, for TagPrefix#setIgnoredBlock .generationCondition((material) -> false); - public static final TagPrefix frameGt = new TagPrefix(GTCEu.id("frame")) + public static final TagPrefix frameGt = REGISTRATE.tagPrefix("frame") .defaultTagPath("frames/%s") .unformattedTagPath("frames") .langValue("%s Frame") @@ -778,35 +755,35 @@ public boolean isEmpty() { material.hasFlag(MaterialFlags.GENERATE_FRAME)); // Pipes - public static final TagPrefix pipeTinyFluid = new TagPrefix(GTCEu.id("pipeTinyFluid")) + public static final TagPrefix pipeTinyFluid = REGISTRATE.tagPrefix("pipe_tiny_fluid") .itemTable(() -> GTMaterialBlocks.FLUID_PIPE_BLOCKS) .langValue("Tiny %s Fluid Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) .materialAmount(GTValues.M / 2) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeSmallFluid = new TagPrefix(GTCEu.id("pipeSmallFluid")) + public static final TagPrefix pipeSmallFluid = REGISTRATE.tagPrefix("pipe_small_fluid") .itemTable(() -> GTMaterialBlocks.FLUID_PIPE_BLOCKS) .langValue("Small %s Fluid Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) .materialAmount(GTValues.M) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeNormalFluid = new TagPrefix(GTCEu.id("pipeNormalFluid")) + public static final TagPrefix pipeNormalFluid = REGISTRATE.tagPrefix("pipe_normal_fluid") .itemTable(() -> GTMaterialBlocks.FLUID_PIPE_BLOCKS) .langValue("Normal %s Fluid Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) .materialAmount(GTValues.M * 3) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeLargeFluid = new TagPrefix(GTCEu.id("pipeLargeFluid")) + public static final TagPrefix pipeLargeFluid = REGISTRATE.tagPrefix("pipe_large_fluid") .itemTable(() -> GTMaterialBlocks.FLUID_PIPE_BLOCKS) .langValue("Large %s Fluid Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) .materialAmount(GTValues.M * 6) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeHugeFluid = new TagPrefix(GTCEu.id("pipeHugeFluid")) + public static final TagPrefix pipeHugeFluid = REGISTRATE.tagPrefix("pipe_huge_fluid") .itemTable(() -> GTMaterialBlocks.FLUID_PIPE_BLOCKS) .langValue("Huge %s Fluid Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) @@ -814,14 +791,14 @@ public boolean isEmpty() { .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeQuadrupleFluid = new TagPrefix(GTCEu.id("pipeQuadrupleFluid")) + public static final TagPrefix pipeQuadrupleFluid = REGISTRATE.tagPrefix("pipe_quadruple_fluid") .itemTable(() -> GTMaterialBlocks.FLUID_PIPE_BLOCKS) .langValue("Quadruple %s Fluid Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) .materialAmount(GTValues.M * 4) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeNonupleFluid = new TagPrefix(GTCEu.id("pipeNonupleFluid")) + public static final TagPrefix pipeNonupleFluid = REGISTRATE.tagPrefix("pipe_nonuple_fluid") .itemTable(() -> GTMaterialBlocks.FLUID_PIPE_BLOCKS) .langValue("Nonuple %s Fluid Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) @@ -829,28 +806,28 @@ public boolean isEmpty() { .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeSmallItem = new TagPrefix(GTCEu.id("pipeSmallItem")) + public static final TagPrefix pipeSmallItem = REGISTRATE.tagPrefix("pipe_small_item") .itemTable(() -> GTMaterialBlocks.ITEM_PIPE_BLOCKS) .langValue("Small %s Item Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) .materialAmount(GTValues.M) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeNormalItem = new TagPrefix(GTCEu.id("pipeNormalItem")) + public static final TagPrefix pipeNormalItem = REGISTRATE.tagPrefix("pipe_normal_item") .itemTable(() -> GTMaterialBlocks.ITEM_PIPE_BLOCKS) .langValue("Normal %s Item Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) .materialAmount(GTValues.M * 3) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeLargeItem = new TagPrefix(GTCEu.id("pipeLargeItem")) + public static final TagPrefix pipeLargeItem = REGISTRATE.tagPrefix("pipe_large_item") .itemTable(() -> GTMaterialBlocks.ITEM_PIPE_BLOCKS) .langValue("Large %s Item Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) .materialAmount(GTValues.M * 6) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeHugeItem = new TagPrefix(GTCEu.id("pipeHugeItem")) + public static final TagPrefix pipeHugeItem = REGISTRATE.tagPrefix("pipe_huge_item") .itemTable(() -> GTMaterialBlocks.ITEM_PIPE_BLOCKS) .langValue("Huge %s Item Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) @@ -858,31 +835,31 @@ public boolean isEmpty() { .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeSmallRestrictive = new TagPrefix(GTCEu.id("pipeSmallRestrictive")) + public static final TagPrefix pipeSmallRestrictive = REGISTRATE.tagPrefix("pipe_small_restrictive") .itemTable(() -> GTMaterialBlocks.ITEM_PIPE_BLOCKS) .langValue("Small Restrictive %s Item Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH) .materialAmount(GTValues.M) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeNormalRestrictive = new TagPrefix(GTCEu.id("pipeNormalRestrictive")) + public static final TagPrefix pipeNormalRestrictive = REGISTRATE.tagPrefix("pipe_normal_restrictive") .itemTable(() -> GTMaterialBlocks.ITEM_PIPE_BLOCKS).langValue("Normal Restrictive %s Item Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH).materialAmount(GTValues.M * 3) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeLargeRestrictive = new TagPrefix(GTCEu.id("pipeLargeRestrictive")) + public static final TagPrefix pipeLargeRestrictive = REGISTRATE.tagPrefix("pipe_large_restrictive") .itemTable(() -> GTMaterialBlocks.ITEM_PIPE_BLOCKS).langValue("Large Restrictive %s Item Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH).materialAmount(GTValues.M * 6) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix pipeHugeRestrictive = new TagPrefix(GTCEu.id("pipeHugeRestrictive")) + public static final TagPrefix pipeHugeRestrictive = REGISTRATE.tagPrefix("pipe_huge_restrictive") .itemTable(() -> GTMaterialBlocks.ITEM_PIPE_BLOCKS).langValue("Huge Restrictive %s Item Pipe") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WRENCH).materialAmount(GTValues.M * 12) .unificationEnabled(true) .enableRecycling(); // Wires and cables - public static final TagPrefix wireGtHex = new TagPrefix(GTCEu.id("wireGtHex")) + public static final TagPrefix wireGtHex = REGISTRATE.tagPrefix("wire_gt_hex") .itemTable(() -> GTMaterialBlocks.CABLE_BLOCKS) .langValue("16x %s Wire") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WIRE_CUTTER) @@ -890,7 +867,7 @@ public boolean isEmpty() { .materialIconType(MaterialIconType.wire) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix wireGtOctal = new TagPrefix(GTCEu.id("wireGtOctal")) + public static final TagPrefix wireGtOctal = REGISTRATE.tagPrefix("wire_gt_octal") .itemTable(() -> GTMaterialBlocks.CABLE_BLOCKS) .langValue("8x %s Wire") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WIRE_CUTTER) @@ -898,7 +875,7 @@ public boolean isEmpty() { .materialIconType(MaterialIconType.wire) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix wireGtQuadruple = new TagPrefix(GTCEu.id("wireGtQuadruple")) + public static final TagPrefix wireGtQuadruple = REGISTRATE.tagPrefix("wire_gt_quadruple") .itemTable(() -> GTMaterialBlocks.CABLE_BLOCKS) .langValue("4x %s Wire") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WIRE_CUTTER) @@ -906,7 +883,7 @@ public boolean isEmpty() { .materialIconType(MaterialIconType.wire) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix wireGtDouble = new TagPrefix(GTCEu.id("wireGtDouble")) + public static final TagPrefix wireGtDouble = REGISTRATE.tagPrefix("wire_gt_double") .itemTable(() -> GTMaterialBlocks.CABLE_BLOCKS) .langValue("2x %s Wire") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WIRE_CUTTER) @@ -914,7 +891,7 @@ public boolean isEmpty() { .materialIconType(MaterialIconType.wire) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix wireGtSingle = new TagPrefix(GTCEu.id("wireGtSingle")) + public static final TagPrefix wireGtSingle = REGISTRATE.tagPrefix("wire_gt_single") .itemTable(() -> GTMaterialBlocks.CABLE_BLOCKS) .langValue("1x %s Wire") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WIRE_CUTTER) @@ -923,34 +900,34 @@ public boolean isEmpty() { .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix cableGtHex = new TagPrefix(GTCEu.id("cableGtHex")) + public static final TagPrefix cableGtHex = REGISTRATE.tagPrefix("cable_gt_hex") .itemTable(() -> GTMaterialBlocks.CABLE_BLOCKS) .langValue("16x %s Cable") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WIRE_CUTTER) .materialAmount(GTValues.M * 8) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix cableGtOctal = new TagPrefix(GTCEu.id("cableGtOctal")) + public static final TagPrefix cableGtOctal = REGISTRATE.tagPrefix("cable_gt_octal") .itemTable(() -> GTMaterialBlocks.CABLE_BLOCKS) .langValue("8x %s Cable") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WIRE_CUTTER) .materialAmount(GTValues.M * 4) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix cableGtQuadruple = new TagPrefix(GTCEu.id("cableGtQuadruple")) + public static final TagPrefix cableGtQuadruple = REGISTRATE.tagPrefix("cable_gt_quadruple") .itemTable(() -> GTMaterialBlocks.CABLE_BLOCKS).langValue("4x %s Cable") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WIRE_CUTTER) .materialAmount(GTValues.M * 2) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix cableGtDouble = new TagPrefix(GTCEu.id("cableGtDouble")) + public static final TagPrefix cableGtDouble = REGISTRATE.tagPrefix("cable_gt_double") .itemTable(() -> GTMaterialBlocks.CABLE_BLOCKS) .langValue("2x %s Cable") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WIRE_CUTTER) .materialAmount(GTValues.M) .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix cableGtSingle = new TagPrefix(GTCEu.id("cableGtSingle")) + public static final TagPrefix cableGtSingle = REGISTRATE.tagPrefix("cable_gt_Single") .itemTable(() -> GTMaterialBlocks.CABLE_BLOCKS) .langValue("1x %s Cable") .miningToolTag(CustomTags.MINEABLE_WITH_CONFIG_VALID_PICKAXE_WIRE_CUTTER) @@ -958,7 +935,7 @@ public boolean isEmpty() { .unificationEnabled(true) .enableRecycling(); - public static final TagPrefix surfaceRock = new TagPrefix(GTCEu.id("surfaceRock")) + public static final TagPrefix surfaceRock = REGISTRATE.tagPrefix("surface_rock") .langValue("%s Surface Rock") .defaultTagPath("surface_rocks/%s") .unformattedTagPath("surface_rocks") @@ -987,8 +964,6 @@ public record BlockProperties(Supplier> renderType, @Getter public final ResourceLocation id; - @Getter - public final String name; @Getter @Setter private String idPattern; @@ -1058,49 +1033,19 @@ public record BlockProperties(Supplier> renderType, @Getter protected final Set> miningToolTag = new HashSet<>(); - /** - * @deprecated Use {@link TagPrefix#TagPrefix(ResourceLocation)} - */ - @Deprecated(since = "8.0.0") - public TagPrefix(String name) { - this(name, false); - } - - /** - * @deprecated Use {@link TagPrefix#TagPrefix(ResourceLocation, boolean)} - */ - @Deprecated(since = "8.0.0") - public TagPrefix(String name, boolean invertedName) { - this(GTCEu.id(name), invertedName); - } - public TagPrefix(ResourceLocation id) { this(id, false); } public TagPrefix(ResourceLocation id, boolean invertedName) { this.id = id; - this.name = id.getPath(); - this.idPattern = "%s_" + getLowerCaseName(); + this.idPattern = "%s_" + id.getPath(); this.invertedName = invertedName; - this.langValue = "%s " + FormattingUtil.toEnglishName(getLowerCaseName()); - GTRegistries.TAG_PREFIXES.register(id, this); + this.langValue = "%s " + FormattingUtil.toEnglishName(id.getPath()); } - public static TagPrefix oreTagPrefix(String name, TagKey miningToolTag) { - return oreTagPrefix(GTCEu.id(name), miningToolTag); - } - - public static TagPrefix oreTagPrefix(ResourceLocation id, TagKey miningToolTag) { - return new TagPrefix(id) - .defaultTagPath("ores/%s") - .prefixOnlyTagPath("ores_in_ground/%s") - .unformattedTagPath("ores") - .materialIconType(MaterialIconType.ore) - .miningToolTag(miningToolTag) - .unificationEnabled(true) - .blockConstructor(OreBlock::new) - .generationCondition(hasOreProperty); + public String getName() { + return id.getPath(); } public void addSecondaryMaterial(MaterialStack secondaryMaterial) { @@ -1197,22 +1142,6 @@ public long getMaterialAmount(@NotNull Material material) { return (long) (GTValues.M * materialAmounts.getFloat(material)); } - /** - * @deprecated Use {@code GTRegistries.TAG_PREFIXES.get(name)} - */ - @Deprecated(since = "8.0.0") - public static TagPrefix getPrefix(String prefixName) { - return getPrefix(prefixName, null); - } - - /** - * @deprecated Use {@code GTRegistries.TAG_PREFIXES.getOrDefault(prefixName, replacement)} - */ - @Deprecated(since = "8.0.0") - public static TagPrefix getPrefix(String prefixName, @Nullable TagPrefix replacement) { - return GTRegistries.TAG_PREFIXES.getOrDefault(GTCEu.id(prefixName), replacement); - } - public @Unmodifiable List> getItemParentTags() { return tags.stream() .filter(TagType::isParentTag) @@ -1291,12 +1220,8 @@ public MaterialIconType getMaterialIconType(Material material) { return materialIconType; } - public String getLowerCaseName() { - return FormattingUtil.toLowerCaseUnderscore(this.name); - } - public String getUnlocalizedName() { - return "tagprefix." + getLowerCaseName(); + return "tagprefix." + getName(); } public MutableComponent getLocalizedName(Material material) { @@ -1310,7 +1235,7 @@ public String getUnlocalizedName(Material material) { return matSpecificKey; } if (material.hasProperty(PropertyKey.POLYMER)) { - String localizationKey = String.format("tagprefix.polymer.%s", getLowerCaseName()); + String localizationKey = String.format("tagprefix.polymer.%s", getName()); // Not every polymer tag prefix gets a special name if (Language.getInstance().has(localizationKey)) { return localizationKey; @@ -1386,25 +1311,17 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TagPrefix tagPrefix = (TagPrefix) o; - return name.equals(tagPrefix.name); + return id.equals(tagPrefix.id); } @Override public int hashCode() { - return name.hashCode(); - } - - /** - * @deprecated Use {@code GTRegistries.TAG_PREFIXES.values()} - */ - @Deprecated(since = "8.0.0") - public static Collection values() { - return GTRegistries.TAG_PREFIXES.values(); + return id.hashCode(); } @Override public String toString() { - return name; + return id.toString(); } @FunctionalInterface diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagType.java b/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagType.java index e0c01fe8ab0..aafca8111a2 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/tag/TagType.java @@ -41,7 +41,7 @@ public static TagType withDefaultFormatter(String tagPath, boolean isVanilla) { public static TagType withPrefixFormatter(String tagPath) { TagType type = new TagType(tagPath); type.formatter = (prefix, mat) -> TagUtil.createItemTag( - type.tagPath.formatted(prefix.getLowerCaseName(), mat.getName())); + type.tagPath.formatted(prefix.getName(), mat.getName())); return type; } @@ -52,7 +52,7 @@ public static TagType withPrefixFormatter(String tagPath) { public static TagType withPrefixOnlyFormatter(String tagPath) { TagType type = new TagType(tagPath); type.formatter = (prefix, mat) -> TagUtil - .createItemTag(type.tagPath.formatted(prefix.getLowerCaseName())); + .createItemTag(type.tagPath.formatted(prefix.getName())); type.isParentTag = true; return type; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTLayerPattern.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTLayerPattern.java index e2ce393ef5a..da619cdb96d 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTLayerPattern.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTLayerPattern.java @@ -84,7 +84,7 @@ public GTLayerPattern build() { public static class Layer { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codec.list(Codec.either(TargetBlockState.CODEC.listOf(), GTRegistries.MATERIALS.codec())) + Codec.list(Codec.either(TargetBlockState.CODEC.listOf(), GTRegistries.MATERIALS.byNameCodec())) .fieldOf("targets") .forGetter(layer -> layer.targets), Codec.intRange(0, Integer.MAX_VALUE) diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreDefinition.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreDefinition.java index a0b846e7473..fe4d379ada8 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreDefinition.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/GTOreDefinition.java @@ -64,7 +64,7 @@ public class GTOreDefinition { IntProvider.NON_NEGATIVE_CODEC.fieldOf("cluster_size").forGetter(ft -> ft.clusterSize), Codec.floatRange(0.0F, 1.0F).fieldOf("density").forGetter(ft -> ft.density), Codec.INT.fieldOf("weight").forGetter(ft -> ft.weight), - GTRegistries.WORLD_GEN_LAYERS.codec().fieldOf("layer").forGetter(ft -> ft.layer), + GTRegistries.WORLD_GEN_LAYERS.byNameCodec().fieldOf("layer").forGetter(ft -> ft.layer), ResourceKey.codec(Registries.DIMENSION).listOf().fieldOf("dimension_filter") .forGetter(ft -> new ArrayList<>(ft.dimensionFilter)), HeightRangePlacement.CODEC.fieldOf("height_range").forGetter(ft -> ft.range), @@ -182,9 +182,7 @@ public GTOreDefinition weight(int weight) { public GTOreDefinition layer(IWorldGenLayer layer) { this.layer = layer; if (this.dimensionFilter == null || this.dimensionFilter.isEmpty()) { - dimensions(layer.getLevels().stream() - .map(location -> ResourceKey.create(Registries.DIMENSION, location)) - .collect(Collectors.toSet())); + dimensions(new HashSet<>(layer.getLevels())); } return this; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/IWorldGenLayer.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/IWorldGenLayer.java index 8371676d425..7ecc8198a1b 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/IWorldGenLayer.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/IWorldGenLayer.java @@ -1,7 +1,9 @@ package com.gregtechceu.gtceu.api.data.worldgen; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.StringRepresentable; +import net.minecraft.world.level.Level; import net.minecraft.world.level.levelgen.structure.templatesystem.AlwaysTrueTest; import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest; @@ -11,7 +13,7 @@ public interface IWorldGenLayer extends StringRepresentable { boolean isApplicableForLevel(ResourceLocation level); - Set getLevels(); + Set> getLevels(); RuleTest getTarget(); @@ -29,7 +31,7 @@ public boolean isApplicableForLevel(ResourceLocation level) { } @Override - public Set getLevels() { + public Set> getLevels() { return Set.of(); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/SimpleWorldGenLayer.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/SimpleWorldGenLayer.java index 231ea92246f..425045b6a85 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/SimpleWorldGenLayer.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/SimpleWorldGenLayer.java @@ -1,12 +1,14 @@ package com.gregtechceu.gtceu.api.data.worldgen; -import com.gregtechceu.gtceu.api.registry.GTRegistries; - +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest; import com.mojang.serialization.JsonOps; import lombok.Getter; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import java.util.Set; @@ -16,15 +18,14 @@ public class SimpleWorldGenLayer implements IWorldGenLayer { private final ResourceLocation id; private final IWorldGenLayer.RuleTestSupplier target; @Getter - private final Set levels; + private final Set> levels; + @ApiStatus.Internal public SimpleWorldGenLayer(ResourceLocation id, IWorldGenLayer.RuleTestSupplier target, - Set levels) { + Set> levels) { this.id = id; this.target = target; this.levels = levels; - - GTRegistries.WORLD_GEN_LAYERS.register(id, this); } @Override @@ -58,6 +59,6 @@ public RuleTest getTarget() { @Override public boolean isApplicableForLevel(ResourceLocation level) { - return levels.contains(level); + return levels.contains(ResourceKey.create(Registries.DIMENSION, level)); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java index e9221af82c3..e9909429843 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/WorldGenLayers.java @@ -1,46 +1,29 @@ package com.gregtechceu.gtceu.api.data.worldgen; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; -import com.gregtechceu.gtceu.api.addon.AddonFinder; -import com.gregtechceu.gtceu.api.addon.IGTAddon; -import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; - import net.minecraft.tags.BlockTags; import net.minecraft.world.level.Level; import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest; -import net.minecraftforge.fml.ModLoader; import java.util.Set; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; + public class WorldGenLayers { - static { - GTRegistries.WORLD_GEN_LAYERS.unfreeze(); - } - - public static final SimpleWorldGenLayer STONE = new SimpleWorldGenLayer( - GTCEu.id("stone"), () -> new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES), - Set.of(Level.OVERWORLD.location())); - - public static final SimpleWorldGenLayer DEEPSLATE = new SimpleWorldGenLayer( - GTCEu.id("deepslate"), () -> new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES), - Set.of(Level.OVERWORLD.location())); - - public static final SimpleWorldGenLayer NETHERRACK = new SimpleWorldGenLayer( - GTCEu.id("netherrack"), () -> new TagMatchTest(BlockTags.NETHER_CARVER_REPLACEABLES), - Set.of(Level.NETHER.location())); - public static final SimpleWorldGenLayer ENDSTONE = new SimpleWorldGenLayer( - GTCEu.id("endstone"), () -> WorldGeneratorUtils.END_ORE_REPLACEABLES, - Set.of(Level.END.location())); - - public static void init() { - AddonFinder.getAddons().forEach(IGTAddon::registerWorldgenLayers); - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.WORLD_GEN_LAYERS, IWorldGenLayer.class)); - if (GTCEu.Mods.isKubeJSLoaded()) { - GTRegistryInfo.registerFor(GTRegistries.WORLD_GEN_LAYERS.getRegistryName()); - } - GTRegistries.WORLD_GEN_LAYERS.freeze(); - } + public static final SimpleWorldGenLayer STONE = REGISTRATE.simpleWorldGenLayer( + "stone", () -> new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES), + Set.of(Level.OVERWORLD)); + + public static final SimpleWorldGenLayer DEEPSLATE = REGISTRATE.simpleWorldGenLayer( + "deepslate", () -> new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES), + Set.of(Level.OVERWORLD)); + + public static final SimpleWorldGenLayer NETHERRACK = REGISTRATE.simpleWorldGenLayer( + "netherrack", () -> new TagMatchTest(BlockTags.NETHER_CARVER_REPLACEABLES), + Set.of(Level.NETHER)); + public static final SimpleWorldGenLayer ENDSTONE = REGISTRATE.simpleWorldGenLayer( + "endstone", () -> WorldGeneratorUtils.END_ORE_REPLACEABLES, + Set.of(Level.END)); + + public static void init() {} } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/WeightedMaterial.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/WeightedMaterial.java index c6aa5690de6..ee82158b318 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/WeightedMaterial.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/bedrockore/WeightedMaterial.java @@ -11,7 +11,7 @@ public record WeightedMaterial(Material material, int weight) implements Weighte public static final Codec CODEC = RecordCodecBuilder.create( instance -> instance.group( - GTRegistries.MATERIALS.codec().fieldOf("material").forGetter(WeightedMaterial::material), + GTRegistries.MATERIALS.byNameCodec().fieldOf("material").forGetter(WeightedMaterial::material), Codec.INT.fieldOf("weight").forGetter(WeightedMaterial::weight)) .apply(instance, WeightedMaterial::new)); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/indicators/SurfaceIndicatorGenerator.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/indicators/SurfaceIndicatorGenerator.java index 91fece04d83..d1317e0d2f7 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/indicators/SurfaceIndicatorGenerator.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/indicators/SurfaceIndicatorGenerator.java @@ -50,7 +50,7 @@ public class SurfaceIndicatorGenerator extends IndicatorGenerator { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codec.either(BlockState.CODEC, GTRegistries.MATERIALS.codec()).fieldOf("block") + Codec.either(BlockState.CODEC, GTRegistries.MATERIALS.byNameCodec()).fieldOf("block") .forGetter(ext -> ext.block), IntProvider.codec(1, 32).fieldOf("radius").forGetter(ext -> ext.radius), FloatProvider.codec(0.0f, 2.0f).fieldOf("density").forGetter(ext -> ext.density), diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/ClassicVeinGenerator.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/ClassicVeinGenerator.java index 9f5ed39de59..32d8ef64b88 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/ClassicVeinGenerator.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/ClassicVeinGenerator.java @@ -230,7 +230,7 @@ public ClassicVeinGenerator sporadic(Consumer builder) { public static class Layer { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codec.either(OreConfiguration.TargetBlockState.CODEC.listOf(), GTRegistries.MATERIALS.codec()) + Codec.either(OreConfiguration.TargetBlockState.CODEC.listOf(), GTRegistries.MATERIALS.byNameCodec()) .fieldOf("targets").forGetter(layer -> layer.target), ExtraCodecs.intRange(-1, Integer.MAX_VALUE).optionalFieldOf("layers", -1) .forGetter(layer -> layer.layers)) diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/DikeVeinGenerator.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/DikeVeinGenerator.java index 46de33fa340..f60b9ccd6fe 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/DikeVeinGenerator.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/DikeVeinGenerator.java @@ -180,7 +180,7 @@ public record DikeBlockDefinition(Either, Material> block implements WeightedEntry { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codec.either(TargetBlockState.CODEC.listOf(), GTRegistries.MATERIALS.codec()).fieldOf("block") + Codec.either(TargetBlockState.CODEC.listOf(), GTRegistries.MATERIALS.byNameCodec()).fieldOf("block") .forGetter(x -> x.block), Codec.INT.fieldOf("weight").forGetter(x -> x.weight), Codec.INT.fieldOf("min_y").orElse(320).forGetter(x -> x.minY), diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/GeodeVeinGenerator.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/GeodeVeinGenerator.java index 14a6dbdef33..eb3d4f690f2 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/GeodeVeinGenerator.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/GeodeVeinGenerator.java @@ -324,16 +324,18 @@ public record GeodeBlockSettings(Either fillingPro TagKey invalidBlocks, @NotNull TagPrefix providerMaterialPrefix) { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - Codec.either(BlockStateProvider.CODEC, GTRegistries.MATERIALS.codec()).fieldOf("filling_provider") + Codec.either(BlockStateProvider.CODEC, GTRegistries.MATERIALS.byNameCodec()).fieldOf("filling_provider") .forGetter(config -> config.fillingProvider), - Codec.either(BlockStateProvider.CODEC, GTRegistries.MATERIALS.codec()).fieldOf("inner_layer_provider") + Codec.either(BlockStateProvider.CODEC, GTRegistries.MATERIALS.byNameCodec()) + .fieldOf("inner_layer_provider") .forGetter(config -> config.innerLayerProvider), - Codec.either(BlockStateProvider.CODEC, GTRegistries.MATERIALS.codec()) + Codec.either(BlockStateProvider.CODEC, GTRegistries.MATERIALS.byNameCodec()) .fieldOf("alternate_inner_layer_provider") .forGetter(config -> config.alternateInnerLayerProvider), - Codec.either(BlockStateProvider.CODEC, GTRegistries.MATERIALS.codec()) + Codec.either(BlockStateProvider.CODEC, GTRegistries.MATERIALS.byNameCodec()) .fieldOf("middle_layer_provider").forGetter(config -> config.middleLayerProvider), - Codec.either(BlockStateProvider.CODEC, GTRegistries.MATERIALS.codec()).fieldOf("outer_layer_provider") + Codec.either(BlockStateProvider.CODEC, GTRegistries.MATERIALS.byNameCodec()) + .fieldOf("outer_layer_provider") .forGetter(config -> config.outerLayerProvider), ExtraCodecs.nonEmptyList(BlockState.CODEC.listOf()).fieldOf("inner_placements") .forGetter(config -> config.innerPlacements), @@ -341,7 +343,7 @@ public record GeodeBlockSettings(Either fillingPro .forGetter(config -> config.cannotReplace), TagKey.hashedCodec(Registries.BLOCK).fieldOf("invalid_blocks") .forGetter(config -> config.invalidBlocks), - GTRegistries.TAG_PREFIXES.codec().optionalFieldOf("provider_material_prefix", TagPrefix.block) + GTRegistries.TAG_PREFIXES.byNameCodec().optionalFieldOf("provider_material_prefix", TagPrefix.block) .forGetter(config -> config.providerMaterialPrefix)) .apply(instance, GeodeBlockSettings::new)); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/StandardVeinGenerator.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/StandardVeinGenerator.java index a2f82482d63..c81eee4053b 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/StandardVeinGenerator.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/StandardVeinGenerator.java @@ -47,7 +47,7 @@ public class StandardVeinGenerator extends VeinGenerator { .apply(instance, StandardVeinGenerator::new)); public static final Codec CODEC_LIST = RecordCodecBuilder.create(instance -> instance.group( - Codec.either(OreConfiguration.TargetBlockState.CODEC.listOf(), GTRegistries.MATERIALS.codec()) + Codec.either(OreConfiguration.TargetBlockState.CODEC.listOf(), GTRegistries.MATERIALS.byNameCodec()) .fieldOf("targets").forGetter(ext -> ext.blocks)) .apply(instance, StandardVeinGenerator::new)); diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/VeinedVeinGenerator.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/VeinedVeinGenerator.java index 502a12d15e4..7af387df0db 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/VeinedVeinGenerator.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/generator/veins/VeinedVeinGenerator.java @@ -54,7 +54,7 @@ public class VeinedVeinGenerator extends VeinGenerator { public static final Codec, Material>> BLOCK_ENTRY_CODEC = Codec - .either(TargetBlockState.CODEC.listOf(), GTRegistries.MATERIALS.codec()); + .either(TargetBlockState.CODEC.listOf(), GTRegistries.MATERIALS.byNameCodec()); public static final Codec CODEC = RecordCodecBuilder.create((instance) -> instance.group( VeinBlockDefinition.CODEC.listOf().fieldOf("ore_blocks").forGetter(it -> it.oreBlocks), diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/BiomePlacement.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/BiomePlacement.java index db84648121d..827b7397454 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/BiomePlacement.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/BiomePlacement.java @@ -1,11 +1,8 @@ package com.gregtechceu.gtceu.api.data.worldgen.modifier; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.worldgen.BiomeWeightModifier; -import com.gregtechceu.gtceu.api.registry.GTRegistries; import net.minecraft.core.BlockPos; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.util.RandomSource; import net.minecraft.world.level.levelgen.placement.PlacementContext; import net.minecraft.world.level.levelgen.placement.PlacementModifier; @@ -18,8 +15,7 @@ public class BiomePlacement extends PlacementModifier { - public static final PlacementModifierType BIOME_PLACEMENT = GTRegistries.register( - BuiltInRegistries.PLACEMENT_MODIFIER_TYPE, GTCEu.id("biome_placement"), () -> BiomePlacement.CODEC); + public static final PlacementModifierType BIOME_PLACEMENT = () -> BiomePlacement.CODEC; public static final Codec CODEC = BiomeWeightModifier.CODEC.listOf().fieldOf("modifiers") .xmap(BiomePlacement::new, placement -> placement.modifiers).codec(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/DimensionFilter.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/DimensionFilter.java index 1d2d3269372..1bfd7645120 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/DimensionFilter.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/DimensionFilter.java @@ -1,12 +1,8 @@ package com.gregtechceu.gtceu.api.data.worldgen.modifier; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.registry.GTRegistries; - import net.minecraft.core.BlockPos; import net.minecraft.core.HolderSet; import net.minecraft.core.RegistryCodecs; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.util.RandomSource; import net.minecraft.world.level.dimension.DimensionType; @@ -19,8 +15,7 @@ public class DimensionFilter extends PlacementFilter { - public static final PlacementModifierType DIMENSION_FILTER = GTRegistries - .register(BuiltInRegistries.PLACEMENT_MODIFIER_TYPE, GTCEu.id("dimension"), () -> DimensionFilter.CODEC); + public static final PlacementModifierType DIMENSION_FILTER = () -> DimensionFilter.CODEC; public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( RegistryCodecs.homogeneousList(Registries.DIMENSION_TYPE).fieldOf("dimension_id") diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/FrequencyModifier.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/FrequencyModifier.java index f659cb34b01..1eb2ca61b9e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/FrequencyModifier.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/FrequencyModifier.java @@ -1,11 +1,7 @@ package com.gregtechceu.gtceu.api.data.worldgen.modifier; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.registry.GTRegistries; - import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.util.ExtraCodecs; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; @@ -23,8 +19,7 @@ @MethodsReturnNonnullByDefault public class FrequencyModifier extends PlacementModifier { - public static final PlacementModifierType FREQUENCY_MODIFIER = GTRegistries - .register(BuiltInRegistries.PLACEMENT_MODIFIER_TYPE, GTCEu.id("frequency"), () -> FrequencyModifier.CODEC); + public static final PlacementModifierType FREQUENCY_MODIFIER = () -> FrequencyModifier.CODEC; public static final Codec CODEC = ExtraCodecs.POSITIVE_FLOAT.fieldOf("chance") .xmap(FrequencyModifier::new, (modifier) -> modifier.frequency).codec(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/GTPlacementModifiers.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/GTPlacementModifiers.java new file mode 100644 index 00000000000..63df6e378d6 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/modifier/GTPlacementModifiers.java @@ -0,0 +1,30 @@ +package com.gregtechceu.gtceu.api.data.worldgen.modifier; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.common.worldgen.modifier.RubberTreeChancePlacement; + +import net.minecraft.core.registries.Registries; +import net.minecraft.world.level.levelgen.placement.PlacementModifier; +import net.minecraft.world.level.levelgen.placement.PlacementModifierType; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; + +public class GTPlacementModifiers { + + public static final DeferredRegister> PLACEMENT_MODIFIER = DeferredRegister + .create(Registries.PLACEMENT_MODIFIER_TYPE, GTCEu.MOD_ID); + + public static PlacementModifierType register(String name, + PlacementModifierType value) { + PLACEMENT_MODIFIER.register(name, () -> (PlacementModifierType) value); + return value; + } + + public static void init(IEventBus modBus) { + PLACEMENT_MODIFIER.register(modBus); + register("frequency", () -> FrequencyModifier.CODEC); + register("dimension", () -> DimensionFilter.CODEC); + register("biome_placement", () -> BiomePlacement.CODEC); + register("rubber_tree_chance", () -> RubberTreeChancePlacement.CODEC); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/ores/OreGenerator.java b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/ores/OreGenerator.java index 808241cfa9c..cf8c8dfcb90 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/ores/OreGenerator.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/worldgen/ores/OreGenerator.java @@ -132,7 +132,7 @@ private List createConfigs(WorldGenLevel level, ChunkGenerato } private Stream getEntries(WorldGenLevel level, BlockPos veinCenter, XoroshiroRandomSource random) { - return GTRegistries.WORLD_GEN_LAYERS.values().stream() + return GTRegistries.WORLD_GEN_LAYERS.stream() .filter(layer -> layer.isApplicableForLevel(level.getLevel().dimension().location())) .map(layer -> getEntry(level, level.getBiome(veinCenter), random, layer)) .filter(Objects::nonNull); diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/component/prospector/ProspectorMode.java b/src/main/java/com/gregtechceu/gtceu/api/item/component/prospector/ProspectorMode.java index 8c7acd92b7d..04f9cacbd31 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/component/prospector/ProspectorMode.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/component/prospector/ProspectorMode.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.api.item.component.prospector; +import com.gregtechceu.gtceu.GTCEu; 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.MaterialEntry; @@ -335,7 +336,8 @@ public int getItemColor(BedrockOreInfo item) { public IDrawable getItemIcon(BedrockOreInfo item) { Material material = item.material; ItemStack stack = GTUtil.getFirstNonEmpty( - ChemicalHelper.get(TagPrefix.get(ConfigHolder.INSTANCE.machines.bedrockOreDropTagPrefix), material), + ChemicalHelper.get(Objects.requireNonNull(GTRegistries.TAG_PREFIXES + .get(GTCEu.id(ConfigHolder.INSTANCE.machines.bedrockOreDropTagPrefix))), material), ChemicalHelper.get(TagPrefix.crushed, material), ChemicalHelper.get(TagPrefix.gem, material), ChemicalHelper.get(TagPrefix.ore, material), diff --git a/src/main/java/com/gregtechceu/gtceu/api/item/tool/IToolGridHighlight.java b/src/main/java/com/gregtechceu/gtceu/api/item/tool/IToolGridHighlight.java index d91f04b3940..9066f456808 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/item/tool/IToolGridHighlight.java +++ b/src/main/java/com/gregtechceu/gtceu/api/item/tool/IToolGridHighlight.java @@ -36,11 +36,12 @@ default boolean shouldRenderGrid(Player player, BlockPos pos, BlockState state, * @param pos Block pos * @param state Block state * @param toolTypes The GT tool types of the held item, if any + * @param held * @param side The machine side which this grid segment correspond to * @return The icon to be rendered, or null */ default @Nullable UITexture sideTips(Player player, BlockPos pos, BlockState state, Set toolTypes, - Direction side) { + ItemStack held, Direction side) { return null; } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/MachineCoverContainer.java b/src/main/java/com/gregtechceu/gtceu/api/machine/MachineCoverContainer.java index 445e2013874..ccbc306dd6a 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/MachineCoverContainer.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/MachineCoverContainer.java @@ -90,10 +90,10 @@ public boolean shouldRenderGridOverlay(Player player, BlockPos pos, BlockState s @Override public @Nullable UITexture getGridOverlayIcon(Player player, BlockPos pos, BlockState state, - Set toolTypes, Direction side) { + Set toolTypes, ItemStack held, Direction side) { var cover = getCoverAtSide(side); if (cover != null) { - return cover.sideTips(player, pos, state, toolTypes, side); + return cover.sideTips(player, pos, state, toolTypes, held, side); } return null; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/MachineDefinition.java b/src/main/java/com/gregtechceu/gtceu/api/machine/MachineDefinition.java index ff57306e85e..be8a00923ee 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/MachineDefinition.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/MachineDefinition.java @@ -61,7 +61,7 @@ public class MachineDefinition implements Supplier { private Supplier> blockEntityTypeSupplier; @Getter @Setter - private @NotNull GTRecipeType @NotNull [] recipeTypes; + private GTRecipeType[] recipeTypes; @Getter @Setter private int tier; diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java index 6650440a7aa..ba7ef7cccb8 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/MetaMachine.java @@ -656,7 +656,7 @@ public boolean shouldRenderGrid(Player player, BlockPos pos, BlockState state, I @Override public @Nullable UITexture sideTips(Player player, BlockPos pos, BlockState state, Set toolTypes, - Direction side) { + ItemStack held, Direction side) { if (toolTypes.contains(GTToolType.WRENCH)) { if (player.isShiftKeyDown()) { if (isFacingValid(side) || (allowExtendedFacing() && hasFrontFacing() && side == getFrontFacing())) { @@ -675,7 +675,7 @@ public boolean shouldRenderGrid(Player player, BlockPos pos, BlockState state, I for (var trait : getAllTraits()) { if (trait instanceof IRenderingTrait renderingTrait) { - var result = renderingTrait.getGridOverlayIcon(player, pos, state, toolTypes, side); + var result = renderingTrait.getGridOverlayIcon(player, pos, state, toolTypes, held, side); if (result != null) return result; } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamWorkableMachine.java b/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamWorkableMachine.java index 2f90f65552b..3b6324c4a7c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamWorkableMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamWorkableMachine.java @@ -21,6 +21,7 @@ import net.minecraft.core.Direction; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.fluids.FluidType; @@ -186,7 +187,7 @@ public void clientTick() { ////////////////////////////////////// @Override public @Nullable UITexture sideTips(Player player, BlockPos pos, BlockState state, Set toolTypes, - Direction side) { + ItemStack held, Direction side) { if (toolTypes.contains(GTToolType.WRENCH)) { if (!player.isShiftKeyDown()) { if (!hasFrontFacing() || side != getFrontFacing()) { @@ -194,6 +195,6 @@ public void clientTick() { } } } - return super.sideTips(player, pos, state, toolTypes, side); + return super.sideTips(player, pos, state, toolTypes, held, side); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/feature/IRenderingTrait.java b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/feature/IRenderingTrait.java index a5d708c3d34..bdb73bb09c9 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/machine/trait/feature/IRenderingTrait.java +++ b/src/main/java/com/gregtechceu/gtceu/api/machine/trait/feature/IRenderingTrait.java @@ -41,12 +41,13 @@ default boolean shouldRenderGridOverlay(Player player, BlockPos pos, BlockState * @param pos Block pos * @param state Block state * @param toolTypes The GT tool types of the held item, if any + * @param held Item the player is currently holding. * @param side The machine side which this grid segment correspond to * @return The icon to be rendered, or null */ default @Nullable UITexture getGridOverlayIcon(Player player, BlockPos pos, BlockState state, Set toolTypes, - Direction side) { + ItemStack held, Direction side) { return null; } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/multiblock/error/GTPatternErrors.java b/src/main/java/com/gregtechceu/gtceu/api/multiblock/error/GTPatternErrors.java index 397462ee1c6..85412be9d44 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/multiblock/error/GTPatternErrors.java +++ b/src/main/java/com/gregtechceu/gtceu/api/multiblock/error/GTPatternErrors.java @@ -1,30 +1,36 @@ package com.gregtechceu.gtceu.api.multiblock.error; -import com.gregtechceu.gtceu.api.GTCEuAPI; +import com.gregtechceu.gtceu.api.registry.GTRegistries; -import net.minecraftforge.fml.ModLoader; - -import static com.gregtechceu.gtceu.api.registry.GTRegistries.PATTERN_ERRORS; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.RegistryObject; +@SuppressWarnings("unused") public class GTPatternErrors { - public static void register(PatternError.PatternErrorType patternErrorType) { - PATTERN_ERRORS.register(patternErrorType.id(), patternErrorType); + private static final DeferredRegister PATTERN_ERRORS = DeferredRegister + .create(GTRegistries.Keys.PATTERN_ERROR_TYPE, "gtceu"); + + public static RegistryObject PLACEHOLDER_ERROR = register(PlaceholderError.TYPE); + public static RegistryObject BLOCK_MATCHING_ERROR = register( + BlockMatchingError.TYPE); + public static RegistryObject PART_ABILITY_ERROR = register(PartAbilityError.TYPE); + public static RegistryObject COIL_MATCHING_ERROR = register(CoilMatchingError.TYPE); + public static RegistryObject FILTER_MATCHING_ERROR = register( + FilterMatchingError.TYPE); + public static RegistryObject PATTERN_STRING_ERROR = register( + PatternStringError.TYPE); + public static RegistryObject SINGLE_PREDICATE_ERROR = register( + SinglePredicateError.TYPE); + public static RegistryObject SIMPLE_PATTERN_ERROR = register( + SimplePatternError.TYPE); + + private static RegistryObject register(PatternError.PatternErrorType patternErrorType) { + return PATTERN_ERRORS.register(patternErrorType.id().getPath(), () -> patternErrorType); } - public static void init() { - PATTERN_ERRORS.unfreeze(); - register(PlaceholderError.TYPE); - register(BlockMatchingError.TYPE); - register(PartAbilityError.TYPE); - register(CoilMatchingError.TYPE); - register(FilterMatchingError.TYPE); - register(PatternStringError.TYPE); - register(SinglePredicateError.TYPE); - register(SimplePatternError.TYPE); - - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(PATTERN_ERRORS, PatternError.PatternErrorType.class)); - - PATTERN_ERRORS.freeze(); + public static void init(IEventBus bus) { + PATTERN_ERRORS.register(bus); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/multiblock/error/PatternError.java b/src/main/java/com/gregtechceu/gtceu/api/multiblock/error/PatternError.java index 170beb040a6..c24936e7c1b 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/multiblock/error/PatternError.java +++ b/src/main/java/com/gregtechceu/gtceu/api/multiblock/error/PatternError.java @@ -17,7 +17,7 @@ public abstract class PatternError { - public static final Codec CODEC = GTRegistries.PATTERN_ERRORS.codec() + public static final Codec CODEC = GTRegistries.PATTERN_ERROR_TYPES.byNameCodec() .dispatch(PatternError::type, PatternErrorType::codec); @Getter diff --git a/src/main/java/com/gregtechceu/gtceu/api/placeholder/PlaceholderHandler.java b/src/main/java/com/gregtechceu/gtceu/api/placeholder/PlaceholderHandler.java index bc2bba01f96..36bb56ef1dc 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/placeholder/PlaceholderHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/api/placeholder/PlaceholderHandler.java @@ -65,14 +65,6 @@ private static final class RendererHolder { public static final Map renderers = new HashMap<>(); } - public static void addPlaceholder(Placeholder placeholder) { - GTRegistries.PLACEHOLDERS.register(placeholder.getId(), placeholder); - } - - public static void addOrOverridePlaceholder(Placeholder placeholder) { - GTRegistries.PLACEHOLDERS.registerOrOverride(placeholder.getId(), placeholder); - } - public static @Nullable Placeholder getPlaceholder(String str) { return GTRegistries.PLACEHOLDERS.get(GTCEu.id(str)); } @@ -329,7 +321,7 @@ public static ModularPanel createPlaceholderEditorPanel(String name, .paddingBottom(5) .excludeAreaInRecipeViewer() .fullHeight() - .children(GTRegistries.PLACEHOLDERS.keys() + .children(GTRegistries.PLACEHOLDERS.keySet() .stream() .sorted() .map(s -> (IWidget) Flow.row() diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java index aada06e40bc..adc9b59127a 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializer.java @@ -21,15 +21,26 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.mojang.serialization.Codec; +import com.mojang.serialization.DataResult; import com.mojang.serialization.JsonOps; import com.mojang.serialization.codecs.RecordCodecBuilder; import dev.latvian.mods.kubejs.recipe.ingredientaction.IngredientAction; import org.jetbrains.annotations.NotNull; import java.util.*; +import java.util.function.Function; public class GTRecipeSerializer implements RecipeSerializer { + public static final Codec GT_RECIPE_TYPE_CODEC = BuiltInRegistries.RECIPE_TYPE.byNameCodec() + .comapFlatMap(recipeType -> { + if (recipeType instanceof GTRecipeType gtRecipeType) { + return DataResult.success(gtRecipeType); + } else { + return DataResult.error(() -> "Recipe type " + recipeType + " is not a GTRecipeType"); + } + }, Function.identity()); + public static final Codec CODEC = makeCodec(GTCEu.Mods.isKubeJSLoaded()); public static final GTRecipeSerializer SERIALIZER = new GTRecipeSerializer(); @@ -69,7 +80,8 @@ public Map, ChanceLogic> chanceLogicsFromJson(JsonObject jso } public static Tuple, List> entryReader(FriendlyByteBuf buf) { - RecipeCapability capability = GTRegistries.RECIPE_CAPABILITIES.get(buf.readResourceLocation()); + RecipeCapability capability = GTRegistries.RECIPE_CAPABILITIES + .getOrThrow(buf.readResourceKey(GTRegistries.Keys.RECIPE_CAPABILITY)); List contents = buf.readList(capability.serializer::fromNetworkContent); return new Tuple<>(capability, contents); } @@ -77,7 +89,7 @@ public static Tuple, List> entryReader(FriendlyByte public static void entryWriter(FriendlyByteBuf buf, Map.Entry, ? extends List> entry) { RecipeCapability capability = entry.getKey(); List contents = entry.getValue(); - buf.writeResourceLocation(GTRegistries.RECIPE_CAPABILITIES.getKey(capability)); + buf.writeResourceKey(GTRegistries.RECIPE_CAPABILITIES.getResourceKey(capability).orElseThrow()); buf.writeCollection(contents, capability.serializer::toNetworkContent); } @@ -110,17 +122,21 @@ public GTRecipe fromNetwork(@NotNull ResourceLocation id, @NotNull FriendlyByteB buf.readCollection(c -> new ArrayList<>(), GTRecipeSerializer::entryReader)); Map, ChanceLogic> inputChanceLogics = buf.readMap( - buf1 -> GTRegistries.RECIPE_CAPABILITIES.get(buf1.readResourceLocation()), - buf1 -> GTRegistries.CHANCE_LOGICS.get(buf1.readResourceLocation())); + buf1 -> GTRegistries.RECIPE_CAPABILITIES + .getOrThrow(buf1.readResourceKey(GTRegistries.Keys.RECIPE_CAPABILITY)), + buf1 -> GTRegistries.CHANCE_LOGICS.getOrThrow(buf1.readResourceKey(GTRegistries.Keys.CHANCE_LOGIC))); Map, ChanceLogic> outputChanceLogics = buf.readMap( - buf1 -> GTRegistries.RECIPE_CAPABILITIES.get(buf1.readResourceLocation()), - buf1 -> GTRegistries.CHANCE_LOGICS.get(buf1.readResourceLocation())); + buf1 -> GTRegistries.RECIPE_CAPABILITIES + .getOrThrow(buf1.readResourceKey(GTRegistries.Keys.RECIPE_CAPABILITY)), + buf1 -> GTRegistries.CHANCE_LOGICS.getOrThrow(buf1.readResourceKey(GTRegistries.Keys.CHANCE_LOGIC))); Map, ChanceLogic> tickInputChanceLogics = buf.readMap( - buf1 -> GTRegistries.RECIPE_CAPABILITIES.get(buf1.readResourceLocation()), - buf1 -> GTRegistries.CHANCE_LOGICS.get(buf1.readResourceLocation())); + buf1 -> GTRegistries.RECIPE_CAPABILITIES + .getOrThrow(buf1.readResourceKey(GTRegistries.Keys.RECIPE_CAPABILITY)), + buf1 -> GTRegistries.CHANCE_LOGICS.getOrThrow(buf1.readResourceKey(GTRegistries.Keys.CHANCE_LOGIC))); Map, ChanceLogic> tickOutputChanceLogics = buf.readMap( - buf1 -> GTRegistries.RECIPE_CAPABILITIES.get(buf1.readResourceLocation()), - buf1 -> GTRegistries.CHANCE_LOGICS.get(buf1.readResourceLocation())); + buf1 -> GTRegistries.RECIPE_CAPABILITIES + .getOrThrow(buf1.readResourceKey(GTRegistries.Keys.RECIPE_CAPABILITY)), + buf1 -> GTRegistries.CHANCE_LOGICS.getOrThrow(buf1.readResourceKey(GTRegistries.Keys.CHANCE_LOGIC))); List> conditions = buf.readCollection(c -> new ArrayList<>(), GTRecipeSerializer::conditionReader); @@ -167,17 +183,21 @@ public void toNetwork(FriendlyByteBuf buf, GTRecipe recipe) { buf.writeCollection(recipe.tickOutputs.entrySet(), GTRecipeSerializer::entryWriter); buf.writeMap(recipe.inputChanceLogics, - (buf1, cap) -> buf1.writeResourceLocation(GTRegistries.RECIPE_CAPABILITIES.getKey(cap)), - (buf1, logic) -> buf1.writeResourceLocation(GTRegistries.CHANCE_LOGICS.getKey(logic))); + (buf1, cap) -> buf1 + .writeResourceKey(GTRegistries.RECIPE_CAPABILITIES.getResourceKey(cap).orElseThrow()), + (buf1, logic) -> buf1.writeResourceKey(GTRegistries.CHANCE_LOGICS.getResourceKey(logic).orElseThrow())); buf.writeMap(recipe.outputChanceLogics, - (buf1, cap) -> buf1.writeResourceLocation(GTRegistries.RECIPE_CAPABILITIES.getKey(cap)), - (buf1, logic) -> buf1.writeResourceLocation(GTRegistries.CHANCE_LOGICS.getKey(logic))); + (buf1, cap) -> buf1 + .writeResourceKey(GTRegistries.RECIPE_CAPABILITIES.getResourceKey(cap).orElseThrow()), + (buf1, logic) -> buf1.writeResourceKey(GTRegistries.CHANCE_LOGICS.getResourceKey(logic).orElseThrow())); buf.writeMap(recipe.tickInputChanceLogics, - (buf1, cap) -> buf1.writeResourceLocation(GTRegistries.RECIPE_CAPABILITIES.getKey(cap)), - (buf1, logic) -> buf1.writeResourceLocation(GTRegistries.CHANCE_LOGICS.getKey(logic))); + (buf1, cap) -> buf1 + .writeResourceKey(GTRegistries.RECIPE_CAPABILITIES.getResourceKey(cap).orElseThrow()), + (buf1, logic) -> buf1.writeResourceKey(GTRegistries.CHANCE_LOGICS.getResourceKey(logic).orElseThrow())); buf.writeMap(recipe.tickOutputChanceLogics, - (buf1, cap) -> buf1.writeResourceLocation(GTRegistries.RECIPE_CAPABILITIES.getKey(cap)), - (buf1, logic) -> buf1.writeResourceLocation(GTRegistries.CHANCE_LOGICS.getKey(logic))); + (buf1, cap) -> buf1 + .writeResourceKey(GTRegistries.RECIPE_CAPABILITIES.getResourceKey(cap).orElseThrow()), + (buf1, logic) -> buf1.writeResourceKey(GTRegistries.CHANCE_LOGICS.getResourceKey(logic).orElseThrow())); buf.writeCollection(recipe.conditions, GTRecipeSerializer::conditionWriter); if (GTCEu.Mods.isKubeJSLoaded()) { @@ -192,23 +212,23 @@ private static Codec makeCodec(boolean isKubeLoaded) { // spotless:off if (!isKubeLoaded) { return RecordCodecBuilder.create(instance -> instance.group( - GTRegistries.RECIPE_TYPES.codec().fieldOf("type").forGetter(val -> val.recipeType), + GT_RECIPE_TYPE_CODEC.fieldOf("type").forGetter(val -> val.recipeType), RecipeCapability.CODEC.optionalFieldOf("inputs", Map.of()).forGetter(val -> val.inputs), RecipeCapability.CODEC.optionalFieldOf("outputs", Map.of()).forGetter(val -> val.outputs), RecipeCapability.CODEC.optionalFieldOf("tickInputs", Map.of()).forGetter(val -> val.tickInputs), RecipeCapability.CODEC.optionalFieldOf("tickOutputs", Map.of()).forGetter(val -> val.tickOutputs), - Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.codec()) + Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.byNameCodec()) .optionalFieldOf("inputChanceLogics", Map.of()).forGetter(val -> val.inputChanceLogics), - Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.codec()) + Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.byNameCodec()) .optionalFieldOf("outputChanceLogics", Map.of()).forGetter(val -> val.outputChanceLogics), - Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.codec()) + Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.byNameCodec()) .optionalFieldOf("tickInputChanceLogics", Map.of()).forGetter(val -> val.tickInputChanceLogics), - Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.codec()) + Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.byNameCodec()) .optionalFieldOf("tickOutputChanceLogics", Map.of()).forGetter(val -> val.tickOutputChanceLogics), RecipeCondition.CODEC.listOf().optionalFieldOf("recipeConditions", List.of()).forGetter(val -> val.conditions), CompoundTag.CODEC.optionalFieldOf("data", new CompoundTag()).forGetter(val -> val.data), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("duration").forGetter(val -> val.duration), - GTRegistries.RECIPE_CATEGORIES.codec().optionalFieldOf("category", GTRecipeCategory.DEFAULT).forGetter(val -> val.recipeCategory), + GTRegistries.RECIPE_CATEGORIES.byNameCodec().optionalFieldOf("category", GTRecipeCategory.DEFAULT).forGetter(val -> val.recipeCategory), Codec.INT.optionalFieldOf("groupColor", -1).forGetter(val -> val.groupColor)) .apply(instance, (type, inputs, outputs, tickInputs, tickOutputs, @@ -219,24 +239,24 @@ private static Codec makeCodec(boolean isKubeLoaded) { conditions, List.of(), data, duration, recipeCategory, groupColor))); } else { return RecordCodecBuilder.create(instance -> instance.group( - GTRegistries.RECIPE_TYPES.codec().fieldOf("type").forGetter(val -> val.recipeType), + GT_RECIPE_TYPE_CODEC.fieldOf("type").forGetter(val -> val.recipeType), RecipeCapability.CODEC.optionalFieldOf("inputs", Map.of()).forGetter(val -> val.inputs), RecipeCapability.CODEC.optionalFieldOf("outputs", Map.of()).forGetter(val -> val.outputs), RecipeCapability.CODEC.optionalFieldOf("tickInputs", Map.of()).forGetter(val -> val.tickInputs), RecipeCapability.CODEC.optionalFieldOf("tickOutputs", Map.of()).forGetter(val -> val.tickOutputs), - Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.codec()) + Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.byNameCodec()) .optionalFieldOf("inputChanceLogics", Map.of()).forGetter(val -> val.inputChanceLogics), - Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.codec()) + Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.byNameCodec()) .optionalFieldOf("outputChanceLogics", Map.of()).forGetter(val -> val.outputChanceLogics), - Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.codec()) + Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.byNameCodec()) .optionalFieldOf("tickInputChanceLogics", Map.of()).forGetter(val -> val.tickInputChanceLogics), - Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.codec()) + Codec.unboundedMap(RecipeCapability.DIRECT_CODEC, GTRegistries.CHANCE_LOGICS.byNameCodec()) .optionalFieldOf("tickOutputChanceLogics", Map.of()).forGetter(val -> val.tickOutputChanceLogics), RecipeCondition.CODEC.listOf().optionalFieldOf("recipeConditions", List.of()).forGetter(val -> val.conditions), KJSCallWrapper.INGREDIENT_ACTION_CODEC.optionalFieldOf("kubejs:actions", List.of()).forGetter(val -> (List) val.ingredientActions), CompoundTag.CODEC.optionalFieldOf("data", new CompoundTag()).forGetter(val -> val.data), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("duration").forGetter(val -> val.duration), - GTRegistries.RECIPE_CATEGORIES.codec().optionalFieldOf("category", GTRecipeCategory.DEFAULT).forGetter(val -> val.recipeCategory), + GTRegistries.RECIPE_CATEGORIES.byNameCodec().optionalFieldOf("category", GTRecipeCategory.DEFAULT).forGetter(val -> val.recipeCategory), Codec.INT.optionalFieldOf("groupColor", -1).forGetter(val -> val.groupColor)) .apply(instance, GTRecipe::new)); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeType.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeType.java index 76563b88c4b..c47e7ac1767 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeType.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/GTRecipeType.java @@ -7,12 +7,14 @@ import com.gregtechceu.gtceu.api.recipe.gui.GTRecipeTypeUILayout; import com.gregtechceu.gtceu.api.recipe.lookup.RecipeAdditionHandler; import com.gregtechceu.gtceu.api.recipe.lookup.RecipeDB; +import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate; import com.gregtechceu.gtceu.api.sound.SoundEntry; import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; import com.gregtechceu.gtceu.utils.FormattingUtil; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; @@ -94,9 +96,13 @@ public class GTRecipeType implements RecipeType { private GTRecipeTypeUILayout uiLayout; public GTRecipeType(ResourceLocation registryName, String group, RecipeType... proxyRecipes) { + var registrate = GTRegistrate.createIgnoringListenerErrors(registryName.getNamespace()); + registrate.generic(registryName.getPath(), Registries.RECIPE_TYPE, () -> this).build(); + registrate.generic(registryName.getPath(), Registries.RECIPE_SERIALIZER, GTRecipeSerializer::new).build(); + this.registryName = registryName; this.group = group; - this.category = GTRecipeCategory.registerDefault(this); + this.category = registrate.recipeCategory(registryName.getPath(), this); recipeBuilder = new GTRecipeBuilder(registryName, this); // must be linked to stop json contents from shuffling Map, List> map = new Object2ObjectLinkedOpenHashMap<>(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeCondition.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeCondition.java index 415faf761de..cc6f7a98d79 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/RecipeCondition.java @@ -27,7 +27,7 @@ @Accessors(chain = true) public abstract class RecipeCondition> { - public static final Codec> CODEC = GTRegistries.RECIPE_CONDITIONS.codec() + public static final Codec> CODEC = GTRegistries.RECIPE_CONDITIONS.byNameCodec() .dispatch(RecipeCondition::getType, RecipeConditionType::getCodec); // spotless:off diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/category/GTRecipeCategory.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/category/GTRecipeCategory.java index cee9e45f1cd..78ff1ffe09f 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/category/GTRecipeCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/category/GTRecipeCategory.java @@ -7,10 +7,12 @@ import com.gregtechceu.gtceu.common.data.GTRecipeTypes; import com.gregtechceu.gtceu.integration.recipeviewer.CategoryIcon; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import com.mojang.serialization.Lifecycle; import lombok.Getter; import lombok.Setter; import lombok.experimental.Accessors; @@ -52,7 +54,9 @@ public GTRecipeCategory(@NotNull String categoryName, @NotNull GTRecipeType reci public static GTRecipeCategory registerDefault(@NotNull GTRecipeType recipeType) { GTRecipeCategory category = new GTRecipeCategory(recipeType); - GTRegistries.RECIPE_CATEGORIES.register(category.registryKey, category); + GTRegistries.RECIPE_CATEGORIES.register( + ResourceKey.create(GTRegistries.Keys.RECIPE_CATEGORY, category.registryKey), category, + Lifecycle.stable()); return category; } diff --git a/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/logic/ChanceLogic.java b/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/logic/ChanceLogic.java index 60857ba3110..bbc8fc73e2a 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/logic/ChanceLogic.java +++ b/src/main/java/com/gregtechceu/gtceu/api/recipe/chance/logic/ChanceLogic.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.api.recipe.chance.logic; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; import com.gregtechceu.gtceu.api.recipe.chance.boost.ChanceBoostFunction; @@ -10,14 +9,13 @@ import com.gregtechceu.gtceu.api.registry.GTRegistries; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fml.ModLoader; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; import com.google.common.collect.ImmutableList; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.objects.Object2IntMap; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; @@ -31,14 +29,23 @@ */ public abstract class ChanceLogic { - static { - GTRegistries.CHANCE_LOGICS.unfreeze(); + private static final DeferredRegister CHANCE_LOGIC = DeferredRegister + .create(GTRegistries.Keys.CHANCE_LOGIC, GTCEu.MOD_ID); + + public static void init(IEventBus modBus) { + CHANCE_LOGIC.register(modBus); + + CHANCE_LOGIC.register("or", () -> OR); + CHANCE_LOGIC.register("and", () -> AND); + CHANCE_LOGIC.register("first", () -> FIRST); + CHANCE_LOGIC.register("xor", () -> XOR); + CHANCE_LOGIC.register("none", () -> NONE); } /** * Chanced Output Logic where any ingredients succeeding their roll will be produced */ - public static final ChanceLogic OR = new ChanceLogic("or") { + public static final ChanceLogic OR = new ChanceLogic() { @Override public @Unmodifiable List<@NotNull Content> roll(RecipeCapability cap, @@ -84,7 +91,7 @@ public String toString() { /** * Chanced Output Logic where all ingredients must succeed their roll in order for any to be produced */ - public static final ChanceLogic AND = new ChanceLogic("and") { + public static final ChanceLogic AND = new ChanceLogic() { @Override public @Unmodifiable List<@NotNull Content> roll(RecipeCapability cap, @@ -124,7 +131,7 @@ public String toString() { * Deprecated following the rewrite of XOR */ @Deprecated - public static final ChanceLogic FIRST = new ChanceLogic("first") { + public static final ChanceLogic FIRST = new ChanceLogic() { @Override public @Unmodifiable List<@NotNull Content> roll(RecipeCapability cap, @@ -164,7 +171,7 @@ public String toString() { /** * Chanced Output Logic where only one of the ingredients will be output, in a manner weighted to the input chances */ - public static final ChanceLogic XOR = new ChanceLogic("xor") { + public static final ChanceLogic XOR = new ChanceLogic() { @Override public @Unmodifiable List<@NotNull Content> roll(RecipeCapability cap, @@ -261,7 +268,7 @@ public String toString() { /** * Chanced Output Logic where nothing is produced */ - public static final ChanceLogic NONE = new ChanceLogic("none") { + public static final ChanceLogic NONE = new ChanceLogic() { @Override public @Unmodifiable List<@NotNull Content> roll(RecipeCapability cap, @@ -282,14 +289,6 @@ public String toString() { } }; - public ChanceLogic(ResourceLocation id) { - GTRegistries.CHANCE_LOGICS.register(id, this); - } - - private ChanceLogic(String id) { - this(GTCEu.id(id)); - } - /** * @param entry the entry to get the complete chance for * @param boostFunction the function boosting the entry's chance @@ -378,10 +377,4 @@ static void updateCachedChance(Object ingredient, @Nullable Object2IntMap cac @NotNull public abstract Component getTranslation(); - - @ApiStatus.Internal - public static void init() { - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.CHANCE_LOGICS, ChanceLogic.class)); - GTRegistries.CHANCE_LOGICS.freeze(); - } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java b/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java index 12117c6427f..9ab31f9b4d8 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistries.java @@ -5,7 +5,9 @@ import com.gregtechceu.gtceu.api.cover.CoverDefinition; import com.gregtechceu.gtceu.api.data.DimensionMarker; import com.gregtechceu.gtceu.api.data.chemical.Element; +import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet; +import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; import com.gregtechceu.gtceu.api.data.chemical.material.registry.MaterialRegistry; import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; @@ -21,105 +23,118 @@ import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic; import com.gregtechceu.gtceu.api.recipe.condition.RecipeConditionType; import com.gregtechceu.gtceu.api.sound.SoundEntry; +import com.gregtechceu.gtceu.core.mixins.BuiltInRegistriesAccessor; import net.minecraft.client.Minecraft; +import net.minecraft.core.MappedRegistry; import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; +import net.minecraft.core.WritableRegistry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.RecipeSerializer; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.level.levelgen.feature.Feature; -import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType; -import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType; -import net.minecraft.world.level.levelgen.placement.PlacementModifierType; -import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; - -import com.mojang.serialization.Codec; +import net.minecraftforge.fml.common.Mod; + +import com.mojang.serialization.Lifecycle; +import org.checkerframework.checker.units.qual.K; import org.jetbrains.annotations.ApiStatus; +@Mod.EventBusSubscriber(modid = "gtceu") public final class GTRegistries { + private GTRegistries() {} + // spotless:off + public static final class Keys { - // Material related registries + private Keys() {} - // spotless:off + // Material related registries + public static final ResourceKey> MATERIAL = makeRegistryKey(GTCEu.id("material")); + public static final ResourceKey> ELEMENT = makeRegistryKey(GTCEu.id("element")); + public static final ResourceKey> TAG_PREFIX = makeRegistryKey(GTCEu.id("tag_prefix")); + public static final ResourceKey> MATERIAL_ICON_SET = makeRegistryKey(GTCEu.id("material_icon_set")); + + // Recipe related registries + + public static final ResourceKey> RECIPE_TYPE = makeRegistryKey(GTCEu.id("recipe_type")); + public static final ResourceKey> RECIPE_CATEGORY = makeRegistryKey(GTCEu.id("recipe_category")); + public static final ResourceKey>> RECIPE_CAPABILITY = makeRegistryKey(GTCEu.id("recipe_capability")); + public static final ResourceKey>> RECIPE_CONDITION = makeRegistryKey(GTCEu.id("recipe_condition")); + public static final ResourceKey> CHANCE_LOGIC = makeRegistryKey(GTCEu.id("chance_logic")); + + // Datapack registries + + public static final ResourceKey> BEDROCK_FLUID = makeRegistryKey(GTCEu.id("bedrock_fluid")); + public static final ResourceKey> BEDROCK_ORE = makeRegistryKey(GTCEu.id("bedrock_ore")); + public static final ResourceKey> ORE_VEIN = makeRegistryKey(GTCEu.id("ore_vein")); + + // Worldgen related registries + + public static final ResourceKey> WORLD_GEN_LAYER = makeRegistryKey(GTCEu.id("world_gen_layer")); + + // Other registries - public static final MaterialRegistry MATERIALS = new MaterialRegistry(); - public static final GTRegistry.RL ELEMENTS = new GTRegistry.RL<>(GTCEu.id("element")); - public static final GTRegistry.RL TAG_PREFIXES = new GTRegistry.RL<>(GTCEu.id("tag_prefix")); - public static final GTRegistry.RL MATERIAL_ICON_SETS = new GTRegistry.RL<>(GTCEu.id("material_icon_set")); + public static final ResourceKey> COVER = makeRegistryKey(GTCEu.id("cover")); + public static final ResourceKey> MACHINE = makeRegistryKey(GTCEu.id("machine")); + + public static final ResourceKey> SOUND = makeRegistryKey(GTCEu.id("sound")); + + public static final ResourceKey> DIMENSION_MARKER = makeRegistryKey(GTCEu.id("dimension_marker")); + public static final ResourceKey> MEDICAL_CONDITION = makeRegistryKey(GTCEu.id("medical_condition")); + public static final ResourceKey> PATTERN_ERROR_TYPE = makeRegistryKey(GTCEu.id("pattern_error_type")); + public static final ResourceKey> PLACEHOLDER = makeRegistryKey(GTCEu.id("placeholder")); + } + + // Material related registries + + public static final MaterialRegistry MATERIALS = makeRegistry(Keys.MATERIAL, new MaterialRegistry()); + public static final MappedRegistry ELEMENTS = makeRegistry(Keys.ELEMENT); + public static final MappedRegistry TAG_PREFIXES = makeRegistry(Keys.TAG_PREFIX); + public static final MappedRegistry MATERIAL_ICON_SETS = makeRegistry(Keys.MATERIAL_ICON_SET); // Recipe related registries - public static final GTRegistry.RL RECIPE_TYPES = new GTRegistry.RL<>(GTCEu.id("recipe_type")); - public static final GTRegistry.RL RECIPE_CATEGORIES = new GTRegistry.RL<>(GTCEu.id("recipe_category")); - public static final GTRegistry.RL> RECIPE_CAPABILITIES = new GTRegistry.RL<>(GTCEu.id("recipe_capability")); - public static final GTRegistry.RL> RECIPE_CONDITIONS = new GTRegistry.RL<>(GTCEu.id("recipe_condition")); - public static final GTRegistry.RL CHANCE_LOGICS = new GTRegistry.RL<>(GTCEu.id("chance_logic")); + public static final MappedRegistry RECIPE_TYPE = makeRegistry(Keys.RECIPE_TYPE); + public static final MappedRegistry RECIPE_CATEGORIES = makeRegistry(Keys.RECIPE_CATEGORY); + public static final MappedRegistry> RECIPE_CAPABILITIES = makeRegistry(Keys.RECIPE_CAPABILITY); + public static final MappedRegistry> RECIPE_CONDITIONS = makeRegistry(Keys.RECIPE_CONDITION); + public static final MappedRegistry CHANCE_LOGICS = makeRegistry(Keys.CHANCE_LOGIC); // Worldgen related registries - public static final GTRegistry.RL BEDROCK_FLUID_DEFINITIONS = new GTRegistry.RL<>(GTCEu.id("bedrock_fluid")); - public static final GTRegistry.RL BEDROCK_ORE_DEFINITIONS = new GTRegistry.RL<>(GTCEu.id("bedrock_ore")); - public static final GTRegistry.RL ORE_VEINS = new GTRegistry.RL<>(GTCEu.id("ore_vein")); - public static final GTRegistry.RL WORLD_GEN_LAYERS = new GTRegistry.RL<>(GTCEu.id("world_gen_layer")); + public static final GTRegistry BEDROCK_FLUID_DEFINITIONS = new GTRegistry<>(GTCEu.id("bedrock_fluid")); + public static final GTRegistry BEDROCK_ORE_DEFINITIONS = new GTRegistry<>(GTCEu.id("bedrock_ore")); + public static final GTRegistry ORE_VEINS = new GTRegistry<>(GTCEu.id("ore_vein")); + public static final MappedRegistry WORLD_GEN_LAYERS = makeRegistry(Keys.WORLD_GEN_LAYER); // Other registries - public static final GTRegistry.RL COVERS = new GTRegistry.RL<>(GTCEu.id("cover")); - public static final GTRegistry.RL MACHINES = new GTRegistry.RL<>(GTCEu.id("machine")); - public static final GTRegistry.RL SOUNDS = new GTRegistry.RL<>(GTCEu.id("sound")); - public static final GTRegistry.RL DIMENSION_MARKERS = new GTRegistry.RL<>(GTCEu.id("dimension_marker")); - public static final GTRegistry.RL MEDICAL_CONDITIONS = new GTRegistry.RL<>(GTCEu.id("medical_condition")); - public static final GTRegistry.RL PLACEHOLDERS = new GTRegistry.RL<>(GTCEu.id("placeholder")); - public static final GTRegistry.RL PATTERN_ERRORS = new GTRegistry.RL<>( - GTCEu.id("pattern_errors")); - - - - public static final DeferredRegister> TRUNK_PLACER_TYPE = DeferredRegister.create(Registries.TRUNK_PLACER_TYPE, GTCEu.MOD_ID); - public static final DeferredRegister> PLACEMENT_MODIFIER = DeferredRegister.create(Registries.PLACEMENT_MODIFIER_TYPE, GTCEu.MOD_ID); - public static final DeferredRegister> GLOBAL_LOOT_MODIFIES = DeferredRegister.create(ForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, GTCEu.MOD_ID); - - // spotless:on - - public static T register(Registry registry, ResourceLocation name, T value) { - ResourceKey registryKey = registry.key(); - - if (registryKey == Registries.RECIPE_TYPE) { - ForgeRegistries.RECIPE_TYPES.register(name, (RecipeType) value); - } else if (registryKey == Registries.RECIPE_SERIALIZER) { - ForgeRegistries.RECIPE_SERIALIZERS.register(name, (RecipeSerializer) value); - } else if (registryKey == Registries.FEATURE) { - ForgeRegistries.FEATURES.register(name, (Feature) value); - } else if (registryKey == Registries.FOLIAGE_PLACER_TYPE) { - ForgeRegistries.FOLIAGE_PLACER_TYPES.register(name, (FoliagePlacerType) value); - } else if (registryKey == Registries.TRUNK_PLACER_TYPE) { - TRUNK_PLACER_TYPE.register(name.getPath(), () -> (TrunkPlacerType) value); - } else if (registryKey == Registries.PLACEMENT_MODIFIER_TYPE) { - PLACEMENT_MODIFIER.register(name.getPath(), () -> (PlacementModifierType) value); - } else { - return Registry.register(registry, name, value); - } + public static final MappedRegistry COVERS = makeRegistry(Keys.COVER); + public static final MappedRegistry MACHINES = makeRegistry(Keys.MACHINE); + public static final MappedRegistry SOUNDS = makeRegistry(Keys.SOUND); + public static final MappedRegistry DIMENSION_MARKERS = makeRegistry(Keys.DIMENSION_MARKER); + public static final MappedRegistry MEDICAL_CONDITIONS = makeRegistry(Keys.MEDICAL_CONDITION); + + public static final MappedRegistry PLACEHOLDERS = makeRegistry(Keys.PLACEHOLDER); + public static final MappedRegistry PATTERN_ERROR_TYPES = makeRegistry( + Keys.PATTERN_ERROR_TYPE); - return value; + private static ResourceKey> makeRegistryKey(ResourceLocation registryId) { + return ResourceKey.createRegistryKey(registryId); } - public static void init(IEventBus eventBus) { - TRUNK_PLACER_TYPE.register(eventBus); - PLACEMENT_MODIFIER.register(eventBus); - GLOBAL_LOOT_MODIFIES.register(eventBus); + private static MappedRegistry makeRegistry(ResourceKey> key) { + return makeRegistry(key, new MappedRegistry<>(key, Lifecycle.stable(), false)); } - private static final RegistryAccess BLANK = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); - private static RegistryAccess FROZEN = BLANK; + @SuppressWarnings("unchecked") + private static > R makeRegistry(ResourceKey> key, R registry) { + BuiltInRegistriesAccessor.gtceu$getWRITABLE_REGISTRY().register((ResourceKey>) (Object) key, registry, Lifecycle.stable()); + return registry; + } + + private static RegistryAccess FROZEN = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); /** * You shouldn't call it, you should probably not even look at it just to be extra safe @@ -148,4 +163,6 @@ private static RegistryAccess getClientRegistries() { } } } + + public static void init() {} } diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistry.java b/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistry.java index b549d41eba3..a4257359e9e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistry.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/GTRegistry.java @@ -19,12 +19,12 @@ import java.util.*; -public abstract class GTRegistry implements Iterable { +public class GTRegistry implements Iterable { - public static final Map> REGISTERED = new HashMap<>(); + public static final Map> REGISTERED = new HashMap<>(); - protected final Map keyToValue; - protected final Map valueToKey; + protected final Map keyToValue; + protected final Map valueToKey; @Getter protected final ResourceLocation registryName; @Getter @@ -38,15 +38,15 @@ public GTRegistry(ResourceLocation registryName) { REGISTERED.put(registryName, this); } - public boolean containsKey(K key) { + public boolean containsKey(ResourceLocation key) { return keyToValue.containsKey(key); } /** - * @deprecated use {@link #containsKey(Object)} (Object)} (Object)} + * @deprecated use {@link #containsKey(ResourceLocation)} (Object)} (Object)} */ @Deprecated(since = "8.0.0") - public boolean containKey(K key) { + public boolean containKey(ResourceLocation key) { return containsKey(key); } @@ -94,7 +94,7 @@ private boolean checkActiveModContainerIsGregtech() { container.getModId().equals("minecraft")); // check for minecraft modid in case of datagen or a mishap } - public T register(K key, T value) { + public T register(ResourceLocation key, T value) { if (keyToValue.containsKey(key)) { throw new IllegalStateException( "[register] registry %s contains key %s already".formatted(registryName, key)); @@ -103,7 +103,7 @@ public T register(K key, T value) { return registerOrOverride(key, value); } - public void remap(K oldKey, K newKey) { + public void remap(ResourceLocation oldKey, ResourceLocation newKey) { if (frozen) { throw new IllegalStateException("[register] registry %s has been frozen".formatted(registryName)); } @@ -121,7 +121,7 @@ public void remap(K oldKey, K newKey) { } @Nullable - public T replace(K key, T value) { + public T replace(ResourceLocation key, T value) { if (!containsKey(key)) { GTCEu.LOGGER.warn("[replace] couldn't find key {} in registry {}", registryName, key); } @@ -129,7 +129,7 @@ public T replace(K key, T value) { return registerOrOverride(key, value); } - public T registerOrOverride(K key, T value) { + public T registerOrOverride(ResourceLocation key, T value) { if (frozen) { throw new IllegalStateException("[register] registry %s has been frozen".formatted(registryName)); } @@ -149,15 +149,15 @@ public T registerOrOverride(K key, T value) { return Collections.unmodifiableMap(valueToKey).keySet(); } - public @UnmodifiableView Set keys() { + public @UnmodifiableView Set keys() { return registry().keySet(); } - public @UnmodifiableView Set> entries() { + public @UnmodifiableView Set> entries() { return registry().entrySet(); } - public @UnmodifiableView Map registry() { + public @UnmodifiableView Map registry() { return Collections.unmodifiableMap(keyToValue); } @@ -170,33 +170,48 @@ public void clear() { } @Nullable - public V get(K key) { + public V get(ResourceLocation key) { return keyToValue.get(key); } - public V getOrDefault(K key, V defaultValue) { + public V getOrDefault(ResourceLocation key, V defaultValue) { return keyToValue.getOrDefault(key, defaultValue); } - public K getKey(V value) { + public ResourceLocation getKey(V value) { return valueToKey.get(value); } - public K getOrDefaultKey(V value, K defaultKey) { + public ResourceLocation getOrDefaultKey(V value, ResourceLocation defaultKey) { return valueToKey.getOrDefault(value, defaultKey); } - public abstract void writeBuf(V value, FriendlyByteBuf buf); + public void writeBuf(V value, FriendlyByteBuf buf) { + buf.writeBoolean(containsValue(value)); + if (containsValue(value)) { + buf.writeUtf(getKey(value).toString()); + } + } - @Nullable - public abstract V readBuf(FriendlyByteBuf buf); + public V readBuf(FriendlyByteBuf buf) { + if (buf.readBoolean()) { + return get(new ResourceLocation(buf.readUtf())); + } + return null; + } - public abstract Tag saveToNBT(V value); + public Tag saveToNBT(V value) { + if (containsValue(value)) { + return StringTag.valueOf(getKey(value).toString()); + } + return new CompoundTag(); + } - @Nullable - public abstract V loadFromNBT(Tag tag); + public V loadFromNBT(Tag tag) { + return get(new ResourceLocation(tag.getAsString())); + } - public boolean remove(K name) { + public boolean remove(ResourceLocation name) { var value = keyToValue.remove(name); if (value != null) { valueToKey.remove(value); @@ -205,54 +220,13 @@ public boolean remove(K name) { return false; } - public abstract Codec codec(); - - // ************************ Built-in Registry ************************// - - public static class RL extends GTRegistry { - - public RL(ResourceLocation registryName) { - super(registryName); - } - - @Override - public void writeBuf(V value, FriendlyByteBuf buf) { - buf.writeBoolean(containsValue(value)); - if (containsValue(value)) { - buf.writeUtf(getKey(value).toString()); - } - } - - @Override - public V readBuf(FriendlyByteBuf buf) { - if (buf.readBoolean()) { - return get(new ResourceLocation(buf.readUtf())); - } - return null; - } - - @Override - public Tag saveToNBT(V value) { - if (containsValue(value)) { - return StringTag.valueOf(getKey(value).toString()); - } - return new CompoundTag(); - } - - @Override - public V loadFromNBT(Tag tag) { - return get(new ResourceLocation(tag.getAsString())); - } - - @Override - public Codec codec() { - return ResourceLocation.CODEC.flatXmap( - key -> Optional.ofNullable(this.get(key)).map(DataResult::success) - .orElseGet(() -> DataResult.error( - () -> "Unknown registry key in %s: %s".formatted(this.registryName, key))), - val -> Optional.ofNullable(this.getKey(val)).map(DataResult::success) - .orElseGet(() -> DataResult.error( - () -> "Unknown registry value in %s: %s".formatted(this.registryName, val)))); - } + public Codec codec() { + return ResourceLocation.CODEC.flatXmap( + key -> Optional.ofNullable(this.get(key)).map(DataResult::success) + .orElseGet(() -> DataResult.error( + () -> "Unknown registry key in %s: %s".formatted(this.registryName, key))), + val -> Optional.ofNullable(this.getKey(val)).map(DataResult::success) + .orElseGet(() -> DataResult.error( + () -> "Unknown registry value in %s: %s".formatted(this.registryName, val)))); } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/BuilderBase.java b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/BuilderBase.java deleted file mode 100644 index 7f771960908..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/BuilderBase.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gregtechceu.gtceu.api.registry.registrate; - -import net.minecraft.resources.ResourceLocation; - -import dev.latvian.mods.kubejs.client.LangEventJS; -import dev.latvian.mods.kubejs.generator.AssetJsonGenerator; -import dev.latvian.mods.kubejs.generator.DataJsonGenerator; -import org.jetbrains.annotations.Nullable; - -import java.util.function.Supplier; - -public abstract class BuilderBase implements Supplier { - - public ResourceLocation id; - protected T value = null; - - public BuilderBase(ResourceLocation id) { - this.id = id; - } - - public void generateDataJsons(DataJsonGenerator generator) {} - - public void generateAssetJsons(@Nullable AssetJsonGenerator generator) {} - - public void generateLang(LangEventJS lang) {} - - public abstract T register(); - - @Override - public T get() { - return value; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/GTRegistrate.java b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/GTRegistrate.java index 13461e0b085..60f7ae97793 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/GTRegistrate.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/GTRegistrate.java @@ -2,12 +2,24 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.block.MetaMachineBlock; +import com.gregtechceu.gtceu.api.block.OreBlock; import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo; +import com.gregtechceu.gtceu.api.data.chemical.Element; import com.gregtechceu.gtceu.api.data.chemical.material.Material; +import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet; +import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; +import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition; +import com.gregtechceu.gtceu.api.data.medicalcondition.Symptom; +import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.data.worldgen.IWorldGenLayer; +import com.gregtechceu.gtceu.api.data.worldgen.SimpleWorldGenLayer; import com.gregtechceu.gtceu.api.item.MetaMachineItem; import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.machine.MetaMachine; import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; +import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.registry.registrate.forge.GTFluidBuilder; import com.gregtechceu.gtceu.core.mixins.registrate.AbstractRegistrateAccessor; @@ -16,10 +28,13 @@ import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraftforge.data.event.GatherDataEvent; @@ -49,6 +64,7 @@ import java.util.IdentityHashMap; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiFunction; import java.util.function.Consumer; @@ -57,6 +73,8 @@ import javax.annotation.ParametersAreNonnullByDefault; +import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.Conditions.hasOreProperty; + @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class GTRegistrate extends AbstractRegistrate { @@ -73,6 +91,11 @@ public ResourceLocation makeResourceLocation(String path) { return new ResourceLocation(this.getModid(), path); } + @Override + public boolean isRegistered(ResourceKey> registryType) { + return super.isRegistered(registryType); + } + /** * Get or create a new {@link GTRegistrate} and register event listeners for registration and data generation. * A new {@code GTRegistrate} instance is only made if one doesn't already exist in the cache. @@ -163,24 +186,7 @@ public GTRegistrate registerEventListeners(IEventBus bus) { return this; } - protected

NoConfigBuilder createCreativeModeTab(P parent, String name, - Consumer config) { - return this.generic(parent, name, Registries.CREATIVE_MODE_TAB, () -> { - var builder = CreativeModeTab.builder() - .icon(() -> getAll(Registries.ITEM).stream().findFirst().map(ItemEntry::cast) - .map(ItemEntry::asStack).orElse(new ItemStack(Items.AIR))); - config.accept(builder); - return builder.build(); - }); - } - - public IGTFluidBuilder createFluid(String name, String langKey, Material material, ResourceLocation stillTexture, - ResourceLocation flowingTexture) { - return entry(name, - callback -> new GTFluidBuilder<>(this, this, material, name, langKey, callback, stillTexture, - flowingTexture, GTFluidBuilder::defaultFluidType).defaultLang().defaultSource() - .setData(ProviderType.LANG, NonNullBiConsumer.noop())); - } + // Machines public MachineBuilder machine(String name, Function definitionFactory, @@ -197,6 +203,8 @@ public IGTFluidBuilder createFluid(String name, String langKey, Material materia MetaMachineBlock::new, MetaMachineItem::new, blockEntityFactory); } + // Multiblock machines + public MultiblockMachineBuilder multiblock(String name, BiFunction blockFactory, BiFunction itemFactory, @@ -211,12 +219,107 @@ public IGTFluidBuilder createFluid(String name, String langKey, Material materia blockEntityFactory); } + // Recipe types + + public GTRecipeType recipeType(String name, String group, RecipeType... proxyRecipes) { + var recipeType = new GTRecipeType(GTCEu.id(name), group, proxyRecipes); + this.generic(name, GTRegistries.Keys.RECIPE_TYPE, () -> recipeType).build(); + return recipeType; + } + + // Recipe categories + + public GTRecipeCategory recipeCategory(String categoryName, GTRecipeType recipeType) { + var category = new GTRecipeCategory(categoryName, recipeType); + this.generic(categoryName, GTRegistries.Keys.RECIPE_CATEGORY, () -> category).build(); + return category; + } + + // Tag prefixes + + public TagPrefix tagPrefix(String name) { + return tagPrefix(name, false); + } + + public TagPrefix tagPrefix(String name, boolean invertedName) { + var tagPrefix = new TagPrefix(makeResourceLocation(name), invertedName); + this.generic(name.toLowerCase(), GTRegistries.Keys.TAG_PREFIX, () -> tagPrefix).register(); + return tagPrefix; + } + + public TagPrefix oreTagPrefix(String name, TagKey miningToolTag) { + return tagPrefix(name) + .defaultTagPath("ores/%s") + .prefixOnlyTagPath("ores_in_ground/%s") + .unformattedTagPath("ores") + .materialIconType(MaterialIconType.ore) + .miningToolTag(miningToolTag) + .unificationEnabled(true) + .blockConstructor(OreBlock::new) + .generationCondition(hasOreProperty); + } + + // Materials + + public Material.Builder material(String name) { + return new Material.Builder(this, makeResourceLocation(name)); + } + + // Elements + + public Element element(String name, long protons, long neutrons, long halfLifeSeconds, @Nullable String decayTo, + String symbol, boolean isIsotope) { + var element = new Element(protons, neutrons, halfLifeSeconds, decayTo, name, symbol, isIsotope); + this.generic(name.toLowerCase(), GTRegistries.Keys.ELEMENT, () -> element).register(); + return element; + } + + public Element element(long protons, long neutrons, long halfLifeSeconds, String decayTo, String name, String symbol, + boolean isIsotope) { + return element(name, protons, neutrons, halfLifeSeconds, decayTo, symbol, isIsotope); + } + + // Material icon sets + + public MaterialIconSet materialIconSet(String id) { + return materialIconSet(id, MaterialIconSet.DULL); + } + + public MaterialIconSet materialIconSet(String id, MaterialIconSet parent) { + return materialIconSet(id, parent, false); + } + + public MaterialIconSet materialIconSet(String id, @Nullable MaterialIconSet parent, boolean isRoot) { + var iconSet = new MaterialIconSet(makeResourceLocation(id), parent, isRoot); + this.generic(id, GTRegistries.Keys.MATERIAL_ICON_SET, () -> iconSet).build(); + return iconSet; + } + + // Medical conditions + + public MedicalCondition medicalCondition(String name, int color, + int maxProgression, MedicalCondition.IdleProgressionType progressionType, + float progressionRate, + boolean canBePermanent, Symptom.ConfiguredSymptom... symptoms) { + var medicalCondition = new MedicalCondition(makeResourceLocation(name), color, maxProgression, progressionType, + progressionRate, canBePermanent, symptoms); + this.generic(name, GTRegistries.Keys.MEDICAL_CONDITION, () -> medicalCondition).register(); + return medicalCondition; + } + + // Sounds + public SoundEntryBuilder sound(String name) { - return new SoundEntryBuilder(GTCEu.id(name)); + return new SoundEntryBuilder(new ResourceLocation(getModid(), name)); } - public SoundEntryBuilder sound(ResourceLocation name) { - return new SoundEntryBuilder(name); + // World gen layers + + public SimpleWorldGenLayer simpleWorldGenLayer(String id, IWorldGenLayer.RuleTestSupplier target, + Set> levels) { + var worldGenLayer = new SimpleWorldGenLayer(makeResourceLocation(id), target, levels); + this.generic(id, GTRegistries.Keys.WORLD_GEN_LAYER, () -> worldGenLayer).build(); + return worldGenLayer; } // Blocks @@ -244,6 +347,17 @@ public GTBlockBuilder block(P parent, String name, callback -> GTBlockBuilder.create(this, parent, name, callback, factory)); } + // Fluids + public IGTFluidBuilder createFluid(String name, String langKey, Material material, ResourceLocation stillTexture, + ResourceLocation flowingTexture) { + return entry(name, + callback -> new GTFluidBuilder<>(this, this, material, name, langKey, callback, stillTexture, + flowingTexture, GTFluidBuilder::defaultFluidType).defaultLang().defaultSource() + .setData(ProviderType.LANG, NonNullBiConsumer.noop())); + } + + // Creative mode tabs + private RegistryEntry currentTab; private static final Map, RegistryEntry> TAB_LOOKUP = new IdentityHashMap<>(); @@ -284,4 +398,15 @@ public

NoConfigBuilder defaultCreativeT Consumer config) { return createCreativeModeTab(parent, name, config); } + + protected

NoConfigBuilder createCreativeModeTab(P parent, String name, + Consumer config) { + return this.generic(parent, name, Registries.CREATIVE_MODE_TAB, () -> { + var builder = CreativeModeTab.builder() + .icon(() -> getAll(Registries.ITEM).stream().findFirst().map(ItemEntry::cast) + .map(ItemEntry::asStack).orElse(new ItemStack(Items.AIR))); + config.accept(builder); + return builder.build(); + }); + } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java index 38c0b42c421..7a7b8fe8f18 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MachineBuilder.java @@ -24,10 +24,8 @@ import com.gregtechceu.gtceu.client.renderer.BlockEntityWithBERModelRenderer; import com.gregtechceu.gtceu.common.data.GTRecipeModifiers; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; -import com.gregtechceu.gtceu.common.data.models.GTMachineModels; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.model.builder.MachineModelBuilder; -import com.gregtechceu.gtceu.utils.data.RuntimeBlockstateProvider; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.client.renderer.RenderType; @@ -57,16 +55,15 @@ import com.tterrag.registrate.util.nullness.NonNullBiConsumer; import com.tterrag.registrate.util.nullness.NonNullConsumer; import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; -import dev.latvian.mods.kubejs.client.LangEventJS; -import dev.latvian.mods.kubejs.generator.AssetJsonGenerator; import dev.latvian.mods.rhino.util.HideFromJS; -import dev.latvian.mods.rhino.util.RemapPrefixForJS; import it.unimi.dsi.fastutil.objects.Reference2IntMap; import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; import lombok.Getter; +import lombok.Setter; import lombok.experimental.Accessors; import lombok.experimental.Tolerate; import org.apache.commons.lang3.ArrayUtils; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -77,21 +74,23 @@ import static com.gregtechceu.gtceu.common.data.models.GTMachineModels.*; -@SuppressWarnings("unused") +@SuppressWarnings({ "unused", "UnusedReturnValue" }) @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -@RemapPrefixForJS("kjs$") @Accessors(chain = true, fluent = true) -public class MachineBuilder> - extends BuilderBase { +public class MachineBuilder> { + protected final ResourceLocation id; protected final GTRegistrate registrate; protected final String name; protected final BiFunction blockFactory; protected final BiFunction itemFactory; - protected final Function blockEntityFactory; - protected final Function definition; + @Setter(onMethod_ = @ApiStatus.Internal) + protected Function blockEntityFactory; + @Setter(onMethod_ = @ApiStatus.Internal) + protected Function definition; + @Nullable @Getter private MachineBuilder.ModelInitializer model = null; @@ -125,7 +124,7 @@ public class MachineBuilder itemColor = ((itemStack, tintIndex) -> tintIndex == 2 ? GTValues.VC[tier] : tintIndex == 1 ? paintingColor : -1); private PartAbility[] abilities = new PartAbility[0]; - private final List tooltips = new ArrayList<>(); + private final List> tooltips = new ArrayList<>(); @Nullable private BiConsumer> tooltipBuilder; private RecipeModifier recipeModifier = new RecipeModifierList(GTRecipeModifiers.OC_NON_PERFECT); @@ -160,7 +159,7 @@ public MachineBuilder(GTRegistrate registrate, String name, BiFunction blockFactory, BiFunction itemFactory, Function blockEntityFactory) { - super(new ResourceLocation(registrate.getModid(), name)); + this.id = new ResourceLocation(registrate.getModid(), name); this.registrate = registrate; this.name = name; this.blockFactory = blockFactory; @@ -174,7 +173,7 @@ public TYPE getThis() { return (TYPE) this; } - public TYPE blockModel(NonNullBiConsumer, GTBlockstateProvider> blockModel) { + public TYPE blockModel(@Nullable NonNullBiConsumer, GTBlockstateProvider> blockModel) { this.blockModel = blockModel; return getThis(); } @@ -219,12 +218,12 @@ public TYPE itemProp(NonNullUnaryOperator itemProp) { return getThis(); } - public TYPE blockBuilder(Consumer> blockBuilder) { + public TYPE blockBuilder(@Nullable Consumer> blockBuilder) { this.blockBuilder = blockBuilder; return getThis(); } - public TYPE itemBuilder(Consumer> itemBuilder) { + public TYPE itemBuilder(@Nullable Consumer> itemBuilder) { this.itemBuilder = itemBuilder; return getThis(); } @@ -254,7 +253,7 @@ public TYPE itemColor(BiFunction itemColor) { return getThis(); } - public TYPE tooltipBuilder(BiConsumer> tooltipBuilder) { + public TYPE tooltipBuilder(@Nullable BiConsumer> tooltipBuilder) { this.tooltipBuilder = tooltipBuilder; return getThis(); } @@ -294,17 +293,17 @@ public TYPE allowCoverOnFront(boolean allowCoverOnFront) { return getThis(); } - public TYPE appearance(Supplier appearance) { + public TYPE appearance(@Nullable Supplier appearance) { this.appearance = appearance; return getThis(); } - public TYPE ui(PanelFactory ui) { + public TYPE ui(@Nullable PanelFactory ui) { this.ui = ui; return getThis(); } - public TYPE langValue(String langValue) { + public TYPE langValue(@Nullable String langValue) { this.langValue = langValue; return getThis(); } @@ -351,7 +350,7 @@ protected void initRecipeMachineModelProperties(GTRecipeType type) { } } - public TYPE model(MachineBuilder.ModelInitializer model) { + public TYPE model(@Nullable MachineBuilder.ModelInitializer model) { this.model = model; return getThis(); } @@ -495,7 +494,14 @@ public TYPE tooltips(@Nullable Component... components) { } public TYPE tooltips(List components) { - tooltips.addAll(components.stream().filter(Objects::nonNull).toList()); + tooltips.addAll( + components.stream().filter(Objects::nonNull).map(c -> (Supplier) (() -> c)).toList()); + return getThis(); + } + + @SafeVarargs + public final TYPE tooltips(Supplier... componentSuppliers) { + tooltips.addAll(List.of(componentSuppliers)); return getThis(); } @@ -504,8 +510,12 @@ public TYPE conditionalTooltip(Component component, BooleanSupplier condition) { } public TYPE conditionalTooltip(Component component, boolean condition) { - if (condition) - tooltips.add(component); + if (condition) tooltips.add(() -> component); + return getThis(); + } + + public TYPE conditionalTooltip(Supplier component, boolean condition) { + if (condition) tooltips.add(component); return getThis(); } @@ -534,22 +544,6 @@ public > TYPE modelProperty(Property property, return getThis(); } - // KJS helpers for model property defaults - // These don't need to be copied to the multiblock builder because KJS doesn't care about the return type downgrade - - public TYPE kjs$modelPropertyBool(Property property, boolean defaultValue) { - return modelProperty(property, defaultValue); - } - - public TYPE kjs$modelPropertyInt(Property property, int defaultValue) { - return modelProperty(property, defaultValue); - } - - public & Comparable> TYPE kjs$modelPropertyEnum(Property property, - T defaultValue) { - return modelProperty(property, defaultValue); - } - @Tolerate public TYPE modelProperties(Property... properties) { return this.modelProperties(List.of(properties)); @@ -622,20 +616,6 @@ protected DEFINITION createDefinition() { return definition.apply(new ResourceLocation(registrate.getModid(), name)); } - @Override - public void generateAssetJsons(@Nullable AssetJsonGenerator generator) { - super.generateAssetJsons(generator); - KJSCallWrapper.generateAssetJsons(generator, this, this.value); - } - - @Override - public void generateLang(LangEventJS lang) { - super.generateLang(lang); - if (langValue() != null) { - lang.add(GTCEu.MOD_ID, value.getDescriptionId(), value.getLangValue()); - } - } - @SuppressWarnings({ "unchecked", "rawtypes" }) protected void setupStateDefinition(MachineDefinition definition) { StateDefinition.Builder builder = new StateDefinition.Builder<>( @@ -655,6 +635,7 @@ protected void setupStateDefinition(MachineDefinition definition) { @HideFromJS public DEFINITION register() { this.registrate.object(name); + var definition = createDefinition(); definition.setRotationState(rotationState); @@ -700,7 +681,7 @@ public DEFINITION register() { definition.setRecipeOutputLimits(recipeOutputLimits); definition.setBlockEntityTypeSupplier(blockEntity::get); definition.setTooltipBuilder((itemStack, components) -> { - components.addAll(tooltips); + components.addAll(tooltips.stream().map(Supplier::get).toList()); if (tooltipBuilder != null) tooltipBuilder.accept(itemStack, components); }); definition.setRecipeModifier(recipeModifier); @@ -726,8 +707,10 @@ public DEFINITION register() { definition.setDefaultPaintingColor(paintingColor); definition.setRenderXEIPreview(renderMultiblockXEIPreview); definition.setRenderWorldPreview(renderMultiblockWorldPreview); - GTRegistries.MACHINES.register(definition.getId(), definition); - return value = definition; + + this.registrate.generic(definition.getId().getPath(), GTRegistries.Keys.MACHINE, () -> definition).register(); + + return definition; } @FunctionalInterface @@ -805,28 +788,4 @@ protected static class ItemBuilderWrapper { } } // spotless:on - - protected static final class KJSCallWrapper { - - public static void generateAssetJsons(@Nullable AssetJsonGenerator generator, - MachineBuilder builder, - D definition) { - if (builder.model() == null && builder.blockModel() == null) return; - - final ResourceLocation id = definition.getId(); - // if generator is null, we're making the block models through GT - if (generator == null) { - // Fake a data provider for the GT model builders - var context = new DataGenContext<>(definition::getBlock, definition.getName(), id); - if (builder.blockModel() != null) { - builder.blockModel().accept(context, RuntimeBlockstateProvider.INSTANCE); - } else { - GTMachineModels.createMachineModel(builder.model()) - .accept(context, RuntimeBlockstateProvider.INSTANCE); - } - } else { - generator.itemModel(id, gen -> gen.parent(id.withPrefix("block/machine/").toString())); - } - } - } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MultiblockMachineBuilder.java b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MultiblockMachineBuilder.java index 7f7c3f287f1..05d2577f8fb 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MultiblockMachineBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/MultiblockMachineBuilder.java @@ -26,6 +26,7 @@ import lombok.experimental.Accessors; import lombok.experimental.Tolerate; import org.apache.commons.lang3.function.TriFunction; +import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.function.*; @@ -39,7 +40,7 @@ public class MultiblockMachineBuilder> extends MachineBuilder { private boolean generator; - private Map> patterns; + private final Map> patterns; private boolean allowFlip = true; private final List> recoveryItems = new ArrayList<>(); private Function> partSorter = (c) -> (a, b) -> 0; @@ -86,7 +87,7 @@ public TYPE partSorter(Function partAppearance) { + public TYPE partAppearance(@Nullable TriFunction partAppearance) { this.partAppearance = partAppearance; return getThis(); } @@ -136,6 +137,6 @@ public DEFINITION register() { } definition.setPartAppearance(partAppearance); definition.setAdditionalDisplay(additionalDisplay); - return value = definition; + return definition; } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/SoundEntryBuilder.java b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/SoundEntryBuilder.java index 26cb40fb445..07f5615814a 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/SoundEntryBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/api/registry/registrate/SoundEntryBuilder.java @@ -11,11 +11,13 @@ import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import com.google.gson.JsonObject; +import com.mojang.serialization.Lifecycle; import java.nio.file.Path; import java.util.*; @@ -118,7 +120,9 @@ public SoundEntry build() { SoundEntry entry = wrappedEvents.isEmpty() ? new CustomSoundEntry(id, variants, subtitle, category, attenuationDistance) : new WrappedSoundEntry(id, subtitle, wrappedEvents, category, attenuationDistance); - GTRegistries.SOUNDS.register(entry.getId(), entry); + GTRegistries.SOUNDS.unfreeze(); + GTRegistries.SOUNDS.register(ResourceKey.create(GTRegistries.Keys.SOUND, entry.getId()), entry, + Lifecycle.stable()); return entry; } } diff --git a/src/main/java/com/gregtechceu/gtceu/api/sync_system/data_transformers/ValueTransformers.java b/src/main/java/com/gregtechceu/gtceu/api/sync_system/data_transformers/ValueTransformers.java index 1ccd8ea1767..5b46ac9210d 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/sync_system/data_transformers/ValueTransformers.java +++ b/src/main/java/com/gregtechceu/gtceu/api/sync_system/data_transformers/ValueTransformers.java @@ -14,6 +14,7 @@ import com.gregtechceu.gtceu.common.machine.multiblock.electric.monitor.MonitorGroup; import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.*; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; @@ -187,7 +188,7 @@ public static void registerGenericTransformerSupplier(Class type, Supplie registerTransformer(GTRecipe.class, new GTRecipeTransformer()); registerTransformer(MachineRenderState.class, new CodecTransformer<>(MachineRenderState.CODEC)); registerTransformer(GTRecipeType.class, new ResourceLocationReferenceTransformer<>( - GTRecipeType::getRegistryName, GTRegistries.RECIPE_TYPES::get)); + GTRecipeType::getRegistryName, (r) -> (GTRecipeType) BuiltInRegistries.RECIPE_TYPE.get(r))); registerTransformer(Material.class, new ResourceLocationReferenceTransformer<>( Material::getResourceLocation, GTRegistries.MATERIALS::get)); registerTransformer(MonitorGroup.class, new MonitorGroupTransformer()); diff --git a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java index 1ba4c54baa4..ec0819f3e27 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/client/ClientProxy.java @@ -131,8 +131,8 @@ public void onRegisterEntityRenderers(EntityRenderersEvent.RegisterRenderers eve event.registerEntityRenderer(GTEntityTypes.POWDERBARREL.get(), GTExplosiveRenderer::new); event.registerEntityRenderer(GTEntityTypes.INDUSTRIAL_TNT.get(), GTExplosiveRenderer::new); - event.registerBlockEntityRenderer(GTBlockEntities.GT_SIGN.get(), SignRenderer::new); - event.registerBlockEntityRenderer(GTBlockEntities.GT_HANGING_SIGN.get(), HangingSignRenderer::new); + event.registerBlockEntityRenderer(GTSignBlockEntities.GT_SIGN.get(), SignRenderer::new); + event.registerBlockEntityRenderer(GTSignBlockEntities.GT_HANGING_SIGN.get(), HangingSignRenderer::new); event.registerEntityRenderer(GTEntityTypes.BOAT.get(), c -> new GTBoatRenderer(c, false)); event.registerEntityRenderer(GTEntityTypes.CHEST_BOAT.get(), c -> new GTBoatRenderer(c, true)); diff --git a/src/main/java/com/gregtechceu/gtceu/client/model/machine/MachineRenderState.java b/src/main/java/com/gregtechceu/gtceu/client/model/machine/MachineRenderState.java index ec43fff974f..807e7879808 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/model/machine/MachineRenderState.java +++ b/src/main/java/com/gregtechceu/gtceu/client/model/machine/MachineRenderState.java @@ -13,7 +13,7 @@ public class MachineRenderState extends StateHolder { - public static final Codec CODEC = codec(GTRegistries.MACHINES.codec(), + public static final Codec CODEC = codec(GTRegistries.MACHINES.byNameCodec(), MachineDefinition::defaultRenderState).stable(); public MachineRenderState(MachineDefinition owner, ImmutableMap, Comparable> values, diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/BlockHighlightRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/BlockHighlightRenderer.java index a0d16707aaa..126abe8dc93 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/BlockHighlightRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/BlockHighlightRenderer.java @@ -78,7 +78,7 @@ public static void renderBlockHighlight(PoseStack poseStack, Camera camera, Bloc public @Nullable UITexture sideTips(@NotNull Player player, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull Set toolTypes, - @NotNull Direction side) { + @NotNull ItemStack held, @NotNull Direction side) { return behavior.showSideTip(state, side) ? GTGuiTextures.TOOL_FRONT_FACING_ROTATION : null; } @@ -93,10 +93,10 @@ public static void renderBlockHighlight(PoseStack poseStack, Camera camera, Bloc if (gridHighlight.shouldRenderGrid(player, blockPos, state, held, toolType)) { final IToolGridHighlight finalGridHighlight = gridHighlight; drawGridOverlays(poseStack, multiBufferSource, cameraPos, target, - side -> finalGridHighlight.sideTips(player, blockPos, state, toolType, side)); + side -> finalGridHighlight.sideTips(player, blockPos, state, toolType, held, side)); } else { Direction facing = target.getDirection(); - var texture = gridHighlight.sideTips(player, blockPos, state, toolType, facing); + var texture = gridHighlight.sideTips(player, blockPos, state, toolType, held, facing); if (texture != null) { RenderSystem.disableDepthTest(); RenderSystem.enableBlend(); diff --git a/src/main/java/com/gregtechceu/gtceu/client/renderer/block/OreBlockRenderer.java b/src/main/java/com/gregtechceu/gtceu/client/renderer/block/OreBlockRenderer.java index 212b227419f..a26c355b3b9 100644 --- a/src/main/java/com/gregtechceu/gtceu/client/renderer/block/OreBlockRenderer.java +++ b/src/main/java/com/gregtechceu/gtceu/client/renderer/block/OreBlockRenderer.java @@ -73,7 +73,7 @@ public static void reinitModels() { ResourceLocation blockId = BuiltInRegistries.BLOCK.getKey(model.block); ResourceLocation modelId = iconSet.id.withPath(ORE_MODEL_NAME_FORMAT - .formatted(iconSet.getName(), tagPrefix.name, iconType.name())); + .formatted(iconSet.getName(), tagPrefix.getName(), iconType.name())); GTDynamicResourcePack.addBlockState(blockId, BlockModelGenerators.createSimpleBlock(model.block, modelId)); GTDynamicResourcePack.addItemModel(BuiltInRegistries.ITEM.getKey(model.block.asItem()), @@ -92,7 +92,7 @@ protected static void copyOreModelWithBaseStone(TagPrefix tagPrefix, TagPrefix.O original = TEMPLATE_MODEL_CACHE.apply(iconType, iconSet); } catch (RuntimeException e) { GTCEu.LOGGER.error("Could not load template block model for ore type {}, icon type '{}', icon set '{}'", - tagPrefix.name, iconType.name(), iconSet.id, e); + tagPrefix.getName(), iconType.name(), iconSet.id, e); return; } if (original == NULL_ELEMENT_MARKER) { @@ -109,7 +109,8 @@ protected static void copyOreModelWithBaseStone(TagPrefix tagPrefix, TagPrefix.O GTDynamicResourcePack.addBlockModel( iconSet.id - .withPath(ORE_MODEL_NAME_FORMAT.formatted(iconSet.getName(), tagPrefix.name, iconType.name())), + .withPath(ORE_MODEL_NAME_FORMAT.formatted(iconSet.getName(), tagPrefix.getName(), + iconType.name())), newJson); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/CommonEventListener.java b/src/main/java/com/gregtechceu/gtceu/common/CommonEventListener.java index bfc74d6e9a3..d475d62c7de 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/CommonEventListener.java +++ b/src/main/java/com/gregtechceu/gtceu/common/CommonEventListener.java @@ -101,8 +101,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import static com.gregtechceu.gtceu.utils.FormattingUtil.toLowerCaseUnderscore; - @Mod.EventBusSubscriber(modid = GTCEu.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class CommonEventListener { @@ -660,9 +658,9 @@ public static void remapIds(MissingMappingsEvent event) { } }); - for (TagPrefix prefix : TagPrefix.values()) { - String first = prefix.invertedName ? toLowerCaseUnderscore(prefix.name) : "(.+?)"; - String last = prefix.invertedName ? "(.+?)" : toLowerCaseUnderscore(prefix.name); + for (TagPrefix prefix : GTRegistries.TAG_PREFIXES) { + String first = prefix.invertedName ? prefix.getName() : "(.+?)"; + String last = prefix.invertedName ? "(.+?)" : prefix.getName(); Pattern idPattern = Pattern.compile(first + "_" + last); event.getMappings(Registries.BLOCK, GTCEu.MOD_ID).forEach(mapping -> { Matcher matcher = idPattern.matcher(mapping.getKey().getPath()); diff --git a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java index 8904d0ba326..0993b4fde1d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java +++ b/src/main/java/com/gregtechceu/gtceu/common/CommonProxy.java @@ -7,14 +7,18 @@ import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.api.capability.GTCapability; import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; -import com.gregtechceu.gtceu.api.data.chemical.material.event.MaterialEvent; import com.gregtechceu.gtceu.api.data.chemical.material.event.PostMaterialEvent; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; import com.gregtechceu.gtceu.api.data.worldgen.WorldGenLayers; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; +import com.gregtechceu.gtceu.api.data.worldgen.bedrockore.BedrockOreDefinition; import com.gregtechceu.gtceu.api.data.worldgen.generator.IndicatorGenerators; import com.gregtechceu.gtceu.api.data.worldgen.generator.VeinGenerators; +import com.gregtechceu.gtceu.api.data.worldgen.modifier.GTPlacementModifiers; +import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.mui.factory.CoverUIFactory; import com.gregtechceu.gtceu.api.mui.factory.MachineUIFactory; import com.gregtechceu.gtceu.api.multiblock.error.GTPatternErrors; @@ -25,9 +29,9 @@ import com.gregtechceu.gtceu.api.recipe.lookup.ingredient.item.*; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate; +import com.gregtechceu.gtceu.client.model.machine.MachineRenderState; import com.gregtechceu.gtceu.common.data.*; import com.gregtechceu.gtceu.common.data.GTPlaceholders; -import com.gregtechceu.gtceu.common.data.machines.GTMachineUtils; import com.gregtechceu.gtceu.common.data.materials.AlloyBlastPropertyAddition; import com.gregtechceu.gtceu.common.data.materials.GTFoods; import com.gregtechceu.gtceu.common.item.tool.rotation.CustomBlockRotations; @@ -47,13 +51,13 @@ import com.gregtechceu.gtceu.integration.cctweaked.CCTweakedPlugin; import com.gregtechceu.gtceu.integration.create.GTCreateIntegration; import com.gregtechceu.gtceu.integration.kjs.GTCEuStartupEvents; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.integration.kjs.events.MaterialModificationEventJS; import com.gregtechceu.gtceu.integration.map.WaypointManager; import com.gregtechceu.gtceu.utils.input.KeyBind; import com.gregtechceu.gtceu.utils.input.SyncedKeyMappings; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.repository.Pack; import net.minecraft.world.item.ItemStack; @@ -64,6 +68,7 @@ import net.minecraftforge.common.crafting.PartialNBTIngredient; import net.minecraftforge.common.crafting.StrictNBTIngredient; import net.minecraftforge.event.AddPackFindersEvent; +import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fluids.FluidStack; @@ -71,6 +76,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.DataPackRegistryEvent; import net.minecraftforge.registries.RegisterEvent; import brachy.modularui.factory.GuiManager; @@ -82,6 +88,8 @@ import java.util.List; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; + public class CommonProxy { public CommonProxy() { @@ -102,89 +110,73 @@ public CommonProxy() { ConfigHolder.INSTANCE.compat.energy.enableFEConverters = true; } - GTValueProviderTypes.init(eventBus); - GTRegistries.init(eventBus); - GTFeatures.init(eventBus); - GTCommandArguments.init(eventBus); - GTMobEffects.init(eventBus); - GTParticleTypes.init(eventBus); - + REGISTRATE.registerEventListeners(eventBus); + init(eventBus); eventBus.addListener(AlloyBlastPropertyAddition::addAlloyBlastProperties); } - public static void init() { + public static void init(IEventBus modBus) { GTCEu.LOGGER.info("GTCEu common proxy init!"); GTNetwork.init(); + ConfigHolder.init(); // Initialize the model generator before any content is loaded so machine models can use the generated data GregTechDatagen.initPre(); - GTRecipeCapabilities.init(); - GTRecipeConditions.init(); + GTValueProviderTypes.init(modBus); + GTFeatures.init(modBus); + GTPlacementModifiers.init(modBus); + GTCommandArguments.init(modBus); + GTMobEffects.init(modBus); + GTParticleTypes.init(modBus); + GTPlaceholders.init(modBus); + GTPatternErrors.init(modBus); + + GTCreativeModeTabs.init(); + GTRecipeCapabilities.init(modBus); + GTRecipeConditions.init(modBus); GTToolTiers.init(); GTElements.init(); MaterialIconSet.init(); MaterialIconType.init(); - initMaterials(); + GTMaterials.init(); GTMedicalConditions.init(); TagPrefix.init(); GTSoundEntries.init(); GTDamageTypes.init(); - GTPlaceholders.init(); + GTPlaceholders.init(modBus); if (ConfigHolder.INSTANCE.compat.createCompat && GTCEu.Mods.isCreateLoaded()) { - GTCreateIntegration.init(); + GTCreateIntegration.init(modBus); } - GTCovers.init(); + GTCovers.init(modBus); GTCreativeModeTabs.init(); - IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); GTMenuTypes.init(modBus); GTBlocks.init(); - GTFluids.init(); GTEntityTypes.init(); - GTBlockEntities.init(); - GTRecipeTypes.init(); + GTSignBlockEntities.init(); + GTRecipeTypes.init(modBus); GTRecipeCategories.init(); - GTPatternErrors.init(); - GTMachineUtils.init(); + GTPatternErrors.init(modBus); GTMachines.init(); GTFoods.init(); GTItems.init(); - GTDimensionMarkers.init(); - ChanceLogic.init(); + GTDimensionMarkers.init(modBus); + ChanceLogic.init(modBus); WaypointManager.init(); AddonFinder.getAddons().forEach(IGTAddon::initializeAddon); GregTechDatagen.initPost(); // Register all material manager registries, for materials with mod ids. - GTRegistries.MATERIALS.getUsedNamespaces().forEach(namespace -> { - // Force the material lang generator to be at index 0, so that addons' lang generators can override it. - var registrate = GTRegistrate.createIgnoringListenerErrors(namespace); - AbstractRegistrateAccessor accessor = (AbstractRegistrateAccessor) registrate; - if (accessor.getDoDatagen().get()) { - // noinspection UnstableApiUsage - List> providers = Multimaps.asMap(accessor.getDatagens()) - .get(ProviderType.LANG); - NonNullConsumer generator = (provider) -> MaterialLangGenerator - .generate((RegistrateLangProvider) provider, namespace); - if (providers == null) { - accessor.getDatagens().put(ProviderType.LANG, generator); - } else { - providers.add(0, generator); - } - } - }); WorldGenLayers.init(); VeinGenerators.registerAddonGenerators(); IndicatorGenerators.registerAddonGenerators(); - GTFeatures.init(); - GTFeatures.register(); CustomBlockRotations.init(); KeyBind.init(); SyncedKeyMappings.init(); @@ -195,46 +187,99 @@ public static void init() { FusionReactorMachine.registerFusionTier(GTValues.UV, " (MKIII)"); } - @SubscribeEvent - public void preInit(FMLConstructModEvent event) {} - - private static void initMaterials() { - // First, register CEu Materials - GTRegistries.MATERIALS.unfreeze(); - GTCEu.LOGGER.info("Registering GTCEu Materials"); - GTMaterials.init(); + // Fire post material events after all other material registry events. + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onRegisterLowest(RegisterEvent event) { + if (event.getRegistryKey() == GTRegistries.Keys.MATERIAL) { + // Fire Post-Material event, intended for when Materials need to be iterated over in-full before freezing + // Block entirely new Materials from being added in the Post event + GTCEu.LOGGER.info("Firing material register late event"); + GTRegistries.MATERIALS.closeRegistry(); + ModLoader.get().postEventWrapContainerInModOrder(new PostMaterialEvent()); + if (GTCEu.Mods.isKubeJSLoaded()) { + KJSEventWrapper.materialModification(); + } - // Then, register addon Materials - GTCEu.LOGGER.info("Registering addon Materials"); - MaterialEvent materialEvent = new MaterialEvent(); - ModLoader.get().postEvent(materialEvent); - if (GTCEu.Mods.isKubeJSLoaded()) { - KJSEventWrapper.materialRegistry(); + GTRegistries.MATERIALS.getUsedNamespaces().forEach(namespace -> { + // Force the material lang generator to be at index 0, so that addons' lang generators can override it. + var registrate = GTRegistrate.createIgnoringListenerErrors(namespace); + AbstractRegistrateAccessor accessor = (AbstractRegistrateAccessor) registrate; + if (accessor.getDoDatagen().get()) { + // noinspection UnstableApiUsage + List> providers = Multimaps + .asMap(accessor.getDatagens()) + .get(ProviderType.LANG); + NonNullConsumer generator = (provider) -> MaterialLangGenerator + .generate((RegistrateLangProvider) provider, namespace); + if (providers == null) { + accessor.getDatagens().put(ProviderType.LANG, generator); + } else { + providers.add(0, generator); + } + } + }); + } else if (event.getRegistryKey() == GTRegistries.Keys.MACHINE) { + // Prepare machine render states after all machines have been registered + for (MachineDefinition machine : GTRegistries.MACHINES) { + for (MachineRenderState renderState : machine.getStateDefinition().getPossibleStates()) { + MachineDefinition.RENDER_STATE_REGISTRY.add(renderState); + } + } } + } - // Fire Post-Material event, intended for when Materials need to be iterated over in-full before freezing - // Block entirely new Materials from being added in the Post event - GTRegistries.MATERIALS.closeRegistry(); - ModLoader.get().postEvent(new PostMaterialEvent()); - if (GTCEu.Mods.isKubeJSLoaded()) { - KJSEventWrapper.materialModification(); + @SubscribeEvent(priority = EventPriority.LOW) + public void registerMaterialContent(RegisterEvent event) { + if (event.getRegistryKey() == Registries.BLOCK) { + GTCEu.LOGGER.info("Firing block register late event"); + + // Material Blocks + REGISTRATE.creativeModeTab(GTCreativeModeTabs.MATERIAL_BLOCK); + GTMaterialBlocks.generateMaterialBlocks(); // Compressed Blocks + GTMaterialBlocks.generateOreBlocks(); // Ore Blocks + GTMaterialBlocks.generateOreIndicators(); // Ore Indicators + + // Material Pipes/Wires + REGISTRATE.creativeModeTab(GTCreativeModeTabs.MATERIAL_PIPE); + GTMaterialBlocks.generateCableBlocks(); // Cable & Wire Blocks + GTMaterialBlocks.generateFluidPipeBlocks(); // Fluid Pipe Blocks + GTMaterialBlocks.generateItemPipeBlocks(); // Item Pipe Blocks + + GTMaterialBlocks.finaliseMaterialBlocks(); + + } else if (event.getRegistryKey() == Registries.ITEM) { + GTCEu.LOGGER.info("Firing item register late event"); + + // Material Items & Tools + GTMaterialItems.generateMaterialItems(); + GTMaterialItems.generateTools(); + GTMaterialItems.generateArmors(); + + } else if (event.getRegistryKey() == Registries.FLUID) { + GTFluids.init(); + } else if (event.getRegistryKey() == Registries.BLOCK_ENTITY_TYPE) { + GTBlockEntities.init(); } - - // Freeze Material Registry before processing Items, Blocks, and Fluids - GTRegistries.MATERIALS.freeze(); - /* End Material Registration */ } @SubscribeEvent - public void register(RegisterEvent event) { + public void preInit(FMLConstructModEvent event) {} + + @SubscribeEvent + public void onRegister(RegisterEvent event) { if (event.getRegistryKey().equals(BuiltInRegistries.LOOT_FUNCTION_TYPE.key())) - ChestGenHooks.RandomWeightLootFunction.init(); + event.register(Registries.LOOT_FUNCTION_TYPE, GTCEu.id("random_weight"), + () -> ChestGenHooks.RandomWeightLootFunction.TYPE); } @SubscribeEvent - public void modConstruct(FMLConstructModEvent event) { - // this is done to delay initialization of content to be after KJS has set up. - event.enqueueWork(CommonProxy::init); + public static void registerDataPackRegistries(DataPackRegistryEvent.NewRegistry event) { + event.dataPackRegistry(GTRegistries.Keys.ORE_VEIN, + GTOreDefinition.CODEC, GTOreDefinition.CODEC); + event.dataPackRegistry(GTRegistries.Keys.BEDROCK_FLUID, + BedrockFluidDefinition.FULL_CODEC, BedrockFluidDefinition.FULL_CODEC); + event.dataPackRegistry(GTRegistries.Keys.BEDROCK_ORE, + BedrockOreDefinition.FULL_CODEC, BedrockOreDefinition.FULL_CODEC); } @SubscribeEvent @@ -318,10 +363,6 @@ public void registerPackFinders(AddPackFindersEvent event) { public static final class KJSEventWrapper { - public static void materialRegistry() { - GTRegistryInfo.registerFor(GTRegistries.MATERIALS.getRegistryName()); - } - public static void materialModification() { GTCEuStartupEvents.MATERIAL_MODIFICATION.post(new MaterialModificationEventJS()); } diff --git a/src/main/java/com/gregtechceu/gtceu/common/block/GTCeilingHangingSignBlock.java b/src/main/java/com/gregtechceu/gtceu/common/block/GTCeilingHangingSignBlock.java index cda54218570..049975c0695 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/block/GTCeilingHangingSignBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/common/block/GTCeilingHangingSignBlock.java @@ -1,7 +1,7 @@ package com.gregtechceu.gtceu.common.block; import com.gregtechceu.gtceu.common.blockentity.GTHangingSignBlockEntity; -import com.gregtechceu.gtceu.common.data.GTBlockEntities; +import com.gregtechceu.gtceu.common.data.GTSignBlockEntities; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; @@ -23,13 +23,13 @@ public GTCeilingHangingSignBlock(Properties properties, WoodType type) { @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - return new GTHangingSignBlockEntity(GTBlockEntities.GT_HANGING_SIGN.get(), pos, state); + return new GTHangingSignBlockEntity(GTSignBlockEntities.GT_HANGING_SIGN.get(), pos, state); } @Nullable @Override public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { - return createTickerHelper(blockEntityType, GTBlockEntities.GT_HANGING_SIGN.get(), SignBlockEntity::tick); + return createTickerHelper(blockEntityType, GTSignBlockEntities.GT_HANGING_SIGN.get(), SignBlockEntity::tick); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/block/GTStandingSignBlock.java b/src/main/java/com/gregtechceu/gtceu/common/block/GTStandingSignBlock.java index c1c73cf49b4..f67f019a7a6 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/block/GTStandingSignBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/common/block/GTStandingSignBlock.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.common.block; -import com.gregtechceu.gtceu.common.data.GTBlockEntities; +import com.gregtechceu.gtceu.common.data.GTSignBlockEntities; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; @@ -22,13 +22,13 @@ public GTStandingSignBlock(Properties properties, WoodType type) { @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - return new SignBlockEntity(GTBlockEntities.GT_SIGN.get(), pos, state); + return new SignBlockEntity(GTSignBlockEntities.GT_SIGN.get(), pos, state); } @Nullable @Override public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { - return createTickerHelper(blockEntityType, GTBlockEntities.GT_SIGN.get(), SignBlockEntity::tick); + return createTickerHelper(blockEntityType, GTSignBlockEntities.GT_SIGN.get(), SignBlockEntity::tick); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/block/GTWallHangingSignBlock.java b/src/main/java/com/gregtechceu/gtceu/common/block/GTWallHangingSignBlock.java index 328fbb51281..015887cd7a6 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/block/GTWallHangingSignBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/common/block/GTWallHangingSignBlock.java @@ -1,7 +1,7 @@ package com.gregtechceu.gtceu.common.block; import com.gregtechceu.gtceu.common.blockentity.GTHangingSignBlockEntity; -import com.gregtechceu.gtceu.common.data.GTBlockEntities; +import com.gregtechceu.gtceu.common.data.GTSignBlockEntities; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; @@ -23,13 +23,13 @@ public GTWallHangingSignBlock(Properties properties, WoodType type) { @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - return new GTHangingSignBlockEntity(GTBlockEntities.GT_HANGING_SIGN.get(), pos, state); + return new GTHangingSignBlockEntity(GTSignBlockEntities.GT_HANGING_SIGN.get(), pos, state); } @Nullable @Override public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { - return createTickerHelper(blockEntityType, GTBlockEntities.GT_HANGING_SIGN.get(), SignBlockEntity::tick); + return createTickerHelper(blockEntityType, GTSignBlockEntities.GT_HANGING_SIGN.get(), SignBlockEntity::tick); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/block/GTWallSignBlock.java b/src/main/java/com/gregtechceu/gtceu/common/block/GTWallSignBlock.java index a400ec7df65..38687c3ef3d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/block/GTWallSignBlock.java +++ b/src/main/java/com/gregtechceu/gtceu/common/block/GTWallSignBlock.java @@ -1,6 +1,6 @@ package com.gregtechceu.gtceu.common.block; -import com.gregtechceu.gtceu.common.data.GTBlockEntities; +import com.gregtechceu.gtceu.common.data.GTSignBlockEntities; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; @@ -22,13 +22,13 @@ public GTWallSignBlock(Properties properties, WoodType type) { @Override public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { - return new SignBlockEntity(GTBlockEntities.GT_SIGN.get(), pos, state); + return new SignBlockEntity(GTSignBlockEntities.GT_SIGN.get(), pos, state); } @Nullable @Override public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { - return createTickerHelper(blockEntityType, GTBlockEntities.GT_SIGN.get(), SignBlockEntity::tick); + return createTickerHelper(blockEntityType, GTSignBlockEntities.GT_SIGN.get(), SignBlockEntity::tick); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/commands/GTCommands.java b/src/main/java/com/gregtechceu/gtceu/common/commands/GTCommands.java index dbf4d511217..d746fe93e2f 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/commands/GTCommands.java +++ b/src/main/java/com/gregtechceu/gtceu/common/commands/GTCommands.java @@ -94,7 +94,7 @@ public static void register(CommandDispatcher dispatcher, Co GTOreLoader.FOLDER)))) .then(literal("place_vein") .requires(ctx -> ctx.hasPermission(LEVEL_GAMEMASTERS)) - .then(argument("vein", GTRegistryArgument.registry(GTRegistries.ORE_VEINS, ResourceLocation.class)) + .then(argument("vein", GTRegistryArgument.registry(GTRegistries.ORE_VEINS)) .executes(context -> { return GTCommands.placeVein(context, BlockPos.containing(context.getSource().getPosition())); }) @@ -298,7 +298,7 @@ private static int setActiveCape(CommandSourceStack source, ServerPlayer player, } private static int dumpDataRegistry(CommandContext context, - GTRegistry registry, Codec codec, String folder) { + GTRegistry registry, Codec codec, String folder) { Path parent = GTCEu.GTCEU_FOLDER.resolve("dumped/data"); var ops = RegistryOps.create(JsonOps.INSTANCE, context.getSource().registryAccess()); int dumpedCount = 0; diff --git a/src/main/java/com/gregtechceu/gtceu/common/commands/HazardCommands.java b/src/main/java/com/gregtechceu/gtceu/common/commands/HazardCommands.java index 91d3d67dc6f..b7470613ba9 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/commands/HazardCommands.java +++ b/src/main/java/com/gregtechceu/gtceu/common/commands/HazardCommands.java @@ -2,32 +2,40 @@ import com.gregtechceu.gtceu.api.data.chemical.material.properties.HazardProperty; import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.capability.EnvironmentalHazardSavedData; import com.gregtechceu.gtceu.common.capability.LocalizedHazardSavedData; -import com.gregtechceu.gtceu.common.commands.arguments.MedicalConditionArgument; +import com.gregtechceu.gtceu.core.mixins.ResourceKeyArgumentAccessor; import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.ResourceKeyArgument; import net.minecraft.commands.arguments.coordinates.BlockPosArgument; import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.BoolArgumentType; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import static net.minecraft.commands.Commands.*; public class HazardCommands { + private static final DynamicCommandExceptionType ERROR_UNKNOWN_ITEM = new DynamicCommandExceptionType( + id -> Component.translatable("argument.item.id.invalid", id)); + // spotless:off public static void register(CommandDispatcher dispatcher, CommandBuildContext buildContext) { dispatcher.register( literal("environmental_hazard") .requires(source -> source.hasPermission(LEVEL_ADMINS)) - .then(argument("condition", MedicalConditionArgument.medicalCondition()) + .then(argument("condition", ResourceKeyArgument.key(GTRegistries.Keys.MEDICAL_CONDITION)) .then(argument("can_spread", BoolArgumentType.bool()) .then(argument("source", BlockPosArgument.blockPos()) .then(literal("chunk") @@ -43,21 +51,23 @@ public static void register(CommandDispatcher dispatcher, Co BlockPos source = BlockPosArgument.getBlockPos(context, "source"); return clearEnvironmentalHazard(context, source, null); }) - .then(argument("condition", MedicalConditionArgument.medicalCondition()) + .then(argument("condition", ResourceKeyArgument.key(GTRegistries.Keys.MEDICAL_CONDITION)) .executes(context -> { BlockPos source = BlockPosArgument.getBlockPos(context, "source"); - MedicalCondition condition = MedicalConditionArgument.getCondition(context, "condition"); + MedicalCondition condition = ResourceKeyArgumentAccessor.callResolveKey(context, "condition", + GTRegistries.Keys.MEDICAL_CONDITION, ERROR_UNKNOWN_ITEM).value(); return clearEnvironmentalHazard(context, source, condition); }))))); } // spotless:on - private static int spawnChunkEnvironmentalHazard(CommandContext context) { + private static int spawnChunkEnvironmentalHazard(CommandContext context) throws CommandSyntaxException { ServerLevel serverLevel = context.getSource().getLevel(); BlockPos source = BlockPosArgument.getBlockPos(context, "source"); int strength = IntegerArgumentType.getInteger(context, "strength"); - MedicalCondition condition = MedicalConditionArgument.getCondition(context, "condition"); + MedicalCondition condition = ResourceKeyArgumentAccessor.callResolveKey(context, "condition", + GTRegistries.Keys.MEDICAL_CONDITION, ERROR_UNKNOWN_ITEM).value(); boolean canSpread = BoolArgumentType.getBool(context, "can_spread"); EnvironmentalHazardSavedData.getOrCreate(serverLevel) @@ -66,13 +76,14 @@ private static int spawnChunkEnvironmentalHazard(CommandContext context) { + private static int spawnLocalEnvironmentalHazard(CommandContext context) throws CommandSyntaxException { ServerLevel serverLevel = context.getSource().getLevel(); BlockPos source = BlockPosArgument.getBlockPos(context, "source"); BlockPos from = BlockPosArgument.getBlockPos(context, "from"); BlockPos to = BlockPosArgument.getBlockPos(context, "to"); - MedicalCondition condition = MedicalConditionArgument.getCondition(context, "condition"); + MedicalCondition condition = ResourceKeyArgumentAccessor.callResolveKey(context, "condition", + GTRegistries.Keys.MEDICAL_CONDITION, ERROR_UNKNOWN_ITEM).value(); boolean canSpread = BoolArgumentType.getBool(context, "can_spread"); LocalizedHazardSavedData.getOrCreate(serverLevel) diff --git a/src/main/java/com/gregtechceu/gtceu/common/commands/MedicalConditionCommands.java b/src/main/java/com/gregtechceu/gtceu/common/commands/MedicalConditionCommands.java index 3055c97a4ac..98153e396c8 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/commands/MedicalConditionCommands.java +++ b/src/main/java/com/gregtechceu/gtceu/common/commands/MedicalConditionCommands.java @@ -3,18 +3,21 @@ import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper; import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition; import com.gregtechceu.gtceu.api.data.medicalcondition.Symptom; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.capability.MedicalConditionTracker; -import com.gregtechceu.gtceu.common.commands.arguments.MedicalConditionArgument; +import com.gregtechceu.gtceu.core.mixins.ResourceKeyArgumentAccessor; import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.EntityArgument; +import net.minecraft.commands.arguments.ResourceKeyArgument; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.FloatArgumentType; import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -32,6 +35,8 @@ public class MedicalConditionCommands { Component.translatable("command.gtceu.medical_condition.give.failed")); private static final SimpleCommandExceptionType ERROR_CLEAR_SPECIFIC_FAILED = new SimpleCommandExceptionType( Component.translatable("command.gtceu.medical_condition.clear.specific.failed")); + private static final DynamicCommandExceptionType ERROR_UNKNOWN_ITEM = new DynamicCommandExceptionType( + id -> Component.translatable("argument.item.id.invalid", id)); // spotless:off public static void register(CommandDispatcher dispatcher, CommandBuildContext buildContext) { @@ -64,24 +69,27 @@ public static void register(CommandDispatcher dispatcher, Co .executes(ctx -> { return clearMedicalConditions(ctx.getSource(), EntityArgument.getPlayers(ctx, "targets"), null); }) - .then(argument("condition", MedicalConditionArgument.medicalCondition()) + .then(argument("condition", ResourceKeyArgument.key(GTRegistries.Keys.MEDICAL_CONDITION)) .executes(ctx -> { Collection targets = EntityArgument.getPlayers(ctx, "targets"); - MedicalCondition condition = MedicalConditionArgument.getCondition(ctx, "condition"); + MedicalCondition condition = ResourceKeyArgumentAccessor.callResolveKey(ctx, "condition", + GTRegistries.Keys.MEDICAL_CONDITION, ERROR_UNKNOWN_ITEM).value(); return clearMedicalConditions(ctx.getSource(), targets, condition); })))) .then(literal("apply") .requires(ctx -> ctx.hasPermission(LEVEL_GAMEMASTERS)) .then(argument("targets", EntityArgument.players()) - .then(argument("condition", MedicalConditionArgument.medicalCondition()) + .then(argument("condition", ResourceKeyArgument.key(GTRegistries.Keys.MEDICAL_CONDITION)) .executes(ctx -> { - MedicalCondition condition = MedicalConditionArgument.getCondition(ctx, "condition"); + MedicalCondition condition = ResourceKeyArgumentAccessor.callResolveKey(ctx, "condition", + GTRegistries.Keys.MEDICAL_CONDITION, ERROR_UNKNOWN_ITEM).value(); Collection players = EntityArgument.getPlayers(ctx, "targets"); return applyMedicalConditions(ctx.getSource(), players, condition, 20); }) .then(argument("progression", FloatArgumentType.floatArg()) .executes(ctx -> { - MedicalCondition condition = MedicalConditionArgument.getCondition(ctx, "condition"); + MedicalCondition condition = ResourceKeyArgumentAccessor.callResolveKey(ctx, "condition", + GTRegistries.Keys.MEDICAL_CONDITION, ERROR_UNKNOWN_ITEM).value(); Collection players = EntityArgument.getPlayers(ctx, "targets"); float progression = FloatArgumentType.getFloat(ctx, "progression"); return applyMedicalConditions(ctx.getSource(), players, condition, progression); diff --git a/src/main/java/com/gregtechceu/gtceu/common/commands/arguments/GTRegistryArgument.java b/src/main/java/com/gregtechceu/gtceu/common/commands/arguments/GTRegistryArgument.java index f2ac5210b39..61c55c89cbf 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/commands/arguments/GTRegistryArgument.java +++ b/src/main/java/com/gregtechceu/gtceu/common/commands/arguments/GTRegistryArgument.java @@ -28,7 +28,7 @@ import java.util.function.Consumer; import java.util.function.Function; -public class GTRegistryArgument implements ArgumentType { +public class GTRegistryArgument implements ArgumentType { private static final SimpleCommandExceptionType ERROR_INVALID = new SimpleCommandExceptionType( Component.translatable("argument.id.invalid")); @@ -36,39 +36,25 @@ public class GTRegistryArgument implements ArgumentType { private static final Collection EXAMPLES = Arrays.asList("gtceu:iron_vein", "gtceu:pitchblende_vein_end", "gtceu:lava_deposit"); - private final GTRegistry registry; - private final Class keyClass; + private final GTRegistry registry; - public GTRegistryArgument(GTRegistry registry, Class keyClass) { + public GTRegistryArgument(GTRegistry registry) { this.registry = registry; - this.keyClass = keyClass; } - public static GTRegistryArgument registry(GTRegistry registry, Class keyClass) { - return new GTRegistryArgument<>(registry, keyClass); + public static GTRegistryArgument registry(GTRegistry registry) { + return new GTRegistryArgument<>(registry); } @SuppressWarnings("unchecked") public V parse(StringReader reader) throws CommandSyntaxException { String id = readId(reader); - if (ResourceLocation.class.isAssignableFrom(keyClass)) { - K loc = (K) new ResourceLocation(id); - if (!registry.containsKey(loc)) { - throw new SimpleCommandExceptionType(new LiteralMessage("Failed to find object" + id + " in registry")) - .createWithContext(reader); - } - - return registry.get(loc); - } else if (String.class.isAssignableFrom(keyClass)) { - K loc = (K) id; - if (!registry.containsKey(loc)) { - throw new SimpleCommandExceptionType(Component.literal("Failed to find object " + id + " in registry")) - .createWithContext(reader); - } - return registry.get(loc); + var loc = new ResourceLocation(id); + if (!registry.containsKey(loc)) { + throw new SimpleCommandExceptionType(new LiteralMessage("Failed to find object" + id + " in registry")) + .createWithContext(reader); } - throw new SimpleCommandExceptionType(Component.literal("Invalid key class! this should never happen!")) - .createWithContext(reader); + return registry.get(loc); } public static String readId(StringReader reader) throws CommandSyntaxException { @@ -123,51 +109,44 @@ public Collection getExamples() { } @MethodsReturnNonnullByDefault - public static class Info + public static class Info implements - ArgumentTypeInfo, GTRegistryArgument.Info.Template> { + ArgumentTypeInfo, GTRegistryArgument.Info.Template> { - public void serializeToNetwork(GTRegistryArgument.Info.Template template, FriendlyByteBuf buffer) { + public void serializeToNetwork(GTRegistryArgument.Info.Template template, FriendlyByteBuf buffer) { buffer.writeResourceLocation(template.registryKey.getRegistryName()); - buffer.writeBoolean(ResourceLocation.class.isAssignableFrom(template.keyClass)); } @SuppressWarnings("unchecked") - public GTRegistryArgument.Info.Template deserializeFromNetwork(FriendlyByteBuf buffer) { + public GTRegistryArgument.Info.Template deserializeFromNetwork(FriendlyByteBuf buffer) { ResourceLocation resourceLocation = buffer.readResourceLocation(); - Class keyClass = (Class) String.class; - if (buffer.readBoolean()) { - keyClass = (Class) ResourceLocation.class; - } // noinspection unchecked - return new GTRegistryArgument.Info.Template( - (GTRegistry) GTRegistry.REGISTERED.get(resourceLocation), keyClass); + return new GTRegistryArgument.Info.Template( + (GTRegistry) GTRegistry.REGISTERED.get(resourceLocation)); } - public void serializeToJson(GTRegistryArgument.Info.Template template, JsonObject json) { + public void serializeToJson(GTRegistryArgument.Info.Template template, JsonObject json) { json.addProperty("registry", template.registryKey.getRegistryName().toString()); } - public GTRegistryArgument.Info.Template unpack(GTRegistryArgument argument) { - return new GTRegistryArgument.Info.Template(argument.registry, argument.keyClass); + public GTRegistryArgument.Info.Template unpack(GTRegistryArgument argument) { + return new GTRegistryArgument.Info.Template(argument.registry); } - public final class Template implements ArgumentTypeInfo.Template> { + public final class Template implements ArgumentTypeInfo.Template> { - final GTRegistry registryKey; - final Class keyClass; + final GTRegistry registryKey; - Template(GTRegistry registryKey, Class keyClass) { + Template(GTRegistry registryKey) { this.registryKey = registryKey; - this.keyClass = keyClass; } - public GTRegistryArgument instantiate(@NotNull CommandBuildContext context) { - return new GTRegistryArgument<>(this.registryKey, keyClass); + public GTRegistryArgument instantiate(@NotNull CommandBuildContext context) { + return new GTRegistryArgument<>(this.registryKey); } @Override - public ArgumentTypeInfo, ?> type() { + public ArgumentTypeInfo, ?> type() { return GTRegistryArgument.Info.this; } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/commands/arguments/MedicalConditionArgument.java b/src/main/java/com/gregtechceu/gtceu/common/commands/arguments/MedicalConditionArgument.java deleted file mode 100644 index c3fdae68a4c..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/common/commands/arguments/MedicalConditionArgument.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.gregtechceu.gtceu.common.commands.arguments; - -import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition; - -import com.mojang.brigadier.StringReader; -import com.mojang.brigadier.arguments.ArgumentType; -import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import com.mojang.brigadier.suggestion.Suggestions; -import com.mojang.brigadier.suggestion.SuggestionsBuilder; - -import java.util.Arrays; -import java.util.Collection; -import java.util.concurrent.CompletableFuture; - -public class MedicalConditionArgument implements ArgumentType { - - private static final Collection EXAMPLES = Arrays.asList("chemical_burns", "carcinogen", "asbestosis"); - - public MedicalConditionArgument() {} - - public static MedicalConditionArgument medicalCondition() { - return new MedicalConditionArgument(); - } - - @Override - public MedicalCondition parse(StringReader reader) throws CommandSyntaxException { - return MedicalConditionParser.parseForMedicalCondition(reader); - } - - public static MedicalCondition getCondition(CommandContext context, String name) { - return context.getArgument(name, MedicalCondition.class); - } - - @Override - public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { - return MedicalConditionParser.fillSuggestions(builder); - } - - @Override - public Collection getExamples() { - return EXAMPLES; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/common/commands/arguments/MedicalConditionParser.java b/src/main/java/com/gregtechceu/gtceu/common/commands/arguments/MedicalConditionParser.java deleted file mode 100644 index 596557038f8..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/common/commands/arguments/MedicalConditionParser.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.gregtechceu.gtceu.common.commands.arguments; - -import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition; -import com.gregtechceu.gtceu.api.registry.GTRegistries; - -import net.minecraft.commands.SharedSuggestionProvider; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; - -import com.mojang.brigadier.StringReader; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; -import com.mojang.brigadier.suggestion.Suggestions; -import com.mojang.brigadier.suggestion.SuggestionsBuilder; - -import java.util.concurrent.CompletableFuture; -import java.util.function.Function; - -public class MedicalConditionParser { - - private static final DynamicCommandExceptionType ERROR_UNKNOWN_ITEM = new DynamicCommandExceptionType( - id -> Component.translatable("argument.item.id.invalid", id)); - private static final Function> SUGGEST_NOTHING = SuggestionsBuilder::buildFuture; - private final StringReader reader; - private MedicalCondition result; - /** - * Builder to be used when creating a list of suggestions - */ - private Function> suggestions = SUGGEST_NOTHING; - - private MedicalConditionParser(StringReader reader) { - this.reader = reader; - } - - public static MedicalCondition parseForMedicalCondition(StringReader reader) throws CommandSyntaxException { - int i = reader.getCursor(); - - try { - MedicalConditionParser materialParser = new MedicalConditionParser(reader); - materialParser.parse(); - return materialParser.result; - } catch (CommandSyntaxException var5) { - reader.setCursor(i); - throw var5; - } - } - - public static CompletableFuture fillSuggestions(SuggestionsBuilder builder) { - StringReader stringReader = new StringReader(builder.getInput()); - stringReader.setCursor(builder.getStart()); - MedicalConditionParser materialParser = new MedicalConditionParser(stringReader); - - try { - materialParser.parse(); - } catch (CommandSyntaxException ignored) {} - - return materialParser.suggestions.apply(builder.createOffset(stringReader.getCursor())); - } - - private void readMedicalCondition() throws CommandSyntaxException { - int i = this.reader.getCursor(); - ResourceLocation id = ResourceLocation.read(this.reader); - - MedicalCondition condition = GTRegistries.MEDICAL_CONDITIONS.get(id); - if (condition == null) { - this.reader.setCursor(i); - throw ERROR_UNKNOWN_ITEM.createWithContext(this.reader, id.toString()); - } - this.result = condition; - } - - private void parse() throws CommandSyntaxException { - this.suggestions = this::suggestMedicalCondition; - this.readMedicalCondition(); - } - - private CompletableFuture suggestMedicalCondition(SuggestionsBuilder builder) { - return SharedSuggestionProvider.suggestResource(GTRegistries.MEDICAL_CONDITIONS.keys(), builder); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/FluidVoidingCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/FluidVoidingCover.java index 19dd9756999..d17826a463c 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/FluidVoidingCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/FluidVoidingCover.java @@ -16,6 +16,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -104,10 +105,11 @@ public InteractionResult onSoftMalletClick(ExtendedUseOnContext context) { @Override public @Nullable UITexture sideTips(Player player, BlockPos pos, BlockState state, Set toolTypes, + ItemStack held, Direction side) { if (toolTypes.contains(GTToolType.SOFT_MALLET)) { return isWorkingEnabled() ? GTGuiTextures.TOOL_START : GTGuiTextures.TOOL_PAUSE; } - return super.sideTips(player, pos, state, toolTypes, side); + return super.sideTips(player, pos, state, toolTypes, held, side); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/ItemVoidingCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/ItemVoidingCover.java index ec4ff903959..fa294fb82f2 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/ItemVoidingCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/voiding/ItemVoidingCover.java @@ -104,8 +104,9 @@ public InteractionResult onSoftMalletClick(ExtendedUseOnContext context) { @Override public @Nullable UITexture sideTips(Player player, BlockPos pos, BlockState state, Set toolTypes, + ItemStack held, Direction side) { - var superTips = super.sideTips(player, pos, state, toolTypes, side); + var superTips = super.sideTips(player, pos, state, toolTypes, held, side); if (superTips != null) return superTips; if (toolTypes.contains(GTToolType.SOFT_MALLET)) { return isWorkingEnabled() ? GTGuiTextures.TOOL_START : GTGuiTextures.TOOL_PAUSE; diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java index f0920a4f129..7ac6af5c9ef 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GCYMRecipeTypes.java @@ -4,16 +4,17 @@ import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.common.mui.GTGuiTextures; import com.gregtechceu.gtceu.common.recipe.gui.GTRecipeUIModifiers; +import com.gregtechceu.gtceu.common.registry.GTRegistration; import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.MULTIBLOCK; -import static com.gregtechceu.gtceu.common.data.GTRecipeTypes.register; public class GCYMRecipeTypes { ////////////////////////////////////// // ******* Multiblock *******// ////////////////////////////////////// - public final static GTRecipeType ALLOY_BLAST_RECIPES = register("alloy_blast_smelter", MULTIBLOCK) + public final static GTRecipeType ALLOY_BLAST_RECIPES = GTRegistration.REGISTRATE + .recipeType("alloy_blast_smelter", MULTIBLOCK) .setMaxIOSize(9, 0, 3, 1) .setEUIO(IO.IN) .UI(builder -> builder diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTBlockEntities.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTBlockEntities.java index c4330ecb17b..841d4a25d22 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTBlockEntities.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTBlockEntities.java @@ -2,8 +2,6 @@ import com.gregtechceu.gtceu.common.blockentity.*; -import net.minecraft.world.level.block.entity.SignBlockEntity; - import com.tterrag.registrate.util.entry.BlockEntityEntry; import com.tterrag.registrate.util.entry.BlockEntry; @@ -49,21 +47,5 @@ public class GTBlockEntities { .validBlocks(GTBlocks.DUCT_PIPES) .register(); - public static final BlockEntityEntry GT_SIGN = REGISTRATE - .blockEntity("sign", SignBlockEntity::new) - .validBlocks(GTBlocks.RUBBER_SIGN, - GTBlocks.RUBBER_WALL_SIGN, - GTBlocks.TREATED_WOOD_SIGN, - GTBlocks.TREATED_WOOD_WALL_SIGN) - .register(); - - public static final BlockEntityEntry GT_HANGING_SIGN = REGISTRATE - .blockEntity("hanging_sign", GTHangingSignBlockEntity::new) - .validBlocks(GTBlocks.RUBBER_HANGING_SIGN, - GTBlocks.RUBBER_WALL_HANGING_SIGN, - GTBlocks.TREATED_WOOD_HANGING_SIGN, - GTBlocks.TREATED_WOOD_WALL_HANGING_SIGN) - .register(); - public static void init() {} } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTBlocks.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTBlocks.java index 585ea6765e5..6d4b6473515 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTBlocks.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTBlocks.java @@ -1402,29 +1402,10 @@ public static void init() { generateStoneBlocks(); initializeCobbleReplacements(); - // Procedural Blocks - REGISTRATE.creativeModeTab(() -> GTCreativeModeTabs.MATERIAL_BLOCK); - GTMaterialBlocks.generateMaterialBlocks(); // Compressed Blocks - GTMaterialBlocks.generateOreBlocks(); // Ore Blocks - GTMaterialBlocks.generateOreIndicators(); // Ore Indicators - GTMaterialBlocks.MATERIAL_BLOCKS = GTMaterialBlocks.MATERIAL_BLOCKS_BUILDER.build(); - - // Procedural Pipes/Wires - REGISTRATE.creativeModeTab(() -> GTCreativeModeTabs.MATERIAL_PIPE); - GTMaterialBlocks.generateCableBlocks(); // Cable & Wire Blocks - GTMaterialBlocks.generateFluidPipeBlocks(); // Fluid Pipe Blocks - GTMaterialBlocks.generateItemPipeBlocks(); // Item Pipe Blocks generateLaserPipeBlocks(); // Laser Pipe Blocks generateOpticalPipeBlocks(); // Optical Pipe Blocks generateDuctPipeBlocks(); // Duct Pipe Blocks - // Remove Builder Tables - GTMaterialBlocks.MATERIAL_BLOCKS_BUILDER = null; - GTMaterialBlocks.SURFACE_ROCK_BLOCKS_BUILDER = null; - GTMaterialBlocks.CABLE_BLOCKS_BUILDER = null; - GTMaterialBlocks.FLUID_PIPE_BLOCKS_BUILDER = null; - GTMaterialBlocks.ITEM_PIPE_BLOCKS_BUILDER = null; - // GCYM GCYMBlocks.init(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTCommandArguments.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTCommandArguments.java index 44fb23eff9a..eed15dca4bf 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTCommandArguments.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTCommandArguments.java @@ -4,7 +4,6 @@ import com.gregtechceu.gtceu.api.registry.GTRegistry; import com.gregtechceu.gtceu.common.commands.arguments.GTRegistryArgument; import com.gregtechceu.gtceu.common.commands.arguments.MaterialArgument; -import com.gregtechceu.gtceu.common.commands.arguments.MedicalConditionArgument; import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.commands.synchronization.ArgumentTypeInfos; @@ -27,13 +26,8 @@ public class GTCommandArguments { "material", () -> ArgumentTypeInfos.registerByClass(MaterialArgument.class, SingletonArgumentInfo.contextFree(MaterialArgument::material))); - private static final RegistryObject> MEDICAL_CONDITION_ARGUMENT_TYPE = COMMAND_ARGUMENT_TYPES - .register("medical_condition", - () -> ArgumentTypeInfos.registerByClass(MedicalConditionArgument.class, - SingletonArgumentInfo.contextFree(MedicalConditionArgument::medicalCondition))); - @SuppressWarnings({ "unchecked", "rawtypes" }) - private static final RegistryObject>> GT_REGISTRY_ARGUMENT_TYPE = COMMAND_ARGUMENT_TYPES + private static final RegistryObject>> GT_REGISTRY_ARGUMENT_TYPE = COMMAND_ARGUMENT_TYPES .register("gt_registry", () -> ArgumentTypeInfos.registerByClass( fixClassType(GTRegistryArgument.class), diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTCovers.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTCovers.java index 1e6b45c64fc..203833157fd 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTCovers.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTCovers.java @@ -3,8 +3,6 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; -import com.gregtechceu.gtceu.api.addon.AddonFinder; -import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.api.cover.CoverDefinition; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.client.renderer.cover.*; @@ -18,8 +16,9 @@ import com.gregtechceu.gtceu.common.cover.voiding.FluidVoidingCover; import com.gregtechceu.gtceu.common.cover.voiding.ItemVoidingCover; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fml.ModLoader; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.RegistryObject; import it.unimi.dsi.fastutil.ints.Int2ObjectFunction; @@ -34,25 +33,27 @@ public class GTCovers { public static final int[] ALL_TIERS_WITH_ULV = GTValues.tiersBetween(GTValues.ULV, GTCEuAPI.isHighTier() ? GTValues.OpV : GTValues.UV); - static { - GTRegistries.COVERS.unfreeze(); - } + private static final DeferredRegister COVER = DeferredRegister.create(GTRegistries.Keys.COVER, + GTCEu.MOD_ID); - public final static CoverDefinition FACADE = register("facade", FacadeCover::new, + public final static RegistryObject FACADE = register("facade", FacadeCover::new, () -> () -> FacadeCoverRenderer.INSTANCE); - public final static CoverDefinition ITEM_FILTER = register("item_filter", ItemFilterCover::new); - public final static CoverDefinition FLUID_FILTER = register("fluid_filter", FluidFilterCover::new); + public final static RegistryObject ITEM_FILTER = register("item_filter", ItemFilterCover::new); + public final static RegistryObject FLUID_FILTER = register("fluid_filter", FluidFilterCover::new); - public final static CoverDefinition INFINITE_WATER = register("infinite_water", InfiniteWaterCover::new); - public final static CoverDefinition ENDER_FLUID_LINK = register("ender_fluid_link", EnderFluidLinkCover::new); - public final static CoverDefinition ENDER_ITEM_LINK = register("ender_item_link", EnderItemLinkCover::new); - public final static CoverDefinition ENDER_REDSTONE_LINK = register("ender_redstone_link", + public final static RegistryObject INFINITE_WATER = register("infinite_water", + InfiniteWaterCover::new); + public final static RegistryObject ENDER_FLUID_LINK = register("ender_fluid_link", + EnderFluidLinkCover::new); + public final static RegistryObject ENDER_ITEM_LINK = register("ender_item_link", + EnderItemLinkCover::new); + public final static RegistryObject ENDER_REDSTONE_LINK = register("ender_redstone_link", EnderRedstoneLinkCover::new); - public final static CoverDefinition SHUTTER = register("shutter", ShutterCover::new); - public final static CoverDefinition COVER_STORAGE = register("storage", StorageCover::new); + public final static RegistryObject SHUTTER = register("shutter", ShutterCover::new); + public final static RegistryObject COVER_STORAGE = register("storage", StorageCover::new); - public final static CoverDefinition[] CONVEYORS = registerTiered("conveyor", ConveyorCover::new, + public final static RegistryObject[] CONVEYORS = registerTiered("conveyor", ConveyorCover::new, () -> tier -> new IOCoverRenderer( GTCEu.id("block/cover/conveyor"), null, @@ -60,7 +61,7 @@ public class GTCovers { GTCEu.id("block/cover/conveyor_inverted_emissive")), ALL_TIERS); - public final static CoverDefinition[] ROBOT_ARMS = registerTiered("robot_arm", RobotArmCover::new, + public final static RegistryObject[] ROBOT_ARMS = registerTiered("robot_arm", RobotArmCover::new, () -> tier -> new IOCoverRenderer( GTCEu.id("block/cover/arm"), null, @@ -68,93 +69,88 @@ public class GTCovers { GTCEu.id("block/cover/arm_inverted_emissive")), ALL_TIERS); - public final static CoverDefinition[] PUMPS = registerTiered("pump", PumpCover::new, + public final static RegistryObject[] PUMPS = registerTiered("pump", PumpCover::new, () -> tier -> IOCoverRenderer.PUMP_LIKE_COVER_RENDERER, ALL_TIERS); - public final static CoverDefinition[] FLUID_REGULATORS = registerTiered("fluid_regulator", FluidRegulatorCover::new, + public final static RegistryObject[] FLUID_REGULATORS = registerTiered("fluid_regulator", + FluidRegulatorCover::new, () -> tier -> IOCoverRenderer.PUMP_LIKE_COVER_RENDERER, ALL_TIERS); - public final static CoverDefinition COMPUTER_MONITOR = register("computer_monitor", ComputerMonitorCover::new); + public final static RegistryObject COMPUTER_MONITOR = register("computer_monitor", + ComputerMonitorCover::new); - public final static CoverDefinition MACHINE_CONTROLLER = register("machine_controller", + public final static RegistryObject MACHINE_CONTROLLER = register("machine_controller", MachineControllerCover::new); - public final static CoverDefinition WIRELESS_TRANSMITTER = register( + public final static RegistryObject WIRELESS_TRANSMITTER = register( "wireless_transmitter", WirelessTransmitterCover::new, () -> () -> new SimpleCoverRenderer(GTCEu.id("block/cover/wireless_transmitter"))); // Voiding - public final static CoverDefinition ITEM_VOIDING = register("item_voiding", ItemVoidingCover::new); - public final static CoverDefinition ITEM_VOIDING_ADVANCED = register("item_voiding_advanced", + public final static RegistryObject ITEM_VOIDING = register("item_voiding", ItemVoidingCover::new); + public final static RegistryObject ITEM_VOIDING_ADVANCED = register("item_voiding_advanced", AdvancedItemVoidingCover::new); - public final static CoverDefinition FLUID_VOIDING = register("fluid_voiding", FluidVoidingCover::new); - public final static CoverDefinition FLUID_VOIDING_ADVANCED = register("fluid_voiding_advanced", + public final static RegistryObject FLUID_VOIDING = register("fluid_voiding", + FluidVoidingCover::new); + public final static RegistryObject FLUID_VOIDING_ADVANCED = register("fluid_voiding_advanced", AdvancedFluidVoidingCover::new); // Detectors - public final static CoverDefinition ACTIVITY_DETECTOR = register("activity_detector", ActivityDetectorCover::new); - public final static CoverDefinition ACTIVITY_DETECTOR_ADVANCED = register("activity_detector_advanced", + public final static RegistryObject ACTIVITY_DETECTOR = register("activity_detector", + ActivityDetectorCover::new); + public final static RegistryObject ACTIVITY_DETECTOR_ADVANCED = register( + "activity_detector_advanced", AdvancedActivityDetectorCover::new); - public final static CoverDefinition FLUID_DETECTOR = register("fluid_detector", FluidDetectorCover::new); - public final static CoverDefinition FLUID_DETECTOR_ADVANCED = register("fluid_detector_advanced", + public final static RegistryObject FLUID_DETECTOR = register("fluid_detector", + FluidDetectorCover::new); + public final static RegistryObject FLUID_DETECTOR_ADVANCED = register("fluid_detector_advanced", AdvancedFluidDetectorCover::new); - public final static CoverDefinition ITEM_DETECTOR = register("item_detector", ItemDetectorCover::new); - public final static CoverDefinition ITEM_DETECTOR_ADVANCED = register("item_detector_advanced", + public final static RegistryObject ITEM_DETECTOR = register("item_detector", + ItemDetectorCover::new); + public final static RegistryObject ITEM_DETECTOR_ADVANCED = register("item_detector_advanced", AdvancedItemDetectorCover::new); - public final static CoverDefinition ENERGY_DETECTOR = register("energy_detector", EnergyDetectorCover::new); - public final static CoverDefinition ENERGY_DETECTOR_ADVANCED = register("energy_detector_advanced", + public final static RegistryObject ENERGY_DETECTOR = register("energy_detector", + EnergyDetectorCover::new); + public final static RegistryObject ENERGY_DETECTOR_ADVANCED = register("energy_detector_advanced", AdvancedEnergyDetectorCover::new); - public final static CoverDefinition MAINTENANCE_DETECTOR = register("maintenance_detector", + public final static RegistryObject MAINTENANCE_DETECTOR = register("maintenance_detector", MaintenanceDetectorCover::new); // Solar Panels - public final static CoverDefinition SOLAR_PANEL_BASIC = register("solar_panel", CoverSolarPanel::new); - public final static CoverDefinition[] SOLAR_PANEL = registerTiered("solar_panel", CoverSolarPanel::new, + public final static RegistryObject SOLAR_PANEL_BASIC = register("solar_panel", + CoverSolarPanel::new); + public final static RegistryObject[] SOLAR_PANEL = registerTiered("solar_panel", + CoverSolarPanel::new, () -> tier -> new SimpleCoverRenderer(GTCEu.id("block/cover/solar_panel")), ALL_TIERS_WITH_ULV); /////////////////////////////////////////////// // *********** UTIL METHODS ***********// /////////////////////////////////////////////// - private static CoverDefinition register(String id, CoverDefinition.CoverBehaviourProvider behaviorCreator) { - return register(id, behaviorCreator, () -> () -> new SimpleCoverRenderer(GTCEu.id("block/cover/" + id))); - } - - private static CoverDefinition register(String id, CoverDefinition.CoverBehaviourProvider behaviorCreator, - Supplier> coverRenderer) { - return register(GTCEu.id(id), behaviorCreator, coverRenderer); + private static RegistryObject register(String id, + CoverDefinition.CoverBehaviourProvider behaviorCreator) { + return COVER.register(id, () -> new CoverDefinition(GTCEu.id(id), behaviorCreator)); } - public static CoverDefinition register(ResourceLocation id, CoverDefinition.CoverBehaviourProvider behaviorCreator, - Supplier> coverRenderer) { - var definition = new CoverDefinition(id, behaviorCreator, coverRenderer); - GTRegistries.COVERS.register(definition.getId(), definition); - return definition; + private static RegistryObject register(String id, + CoverDefinition.CoverBehaviourProvider behaviorCreator, + Supplier> coverRenderer) { + return COVER.register(id, () -> new CoverDefinition(GTCEu.id(id), behaviorCreator, coverRenderer)); } - private static CoverDefinition[] registerTiered(String id, - CoverDefinition.TieredCoverBehaviourProvider behaviorCreator, - Supplier> coverRenderer, - int... tiers) { + @SuppressWarnings("unchecked") + private static RegistryObject[] registerTiered(String id, + CoverDefinition.TieredCoverBehaviourProvider behaviorCreator, + Supplier> coverRenderer, + int... tiers) { return Arrays.stream(tiers).mapToObj(tier -> { var name = id + "." + GTValues.VN[tier].toLowerCase(Locale.ROOT); return register(name, (def, coverable, side) -> behaviorCreator.create(def, coverable, side, tier), () -> () -> coverRenderer.get().apply(tier)); - }).toArray(CoverDefinition[]::new); - } - - private static CoverDefinition[] registerTiered(String id, - CoverDefinition.TieredCoverBehaviourProvider behaviorCreator, - int... tiers) { - return Arrays.stream(tiers).mapToObj(tier -> { - var name = id + "." + GTValues.VN[tier].toLowerCase(Locale.ROOT); - return register(name, (def, coverable, side) -> behaviorCreator.create(def, coverable, side, tier)); - }).toArray(CoverDefinition[]::new); + }).toArray(RegistryObject[]::new); } - public static void init() { - AddonFinder.getAddons().forEach(IGTAddon::registerCovers); - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.COVERS, CoverDefinition.class)); - GTRegistries.COVERS.freeze(); + public static void init(IEventBus modBus) { + COVER.register(modBus); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java index aec91b22622..e7e30cdce02 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTDimensionMarkers.java @@ -1,23 +1,17 @@ package com.gregtechceu.gtceu.common.data; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.data.DimensionMarker; import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.utils.FormattingUtil; import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -import net.minecraftforge.fml.ModLoader; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.RegistryObject; import com.tterrag.registrate.util.entry.BlockEntry; -import org.jetbrains.annotations.Nullable; - -import java.util.function.Supplier; import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; @@ -25,34 +19,27 @@ public class GTDimensionMarkers { static { - GTRegistries.DIMENSION_MARKERS.unfreeze(); REGISTRATE.creativeModeTab(() -> null); } + private static final DeferredRegister DIMENSION_MARKER = DeferredRegister + .create(GTRegistries.Keys.DIMENSION_MARKER, "gtceu"); + public static final BlockEntry OVERWORLD_MARKER = createMarker("overworld"); public static final BlockEntry NETHER_MARKER = createMarker("the_nether"); public static final BlockEntry END_MARKER = createMarker("the_end"); - public static final DimensionMarker OVERWORLD = createAndRegister(Level.OVERWORLD.location(), 0, - () -> OVERWORLD_MARKER, null); - public static final DimensionMarker NETHER = createAndRegister(Level.NETHER.location(), 0, - () -> NETHER_MARKER, null); - public static final DimensionMarker END = createAndRegister(Level.END.location(), 0, - () -> END_MARKER, null); + public static final RegistryObject OVERWORLD = DIMENSION_MARKER.register("overworld", + () -> new DimensionMarker(Level.OVERWORLD, 0, + () -> OVERWORLD_MARKER, null)); - public static DimensionMarker createAndRegister(ResourceLocation dim, int tier, ResourceLocation itemKey, - @Nullable String overrideName) { - DimensionMarker marker = new DimensionMarker(tier, itemKey, overrideName); - marker.register(dim); - return marker; - } + public static final RegistryObject NETHER = DIMENSION_MARKER.register("nether", + () -> new DimensionMarker(Level.NETHER, 0, + () -> NETHER_MARKER, null)); - public static DimensionMarker createAndRegister(ResourceLocation dim, int tier, Supplier supplier, - @Nullable String overrideName) { - DimensionMarker marker = new DimensionMarker(tier, supplier, overrideName); - marker.register(dim); - return marker; - } + public static final RegistryObject END = DIMENSION_MARKER.register("end", + () -> new DimensionMarker(Level.END, 0, + () -> END_MARKER, null)); private static BlockEntry createMarker(String name) { return REGISTRATE.block("%s_marker".formatted(name), Block::new) @@ -70,11 +57,7 @@ private static BlockEntry createMarker(String name) { .register(); } - public static void init() { - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.DIMENSION_MARKERS, DimensionMarker.class)); - if (GTCEu.Mods.isKubeJSLoaded()) { - GTRegistryInfo.registerFor(GTRegistries.DIMENSION_MARKERS.getRegistryName()); - } - GTRegistries.DIMENSION_MARKERS.freeze(); + public static void init(IEventBus bus) { + DIMENSION_MARKER.register(bus); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java index 7c70768697b..51bafbadf26 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTElements.java @@ -1,249 +1,205 @@ package com.gregtechceu.gtceu.common.data; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; -import com.gregtechceu.gtceu.api.addon.AddonFinder; -import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.api.data.chemical.Element; -import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fml.ModLoader; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; public class GTElements { - static { - GTRegistries.ELEMENTS.unfreeze(); - } - - public static final Element H = createAndRegister(GTCEu.id("Hydrogen"), 1, 0, -1, null, "Hydrogen", "H", false); - public static final Element D = createAndRegister(GTCEu.id("Deuterium"), 1, 1, -1, "H", "Deuterium", "D", true); - public static final Element T = createAndRegister(GTCEu.id("Tritium"), 1, 2, -1, "D", "Tritium", "T", true); - public static final Element He = createAndRegister(GTCEu.id("Helium"), 2, 2, -1, null, "Helium", "He", false); - public static final Element He3 = createAndRegister(GTCEu.id("Helium-3"), 2, 1, -1, "H&D", "Helium-3", "He-3", + public static final Element H = REGISTRATE.element("Hydrogen", 1, 0, -1, null, "H", false); + public static final Element D = REGISTRATE.element("Deuterium", 1, 1, -1, "H", "D", true); + public static final Element T = REGISTRATE.element("Tritium", 1, 2, -1, "D", "T", true); + public static final Element He = REGISTRATE.element("Helium", 2, 2, -1, null, "He", false); + public static final Element He3 = REGISTRATE.element("Helium-3", 2, 1, -1, "H&D", "He-3", true); - public static final Element Li = createAndRegister(GTCEu.id("Lithium"), 3, 4, -1, null, "Lithium", "Li", false); - public static final Element Be = createAndRegister(GTCEu.id("Beryllium"), 4, 5, -1, null, "Beryllium", "Be", false); - public static final Element B = createAndRegister(GTCEu.id("Boron"), 5, 5, -1, null, "Boron", "B", false); - public static final Element C = createAndRegister(GTCEu.id("Carbon"), 6, 6, -1, null, "Carbon", "C", false); - public static final Element N = createAndRegister(GTCEu.id("Nitrogen"), 7, 7, -1, null, "Nitrogen", "N", false); - public static final Element O = createAndRegister(GTCEu.id("Oxygen"), 8, 8, -1, null, "Oxygen", "O", false); - public static final Element F = createAndRegister(GTCEu.id("Fluorine"), 9, 9, -1, null, "Fluorine", "F", false); - public static final Element Ne = createAndRegister(GTCEu.id("Neon"), 10, 10, -1, null, "Neon", "Ne", false); - public static final Element Na = createAndRegister(GTCEu.id("Sodium"), 11, 11, -1, null, "Sodium", "Na", false); - public static final Element Mg = createAndRegister(GTCEu.id("Magnesium"), 12, 12, -1, null, "Magnesium", "Mg", - false); - public static final Element Al = createAndRegister(GTCEu.id("Aluminium"), 13, 13, -1, null, "Aluminium", "Al", - false); - public static final Element Si = createAndRegister(GTCEu.id("Silicon"), 14, 14, -1, null, "Silicon", "Si", false); - public static final Element P = createAndRegister(GTCEu.id("Phosphorus"), 15, 15, -1, null, "Phosphorus", "P", - false); - public static final Element S = createAndRegister(GTCEu.id("Sulfur"), 16, 16, -1, null, "Sulfur", "S", false); - public static final Element Cl = createAndRegister(GTCEu.id("Chlorine"), 17, 18, -1, null, "Chlorine", "Cl", false); - public static final Element Ar = createAndRegister(GTCEu.id("Argon"), 18, 22, -1, null, "Argon", "Ar", false); - public static final Element K = createAndRegister(GTCEu.id("Potassium"), 19, 20, -1, null, "Potassium", "K", false); - public static final Element Ca = createAndRegister(GTCEu.id("Calcium"), 20, 20, -1, null, "Calcium", "Ca", false); - public static final Element Sc = createAndRegister(GTCEu.id("Scandium"), 21, 24, -1, null, "Scandium", "Sc", false); - public static final Element Ti = createAndRegister(GTCEu.id("Titanium"), 22, 26, -1, null, "Titanium", "Ti", false); - public static final Element V = createAndRegister(GTCEu.id("Vanadium"), 23, 28, -1, null, "Vanadium", "V", false); - public static final Element Cr = createAndRegister(GTCEu.id("Chrome"), 24, 28, -1, null, "Chrome", "Cr", false); - public static final Element Mn = createAndRegister(GTCEu.id("Manganese"), 25, 30, -1, null, "Manganese", "Mn", - false); - public static final Element Fe = createAndRegister(GTCEu.id("Iron"), 26, 30, -1, null, "Iron", "Fe", false); - public static final Element Co = createAndRegister(GTCEu.id("Cobalt"), 27, 32, -1, null, "Cobalt", "Co", false); - public static final Element Ni = createAndRegister(GTCEu.id("Nickel"), 28, 30, -1, null, "Nickel", "Ni", false); - public static final Element Cu = createAndRegister(GTCEu.id("Copper"), 29, 34, -1, null, "Copper", "Cu", false); - public static final Element Zn = createAndRegister(GTCEu.id("Zinc"), 30, 35, -1, null, "Zinc", "Zn", false); - public static final Element Ga = createAndRegister(GTCEu.id("Gallium"), 31, 39, -1, null, "Gallium", "Ga", false); - public static final Element Ge = createAndRegister(GTCEu.id("Germanium"), 32, 40, -1, null, "Germanium", "Ge", - false); - public static final Element As = createAndRegister(GTCEu.id("Arsenic"), 33, 42, -1, null, "Arsenic", "As", false); - public static final Element Se = createAndRegister(GTCEu.id("Selenium"), 34, 45, -1, null, "Selenium", "Se", false); - public static final Element Br = createAndRegister(GTCEu.id("Bromine"), 35, 45, -1, null, "Bromine", "Br", false); - public static final Element Kr = createAndRegister(GTCEu.id("Krypton"), 36, 48, -1, null, "Krypton", "Kr", false); - public static final Element Rb = createAndRegister(GTCEu.id("Rubidium"), 37, 48, -1, null, "Rubidium", "Rb", false); - public static final Element Sr = createAndRegister(GTCEu.id("Strontium"), 38, 49, -1, null, "Strontium", "Sr", - false); - public static final Element Y = createAndRegister(GTCEu.id("Yttrium"), 39, 50, -1, null, "Yttrium", "Y", false); - public static final Element Zr = createAndRegister(GTCEu.id("Zirconium"), 40, 51, -1, null, "Zirconium", "Zr", - false); - public static final Element Nb = createAndRegister(GTCEu.id("Niobium"), 41, 53, -1, null, "Niobium", "Nb", false); - public static final Element Mo = createAndRegister(GTCEu.id("Molybdenum"), 42, 53, -1, null, "Molybdenum", "Mo", - false); - public static final Element Tc = createAndRegister(GTCEu.id("Technetium"), 43, 55, -1, null, "Technetium", "Tc", - false); - public static final Element Ru = createAndRegister(GTCEu.id("Ruthenium"), 44, 57, -1, null, "Ruthenium", "Ru", - false); - public static final Element Rh = createAndRegister(GTCEu.id("Rhodium"), 45, 58, -1, null, "Rhodium", "Rh", false); - public static final Element Pd = createAndRegister(GTCEu.id("Palladium"), 46, 60, -1, null, "Palladium", "Pd", - false); - public static final Element Ag = createAndRegister(GTCEu.id("Silver"), 47, 60, -1, null, "Silver", "Ag", false); - public static final Element Cd = createAndRegister(GTCEu.id("Cadmium"), 48, 64, -1, null, "Cadmium", "Cd", false); - public static final Element In = createAndRegister(GTCEu.id("Indium"), 49, 65, -1, null, "Indium", "In", false); - public static final Element Sn = createAndRegister(GTCEu.id("Tin"), 50, 68, -1, null, "Tin", "Sn", false); - public static final Element Sb = createAndRegister(GTCEu.id("Antimony"), 51, 70, -1, null, "Antimony", "Sb", false); - public static final Element Te = createAndRegister(GTCEu.id("Tellurium"), 52, 75, -1, null, "Tellurium", "Te", - false); - public static final Element I = createAndRegister(GTCEu.id("Iodine"), 53, 74, -1, null, "Iodine", "I", false); - public static final Element Xe = createAndRegister(GTCEu.id("Xenon"), 54, 77, -1, null, "Xenon", "Xe", false); - public static final Element Cs = createAndRegister(GTCEu.id("Caesium"), 55, 77, -1, null, "Caesium", "Cs", false); - public static final Element Ba = createAndRegister(GTCEu.id("Barium"), 56, 81, -1, null, "Barium", "Ba", false); - public static final Element La = createAndRegister(GTCEu.id("Lanthanum"), 57, 81, -1, null, "Lanthanum", "La", - false); - public static final Element Ce = createAndRegister(GTCEu.id("Cerium"), 58, 82, -1, null, "Cerium", "Ce", false); - public static final Element Pr = createAndRegister(GTCEu.id("Praseodymium"), 59, 81, -1, null, "Praseodymium", "Pr", - false); - public static final Element Nd = createAndRegister(GTCEu.id("Neodymium"), 60, 84, -1, null, "Neodymium", "Nd", - false); - public static final Element Pm = createAndRegister(GTCEu.id("Promethium"), 61, 83, -1, null, "Promethium", "Pm", - false); - public static final Element Sm = createAndRegister(GTCEu.id("Samarium"), 62, 88, -1, null, "Samarium", "Sm", false); - public static final Element Eu = createAndRegister(GTCEu.id("Europium"), 63, 88, -1, null, "Europium", "Eu", false); - public static final Element Gd = createAndRegister(GTCEu.id("Gadolinium"), 64, 93, -1, null, "Gadolinium", "Gd", - false); - public static final Element Tb = createAndRegister(GTCEu.id("Terbium"), 65, 93, -1, null, "Terbium", "Tb", false); - public static final Element Dy = createAndRegister(GTCEu.id("Dysprosium"), 66, 96, -1, null, "Dysprosium", "Dy", - false); - public static final Element Ho = createAndRegister(GTCEu.id("Holmium"), 67, 97, -1, null, "Holmium", "Ho", false); - public static final Element Er = createAndRegister(GTCEu.id("Erbium"), 68, 99, -1, null, "Erbium", "Er", false); - public static final Element Tm = createAndRegister(GTCEu.id("Thulium"), 69, 99, -1, null, "Thulium", "Tm", false); - public static final Element Yb = createAndRegister(GTCEu.id("Ytterbium"), 70, 103, -1, null, "Ytterbium", "Yb", - false); - public static final Element Lu = createAndRegister(GTCEu.id("Lutetium"), 71, 103, -1, null, "Lutetium", "Lu", - false); - public static final Element Hf = createAndRegister(GTCEu.id("Hafnium"), 72, 106, -1, null, "Hafnium", "Hf", false); - public static final Element Ta = createAndRegister(GTCEu.id("Tantalum"), 73, 107, -1, null, "Tantalum", "Ta", - false); - public static final Element W = createAndRegister(GTCEu.id("Tungsten"), 74, 109, -1, null, "Tungsten", "W", false); - public static final Element Re = createAndRegister(GTCEu.id("Rhenium"), 75, 111, -1, null, "Rhenium", "Re", false); - public static final Element Os = createAndRegister(GTCEu.id("Osmium"), 76, 114, -1, null, "Osmium", "Os", false); - public static final Element Ir = createAndRegister(GTCEu.id("Iridium"), 77, 115, -1, null, "Iridium", "Ir", false); - public static final Element Pt = createAndRegister(GTCEu.id("Platinum"), 78, 117, -1, null, "Platinum", "Pt", - false); - public static final Element Au = createAndRegister(GTCEu.id("Gold"), 79, 117, -1, null, "Gold", "Au", false); - public static final Element Hg = createAndRegister(GTCEu.id("Mercury"), 80, 120, -1, null, "Mercury", "Hg", false); - public static final Element Tl = createAndRegister(GTCEu.id("Thallium"), 81, 123, -1, null, "Thallium", "Tl", - false); - public static final Element Pb = createAndRegister(GTCEu.id("Lead"), 82, 125, -1, null, "Lead", "Pb", false); - public static final Element Bi = createAndRegister(GTCEu.id("Bismuth"), 83, 125, -1, null, "Bismuth", "Bi", false); - public static final Element Po = createAndRegister(GTCEu.id("Polonium"), 84, 124, -1, null, "Polonium", "Po", + public static final Element Li = REGISTRATE.element("Lithium", 3, 4, -1, null, "Li", false); + public static final Element Be = REGISTRATE.element("Beryllium", 4, 5, -1, null, "Be", false); + public static final Element B = REGISTRATE.element("Boron", 5, 5, -1, null, "B", false); + public static final Element C = REGISTRATE.element("Carbon", 6, 6, -1, null, "C", false); + public static final Element N = REGISTRATE.element("Nitrogen", 7, 7, -1, null, "N", false); + public static final Element O = REGISTRATE.element("Oxygen", 8, 8, -1, null, "O", false); + public static final Element F = REGISTRATE.element("Fluorine", 9, 9, -1, null, "F", false); + public static final Element Ne = REGISTRATE.element("Neon", 10, 10, -1, null, "Ne", false); + public static final Element Na = REGISTRATE.element("Sodium", 11, 11, -1, null, "Na", false); + public static final Element Mg = REGISTRATE.element("Magnesium", 12, 12, -1, null, "Mg", + false); + public static final Element Al = REGISTRATE.element("Aluminium", 13, 13, -1, null, "Al", + false); + public static final Element Si = REGISTRATE.element("Silicon", 14, 14, -1, null, "Si", false); + public static final Element P = REGISTRATE.element("Phosphorus", 15, 15, -1, null, "P", + false); + public static final Element S = REGISTRATE.element("Sulfur", 16, 16, -1, null, "S", false); + public static final Element Cl = REGISTRATE.element("Chlorine", 17, 18, -1, null, "Cl", false); + public static final Element Ar = REGISTRATE.element("Argon", 18, 22, -1, null, "Ar", false); + public static final Element K = REGISTRATE.element("Potassium", 19, 20, -1, null, "K", false); + public static final Element Ca = REGISTRATE.element("Calcium", 20, 20, -1, null, "Ca", false); + public static final Element Sc = REGISTRATE.element("Scandium", 21, 24, -1, null, "Sc", false); + public static final Element Ti = REGISTRATE.element("Titanium", 22, 26, -1, null, "Ti", false); + public static final Element V = REGISTRATE.element("Vanadium", 23, 28, -1, null, "V", false); + public static final Element Cr = REGISTRATE.element("Chrome", 24, 28, -1, null, "Cr", false); + public static final Element Mn = REGISTRATE.element("Manganese", 25, 30, -1, null, "Mn", + false); + public static final Element Fe = REGISTRATE.element("Iron", 26, 30, -1, null, "Fe", false); + public static final Element Co = REGISTRATE.element("Cobalt", 27, 32, -1, null, "Co", false); + public static final Element Ni = REGISTRATE.element("Nickel", 28, 30, -1, null, "Ni", false); + public static final Element Cu = REGISTRATE.element("Copper", 29, 34, -1, null, "Cu", false); + public static final Element Zn = REGISTRATE.element("Zinc", 30, 35, -1, null, "Zn", false); + public static final Element Ga = REGISTRATE.element("Gallium", 31, 39, -1, null, "Ga", false); + public static final Element Ge = REGISTRATE.element("Germanium", 32, 40, -1, null, "Ge", + false); + public static final Element As = REGISTRATE.element("Arsenic", 33, 42, -1, null, "As", false); + public static final Element Se = REGISTRATE.element("Selenium", 34, 45, -1, null, "Se", false); + public static final Element Br = REGISTRATE.element("Bromine", 35, 45, -1, null, "Br", false); + public static final Element Kr = REGISTRATE.element("Krypton", 36, 48, -1, null, "Kr", false); + public static final Element Rb = REGISTRATE.element("Rubidium", 37, 48, -1, null, "Rb", false); + public static final Element Sr = REGISTRATE.element("Strontium", 38, 49, -1, null, "Sr", + false); + public static final Element Y = REGISTRATE.element("Yttrium", 39, 50, -1, null, "Y", false); + public static final Element Zr = REGISTRATE.element("Zirconium", 40, 51, -1, null, "Zr", + false); + public static final Element Nb = REGISTRATE.element("Niobium", 41, 53, -1, null, "Nb", false); + public static final Element Mo = REGISTRATE.element("Molybdenum", 42, 53, -1, null, "Mo", + false); + public static final Element Tc = REGISTRATE.element("Technetium", 43, 55, -1, null, "Tc", + false); + public static final Element Ru = REGISTRATE.element("Ruthenium", 44, 57, -1, null, "Ru", + false); + public static final Element Rh = REGISTRATE.element("Rhodium", 45, 58, -1, null, "Rh", false); + public static final Element Pd = REGISTRATE.element("Palladium", 46, 60, -1, null, "Pd", + false); + public static final Element Ag = REGISTRATE.element("Silver", 47, 60, -1, null, "Ag", false); + public static final Element Cd = REGISTRATE.element("Cadmium", 48, 64, -1, null, "Cd", false); + public static final Element In = REGISTRATE.element("Indium", 49, 65, -1, null, "In", false); + public static final Element Sn = REGISTRATE.element("Tin", 50, 68, -1, null, "Sn", false); + public static final Element Sb = REGISTRATE.element("Antimony", 51, 70, -1, null, "Sb", false); + public static final Element Te = REGISTRATE.element("Tellurium", 52, 75, -1, null, "Te", + false); + public static final Element I = REGISTRATE.element("Iodine", 53, 74, -1, null, "I", false); + public static final Element Xe = REGISTRATE.element("Xenon", 54, 77, -1, null, "Xe", false); + public static final Element Cs = REGISTRATE.element("Caesium", 55, 77, -1, null, "Cs", false); + public static final Element Ba = REGISTRATE.element("Barium", 56, 81, -1, null, "Ba", false); + public static final Element La = REGISTRATE.element("Lanthanum", 57, 81, -1, null, "La", + false); + public static final Element Ce = REGISTRATE.element("Cerium", 58, 82, -1, null, "Ce", false); + public static final Element Pr = REGISTRATE.element("Praseodymium", 59, 81, -1, null, "Pr", + false); + public static final Element Nd = REGISTRATE.element("Neodymium", 60, 84, -1, null, "Nd", + false); + public static final Element Pm = REGISTRATE.element("Promethium", 61, 83, -1, null, "Pm", + false); + public static final Element Sm = REGISTRATE.element("Samarium", 62, 88, -1, null, "Sm", false); + public static final Element Eu = REGISTRATE.element("Europium", 63, 88, -1, null, "Eu", false); + public static final Element Gd = REGISTRATE.element("Gadolinium", 64, 93, -1, null, "Gd", + false); + public static final Element Tb = REGISTRATE.element("Terbium", 65, 93, -1, null, "Tb", false); + public static final Element Dy = REGISTRATE.element("Dysprosium", 66, 96, -1, null, "Dy", + false); + public static final Element Ho = REGISTRATE.element("Holmium", 67, 97, -1, null, "Ho", false); + public static final Element Er = REGISTRATE.element("Erbium", 68, 99, -1, null, "Er", false); + public static final Element Tm = REGISTRATE.element("Thulium", 69, 99, -1, null, "Tm", false); + public static final Element Yb = REGISTRATE.element("Ytterbium", 70, 103, -1, null, "Yb", + false); + public static final Element Lu = REGISTRATE.element("Lutetium", 71, 103, -1, null, "Lu", + false); + public static final Element Hf = REGISTRATE.element("Hafnium", 72, 106, -1, null, "Hf", false); + public static final Element Ta = REGISTRATE.element("Tantalum", 73, 107, -1, null, "Ta", + false); + public static final Element W = REGISTRATE.element("Tungsten", 74, 109, -1, null, "W", false); + public static final Element Re = REGISTRATE.element("Rhenium", 75, 111, -1, null, "Re", false); + public static final Element Os = REGISTRATE.element("Osmium", 76, 114, -1, null, "Os", false); + public static final Element Ir = REGISTRATE.element("Iridium", 77, 115, -1, null, "Ir", false); + public static final Element Pt = REGISTRATE.element("Platinum", 78, 117, -1, null, "Pt", + false); + public static final Element Au = REGISTRATE.element("Gold", 79, 117, -1, null, "Au", false); + public static final Element Hg = REGISTRATE.element("Mercury", 80, 120, -1, null, "Hg", false); + public static final Element Tl = REGISTRATE.element("Thallium", 81, 123, -1, null, "Tl", + false); + public static final Element Pb = REGISTRATE.element("Lead", 82, 125, -1, null, "Pb", false); + public static final Element Bi = REGISTRATE.element("Bismuth", 83, 125, -1, null, "Bi", false); + public static final Element Po = REGISTRATE.element("Polonium", 84, 124, -1, null, "Po", false); - public static final Element At = createAndRegister(GTCEu.id("Astatine"), 85, 124, -1, null, "Astatine", "At", + public static final Element At = REGISTRATE.element("Astatine", 85, 124, -1, null, "At", false); - public static final Element Rn = createAndRegister(GTCEu.id("Radon"), 86, 134, -1, null, "Radon", "Rn", false); - public static final Element Fr = createAndRegister(GTCEu.id("Francium"), 87, 134, -1, null, "Francium", "Fr", + public static final Element Rn = REGISTRATE.element("Radon", 86, 134, -1, null, "Rn", false); + public static final Element Fr = REGISTRATE.element("Francium", 87, 134, -1, null, "Fr", false); - public static final Element Ra = createAndRegister(GTCEu.id("Radium"), 88, 136, -1, null, "Radium", "Ra", false); - public static final Element Ac = createAndRegister(GTCEu.id("Actinium"), 89, 136, -1, null, "Actinium", "Ac", + public static final Element Ra = REGISTRATE.element("Radium", 88, 136, -1, null, "Ra", false); + public static final Element Ac = REGISTRATE.element("Actinium", 89, 136, -1, null, "Ac", false); - public static final Element Th = createAndRegister(GTCEu.id("Thorium"), 90, 140, -1, null, "Thorium", "Th", false); - public static final Element Pa = createAndRegister(GTCEu.id("Protactinium"), 91, 138, -1, null, "Protactinium", + public static final Element Th = REGISTRATE.element("Thorium", 90, 140, -1, null, "Th", false); + public static final Element Pa = REGISTRATE.element("Protactinium", 91, 138, -1, null, "Pa", false); - public static final Element U = createAndRegister(GTCEu.id("Uranium"), 92, 146, -1, null, "Uranium", "U", false); - public static final Element U238 = createAndRegister(GTCEu.id("Uranium-238"), 92, 146, -1, null, "Uranium-238", + public static final Element U = REGISTRATE.element("Uranium", 92, 146, -1, null, "U", false); + public static final Element U238 = REGISTRATE.element("Uranium-238", 92, 146, -1, null, "U-238", false); - public static final Element U235 = createAndRegister(GTCEu.id("Uranium-235"), 92, 143, -1, null, "Uranium-235", + public static final Element U235 = REGISTRATE.element("Uranium-235", 92, 143, -1, null, "U-235", true); - public static final Element Np = createAndRegister(GTCEu.id("Neptunium"), 93, 144, -1, null, "Neptunium", "Np", + public static final Element Np = REGISTRATE.element("Neptunium", 93, 144, -1, null, "Np", false); - public static final Element Pu = createAndRegister(GTCEu.id("Plutonium"), 94, 152, -1, null, "Plutonium", "Pu", + public static final Element Pu = REGISTRATE.element("Plutonium", 94, 152, -1, null, "Pu", false); - public static final Element Pu239 = createAndRegister(GTCEu.id("Plutonium-239"), 94, 145, -1, null, "Plutonium-239", + public static final Element Pu239 = REGISTRATE.element("Plutonium-239", 94, 145, -1, null, "Pu-239", false); - public static final Element Pu241 = createAndRegister(GTCEu.id("Plutonium-241"), 94, 149, -1, null, "Plutonium-241", + public static final Element Pu241 = REGISTRATE.element("Plutonium-241", 94, 149, -1, null, "Pu-241", true); - public static final Element Am = createAndRegister(GTCEu.id("Americium"), 95, 150, -1, null, "Americium", "Am", + public static final Element Am = REGISTRATE.element("Americium", 95, 150, -1, null, "Am", false); - public static final Element Cm = createAndRegister(GTCEu.id("Curium"), 96, 153, -1, null, "Curium", "Cm", false); - public static final Element Bk = createAndRegister(GTCEu.id("Berkelium"), 97, 152, -1, null, "Berkelium", "Bk", + public static final Element Cm = REGISTRATE.element("Curium", 96, 153, -1, null, "Cm", false); + public static final Element Bk = REGISTRATE.element("Berkelium", 97, 152, -1, null, "Bk", false); - public static final Element Cf = createAndRegister(GTCEu.id("Californium"), 98, 153, -1, null, "Californium", "Cf", + public static final Element Cf = REGISTRATE.element("Californium", 98, 153, -1, null, "Cf", false); - public static final Element Es = createAndRegister(GTCEu.id("Einsteinium"), 99, 153, -1, null, "Einsteinium", "Es", + public static final Element Es = REGISTRATE.element("Einsteinium", 99, 153, -1, null, "Es", false); - public static final Element Fm = createAndRegister(GTCEu.id("Fermium"), 100, 157, -1, null, "Fermium", "Fm", false); - public static final Element Md = createAndRegister(GTCEu.id("Mendelevium"), 101, 157, -1, null, "Mendelevium", "Md", + public static final Element Fm = REGISTRATE.element("Fermium", 100, 157, -1, null, "Fm", false); + public static final Element Md = REGISTRATE.element("Mendelevium", 101, 157, -1, null, "Md", false); - public static final Element No = createAndRegister(GTCEu.id("Nobelium"), 102, 157, -1, null, "Nobelium", "No", + public static final Element No = REGISTRATE.element("Nobelium", 102, 157, -1, null, "No", false); - public static final Element Lr = createAndRegister(GTCEu.id("Lawrencium"), 103, 159, -1, null, "Lawrencium", "Lr", + public static final Element Lr = REGISTRATE.element("Lawrencium", 103, 159, -1, null, "Lr", false); - public static final Element Rf = createAndRegister(GTCEu.id("Rutherfordium"), 104, 161, -1, null, "Rutherfordium", + public static final Element Rf = REGISTRATE.element("Rutherfordium", 104, 161, -1, null, "Rf", false); - public static final Element Db = createAndRegister(GTCEu.id("Dubnium"), 105, 163, -1, null, "Dubnium", "Db", false); - public static final Element Sg = createAndRegister(GTCEu.id("Seaborgium"), 106, 165, -1, null, "Seaborgium", "Sg", + public static final Element Db = REGISTRATE.element("Dubnium", 105, 163, -1, null, "Db", false); + public static final Element Sg = REGISTRATE.element("Seaborgium", 106, 165, -1, null, "Sg", false); - public static final Element Bh = createAndRegister(GTCEu.id("Bohrium"), 107, 163, -1, null, "Bohrium", "Bh", false); - public static final Element Hs = createAndRegister(GTCEu.id("Hassium"), 108, 169, -1, null, "Hassium", "Hs", false); - public static final Element Mt = createAndRegister(GTCEu.id("Meitnerium"), 109, 167, -1, null, "Meitnerium", "Mt", + public static final Element Bh = REGISTRATE.element("Bohrium", 107, 163, -1, null, "Bh", false); + public static final Element Hs = REGISTRATE.element("Hassium", 108, 169, -1, null, "Hs", false); + public static final Element Mt = REGISTRATE.element("Meitnerium", 109, 167, -1, null, "Mt", false); - public static final Element Ds = createAndRegister(GTCEu.id("Darmstadtium"), 110, 171, -1, null, "Darmstadtium", + public static final Element Ds = REGISTRATE.element("Darmstadtium", 110, 171, -1, null, "Ds", false); - public static final Element Rg = createAndRegister(GTCEu.id("Roentgenium"), 111, 169, -1, null, "Roentgenium", "Rg", + public static final Element Rg = REGISTRATE.element("Roentgenium", 111, 169, -1, null, "Rg", false); - public static final Element Cn = createAndRegister(GTCEu.id("Copernicium"), 112, 173, -1, null, "Copernicium", "Cn", + public static final Element Cn = REGISTRATE.element("Copernicium", 112, 173, -1, null, "Cn", false); - public static final Element Nh = createAndRegister(GTCEu.id("Nihonium"), 113, 171, -1, null, "Nihonium", "Nh", + public static final Element Nh = REGISTRATE.element("Nihonium", 113, 171, -1, null, "Nh", false); - public static final Element Fl = createAndRegister(GTCEu.id("Flerovium"), 114, 175, -1, null, "Flerovium", "Fl", + public static final Element Fl = REGISTRATE.element("Flerovium", 114, 175, -1, null, "Fl", false); - public static final Element Mc = createAndRegister(GTCEu.id("Moscovium"), 115, 173, -1, null, "Moscovium", "Mc", + public static final Element Mc = REGISTRATE.element("Moscovium", 115, 173, -1, null, "Mc", false); - public static final Element Lv = createAndRegister(GTCEu.id("Livermorium"), 116, 177, -1, null, "Livermorium", "Lv", + public static final Element Lv = REGISTRATE.element("Livermorium", 116, 177, -1, null, "Lv", false); - public static final Element Ts = createAndRegister(GTCEu.id("Tennessine"), 117, 177, -1, null, "Tennessine", "Ts", + public static final Element Ts = REGISTRATE.element("Tennessine", 117, 177, -1, null, "Ts", false); - public static final Element Og = createAndRegister(GTCEu.id("Oganesson"), 118, 176, -1, null, "Oganesson", "Og", + public static final Element Og = REGISTRATE.element("Oganesson", 118, 176, -1, null, "Og", false); - public static final Element Tr = createAndRegister(GTCEu.id("Tritanium"), 119, 178, -1, null, "Tritanium", "Tr", + public static final Element Tr = REGISTRATE.element("Tritanium", 119, 178, -1, null, "Tr", false); - public static final Element Dr = createAndRegister(GTCEu.id("Duranium"), 120, 180, -1, null, "Duranium", "Dr", + public static final Element Dr = REGISTRATE.element("Duranium", 120, 180, -1, null, "Dr", false); - public static final Element Ke = createAndRegister(GTCEu.id("Trinium"), 125, 198, -1, null, "Trinium", "Ke", false); - public static final Element Nq = createAndRegister(GTCEu.id("Naquadah"), 174, 352, 140, null, "Naquadah", "Nq", + public static final Element Ke = REGISTRATE.element("Trinium", 125, 198, -1, null, "Ke", false); + public static final Element Nq = REGISTRATE.element("Naquadah", 174, 352, 140, null, "Nq", true); - public static final Element Nq1 = createAndRegister(GTCEu.id("NaquadahEnriched"), 174, 354, 140, null, - "NaquadahEnriched", "Nq+", true); - public static final Element Nq2 = createAndRegister(GTCEu.id("Naquadria"), 174, 348, 140, null, "Naquadria", "*Nq*", + public static final Element Nq1 = REGISTRATE.element("NaquadahEnriched", 174, 354, 140, null, + "Nq+", true); + public static final Element Nq2 = REGISTRATE.element("Naquadria", 174, 348, 140, null, "*Nq*", true); - public static final Element Nt = createAndRegister(GTCEu.id("Neutronium"), 0, 1000, -1, null, "Neutronium", "Nt", + public static final Element Nt = REGISTRATE.element("Neutronium", 0, 1000, -1, null, "Nt", false); - public static final Element Sp = createAndRegister(GTCEu.id("Space"), 1, 0, -1, null, "Space", "Sp", false); - public static final Element Ma = createAndRegister(GTCEu.id("Magic"), 1, 0, -1, null, "Magic", "Ma", false); - - /** - * @deprecated Use - * {@link GTElements#createAndRegister(ResourceLocation, long, long, long, String, String, String, boolean)} - */ - @Deprecated - public static Element createAndRegister(long protons, long neutrons, long halfLifeSeconds, String decayTo, - String name, String symbol, boolean isIsotope) { - return createAndRegister(GTCEu.id(name), protons, neutrons, halfLifeSeconds, decayTo, name, symbol, isIsotope); - } - - public static Element createAndRegister(ResourceLocation id, long protons, long neutrons, long halfLifeSeconds, - String decayTo, - String name, String symbol, boolean isIsotope) { - Element element = new Element(protons, neutrons, halfLifeSeconds, decayTo, name, symbol, isIsotope); - GTRegistries.ELEMENTS.register(id, element); - return element; - } - - public static void init() { - AddonFinder.getAddons().forEach(IGTAddon::registerElements); - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.ELEMENTS, Element.class)); - if (GTCEu.Mods.isKubeJSLoaded()) { - GTRegistryInfo.registerFor(GTRegistries.ELEMENTS.getRegistryName()); - } - GTRegistries.ELEMENTS.freeze(); - } + public static final Element Sp = REGISTRATE.element("Space", 1, 0, -1, null, "Sp", false); + public static final Element Ma = REGISTRATE.element("Magic", 1, 0, -1, null, "Ma", false); - /** - * @deprecated Use {@code GTRegistries.ELEMENTS.get(name)} instead - */ - @Deprecated(since = "8.0.0") - public static Element get(String name) { - return GTRegistries.ELEMENTS.get(GTCEu.id(name)); - } + public static void init() {} } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTFeatures.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTFeatures.java index e888a9636f8..aca55315ed6 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTFeatures.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTFeatures.java @@ -1,12 +1,8 @@ package com.gregtechceu.gtceu.common.data; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.data.worldgen.modifier.BiomePlacement; -import com.gregtechceu.gtceu.api.data.worldgen.modifier.DimensionFilter; -import com.gregtechceu.gtceu.api.data.worldgen.modifier.FrequencyModifier; import com.gregtechceu.gtceu.common.worldgen.feature.FluidSproutFeature; import com.gregtechceu.gtceu.common.worldgen.feature.StoneBlobFeature; -import com.gregtechceu.gtceu.common.worldgen.modifier.RubberTreeChancePlacement; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; @@ -28,18 +24,7 @@ public class GTFeatures { public static final RegistryObject FLUID_SPROUT = FEATURE_REGISTER.register("fluid_sprout", FluidSproutFeature::new); - public static void init() { - Object inst = FrequencyModifier.FREQUENCY_MODIFIER; // seemingly useless access to init the class in time - inst = DimensionFilter.DIMENSION_FILTER; - inst = BiomePlacement.BIOME_PLACEMENT; - inst = RubberTreeChancePlacement.RUBBER_TREE_CHANCE_PLACEMENT; - } - public static void init(IEventBus modEventBus) { FEATURE_REGISTER.register(modEventBus); } - - public static void register() { - // no-op - } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java index fafef5889c9..2b2f2e84ee5 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java @@ -2559,11 +2559,7 @@ public static ItemEntry createFluidCell(Material mat, int capacit .onRegister(attach(new GuiModuleBehaviour())) .register(); - public static void init() { - GTMaterialItems.generateMaterialItems(); - GTMaterialItems.generateTools(); - GTMaterialItems.generateArmors(); - } + public static void init() {} public static NonNullConsumer materialInfo(ItemMaterialInfo materialInfo) { return item -> ItemMaterialData.registerMaterialInfo(item, materialInfo); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java index 55b6c5be64d..ca001523d41 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTMachines.java @@ -16,7 +16,6 @@ import com.gregtechceu.gtceu.api.machine.steam.SteamBoilerMachine; import com.gregtechceu.gtceu.api.multiblock.util.RelativeDirection; import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.client.model.machine.MachineRenderState; import com.gregtechceu.gtceu.client.renderer.machine.DynamicRenderHelper; import com.gregtechceu.gtceu.client.util.TooltipHelper; import com.gregtechceu.gtceu.common.data.machines.*; @@ -37,7 +36,6 @@ import com.gregtechceu.gtceu.common.pipelike.item.longdistance.LDItemEndpointMachine; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.lang.LangHandler; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.utils.FormattingUtil; import net.minecraft.ChatFormatting; @@ -46,7 +44,6 @@ import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidType; -import net.minecraftforge.fml.ModLoader; import com.google.common.math.IntMath; import it.unimi.dsi.fastutil.Pair; @@ -69,7 +66,6 @@ public class GTMachines { static { REGISTRATE.creativeModeTab(() -> MACHINE); - GTRegistries.MACHINES.unfreeze(); } ////////////////////////////////////// @@ -1178,19 +1174,6 @@ public static void init() { if (GTCEu.Mods.isAE2Loaded()) { GTAEMachines.init(); } - - if (GTCEu.Mods.isKubeJSLoaded()) { - GTRegistryInfo.registerFor(GTRegistries.MACHINES.getRegistryName()); - } - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.MACHINES, MachineDefinition.class)); - - GTRegistries.MACHINES.freeze(); - - for (MachineDefinition machine : GTRegistries.MACHINES) { - for (MachineRenderState renderState : machine.getStateDefinition().getPossibleStates()) { - MachineDefinition.RENDER_STATE_REGISTRY.add(renderState); - } - } } public static MachineDefinition get(String name) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterialBlocks.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterialBlocks.java index 9dc90845be7..f742076b918 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterialBlocks.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterialBlocks.java @@ -15,7 +15,6 @@ import com.gregtechceu.gtceu.common.pipelike.cable.Insulation; import com.gregtechceu.gtceu.common.pipelike.fluidpipe.FluidPipeType; import com.gregtechceu.gtceu.common.pipelike.item.ItemPipeType; -import com.gregtechceu.gtceu.utils.FormattingUtil; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.block.Block; @@ -34,15 +33,15 @@ public class GTMaterialBlocks { // Reference Table Builders - static ImmutableTable.Builder> MATERIAL_BLOCKS_BUILDER = ImmutableTable + private static ImmutableTable.Builder> MATERIAL_BLOCKS_BUILDER = ImmutableTable .builder(); - static ImmutableMap.Builder> SURFACE_ROCK_BLOCKS_BUILDER = ImmutableMap + private static ImmutableMap.Builder> SURFACE_ROCK_BLOCKS_BUILDER = ImmutableMap .builder(); - static ImmutableTable.Builder> CABLE_BLOCKS_BUILDER = ImmutableTable + private static ImmutableTable.Builder> CABLE_BLOCKS_BUILDER = ImmutableTable .builder(); - static ImmutableTable.Builder> FLUID_PIPE_BLOCKS_BUILDER = ImmutableTable + private static ImmutableTable.Builder> FLUID_PIPE_BLOCKS_BUILDER = ImmutableTable .builder(); - static ImmutableTable.Builder> ITEM_PIPE_BLOCKS_BUILDER = ImmutableTable + private static ImmutableTable.Builder> ITEM_PIPE_BLOCKS_BUILDER = ImmutableTable .builder(); // Reference Tables @@ -56,7 +55,7 @@ public class GTMaterialBlocks { public static void generateMaterialBlocks() { GTCEu.LOGGER.debug("Generating GTCEu Material Blocks..."); - for (TagPrefix tagPrefix : TagPrefix.values()) { + for (TagPrefix tagPrefix : GTRegistries.TAG_PREFIXES) { if (!TagPrefix.ORES.containsKey(tagPrefix) && tagPrefix.doGenerateBlock()) { for (Material material : GTRegistries.MATERIALS) { if (tagPrefix.doGenerateBlock(material)) { @@ -110,7 +109,7 @@ private static void registerOreBlock(Material material, GTRegistrate registrate) final TagPrefix.OreType oreType = ore.getValue(); String typePrefix = ""; if (oreTag != TagPrefix.ore) { - typePrefix = FormattingUtil.toLowerCaseUnderscore(oreTag.name) + "_"; + typePrefix = oreTag.getName() + "_"; } var entry = registrate.block("%s%s_ore".formatted(typePrefix, material.getName()), properties -> oreTag.blockConstructor().create(properties, oreTag, material)) @@ -144,7 +143,6 @@ public static void generateOreIndicators() { registerOreIndicator(material, GTRegistrate.createIgnoringListenerErrors(material.getModid())); } } - SURFACE_ROCK_BLOCKS = SURFACE_ROCK_BLOCKS_BUILDER.build(); GTCEu.LOGGER.debug("Generating GTCEu Surface Rock Indicator Blocks... Complete!"); } @@ -182,7 +180,6 @@ public static void generateCableBlocks() { } } } - CABLE_BLOCKS = CABLE_BLOCKS_BUILDER.build(); GTCEu.LOGGER.debug("Generating GTCEu Cable/Wire Blocks... Complete!"); } @@ -223,7 +220,6 @@ public static void generateFluidPipeBlocks() { } } } - FLUID_PIPE_BLOCKS = FLUID_PIPE_BLOCKS_BUILDER.build(); GTCEu.LOGGER.debug("Generating GTCEu Fluid Pipe Blocks... Complete!"); } @@ -269,7 +265,6 @@ public static void generateItemPipeBlocks() { } } } - ITEM_PIPE_BLOCKS = ITEM_PIPE_BLOCKS_BUILDER.build(); GTCEu.LOGGER.debug("Generating GTCEu Item Pipe Blocks... Complete!"); } @@ -302,4 +297,17 @@ private static void registerItemPipeBlock(Material material, ItemPipeType itemPi .register(); ITEM_PIPE_BLOCKS_BUILDER.put(itemPipeType.getTagPrefix(), material, entry); } + + public static void finaliseMaterialBlocks() { + MATERIAL_BLOCKS = MATERIAL_BLOCKS_BUILDER.buildOrThrow(); + MATERIAL_BLOCKS_BUILDER = null; + SURFACE_ROCK_BLOCKS = SURFACE_ROCK_BLOCKS_BUILDER.buildOrThrow(); + SURFACE_ROCK_BLOCKS_BUILDER = null; + ITEM_PIPE_BLOCKS = ITEM_PIPE_BLOCKS_BUILDER.buildOrThrow(); + ITEM_PIPE_BLOCKS_BUILDER = null; + FLUID_PIPE_BLOCKS = FLUID_PIPE_BLOCKS_BUILDER.buildOrThrow(); + FLUID_PIPE_BLOCKS_BUILDER = null; + CABLE_BLOCKS = CABLE_BLOCKS_BUILDER.buildOrThrow(); + CABLE_BLOCKS_BUILDER = null; + } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterialItems.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterialItems.java index f9c52f2da96..579e02fcaac 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterialItems.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterialItems.java @@ -18,7 +18,6 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.ItemLike; -import com.google.common.collect.ArrayTable; import com.google.common.collect.ImmutableTable; import com.google.common.collect.Table; import com.tterrag.registrate.providers.ProviderType; @@ -26,7 +25,6 @@ import com.tterrag.registrate.util.entry.ItemProviderEntry; import com.tterrag.registrate.util.nullness.NonNullBiConsumer; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.function.Supplier; @@ -35,13 +33,20 @@ import static com.gregtechceu.gtceu.common.data.GTCreativeModeTabs.TOOL; import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; -@SuppressWarnings("UnstableApiUsage") public class GTMaterialItems { + public static void init() {} + // Reference Table Builders static ImmutableTable.Builder> MATERIAL_ITEMS_BUILDER = ImmutableTable .builder(); + static ImmutableTable.Builder> TOOL_ITEMS_BUILDER = ImmutableTable + .builder(); + + static ImmutableTable.Builder> ARMOR_ITEMS_BUILDER = ImmutableTable + .builder(); + // Reference Maps public static final Map> toUnify = new HashMap<>(); public static final Map purifyMap = new HashMap<>(); @@ -54,21 +59,13 @@ public class GTMaterialItems { // Reference Tables public static Table> MATERIAL_ITEMS; - public static final Table> TOOL_ITEMS = ArrayTable.create( - GTRegistries.MATERIALS.values().stream() - .filter(mat -> mat.hasProperty(PropertyKey.TOOL)) - .toList(), - GTToolType.getTypes().values().stream().toList()); - public static final Table> ARMOR_ITEMS = ArrayTable.create( - GTRegistries.MATERIALS.values().stream() - .filter(mat -> mat.hasProperty(PropertyKey.ARMOR)) - .toList(), - Arrays.asList(ArmorItem.Type.values())); + public static Table> TOOL_ITEMS; + public static Table> ARMOR_ITEMS; // Material Items public static void generateMaterialItems() { REGISTRATE.creativeModeTab(() -> MATERIAL_ITEM); - for (var tagPrefix : TagPrefix.values()) { + for (var tagPrefix : GTRegistries.TAG_PREFIXES) { if (tagPrefix.doGenerateItem()) { for (Material material : GTRegistries.MATERIALS) { if (tagPrefix.doGenerateItem(material)) { @@ -110,12 +107,13 @@ public static void generateTools() { } } } + TOOL_ITEMS = TOOL_ITEMS_BUILDER.build(); } @SuppressWarnings("unchecked") private static void generateTool(Material material, GTToolType toolType, GTRegistrate registrate) { var tier = material.getToolTier(); - TOOL_ITEMS.put(material, toolType, (ItemProviderEntry) (ItemProviderEntry) registrate + TOOL_ITEMS_BUILDER.put(material, toolType, (ItemProviderEntry) (ItemProviderEntry) registrate .item(toolType.idFormat.formatted(tier.material.getName()), p -> toolType.constructor.apply(toolType, tier, material, toolType.toolDefinition, p).asItem()) @@ -136,12 +134,13 @@ public static void generateArmors() { } } } + ARMOR_ITEMS = ARMOR_ITEMS_BUILDER.build(); } private static void generateArmor(final Material material, final ArmorItem.Type type, GTRegistrate registrate) { var property = material.getProperty(PropertyKey.ARMOR); if (property.isDyeable()) { - ARMOR_ITEMS.put(material, type, registrate + ARMOR_ITEMS_BUILDER.put(material, type, registrate .item("%s_%s".formatted(material.getName(), type.getName()), p -> new GTDyeableArmorItem(property.getArmorMaterial(), type, p, material, property)) @@ -150,7 +149,7 @@ private static void generateArmor(final Material material, final ArmorItem.Type .color(() -> GTArmorItem::tintColor) .register()); } else { - ARMOR_ITEMS.put(material, type, registrate + ARMOR_ITEMS_BUILDER.put(material, type, registrate .item("%s_%s".formatted(material.getName(), type.getName()), p -> new GTArmorItem(property.getArmorMaterial(), type, p, material, property)) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTMedicalConditions.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTMedicalConditions.java index 795b25d83d9..b74c6ab6609 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTMedicalConditions.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTMedicalConditions.java @@ -1,63 +1,60 @@ package com.gregtechceu.gtceu.common.data; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition; import com.gregtechceu.gtceu.api.data.medicalcondition.Symptom; -import com.gregtechceu.gtceu.api.registry.GTRegistries; - -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fml.ModLoader; import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.dust; import static com.gregtechceu.gtceu.common.data.GTMaterials.*; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; public class GTMedicalConditions { - static { - GTRegistries.MEDICAL_CONDITIONS.unfreeze(); - } - // General Conditions - public static final MedicalCondition NONE = register("none", 0xffffff, 0, + public static final MedicalCondition NONE = REGISTRATE.medicalCondition("none", 0xffffff, 0, MedicalCondition.IdleProgressionType.NONE, 0, false); + // takes 5 minutes of having burn-causing items in the player's inventory for them to get the weakness effect // heals 2 seconds' worth of progression every second when not holding those items - public static final MedicalCondition CHEMICAL_BURNS = register("chemical_burns", 0xbc305a, 300, + public static final MedicalCondition CHEMICAL_BURNS = REGISTRATE.medicalCondition("chemical_burns", 0xbc305a, 300, MedicalCondition.IdleProgressionType.HEAL, 2, false, new Symptom.ConfiguredSymptom(Symptom.WEAKNESS)) .setRecipeModifier(builder -> builder .outputFluids(DilutedHydrochloricAcid.getFluid(500)) .outputFluids(DilutedSulfuricAcid.getFluid(750))); + // takes 5 minutes of having poisonous items in the player's inventory for them to get the weakness effect // at 10 minutes, they get a weaker version of the poison effect // heals 2 seconds' worth of progression every second when not holding those items - public static final MedicalCondition POISON = register("poison", 0xA36300, 600, + public static final MedicalCondition POISON = REGISTRATE.medicalCondition("poison", 0xA36300, 600, MedicalCondition.IdleProgressionType.HEAL, 2, true, new Symptom.ConfiguredSymptom(Symptom.WEAK_POISONING), new Symptom.ConfiguredSymptom(Symptom.WEAKNESS, 300, 600)) .setRecipeModifier(builder -> builder .outputFluids(SulfurTrioxide.getFluid(1000))); + // having weakly poisonous items in the player's inventory gives them the weak poison effect // the effect ramps up in 6 "stages", getting progressively worse every stage. It caps out at Weak Poison 10. // does NOT heal automatically - public static final MedicalCondition WEAK_POISON = register("weak_poison", 0x6D7917, 1800, + public static final MedicalCondition WEAK_POISON = REGISTRATE.medicalCondition("weak_poison", 0x6D7917, 1800, MedicalCondition.IdleProgressionType.NONE, 0, false, new Symptom.ConfiguredSymptom(Symptom.WEAK_POISONING, 6, 1800)) .setRecipeModifier(builder -> builder .outputFluids(NitricOxide.getFluid(1000))); + // takes 2.5 minutes of having irritating items in the player's inventory for them to get the weakness effect // at 5 minutes, they begin getting random damage every so often // heals 5 seconds' worth of progression every second when not holding those items - public static final MedicalCondition IRRITANT = register("irritant", 0x02512f, 600, + public static final MedicalCondition IRRITANT = REGISTRATE.medicalCondition("irritant", 0x02512f, 600, MedicalCondition.IdleProgressionType.HEAL, 5, false, new Symptom.ConfiguredSymptom(Symptom.RANDOM_DAMAGE), new Symptom.ConfiguredSymptom(Symptom.WEAKNESS, 300, 600)) .setRecipeModifier(builder -> builder .outputItems(dust, DarkAsh, 4)); + // takes 5 minutes of having nauseating items in the player's inventory for them to get the nausea effect // heals 5 seconds' worth of progression every second when not holding those items - public static final MedicalCondition NAUSEA = register("nausea", 0x1D4A00, 600, + public static final MedicalCondition NAUSEA = REGISTRATE.medicalCondition("nausea", + 0x1D4A00, 600, MedicalCondition.IdleProgressionType.HEAL, 5, false, new Symptom.ConfiguredSymptom(Symptom.NAUSEA, 1, 420, 600)) .setRecipeModifier(builder -> builder @@ -81,7 +78,8 @@ public class GTMedicalConditions { * This condition does NOT heal automatically. You can use {@linkplain GTItems#RAD_AWAY_PILL * rad-away pills} to heal it. */ - public static final MedicalCondition CARCINOGEN = register("carcinogen", 0x0f570f, 36000, + public static final MedicalCondition CARCINOGEN = REGISTRATE.medicalCondition("carcinogen", + 0x0f570f, 36000, MedicalCondition.IdleProgressionType.NONE, 0, true, new Symptom.ConfiguredSymptom(Symptom.DEATH), new Symptom.ConfiguredSymptom(Symptom.HEALTH_DEBUFF, 10800, 21600), @@ -92,15 +90,13 @@ public class GTMedicalConditions { new Symptom.ConfiguredSymptom(Symptom.WEAKNESS, 3600, 14400)); // Material specific Conditions - public static final MedicalCondition ASBESTOSIS = register("asbestosis", 0xe3e3e3, 5000, + public static final MedicalCondition ASBESTOSIS = REGISTRATE.medicalCondition("asbestosis", 0xe3e3e3, 5000, MedicalCondition.IdleProgressionType.HEAL, 1, true, - // new Symptom.ConfiguredSymptom(Symptom.HEALTH_DEBUFF, 3000, 5000), - // new Symptom.ConfiguredSymptom(Symptom.AIR_SUPPLY_DEBUFF, 1500, 3500), - // new Symptom.ConfiguredSymptom(Symptom.HUNGER, 500, 4000), new Symptom.ConfiguredSymptom(Symptom.WEAKNESS, 1200, 5000)) .setRecipeModifier(builder -> builder .outputItems(dust, Asbestos, 4)); - public static final MedicalCondition ARSENICOSIS = register("arsenicosis", 0xbd4b15, 1000, + + public static final MedicalCondition ARSENICOSIS = REGISTRATE.medicalCondition("arsenicosis", 0xbd4b15, 1000, MedicalCondition.IdleProgressionType.HEAL, 1, true, new Symptom.ConfiguredSymptom(Symptom.WITHER), new Symptom.ConfiguredSymptom(Symptom.NAUSEA), @@ -109,45 +105,24 @@ public class GTMedicalConditions { // new Symptom.ConfiguredSymptom(Symptom.HUNGER, 2, .2f)) .setRecipeModifier(builder -> builder .outputItems(dust, Arsenic, 4)); - public static final MedicalCondition METHANOL_POISONING = register("methanol_poisoning", 0xaa8800, 600, - MedicalCondition.IdleProgressionType.HEAL, .5f, true, - new Symptom.ConfiguredSymptom(Symptom.POISONING), - new Symptom.ConfiguredSymptom(Symptom.BLINDNESS, 2, 450, 600), - new Symptom.ConfiguredSymptom(Symptom.WEAKNESS, 2, 300, 600), - new Symptom.ConfiguredSymptom(Symptom.SLOWNESS, 1, 150, 600)) + + public static final MedicalCondition METHANOL_POISONING = REGISTRATE + .medicalCondition("methanol_poisoning", 0xaa8800, 600, + MedicalCondition.IdleProgressionType.HEAL, .5f, true, + new Symptom.ConfiguredSymptom(Symptom.POISONING), + new Symptom.ConfiguredSymptom(Symptom.BLINDNESS, 2, 450, 600), + new Symptom.ConfiguredSymptom(Symptom.WEAKNESS, 2, 300, 600), + new Symptom.ConfiguredSymptom(Symptom.SLOWNESS, 1, 150, 600)) .setRecipeModifier(builder -> builder .outputFluids(Methanol.getFluid(1000))); - public static final MedicalCondition CARBON_MONOXIDE_POISONING = register("carbon_monoxide_poisoning", - 0x041525, 2000, MedicalCondition.IdleProgressionType.HEAL, 1, true, - new Symptom.ConfiguredSymptom(Symptom.DEATH), + + public static final MedicalCondition CARBON_MONOXIDE_POISONING = REGISTRATE.medicalCondition( + "carbon_monoxide_poisoning", + 0x041525, 2000, + MedicalCondition.IdleProgressionType.HEAL, 1, true, new Symptom.ConfiguredSymptom(Symptom.DEATH), new Symptom.ConfiguredSymptom(Symptom.NAUSEA), new Symptom.ConfiguredSymptom(Symptom.SLOWNESS, 2, 1500, 2000), - new Symptom.ConfiguredSymptom(Symptom.WEAKNESS, 2, 500, 2000)) - .setRecipeModifier(builder -> builder - .outputFluids(CarbonMonoxide.getFluid(1000))); - - public static MedicalCondition register(ResourceLocation id, int color, - int maxProgression, MedicalCondition.IdleProgressionType progressionType, - float progressionRate, boolean canBePermanent, - Symptom.ConfiguredSymptom... symptoms) { - var condition = new MedicalCondition(id, color, maxProgression, - progressionType, progressionRate, canBePermanent, symptoms); - GTRegistries.MEDICAL_CONDITIONS.register(id, condition); - return condition; - } - - // internal variant of the above that skips having to write `register(GTCEu.id(...` - private static MedicalCondition register(String id, int color, - int maxProgression, MedicalCondition.IdleProgressionType progressionType, - float progressionRate, boolean canBePermanent, - Symptom.ConfiguredSymptom... symptoms) { - return register(GTCEu.id(id), color, maxProgression, progressionType, progressionRate, canBePermanent, - symptoms); - } + new Symptom.ConfiguredSymptom(Symptom.WEAKNESS, 2, 500, 2000)); - public static void init() { - ModLoader.get() - .postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.MEDICAL_CONDITIONS, MedicalCondition.class)); - GTRegistries.MEDICAL_CONDITIONS.freeze(); - } + public static void init() {} } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTOres.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTOres.java index 36f5af9d085..7042e526b29 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTOres.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTOres.java @@ -722,7 +722,7 @@ private static Supplier ore(TagPrefix oreTag, Material material } else if (oreTag == oreNetherrack) { oreKey = new ResourceLocation("nether_%s_ore".formatted(material.getName())); } else { - oreKey = new ResourceLocation("%s_%s_ore".formatted(oreTag.name, material.getName())); + oreKey = new ResourceLocation("%s_%s_ore".formatted(oreTag.getName(), material.getName())); } return BuiltInRegistries.BLOCK.containsKey(oreKey) ? () -> BuiltInRegistries.BLOCK.get(oreKey) : () -> Blocks.AIR; diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTPlaceholders.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTPlaceholders.java index 57527842a4f..01cb413d224 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTPlaceholders.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTPlaceholders.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.common.data; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.*; import com.gregtechceu.gtceu.api.cover.filter.ItemFilter; @@ -52,676 +51,512 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.ModLoader; import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; +@SuppressWarnings("unused") public class GTPlaceholders { - static { - GTRegistries.PLACEHOLDERS.unfreeze(); - } + private static final DeferredRegister PLACEHOLDERS = DeferredRegister + .create(GTRegistries.Keys.PLACEHOLDER, GTCEu.MOD_ID); - public static int countItems(String id, @Nullable IItemHandler itemHandler) { - if (itemHandler == null) return 0; - int cnt = 0; - for (int i = 0; i < itemHandler.getSlots(); i++) { - ItemStack itemStack = itemHandler.getStackInSlot(i); - String itemId = "%s:%s".formatted(itemStack.getItem().getCreatorModId(itemStack), - itemStack.getItem().toString()); - if (itemId.equals(id)) cnt += itemStack.getCount(); - } - return cnt; - } + public static void init(IEventBus modBus) { + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> GTPlaceholders::initRenderers); + PLACEHOLDERS.register(modBus); - public static int countFluids(@Nullable String id, @Nullable IFluidHandler fluidHandler) { - if (fluidHandler == null) return 0; - int cnt = 0; - for (int i = 0; i < fluidHandler.getTanks(); i++) { - FluidStack fluidStack = fluidHandler.getFluidInTank(i); - String fluidId = Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(fluidStack.getFluid())).toString(); - if (id == null || fluidId.equals(id)) cnt += fluidStack.getAmount(); + if (GTCEu.Mods.isAE2Loaded()) { + GTAEPlaceholders.init(modBus); } - return cnt; - } - public static int countItems(@Nullable ItemFilter filter, @Nullable IItemHandler itemHandler) { - if (itemHandler == null) - return -1; - int cnt = 0; - for (int i = 0; i < itemHandler.getSlots(); i++) { - if (filter == null || filter.test(itemHandler.getStackInSlot(i))) - cnt += itemHandler.getStackInSlot(i).getCount(); + if (GTCEu.Mods.isCCTweakedLoaded()) { + CCTweakedPlugin.initPlaceholders(modBus); } - return cnt; } - public static void init() { - DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> GTPlaceholders::initRenderers); - PlaceholderHandler.addPlaceholder(new Placeholder("energy") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 0); - if (ctx.pos() == null) throw new NoTargetException(); - if (ctx.level().getBlockEntity(ctx.pos()) instanceof IEnergyInfoProvider energyInfoProvider) { - return MultiLineComponent.literal(energyInfoProvider.getEnergyInfo().stored().longValue()); + public static final RegistryObject ENERGY = PLACEHOLDERS.register("energy", + () -> new Placeholder("energy") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 0); + if (ctx.pos() == null) throw new NoTargetException(); + if (ctx.level().getBlockEntity(ctx.pos()) instanceof IEnergyInfoProvider energyInfoProvider) { + return MultiLineComponent.literal(energyInfoProvider.getEnergyInfo().stored().longValue()); + } + IEnergyContainer energy = GTCapabilityHelper.getEnergyContainer(ctx.level(), ctx.pos(), ctx.side()); + return MultiLineComponent.literal(energy != null ? energy.getEnergyStored() : 0); } - IEnergyContainer energy = GTCapabilityHelper.getEnergyContainer(ctx.level(), ctx.pos(), ctx.side()); - return MultiLineComponent.literal(energy != null ? energy.getEnergyStored() : 0); - } - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("energyCapacity") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 0); - if (ctx.level().getBlockEntity(ctx.pos()) instanceof IEnergyInfoProvider energyInfoProvider) { - return MultiLineComponent.literal(energyInfoProvider.getEnergyInfo().capacity().longValue()); + @Override + public boolean isView() { + return true; } - IEnergyContainer energy = GTCapabilityHelper.getEnergyContainer(ctx.level(), ctx.pos(), ctx.side()); - return MultiLineComponent.literal(energy != null ? energy.getEnergyCapacity() : 0); - } + }); - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("calc") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - String expression = args.stream().map(MultiLineComponent::toString).reduce("", (a, b) -> a + b); - ParseResult result = GTMath.parseExpression(expression, 0, true); - if (result.isFailure()) - throw new PlaceholderException(result.getError().toString()); - return MultiLineComponent.literal(result.getResult().getNumberValue().toString()); - } + public static final RegistryObject ENERGY_CAPACITY = PLACEHOLDERS.register("energy_capacity", + () -> new Placeholder("energyCapacity") { - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("itemCount") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - if (ctx.pos() == null) throw new NoTargetException(); - IItemHandler itemHandler = GTCapabilityHelper.getItemHandler(ctx.level(), ctx.pos(), ctx.side()); - if (args.isEmpty()) return MultiLineComponent.literal(countItems((ItemFilter) null, itemHandler)); - if (args.size() == 1) return MultiLineComponent - .literal(countItems(GTStringUtils.componentsToString(args.get(0)), itemHandler)); - if (GTStringUtils.equals(args.get(0), "filter")) { - int slot = PlaceholderUtils.toInt(args.get(1)); - if (ctx.itemStackHandler() == null) - throw new NotSupportedException(); - PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); - try { - return MultiLineComponent.literal(countItems( - ItemFilter.loadFilter(ctx.itemStackHandler().getStackInSlot(slot - 1)), itemHandler)); - } catch (NullPointerException e) { - throw new MissingItemException("filter", slot); + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 0); + if (ctx.level().getBlockEntity(ctx.pos()) instanceof IEnergyInfoProvider energyInfoProvider) { + return MultiLineComponent.literal(energyInfoProvider.getEnergyInfo().capacity().longValue()); } + IEnergyContainer energy = GTCapabilityHelper.getEnergyContainer(ctx.level(), ctx.pos(), ctx.side()); + return MultiLineComponent.literal(energy != null ? energy.getEnergyCapacity() : 0); } - throw new InvalidArgsException(); - } - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("fluidCount") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - if (ctx.pos() == null) throw new NoTargetException(); - IFluidHandler fluidHandler = GTCapabilityHelper.getFluidHandler(ctx.level(), ctx.pos(), ctx.side()); - if (args.isEmpty()) return MultiLineComponent.literal(countFluids(null, fluidHandler)); - if (args.size() == 1) - return MultiLineComponent - .literal(countFluids(GTStringUtils.componentsToString(args.get(0)), fluidHandler)); - PlaceholderUtils.checkArgs(args, 1); - return MultiLineComponent.empty(); // unreachable - } + @Override + public boolean isView() { + return true; + } + }); + + public static final RegistryObject CALCULATION = PLACEHOLDERS.register("calc", + () -> new Placeholder("calc") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + String expression = args.stream().map(MultiLineComponent::toString).reduce("", (a, b) -> a + b); + ParseResult result = GTMath.parseExpression(expression, 0, true); + if (result.isFailure()) + throw new PlaceholderException(result.getError().toString()); + return MultiLineComponent.literal(result.getResult().getNumberValue().toString()); + } - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("if") { + @Override + public boolean isPure() { + return true; + } + }); + + public static final RegistryObject ITEM_COUNT = PLACEHOLDERS.register("item_count", + () -> new Placeholder("itemCount") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + if (ctx.pos() == null) throw new NoTargetException(); + IItemHandler itemHandler = GTCapabilityHelper.getItemHandler(ctx.level(), ctx.pos(), ctx.side()); + if (args.isEmpty()) return MultiLineComponent.literal(countItems((ItemFilter) null, itemHandler)); + if (args.size() == 1) return MultiLineComponent + .literal(countItems(GTStringUtils.componentsToString(args.get(0)), itemHandler)); + if (GTStringUtils.equals(args.get(0), "filter")) { + int slot = PlaceholderUtils.toInt(args.get(1)); + if (ctx.itemStackHandler() == null) + throw new NotSupportedException(); + PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); + try { + return MultiLineComponent.literal(countItems( + ItemFilter.loadFilter(ctx.itemStackHandler().getStackInSlot(slot - 1)), + itemHandler)); + } catch (NullPointerException e) { + throw new MissingItemException("filter", slot); + } + } + throw new InvalidArgsException(); + } - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 2, true); - try { - if (GTStringUtils.toDouble(args.get(0)) != 0) { - return new MultiLineComponent(args.get(1)).setIgnoreSpaces(true); - } else if (args.size() > 2) { - return new MultiLineComponent(args.get(2)).setIgnoreSpaces(true); - } else return MultiLineComponent.empty(); - } catch (NumberFormatException e) { - if (args.size() > 2 && args.get(0).equalsString("")) - return args.get(2).setIgnoreSpaces(true); - return args.get(1).setIgnoreSpaces(true); + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject FLUID_COUNT = PLACEHOLDERS.register("fluid_count", + () -> new Placeholder("fluidCount") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + if (ctx.pos() == null) throw new NoTargetException(); + IFluidHandler fluidHandler = GTCapabilityHelper.getFluidHandler(ctx.level(), ctx.pos(), ctx.side()); + if (args.isEmpty()) return MultiLineComponent.literal(countFluids(null, fluidHandler)); + if (args.size() == 1) + return MultiLineComponent + .literal(countFluids(GTStringUtils.componentsToString(args.get(0)), fluidHandler)); + PlaceholderUtils.checkArgs(args, 1); + return MultiLineComponent.empty(); // unreachable } - } - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("color") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 2); - ChatFormatting color = ChatFormatting.getByName(GTStringUtils.componentsToString(args.get(0))); - if (color == null) throw new InvalidArgsException(); - return new MultiLineComponent(args.get(1).stream().map(c -> c.withStyle(color)).toList()); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("underline") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1); - return new MultiLineComponent( - args.get(0).stream().map(c -> c.withStyle(ChatFormatting.UNDERLINE)).toList()); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("strike") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1); - return new MultiLineComponent( - args.get(0).stream().map(c -> c.withStyle(ChatFormatting.STRIKETHROUGH)).toList()); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("obf") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1); - return new MultiLineComponent( - args.get(0).stream().map(c -> c.withStyle(ChatFormatting.OBFUSCATED)).toList()); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("random") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 2); - return MultiLineComponent.literal(GTValues.RNG.nextIntBetweenInclusive( - PlaceholderUtils.toInt(args.get(0)), PlaceholderUtils.toInt(args.get(1)))); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("repeat") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1, true); - int count = PlaceholderUtils.toInt(args.get(0)); - PlaceholderUtils.checkRange("n", 0, 50000, count); - MultiLineComponent arg = MultiLineComponent.empty(); - for (int i = 1; i < args.size(); i++) { - arg.append(args.get(i)); - if (i != args.size() - 1) arg.append(" "); + @Override + public boolean isView() { + return true; } - MultiLineComponent out = MultiLineComponent.empty(); - for (int i = 0; i < count; i++) out.append(arg); - return out.setIgnoreSpaces(true); + }); + + public static RegistryObject IF = PLACEHOLDERS.register("if", () -> new Placeholder("if") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 2, true); + try { + if (GTStringUtils.toDouble(args.get(0)) != 0) { + return new MultiLineComponent(args.get(1)).setIgnoreSpaces(true); + } else if (args.size() > 2) { + return new MultiLineComponent(args.get(2)).setIgnoreSpaces(true); + } else return MultiLineComponent.empty(); + } catch (NumberFormatException e) { + if (args.size() > 2 && args.get(0).equalsString("")) + return args.get(2).setIgnoreSpaces(true); + return args.get(1).setIgnoreSpaces(true); } + } - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("block") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 0); - return MultiLineComponent.literal("â–ˆ"); - } + @Override + public boolean isPure() { + return true; + } + }); - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("tick") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 0); - return MultiLineComponent.literal(ctx.level().getGameTime()); - } + public static RegistryObject COLOR = PLACEHOLDERS.register("color", () -> new Placeholder("color") { - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("select") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1, true); - int i = PlaceholderUtils.toInt(args.get(0)); - PlaceholderUtils.checkArgs(args, i + 1, true); - return new MultiLineComponent(args.get(i + 1)).setIgnoreSpaces(true); - } + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 2); + ChatFormatting color = ChatFormatting.getByName(GTStringUtils.componentsToString(args.get(0))); + if (color == null) throw new InvalidArgsException(); + return new MultiLineComponent(args.get(1).stream().map(c -> c.withStyle(color)).toList()); + } + }); - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("redstone") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 2, true); - if (GTStringUtils.equals(args.get(0), "get")) { - Direction direction = Direction.byName(GTStringUtils.componentsToString(args.get(1))); - if (direction == null) - throw new InvalidArgsException(); - return MultiLineComponent.literal(ctx.level() - .getSignal(ctx.pos().relative(direction), direction)); - } else if (GTStringUtils.equals(args.get(0), "set")) { - int power = PlaceholderUtils.toInt(args.get(1)); - PlaceholderUtils.checkRange("redstone power", 0, 15, power); - if (ctx.cover() == null) throw new NotSupportedException(); - ctx.cover().setRedstoneSignalOutput(power); - return MultiLineComponent.empty(); + public static RegistryObject UNDERLINE = PLACEHOLDERS.register("underline", + () -> new Placeholder("underline") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1); + return new MultiLineComponent( + args.get(0).stream().map(c -> c.withStyle(ChatFormatting.UNDERLINE)).toList()); } - throw new InvalidArgsException(); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("previousText") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1); - int i = PlaceholderUtils.toInt(args.get(0)); - if (ctx.previousText() == null) throw new NotSupportedException(); - PlaceholderUtils.checkRange("line", 1, ctx.previousText().size(), i); - return MultiLineComponent.of(ctx.previousText().get(i - 1)).setIgnoreSpaces(true); - } + }); - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("progress") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 0); - if (ctx.pos() == null) throw new NoTargetException(); - IWorkable workable = GTCapabilityHelper.getWorkable(ctx.level(), - ctx.pos(), ctx.side()); - if (workable == null) throw new NotSupportedException(); - return MultiLineComponent.literal(workable.getProgress()); - } + public static RegistryObject STRIKE = PLACEHOLDERS.register("strike", () -> new Placeholder("strike") { - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("maxProgress") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 0); - if (ctx.pos() == null) throw new NoTargetException(); - IWorkable workable = GTCapabilityHelper.getWorkable(ctx.level(), - ctx.pos(), ctx.side()); - if (workable == null) throw new NotSupportedException(); - return MultiLineComponent.literal(workable.getMaxProgress()); - } + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1); + return new MultiLineComponent( + args.get(0).stream().map(c -> c.withStyle(ChatFormatting.STRIKETHROUGH)).toList()); + } + }); - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("maintenance") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 0); - if (ctx.pos() == null) throw new NoTargetException(); - IMaintenanceMachine maintenance = GTCapabilityHelper.getMaintenanceMachine(ctx.level(), - ctx.pos(), ctx.side()); - if (maintenance == null) throw new NotSupportedException(); - return MultiLineComponent.literal(maintenance.hasMaintenanceProblems() ? 1 : 0); - } + public static RegistryObject OBF = PLACEHOLDERS.register("obf", () -> new Placeholder("obf") { - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("active") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 0); - if (ctx.pos() == null) throw new NoTargetException(); - IWorkable workable = GTCapabilityHelper.getWorkable(ctx.level(), - ctx.pos(), ctx.side()); - if (workable == null) throw new NotSupportedException(); - return MultiLineComponent.literal(workable.isActive() ? 1 : 0); - } + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1); + return new MultiLineComponent( + args.get(0).stream().map(c -> c.withStyle(ChatFormatting.OBFUSCATED)).toList()); + } + }); - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("voltage") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 0); - if (ctx.pos() == null) throw new NoTargetException(); - if (ctx.level().getBlockEntity(ctx.pos()) instanceof CableBlockEntity cable) { - return MultiLineComponent.literal(cable.getAverageVoltage()); - } - throw new NotSupportedException(); - } + public static RegistryObject RANDOM = PLACEHOLDERS.register("random", () -> new Placeholder("random") { - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("amperage") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 0); - if (ctx.pos() == null) throw new NoTargetException(); - if (ctx.level().getBlockEntity(ctx.pos()) instanceof CableBlockEntity cable) { - return MultiLineComponent.literal(cable.getAverageAmperage()); - } - throw new NotSupportedException(); - } + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 2); + return MultiLineComponent.literal(GTValues.RNG.nextIntBetweenInclusive( + PlaceholderUtils.toInt(args.get(0)), PlaceholderUtils.toInt(args.get(1)))); + } + }); + + public static RegistryObject REPEAT = PLACEHOLDERS.register("repeat", () -> new Placeholder("repeat") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1, true); + int count = PlaceholderUtils.toInt(args.get(0)); + PlaceholderUtils.checkRange("n", 0, 50000, count); + MultiLineComponent arg = MultiLineComponent.empty(); + for (int i = 1; i < args.size(); i++) { + arg.append(args.get(i)); + if (i != args.size() - 1) arg.append(" "); + } + MultiLineComponent out = MultiLineComponent.empty(); + for (int i = 0; i < count; i++) out.append(arg); + return out.setIgnoreSpaces(true); + } - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("count") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1, true); - String arg1 = GTStringUtils.componentsToString(args.get(0)); - int cnt = -1; - for (List arg : args) { - if (GTStringUtils.equals(arg, arg1)) cnt++; - } - return MultiLineComponent.literal(cnt); - } + @Override + public boolean isPure() { + return true; + } + }); - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("data") { + public static RegistryObject BLOCK = PLACEHOLDERS.register("block", () -> new Placeholder("block") { - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 2, true); - try { - int slot = PlaceholderUtils.toInt(args.get(1)); - slot = Math.max(slot, 1); - PlaceholderUtils.checkRange("slot index", 1, 8, slot); - if (ctx.itemStackHandler() == null) throw new NotSupportedException(); - PlaceholderUtils.checkRange("slot index", 0, ctx.itemStackHandler().getSlots(), slot); - ItemStack stack; - if (slot == 0) { - if (ctx.monitorGroup() == null) throw new NotSupportedException(); - if (ctx.monitorGroup().getTargetRaw() == null) throw new NoTargetException(); - IMonitorComponent component = GTCapabilityHelper.getMonitorComponent(ctx.level(), - ctx.monitorGroup().getTargetRaw(), null); - if (component != null && component.getDataItems() != null) { - stack = component.getDataItems().getStackInSlot(ctx.monitorGroup().getDataSlot()); - } else throw new NotSupportedException(); - } else stack = ctx.itemStackHandler().getStackInSlot(slot - 1); - int capacity = -1; - if (stack.getItem() instanceof ComponentItem componentItem) { - for (IItemComponent component : componentItem.getComponents()) { - if (component instanceof IDataItem dataComponent) { - capacity = dataComponent.getCapacity(); - break; + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 0); + return MultiLineComponent.literal("â–ˆ"); + } + + @Override + public boolean isPure() { + return true; + } + }); + + public static RegistryObject TICK = PLACEHOLDERS.register("tick", () -> new Placeholder("tick") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 0); + return MultiLineComponent.literal(ctx.level().getGameTime()); + } + + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject SELECT = PLACEHOLDERS.register("select", () -> new Placeholder("select") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1, true); + int i = PlaceholderUtils.toInt(args.get(0)); + PlaceholderUtils.checkArgs(args, i + 1, true); + return new MultiLineComponent(args.get(i + 1)).setIgnoreSpaces(true); + } + + @Override + public boolean isPure() { + return true; + } + }); + + public static RegistryObject REDSTONE = PLACEHOLDERS.register("redstone", + () -> ConfigHolder.INSTANCE.compat.createCompat && GTCEu.Mods.isCreateLoaded() ? + GTCreateIntegration.getCreateRedstonePlaceholder() : new Placeholder("redstone") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 2, true); + if (GTStringUtils.equals(args.get(0), "get")) { + Direction direction = Direction.byName(GTStringUtils.componentsToString(args.get(1))); + if (direction == null) + throw new InvalidArgsException(); + return MultiLineComponent.literal(ctx.level() + .getSignal(ctx.pos().relative(direction), direction)); + } else if (GTStringUtils.equals(args.get(0), "set")) { + int power = PlaceholderUtils.toInt(args.get(1)); + PlaceholderUtils.checkRange("redstone power", 0, 15, power); + if (ctx.cover() == null) throw new NotSupportedException(); + ctx.cover().setRedstoneSignalOutput(power); + return MultiLineComponent.empty(); } + throw new InvalidArgsException(); } - } - if (capacity == -1) throw new MissingItemException("any data item", slot); - PlaceholderUtils.checkRange("index", 0, capacity - 1, PlaceholderUtils.toInt(args.get(2))); - ListTag data = stack.getOrCreateTag().getList("computer_monitor_cover_data", Tag.TAG_STRING); - while (data.size() <= PlaceholderUtils.toInt(args.get(2))) data.add(StringTag.valueOf("")); - int p = stack.getOrCreateTag().getInt("computer_monitor_cover_p"); - if (GTStringUtils.equals(args.get(2), "")) args.set(2, MultiLineComponent.literal(p)); - if (GTStringUtils.equals(args.get(0), "get")) - return MultiLineComponent - .literal(data.getString(PlaceholderUtils.toInt(args.get(2)) % capacity)) - .setIgnoreSpaces(true); - else if (args.get(0).equalsString("set")) { - data.set(PlaceholderUtils.toInt(args.get(2)) % capacity, - StringTag.valueOf(args.get(3).toString())); - stack.getOrCreateTag().put("computer_monitor_cover_data", data); - return MultiLineComponent.empty(); - } else if (args.get(0).equalsString("setp")) { - stack.getOrCreateTag().putInt("computer_monitor_cover_p", - PlaceholderUtils.toInt(args.get(3)) % capacity); - return MultiLineComponent.empty(); - } else if (args.get(0).equalsString("inc")) { - stack.getOrCreateTag().putInt("computer_monitor_cover_p", (p + 1) % capacity); - return MultiLineComponent.empty(); - } else if (args.get(0).equalsString("dec")) { - stack.getOrCreateTag().putInt("computer_monitor_cover_p", p == 0 ? capacity - 1 : p - 1); - return MultiLineComponent.empty(); - } else throw new InvalidArgsException(); - } catch (IndexOutOfBoundsException e) { - throw new InvalidArgsException(); + }); + + public static RegistryObject PREVIOUS_TEXT = PLACEHOLDERS.register("previous_text", + () -> new Placeholder("previousText") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1); + int i = PlaceholderUtils.toInt(args.get(0)); + if (ctx.previousText() == null) throw new NotSupportedException(); + PlaceholderUtils.checkRange("line", 1, ctx.previousText().size(), i); + return MultiLineComponent.of(ctx.previousText().get(i - 1)).setIgnoreSpaces(true); } - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("combine") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, List args) { - MultiLineComponent out = MultiLineComponent.empty(); - for (int i = 0; i < args.size(); i++) { - out.append(args.get(i)); - if (i != args.size() - 1) out.append(" "); + + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject PROGRESS = PLACEHOLDERS.register("progress", + () -> new Placeholder("progress") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 0); + if (ctx.pos() == null) throw new NoTargetException(); + IWorkable workable = GTCapabilityHelper.getWorkable(ctx.level(), + ctx.pos(), ctx.side()); + if (workable == null) throw new NotSupportedException(); + return MultiLineComponent.literal(workable.getProgress()); } - return out.setIgnoreSpaces(true); - } - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("nbt") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1, true); - int slot = GTStringUtils.toInt(args.get(0)); - if (ctx.itemStackHandler() == null) throw new NotSupportedException(); - PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); - Tag tag = ctx.itemStackHandler().getStackInSlot(slot - 1).getOrCreateTag(); - for (int i = 1; i < args.size() - 1; i++) { - if (!(tag instanceof CompoundTag compoundTag)) return MultiLineComponent.empty(); - tag = compoundTag.get(args.get(i).toString()); + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject MAX_PROGRESS = PLACEHOLDERS.register("max_progress", + () -> new Placeholder("maxProgress") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 0); + if (ctx.pos() == null) throw new NoTargetException(); + IWorkable workable = GTCapabilityHelper.getWorkable(ctx.level(), + ctx.pos(), ctx.side()); + if (workable == null) throw new NotSupportedException(); + return MultiLineComponent.literal(workable.getMaxProgress()); } - return tag == null ? MultiLineComponent.empty() : MultiLineComponent.literal(tag.toString()); - } - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("toChars") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1); - if (args.get(0).isEmpty()) return MultiLineComponent.empty(); - StringBuilder out = new StringBuilder(); - for (char c : GTStringUtils.componentsToString(args.get(0)).toCharArray()) out.append(c).append(' '); - return MultiLineComponent.literal(out.substring(0, out.length() - 2)); - } + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject MAINTENANCE = PLACEHOLDERS.register("maintenance", + () -> new Placeholder("maintenance") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 0); + if (ctx.pos() == null) throw new NoTargetException(); + IMaintenanceMachine maintenance = GTCapabilityHelper.getMaintenanceMachine(ctx.level(), + ctx.pos(), ctx.side()); + if (maintenance == null) throw new NotSupportedException(); + return MultiLineComponent.literal(maintenance.hasMaintenanceProblems() ? 1 : 0); + } - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("toAscii") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1); - String arg = args.get(0).toString(); - if (arg.length() != 1) throw new InvalidArgsException(); - return MultiLineComponent.literal((int) arg.toCharArray()[0]); - } + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject ACTIVE = PLACEHOLDERS.register("active", () -> new Placeholder("active") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 0); + if (ctx.pos() == null) throw new NoTargetException(); + IWorkable workable = GTCapabilityHelper.getWorkable(ctx.level(), + ctx.pos(), ctx.side()); + if (workable == null) throw new NotSupportedException(); + return MultiLineComponent.literal(workable.isActive() ? 1 : 0); + } - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("fromAscii") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1); - return MultiLineComponent.literal((char) PlaceholderUtils.toInt(args.get(0))).setIgnoreSpaces(true); - } + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject VOLTAGE = PLACEHOLDERS.register("voltage", + () -> new Placeholder("voltage") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 0); + if (ctx.pos() == null) throw new NoTargetException(); + if (ctx.level().getBlockEntity(ctx.pos()) instanceof CableBlockEntity cable) { + return MultiLineComponent.literal(cable.getAverageVoltage()); + } + throw new NotSupportedException(); + } - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("subList") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 2, true); - int l = PlaceholderUtils.toInt(args.get(0)); - int r = PlaceholderUtils.toInt(args.get(1)); - PlaceholderUtils.checkRange("start index", 0, args.size(), l); - PlaceholderUtils.checkRange("end index", 0, args.size(), r); - MultiLineComponent out = MultiLineComponent.empty(); - for (int i = l; i < r - 1; i++) out.append(args.get(i)).append(' '); - out.append(args.get(r - 1)); - out.setIgnoreSpaces(true); - return out; - } + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject AMPERAGE = PLACEHOLDERS.register("amperage", + () -> new Placeholder("amperage") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 0); + if (ctx.pos() == null) throw new NoTargetException(); + if (ctx.level().getBlockEntity(ctx.pos()) instanceof CableBlockEntity cable) { + return MultiLineComponent.literal(cable.getAverageAmperage()); + } + throw new NotSupportedException(); + } - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("cmp") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 3); - double a = PlaceholderUtils.toDouble(args.get(0)); - double b = PlaceholderUtils.toDouble(args.get(2)); - return switch (args.get(1).toString()) { - case ">" -> MultiLineComponent.literal(a > b ? 1 : 0); - case "<" -> MultiLineComponent.literal(a < b ? 1 : 0); - case ">=" -> MultiLineComponent.literal(a >= b ? 1 : 0); - case "<=" -> MultiLineComponent.literal(a <= b ? 1 : 0); - case "==" -> MultiLineComponent.literal(a == b ? 1 : 0); - case "!=" -> MultiLineComponent.literal(a != b ? 1 : 0); - default -> throw new InvalidArgsException(); - }; - } + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject COUNT = PLACEHOLDERS.register("count", () -> new Placeholder("count") { - @Override - public boolean isPure() { - return true; + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1, true); + String arg1 = GTStringUtils.componentsToString(args.get(0)); + int cnt = -1; + for (List arg : args) { + if (GTStringUtils.equals(arg, arg1)) cnt++; } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("bf") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 2); - int slot = PlaceholderUtils.toInt(args.get(0)); + return MultiLineComponent.literal(cnt); + } + + @Override + public boolean isPure() { + return true; + } + }); + + public static RegistryObject DATA = PLACEHOLDERS.register("data", () -> new Placeholder("data") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 2, true); + try { + int slot = PlaceholderUtils.toInt(args.get(1)); + slot = Math.max(slot, 1); + PlaceholderUtils.checkRange("slot index", 1, 8, slot); if (ctx.itemStackHandler() == null) throw new NotSupportedException(); - PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); - ItemStack stack = ctx.itemStackHandler().getStackInSlot(slot - 1); + PlaceholderUtils.checkRange("slot index", 0, ctx.itemStackHandler().getSlots(), slot); + ItemStack stack; + if (slot == 0) { + if (ctx.monitorGroup() == null) throw new NotSupportedException(); + if (ctx.monitorGroup().getTargetRaw() == null) throw new NoTargetException(); + IMonitorComponent component = GTCapabilityHelper.getMonitorComponent(ctx.level(), + ctx.monitorGroup().getTargetRaw(), null); + if (component != null && component.getDataItems() != null) { + stack = component.getDataItems().getStackInSlot(ctx.monitorGroup().getDataSlot()); + } else throw new NotSupportedException(); + } else stack = ctx.itemStackHandler().getStackInSlot(slot - 1); int capacity = -1; if (stack.getItem() instanceof ComponentItem componentItem) { for (IItemComponent component : componentItem.getComponents()) { @@ -732,471 +567,705 @@ public MultiLineComponent apply(PlaceholderContext ctx, } } if (capacity == -1) throw new MissingItemException("any data item", slot); - if (!stack.getOrCreateTag().contains("computer_monitor_cover_data")) { - stack.getOrCreateTag().put("computer_monitor_cover_data", new ListTag()); + PlaceholderUtils.checkRange("index", 0, capacity - 1, PlaceholderUtils.toInt(args.get(2))); + ListTag data = stack.getOrCreateTag().getList("computer_monitor_cover_data", Tag.TAG_STRING); + while (data.size() <= PlaceholderUtils.toInt(args.get(2))) data.add(StringTag.valueOf("")); + int p = stack.getOrCreateTag().getInt("computer_monitor_cover_p"); + if (GTStringUtils.equals(args.get(2), "")) args.set(2, MultiLineComponent.literal(p)); + if (GTStringUtils.equals(args.get(0), "get")) + return MultiLineComponent + .literal(data.getString(PlaceholderUtils.toInt(args.get(2)) % capacity)) + .setIgnoreSpaces(true); + else if (args.get(0).equalsString("set")) { + data.set(PlaceholderUtils.toInt(args.get(2)) % capacity, + StringTag.valueOf(args.get(3).toString())); + stack.getOrCreateTag().put("computer_monitor_cover_data", data); + return MultiLineComponent.empty(); + } else if (args.get(0).equalsString("setp")) { + stack.getOrCreateTag().putInt("computer_monitor_cover_p", + PlaceholderUtils.toInt(args.get(3)) % capacity); + return MultiLineComponent.empty(); + } else if (args.get(0).equalsString("inc")) { + stack.getOrCreateTag().putInt("computer_monitor_cover_p", (p + 1) % capacity); + return MultiLineComponent.empty(); + } else if (args.get(0).equalsString("dec")) { + stack.getOrCreateTag().putInt("computer_monitor_cover_p", p == 0 ? capacity - 1 : p - 1); + return MultiLineComponent.empty(); + } else throw new InvalidArgsException(); + } catch (IndexOutOfBoundsException e) { + throw new InvalidArgsException(); + } + } + }); + + public static RegistryObject COMBINE = PLACEHOLDERS.register("combine", + () -> new Placeholder("combine") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, List args) { + MultiLineComponent out = MultiLineComponent.empty(); + for (int i = 0; i < args.size(); i++) { + out.append(args.get(i)); + if (i != args.size() - 1) out.append(" "); + } + return out.setIgnoreSpaces(true); } - ListTag tag = stack.getOrCreateTag().getList("computer_monitor_cover_data", Tag.TAG_STRING); - int operationsLeft = 5000; - int p = 0, start = 0, cnt = 0; - String rawCode = args.get(1).toString().replaceAll("[^+\\-><\\[\\]]", ""); - StringBuilder codeBuilder = new StringBuilder(); - // optimize BF code ("[----[+++]-<<-]" -> "[4-[3+]1-2<1-]") - @Nullable - Character cur = null; - for (char i : rawCode.toCharArray()) { - if (cur != null) { - if (cur == i) cnt++; - else { - codeBuilder.append(cnt).append(cur); - cur = null; - cnt = 0; - } + + @Override + public boolean isPure() { + return true; + } + }); + + public static RegistryObject NBT = PLACEHOLDERS.register("nbt", () -> new Placeholder("nbt") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1, true); + int slot = GTStringUtils.toInt(args.get(0)); + if (ctx.itemStackHandler() == null) throw new NotSupportedException(); + PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); + Tag tag = ctx.itemStackHandler().getStackInSlot(slot - 1).getOrCreateTag(); + for (int i = 1; i < args.size() - 1; i++) { + if (!(tag instanceof CompoundTag compoundTag)) return MultiLineComponent.empty(); + tag = compoundTag.get(args.get(i).toString()); + } + return tag == null ? MultiLineComponent.empty() : MultiLineComponent.literal(tag.toString()); + } + + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject TO_CHARS = PLACEHOLDERS.register("to_chars", + () -> new Placeholder("toChars") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1); + if (args.get(0).isEmpty()) return MultiLineComponent.empty(); + StringBuilder out = new StringBuilder(); + for (char c : GTStringUtils.componentsToString(args.get(0)).toCharArray()) + out.append(c).append(' '); + return MultiLineComponent.literal(out.substring(0, out.length() - 2)); + } + + @Override + public boolean isPure() { + return true; + } + }); + + public static RegistryObject TO_ASCII = PLACEHOLDERS.register("to_ascii", + () -> new Placeholder("toAscii") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1); + String arg = args.get(0).toString(); + if (arg.length() != 1) throw new InvalidArgsException(); + return MultiLineComponent.literal((int) arg.toCharArray()[0]); + } + + @Override + public boolean isPure() { + return true; + } + }); + + public static RegistryObject FROM_ASCII = PLACEHOLDERS.register("from_ascii", + () -> new Placeholder("fromAscii") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1); + return MultiLineComponent.literal((char) PlaceholderUtils.toInt(args.get(0))).setIgnoreSpaces(true); + } + + @Override + public boolean isPure() { + return true; + } + }); + + public static RegistryObject SUBLIST = PLACEHOLDERS.register("sublist", + () -> new Placeholder("subList") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 2, true); + int l = PlaceholderUtils.toInt(args.get(0)); + int r = PlaceholderUtils.toInt(args.get(1)); + PlaceholderUtils.checkRange("start index", 0, args.size(), l); + PlaceholderUtils.checkRange("end index", 0, args.size(), r); + MultiLineComponent out = MultiLineComponent.empty(); + for (int i = l; i < r - 1; i++) out.append(args.get(i)).append(' '); + out.append(args.get(r - 1)); + out.setIgnoreSpaces(true); + return out; + } + + @Override + public boolean isPure() { + return true; + } + }); + + public static RegistryObject CMP = PLACEHOLDERS.register("cmp", () -> new Placeholder("cmp") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 3); + double a = PlaceholderUtils.toDouble(args.get(0)); + double b = PlaceholderUtils.toDouble(args.get(2)); + return switch (args.get(1).toString()) { + case ">" -> MultiLineComponent.literal(a > b ? 1 : 0); + case "<" -> MultiLineComponent.literal(a < b ? 1 : 0); + case ">=" -> MultiLineComponent.literal(a >= b ? 1 : 0); + case "<=" -> MultiLineComponent.literal(a <= b ? 1 : 0); + case "==" -> MultiLineComponent.literal(a == b ? 1 : 0); + case "!=" -> MultiLineComponent.literal(a != b ? 1 : 0); + default -> throw new InvalidArgsException(); + }; + } + + @Override + public boolean isPure() { + return true; + } + }); + + public static RegistryObject BF = PLACEHOLDERS.register("bf", () -> new Placeholder("bf") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 2); + int slot = PlaceholderUtils.toInt(args.get(0)); + if (ctx.itemStackHandler() == null) throw new NotSupportedException(); + PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); + ItemStack stack = ctx.itemStackHandler().getStackInSlot(slot - 1); + int capacity = -1; + if (stack.getItem() instanceof ComponentItem componentItem) { + for (IItemComponent component : componentItem.getComponents()) { + if (component instanceof IDataItem dataComponent) { + capacity = dataComponent.getCapacity(); + break; } - if (cur == null) { - if (List.of('+', '-', '<', '>').contains(i)) { - cur = i; - cnt = 1; - } else codeBuilder.append(i); + } + } + if (capacity == -1) throw new MissingItemException("any data item", slot); + if (!stack.getOrCreateTag().contains("computer_monitor_cover_data")) { + stack.getOrCreateTag().put("computer_monitor_cover_data", new ListTag()); + } + ListTag tag = stack.getOrCreateTag().getList("computer_monitor_cover_data", Tag.TAG_STRING); + int operationsLeft = 5000; + int p = 0, start = 0, cnt = 0; + String rawCode = args.get(1).toString().replaceAll("[^+\\-><\\[\\]]", ""); + StringBuilder codeBuilder = new StringBuilder(); + // optimize BF code ("[----[+++]-<<-]" -> "[4-[3+]1-2<1-]") + @Nullable + Character cur = null; + for (char i : rawCode.toCharArray()) { + if (cur != null) { + if (cur == i) cnt++; + else { + codeBuilder.append(cnt).append(cur); + cur = null; + cnt = 0; } } - if (cur != null) codeBuilder.append(cnt).append(cur); - String code = codeBuilder.toString(); - Stack loops = new Stack<>(); - if (!getData(ctx).contains(String.valueOf(ctx.index()))) { - getData(ctx).put(String.valueOf(ctx.index()), new CompoundTag()); + if (cur == null) { + if (List.of('+', '-', '<', '>').contains(i)) { + cur = i; + cnt = 1; + } else codeBuilder.append(i); } - CompoundTag data = getData(ctx).getCompound(String.valueOf(ctx.index())); - int num = 0; - if (!data.getBoolean("completed")) { - p = data.getInt("pointer"); - start = data.getInt("index"); - num = data.getInt("num"); + } + if (cur != null) codeBuilder.append(cnt).append(cur); + String code = codeBuilder.toString(); + Stack loops = new Stack<>(); + if (!getData(ctx).contains(String.valueOf(ctx.index()))) { + getData(ctx).put(String.valueOf(ctx.index()), new CompoundTag()); + } + CompoundTag data = getData(ctx).getCompound(String.valueOf(ctx.index())); + int num = 0; + if (!data.getBoolean("completed")) { + p = data.getInt("pointer"); + start = data.getInt("index"); + num = data.getInt("num"); + } + data.putBoolean("completed", true); + for (int i = start; i < code.length(); i++) { + if (operationsLeft <= 0) { + data.putBoolean("completed", false); + data.putInt("pointer", p); + data.putInt("index", i); + data.putInt("num", num); + break; } - data.putBoolean("completed", true); - for (int i = start; i < code.length(); i++) { - if (operationsLeft <= 0) { - data.putBoolean("completed", false); - data.putInt("pointer", p); - data.putInt("index", i); - data.putInt("num", num); - break; + if (p > capacity) p = p % capacity; + if (p < 0) p = (capacity - ((-p) % capacity)) % capacity; + while (tag.size() <= p) tag.add(StringTag.valueOf("0")); + if (tag.getString(p).isEmpty()) tag.set(i, StringTag.valueOf("0")); + switch (code.charAt(i)) { + case '+' -> tag.set(p, + StringTag.valueOf(String.valueOf((Integer.parseInt(tag.getString(p)) + num) % 256))); + case '-' -> { + int tmp = Integer.parseInt(tag.getString(p)) - num; + if (tmp < 0) tmp = (256 - ((-tmp) % 256)) % 256; + tag.set(p, StringTag.valueOf(String.valueOf(tmp))); } - if (p > capacity) p = p % capacity; - if (p < 0) p = (capacity - ((-p) % capacity)) % capacity; - while (tag.size() <= p) tag.add(StringTag.valueOf("0")); - if (tag.getString(p).isEmpty()) tag.set(i, StringTag.valueOf("0")); - switch (code.charAt(i)) { - case '+' -> tag.set(p, - StringTag.valueOf(String.valueOf((Integer.parseInt(tag.getString(p)) + num) % 256))); - case '-' -> { - int tmp = Integer.parseInt(tag.getString(p)) - num; - if (tmp < 0) tmp = (256 - ((-tmp) % 256)) % 256; - tag.set(p, StringTag.valueOf(String.valueOf(tmp))); - } - case '>' -> p += num; - case '<' -> p -= num; - case '[' -> loops.push(i); - case ']' -> { - if (Integer.parseInt(tag.getString(p)) == 0) loops.pop(); - else i = loops.peek() + 1; - } + case '>' -> p += num; + case '<' -> p -= num; + case '[' -> loops.push(i); + case ']' -> { + if (Integer.parseInt(tag.getString(p)) == 0) loops.pop(); + else i = loops.peek() + 1; } - if (Character.isDigit(code.charAt(i))) { - num = num * 10 + code.charAt(i) - '0'; - } else num = 0; - operationsLeft--; } - return MultiLineComponent.empty(); + if (Character.isDigit(code.charAt(i))) { + num = num * 10 + code.charAt(i) - '0'; + } else num = 0; + operationsLeft--; } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("cmd") { + return MultiLineComponent.empty(); + } + }); + + public static RegistryObject CMD = PLACEHOLDERS.register("cmd", () -> new Placeholder("cmd") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 2); + if (ctx.itemStackHandler() == null) throw new NotSupportedException(); + int slot = PlaceholderUtils.toInt(args.get(0)); + PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); + ItemStack stack = ctx.itemStackHandler().getStackInSlot(slot - 1); + if (!stack.getOrCreateTag().contains("boundPlayerPermLevel")) + throw new MissingItemException("any data item bound to player", slot); + int perm = stack.getOrCreateTag().getInt("boundPlayerPermLevel"); + Component displayName = Component.Serializer + .fromJson(stack.getOrCreateTag().getString("boundPlayerName")); + if (displayName == null) displayName = Component.literal("Placeholder processor"); + if (ctx.level() instanceof ServerLevel serverLevel) { + MinecraftServer server = serverLevel.getServer(); + MultiLineComponent output = MultiLineComponent.empty(); + UUID playerUUID = null; + try { + playerUUID = UUID.fromString(stack.getOrCreateTag().getString("boundPlayerUUID")); + } catch (RuntimeException ignored) {} + ServerPlayer player = playerUUID == null ? null : server.getPlayerList().getPlayer(playerUUID); + CommandSource customSource = new CommandSource() { + + @Override + public void sendSystemMessage(@NotNull Component message) { + output.append(List.of(message)); + output.appendNewline(); + } - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 2); - if (ctx.itemStackHandler() == null) throw new NotSupportedException(); - int slot = PlaceholderUtils.toInt(args.get(0)); - PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); - ItemStack stack = ctx.itemStackHandler().getStackInSlot(slot - 1); - if (!stack.getOrCreateTag().contains("boundPlayerPermLevel")) - throw new MissingItemException("any data item bound to player", slot); - int perm = stack.getOrCreateTag().getInt("boundPlayerPermLevel"); - Component displayName = Component.Serializer - .fromJson(stack.getOrCreateTag().getString("boundPlayerName")); - if (displayName == null) displayName = Component.literal("Placeholder processor"); - if (ctx.level() instanceof ServerLevel serverLevel) { - MinecraftServer server = serverLevel.getServer(); - MultiLineComponent output = MultiLineComponent.empty(); - UUID playerUUID = null; - try { - playerUUID = UUID.fromString(stack.getOrCreateTag().getString("boundPlayerUUID")); - } catch (RuntimeException ignored) {} - ServerPlayer player = playerUUID == null ? null : server.getPlayerList().getPlayer(playerUUID); - CommandSource customSource = new CommandSource() { + @Override + public boolean acceptsSuccess() { + return true; + } - @Override - public void sendSystemMessage(@NotNull Component message) { - output.append(List.of(message)); - output.appendNewline(); - } + @Override + public boolean acceptsFailure() { + return true; + } - @Override - public boolean acceptsSuccess() { - return true; - } + @Override + public boolean shouldInformAdmins() { + return false; + } + }; + CommandSourceStack source = new CommandSourceStack( + customSource, + ctx.pos() == null ? Vec3.ZERO : ctx.pos().getCenter(), + Vec2.ZERO, + serverLevel, + perm, + displayName.getString(), + displayName, + server, + player); + server.getCommands().performPrefixedCommand(source, args.get(1).toString()); + return output; + } else throw new NotSupportedException(); + } + }); - @Override - public boolean acceptsFailure() { - return true; - } + public static RegistryObject TM = PLACEHOLDERS.register("tm", () -> new Placeholder("tm") { - @Override - public boolean shouldInformAdmins() { - return false; - } - }; - CommandSourceStack source = new CommandSourceStack( - customSource, - ctx.pos() == null ? Vec3.ZERO : ctx.pos().getCenter(), - Vec2.ZERO, - serverLevel, - perm, - displayName.getString(), - displayName, - server, - player); - server.getCommands().performPrefixedCommand(source, args.get(1).toString()); - return output; - } else throw new NotSupportedException(); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("tm") { + @Override + public MultiLineComponent apply(PlaceholderContext ctx, List args) { + return MultiLineComponent.literal("â„¢"); + } - @Override - public MultiLineComponent apply(PlaceholderContext ctx, List args) { - return MultiLineComponent.literal("â„¢"); - } + @Override + public boolean isPure() { + return true; + } + }); + + public static RegistryObject FORMAT_INT = PLACEHOLDERS.register("format_int", + () -> new Placeholder("formatInt") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1); + long n = PlaceholderUtils.toLong(args.get(0)); + Map suffixes = Map.of( + 1L, "", + 1000L, "K", + 1000000L, "M", + 1000000000L, "B", + 1000000000000L, "T"); + long max = 1; + for (long i : suffixes.keySet()) { + if (n >= i && max < i) max = i; + } + return MultiLineComponent.literal(String.format(Locale.ROOT, "%.2f%s", + ((double) n) / max, suffixes.get(max))); + } - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("formatInt") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1); - long n = PlaceholderUtils.toLong(args.get(0)); - Map suffixes = Map.of( - 1L, "", - 1000L, "K", - 1000000L, "M", - 1000000000L, "B", - 1000000000000L, "T"); - long max = 1; - for (long i : suffixes.keySet()) { - if (n >= i && max < i) max = i; + @Override + public boolean isPure() { + return true; } - return MultiLineComponent.literal(String.format(Locale.ROOT, "%.2f%s", - ((double) n) / max, suffixes.get(max))); - } + }); - @Override - public boolean isPure() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("click") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - if (ctx.pos() == null) throw new NoTargetException(); - if (!(MetaMachine.getMachine(ctx.level(), ctx.pos()) instanceof AdvancedMonitorPartMachine monitor)) - throw new NotSupportedException(); - monitor.resetClicked(); - if (args.isEmpty()) return MultiLineComponent.literal(monitor.isClicked() ? 1 : 0); - PlaceholderUtils.checkArgs(args, 1); - if (args.get(0).equalsString("x")) return MultiLineComponent.literal(monitor.getClickPosX()); - if (args.get(0).equalsString("y")) return MultiLineComponent.literal(monitor.getClickPosY()); - throw new InvalidArgsException(); - } + public static RegistryObject CLICK = PLACEHOLDERS.register("click", () -> new Placeholder("click") { - @Override - public boolean isView() { - return true; - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("ender") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 2, true); - String type = args.get(0).toString(); - String channel = args.get(1).toString(); - UUID owner = null; - if (args.size() > 2 && !args.get(2).toString().isEmpty()) { - if (ctx.itemStackHandler() == null) throw new NotSupportedException(); - int slot = PlaceholderUtils.toInt(args.get(2)); - PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); - ItemStack stack = ctx.itemStackHandler().getStackInSlot(slot - 1); - if (stack.getOrCreateTag().contains("boundPlayerUUID")) - owner = UUID.fromString(stack.getOrCreateTag().getString("boundPlayerUUID")); + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + if (ctx.pos() == null) throw new NoTargetException(); + if (!(MetaMachine.getMachine(ctx.level(), ctx.pos()) instanceof AdvancedMonitorPartMachine monitor)) + throw new NotSupportedException(); + monitor.resetClicked(); + if (args.isEmpty()) return MultiLineComponent.literal(monitor.isClicked() ? 1 : 0); + PlaceholderUtils.checkArgs(args, 1); + if (args.get(0).equalsString("x")) return MultiLineComponent.literal(monitor.getClickPosX()); + if (args.get(0).equalsString("y")) return MultiLineComponent.literal(monitor.getClickPosY()); + throw new InvalidArgsException(); + } + + @Override + public boolean isView() { + return true; + } + }); + + public static RegistryObject ENDER = PLACEHOLDERS.register("ender", () -> new Placeholder("ender") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 2, true); + String type = args.get(0).toString(); + String channel = args.get(1).toString(); + UUID owner = null; + if (args.size() > 2 && !args.get(2).toString().isEmpty()) { + if (ctx.itemStackHandler() == null) throw new NotSupportedException(); + int slot = PlaceholderUtils.toInt(args.get(2)); + PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); + ItemStack stack = ctx.itemStackHandler().getStackInSlot(slot - 1); + if (stack.getOrCreateTag().contains("boundPlayerUUID")) + owner = UUID.fromString(stack.getOrCreateTag().getString("boundPlayerUUID")); + } + VirtualEnderRegistry ender = VirtualEnderRegistry.get((ServerLevel) ctx.level()); + switch (type) { + case "redstone" -> { + if (!ender.hasEntry(owner, EntryTypes.ENDER_REDSTONE, channel)) + return MultiLineComponent.literal(0); + return MultiLineComponent + .literal(ender.getEntry(owner, EntryTypes.ENDER_REDSTONE, channel).getSignal()); } - VirtualEnderRegistry ender = VirtualEnderRegistry.get((ServerLevel) ctx.level()); - switch (type) { - case "redstone" -> { - if (!ender.hasEntry(owner, EntryTypes.ENDER_REDSTONE, channel)) - return MultiLineComponent.literal(0); - return MultiLineComponent - .literal(ender.getEntry(owner, EntryTypes.ENDER_REDSTONE, channel).getSignal()); - } - case "item" -> { - channel = "EILink#" + channel; - if (!ender.hasEntry(owner, EntryTypes.ENDER_ITEM, channel)) - return MultiLineComponent.literal(0); - IItemHandler items = ender.getEntry(owner, EntryTypes.ENDER_ITEM, channel).getHandler(); - int count = 0; - for (int i = 0; i < items.getSlots(); i++) count += items.getStackInSlot(i).getCount(); - return MultiLineComponent.literal(count); - } - case "itemId" -> { - channel = "EILink#" + channel; - if (!ender.hasEntry(owner, EntryTypes.ENDER_ITEM, channel)) - return MultiLineComponent.literal(ItemStack.EMPTY.toString()); - IItemHandler items = ender.getEntry(owner, EntryTypes.ENDER_ITEM, channel).getHandler(); - if (items.getSlots() == 0) return MultiLineComponent.literal(ItemStack.EMPTY.toString()); - return MultiLineComponent.literal(items.getStackInSlot(0).toString()); - } - case "itemPull" -> { - channel = "EILink#" + channel; - if (!ender.hasEntry(owner, EntryTypes.ENDER_ITEM, channel)) - return MultiLineComponent.empty(); - IItemHandler items = ender.getEntry(owner, EntryTypes.ENDER_ITEM, channel).getHandler(); - if (ctx.itemStackHandler() != null) - GTTransferUtils.transferItemsFiltered(items, ctx.itemStackHandler(), stack -> true, 1); - else throw new NotSupportedException(); + case "item" -> { + channel = "EILink#" + channel; + if (!ender.hasEntry(owner, EntryTypes.ENDER_ITEM, channel)) + return MultiLineComponent.literal(0); + IItemHandler items = ender.getEntry(owner, EntryTypes.ENDER_ITEM, channel).getHandler(); + int count = 0; + for (int i = 0; i < items.getSlots(); i++) count += items.getStackInSlot(i).getCount(); + return MultiLineComponent.literal(count); + } + case "itemId" -> { + channel = "EILink#" + channel; + if (!ender.hasEntry(owner, EntryTypes.ENDER_ITEM, channel)) + return MultiLineComponent.literal(ItemStack.EMPTY.toString()); + IItemHandler items = ender.getEntry(owner, EntryTypes.ENDER_ITEM, channel).getHandler(); + if (items.getSlots() == 0) return MultiLineComponent.literal(ItemStack.EMPTY.toString()); + return MultiLineComponent.literal(items.getStackInSlot(0).toString()); + } + case "itemPull" -> { + channel = "EILink#" + channel; + if (!ender.hasEntry(owner, EntryTypes.ENDER_ITEM, channel)) return MultiLineComponent.empty(); - } - case "itemPush" -> { - channel = "EILink#" + channel; - if (!ender.hasEntry(owner, EntryTypes.ENDER_ITEM, channel)) - return MultiLineComponent.empty(); - IItemHandler items = ender.getEntry(owner, EntryTypes.ENDER_ITEM, channel).getHandler(); - if (ctx.itemStackHandler() != null) - GTTransferUtils.transferItemsFiltered(ctx.itemStackHandler(), items, stack -> true, 1); - else throw new NotSupportedException(); + IItemHandler items = ender.getEntry(owner, EntryTypes.ENDER_ITEM, channel).getHandler(); + if (ctx.itemStackHandler() != null) + GTTransferUtils.transferItemsFiltered(items, ctx.itemStackHandler(), stack -> true, 1); + else throw new NotSupportedException(); + return MultiLineComponent.empty(); + } + case "itemPush" -> { + channel = "EILink#" + channel; + if (!ender.hasEntry(owner, EntryTypes.ENDER_ITEM, channel)) return MultiLineComponent.empty(); - } - case "fluid" -> { - channel = "EFLink#" + channel; - if (!ender.hasEntry(owner, EntryTypes.ENDER_FLUID, channel)) - return MultiLineComponent.literal(0); - return MultiLineComponent.literal( - ender.getEntry(owner, EntryTypes.ENDER_FLUID, channel).getFluidTank().getFluidAmount()); - } - default -> throw new InvalidArgsException(); + IItemHandler items = ender.getEntry(owner, EntryTypes.ENDER_ITEM, channel).getHandler(); + if (ctx.itemStackHandler() != null) + GTTransferUtils.transferItemsFiltered(ctx.itemStackHandler(), items, stack -> true, 1); + else throw new NotSupportedException(); + return MultiLineComponent.empty(); } - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("eval") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) { - MultiLineComponent out = MultiLineComponent.empty(); - for (int i = 0; i < args.size(); i++) { - out.append(args.get(i)); - if (i != args.size() - 1) out.append(" "); + case "fluid" -> { + channel = "EFLink#" + channel; + if (!ender.hasEntry(owner, EntryTypes.ENDER_FLUID, channel)) + return MultiLineComponent.literal(0); + return MultiLineComponent.literal( + ender.getEntry(owner, EntryTypes.ENDER_FLUID, channel).getFluidTank().getFluidAmount()); } - return PlaceholderHandler.processPlaceholders(out.toString(), ctx); + default -> throw new InvalidArgsException(); } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("module") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 3); - int slot = PlaceholderUtils.toInt(args.get(0)); - double x = PlaceholderUtils.toDouble(args.get(1)); - double y = PlaceholderUtils.toDouble(args.get(2)); - if (ctx.itemStackHandler() == null) throw new NotSupportedException(); - PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); - ItemStack stack = ctx.itemStackHandler().getStackInSlot(slot); - if (stack.getItem() instanceof IComponentItem componentItem) { - for (IItemComponent component : componentItem.getComponents()) { - if (component instanceof IMonitorModuleItem module) module.tickInPlaceholder(stack, ctx); - } + } + }); + + public static RegistryObject EVAL = PLACEHOLDERS.register("eval", () -> new Placeholder("eval") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) { + MultiLineComponent out = MultiLineComponent.empty(); + for (int i = 0; i < args.size(); i++) { + out.append(args.get(i)); + if (i != args.size() - 1) out.append(" "); + } + return PlaceholderHandler.processPlaceholders(out.toString(), ctx); + } + }); + + public static RegistryObject MODULE = PLACEHOLDERS.register("module", () -> new Placeholder("module") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 3); + int slot = PlaceholderUtils.toInt(args.get(0)); + double x = PlaceholderUtils.toDouble(args.get(1)); + double y = PlaceholderUtils.toDouble(args.get(2)); + if (ctx.itemStackHandler() == null) throw new NotSupportedException(); + PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); + ItemStack stack = ctx.itemStackHandler().getStackInSlot(slot); + if (stack.getItem() instanceof IComponentItem componentItem) { + for (IItemComponent component : componentItem.getComponents()) { + if (component instanceof IMonitorModuleItem module) module.tickInPlaceholder(stack, ctx); } - return MultiLineComponent.empty().addGraphics(new GraphicsComponent( - x, y, x, y, - "module", - stack.serializeNBT())); } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("setImage") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 2); - int slot = PlaceholderUtils.toInt(args.get(0)); - String url = args.get(1).toString(); - if (ctx.itemStackHandler() == null) throw new NotSupportedException(); - PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); - ItemStack stack = ctx.itemStackHandler().getStackInSlot(slot); - if (stack.getItem() instanceof IComponentItem componentItem) { - for (IItemComponent component : componentItem.getComponents()) { - if (component instanceof ImageModuleBehaviour module) { - module.setUrl(stack, url); + return MultiLineComponent.empty().addGraphics(new GraphicsComponent( + x, y, x, y, + "module", + stack.serializeNBT())); + } + }); + + public static RegistryObject SET_IMAGE = PLACEHOLDERS.register("set_image", + () -> new Placeholder("setImage") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 2); + int slot = PlaceholderUtils.toInt(args.get(0)); + String url = args.get(1).toString(); + if (ctx.itemStackHandler() == null) throw new NotSupportedException(); + PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); + ItemStack stack = ctx.itemStackHandler().getStackInSlot(slot); + if (stack.getItem() instanceof IComponentItem componentItem) { + for (IItemComponent component : componentItem.getComponents()) { + if (component instanceof ImageModuleBehaviour module) { + module.setUrl(stack, url); + } } } + return MultiLineComponent.empty(); } - return MultiLineComponent.empty(); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("rect") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 5); - double x = PlaceholderUtils.toDouble(args.get(0)); - double y = PlaceholderUtils.toDouble(args.get(1)); - double width = PlaceholderUtils.toDouble(args.get(2)); - double height = PlaceholderUtils.toDouble(args.get(3)); - if (x < 0) x = 0; - if (y < 0) y = 0; - CompoundTag renderData = new CompoundTag(); - renderData.putDouble("x", x); - renderData.putDouble("y", y); - renderData.putDouble("width", width); - renderData.putDouble("height", height); - renderData.putInt("color", 0xFF000000 | PlaceholderUtils.toInt(args.get(4))); - return MultiLineComponent.empty().addGraphics(new GraphicsComponent( - x, y, x + width, y + height, - "rect", - renderData)); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("quad") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 12); - CompoundTag renderData = new CompoundTag(); - float x1 = PlaceholderUtils.toFloat(args.get(0)); - float y1 = PlaceholderUtils.toFloat(args.get(1)); - float x2 = PlaceholderUtils.toFloat(args.get(2)); - float y2 = PlaceholderUtils.toFloat(args.get(3)); - float x3 = PlaceholderUtils.toFloat(args.get(4)); - float y3 = PlaceholderUtils.toFloat(args.get(5)); - float x4 = PlaceholderUtils.toFloat(args.get(6)); - float y4 = PlaceholderUtils.toFloat(args.get(7)); - renderData.putFloat("x1", 0); - renderData.putFloat("y1", 0); - renderData.putFloat("x2", x2 - x1); - renderData.putFloat("y2", y2 - y1); - renderData.putFloat("x3", x3 - x1); - renderData.putFloat("y3", y3 - y1); - renderData.putFloat("x4", x4 - x1); - renderData.putFloat("y4", y4 - y1); - renderData.putInt("color1", 0xFF000000 + PlaceholderUtils.toInt(args.get(8))); - renderData.putInt("color2", 0xFF000000 + PlaceholderUtils.toInt(args.get(9))); - renderData.putInt("color3", 0xFF000000 + PlaceholderUtils.toInt(args.get(10))); - renderData.putInt("color4", 0xFF000000 + PlaceholderUtils.toInt(args.get(11))); - return MultiLineComponent.empty().addGraphics(new GraphicsComponent( - GTMath.min(x1, x2, x3, x4), GTMath.min(y1, y2, y3, y4), GTMath.max(x1, x2, x3, x4), - GTMath.max(y1, y2, y3, y4), - "quad", - renderData)); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("item") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - PlaceholderUtils.checkArgs(args, 1); - int slot = PlaceholderUtils.toInt(args.get(0)); - if (ctx.itemStackHandler() == null) throw new NotSupportedException(); - PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); - return MultiLineComponent.literal(ctx.itemStackHandler().getStackInSlot(slot - 1).toString()); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("blockNbt") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - if (ctx.pos() == null) throw new NoTargetException(); - BlockEntity blockEntity = ctx.level().getBlockEntity(ctx.pos()); - if (blockEntity == null) return MultiLineComponent.empty(); - Tag tag = blockEntity.saveWithFullMetadata(); - if (tag instanceof CompoundTag compoundTag && compoundTag.contains("cover")) { - CompoundTag coverTag = compoundTag.getCompound("cover"); - if (coverTag.contains(ctx.side().getName())) { - CompoundTag cover = coverTag.getCompound(ctx.side().getName()).getCompound("payload") - .getCompound("d"); - cover.putString("text", "[REMOVED]"); + }); + + public static RegistryObject RECT = PLACEHOLDERS.register("rect", () -> new Placeholder("rect") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 5); + double x = PlaceholderUtils.toDouble(args.get(0)); + double y = PlaceholderUtils.toDouble(args.get(1)); + double width = PlaceholderUtils.toDouble(args.get(2)); + double height = PlaceholderUtils.toDouble(args.get(3)); + if (x < 0) x = 0; + if (y < 0) y = 0; + CompoundTag renderData = new CompoundTag(); + renderData.putDouble("x", x); + renderData.putDouble("y", y); + renderData.putDouble("width", width); + renderData.putDouble("height", height); + renderData.putInt("color", 0xFF000000 | PlaceholderUtils.toInt(args.get(4))); + return MultiLineComponent.empty().addGraphics(new GraphicsComponent( + x, y, x + width, y + height, + "rect", + renderData)); + } + }); + + public static RegistryObject QUAD = PLACEHOLDERS.register("quad", () -> new Placeholder("quad") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 12); + CompoundTag renderData = new CompoundTag(); + float x1 = PlaceholderUtils.toFloat(args.get(0)); + float y1 = PlaceholderUtils.toFloat(args.get(1)); + float x2 = PlaceholderUtils.toFloat(args.get(2)); + float y2 = PlaceholderUtils.toFloat(args.get(3)); + float x3 = PlaceholderUtils.toFloat(args.get(4)); + float y3 = PlaceholderUtils.toFloat(args.get(5)); + float x4 = PlaceholderUtils.toFloat(args.get(6)); + float y4 = PlaceholderUtils.toFloat(args.get(7)); + renderData.putFloat("x1", 0); + renderData.putFloat("y1", 0); + renderData.putFloat("x2", x2 - x1); + renderData.putFloat("y2", y2 - y1); + renderData.putFloat("x3", x3 - x1); + renderData.putFloat("y3", y3 - y1); + renderData.putFloat("x4", x4 - x1); + renderData.putFloat("y4", y4 - y1); + renderData.putInt("color1", 0xFF000000 + PlaceholderUtils.toInt(args.get(8))); + renderData.putInt("color2", 0xFF000000 + PlaceholderUtils.toInt(args.get(9))); + renderData.putInt("color3", 0xFF000000 + PlaceholderUtils.toInt(args.get(10))); + renderData.putInt("color4", 0xFF000000 + PlaceholderUtils.toInt(args.get(11))); + return MultiLineComponent.empty().addGraphics(new GraphicsComponent( + GTMath.min(x1, x2, x3, x4), GTMath.min(y1, y2, y3, y4), GTMath.max(x1, x2, x3, x4), + GTMath.max(y1, y2, y3, y4), + "quad", + renderData)); + } + }); + + public static RegistryObject ITEM = PLACEHOLDERS.register("item", () -> new Placeholder("item") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + PlaceholderUtils.checkArgs(args, 1); + int slot = PlaceholderUtils.toInt(args.get(0)); + if (ctx.itemStackHandler() == null) throw new NotSupportedException(); + PlaceholderUtils.checkRange("slot index", 1, ctx.itemStackHandler().getSlots(), slot); + return MultiLineComponent.literal(ctx.itemStackHandler().getStackInSlot(slot - 1).toString()); + } + }); + + public static RegistryObject BLOCK_NBT = PLACEHOLDERS.register("block_nbt", + () -> new Placeholder("blockNbt") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + if (ctx.pos() == null) throw new NoTargetException(); + BlockEntity blockEntity = ctx.level().getBlockEntity(ctx.pos()); + if (blockEntity == null) return MultiLineComponent.empty(); + Tag tag = blockEntity.saveWithFullMetadata(); + if (tag instanceof CompoundTag compoundTag && compoundTag.contains("cover")) { + CompoundTag coverTag = compoundTag.getCompound("cover"); + if (coverTag.contains(ctx.side().getName())) { + CompoundTag cover = coverTag.getCompound(ctx.side().getName()).getCompound("payload") + .getCompound("d"); + cover.putString("text", "[REMOVED]"); + } } + for (MultiLineComponent arg : args) { + if (!(tag instanceof CompoundTag compoundTag)) return MultiLineComponent.empty(); + tag = compoundTag.get(arg.toString()); + } + return tag == null ? MultiLineComponent.empty() : MultiLineComponent.literal(tag.toString()); } - for (MultiLineComponent arg : args) { - if (!(tag instanceof CompoundTag compoundTag)) return MultiLineComponent.empty(); - tag = compoundTag.get(arg.toString()); + }); + + public static RegistryObject SET_TARGET_SLOT = PLACEHOLDERS.register("set_target_slot", + () -> new Placeholder("setTargetSlot") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + if (ctx.monitorGroup() == null) throw new NotSupportedException(); + PlaceholderUtils.checkArgs(args, 1); + int slot = PlaceholderUtils.toInt(args.get(0)); + BlockPos dataHatchPos = ctx.monitorGroup().getTargetRaw(); + if (dataHatchPos == null) throw new NotSupportedException(); + IMonitorComponent dataHatch = GTCapabilityHelper.getMonitorComponent(ctx.level(), dataHatchPos, + null); + if (dataHatch == null || dataHatch.getDataItems() == null) throw new NotSupportedException(); + PlaceholderUtils.checkRange("slot index", 1, dataHatch.getDataItems().getSlots(), slot); + ctx.monitorGroup().setDataSlot(slot - 1); + ctx.side(ctx.monitorGroup().getTargetCoverSide()); + ctx.pos(ctx.monitorGroup().getTarget(ctx.level())); + return MultiLineComponent.empty(); } - return tag == null ? MultiLineComponent.empty() : MultiLineComponent.literal(tag.toString()); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("setTargetSlot") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - if (ctx.monitorGroup() == null) throw new NotSupportedException(); - PlaceholderUtils.checkArgs(args, 1); - int slot = PlaceholderUtils.toInt(args.get(0)); - BlockPos dataHatchPos = ctx.monitorGroup().getTargetRaw(); - if (dataHatchPos == null) throw new NotSupportedException(); - IMonitorComponent dataHatch = GTCapabilityHelper.getMonitorComponent(ctx.level(), dataHatchPos, null); - if (dataHatch == null || dataHatch.getDataItems() == null) throw new NotSupportedException(); - PlaceholderUtils.checkRange("slot index", 1, dataHatch.getDataItems().getSlots(), slot); - ctx.monitorGroup().setDataSlot(slot - 1); - ctx.side(ctx.monitorGroup().getTargetCoverSide()); - ctx.pos(ctx.monitorGroup().getTarget(ctx.level())); - return MultiLineComponent.empty(); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("targetSlot") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - if (ctx.monitorGroup() == null) throw new NotSupportedException(); - return MultiLineComponent.literal(ctx.monitorGroup().getDataSlot() + 1); - } - }); + }); - if (GTCEu.Mods.isAE2Loaded()) { - GTAEPlaceholders.init(); - } + public static RegistryObject TARGET_SLOT = PLACEHOLDERS.register("target_slot", + () -> new Placeholder("targetSlot") { - if (GTCEu.Mods.isCCTweakedLoaded()) { - CCTweakedPlugin.initPlaceholders(); + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + if (ctx.monitorGroup() == null) throw new NotSupportedException(); + return MultiLineComponent.literal(ctx.monitorGroup().getDataSlot() + 1); + } + }); + + public static int countItems(String id, @Nullable IItemHandler itemHandler) { + if (itemHandler == null) return 0; + int cnt = 0; + for (int i = 0; i < itemHandler.getSlots(); i++) { + ItemStack itemStack = itemHandler.getStackInSlot(i); + String itemId = "%s:%s".formatted(itemStack.getItem().getCreatorModId(itemStack), + itemStack.getItem().toString()); + if (itemId.equals(id)) cnt += itemStack.getCount(); } + return cnt; + } - if (ConfigHolder.INSTANCE.compat.createCompat && GTCEu.Mods.isCreateLoaded()) { - GTCreateIntegration.initPlaceholders(); + public static int countFluids(@Nullable String id, @Nullable IFluidHandler fluidHandler) { + if (fluidHandler == null) return 0; + int cnt = 0; + for (int i = 0; i < fluidHandler.getTanks(); i++) { + FluidStack fluidStack = fluidHandler.getFluidInTank(i); + String fluidId = Objects.requireNonNull(ForgeRegistries.FLUIDS.getKey(fluidStack.getFluid())).toString(); + if (id == null || fluidId.equals(id)) cnt += fluidStack.getAmount(); } + return cnt; + } - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.PLACEHOLDERS, Placeholder.class)); - GTRegistries.PLACEHOLDERS.freeze(); + public static int countItems(@Nullable ItemFilter filter, @Nullable IItemHandler itemHandler) { + if (itemHandler == null) + return -1; + int cnt = 0; + for (int i = 0; i < itemHandler.getSlots(); i++) { + if (filter == null || filter.test(itemHandler.getStackInSlot(i))) + cnt += itemHandler.getStackInSlot(i).getCount(); + } + return cnt; } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCapabilities.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCapabilities.java index 1b5be42de6e..ca8cd6bf9a8 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCapabilities.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCapabilities.java @@ -1,8 +1,6 @@ package com.gregtechceu.gtceu.common.data; -import com.gregtechceu.gtceu.api.GTCEuAPI; -import com.gregtechceu.gtceu.api.addon.AddonFinder; -import com.gregtechceu.gtceu.api.addon.IGTAddon; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.capability.recipe.*; import com.gregtechceu.gtceu.api.recipe.ingredient.EnergyStack; import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient; @@ -10,28 +8,27 @@ import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.fml.ModLoader; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; public class GTRecipeCapabilities { + private static final DeferredRegister> RECIPE_CAPABILITY = DeferredRegister + .create(GTRegistries.Keys.RECIPE_CAPABILITY, GTCEu.MOD_ID); + public final static RecipeCapability ITEM = ItemRecipeCapability.CAP; public final static RecipeCapability FLUID = FluidRecipeCapability.CAP; public final static RecipeCapability BLOCK_STATE = BlockStateRecipeCapability.CAP; public final static RecipeCapability EU = EURecipeCapability.CAP; public final static RecipeCapability CWU = CWURecipeCapability.CAP; - public static void init() { - GTRegistries.RECIPE_CAPABILITIES.unfreeze(); - - GTRegistries.RECIPE_CAPABILITIES.register(ITEM.id, ITEM); - GTRegistries.RECIPE_CAPABILITIES.register(FLUID.id, FLUID); - GTRegistries.RECIPE_CAPABILITIES.register(BLOCK_STATE.id, BLOCK_STATE); - GTRegistries.RECIPE_CAPABILITIES.register(EU.id, EU); - GTRegistries.RECIPE_CAPABILITIES.register(CWU.id, CWU); + public static void init(IEventBus modBus) { + RECIPE_CAPABILITY.register(modBus); - AddonFinder.getAddons().forEach(IGTAddon::registerRecipeCapabilities); - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.RECIPE_CAPABILITIES, - (Class>) (Class) RecipeCapability.class)); - GTRegistries.RECIPE_CAPABILITIES.freeze(); + RECIPE_CAPABILITY.register(ITEM.id.getPath(), () -> ITEM); + RECIPE_CAPABILITY.register(FLUID.id.getPath(), () -> FLUID); + RECIPE_CAPABILITY.register(BLOCK_STATE.id.getPath(), () -> BLOCK_STATE); + RECIPE_CAPABILITY.register(EU.id.getPath(), () -> EU); + RECIPE_CAPABILITY.register(CWU.id.getPath(), () -> CWU); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java index df7b1a17fed..81e1c448d4c 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeCategories.java @@ -1,50 +1,38 @@ package com.gregtechceu.gtceu.common.data; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; -import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.integration.recipeviewer.CategoryIcon; -import net.minecraftforge.fml.ModLoader; - -import org.jetbrains.annotations.NotNull; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; public class GTRecipeCategories { - public static final GTRecipeCategory ORE_CRUSHING = register("ore_crushing", GTRecipeTypes.MACERATOR_RECIPES); - public static final GTRecipeCategory ORE_FORGING = register("ore_forging", GTRecipeTypes.FORGE_HAMMER_RECIPES); - public static final GTRecipeCategory ORE_BATHING = register("ore_bathing", GTRecipeTypes.CHEMICAL_BATH_RECIPES); - public static final GTRecipeCategory CHEM_DYES = register("chem_dyes", GTRecipeTypes.CHEMICAL_BATH_RECIPES); - public static final GTRecipeCategory INGOT_MOLDING = register("ingot_molding", GTRecipeTypes.ALLOY_SMELTER_RECIPES); - - public static final GTRecipeCategory ARC_FURNACE_RECYCLING = register("arc_furnace_recycling", + public static final GTRecipeCategory ORE_CRUSHING = REGISTRATE.recipeCategory("ore_crushing", + GTRecipeTypes.MACERATOR_RECIPES); + public static final GTRecipeCategory ORE_FORGING = REGISTRATE.recipeCategory("ore_forging", + GTRecipeTypes.FORGE_HAMMER_RECIPES); + public static final GTRecipeCategory ORE_BATHING = REGISTRATE.recipeCategory("ore_bathing", + GTRecipeTypes.CHEMICAL_BATH_RECIPES); + public static final GTRecipeCategory CHEM_DYES = REGISTRATE.recipeCategory("chem_dyes", + GTRecipeTypes.CHEMICAL_BATH_RECIPES); + public static final GTRecipeCategory INGOT_MOLDING = REGISTRATE.recipeCategory("ingot_molding", + GTRecipeTypes.ALLOY_SMELTER_RECIPES); + + public static final GTRecipeCategory ARC_FURNACE_RECYCLING = REGISTRATE.recipeCategory("arc_furnace_recycling", GTRecipeTypes.ARC_FURNACE_RECIPES) .setIcon(new CategoryIcon(GTCEu.id("textures/gui/icon/category/arc_furnace_recycling.png"))); - public static final GTRecipeCategory MACERATOR_RECYCLING = register("macerator_recycling", + public static final GTRecipeCategory MACERATOR_RECYCLING = REGISTRATE.recipeCategory("macerator_recycling", GTRecipeTypes.MACERATOR_RECIPES) .setIcon(new CategoryIcon(GTCEu.id("textures/gui/icon/category/macerator_recycling.png"))); - public static final GTRecipeCategory EXTRACTOR_RECYCLING = register("extractor_recycling", + public static final GTRecipeCategory EXTRACTOR_RECYCLING = REGISTRATE.recipeCategory("extractor_recycling", GTRecipeTypes.EXTRACTOR_RECIPES) .setIcon(new CategoryIcon(GTCEu.id("textures/gui/icon/category/extractor_recycling.png"))); - public static GTRecipeCategory register(String categoryName, @NotNull GTRecipeType recipeType) { - GTRecipeCategory category = new GTRecipeCategory(categoryName, recipeType); - GTRegistries.RECIPE_CATEGORIES.register(category.registryKey, category); - return category; - } - - public static void init() { - if (GTCEu.Mods.isKubeJSLoaded()) { - GTRegistryInfo.registerFor(GTRegistries.RECIPE_CATEGORIES.getRegistryName()); - } - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.RECIPE_CATEGORIES, GTRecipeCategory.class)); - GTRegistries.RECIPE_CATEGORIES.freeze(); - } + public static void init() {} public static GTRecipeCategory get(String name) { return GTRegistries.RECIPE_CATEGORIES.get(GTCEu.id(name)); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeConditions.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeConditions.java index 5f752357db6..ed79695a43d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeConditions.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeConditions.java @@ -1,66 +1,57 @@ package com.gregtechceu.gtceu.common.data; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; -import com.gregtechceu.gtceu.api.recipe.RecipeCondition; import com.gregtechceu.gtceu.api.recipe.condition.RecipeConditionType; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.recipe.condition.*; -import net.minecraftforge.fml.ModLoader; - -import com.mojang.serialization.Codec; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.RegistryObject; public final class GTRecipeConditions { - static { - GTRegistries.RECIPE_CONDITIONS.unfreeze(); - } - private GTRecipeConditions() {} + private static final DeferredRegister> RECIPE_CONDITION = DeferredRegister + .create(GTRegistries.Keys.RECIPE_CONDITION, GTCEu.MOD_ID); + // spotless:off - public static final RecipeConditionType BIOME = register("biome", BiomeCondition::new, BiomeCondition.CODEC); - public static final RecipeConditionType BIOME_TAG = register("biome_tag", BiomeTagCondition::new, BiomeTagCondition.CODEC); - public static final RecipeConditionType DIMENSION = register("dimension", DimensionCondition::new, DimensionCondition.CODEC); - public static final RecipeConditionType POSITION_Y = register("pos_y", PositionYCondition::new, PositionYCondition.CODEC); - public static final RecipeConditionType RAINING = register("rain", RainingCondition::new, RainingCondition.CODEC); - public static final RecipeConditionType ADJACENT_FLUID = register("adjacent_fluid", AdjacentFluidCondition::new, AdjacentFluidCondition.CODEC); - public static final RecipeConditionType ADJACENT_BLOCK = register("adjacent_block", AdjacentBlockCondition::new, AdjacentBlockCondition.CODEC); - public static final RecipeConditionType THUNDER = register("thunder", ThunderCondition::new, ThunderCondition.CODEC); - public static final RecipeConditionType VENT = register("steam_vent", VentCondition::new, VentCondition.CODEC); - public static final RecipeConditionType CLEANROOM = register("cleanroom", CleanroomCondition::new, CleanroomCondition.CODEC); - public static final RecipeConditionType EU_TO_START = register("eu_to_start", EUToStartCondition::new, EUToStartCondition.CODEC); - public static final RecipeConditionType RESEARCH = register("research", ResearchCondition::new, ResearchCondition.CODEC); - public static final RecipeConditionType ENVIRONMENTAL_HAZARD = register("environmental_hazard", EnvironmentalHazardCondition::new, EnvironmentalHazardCondition.CODEC); - public static final RecipeConditionType DAYTIME = register("daytime", DaytimeCondition::new, DaytimeCondition.CODEC); + public static final RegistryObject> BIOME = RECIPE_CONDITION.register("biome", () -> new RecipeConditionType<>(BiomeCondition::new, BiomeCondition.CODEC)); + public static final RegistryObject> BIOME_TAG = RECIPE_CONDITION.register("biome_tag", () -> new RecipeConditionType<>( BiomeTagCondition::new, BiomeTagCondition.CODEC)); + public static final RegistryObject> DIMENSION = RECIPE_CONDITION.register("dimension", () -> new RecipeConditionType<>( DimensionCondition::new, DimensionCondition.CODEC)); + public static final RegistryObject> POSITION_Y = RECIPE_CONDITION.register("pos_y", () -> new RecipeConditionType<>( PositionYCondition::new, PositionYCondition.CODEC)); + public static final RegistryObject> RAINING = RECIPE_CONDITION.register("rain", () -> new RecipeConditionType<>( RainingCondition::new, RainingCondition.CODEC)); + public static final RegistryObject> ADJACENT_FLUID = RECIPE_CONDITION.register("adjacent_fluid", () -> new RecipeConditionType<>( AdjacentFluidCondition::new, AdjacentFluidCondition.CODEC)); + public static final RegistryObject> ADJACENT_BLOCK = RECIPE_CONDITION.register("adjacent_block", () -> new RecipeConditionType<>( AdjacentBlockCondition::new, AdjacentBlockCondition.CODEC)); + public static final RegistryObject> THUNDER = RECIPE_CONDITION.register("thunder", () -> new RecipeConditionType<>( ThunderCondition::new, ThunderCondition.CODEC)); + public static final RegistryObject> VENT = RECIPE_CONDITION.register("steam_vent", () -> new RecipeConditionType<>( VentCondition::new, VentCondition.CODEC)); + public static final RegistryObject> CLEANROOM = RECIPE_CONDITION.register("cleanroom", () -> new RecipeConditionType<>( CleanroomCondition::new, CleanroomCondition.CODEC)); + public static final RegistryObject> EU_TO_START = RECIPE_CONDITION.register("eu_to_start", () -> new RecipeConditionType<>( EUToStartCondition::new, EUToStartCondition.CODEC)); + public static final RegistryObject> RESEARCH = RECIPE_CONDITION.register("research", () -> new RecipeConditionType<>( ResearchCondition::new, ResearchCondition.CODEC)); + public static final RegistryObject> ENVIRONMENTAL_HAZARD = RECIPE_CONDITION.register("environmental_hazard", + () -> new RecipeConditionType<>( EnvironmentalHazardCondition::new, EnvironmentalHazardCondition.CODEC)); + public static final RegistryObject> DAYTIME = RECIPE_CONDITION.register("daytime", () -> new RecipeConditionType<>( DaytimeCondition::new, DaytimeCondition.CODEC)); // spotless:on - public static RecipeConditionType FTB_QUEST; - public static RecipeConditionType GAMESTAGE; - public static RecipeConditionType HERACLES_QUEST; + public static RegistryObject> FTB_QUEST; + public static RegistryObject> GAMESTAGE; + public static RegistryObject> HERACLES_QUEST; - public static void init() { + public static void init(IEventBus modBus) { + RECIPE_CONDITION.register(modBus); if (GTCEu.Mods.isFTBQuestsLoaded()) { - FTB_QUEST = register("ftb_quest", FTBQuestCondition::new, FTBQuestCondition.CODEC); + FTB_QUEST = RECIPE_CONDITION.register("ftb_quest", + () -> new RecipeConditionType<>(FTBQuestCondition::new, FTBQuestCondition.CODEC)); } if (GTCEu.Mods.isGameStagesLoaded()) { - GAMESTAGE = register("game_stage", GameStageCondition::new, GameStageCondition.CODEC); + GAMESTAGE = RECIPE_CONDITION.register("game_stage", + () -> new RecipeConditionType<>(GameStageCondition::new, GameStageCondition.CODEC)); } if (GTCEu.Mods.isHeraclesLoaded()) { - HERACLES_QUEST = register("heracles_quest", HeraclesQuestCondition::new, HeraclesQuestCondition.CODEC); + HERACLES_QUEST = RECIPE_CONDITION.register("heracles_quest", + () -> new RecipeConditionType<>(HeraclesQuestCondition::new, HeraclesQuestCondition.CODEC)); } // fix the rock breaker condition's ID - GTRegistries.RECIPE_CONDITIONS.remap(GTCEu.id("rock_breaker"), GTCEu.id("adjacent_fluid")); - - // noinspection unchecked - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.RECIPE_CONDITIONS, - (Class>) (Class) RecipeConditionType.class)); - GTRegistries.RECIPE_CONDITIONS.freeze(); - } - - private static > RecipeConditionType register(String name, - RecipeConditionType.ConditionFactory factory, - Codec codec) { - return GTRegistries.RECIPE_CONDITIONS.register(GTCEu.id(name), new RecipeConditionType<>(factory, codec)); + // GTRegistries.RECIPE_CONDITIONS.remap(GTCEu.id("rock_breaker"), GTCEu.id("adjacent_fluid")); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index f6d21d5306a..75ba7ba4f78 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.common.data; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.GTCEuAPI; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.IO; @@ -12,7 +11,6 @@ import com.gregtechceu.gtceu.api.recipe.gui.GTRecipeTypeUILayout; import com.gregtechceu.gtceu.api.recipe.gui.RecipeUIModifier; import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient; -import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.sound.ExistingSoundEntry; import com.gregtechceu.gtceu.common.machine.multiblock.electric.FusionReactorMachine; import com.gregtechceu.gtceu.common.machine.trait.customlogic.*; @@ -20,16 +18,19 @@ import com.gregtechceu.gtceu.common.mui.GTMuiWidgets; import com.gregtechceu.gtceu.common.recipe.gui.GTRecipeUIModifiers; import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.utils.GTMath; import com.gregtechceu.gtceu.utils.ResearchManager; +import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; -import net.minecraftforge.fml.ModLoader; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; import brachy.modularui.api.drawable.Text; import brachy.modularui.drawable.progress.CircularProgressDrawable; @@ -40,6 +41,8 @@ import java.util.Collections; import java.util.List; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; + @SuppressWarnings("deprecation") public class GTRecipeTypes { @@ -49,15 +52,13 @@ public class GTRecipeTypes { public static final String MULTIBLOCK = "multiblock"; public static final String DUMMY = "dummy"; - static { - GTRegistries.RECIPE_TYPES.unfreeze(); - GTRegistries.RECIPE_CATEGORIES.unfreeze(); - } + private static final DeferredRegister> RECIPE_SERIALIZERS = DeferredRegister + .create(Registries.RECIPE_SERIALIZER, GTCEu.MOD_ID); ////////////////////////////////////// // ********* Steam **********// ////////////////////////////////////// - public final static GTRecipeType STEAM_BOILER_RECIPES = register("steam_boiler", STEAM) + public final static GTRecipeType STEAM_BOILER_RECIPES = REGISTRATE.recipeType("steam_boiler", STEAM) .setMaxIOSize(1, 0, 1, 1) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BOILER_FUEL_STEEL)) .onRecipeBuild((builder, provider) -> { @@ -73,21 +74,23 @@ public class GTRecipeTypes { ////////////////////////////////////// // ********* Common *********// ////////////////////////////////////// - public final static GTRecipeType FURNACE_RECIPES = register("electric_furnace", ELECTRIC, RecipeType.SMELTING) + public final static GTRecipeType FURNACE_RECIPES = REGISTRATE + .recipeType("electric_furnace", ELECTRIC, RecipeType.SMELTING) .setMaxIOSize(1, 1, 0, 0).setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.EUt(4)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.FURNACE_OVERLAY_1)) .setSound(GTSoundEntries.FURNACE); - public final static GTRecipeType ALLOY_SMELTER_RECIPES = register("alloy_smelter", ELECTRIC) + public final static GTRecipeType ALLOY_SMELTER_RECIPES = REGISTRATE.recipeType("alloy_smelter", ELECTRIC) .setMaxIOSize(2, 1, 0, 0).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.FURNACE_OVERLAY_1)) .setIconSupplier(() -> GTMachines.ALLOY_SMELTER[GTValues.LV].asStack()) .setSound(GTSoundEntries.FURNACE); - public final static GTRecipeType ARC_FURNACE_RECIPES = register("arc_furnace", ELECTRIC).setMaxIOSize(1, 4, 1, 1) + public final static GTRecipeType ARC_FURNACE_RECIPES = REGISTRATE.recipeType("arc_furnace", ELECTRIC) + .setMaxIOSize(1, 4, 1, 1) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW) .setLayoutGridBuilder(ItemRecipeCapability.CAP, IO.OUT, @@ -102,26 +105,29 @@ public class GTRecipeTypes { }) .addCustomRecipeLogic(ArcFurnaceLogic.INSTANCE); - public final static GTRecipeType ASSEMBLER_RECIPES = register("assembler", ELECTRIC).setMaxIOSize(9, 1, 1, 0) + public final static GTRecipeType ASSEMBLER_RECIPES = REGISTRATE.recipeType("assembler", ELECTRIC) + .setMaxIOSize(9, 1, 1, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ASSEMBLER)) .setSound(GTSoundEntries.ASSEMBLER); - public final static GTRecipeType AUTOCLAVE_RECIPES = register("autoclave", ELECTRIC).setMaxIOSize(2, 2, 1, 1) + public final static GTRecipeType AUTOCLAVE_RECIPES = REGISTRATE.recipeType("autoclave", ELECTRIC) + .setMaxIOSize(2, 2, 1, 1) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_CRYSTALLIZATION) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.DUST_OVERLAY) .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.CRYSTAL_OVERLAY)) .setSound(GTSoundEntries.FURNACE); - public final static GTRecipeType BENDER_RECIPES = register("bender", ELECTRIC).setMaxIOSize(2, 1, 0, 0) + public final static GTRecipeType BENDER_RECIPES = REGISTRATE.recipeType("bender", ELECTRIC).setMaxIOSize(2, 1, 0, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BENDING) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.BENDER_OVERLAY) .setItemSlotOverlay(IO.IN, 1, GTGuiTextures.INT_CIRCUIT_OVERLAY)) .setSound(GTSoundEntries.MOTOR); - public final static GTRecipeType BREWING_RECIPES = register("brewery", ELECTRIC).setMaxIOSize(1, 0, 1, 1) + public final static GTRecipeType BREWING_RECIPES = REGISTRATE.recipeType("brewery", ELECTRIC) + .setMaxIOSize(1, 0, 1, 1) .setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.duration(128).EUt(4)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW_MULTIPLE) @@ -129,7 +135,8 @@ public class GTRecipeTypes { .addCustomRecipeLogic(BreweryLogic.INSTANCE) .setSound(GTSoundEntries.CHEMICAL); - public final static GTRecipeType MACERATOR_RECIPES = register("macerator", ELECTRIC).setMaxIOSize(1, 4, 0, 0) + public final static GTRecipeType MACERATOR_RECIPES = REGISTRATE.recipeType("macerator", ELECTRIC) + .setMaxIOSize(1, 4, 0, 0) .setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.duration(150).EUt(2)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_MACERATE) @@ -158,7 +165,7 @@ public class GTRecipeTypes { .addCustomRecipeLogic(MaceratorLogic.INSTANCE) .setSound(GTSoundEntries.MACERATOR); - public final static GTRecipeType CANNER_RECIPES = register("canner", ELECTRIC).setMaxIOSize(2, 2, 1, 1) + public final static GTRecipeType CANNER_RECIPES = REGISTRATE.recipeType("canner", ELECTRIC).setMaxIOSize(2, 2, 1, 1) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_CANNER) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.CANNER_OVERLAY) @@ -169,7 +176,8 @@ public class GTRecipeTypes { .addCustomRecipeLogic(CannerLogic.INSTANCE) .setSound(GTSoundEntries.BATH); - public final static GTRecipeType CENTRIFUGE_RECIPES = register("centrifuge", ELECTRIC).setMaxIOSize(2, 6, 1, 6) + public final static GTRecipeType CENTRIFUGE_RECIPES = REGISTRATE.recipeType("centrifuge", ELECTRIC) + .setMaxIOSize(2, 6, 1, 6) .setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.EUt(5)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_EXTRACT) @@ -178,7 +186,7 @@ public class GTRecipeTypes { .setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.CENTRIFUGE_OVERLAY)) .setSound(GTSoundEntries.CENTRIFUGE); - public final static GTRecipeType CHEMICAL_BATH_RECIPES = register("chemical_bath", ELECTRIC) + public final static GTRecipeType CHEMICAL_BATH_RECIPES = REGISTRATE.recipeType("chemical_bath", ELECTRIC) .setMaxIOSize(1, 6, 1, 1).setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.EUt(GTValues.VA[GTValues.LV])) .UI(builder -> builder @@ -195,7 +203,8 @@ public class GTRecipeTypes { .setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.CENTRIFUGE_OVERLAY)) .setSound(GTSoundEntries.BATH); - public final static GTRecipeType CHEMICAL_RECIPES = register("chemical_reactor", ELECTRIC).setMaxIOSize(2, 2, 3, 2) + public final static GTRecipeType CHEMICAL_RECIPES = REGISTRATE.recipeType("chemical_reactor", ELECTRIC) + .setMaxIOSize(2, 2, 3, 2) .setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.EUt(GTValues.VA[GTValues.LV])) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW_MULTIPLE) @@ -209,7 +218,8 @@ public class GTRecipeTypes { .onRecipeBuild((recipeBuilder, provider) -> GTRecipeTypes.LARGE_CHEMICAL_RECIPES.copyFrom(recipeBuilder) .save(provider)); - public final static GTRecipeType COMPRESSOR_RECIPES = register("compressor", ELECTRIC).setMaxIOSize(1, 1, 0, 0) + public final static GTRecipeType COMPRESSOR_RECIPES = REGISTRATE.recipeType("compressor", ELECTRIC) + .setMaxIOSize(1, 1, 0, 0) .setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.duration(200).EUt(2)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_COMPRESS) @@ -217,7 +227,7 @@ public class GTRecipeTypes { .setIconSupplier(() -> GTMachines.COMPRESSOR[GTValues.LV].asStack()) .setSound(GTSoundEntries.COMPRESSOR); - public final static GTRecipeType CUTTER_RECIPES = register("cutter", ELECTRIC).setMaxIOSize(1, 2, 1, 0) + public final static GTRecipeType CUTTER_RECIPES = REGISTRATE.recipeType("cutter", ELECTRIC).setMaxIOSize(1, 2, 1, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_CUTTER) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.SAWBLADE_OVERLAY) @@ -248,7 +258,8 @@ public class GTRecipeTypes { } }); - public final static GTRecipeType DISTILLERY_RECIPES = register("distillery", ELECTRIC).setMaxIOSize(1, 1, 1, 1) + public final static GTRecipeType DISTILLERY_RECIPES = REGISTRATE.recipeType("distillery", ELECTRIC) + .setMaxIOSize(1, 1, 1, 1) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW_MULTIPLE) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.INT_CIRCUIT_OVERLAY) @@ -262,7 +273,8 @@ public class GTRecipeTypes { // .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, LEFT_TO_RIGHT) .setSound(GTSoundEntries.BOILER); - public final static GTRecipeType ELECTROLYZER_RECIPES = register("electrolyzer", ELECTRIC).setMaxIOSize(2, 6, 1, 6) + public final static GTRecipeType ELECTROLYZER_RECIPES = REGISTRATE.recipeType("electrolyzer", ELECTRIC) + .setMaxIOSize(2, 6, 1, 6) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_EXTRACT) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.LIGHTNING_OVERLAY_1) @@ -270,21 +282,24 @@ public class GTRecipeTypes { .setFluidSlotsOverlay(IO.IN, 0, 5, GTGuiTextures.LIGHTNING_OVERLAY_2)) .setSound(GTSoundEntries.ELECTROLYZER); - public final static GTRecipeType ELECTROMAGNETIC_SEPARATOR_RECIPES = register("electromagnetic_separator", ELECTRIC) + public final static GTRecipeType ELECTROMAGNETIC_SEPARATOR_RECIPES = REGISTRATE + .recipeType("electromagnetic_separator", ELECTRIC) .setMaxIOSize(1, 3, 0, 0).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_MAGNET) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.CRUSHED_ORE_OVERLAY) .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.DUST_OVERLAY)) .setSound(GTSoundEntries.ARC); - public final static GTRecipeType EXTRACTOR_RECIPES = register("extractor", ELECTRIC).setMaxIOSize(1, 1, 0, 1) + public final static GTRecipeType EXTRACTOR_RECIPES = REGISTRATE.recipeType("extractor", ELECTRIC) + .setMaxIOSize(1, 1, 0, 1) .setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.duration(400).EUt(2)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_EXTRACT) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.EXTRACTOR_OVERLAY)) .setIconSupplier(() -> GTMachines.EXTRACTOR[GTValues.LV].asStack()); - public final static GTRecipeType EXTRUDER_RECIPES = register("extruder", ELECTRIC).setMaxIOSize(2, 1, 0, 0) + public final static GTRecipeType EXTRUDER_RECIPES = REGISTRATE.recipeType("extruder", ELECTRIC) + .setMaxIOSize(2, 1, 0, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_EXTRUDER) .setItemSlotOverlay(IO.IN, 1, GTGuiTextures.MOLD_OVERLAY)) @@ -292,7 +307,8 @@ public class GTRecipeTypes { // .setProgressBar(GuiTextures.PROGRESS_BAR_EXTRUDER, LEFT_TO_RIGHT) .setSound(GTSoundEntries.COMPRESSOR); - public final static GTRecipeType FERMENTING_RECIPES = register("fermenter", ELECTRIC).setMaxIOSize(1, 1, 1, 1) + public final static GTRecipeType FERMENTING_RECIPES = REGISTRATE.recipeType("fermenter", ELECTRIC) + .setMaxIOSize(1, 1, 1, 1) .setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.EUt(2)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW) @@ -303,7 +319,8 @@ public class GTRecipeTypes { // .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, LEFT_TO_RIGHT) .setSound(GTSoundEntries.CHEMICAL); - public final static GTRecipeType FLUID_HEATER_RECIPES = register("fluid_heater", ELECTRIC).setMaxIOSize(1, 0, 1, 1) + public final static GTRecipeType FLUID_HEATER_RECIPES = REGISTRATE.recipeType("fluid_heater", ELECTRIC) + .setMaxIOSize(1, 0, 1, 1) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.INT_CIRCUIT_OVERLAY) @@ -315,7 +332,7 @@ public class GTRecipeTypes { // .setProgressBar(GuiTextures.PROGRESS_BAR_ARROW, LEFT_TO_RIGHT) .setSound(GTSoundEntries.BOILER); - public final static GTRecipeType FLUID_SOLIDFICATION_RECIPES = register("fluid_solidifier", ELECTRIC) + public final static GTRecipeType FLUID_SOLIDFICATION_RECIPES = REGISTRATE.recipeType("fluid_solidifier", ELECTRIC) .setMaxIOSize(1, 1, 1, 0).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.SOLIDIFIER_OVERLAY)) @@ -339,7 +356,8 @@ public class GTRecipeTypes { .asWidget() .height(5)); - public final static GTRecipeType FORGE_HAMMER_RECIPES = register("forge_hammer", ELECTRIC).setMaxIOSize(1, 1, 0, 0) + public final static GTRecipeType FORGE_HAMMER_RECIPES = REGISTRATE.recipeType("forge_hammer", ELECTRIC) + .setMaxIOSize(1, 1, 0, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_HAMMER) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.HAMMER_OVERLAY) @@ -347,13 +365,14 @@ public class GTRecipeTypes { .setIconSupplier(() -> GTMachines.FORGE_HAMMER[GTValues.LV].asStack()) .setSound(GTSoundEntries.FORGE_HAMMER); - public final static GTRecipeType FORMING_PRESS_RECIPES = register("forming_press", ELECTRIC) + public final static GTRecipeType FORMING_PRESS_RECIPES = REGISTRATE.recipeType("forming_press", ELECTRIC) .setMaxIOSize(6, 1, 0, 0).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_COMPRESS)) .addCustomRecipeLogic(FormingPressLogic.INSTANCE) .setSound(GTSoundEntries.COMPRESSOR); - public final static GTRecipeType LATHE_RECIPES = register("lathe", ELECTRIC).setMaxIOSize(1, 2, 0, 0).setEUIO(IO.IN) + public final static GTRecipeType LATHE_RECIPES = REGISTRATE.recipeType("lathe", ELECTRIC).setMaxIOSize(1, 2, 0, 0) + .setEUIO(IO.IN) .UI(builder -> builder .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.PIPE_OVERLAY_1) .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.PIPE_OVERLAY_2) @@ -367,7 +386,8 @@ public class GTRecipeTypes { .child(GTGuiTextures.PROGRESS_BAR_LATHE_BASE.asWidget().width(5)))) .setSound(GTSoundEntries.CUT); - public final static GTRecipeType MIXER_RECIPES = register("mixer", ELECTRIC).setMaxIOSize(6, 1, 2, 1).setEUIO(IO.IN) + public final static GTRecipeType MIXER_RECIPES = REGISTRATE.recipeType("mixer", ELECTRIC).setMaxIOSize(6, 1, 2, 1) + .setEUIO(IO.IN) .UI(builder -> builder .setProgressBarSupplier((l, v, m) -> { return new CircularProgressDrawable() @@ -381,7 +401,8 @@ public class GTRecipeTypes { .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.DUST_OVERLAY)) .setSound(GTSoundEntries.MIXER); - public final static GTRecipeType ORE_WASHER_RECIPES = register("ore_washer", ELECTRIC).setMaxIOSize(2, 3, 1, 0) + public final static GTRecipeType ORE_WASHER_RECIPES = REGISTRATE.recipeType("ore_washer", ELECTRIC) + .setMaxIOSize(2, 3, 1, 0) .setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.duration(400).EUt(16)) .UI(builder -> builder @@ -397,7 +418,7 @@ public class GTRecipeTypes { .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.DUST_OVERLAY)) .setSound(GTSoundEntries.BATH); - public final static GTRecipeType PACKER_RECIPES = register("packer", ELECTRIC).setMaxIOSize(2, 2, 0, 0) + public final static GTRecipeType PACKER_RECIPES = REGISTRATE.recipeType("packer", ELECTRIC).setMaxIOSize(2, 2, 0, 0) .setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.EUt(12).duration(10)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_PACKER) @@ -405,23 +426,24 @@ public class GTRecipeTypes { .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.BOX_OVERLAY)) .setSound(GTSoundEntries.ASSEMBLER); - public final static GTRecipeType POLARIZER_RECIPES = register("polarizer", ELECTRIC).setMaxIOSize(1, 1, 0, 0) + public final static GTRecipeType POLARIZER_RECIPES = REGISTRATE.recipeType("polarizer", ELECTRIC) + .setMaxIOSize(1, 1, 0, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_MAGNET)) .setSound(GTSoundEntries.ARC); - public final static GTRecipeType LASER_ENGRAVER_RECIPES = register("laser_engraver", ELECTRIC) + public final static GTRecipeType LASER_ENGRAVER_RECIPES = REGISTRATE.recipeType("laser_engraver", ELECTRIC) .setMaxIOSize(2, 1, 0, 0).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW) .setItemSlotOverlay(IO.IN, 1, GTGuiTextures.LENS_OVERLAY)) .setSound(GTSoundEntries.ELECTROLYZER); - public final static GTRecipeType SIFTER_RECIPES = register("sifter", ELECTRIC).setMaxIOSize(1, 6, 0, 0) + public final static GTRecipeType SIFTER_RECIPES = REGISTRATE.recipeType("sifter", ELECTRIC).setMaxIOSize(1, 6, 0, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_SIFTER)) .setSound(new ExistingSoundEntry(SoundEvents.SAND_PLACE, SoundSource.BLOCKS)); - public final static GTRecipeType THERMAL_CENTRIFUGE_RECIPES = register("thermal_centrifuge", ELECTRIC) + public final static GTRecipeType THERMAL_CENTRIFUGE_RECIPES = REGISTRATE.recipeType("thermal_centrifuge", ELECTRIC) .setMaxIOSize(1, 3, 0, 0).setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.duration(400).EUt(30)) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW) @@ -429,13 +451,14 @@ public class GTRecipeTypes { .setItemSlotOverlay(IO.OUT, 0, GTGuiTextures.DUST_OVERLAY)) .setSound(GTSoundEntries.CENTRIFUGE); - public final static GTRecipeType WIREMILL_RECIPES = register("wiremill", ELECTRIC).setMaxIOSize(2, 1, 0, 0) + public final static GTRecipeType WIREMILL_RECIPES = REGISTRATE.recipeType("wiremill", ELECTRIC) + .setMaxIOSize(2, 1, 0, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_WIREMILL) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.WIREMILL_OVERLAY)) .setSound(GTSoundEntries.MOTOR); - public final static GTRecipeType CIRCUIT_ASSEMBLER_RECIPES = register("circuit_assembler", ELECTRIC) + public final static GTRecipeType CIRCUIT_ASSEMBLER_RECIPES = REGISTRATE.recipeType("circuit_assembler", ELECTRIC) .setMaxIOSize(6, 1, 1, 0).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_CIRCUIT_ASSEMBLER) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.CIRCUIT_OVERLAY)) @@ -457,19 +480,19 @@ public class GTRecipeTypes { } }); - public final static GTRecipeType GAS_COLLECTOR_RECIPES = register("gas_collector", ELECTRIC) + public final static GTRecipeType GAS_COLLECTOR_RECIPES = REGISTRATE.recipeType("gas_collector", ELECTRIC) .setMaxIOSize(1, 0, 0, 1).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_GAS_COLLECTOR) .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.INT_CIRCUIT_OVERLAY) .setFluidSlotOverlay(IO.OUT, 0, GTGuiTextures.CENTRIFUGE_OVERLAY)) .setSound(GTSoundEntries.COOLING); - public final static GTRecipeType AIR_SCRUBBER_RECIPES = register("air_scrubber", ELECTRIC) + public final static GTRecipeType AIR_SCRUBBER_RECIPES = REGISTRATE.recipeType("air_scrubber", ELECTRIC) .setMaxIOSize(1, 3, 1, 3).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_GAS_COLLECTOR)) .setSound(GTSoundEntries.COOLING); - public static final GTRecipeType RESEARCH_STATION_RECIPES = register("research_station", ELECTRIC) + public static final GTRecipeType RESEARCH_STATION_RECIPES = REGISTRATE.recipeType("research_station", ELECTRIC) .setEUIO(IO.IN) .setMaxSize(IO.IN, GTRecipeCapabilities.CWU, 1) .setMaxIOSize(2, 1, 0, 0) @@ -480,7 +503,8 @@ public class GTRecipeTypes { .setMaxTooltips(4) .setSound(GTValues.FOOLS.getAsBoolean() ? GTSoundEntries.SCIENCE : GTSoundEntries.COMPUTATION); - public final static GTRecipeType ROCK_BREAKER_RECIPES = register("rock_breaker", ELECTRIC).setMaxIOSize(1, 4, 0, 0) + public final static GTRecipeType ROCK_BREAKER_RECIPES = REGISTRATE.recipeType("rock_breaker", ELECTRIC) + .setMaxIOSize(1, 4, 0, 0) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_MACERATE) .setMachineLayoutGridBuilder(ItemRecipeCapability.CAP, IO.OUT, (machine, layout) -> { @@ -492,7 +516,7 @@ public class GTRecipeTypes { .setIconSupplier(() -> GTMachines.ROCK_CRUSHER[GTValues.LV].asStack()) .setSound(GTSoundEntries.FIRE); - public static final GTRecipeType SCANNER_RECIPES = register("scanner", ELECTRIC) + public static final GTRecipeType SCANNER_RECIPES = REGISTRATE.recipeType("scanner", ELECTRIC) .setEUIO(IO.IN) .setMaxIOSize(2, 1, 1, 0) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW) @@ -505,25 +529,28 @@ public class GTRecipeTypes { ////////////////////////////////////// // ******* Generator *******// ////////////////////////////////////// - public final static GTRecipeType COMBUSTION_GENERATOR_FUELS = register("combustion_generator", GENERATOR) + public final static GTRecipeType COMBUSTION_GENERATOR_FUELS = REGISTRATE + .recipeType("combustion_generator", GENERATOR) .setMaxIOSize(0, 0, 1, 0).setEUIO(IO.OUT) .UI(builder -> builder.setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.FURNACE_OVERLAY_2) .setProgressBar(GTGuiTextures.PROGRESS_ARROW_MULTIPLE)) .setSound(GTSoundEntries.COMBUSTION); - public final static GTRecipeType GAS_TURBINE_FUELS = register("gas_turbine", GENERATOR).setMaxIOSize(0, 0, 1, 0) + public final static GTRecipeType GAS_TURBINE_FUELS = REGISTRATE.recipeType("gas_turbine", GENERATOR) + .setMaxIOSize(0, 0, 1, 0) .setEUIO(IO.OUT) .UI(builder -> builder.setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.DARK_CANISTER_OVERLAY) .setProgressBar(GTGuiTextures.PROGRESS_GAS_COLLECTOR)) .setSound(GTSoundEntries.TURBINE); - public final static GTRecipeType STEAM_TURBINE_FUELS = register("steam_turbine", GENERATOR).setMaxIOSize(0, 0, 1, 1) + public final static GTRecipeType STEAM_TURBINE_FUELS = REGISTRATE.recipeType("steam_turbine", GENERATOR) + .setMaxIOSize(0, 0, 1, 1) .setEUIO(IO.OUT) .UI(builder -> builder.setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.CENTRIFUGE_OVERLAY) .setProgressBar(GTGuiTextures.PROGRESS_GAS_COLLECTOR)) .setSound(GTSoundEntries.TURBINE); - public final static GTRecipeType PLASMA_GENERATOR_FUELS = register("plasma_generator", GENERATOR) + public final static GTRecipeType PLASMA_GENERATOR_FUELS = REGISTRATE.recipeType("plasma_generator", GENERATOR) .setMaxIOSize(0, 0, 1, 1).setEUIO(IO.OUT) .UI(builder -> builder.setFluidSlotOverlay(IO.IN, 0, GTGuiTextures.CENTRIFUGE_OVERLAY) .setProgressBar(GTGuiTextures.PROGRESS_GAS_COLLECTOR)) @@ -532,30 +559,32 @@ public class GTRecipeTypes { ////////////////////////////////////// // ******* Multiblock *******// ////////////////////////////////////// - public final static GTRecipeType LARGE_BOILER_RECIPES = register("large_boiler", MULTIBLOCK) + public final static GTRecipeType LARGE_BOILER_RECIPES = REGISTRATE.recipeType("large_boiler", MULTIBLOCK) .setMaxIOSize(1, 0, 1, 1) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_BOILER_FUEL_STEEL)) .setMaxTooltips(1) .setSound(GTSoundEntries.FURNACE); - public final static GTRecipeType COKE_OVEN_RECIPES = register("coke_oven", MULTIBLOCK).setMaxIOSize(1, 1, 0, 1) + public final static GTRecipeType COKE_OVEN_RECIPES = REGISTRATE.recipeType("coke_oven", MULTIBLOCK) + .setMaxIOSize(1, 1, 0, 1) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW)) .setMaxTooltips(1) .setSound(GTSoundEntries.FIRE); - public final static GTRecipeType PRIMITIVE_BLAST_FURNACE_RECIPES = register("primitive_blast_furnace", MULTIBLOCK) + public final static GTRecipeType PRIMITIVE_BLAST_FURNACE_RECIPES = REGISTRATE + .recipeType("primitive_blast_furnace", MULTIBLOCK) .setMaxIOSize(3, 3, 0, 0) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW)) .setMaxTooltips(1) .setSound(GTSoundEntries.FIRE); - public final static GTRecipeType BLAST_RECIPES = register("electric_blast_furnace", MULTIBLOCK) + public final static GTRecipeType BLAST_RECIPES = REGISTRATE.recipeType("electric_blast_furnace", MULTIBLOCK) .setMaxIOSize(3, 3, 1, 1).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW) .addRecipeUIModifier(GTRecipeUIModifiers.TEMP_COIL_INFO)) .setSound(GTSoundEntries.FURNACE); - public final static GTRecipeType DISTILLATION_RECIPES = register("distillation_tower", MULTIBLOCK) + public final static GTRecipeType DISTILLATION_RECIPES = REGISTRATE.recipeType("distillation_tower", MULTIBLOCK) .setMaxIOSize(0, 1, 1, 12).setEUIO(IO.IN) .setSound(GTSoundEntries.CHEMICAL) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW_MULTIPLE)) @@ -633,12 +662,14 @@ public class GTRecipeTypes { } }); - public final static GTRecipeType PYROLYSE_RECIPES = register("pyrolyse_oven", MULTIBLOCK).setMaxIOSize(2, 1, 1, 1) + public final static GTRecipeType PYROLYSE_RECIPES = REGISTRATE.recipeType("pyrolyse_oven", MULTIBLOCK) + .setMaxIOSize(2, 1, 1, 1) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW)) .setSound(GTSoundEntries.FIRE); - public final static GTRecipeType CRACKING_RECIPES = register("cracker", MULTIBLOCK).setMaxIOSize(1, 0, 2, 2) + public final static GTRecipeType CRACKING_RECIPES = REGISTRATE.recipeType("cracker", MULTIBLOCK) + .setMaxIOSize(1, 0, 2, 2) .setEUIO(IO.IN) .UI(builder -> builder .setProgressBar(GTGuiTextures.PROGRESS_CRACKING) @@ -647,7 +678,7 @@ public class GTRecipeTypes { .setItemSlotOverlay(IO.IN, 0, GTGuiTextures.CIRCUIT_OVERLAY)) .setSound(GTSoundEntries.FIRE); - public final static GTRecipeType IMPLOSION_RECIPES = register("implosion_compressor", MULTIBLOCK) + public final static GTRecipeType IMPLOSION_RECIPES = REGISTRATE.recipeType("implosion_compressor", MULTIBLOCK) .setMaxIOSize(3, 2, 0, 0).setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.duration(20).EUt(GTValues.VA[GTValues.LV])) .UI(builder -> builder @@ -657,20 +688,22 @@ public class GTRecipeTypes { .setItemSlotOverlay(IO.OUT, 1, GTGuiTextures.DUST_OVERLAY)) .setSound(new ExistingSoundEntry(SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS)); - public final static GTRecipeType VACUUM_RECIPES = register("vacuum_freezer", MULTIBLOCK).setMaxIOSize(1, 1, 2, 1) + public final static GTRecipeType VACUUM_RECIPES = REGISTRATE.recipeType("vacuum_freezer", MULTIBLOCK) + .setMaxIOSize(1, 1, 2, 1) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW)) .prepareBuilder(recipeBuilder -> recipeBuilder.EUt(GTValues.VA[GTValues.MV])) .setSound(GTSoundEntries.COOLING); - public final static GTRecipeType ASSEMBLY_LINE_RECIPES = register("assembly_line", MULTIBLOCK) + public final static GTRecipeType ASSEMBLY_LINE_RECIPES = REGISTRATE.recipeType("assembly_line", MULTIBLOCK) .setMaxIOSize(16, 1, 4, 0).setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_ARROW)) .setSound(GTSoundEntries.ASSEMBLER) .setHasResearchSlot(true) .onRecipeBuild(ResearchManager::createDefaultResearchRecipe); - public static final GTRecipeType LARGE_CHEMICAL_RECIPES = register("large_chemical_reactor", MULTIBLOCK) + public static final GTRecipeType LARGE_CHEMICAL_RECIPES = REGISTRATE + .recipeType("large_chemical_reactor", MULTIBLOCK) .setMaxIOSize(3, 3, 5, 4).setEUIO(IO.IN) .prepareBuilder(recipeBuilder -> recipeBuilder.EUt(GTValues.VA[GTValues.LV])) .UI(builder -> builder @@ -684,47 +717,32 @@ public class GTRecipeTypes { .setSound(GTValues.FOOLS.getAsBoolean() ? GTSoundEntries.SCIENCE : GTSoundEntries.CHEMICAL) .setSmallRecipeMap(CHEMICAL_RECIPES); - public static final GTRecipeType FUSION_RECIPES = register("fusion_reactor", MULTIBLOCK).setMaxIOSize(0, 0, 2, 1) + public static final GTRecipeType FUSION_RECIPES = REGISTRATE.recipeType("fusion_reactor", MULTIBLOCK) + .setMaxIOSize(0, 0, 2, 1) .setEUIO(IO.IN) .UI(builder -> builder.setProgressBar(GTGuiTextures.PROGRESS_FUSION) .addRecipeUIModifier(FusionReactorMachine::addEUToStartLabel)) .setSound(GTSoundEntries.ARC) .setMaxTooltips(4); - public static final GTRecipeType DUMMY_RECIPES = register("dummy", DUMMY) + public static final GTRecipeType DUMMY_RECIPES = REGISTRATE.recipeType("dummy", DUMMY) .setXEIVisible(false); - public static GTRecipeType register(String name, String group, RecipeType... proxyRecipes) { - var recipeType = new GTRecipeType(GTCEu.id(name), group, proxyRecipes); - GTRegistries.register(BuiltInRegistries.RECIPE_TYPE, recipeType.registryName, recipeType); - GTRegistries.register(BuiltInRegistries.RECIPE_SERIALIZER, recipeType.registryName, new GTRecipeSerializer()); - GTRegistries.RECIPE_TYPES.register(recipeType.registryName, recipeType); - return recipeType; - } - - public static void init() { + public static void init(IEventBus modBus) { GCYMRecipeTypes.init(); - if (GTCEu.Mods.isKubeJSLoaded()) { - GTRegistryInfo.registerFor(GTRegistries.RECIPE_TYPES.getRegistryName()); - } - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.RECIPE_TYPES, GTRecipeType.class)); - GTRegistries.RECIPE_TYPES.freeze(); - - GTRegistries.register(BuiltInRegistries.RECIPE_SERIALIZER, GTCEu.id("machine"), - GTRecipeSerializer.SERIALIZER); - GTRegistries.register(BuiltInRegistries.RECIPE_SERIALIZER, GTCEu.id("crafting_facade_cover"), - FacadeCoverRecipe.SERIALIZER); - GTRegistries.register(BuiltInRegistries.RECIPE_SERIALIZER, GTCEu.id("crafting_shaped_strict"), - StrictShapedRecipe.SERIALIZER); - GTRegistries.register(BuiltInRegistries.RECIPE_SERIALIZER, GTCEu.id("crafting_shaped_energy_transfer"), - ShapedEnergyTransferRecipe.SERIALIZER); - GTRegistries.register(BuiltInRegistries.RECIPE_SERIALIZER, GTCEu.id("crafting_tool_head_replace"), - ToolHeadReplaceRecipe.SERIALIZER); - GTRegistries.register(BuiltInRegistries.RECIPE_SERIALIZER, GTCEu.id("crafting_shaped_fluid_container"), - ShapedFluidContainerRecipe.SERIALIZER); + + RECIPE_SERIALIZERS.register(modBus); + + RECIPE_SERIALIZERS.register("machine", () -> GTRecipeSerializer.SERIALIZER); + RECIPE_SERIALIZERS.register("crafting_facade_cover", () -> FacadeCoverRecipe.SERIALIZER); + RECIPE_SERIALIZERS.register("crafting_shaped_strict", () -> StrictShapedRecipe.SERIALIZER); + RECIPE_SERIALIZERS.register("crafting_shaped_energy_transfer", () -> ShapedEnergyTransferRecipe.SERIALIZER); + RECIPE_SERIALIZERS.register("crafting_tool_head_replace", () -> ToolHeadReplaceRecipe.SERIALIZER); + RECIPE_SERIALIZERS.register("crafting_shaped_fluid_container", () -> ShapedFluidContainerRecipe.SERIALIZER); } public static GTRecipeType get(String name) { - return GTRegistries.RECIPE_TYPES.get(GTCEu.id(name)); + return (GTRecipeType) RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY) + .registryOrThrow(Registries.RECIPE_TYPE).get(GTCEu.id(name)); } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTSignBlockEntities.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTSignBlockEntities.java new file mode 100644 index 00000000000..0ff07c8b930 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTSignBlockEntities.java @@ -0,0 +1,32 @@ +package com.gregtechceu.gtceu.common.data; + +import com.gregtechceu.gtceu.common.blockentity.GTHangingSignBlockEntity; + +import net.minecraft.world.level.block.entity.SignBlockEntity; + +import com.tterrag.registrate.util.entry.BlockEntityEntry; + +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; + +// This has to be seperate from GTBlockEntities because of the order in which forge events are fired, as the main block +// entities class can't be loaded before the registries are populated. +public class GTSignBlockEntities { + + public static void init() {} + + public static final BlockEntityEntry GT_SIGN = REGISTRATE + .blockEntity("sign", SignBlockEntity::new) + .validBlocks(GTBlocks.RUBBER_SIGN, + GTBlocks.RUBBER_WALL_SIGN, + GTBlocks.TREATED_WOOD_SIGN, + GTBlocks.TREATED_WOOD_WALL_SIGN) + .register(); + + public static final BlockEntityEntry GT_HANGING_SIGN = REGISTRATE + .blockEntity("hanging_sign", GTHangingSignBlockEntity::new) + .validBlocks(GTBlocks.RUBBER_HANGING_SIGN, + GTBlocks.RUBBER_WALL_HANGING_SIGN, + GTBlocks.TREATED_WOOD_HANGING_SIGN, + GTBlocks.TREATED_WOOD_WALL_HANGING_SIGN) + .register(); +} diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTSoundEntries.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTSoundEntries.java index 3064fea1909..5b84d45eeca 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTSoundEntries.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTSoundEntries.java @@ -1,22 +1,18 @@ package com.gregtechceu.gtceu.common.data; -import com.gregtechceu.gtceu.api.GTCEuAPI; -import com.gregtechceu.gtceu.api.addon.AddonFinder; -import com.gregtechceu.gtceu.api.addon.IGTAddon; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.sound.SoundEntry; -import net.minecraftforge.fml.ModLoader; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.registries.RegisterEvent; import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; +@Mod.EventBusSubscriber public class GTSoundEntries { - static { - GTRegistries.SOUNDS.unfreeze(); - } - // Machine Sounds public static final SoundEntry FORGE_HAMMER = REGISTRATE.sound("forge_hammer").build(); public static final SoundEntry MACERATOR = REGISTRATE.sound("macerator").build(); @@ -58,18 +54,17 @@ public class GTSoundEntries { public static final SoundEntry PORTAL_CLOSING = REGISTRATE.sound("portal_closing").build(); public static final SoundEntry METAL_PIPE = REGISTRATE.sound("metal_pipe").build(); - public static void init() { - AddonFinder.getAddons().forEach(IGTAddon::registerSounds); - ModLoader.get().postEvent(new GTCEuAPI.RegisterEvent<>(GTRegistries.SOUNDS, SoundEntry.class)); - GTRegistries.SOUNDS.forEach(SoundEntry::prepare); - registerSounds(); - - GTRegistries.SOUNDS.freeze(); - } + public static void init() {} - private static void registerSounds() { - for (SoundEntry entry : GTRegistries.SOUNDS) { - entry.register(soundEvent -> ForgeRegistries.SOUND_EVENTS.register(soundEvent.getLocation(), soundEvent)); + @SubscribeEvent + public static void registerSounds(RegisterEvent event) { + if (event.getRegistryKey() == Registries.SOUND_EVENT) { + GTRegistries.SOUNDS.forEach(SoundEntry::prepare); + for (SoundEntry entry : GTRegistries.SOUNDS) { + entry.register(soundEvent -> { + event.register(Registries.SOUND_EVENT, soundEvent.getLocation(), () -> soundEvent); + }); + } } } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMachineUtils.java b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMachineUtils.java index d2d449d7c3b..98a405e10e8 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMachineUtils.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/machines/GTMachineUtils.java @@ -1031,6 +1031,4 @@ public MachineDefinition[] register() { tiers); } } - - public static void init() {} } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/materials/ElementMaterials.java b/src/main/java/com/gregtechceu/gtceu/common/data/materials/ElementMaterials.java index 432009190f2..01d84f0cee7 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/materials/ElementMaterials.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/materials/ElementMaterials.java @@ -1,7 +1,5 @@ package com.gregtechceu.gtceu.common.data.materials; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.ArmorProperty; import com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty.GasTier; import com.gregtechceu.gtceu.api.data.chemical.material.properties.HazardProperty; @@ -19,16 +17,17 @@ import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags.*; import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet.*; import static com.gregtechceu.gtceu.common.data.GTMaterials.*; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; public class ElementMaterials { public static void register() { - Actinium = new Material.Builder(GTCEu.id("actinium")) + Actinium = REGISTRATE.material("actinium") .color(0xC3D1FF).secondaryColor(0x397090).iconSet(METALLIC) .element(GTElements.Ac) .buildAndRegister(); - Aluminium = new Material.Builder(GTCEu.id("aluminium")) + Aluminium = REGISTRATE.material("aluminium") .ingot() .liquid(new FluidBuilder().temperature(933)) .ore() @@ -44,7 +43,7 @@ public static void register() { .blast(1700, GasTier.LOW) .buildAndRegister(); - Americium = new Material.Builder(GTCEu.id("americium")) + Americium = REGISTRATE.material("americium") .ingot(3) .liquid(new FluidBuilder().temperature(1449)) .plasma() @@ -54,7 +53,7 @@ public static void register() { .itemPipeProperties(64, 64) .buildAndRegister(); - Antimony = new Material.Builder(GTCEu.id("antimony")) + Antimony = REGISTRATE.material("antimony") .ingot() .liquid(new FluidBuilder().temperature(904)) .color(0xeaeaff).secondaryColor(0x8181bd).iconSet(SHINY) @@ -62,13 +61,13 @@ public static void register() { .element(GTElements.Sb) .buildAndRegister(); - Argon = new Material.Builder(GTCEu.id("argon")) + Argon = REGISTRATE.material("argon") .gas().plasma() .color(0x00FF00) .element(GTElements.Ar) .buildAndRegister(); - Arsenic = new Material.Builder(GTCEu.id("arsenic")) + Arsenic = REGISTRATE.material("arsenic") .dust() .gas(new FluidBuilder() .state(FluidState.GAS) @@ -78,23 +77,23 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.ARSENICOSIS) .buildAndRegister(); - Astatine = new Material.Builder(GTCEu.id("astatine")) + Astatine = REGISTRATE.material("astatine") .color(0x65204f).secondaryColor(0x17212b) .element(GTElements.At) .buildAndRegister(); - Barium = new Material.Builder(GTCEu.id("barium")) + Barium = REGISTRATE.material("barium") .dust() .color(0xede192).secondaryColor(0xa7ad4d).iconSet(METALLIC) .element(GTElements.Ba) .buildAndRegister(); - Berkelium = new Material.Builder(GTCEu.id("berkelium")) + Berkelium = REGISTRATE.material("berkelium") .color(0x645A88).iconSet(RADIOACTIVE) .element(GTElements.Bk) .buildAndRegister(); - Beryllium = new Material.Builder(GTCEu.id("beryllium")) + Beryllium = REGISTRATE.material("beryllium") .ingot() .liquid(new FluidBuilder().temperature(1560)) .ore() @@ -103,75 +102,75 @@ public static void register() { .element(GTElements.Be) .buildAndRegister(); - Bismuth = new Material.Builder(GTCEu.id("bismuth")) + Bismuth = REGISTRATE.material("bismuth") .ingot(1) .liquid(new FluidBuilder().temperature(545)) .color(0x5fdddd).secondaryColor(0x517385).iconSet(METALLIC) .element(GTElements.Bi) .buildAndRegister(); - Bohrium = new Material.Builder(GTCEu.id("bohrium")) + Bohrium = REGISTRATE.material("bohrium") .color(0xde67ff).secondaryColor(0xDC57FF).iconSet(RADIOACTIVE) .element(GTElements.Bh) .buildAndRegister(); - Boron = new Material.Builder(GTCEu.id("boron")) + Boron = REGISTRATE.material("boron") .dust() .color(0xbffdbf).secondaryColor(0x6d7058) .element(GTElements.B) .buildAndRegister(); - Bromine = new Material.Builder(GTCEu.id("bromine")) + Bromine = REGISTRATE.material("bromine") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0x912200).secondaryColor(0x080101).iconSet(SHINY) .element(GTElements.Br) .buildAndRegister(); - Caesium = new Material.Builder(GTCEu.id("caesium")) + Caesium = REGISTRATE.material("caesium") .dust() .color(0xd1821c).secondaryColor(0x231f14).iconSet(SHINY) .element(GTElements.Cs) .buildAndRegister(); - Calcium = new Material.Builder(GTCEu.id("calcium")) + Calcium = REGISTRATE.material("calcium") .dust() .color(0xFFF5DE).secondaryColor(0xa4a4a4).iconSet(METALLIC) .element(GTElements.Ca) .buildAndRegister(); - Californium = new Material.Builder(GTCEu.id("californium")) + Californium = REGISTRATE.material("californium") .color(0xA85A12).iconSet(RADIOACTIVE) .element(GTElements.Cf) .buildAndRegister(); - Carbon = new Material.Builder(GTCEu.id("carbon")) + Carbon = REGISTRATE.material("carbon") .dust() .liquid(new FluidBuilder().temperature(4600)) .color(0x333030).secondaryColor(0x221c1c) .element(GTElements.C) .buildAndRegister(); - Cadmium = new Material.Builder(GTCEu.id("cadmium")) + Cadmium = REGISTRATE.material("cadmium") .dust() .color(0x636377).secondaryColor(0x431a34).iconSet(SHINY) .element(GTElements.Cd) .hazard(HazardProperty.HazardTrigger.ANY, GTMedicalConditions.POISON) .buildAndRegister(); - Cerium = new Material.Builder(GTCEu.id("cerium")) + Cerium = REGISTRATE.material("cerium") .dust() .liquid(new FluidBuilder().temperature(1068)) .color(0x87917D).secondaryColor(0x5e6458).iconSet(METALLIC) .element(GTElements.Ce) .buildAndRegister(); - Chlorine = new Material.Builder(GTCEu.id("chlorine")) + Chlorine = REGISTRATE.material("chlorine") .gas(new FluidBuilder().state(FluidState.GAS).customStill()) .element(GTElements.Cl) // TODO hazard .buildAndRegister(); - Chromium = new Material.Builder(GTCEu.id("chromium")) + Chromium = REGISTRATE.material("chromium") .ingot(3) .liquid(new FluidBuilder().temperature(2180)) .color(0xf3e0ea).secondaryColor(0x441f2e).iconSet(SHINY) @@ -183,7 +182,7 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.SKIN_CONTACT, GTMedicalConditions.CARCINOGEN) .buildAndRegister(); - Cobalt = new Material.Builder(GTCEu.id("cobalt")) + Cobalt = REGISTRATE.material("cobalt") .ingot() .liquid(new FluidBuilder().temperature(1768)) .ore() // leave for TiCon ore processing @@ -194,13 +193,13 @@ public static void register() { .itemPipeProperties(2560, 2.0f) .buildAndRegister(); - Copernicium = new Material.Builder(GTCEu.id("copernicium")) + Copernicium = REGISTRATE.material("copernicium") .color(0x565c5d).secondaryColor(0xffd34b).iconSet(RADIOACTIVE) .element(GTElements.Cn) // .radioactiveHazard(1) .buildAndRegister(); - Copper = new Material.Builder(GTCEu.id("copper")) + Copper = REGISTRATE.material("copper") .ingot(1) .liquid(new FluidBuilder().temperature(1358)) .ore() @@ -212,47 +211,47 @@ public static void register() { .fluidPipeProperties(1696, 6, true) .buildAndRegister(); - Curium = new Material.Builder(GTCEu.id("curium")) + Curium = REGISTRATE.material("curium") .color(0x7B544E).iconSet(RADIOACTIVE) .element(GTElements.Cm) // .radioactiveHazard(1) .buildAndRegister(); - Darmstadtium = new Material.Builder(GTCEu.id("darmstadtium")) + Darmstadtium = REGISTRATE.material("darmstadtium") .ingot().fluid() .color(0x578062).iconSet(RADIOACTIVE) .appendFlags(EXT2_METAL, GENERATE_ROTOR, GENERATE_DENSE, GENERATE_SMALL_GEAR) .element(GTElements.Ds) .buildAndRegister(); - Deuterium = new Material.Builder(GTCEu.id("deuterium")) + Deuterium = REGISTRATE.material("deuterium") .gas(new FluidBuilder().state(FluidState.GAS).customStill()) .element(GTElements.D) .buildAndRegister(); - Dubnium = new Material.Builder(GTCEu.id("dubnium")) + Dubnium = REGISTRATE.material("dubnium") .color(0xc7ddde).secondaryColor(0x00f3ff).iconSet(RADIOACTIVE) .element(GTElements.Db) .buildAndRegister(); - Dysprosium = new Material.Builder(GTCEu.id("dysprosium")) + Dysprosium = REGISTRATE.material("dysprosium") .color(0x6a664b).secondaryColor(0x423307) .iconSet(METALLIC) .element(GTElements.Dy) .buildAndRegister(); - Einsteinium = new Material.Builder(GTCEu.id("einsteinium")) + Einsteinium = REGISTRATE.material("einsteinium") .color(0xCE9F00).iconSet(RADIOACTIVE) .element(GTElements.Es) .buildAndRegister(); - Erbium = new Material.Builder(GTCEu.id("erbium")) + Erbium = REGISTRATE.material("erbium") .color(0xeccbdb).secondaryColor(0x5d625a) .iconSet(METALLIC) .element(GTElements.Er) .buildAndRegister(); - Europium = new Material.Builder(GTCEu.id("europium")) + Europium = REGISTRATE.material("europium") .ingot() .liquid(new FluidBuilder().temperature(1099)) .color(0x20FFFF).secondaryColor(0x429393).iconSet(METALLIC) @@ -266,35 +265,35 @@ public static void register() { .vacuumStats(VA[HV])) .buildAndRegister(); - Fermium = new Material.Builder(GTCEu.id("fermium")) + Fermium = REGISTRATE.material("fermium") .color(0xc99fe7).secondaryColor(0x890085).iconSet(METALLIC) .element(GTElements.Fm) // .radioactiveHazard(1) .buildAndRegister(); - Flerovium = new Material.Builder(GTCEu.id("flerovium")) + Flerovium = REGISTRATE.material("flerovium") .color(0x2a384e).secondaryColor(0xd2ff00) .iconSet(RADIOACTIVE) .element(GTElements.Fl) .buildAndRegister(); - Fluorine = new Material.Builder(GTCEu.id("fluorine")) + Fluorine = REGISTRATE.material("fluorine") .gas(new FluidBuilder().state(FluidState.GAS).customStill()) .element(GTElements.F) .hazard(HazardProperty.HazardTrigger.SKIN_CONTACT, GTMedicalConditions.CHEMICAL_BURNS, false) .buildAndRegister(); - Francium = new Material.Builder(GTCEu.id("francium")) + Francium = REGISTRATE.material("francium") .color(0xAAAAAA).secondaryColor(0x0000ff).iconSet(RADIOACTIVE) .element(GTElements.Fr) .buildAndRegister(); - Gadolinium = new Material.Builder(GTCEu.id("gadolinium")) + Gadolinium = REGISTRATE.material("gadolinium") .color(0x828a7a).secondaryColor(0x363420).iconSet(METALLIC) .element(GTElements.Gd) .buildAndRegister(); - Gallium = new Material.Builder(GTCEu.id("gallium")) + Gallium = REGISTRATE.material("gallium") .ingot() .liquid(new FluidBuilder().temperature(303)) .color(0x7a84ca).secondaryColor(0x13132e).iconSet(SHINY) @@ -302,12 +301,12 @@ public static void register() { .element(GTElements.Ga) .buildAndRegister(); - Germanium = new Material.Builder(GTCEu.id("germanium")) + Germanium = REGISTRATE.material("germanium") .color(0x4a4a4a).secondaryColor(0x2d2612).iconSet(SHINY) .element(GTElements.Ge) .buildAndRegister(); - Gold = new Material.Builder(GTCEu.id("gold")) + Gold = REGISTRATE.material("gold") .ingot() .liquid(new FluidBuilder().temperature(1337)) .ore() @@ -319,30 +318,30 @@ public static void register() { .fluidPipeProperties(1671, 25, true, true, false, false) .buildAndRegister(); - Hafnium = new Material.Builder(GTCEu.id("hafnium")) + Hafnium = REGISTRATE.material("hafnium") .color(0x99999A).secondaryColor(0x2b4a3a).iconSet(SHINY) .element(GTElements.Hf) .buildAndRegister(); - Hassium = new Material.Builder(GTCEu.id("hassium")) + Hassium = REGISTRATE.material("hassium") .color(0x738786).secondaryColor(0x62ffd5) .iconSet(RADIOACTIVE) .element(GTElements.Hs) .buildAndRegister(); - Holmium = new Material.Builder(GTCEu.id("holmium")) + Holmium = REGISTRATE.material("holmium") .color(0xf6fc9c).secondaryColor(0xa3a3a3) .iconSet(METALLIC) .element(GTElements.Ho) .buildAndRegister(); - Hydrogen = new Material.Builder(GTCEu.id("hydrogen")) + Hydrogen = REGISTRATE.material("hydrogen") .gas() .color(0x0000B5) .element(GTElements.H) .buildAndRegister(); - Helium = new Material.Builder(GTCEu.id("helium")) + Helium = REGISTRATE.material("helium") .gas(new FluidBuilder().state(FluidState.GAS).customStill()) .plasma() .liquid(new FluidBuilder() @@ -354,27 +353,27 @@ public static void register() { .buildAndRegister(); Helium.getProperty(PropertyKey.FLUID).setPrimaryKey(FluidStorageKeys.GAS); - Helium3 = new Material.Builder(GTCEu.id("helium_3")) + Helium3 = REGISTRATE.material("helium_3") .gas(new FluidBuilder() .customStill() .translation("gtceu.fluid.generic")) .element(GTElements.He3) .buildAndRegister(); - Indium = new Material.Builder(GTCEu.id("indium")) + Indium = REGISTRATE.material("indium") .ingot() .liquid(new FluidBuilder().temperature(430)) .color(0x5c3588).secondaryColor(0x2b0b4a).iconSet(SHINY) .element(GTElements.In) .buildAndRegister(); - Iodine = new Material.Builder(GTCEu.id("iodine")) + Iodine = REGISTRATE.material("iodine") .dust() .color(0x3e4467).secondaryColor(0x021e40).iconSet(SHINY) .element(GTElements.I) .buildAndRegister(); - Iridium = new Material.Builder(GTCEu.id("iridium")) + Iridium = REGISTRATE.material("iridium") .ingot(3) .liquid(new FluidBuilder().temperature(2719)) .color(0x99fede).secondaryColor(0x6cd1cf).iconSet(METALLIC) @@ -387,7 +386,7 @@ public static void register() { .vacuumStats(VA[EV], 250)) .buildAndRegister(); - Iron = new Material.Builder(GTCEu.id("iron")) + Iron = REGISTRATE.material("iron") .ingot() .liquid(new FluidBuilder().temperature(1811)) .plasma() @@ -403,7 +402,7 @@ public static void register() { .cableProperties(V[MV], 2, 3) .buildAndRegister(); - Krypton = new Material.Builder(GTCEu.id("krypton")) + Krypton = REGISTRATE.material("krypton") .gas(new FluidBuilder() .customStill() .translation("gtceu.fluid.generic")) @@ -411,20 +410,20 @@ public static void register() { .element(GTElements.Kr) .buildAndRegister(); - Lanthanum = new Material.Builder(GTCEu.id("lanthanum")) + Lanthanum = REGISTRATE.material("lanthanum") .dust() .liquid(new FluidBuilder().temperature(1193)) .color(0xd17d50).secondaryColor(0x4a3560).iconSet(METALLIC) .element(GTElements.La) .buildAndRegister(); - Lawrencium = new Material.Builder(GTCEu.id("lawrencium")) + Lawrencium = REGISTRATE.material("lawrencium") .color(0x5D7575) .iconSet(RADIOACTIVE) .element(GTElements.Lr) .buildAndRegister(); - Lead = new Material.Builder(GTCEu.id("lead")) + Lead = REGISTRATE.material("lead") .ingot(1) .liquid(new FluidBuilder().temperature(600)) .ore() @@ -437,7 +436,7 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.WEAK_POISON) .buildAndRegister(); - Lithium = new Material.Builder(GTCEu.id("lithium")) + Lithium = REGISTRATE.material("lithium") .dust() .liquid(new FluidBuilder().temperature(454)) .ore() @@ -445,31 +444,31 @@ public static void register() { .element(GTElements.Li) .buildAndRegister(); - Livermorium = new Material.Builder(GTCEu.id("livermorium")) + Livermorium = REGISTRATE.material("livermorium") .color(0x939393).secondaryColor(0xff5e5e).iconSet(RADIOACTIVE) .element(GTElements.Lv) .buildAndRegister(); - Lutetium = new Material.Builder(GTCEu.id("lutetium")) + Lutetium = REGISTRATE.material("lutetium") .dust() .liquid(new FluidBuilder().temperature(1925)) .color(0x00ccff).secondaryColor(0x4c687a).iconSet(METALLIC) .element(GTElements.Lu) .buildAndRegister(); - Magnesium = new Material.Builder(GTCEu.id("magnesium")) + Magnesium = REGISTRATE.material("magnesium") .dust() .liquid(new FluidBuilder().temperature(923)) .color(0xd6e3ff).secondaryColor(0x594d19).iconSet(FINE) .element(GTElements.Mg) .buildAndRegister(); - Mendelevium = new Material.Builder(GTCEu.id("mendelevium")) + Mendelevium = REGISTRATE.material("mendelevium") .color(0x1D4ACF).iconSet(RADIOACTIVE) .element(GTElements.Md) .buildAndRegister(); - Manganese = new Material.Builder(GTCEu.id("manganese")) + Manganese = REGISTRATE.material("manganese") .ingot() .liquid(new FluidBuilder().temperature(1519)) .color(0x88a669).secondaryColor(0xCDE1B9) @@ -478,19 +477,19 @@ public static void register() { .rotorStats(100, 115, 2.0f, 512) .buildAndRegister(); - Meitnerium = new Material.Builder(GTCEu.id("meitnerium")) + Meitnerium = REGISTRATE.material("meitnerium") .color(0x4f3c82).secondaryColor(0x6e90ff).iconSet(RADIOACTIVE) .element(GTElements.Mt) .buildAndRegister(); - Mercury = new Material.Builder(GTCEu.id("mercury")) + Mercury = REGISTRATE.material("mercury") .fluid() .color(0xE6DCDC).iconSet(DULL) .element(GTElements.Hg) .hazard(HazardProperty.HazardTrigger.ANY, GTMedicalConditions.WEAK_POISON) .buildAndRegister(); - Molybdenum = new Material.Builder(GTCEu.id("molybdenum")) + Molybdenum = REGISTRATE.material("molybdenum") .ingot() .liquid(new FluidBuilder().temperature(2896)) .ore() @@ -500,12 +499,12 @@ public static void register() { .rotorStats(100, 115, 2.0f, 512) .buildAndRegister(); - Moscovium = new Material.Builder(GTCEu.id("moscovium")) + Moscovium = REGISTRATE.material("moscovium") .color(0x2a1b40).secondaryColor(0xbd91ff).iconSet(RADIOACTIVE) .element(GTElements.Mc) .buildAndRegister(); - Neodymium = new Material.Builder(GTCEu.id("neodymium")) + Neodymium = REGISTRATE.material("neodymium") .ingot().fluid().ore() .color(0x6c5863).secondaryColor(0x2c1919).iconSet(METALLIC) .appendFlags(STD_METAL, GENERATE_ROD, GENERATE_BOLT_SCREW) @@ -514,19 +513,19 @@ public static void register() { .blast(1297, GasTier.MID) .buildAndRegister(); - Neon = new Material.Builder(GTCEu.id("neon")) + Neon = REGISTRATE.material("neon") .gas() .color(0xFAB4B4) .element(GTElements.Ne) .buildAndRegister(); - Neptunium = new Material.Builder(GTCEu.id("neptunium")) + Neptunium = REGISTRATE.material("neptunium") .color(0x284D7B).iconSet(RADIOACTIVE) .element(GTElements.Np) // .radioactiveHazard(1) .buildAndRegister(); - Nickel = new Material.Builder(GTCEu.id("nickel")) + Nickel = REGISTRATE.material("nickel") .ingot() .liquid(new FluidBuilder().temperature(1728)) .plasma() @@ -538,12 +537,12 @@ public static void register() { .itemPipeProperties(2048, 1.0f) .buildAndRegister(); - Nihonium = new Material.Builder(GTCEu.id("nihonium")) + Nihonium = REGISTRATE.material("nihonium") .color(0x323957).secondaryColor(0xbfabff).iconSet(RADIOACTIVE) .element(GTElements.Nh) .buildAndRegister(); - Niobium = new Material.Builder(GTCEu.id("niobium")) + Niobium = REGISTRATE.material("niobium") .ingot().fluid() .color(0xb494b4).secondaryColor(0x4b3f4d).iconSet(BRIGHT) .element(GTElements.Nb) @@ -551,24 +550,24 @@ public static void register() { .blastStats(VA[HV], 900)) .buildAndRegister(); - Nitrogen = new Material.Builder(GTCEu.id("nitrogen")) + Nitrogen = REGISTRATE.material("nitrogen") .gas().plasma() .color(0x00BFC1) .element(GTElements.N) .buildAndRegister(); - Nobelium = new Material.Builder(GTCEu.id("nobelium")) + Nobelium = REGISTRATE.material("nobelium") .color(0x3e4758).secondaryColor(0x43deff) .iconSet(RADIOACTIVE) .element(GTElements.No) .buildAndRegister(); - Oganesson = new Material.Builder(GTCEu.id("oganesson")) + Oganesson = REGISTRATE.material("oganesson") .color(0x443936).secondaryColor(0xff1dbd).iconSet(RADIOACTIVE) .element(GTElements.Og) .buildAndRegister(); - Osmium = new Material.Builder(GTCEu.id("osmium")) + Osmium = REGISTRATE.material("osmium") .ingot(4) .liquid(new FluidBuilder().temperature(3306)) .color(0x54afff).secondaryColor(0x6e6eff).iconSet(METALLIC) @@ -582,7 +581,7 @@ public static void register() { .vacuumStats(VA[EV], 300)) .buildAndRegister(); - Oxygen = new Material.Builder(GTCEu.id("oxygen")) + Oxygen = REGISTRATE.material("oxygen") .gas() .liquid(new FluidBuilder() .temperature(85) @@ -595,7 +594,7 @@ public static void register() { .buildAndRegister(); Oxygen.getProperty(PropertyKey.FLUID).setPrimaryKey(FluidStorageKeys.GAS); - Palladium = new Material.Builder(GTCEu.id("palladium")) + Palladium = REGISTRATE.material("palladium") .ingot().fluid().ore() .color(0xbd92b5).secondaryColor(0x535b14).iconSet(SHINY) .appendFlags(EXT_METAL, GENERATE_FOIL, GENERATE_FINE_WIRE) @@ -605,20 +604,20 @@ public static void register() { .vacuumStats(VA[HV], 150)) .buildAndRegister(); - Phosphorus = new Material.Builder(GTCEu.id("phosphorus")) + Phosphorus = REGISTRATE.material("phosphorus") .dust() .color(0x77332c).secondaryColor(0x220202) .element(GTElements.P) .buildAndRegister(); - Polonium = new Material.Builder(GTCEu.id("polonium")) + Polonium = REGISTRATE.material("polonium") .color(0x163b27).secondaryColor(0x00ff78) .iconSet(RADIOACTIVE) .element(GTElements.Po) // .radioactiveHazard(1) .buildAndRegister(); - Platinum = new Material.Builder(GTCEu.id("platinum")) + Platinum = REGISTRATE.material("platinum") .ingot() .liquid(new FluidBuilder().temperature(2041)) .ore() @@ -630,7 +629,7 @@ public static void register() { .itemPipeProperties(512, 4.0f) .buildAndRegister(); - Plutonium239 = new Material.Builder(GTCEu.id("plutonium")) + Plutonium239 = REGISTRATE.material("plutonium") .ingot(3) .liquid(new FluidBuilder().temperature(913)) .ore(true) @@ -639,7 +638,7 @@ public static void register() { .radioactiveHazard(1.5f) .buildAndRegister(); - Plutonium241 = new Material.Builder(GTCEu.id("plutonium_241")) + Plutonium241 = REGISTRATE.material("plutonium_241") .ingot(3) .liquid(new FluidBuilder().temperature(913)) .color(0xff4c4c).secondaryColor(0x222730).iconSet(RADIOACTIVE) @@ -648,50 +647,50 @@ public static void register() { .radioactiveHazard(1.5f) .buildAndRegister(); - Potassium = new Material.Builder(GTCEu.id("potassium")) + Potassium = REGISTRATE.material("potassium") .dust(1) .liquid(new FluidBuilder().temperature(337)) .color(0xd2e1f2).secondaryColor(0x6189b8).iconSet(METALLIC) .element(GTElements.K) .buildAndRegister(); - Praseodymium = new Material.Builder(GTCEu.id("praseodymium")) + Praseodymium = REGISTRATE.material("praseodymium") .color(0x718060).secondaryColor(0x3f3447).iconSet(METALLIC) .element(GTElements.Pr) .buildAndRegister(); - Promethium = new Material.Builder(GTCEu.id("promethium")) + Promethium = REGISTRATE.material("promethium") .color(0x814947).secondaryColor(0xd0ff71) .iconSet(RADIOACTIVE) .element(GTElements.Pm) // .radioactiveHazard(1) .buildAndRegister(); - Protactinium = new Material.Builder(GTCEu.id("protactinium")) + Protactinium = REGISTRATE.material("protactinium") .color(0xA78B6D).iconSet(RADIOACTIVE) .element(GTElements.Pa) // .radioactiveHazard(1) .buildAndRegister(); - Radon = new Material.Builder(GTCEu.id("radon")) + Radon = REGISTRATE.material("radon") .gas() .color(0xFF39FF) .element(GTElements.Rn) .radioactiveHazard(1) .buildAndRegister(); - Radium = new Material.Builder(GTCEu.id("radium")) + Radium = REGISTRATE.material("radium") .color(0x838361).secondaryColor(0x89ff21).iconSet(RADIOACTIVE) .element(GTElements.Ra) // .radioactiveHazard(1) .buildAndRegister(); - Rhenium = new Material.Builder(GTCEu.id("rhenium")) + Rhenium = REGISTRATE.material("rhenium") .color(0xcbcfd7).secondaryColor(0x37393d).iconSet(SHINY) .element(GTElements.Re) .buildAndRegister(); - Rhodium = new Material.Builder(GTCEu.id("rhodium")) + Rhodium = REGISTRATE.material("rhodium") .ingot().fluid() .color(0xfd46b1).secondaryColor(0xDC0C58).iconSet(BRIGHT) .appendFlags(EXT2_METAL, GENERATE_GEAR, GENERATE_FINE_WIRE) @@ -701,17 +700,17 @@ public static void register() { .vacuumStats(VA[HV])) .buildAndRegister(); - Roentgenium = new Material.Builder(GTCEu.id("roentgenium")) + Roentgenium = REGISTRATE.material("roentgenium") .color(0x388c48).secondaryColor(0x198a92).iconSet(RADIOACTIVE) .element(GTElements.Rg) .buildAndRegister(); - Rubidium = new Material.Builder(GTCEu.id("rubidium")) + Rubidium = REGISTRATE.material("rubidium") .color(0xde0f0f).secondaryColor(0x3a1f1f).iconSet(SHINY) .element(GTElements.Rb) .buildAndRegister(); - Ruthenium = new Material.Builder(GTCEu.id("ruthenium")) + Ruthenium = REGISTRATE.material("ruthenium") .ingot().fluid() .color(0xa2cde0).secondaryColor(0x3c7285).iconSet(SHINY) .flags(GENERATE_FOIL, GENERATE_GEAR) @@ -721,12 +720,12 @@ public static void register() { .vacuumStats(VA[HV], 200)) .buildAndRegister(); - Rutherfordium = new Material.Builder(GTCEu.id("rutherfordium")) + Rutherfordium = REGISTRATE.material("rutherfordium") .color(0x6b6157).secondaryColor(0xFFF6A1).iconSet(RADIOACTIVE) .element(GTElements.Rf) .buildAndRegister(); - Samarium = new Material.Builder(GTCEu.id("samarium")) + Samarium = REGISTRATE.material("samarium") .ingot() .liquid(new FluidBuilder().temperature(1345)) .color(0xc2c289).secondaryColor(0x235254).iconSet(METALLIC) @@ -737,23 +736,23 @@ public static void register() { .vacuumStats(VA[HV], 200)) .buildAndRegister(); - Scandium = new Material.Builder(GTCEu.id("scandium")) + Scandium = REGISTRATE.material("scandium") .color(0xb1b2ac).secondaryColor(0x1c3433) .iconSet(METALLIC) .element(GTElements.Sc) .buildAndRegister(); - Seaborgium = new Material.Builder(GTCEu.id("seaborgium")) + Seaborgium = REGISTRATE.material("seaborgium") .color(0x19C5FF).secondaryColor(0xff19b2).iconSet(RADIOACTIVE) .element(GTElements.Sg) .buildAndRegister(); - Selenium = new Material.Builder(GTCEu.id("selenium")) + Selenium = REGISTRATE.material("selenium") .color(0xffdf77).secondaryColor(0x055d28).iconSet(SHINY) .element(GTElements.Se) .buildAndRegister(); - Silicon = new Material.Builder(GTCEu.id("silicon")) + Silicon = REGISTRATE.material("silicon") .ingot().fluid() .color(0x707078).secondaryColor(0x10293b).iconSet(METALLIC) .flags(GENERATE_FOIL) @@ -761,7 +760,7 @@ public static void register() { .blast(2273) // no gas tier for silicon .buildAndRegister(); - Silver = new Material.Builder(GTCEu.id("silver")) + Silver = REGISTRATE.material("silver") .ingot() .liquid(new FluidBuilder().temperature(1235)) .ore() @@ -771,25 +770,25 @@ public static void register() { .cableProperties(V[HV], 1, 1) .buildAndRegister(); - Sodium = new Material.Builder(GTCEu.id("sodium")) + Sodium = REGISTRATE.material("sodium") .dust() .color(0x7c80ff).secondaryColor(0x2b30a3).iconSet(METALLIC) .element(GTElements.Na) .buildAndRegister(); - Strontium = new Material.Builder(GTCEu.id("strontium")) + Strontium = REGISTRATE.material("strontium") .color(0x7a7953).secondaryColor(0x4c0b06).iconSet(METALLIC) .element(GTElements.Sr) .buildAndRegister(); - Sulfur = new Material.Builder(GTCEu.id("sulfur")) + Sulfur = REGISTRATE.material("sulfur") .dust().ore() .color(0xfdff31).secondaryColor(0xffb400) .flags(FLAMMABLE) .element(GTElements.S) .buildAndRegister(); - Tantalum = new Material.Builder(GTCEu.id("tantalum")) + Tantalum = REGISTRATE.material("tantalum") .ingot() .liquid(new FluidBuilder().temperature(3290)) .color(0xa8a7c6).secondaryColor(0x1f2b20).iconSet(METALLIC) @@ -797,30 +796,30 @@ public static void register() { .element(GTElements.Ta) .buildAndRegister(); - Technetium = new Material.Builder(GTCEu.id("technetium")) + Technetium = REGISTRATE.material("technetium") .color(0x7430e1).secondaryColor(0x7430e1).iconSet(RADIOACTIVE) .element(GTElements.Tc) // .radioactiveHazard(1) .buildAndRegister(); - Tellurium = new Material.Builder(GTCEu.id("tellurium")) + Tellurium = REGISTRATE.material("tellurium") .color(0x8fea66).secondaryColor(0x00bfff) .iconSet(RADIOACTIVE) .element(GTElements.Te) .buildAndRegister(); - Tennessine = new Material.Builder(GTCEu.id("tennessine")) + Tennessine = REGISTRATE.material("tennessine") .color(0x785cc4).secondaryColor(0x7959d4).iconSet(RADIOACTIVE) .element(GTElements.Ts) .buildAndRegister(); - Terbium = new Material.Builder(GTCEu.id("terbium")) + Terbium = REGISTRATE.material("terbium") .color(0xcedab4).secondaryColor(0x263640) .iconSet(METALLIC) .element(GTElements.Tb) .buildAndRegister(); - Thorium = new Material.Builder(GTCEu.id("thorium")) + Thorium = REGISTRATE.material("thorium") .ingot() .liquid(new FluidBuilder().temperature(2023)) .ore() @@ -829,19 +828,19 @@ public static void register() { .element(GTElements.Th) .buildAndRegister(); - Thallium = new Material.Builder(GTCEu.id("thallium")) + Thallium = REGISTRATE.material("thallium") .color(0x5d6b8e).secondaryColor(0x815b63).iconSet(SHINY) .element(GTElements.Tl) // .poison(PoisonProperty.PoisonType.CONTACT) .buildAndRegister(); - Thulium = new Material.Builder(GTCEu.id("thulium")) + Thulium = REGISTRATE.material("thulium") .color(0x467681).secondaryColor(0x682c2c) .iconSet(METALLIC) .element(GTElements.Tm) .buildAndRegister(); - Tin = new Material.Builder(GTCEu.id("tin")) + Tin = REGISTRATE.material("tin") .ingot(1) .liquid(new FluidBuilder().temperature(505)) .plasma() @@ -854,7 +853,7 @@ public static void register() { .itemPipeProperties(4096, 0.5f) .buildAndRegister(); - Titanium = new Material.Builder(GTCEu.id("titanium")) // todo Ore? Look at EBF recipe here if we do Ti ores + Titanium = REGISTRATE.material("titanium") // todo Ore? Look at EBF recipe here if we do Ti ores .ingot(3).fluid() .color(0xed8eea).secondaryColor(0xff64bc).iconSet(METALLIC) .appendFlags(EXT2_METAL, GENERATE_ROTOR, GENERATE_SMALL_GEAR, GENERATE_GEAR, GENERATE_FRAME) @@ -870,7 +869,7 @@ public static void register() { .vacuumStats(VA[HV])) .buildAndRegister(); - Tritium = new Material.Builder(GTCEu.id("tritium")) + Tritium = REGISTRATE.material("tritium") .gas(new FluidBuilder().state(FluidState.GAS).customStill()) .color(0xff316b).secondaryColor(0xd00000) .iconSet(METALLIC) @@ -878,7 +877,7 @@ public static void register() { .radioactiveHazard(1) .buildAndRegister(); - Tungsten = new Material.Builder(GTCEu.id("tungsten")) + Tungsten = REGISTRATE.material("tungsten") .ingot(3) .liquid(new FluidBuilder().temperature(3695)) .color(0x3b3a32).secondaryColor(0x2a2800).iconSet(METALLIC) @@ -893,7 +892,7 @@ public static void register() { .vacuumStats(VA[HV], 300)) .buildAndRegister(); - Uranium238 = new Material.Builder(GTCEu.id("uranium")) + Uranium238 = REGISTRATE.material("uranium") .ingot(3) .liquid(new FluidBuilder().temperature(1405)) .color(0x1d891d).secondaryColor(0x33342c).iconSet(RADIOACTIVE) @@ -902,7 +901,7 @@ public static void register() { .radioactiveHazard(1) .buildAndRegister(); - Uranium235 = new Material.Builder(GTCEu.id("uranium_235")) + Uranium235 = REGISTRATE.material("uranium_235") .ingot(3) .liquid(new FluidBuilder().temperature(1405)) .color(0x46FA46).secondaryColor(0x33342c).iconSet(RADIOACTIVE) @@ -911,32 +910,32 @@ public static void register() { .radioactiveHazard(1) .buildAndRegister(); - Vanadium = new Material.Builder(GTCEu.id("vanadium")) + Vanadium = REGISTRATE.material("vanadium") .ingot().fluid() .color(0x696d76).secondaryColor(0x240808).iconSet(METALLIC) .element(GTElements.V) .blast(2183, GasTier.MID) .buildAndRegister(); - Xenon = new Material.Builder(GTCEu.id("xenon")) + Xenon = REGISTRATE.material("xenon") .gas() .color(0x00FFFF) .element(GTElements.Xe) .buildAndRegister(); - Ytterbium = new Material.Builder(GTCEu.id("ytterbium")) + Ytterbium = REGISTRATE.material("ytterbium") .color(0xA7A7A7).iconSet(METALLIC) .element(GTElements.Yb) .buildAndRegister(); - Yttrium = new Material.Builder(GTCEu.id("yttrium")) + Yttrium = REGISTRATE.material("yttrium") .ingot().fluid() .color(0x7d8072).secondaryColor(0x15161a).iconSet(METALLIC) .element(GTElements.Y) .blast(1799) .buildAndRegister(); - Zinc = new Material.Builder(GTCEu.id("zinc")) + Zinc = REGISTRATE.material("zinc") .ingot(1) .liquid(new FluidBuilder().temperature(693)) .color(0xEBEBFA).secondaryColor(0x232c30).iconSet(METALLIC) @@ -944,12 +943,12 @@ public static void register() { .element(GTElements.Zn) .buildAndRegister(); - Zirconium = new Material.Builder(GTCEu.id("zirconium")) + Zirconium = REGISTRATE.material("zirconium") .color(0xb99b7e).secondaryColor(0x271813).iconSet(METALLIC) .element(GTElements.Zr) .buildAndRegister(); - Naquadah = new Material.Builder(GTCEu.id("naquadah")) + Naquadah = REGISTRATE.material("naquadah") .ingot(4) .liquid(new FluidBuilder().customStill()) .ore() @@ -964,7 +963,7 @@ public static void register() { .vacuumStats(VA[EV], 150)) .buildAndRegister(); - NaquadahEnriched = new Material.Builder(GTCEu.id("enriched_naquadah")) + NaquadahEnriched = REGISTRATE.material("enriched_naquadah") .ingot(4) .liquid(new FluidBuilder().customStill()) .color(0x3C3C3C, false).secondaryColor(0x122f06).iconSet(METALLIC) @@ -975,7 +974,7 @@ public static void register() { .vacuumStats(VA[EV], 150)) .buildAndRegister(); - Naquadria = new Material.Builder(GTCEu.id("naquadria")) + Naquadria = REGISTRATE.material("naquadria") .ingot(3) .liquid(new FluidBuilder().customStill()) .color(0x1E1E1E, false).secondaryColor(0x59b3ff).iconSet(RADIOACTIVE) @@ -987,7 +986,7 @@ public static void register() { .radioactiveHazard(3) .buildAndRegister(); - Neutronium = new Material.Builder(GTCEu.id("neutronium")) + Neutronium = REGISTRATE.material("neutronium") .ingot(6) .liquid(new FluidBuilder().temperature(100_000)) .color(0xFFFFFF).secondaryColor(0x000000) @@ -1000,7 +999,7 @@ public static void register() { .radioactiveHazard(10) .buildAndRegister(); - Tritanium = new Material.Builder(GTCEu.id("tritanium")) + Tritanium = REGISTRATE.material("tritanium") .ingot(6) .liquid(new FluidBuilder().temperature(25_000)) .color(0xc35769).secondaryColor(0x210840).iconSet(METALLIC) @@ -1011,7 +1010,7 @@ public static void register() { .rotorStats(220, 220, 6.0f, 10240) .buildAndRegister(); - Duranium = new Material.Builder(GTCEu.id("duranium")) + Duranium = REGISTRATE.material("duranium") .ingot(5) .liquid(new FluidBuilder().temperature(7500)) .color(0xf3e7a9).secondaryColor(0x9c9487).iconSet(BRIGHT) @@ -1022,7 +1021,7 @@ public static void register() { .fluidPipeProperties(9625, 500, true, true, true, true) .buildAndRegister(); - Trinium = new Material.Builder(GTCEu.id("trinium")) + Trinium = REGISTRATE.material("trinium") .ingot(7).fluid() .color(0x81808a).secondaryColor(0x351d4b).iconSet(SHINY) .flags(GENERATE_FOIL, GENERATE_BOLT_SCREW, GENERATE_GEAR, GENERATE_SPRING) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/materials/FirstDegreeMaterials.java b/src/main/java/com/gregtechceu/gtceu/common/data/materials/FirstDegreeMaterials.java index 9869897279d..1d819261d26 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/materials/FirstDegreeMaterials.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/materials/FirstDegreeMaterials.java @@ -1,7 +1,5 @@ package com.gregtechceu.gtceu.common.data.materials; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.ArmorProperty; import com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty.GasTier; import com.gregtechceu.gtceu.api.data.chemical.material.properties.HazardProperty; @@ -19,23 +17,24 @@ import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags.*; import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet.*; import static com.gregtechceu.gtceu.common.data.GTMaterials.*; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; public class FirstDegreeMaterials { public static void register() { - Almandine = new Material.Builder(GTCEu.id("almandine")) + Almandine = REGISTRATE.material("almandine") .gem(1).ore(3, 1) .color(0xa21717).secondaryColor(0x4b1e0c) .components(Aluminium, 2, Iron, 3, Silicon, 3, Oxygen, 12) .buildAndRegister(); - Andradite = new Material.Builder(GTCEu.id("andradite")) + Andradite = REGISTRATE.material("andradite") .gem(1) .color(0xffce26).secondaryColor(0x647d59).iconSet(RUBY) .components(Calcium, 3, Iron, 2, Silicon, 3, Oxygen, 12) .buildAndRegister(); - AnnealedCopper = new Material.Builder(GTCEu.id("annealed_copper")) + AnnealedCopper = REGISTRATE.material("annealed_copper") .ingot() .liquid(new FluidBuilder().temperature(1358)) .color(0xf2c079).secondaryColor(0xe45534).iconSet(BRIGHT) @@ -45,27 +44,27 @@ public static void register() { .buildAndRegister(); Copper.getProperty(PropertyKey.INGOT).setArcSmeltingInto(AnnealedCopper); - Asbestos = new Material.Builder(GTCEu.id("asbestos")) + Asbestos = REGISTRATE.material("asbestos") .dust(1).ore(3, 1) .color(0xE6E6E6).secondaryColor(0xdbd7bf) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.ASBESTOSIS) .components(Magnesium, 3, Silicon, 2, Hydrogen, 4, Oxygen, 9) .buildAndRegister(); - Ash = new Material.Builder(GTCEu.id("ash")) + Ash = REGISTRATE.material("ash") .dust(1) .color(0xd1d1d1).secondaryColor(0x8b8989) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 1) .buildAndRegister(); - Hematite = new Material.Builder(GTCEu.id("hematite")) + Hematite = REGISTRATE.material("hematite") .dust().ore() .color(0xff7161).secondaryColor(0x330817) .components(Iron, 2, Oxygen, 3) .buildAndRegister(); - BatteryAlloy = new Material.Builder(GTCEu.id("battery_alloy")) + BatteryAlloy = REGISTRATE.material("battery_alloy") .ingot(1) .liquid(new FluidBuilder().temperature(660)) .color(0xcac0ff).secondaryColor(0x5b0020) @@ -73,21 +72,21 @@ public static void register() { .components(Lead, 4, Antimony, 1) .buildAndRegister(); - BlueTopaz = new Material.Builder(GTCEu.id("blue_topaz")) + BlueTopaz = REGISTRATE.material("blue_topaz") .gem(3).ore(2, 1) .color(0xdbfeff).secondaryColor(0xa0c4d7).iconSet(GEM_HORIZONTAL) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT) .components(Aluminium, 2, Silicon, 1, Oxygen, 4, Fluorine, 2) .buildAndRegister(); - Bone = new Material.Builder(GTCEu.id("bone")) + Bone = REGISTRATE.material("bone") .dust(1) .color(0xfcfbed).secondaryColor(0xa0a38b) .flags(MORTAR_GRINDABLE, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES, DISABLE_DECOMPOSITION) .components(Calcium, 3) .buildAndRegister(); - Brass = new Material.Builder(GTCEu.id("brass")) + Brass = REGISTRATE.material("brass") .ingot(1) .liquid(new FluidBuilder().temperature(1160)) .color(0xffe36e).secondaryColor(0x935828).iconSet(SHINY) @@ -97,7 +96,7 @@ public static void register() { .itemPipeProperties(2048, 1) .buildAndRegister(); - Bronze = new Material.Builder(GTCEu.id("bronze")) + Bronze = REGISTRATE.material("bronze") .ingot() .liquid(new FluidBuilder().temperature(1357)) .color(0xffc370).secondaryColor(0x806752).iconSet(METALLIC) @@ -112,65 +111,65 @@ public static void register() { .fluidPipeProperties(1696, 20, true) .buildAndRegister(); - Goethite = new Material.Builder(GTCEu.id("goethite")) + Goethite = REGISTRATE.material("goethite") .dust(1).ore() .color(0x97873a).secondaryColor(0x313131).iconSet(METALLIC) .flags(DECOMPOSITION_BY_CENTRIFUGING, BLAST_FURNACE_CALCITE_TRIPLE) .components(Iron, 1, Hydrogen, 1, Oxygen, 2) .buildAndRegister(); - Calcite = new Material.Builder(GTCEu.id("calcite")) + Calcite = REGISTRATE.material("calcite") .dust(1).ore() .color(0xfffef8).secondaryColor(0xbbaf62) .components(Calcium, 1, Carbon, 1, Oxygen, 3) .buildAndRegister(); - Cassiterite = new Material.Builder(GTCEu.id("cassiterite")) + Cassiterite = REGISTRATE.material("cassiterite") .dust(1).ore(2, 1) .color(0x89847e).secondaryColor(0x3b3b35).iconSet(ROUGH) .components(Tin, 1, Oxygen, 2) .buildAndRegister(); - CassiteriteSand = new Material.Builder(GTCEu.id("cassiterite_sand")) + CassiteriteSand = REGISTRATE.material("cassiterite_sand") .dust(1).ore(2, 1) .color(0x89847e).secondaryColor(0x3b3b35).iconSet(SAND) .components(Tin, 1, Oxygen, 2) .buildAndRegister(); - Chalcopyrite = new Material.Builder(GTCEu.id("chalcopyrite")) + Chalcopyrite = REGISTRATE.material("chalcopyrite") .dust(1).ore() .color(0x96c185).secondaryColor(0xe3af1a) .components(Copper, 1, Iron, 1, Sulfur, 2) .buildAndRegister(); - Charcoal = new Material.Builder(GTCEu.id("charcoal")) + Charcoal = REGISTRATE.material("charcoal") .gem(1, 1600) // default charcoal burn time in vanilla .color(0x7d6f58).secondaryColor(0x13110d).iconSet(FINE) .flags(FLAMMABLE, NO_SMELTING, NO_SMASHING, MORTAR_GRINDABLE) .components(Carbon, 1) .buildAndRegister(); - Chromite = new Material.Builder(GTCEu.id("chromite")) + Chromite = REGISTRATE.material("chromite") .dust(1).ore() .color(0xc5c1a8).secondaryColor(0x4c1a69).iconSet(METALLIC) .components(Iron, 1, Chromium, 2, Oxygen, 4) .buildAndRegister(); - Cinnabar = new Material.Builder(GTCEu.id("cinnabar")) + Cinnabar = REGISTRATE.material("cinnabar") .gem(1).ore() .color(0xff335f).secondaryColor(0x3f0110).iconSet(EMERALD) .flags(CRYSTALLIZABLE, DECOMPOSITION_BY_CENTRIFUGING) .components(Mercury, 1, Sulfur, 1) .buildAndRegister(); - Water = new Material.Builder(GTCEu.id("water")) + Water = REGISTRATE.material("water") .liquid(new FluidBuilder().temperature(300)) .color(0x0000FF) .flags(DISABLE_DECOMPOSITION) .components(Hydrogen, 2, Oxygen, 1) .buildAndRegister(); - Coal = new Material.Builder(GTCEu.id("coal")) + Coal = REGISTRATE.material("coal") .gem(1, 1600).ore(2, 1) // default coal burn time in vanilla .color(0x393e41).secondaryColor(0x101015).iconSet(LIGNITE) .flags(FLAMMABLE, NO_SMELTING, NO_SMASHING, MORTAR_GRINDABLE, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES, @@ -178,20 +177,20 @@ public static void register() { .components(Carbon, 1) .buildAndRegister(); - Cobaltite = new Material.Builder(GTCEu.id("cobaltite")) + Cobaltite = REGISTRATE.material("cobaltite") .dust(1).ore() .color(0x1975ff).secondaryColor(0x56071f).iconSet(METALLIC) .components(Cobalt, 1, Arsenic, 1, Sulfur, 1) .buildAndRegister(); - Cooperite = new Material.Builder(GTCEu.id("cooperite")) + Cooperite = REGISTRATE.material("cooperite") .langValue("Sheldonite") // greg's humor is now on 1.20... .dust(1).ore() .color(0xe9ffa7).secondaryColor(0x665f2f).iconSet(METALLIC) .components(Platinum, 3, Nickel, 1, Sulfur, 1, Palladium, 1) .buildAndRegister(); - Cupronickel = new Material.Builder(GTCEu.id("cupronickel")) + Cupronickel = REGISTRATE.material("cupronickel") .ingot(1) .liquid(new FluidBuilder().temperature(1542)) .color(0xffda8a).secondaryColor(0xcd2b00).iconSet(METALLIC) @@ -201,14 +200,14 @@ public static void register() { .cableProperties(V[MV], 1, 1) .buildAndRegister(); - DarkAsh = new Material.Builder(GTCEu.id("dark_ash")) + DarkAsh = REGISTRATE.material("dark_ash") .dust(1) .color(0x8b8989).secondaryColor(0x555353) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 1) .buildAndRegister(); - Diamond = new Material.Builder(GTCEu.id("diamond")) + Diamond = REGISTRATE.material("diamond") .gem(3).ore() .color(0xC8FFFF).iconSet(DIAMOND) .flags(GENERATE_BOLT_SCREW, GENERATE_LENS, GENERATE_GEAR, NO_SMASHING, NO_SMELTING, @@ -219,7 +218,7 @@ public static void register() { .attackSpeed(0.1F).enchantability(18).build()) .buildAndRegister(); - Electrum = new Material.Builder(GTCEu.id("electrum")) + Electrum = REGISTRATE.material("electrum") .ingot() .liquid(new FluidBuilder().temperature(1285)) .color(0xffff8b).secondaryColor(0xff8533).iconSet(SHINY) @@ -229,7 +228,7 @@ public static void register() { .cableProperties(V[HV], 2, 2) .buildAndRegister(); - Emerald = new Material.Builder(GTCEu.id("emerald")) + Emerald = REGISTRATE.material("emerald") .gem().ore(2, 1) .color(0x17ff6c).secondaryColor(0x003f00).iconSet(EMERALD) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, @@ -237,33 +236,33 @@ public static void register() { .components(Beryllium, 3, Aluminium, 2, Silicon, 6, Oxygen, 18) .buildAndRegister(); - Galena = new Material.Builder(GTCEu.id("galena")) + Galena = REGISTRATE.material("galena") .dust(3).ore() .color(0xf3e8fa).secondaryColor(0x331d42).iconSet(METALLIC) .flags(NO_SMELTING) .components(Lead, 1, Sulfur, 1) .buildAndRegister(); - Garnierite = new Material.Builder(GTCEu.id("garnierite")) + Garnierite = REGISTRATE.material("garnierite") .dust(3).ore() .color(0x32c880).secondaryColor(0x344028).iconSet(METALLIC) .components(Nickel, 1, Oxygen, 1) .buildAndRegister(); - GreenSapphire = new Material.Builder(GTCEu.id("green_sapphire")) + GreenSapphire = REGISTRATE.material("green_sapphire") .gem().ore() .color(0x9ae6b0).secondaryColor(0x64C882).iconSet(GEM_HORIZONTAL) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT) .components(Aluminium, 2, Oxygen, 3) .buildAndRegister(); - Grossular = new Material.Builder(GTCEu.id("grossular")) + Grossular = REGISTRATE.material("grossular") .gem(1).ore(3, 1) .color(0xffb777).secondaryColor(0x856f48).iconSet(RUBY) .components(Calcium, 3, Aluminium, 2, Silicon, 3, Oxygen, 12) .buildAndRegister(); - Ice = new Material.Builder(GTCEu.id("ice")) + Ice = REGISTRATE.material("ice") .dust(0) .liquid(new FluidBuilder() .temperature(273) @@ -273,28 +272,28 @@ public static void register() { .components(Hydrogen, 2, Oxygen, 1) .buildAndRegister(); - Ilmenite = new Material.Builder(GTCEu.id("ilmenite")) + Ilmenite = REGISTRATE.material("ilmenite") .dust(3).ore() .color(0x2b2a24).secondaryColor(0x2b1700).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) .components(Iron, 1, Titanium, 1, Oxygen, 3) .buildAndRegister(); - Rutile = new Material.Builder(GTCEu.id("rutile")) + Rutile = REGISTRATE.material("rutile") .gem() .color(0x892506).secondaryColor(0x330101).iconSet(GEM_HORIZONTAL) .flags(DISABLE_DECOMPOSITION) .components(Titanium, 1, Oxygen, 2) .buildAndRegister(); - Bauxite = new Material.Builder(GTCEu.id("bauxite")) + Bauxite = REGISTRATE.material("bauxite") .dust(1).ore() .color(0xcfb853).secondaryColor(0xe6220c) .flags(DISABLE_DECOMPOSITION) .components(Aluminium, 2, Oxygen, 3) .buildAndRegister(); - Invar = new Material.Builder(GTCEu.id("invar")) + Invar = REGISTRATE.material("invar") .ingot() .liquid(new FluidBuilder().temperature(1916)) .color(0xe2e8e1).secondaryColor(0x495d57).iconSet(METALLIC) @@ -308,7 +307,7 @@ public static void register() { .rotorStats(130, 115, 3.0f, 512) .buildAndRegister(); - Kanthal = new Material.Builder(GTCEu.id("kanthal")) + Kanthal = REGISTRATE.material("kanthal") .ingot() .liquid(new FluidBuilder().temperature(1708)) .color(0xC2D2DF).secondaryColor(0x4c4238).iconSet(METALLIC) @@ -319,7 +318,7 @@ public static void register() { .blastStats(VA[HV], 900)) .buildAndRegister(); - Lazurite = new Material.Builder(GTCEu.id("lazurite")) + Lazurite = REGISTRATE.material("lazurite") .gem(1).ore(6, 4) .color(0x2836f1).secondaryColor(0x183ca3).iconSet(LAPIS) .flags(GENERATE_PLATE, NO_SMASHING, NO_SMELTING, CRYSTALLIZABLE, GENERATE_ROD, @@ -327,7 +326,7 @@ public static void register() { .components(Aluminium, 6, Silicon, 6, Calcium, 8, Sodium, 8) .buildAndRegister(); - Magnalium = new Material.Builder(GTCEu.id("magnalium")) + Magnalium = REGISTRATE.material("magnalium") .ingot() .liquid(new FluidBuilder().temperature(929)) .color(0x98b9e9).secondaryColor(0x2f0b51).iconSet(METALLIC) @@ -337,25 +336,25 @@ public static void register() { .itemPipeProperties(1024, 2) .buildAndRegister(); - Magnesite = new Material.Builder(GTCEu.id("magnesite")) + Magnesite = REGISTRATE.material("magnesite") .dust().ore() .color(0xfbfbf6).secondaryColor(0x80705e).iconSet(ROUGH) .components(Magnesium, 1, Carbon, 1, Oxygen, 3) .buildAndRegister(); - Magnetite = new Material.Builder(GTCEu.id("magnetite")) + Magnetite = REGISTRATE.material("magnetite") .dust().ore() .color(0x9d9d9d).secondaryColor(0x06070e).iconSet(METALLIC) .components(Iron, 3, Oxygen, 4) .buildAndRegister(); - Molybdenite = new Material.Builder(GTCEu.id("molybdenite")) + Molybdenite = REGISTRATE.material("molybdenite") .dust().ore() .color(0xe3ddc3).secondaryColor(0x191919).iconSet(METALLIC) .components(Molybdenum, 1, Sulfur, 2) .buildAndRegister(); - Nichrome = new Material.Builder(GTCEu.id("nichrome")) + Nichrome = REGISTRATE.material("nichrome") .ingot() .liquid(new FluidBuilder().temperature(1818)) .color(0xaf94b2).secondaryColor(0x5b4c6a).iconSet(METALLIC) @@ -367,7 +366,7 @@ public static void register() { .vacuumStats(VA[HV])) .buildAndRegister(); - NiobiumNitride = new Material.Builder(GTCEu.id("niobium_nitride")) + NiobiumNitride = REGISTRATE.material("niobium_nitride") .ingot().fluid() .color(0x574457).secondaryColor(0x332e3c).iconSet(BRIGHT) .appendFlags(EXT_METAL, GENERATE_FOIL) @@ -376,7 +375,7 @@ public static void register() { .blast(2846, GasTier.MID) .buildAndRegister(); - NiobiumTitanium = new Material.Builder(GTCEu.id("niobium_titanium")) + NiobiumTitanium = REGISTRATE.material("niobium_titanium") .ingot() .liquid(new FluidBuilder().temperature(2345)) .color(0xd2d9f9).secondaryColor(0x262528).iconSet(METALLIC) @@ -389,28 +388,28 @@ public static void register() { .vacuumStats(VA[HV], 200)) .buildAndRegister(); - Obsidian = new Material.Builder(GTCEu.id("obsidian")) + Obsidian = REGISTRATE.material("obsidian") .dust(3) .color(0x3b2754).secondaryColor(0x000001).iconSet(SHINY) .flags(NO_SMASHING, EXCLUDE_BLOCK_CRAFTING_RECIPES, GENERATE_PLATE, GENERATE_DENSE) .components(Magnesium, 1, Iron, 1, Silicon, 2, Oxygen, 4) .buildAndRegister(); - Phosphate = new Material.Builder(GTCEu.id("phosphate")) + Phosphate = REGISTRATE.material("phosphate") .dust(1) .color(0xe8dabd).secondaryColor(0xa48b56) .flags(NO_SMASHING, NO_SMELTING, FLAMMABLE, EXPLOSIVE) .components(Phosphorus, 1, Oxygen, 4) .buildAndRegister(); - PlatinumRaw = new Material.Builder(GTCEu.id("platinum_raw")) + PlatinumRaw = REGISTRATE.material("platinum_raw") .dust() .color(0xa09a7b).secondaryColor(0x4e4e45).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) .components(Platinum, 1, Chlorine, 2) .buildAndRegister(); - SterlingSilver = new Material.Builder(GTCEu.id("sterling_silver")) + SterlingSilver = REGISTRATE.material("sterling_silver") .ingot() .liquid(new FluidBuilder().temperature(1258)) .color(0xfaf4dc).secondaryColor(0x484434).iconSet(SHINY) @@ -425,7 +424,7 @@ public static void register() { .blastStats(VA[MV], 1000)) .buildAndRegister(); - RoseGold = new Material.Builder(GTCEu.id("rose_gold")) + RoseGold = REGISTRATE.material("rose_gold") .ingot() .liquid(new FluidBuilder().temperature(1341)) .color(0xecd5b8).secondaryColor(0xd85f2d).iconSet(SHINY) @@ -440,7 +439,7 @@ public static void register() { .blastStats(VA[MV], 1000)) .buildAndRegister(); - BlackBronze = new Material.Builder(GTCEu.id("black_bronze")) + BlackBronze = REGISTRATE.material("black_bronze") .ingot() .liquid(new FluidBuilder().temperature(1328)) .color(0x8b7c70).secondaryColor(0x4b3d32).iconSet(METALLIC) @@ -452,7 +451,7 @@ public static void register() { .blastStats(VA[MV], 1000)) .buildAndRegister(); - BismuthBronze = new Material.Builder(GTCEu.id("bismuth_bronze")) + BismuthBronze = REGISTRATE.material("bismuth_bronze") .ingot() .liquid(new FluidBuilder().temperature(1036)) .color(0xffd26f).secondaryColor(0x895f3d).iconSet(METALLIC) @@ -463,45 +462,45 @@ public static void register() { .blastStats(VA[MV], 1000)) .buildAndRegister(); - Biotite = new Material.Builder(GTCEu.id("biotite")) + Biotite = REGISTRATE.material("biotite") .dust(1) .color(0x343b34).secondaryColor(0x121200).iconSet(METALLIC) .components(Potassium, 1, Magnesium, 3, Aluminium, 3, Fluorine, 2, Silicon, 3, Oxygen, 10) .buildAndRegister(); - Powellite = new Material.Builder(GTCEu.id("powellite")) + Powellite = REGISTRATE.material("powellite") .dust().ore() .color(0xd8cfac).secondaryColor(0xbc7a2c) .components(Calcium, 1, Molybdenum, 1, Oxygen, 4) .buildAndRegister(); - Pyrite = new Material.Builder(GTCEu.id("pyrite")) + Pyrite = REGISTRATE.material("pyrite") .dust(1).ore() .color(0xfffee6).secondaryColor(0xb69f4e).iconSet(ROUGH) .flags(BLAST_FURNACE_CALCITE_DOUBLE) .components(Iron, 1, Sulfur, 2) .buildAndRegister(); - Pyrolusite = new Material.Builder(GTCEu.id("pyrolusite")) + Pyrolusite = REGISTRATE.material("pyrolusite") .dust().ore() .color(0xc7b5ab).secondaryColor(0x595756) .components(Manganese, 1, Oxygen, 2) .buildAndRegister(); - Pyrope = new Material.Builder(GTCEu.id("pyrope")) + Pyrope = REGISTRATE.material("pyrope") .gem().ore(3, 1) .color(0xe81958).secondaryColor(0x811e00).iconSet(RUBY) .components(Aluminium, 2, Magnesium, 3, Silicon, 3, Oxygen, 12) .buildAndRegister(); - RockSalt = new Material.Builder(GTCEu.id("rock_salt")) + RockSalt = REGISTRATE.material("rock_salt") .gem(1).ore(2, 1) .color(0xffeae1).secondaryColor(0xF0C8C8).iconSet(FINE) .flags(NO_SMASHING) .components(Potassium, 1, Chlorine, 1) .buildAndRegister(); - RTMAlloy = new Material.Builder(GTCEu.id("rtm_alloy")) + RTMAlloy = REGISTRATE.material("rtm_alloy") .langValue("RTM Alloy") .ingot().fluid() .color(0x30306B).iconSet(SHINY) @@ -513,7 +512,7 @@ public static void register() { .vacuumStats(VA[HV], 250)) .buildAndRegister(); - Ruridit = new Material.Builder(GTCEu.id("ruridit")) + Ruridit = REGISTRATE.material("ruridit") .ingot(3) .fluid() .color(0x88b5b9).secondaryColor(0x4e885c).iconSet(BRIGHT) @@ -524,35 +523,35 @@ public static void register() { .vacuumStats(VA[HV], 300)) .buildAndRegister(); - Ruby = new Material.Builder(GTCEu.id("ruby")) + Ruby = REGISTRATE.material("ruby") .gem().ore() .color(0xd72310).secondaryColor(0x960b6d).iconSet(RUBY) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, GENERATE_LENS) .components(Chromium, 1, Aluminium, 2, Oxygen, 3) .buildAndRegister(); - Salt = new Material.Builder(GTCEu.id("salt")) + Salt = REGISTRATE.material("salt") .gem(1).ore(2, 1) .color(0xFAFAFA).iconSet(FINE) .flags(NO_SMASHING) .components(Sodium, 1, Chlorine, 1) .buildAndRegister(); - Saltpeter = new Material.Builder(GTCEu.id("saltpeter")) + Saltpeter = REGISTRATE.material("saltpeter") .dust(1).ore(2, 1) .color(0xE6E6E6).secondaryColor(0xe6e1cf).iconSet(FINE) .flags(NO_SMASHING, NO_SMELTING, FLAMMABLE) .components(Potassium, 1, Nitrogen, 1, Oxygen, 3) .buildAndRegister(); - Sapphire = new Material.Builder(GTCEu.id("sapphire")) + Sapphire = REGISTRATE.material("sapphire") .gem().ore() .color(0x3235e3).secondaryColor(0x211455).iconSet(EMERALD) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, GENERATE_LENS) .components(Aluminium, 2, Oxygen, 3) .buildAndRegister(); - Scheelite = new Material.Builder(GTCEu.id("scheelite")) + Scheelite = REGISTRATE.material("scheelite") .dust(3).ore() .color(0xd7e8b3).secondaryColor(0x143cae) .flags(DISABLE_DECOMPOSITION) @@ -560,7 +559,7 @@ public static void register() { .buildAndRegister() .setFormula("Ca(WO3)O", true); - Sodalite = new Material.Builder(GTCEu.id("sodalite")) + Sodalite = REGISTRATE.material("sodalite") .gem(1).ore(6, 4) .color(0x3d54ff).secondaryColor(0x210d78).iconSet(LAPIS) .flags(GENERATE_PLATE, GENERATE_ROD, NO_SMASHING, NO_SMELTING, CRYSTALLIZABLE, @@ -568,46 +567,46 @@ public static void register() { .components(Aluminium, 3, Silicon, 3, Sodium, 4, Chlorine, 1) .buildAndRegister(); - AluminiumSulfite = new Material.Builder(GTCEu.id("aluminium_sulfite")) + AluminiumSulfite = REGISTRATE.material("aluminium_sulfite") .dust() .color(0xd4ecf9).secondaryColor(0xa6b9b6) .components(Aluminium, 2, Sulfur, 3, Oxygen, 9) .buildAndRegister().setFormula("Al2(SO3)3", true); - Tantalite = new Material.Builder(GTCEu.id("tantalite")) + Tantalite = REGISTRATE.material("tantalite") .dust(3).ore() .color(0x4e6b94).secondaryColor(0x632300).iconSet(METALLIC) .components(Manganese, 1, Tantalum, 2, Oxygen, 6) .buildAndRegister(); - Coke = new Material.Builder(GTCEu.id("coke")) + Coke = REGISTRATE.material("coke") .gem(2, 3200) // 2x burn time of coal .color(0x575e5b).secondaryColor(0x1f1f29).iconSet(LIGNITE) .flags(FLAMMABLE, NO_SMELTING, NO_SMASHING, MORTAR_GRINDABLE) .components(Carbon, 1) .buildAndRegister(); - SolderingAlloy = new Material.Builder(GTCEu.id("soldering_alloy")) + SolderingAlloy = REGISTRATE.material("soldering_alloy") .ingot(1) .liquid(new FluidBuilder().temperature(544)) .color(0x8c8ca7).secondaryColor(0x8675a7) .components(Tin, 6, Lead, 3, Antimony, 1) .buildAndRegister(); - Spessartine = new Material.Builder(GTCEu.id("spessartine")) + Spessartine = REGISTRATE.material("spessartine") .gem().ore(3, 1) .color(0xffa81e).secondaryColor(0xb33700).iconSet(RUBY) .components(Aluminium, 2, Manganese, 3, Silicon, 3, Oxygen, 12) .buildAndRegister(); - Sphalerite = new Material.Builder(GTCEu.id("sphalerite")) + Sphalerite = REGISTRATE.material("sphalerite") .dust(1).ore() .color(0xffdc88).secondaryColor(0x0f1605) .flags(DISABLE_DECOMPOSITION) .components(Zinc, 1, Sulfur, 1) .buildAndRegister(); - StainlessSteel = new Material.Builder(GTCEu.id("stainless_steel")) + StainlessSteel = REGISTRATE.material("stainless_steel") .ingot(3) .liquid(new FluidBuilder().temperature(2011)) .color(0xededfd).secondaryColor(0x19191d).iconSet(SHINY) @@ -622,7 +621,7 @@ public static void register() { .blastStats(VA[HV], 1100)) .buildAndRegister(); - Steel = new Material.Builder(GTCEu.id("steel")) + Steel = REGISTRATE.material("steel") .ingot(3) .liquid(new FluidBuilder().temperature(2046)) .color(0xa7a7a7).secondaryColor(0x121c37).iconSet(METALLIC) @@ -642,20 +641,20 @@ public static void register() { .blastStats(VA[MV], 800)) // no gas tier for steel .buildAndRegister(); - Stibnite = new Material.Builder(GTCEu.id("stibnite")) + Stibnite = REGISTRATE.material("stibnite") .dust().ore() .color(0x656565).secondaryColor(0x0a1432).iconSet(METALLIC) .flags(DECOMPOSITION_BY_CENTRIFUGING) .components(Antimony, 2, Sulfur, 3) .buildAndRegister(); - Tetrahedrite = new Material.Builder(GTCEu.id("tetrahedrite")) + Tetrahedrite = REGISTRATE.material("tetrahedrite") .dust().ore() .color(0xa3a09b).secondaryColor(0x143313) .components(Copper, 2, Iron, 1, Antimony, 1, Sulfur, 3) .buildAndRegister(); - TinAlloy = new Material.Builder(GTCEu.id("tin_alloy")) + TinAlloy = REGISTRATE.material("tin_alloy") .ingot() .liquid(new FluidBuilder().temperature(1258)) .color(0xC8C8C8).secondaryColor(0x8b8b8b).iconSet(METALLIC) @@ -664,14 +663,14 @@ public static void register() { .fluidPipeProperties(1572, 20, true) .buildAndRegister(); - Topaz = new Material.Builder(GTCEu.id("topaz")) + Topaz = REGISTRATE.material("topaz") .gem(3).ore() .color(0xe8d73a).secondaryColor(0xf4680f).iconSet(GEM_HORIZONTAL) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT) .components(Aluminium, 2, Silicon, 1, Oxygen, 5, Fluorine, 1, Hydrogen, 1) .buildAndRegister(); - Tungstate = new Material.Builder(GTCEu.id("tungstate")) + Tungstate = REGISTRATE.material("tungstate") .dust(3).ore() .color(0xe0ffc4).secondaryColor(0xab4400) .flags(DISABLE_DECOMPOSITION) @@ -679,7 +678,7 @@ public static void register() { .buildAndRegister() .setFormula("Li2(WO3)O", true); - Ultimet = new Material.Builder(GTCEu.id("ultimet")) + Ultimet = REGISTRATE.material("ultimet") .ingot(4) .liquid(new FluidBuilder().temperature(1980)) .color(0x9f9fb1).secondaryColor(0x385086).iconSet(SHINY) @@ -693,7 +692,7 @@ public static void register() { .blastStats(VA[HV], 1300)) .buildAndRegister(); - Uraninite = new Material.Builder(GTCEu.id("uraninite")) + Uraninite = REGISTRATE.material("uraninite") .dust(3).ore(true) .color(0xffd52e).secondaryColor(0x17212b).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) @@ -701,13 +700,13 @@ public static void register() { .buildAndRegister() .setFormula("UO2", true); - Uvarovite = new Material.Builder(GTCEu.id("uvarovite")) + Uvarovite = REGISTRATE.material("uvarovite") .gem() .color(0x2ded4c).secondaryColor(0x00697c).iconSet(RUBY) .components(Calcium, 3, Chromium, 2, Silicon, 3, Oxygen, 12) .buildAndRegister(); - VanadiumGallium = new Material.Builder(GTCEu.id("vanadium_gallium")) + VanadiumGallium = REGISTRATE.material("vanadium_gallium") .ingot() .liquid(new FluidBuilder().temperature(1712)) .color(0x89aeec).secondaryColor(0x00379d).iconSet(SHINY) @@ -719,7 +718,7 @@ public static void register() { .vacuumStats(VA[HV])) .buildAndRegister(); - WroughtIron = new Material.Builder(GTCEu.id("wrought_iron")) + WroughtIron = REGISTRATE.material("wrought_iron") .ingot() .liquid(new FluidBuilder().temperature(2011)) .color(0xbcbcbc).secondaryColor(0x521c0b).iconSet(METALLIC) @@ -734,13 +733,13 @@ public static void register() { Iron.getProperty(PropertyKey.INGOT).setSmeltingInto(WroughtIron); Iron.getProperty(PropertyKey.INGOT).setArcSmeltingInto(WroughtIron); - Wulfenite = new Material.Builder(GTCEu.id("wulfenite")) + Wulfenite = REGISTRATE.material("wulfenite") .dust(3).ore() .color(0xff9000).secondaryColor(0xFF0000) .components(Lead, 1, Molybdenum, 1, Oxygen, 4) .buildAndRegister(); - Limonite = new Material.Builder(GTCEu.id("yellow_limonite")) + Limonite = REGISTRATE.material("yellow_limonite") .langValue("Limonite") .dust().ore() .color(0xf5e315).secondaryColor(0xc06f33).iconSet(METALLIC) @@ -749,7 +748,7 @@ public static void register() { .buildAndRegister(); YellowLimonite = Limonite; - YttriumBariumCuprate = new Material.Builder(GTCEu.id("yttrium_barium_cuprate")) + YttriumBariumCuprate = REGISTRATE.material("yttrium_barium_cuprate") .ingot() .liquid(new FluidBuilder().temperature(1799)) .color(0x796d72).secondaryColor(0x260a3a).iconSet(METALLIC) @@ -762,7 +761,7 @@ public static void register() { .vacuumStats(VA[EV], 150)) .buildAndRegister(); - NetherQuartz = new Material.Builder(GTCEu.id("nether_quartz")) + NetherQuartz = REGISTRATE.material("nether_quartz") .gem(1).ore(2, 1) .color(0xf8efe3).secondaryColor(0xe6c1bb).iconSet(QUARTZ) .flags(GENERATE_PLATE, NO_SMELTING, CRYSTALLIZABLE, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES, @@ -770,28 +769,28 @@ public static void register() { .components(Silicon, 1, Oxygen, 2) .buildAndRegister(); - CertusQuartz = new Material.Builder(GTCEu.id("certus_quartz")) + CertusQuartz = REGISTRATE.material("certus_quartz") .gem(1).ore(2, 1) .color(0xc2d6ff).secondaryColor(0x86bacf).iconSet(CERTUS) .flags(GENERATE_PLATE, NO_SMELTING, CRYSTALLIZABLE, DISABLE_DECOMPOSITION) .components(Silicon, 1, Oxygen, 2) .buildAndRegister(); - Quartzite = new Material.Builder(GTCEu.id("quartzite")) + Quartzite = REGISTRATE.material("quartzite") .gem(1).ore(2, 1) .color(0xf2f5ed).secondaryColor(0xb8e2b8).iconSet(QUARTZ) .flags(NO_SMELTING, CRYSTALLIZABLE, DISABLE_DECOMPOSITION, GENERATE_PLATE) .components(Silicon, 1, Oxygen, 2) .buildAndRegister(); - Graphite = new Material.Builder(GTCEu.id("graphite")) + Graphite = REGISTRATE.material("graphite") .ore() .color(0xa8a89e).secondaryColor(0x172602) .flags(NO_SMELTING, FLAMMABLE, DISABLE_DECOMPOSITION) .components(Carbon, 1) .buildAndRegister(); - Graphene = new Material.Builder(GTCEu.id("graphene")) + Graphene = REGISTRATE.material("graphene") .dust().ingot() .color(0x808080).secondaryColor(0x3d3838).iconSet(SHINY) .flags(DISABLE_DECOMPOSITION, GENERATE_FOIL) @@ -799,14 +798,14 @@ public static void register() { .cableProperties(V[IV], 1, 1) .buildAndRegister(); - TungsticAcid = new Material.Builder(GTCEu.id("tungstic_acid")) + TungsticAcid = REGISTRATE.material("tungstic_acid") .dust() .color(0xfffc03).secondaryColor(0x886217).iconSet(SHINY) .flags(DISABLE_DECOMPOSITION) .components(Hydrogen, 2, Tungsten, 1, Oxygen, 4) .buildAndRegister(); - Osmiridium = new Material.Builder(GTCEu.id("osmiridium")) + Osmiridium = REGISTRATE.material("osmiridium") .ingot(3) .liquid(new FluidBuilder().temperature(3012)) .color(0x47adb6).secondaryColor(0x241a44).iconSet(METALLIC) @@ -820,31 +819,31 @@ public static void register() { .vacuumStats(VA[EV], 200)) .buildAndRegister(); - LithiumChloride = new Material.Builder(GTCEu.id("lithium_chloride")) + LithiumChloride = REGISTRATE.material("lithium_chloride") .dust() .color(0xDEDEFA).iconSet(FINE) .components(Lithium, 1, Chlorine, 1) .buildAndRegister(); - CalciumChloride = new Material.Builder(GTCEu.id("calcium_chloride")) + CalciumChloride = REGISTRATE.material("calcium_chloride") .dust() .color(0xFFFFFF).secondaryColor(0xe7e7d7).iconSet(FINE) .components(Calcium, 1, Chlorine, 2) .buildAndRegister(); - Bornite = new Material.Builder(GTCEu.id("bornite")) + Bornite = REGISTRATE.material("bornite") .dust(1).ore() .color(0xffe05a).secondaryColor(0x442602).iconSet(ROUGH) .components(Copper, 5, Iron, 1, Sulfur, 4) .buildAndRegister(); - Chalcocite = new Material.Builder(GTCEu.id("chalcocite")) + Chalcocite = REGISTRATE.material("chalcocite") .dust().ore() .color(0x657882).secondaryColor(0x33302e).iconSet(EMERALD) .components(Copper, 2, Sulfur, 1) .buildAndRegister(); - GalliumArsenide = new Material.Builder(GTCEu.id("gallium_arsenide")) + GalliumArsenide = REGISTRATE.material("gallium_arsenide") .ingot(1) .liquid(new FluidBuilder().temperature(1511)) .color(0x938fff).secondaryColor(0x8c548c) @@ -854,19 +853,19 @@ public static void register() { .blastStats(VA[MV], 1200)) .buildAndRegister(); - Potash = new Material.Builder(GTCEu.id("potash")) + Potash = REGISTRATE.material("potash") .dust(1) .color(0xffa772).secondaryColor(0x922f1b).iconSet(FINE) .components(Potassium, 2, Oxygen, 1) .buildAndRegister(); - SodaAsh = new Material.Builder(GTCEu.id("soda_ash")) + SodaAsh = REGISTRATE.material("soda_ash") .dust(1) .color(0xffffff).secondaryColor(0xDCDCFF) .components(Sodium, 2, Carbon, 1, Oxygen, 3) .buildAndRegister(); - IndiumGalliumPhosphide = new Material.Builder(GTCEu.id("indium_gallium_phosphide")) + IndiumGalliumPhosphide = REGISTRATE.material("indium_gallium_phosphide") .ingot(1) .liquid(new FluidBuilder().temperature(350)) .color(0xa77bd7).secondaryColor(0x4e546b) @@ -874,7 +873,7 @@ public static void register() { .components(Indium, 1, Gallium, 1, Phosphorus, 1) .buildAndRegister(); - NickelZincFerrite = new Material.Builder(GTCEu.id("nickel_zinc_ferrite")) + NickelZincFerrite = REGISTRATE.material("nickel_zinc_ferrite") .ingot(0) .liquid(new FluidBuilder().temperature(1410)) .color(0x3f2821).secondaryColor(0x2c2725) @@ -882,143 +881,143 @@ public static void register() { .components(Nickel, 1, Zinc, 1, Iron, 4, Oxygen, 8) .buildAndRegister(); - SiliconDioxide = new Material.Builder(GTCEu.id("silicon_dioxide")) + SiliconDioxide = REGISTRATE.material("silicon_dioxide") .dust(1) .color(0xf2f2f2).secondaryColor(0xb2c4c7).iconSet(QUARTZ) .flags(NO_SMASHING, NO_SMELTING) .components(Silicon, 1, Oxygen, 2) .buildAndRegister(); - MagnesiumChloride = new Material.Builder(GTCEu.id("magnesium_chloride")) + MagnesiumChloride = REGISTRATE.material("magnesium_chloride") .dust(1) .color(0xeee4e9).secondaryColor(0xD40D5C) .flags(DISABLE_DECOMPOSITION) .components(Magnesium, 1, Chlorine, 2) .buildAndRegister(); - SodiumSulfide = new Material.Builder(GTCEu.id("sodium_sulfide")) + SodiumSulfide = REGISTRATE.material("sodium_sulfide") .dust(1) .color(0xffd83d).secondaryColor(0xc54a00) .components(Sodium, 2, Sulfur, 1) .buildAndRegister(); - PhosphorusPentoxide = new Material.Builder(GTCEu.id("phosphorus_pentoxide")) + PhosphorusPentoxide = REGISTRATE.material("phosphorus_pentoxide") .dust(1) .color(0xe89188).secondaryColor(0x220202) .flags(DECOMPOSITION_BY_CENTRIFUGING) .components(Phosphorus, 4, Oxygen, 10) .buildAndRegister(); - Quicklime = new Material.Builder(GTCEu.id("quicklime")) + Quicklime = REGISTRATE.material("quicklime") .dust(1) .color(0xecfff3).secondaryColor(0x7d8e83) .components(Calcium, 1, Oxygen, 1) .hazard(HazardProperty.HazardTrigger.SKIN_CONTACT, GTMedicalConditions.CHEMICAL_BURNS) .buildAndRegister(); - SodiumBisulfate = new Material.Builder(GTCEu.id("sodium_bisulfate")) + SodiumBisulfate = REGISTRATE.material("sodium_bisulfate") .dust(1) .color(0xfeffed).secondaryColor(0xf1f0a3) .flags(DISABLE_DECOMPOSITION) .components(Sodium, 1, Hydrogen, 1, Sulfur, 1, Oxygen, 4) .buildAndRegister(); - FerriteMixture = new Material.Builder(GTCEu.id("ferrite_mixture")) + FerriteMixture = REGISTRATE.material("ferrite_mixture") .dust(1) .color(0xB4B4B4).secondaryColor(0x763200).iconSet(METALLIC) .flags(DECOMPOSITION_BY_CENTRIFUGING) .components(Nickel, 1, Zinc, 1, Iron, 4) .buildAndRegister(); - Magnesia = new Material.Builder(GTCEu.id("magnesia")) + Magnesia = REGISTRATE.material("magnesia") .dust(1) .color(0x998282).secondaryColor(0x594d19) .components(Magnesium, 1, Oxygen, 1) .buildAndRegister(); - PlatinumGroupSludge = new Material.Builder(GTCEu.id("platinum_group_sludge")) + PlatinumGroupSludge = REGISTRATE.material("platinum_group_sludge") .dust(1) .color(0x343228).secondaryColor(0x001E00).iconSet(FINE) .flags(DISABLE_DECOMPOSITION) .buildAndRegister(); - Realgar = new Material.Builder(GTCEu.id("realgar")) + Realgar = REGISTRATE.material("realgar") .gem().ore() .color(0xff3d33).secondaryColor(0x3f0110).iconSet(EMERALD) .flags(DECOMPOSITION_BY_CENTRIFUGING) .components(Arsenic, 4, Sulfur, 4) .buildAndRegister(); - SodiumBicarbonate = new Material.Builder(GTCEu.id("sodium_bicarbonate")) + SodiumBicarbonate = REGISTRATE.material("sodium_bicarbonate") .dust(1) .color(0xFFFFFF).secondaryColor(0xa7d2df).iconSet(ROUGH) .flags(DISABLE_DECOMPOSITION) .components(Sodium, 1, Hydrogen, 1, Carbon, 1, Oxygen, 3) .buildAndRegister(); - PotassiumDichromate = new Material.Builder(GTCEu.id("potassium_dichromate")) + PotassiumDichromate = REGISTRATE.material("potassium_dichromate") .dust(1) .color(0xff6000).secondaryColor(0xFF0000) .components(Potassium, 2, Chromium, 2, Oxygen, 7) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.POISON) .buildAndRegister(); - ChromiumTrioxide = new Material.Builder(GTCEu.id("chromium_trioxide")) + ChromiumTrioxide = REGISTRATE.material("chromium_trioxide") .dust(1) .color(0xFFE4E1) .components(Chromium, 1, Oxygen, 3) .hazard(HazardProperty.HazardTrigger.SKIN_CONTACT, GTMedicalConditions.IRRITANT) .buildAndRegister(); - AntimonyTrioxide = new Material.Builder(GTCEu.id("antimony_trioxide")) + AntimonyTrioxide = REGISTRATE.material("antimony_trioxide") .dust(1) .color(0xf5f5ff).secondaryColor(0xc4c4d6) .components(Antimony, 2, Oxygen, 3) .buildAndRegister(); - Zincite = new Material.Builder(GTCEu.id("zincite")) + Zincite = REGISTRATE.material("zincite") .dust(1) .color(0xff9f49).secondaryColor(0xff0000) .components(Zinc, 1, Oxygen, 1) .buildAndRegister(); - CupricOxide = new Material.Builder(GTCEu.id("cupric_oxide")) + CupricOxide = REGISTRATE.material("cupric_oxide") .dust(1) .color(0x8df7cf).secondaryColor(0x57696e) .components(Copper, 1, Oxygen, 1) .buildAndRegister(); - CobaltOxide = new Material.Builder(GTCEu.id("cobalt_oxide")) + CobaltOxide = REGISTRATE.material("cobalt_oxide") .dust(1) .color(0x3cb099).secondaryColor(0x3b5c66) .components(Cobalt, 1, Oxygen, 1) .buildAndRegister(); - ArsenicTrioxide = new Material.Builder(GTCEu.id("arsenic_trioxide")) + ArsenicTrioxide = REGISTRATE.material("arsenic_trioxide") .dust(1) .color(0xf9f3f3).secondaryColor(0x3b5c66).iconSet(ROUGH) .components(Arsenic, 2, Oxygen, 3) .buildAndRegister(); - Massicot = new Material.Builder(GTCEu.id("massicot")) + Massicot = REGISTRATE.material("massicot") .dust(1) .color(0xFFDD55).secondaryColor(0x000000) .components(Lead, 1, Oxygen, 1) .buildAndRegister(); - Ferrosilite = new Material.Builder(GTCEu.id("ferrosilite")) + Ferrosilite = REGISTRATE.material("ferrosilite") .dust(1) .color(0x968c80).secondaryColor(0x97732a) .components(Iron, 1, Silicon, 1, Oxygen, 3) .buildAndRegister(); - MetalMixture = new Material.Builder(GTCEu.id("metal_mixture")) + MetalMixture = REGISTRATE.material("metal_mixture") .dust(1) .color(0x697077).secondaryColor(0x502d16).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) .buildAndRegister(); - SodiumHydroxide = new Material.Builder(GTCEu.id("sodium_hydroxide")) + SodiumHydroxide = REGISTRATE.material("sodium_hydroxide") .dust(1) .color(0xf5feff).secondaryColor(0xa4ebf1) .flags(DISABLE_DECOMPOSITION) @@ -1026,84 +1025,84 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.SKIN_CONTACT, GTMedicalConditions.CHEMICAL_BURNS) .buildAndRegister(); - SodiumPersulfate = new Material.Builder(GTCEu.id("sodium_persulfate")) + SodiumPersulfate = REGISTRATE.material("sodium_persulfate") .liquid(new FluidBuilder().customStill()) .components(Sodium, 2, Sulfur, 2, Oxygen, 8) .buildAndRegister(); - Bastnasite = new Material.Builder(GTCEu.id("bastnasite")) + Bastnasite = REGISTRATE.material("bastnasite") .dust().ore(2, 1) .color(0xcaab60).secondaryColor(0xc8502d).iconSet(FINE) .components(Cerium, 1, Carbon, 1, Fluorine, 1, Oxygen, 3) .buildAndRegister(); - Pentlandite = new Material.Builder(GTCEu.id("pentlandite")) + Pentlandite = REGISTRATE.material("pentlandite") .dust().ore() .color(0xe3cf13).secondaryColor(0x29315b) .components(Nickel, 9, Sulfur, 8) .buildAndRegister(); - Spodumene = new Material.Builder(GTCEu.id("spodumene")) + Spodumene = REGISTRATE.material("spodumene") .dust().ore() .color(0xffbcbc).secondaryColor(0xc490ff) .components(Lithium, 1, Aluminium, 1, Silicon, 2, Oxygen, 6) .buildAndRegister(); - Lepidolite = new Material.Builder(GTCEu.id("lepidolite")) + Lepidolite = REGISTRATE.material("lepidolite") .dust().ore(2, 1) .color(0xffdae4).secondaryColor(0x75376f).iconSet(FINE) .components(Potassium, 1, Lithium, 3, Aluminium, 4, Fluorine, 2, Oxygen, 10) .buildAndRegister(); - GlauconiteSand = new Material.Builder(GTCEu.id("glauconite_sand")) + GlauconiteSand = REGISTRATE.material("glauconite_sand") .dust().ore(3, 1) .color(0x1da351).secondaryColor(0x1a6e8f).iconSet(SAND) .components(Potassium, 1, Magnesium, 2, Aluminium, 2, Silicon, 3, Oxygen, 12, Hydrogen, 2, Water, 1) .buildAndRegister(); - Malachite = new Material.Builder(GTCEu.id("malachite")) + Malachite = REGISTRATE.material("malachite") .gem().ore() .color(0x00f1b0).secondaryColor(0x107a47).iconSet(LAPIS) .components(Copper, 2, Carbon, 1, Hydrogen, 2, Oxygen, 5) .buildAndRegister(); - Mica = new Material.Builder(GTCEu.id("mica")) + Mica = REGISTRATE.material("mica") .dust().ore(2, 1) .color(0xecfeff).secondaryColor(0xc2a03c).iconSet(FINE) .components(Potassium, 1, Aluminium, 3, Silicon, 3, Fluorine, 2, Oxygen, 10) .buildAndRegister(); - Barite = new Material.Builder(GTCEu.id("barite")) + Barite = REGISTRATE.material("barite") .dust().ore() .color(0xe8e2d1).secondaryColor(0xf4b74b) .components(Barium, 1, Sulfur, 1, Oxygen, 4) .buildAndRegister(); - Alunite = new Material.Builder(GTCEu.id("alunite")) + Alunite = REGISTRATE.material("alunite") .dust().ore(3, 1) .color(0xfbd677).secondaryColor(0xe11e0a).iconSet(METALLIC) .components(Potassium, 1, Aluminium, 2, Silicon, 2, Hydrogen, 6, Oxygen, 14) .buildAndRegister(); - Talc = new Material.Builder(GTCEu.id("talc")) + Talc = REGISTRATE.material("talc") .dust().ore(2, 1) .color(0xebffe9).secondaryColor(0x6fe19b).iconSet(FINE) .components(Magnesium, 3, Silicon, 4, Hydrogen, 2, Oxygen, 12) .buildAndRegister(); - Soapstone = new Material.Builder(GTCEu.id("soapstone")) + Soapstone = REGISTRATE.material("soapstone") .dust(1).ore(3, 1) .color(0x5a7261).secondaryColor(0x464c4b).iconSet(ROUGH) .components(Magnesium, 3, Silicon, 4, Hydrogen, 2, Oxygen, 12) .buildAndRegister(); - Kyanite = new Material.Builder(GTCEu.id("kyanite")) + Kyanite = REGISTRATE.material("kyanite") .dust().ore() .color(0xd5ffff).secondaryColor(0x5a69d6).iconSet(FLINT) .components(Aluminium, 2, Silicon, 1, Oxygen, 5) .buildAndRegister(); - IronMagnetic = new Material.Builder(GTCEu.id("magnetic_iron")) + IronMagnetic = REGISTRATE.material("magnetic_iron") .ingot() .color(0xeeeeee).secondaryColor(0x979797).iconSet(MAGNETIC) .flags(GENERATE_BOLT_SCREW, IS_MAGNETIC) @@ -1114,7 +1113,7 @@ public static void register() { .buildAndRegister(); Iron.getProperty(PropertyKey.INGOT).setMagneticMaterial(IronMagnetic); - TungstenCarbide = new Material.Builder(GTCEu.id("tungsten_carbide")) + TungstenCarbide = REGISTRATE.material("tungsten_carbide") .ingot(4).fluid() .color(0x635480).secondaryColor(0x392e44).iconSet(METALLIC) .appendFlags(EXT2_METAL, GENERATE_FOIL, GENERATE_GEAR, GENERATE_SMALL_GEAR, GENERATE_FRAME, @@ -1129,100 +1128,100 @@ public static void register() { .vacuumStats(VA[HV])) .buildAndRegister(); - CarbonDioxide = new Material.Builder(GTCEu.id("carbon_dioxide")) + CarbonDioxide = REGISTRATE.material("carbon_dioxide") .gas() .color(0xA9D0F5) .components(Carbon, 1, Oxygen, 2) .buildAndRegister(); - TitaniumTetrachloride = new Material.Builder(GTCEu.id("titanium_tetrachloride")) + TitaniumTetrachloride = REGISTRATE.material("titanium_tetrachloride") .liquid(new FluidBuilder().customStill()) .color(0xD40D5C) .flags(DISABLE_DECOMPOSITION) .components(Titanium, 1, Chlorine, 4) .buildAndRegister(); - NitrogenDioxide = new Material.Builder(GTCEu.id("nitrogen_dioxide")) + NitrogenDioxide = REGISTRATE.material("nitrogen_dioxide") .gas() .color(0x85FCFF) .components(Nitrogen, 1, Oxygen, 2) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.POISON, 10) .buildAndRegister(); - HydrogenSulfide = new Material.Builder(GTCEu.id("hydrogen_sulfide")) + HydrogenSulfide = REGISTRATE.material("hydrogen_sulfide") .gas(new FluidBuilder().customStill()) .components(Hydrogen, 2, Sulfur, 1) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.POISON, 5) .buildAndRegister(); - NitricAcid = new Material.Builder(GTCEu.id("nitric_acid")) + NitricAcid = REGISTRATE.material("nitric_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0xCCCC00) .flags(DISABLE_DECOMPOSITION) .components(Hydrogen, 1, Nitrogen, 1, Oxygen, 3) .buildAndRegister(); - SulfuricAcid = new Material.Builder(GTCEu.id("sulfuric_acid")) + SulfuricAcid = REGISTRATE.material("sulfuric_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID).customStill()) .flags(DISABLE_DECOMPOSITION) .components(Hydrogen, 2, Sulfur, 1, Oxygen, 4) .buildAndRegister(); - PhosphoricAcid = new Material.Builder(GTCEu.id("phosphoric_acid")) + PhosphoricAcid = REGISTRATE.material("phosphoric_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0xDCDC01) .flags(DISABLE_DECOMPOSITION) .components(Hydrogen, 3, Phosphorus, 1, Oxygen, 4) .buildAndRegister(); - SulfurTrioxide = new Material.Builder(GTCEu.id("sulfur_trioxide")) + SulfurTrioxide = REGISTRATE.material("sulfur_trioxide") .gas() .color(0xA0A014) .components(Sulfur, 1, Oxygen, 3) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.POISON, 1) .buildAndRegister(); - SulfurDioxide = new Material.Builder(GTCEu.id("sulfur_dioxide")) + SulfurDioxide = REGISTRATE.material("sulfur_dioxide") .gas() .color(0x0E4880) .components(Sulfur, 1, Oxygen, 2) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.POISON, 1) .buildAndRegister(); - CarbonMonoxide = new Material.Builder(GTCEu.id("carbon_monoxide")) + CarbonMonoxide = REGISTRATE.material("carbon_monoxide") .gas() .color(0x0E4880) .components(Carbon, 1, Oxygen, 1) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CARBON_MONOXIDE_POISONING) .buildAndRegister(); - HypochlorousAcid = new Material.Builder(GTCEu.id("hypochlorous_acid")) + HypochlorousAcid = REGISTRATE.material("hypochlorous_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0x6F8A91) .components(Hydrogen, 1, Chlorine, 1, Oxygen, 1) .buildAndRegister(); - Ammonia = new Material.Builder(GTCEu.id("ammonia")) + Ammonia = REGISTRATE.material("ammonia") .gas() .color(0x4465a2).secondaryColor(0x3F3480) .components(Nitrogen, 1, Hydrogen, 3) .buildAndRegister(); - HydrofluoricAcid = new Material.Builder(GTCEu.id("hydrofluoric_acid")) + HydrofluoricAcid = REGISTRATE.material("hydrofluoric_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0x0088AA) .components(Hydrogen, 1, Fluorine, 1) // TODO HF poisoning .hazard(HazardProperty.HazardTrigger.ANY) .buildAndRegister(); - NitricOxide = new Material.Builder(GTCEu.id("nitric_oxide")) + NitricOxide = REGISTRATE.material("nitric_oxide") .gas() .color(0x7DC8F0) .components(Nitrogen, 1, Oxygen, 1) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.POISON, 1) .buildAndRegister(); - Iron3Chloride = new Material.Builder(GTCEu.id("iron_iii_chloride")) + Iron3Chloride = REGISTRATE.material("iron_iii_chloride") .langValue("Iron III Chloride") .liquid() .color(0x060B0B) @@ -1230,7 +1229,7 @@ public static void register() { .components(Iron, 1, Chlorine, 3) .buildAndRegister(); - Iron2Chloride = new Material.Builder(GTCEu.id("iron_ii_chloride")) + Iron2Chloride = REGISTRATE.material("iron_ii_chloride") .langValue("Iron II Chloride") .liquid() .color(0xe8e0be) @@ -1238,7 +1237,7 @@ public static void register() { .components(Iron, 1, Chlorine, 2) .buildAndRegister(); - UraniumHexafluoride = new Material.Builder(GTCEu.id("uranium_hexafluoride")) + UraniumHexafluoride = REGISTRATE.material("uranium_hexafluoride") .gas() .color(0x42D126) .flags(DISABLE_DECOMPOSITION) @@ -1246,41 +1245,41 @@ public static void register() { .buildAndRegister() .setFormula("UF6", true); - EnrichedUraniumHexafluoride = new Material.Builder(GTCEu.id("enriched_uranium_hexafluoride")) + EnrichedUraniumHexafluoride = REGISTRATE.material("enriched_uranium_hexafluoride") .gas() .color(0x4BF52A) .flags(DISABLE_DECOMPOSITION) .components(Uranium235, 1, Fluorine, 6) .buildAndRegister(); - DepletedUraniumHexafluoride = new Material.Builder(GTCEu.id("depleted_uranium_hexafluoride")) + DepletedUraniumHexafluoride = REGISTRATE.material("depleted_uranium_hexafluoride") .gas() .color(0x74BA66) .flags(DISABLE_DECOMPOSITION) .components(Uranium238, 1, Fluorine, 6) .buildAndRegister(); - NitrousOxide = new Material.Builder(GTCEu.id("nitrous_oxide")) + NitrousOxide = REGISTRATE.material("nitrous_oxide") .gas() .color(0x7DC8FF) .components(Nitrogen, 2, Oxygen, 1) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.POISON, .5f) .buildAndRegister(); - EnderPearl = new Material.Builder(GTCEu.id("ender_pearl")) + EnderPearl = REGISTRATE.material("ender_pearl") .gem(1) .color(0x8cf4e2).secondaryColor(0x032620).iconSet(SHINY) .flags(NO_SMASHING, NO_SMELTING, GENERATE_PLATE) .components(Beryllium, 1, Potassium, 4, Nitrogen, 5) .buildAndRegister(); - PotassiumFeldspar = new Material.Builder(GTCEu.id("potassium_feldspar")) + PotassiumFeldspar = REGISTRATE.material("potassium_feldspar") .dust(1) .color(0xffe3bc).secondaryColor(0xd4918a).iconSet(FINE) .components(Potassium, 1, Aluminium, 1, Silicon, 3, Oxygen, 8) .buildAndRegister(); - NeodymiumMagnetic = new Material.Builder(GTCEu.id("magnetic_neodymium")) + NeodymiumMagnetic = REGISTRATE.material("magnetic_neodymium") .ingot() .color(0x9a8b94).secondaryColor(0x2c2c2c).iconSet(MAGNETIC) .flags(GENERATE_ROD, IS_MAGNETIC) @@ -1291,12 +1290,12 @@ public static void register() { .buildAndRegister(); Neodymium.getProperty(PropertyKey.INGOT).setMagneticMaterial(NeodymiumMagnetic); - HydrochloricAcid = new Material.Builder(GTCEu.id("hydrochloric_acid")) + HydrochloricAcid = REGISTRATE.material("hydrochloric_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID).customStill()) .components(Hydrogen, 1, Chlorine, 1) .buildAndRegister(); - Steam = new Material.Builder(GTCEu.id("steam")) + Steam = REGISTRATE.material("steam") .gas(new FluidBuilder() .state(FluidState.GAS) .temperature(373) @@ -1305,21 +1304,21 @@ public static void register() { .components(Hydrogen, 2, Oxygen, 1) .buildAndRegister(); - DistilledWater = new Material.Builder(GTCEu.id("distilled_water")) + DistilledWater = REGISTRATE.material("distilled_water") .fluid() .color(0x4A94FF) .flags(DISABLE_DECOMPOSITION) .components(Hydrogen, 2, Oxygen, 1) .buildAndRegister(); - SodiumPotassium = new Material.Builder(GTCEu.id("sodium_potassium")) + SodiumPotassium = REGISTRATE.material("sodium_potassium") .fluid() .color(0x64FCB4) .flags(DECOMPOSITION_BY_CENTRIFUGING) .components(Sodium, 1, Potassium, 1) .buildAndRegister(); - SamariumMagnetic = new Material.Builder(GTCEu.id("magnetic_samarium")) + SamariumMagnetic = REGISTRATE.material("magnetic_samarium") .ingot() .color(0xc5c5b3).secondaryColor(0x183e3f).iconSet(MAGNETIC) .flags(GENERATE_LONG_ROD, IS_MAGNETIC) @@ -1330,7 +1329,7 @@ public static void register() { .buildAndRegister(); Samarium.getProperty(PropertyKey.INGOT).setMagneticMaterial(SamariumMagnetic); - ManganesePhosphide = new Material.Builder(GTCEu.id("manganese_phosphide")) + ManganesePhosphide = REGISTRATE.material("manganese_phosphide") .ingot() .liquid(new FluidBuilder().temperature(1368)) .color(0xE1B454).secondaryColor(0x223033).iconSet(METALLIC) @@ -1340,7 +1339,7 @@ public static void register() { .blast(1200, GasTier.LOW) .buildAndRegister(); - MagnesiumDiboride = new Material.Builder(GTCEu.id("magnesium_diboride")) + MagnesiumDiboride = REGISTRATE.material("magnesium_diboride") .ingot() .liquid(new FluidBuilder().temperature(1103)) .color(0x603c1a).secondaryColor(0x423e39).iconSet(METALLIC) @@ -1352,7 +1351,7 @@ public static void register() { .vacuumStats(VA[MV], 200)) .buildAndRegister(); - MercuryBariumCalciumCuprate = new Material.Builder(GTCEu.id("mercury_barium_calcium_cuprate")) + MercuryBariumCalciumCuprate = REGISTRATE.material("mercury_barium_calcium_cuprate") .ingot() .liquid(new FluidBuilder().temperature(1075)) .color(0x928547).secondaryColor(0x3f2e2e).iconSet(SHINY) @@ -1364,7 +1363,7 @@ public static void register() { .vacuumStats(VA[HV])) .buildAndRegister(); - UraniumTriplatinum = new Material.Builder(GTCEu.id("uranium_triplatinum")) + UraniumTriplatinum = REGISTRATE.material("uranium_triplatinum") .ingot() .liquid(new FluidBuilder().temperature(1882)) .color(0x457045).secondaryColor(0x66ff00).iconSet(RADIOACTIVE) @@ -1377,7 +1376,7 @@ public static void register() { .buildAndRegister() .setFormula("UPt3", true); - SamariumIronArsenicOxide = new Material.Builder(GTCEu.id("samarium_iron_arsenic_oxide")) + SamariumIronArsenicOxide = REGISTRATE.material("samarium_iron_arsenic_oxide") .ingot() .liquid(new FluidBuilder().temperature(1347)) .color(0x850e85).secondaryColor(0x332f33).iconSet(SHINY) @@ -1389,7 +1388,7 @@ public static void register() { .vacuumStats(VA[IV], 200)) .buildAndRegister(); - IndiumTinBariumTitaniumCuprate = new Material.Builder(GTCEu.id("indium_tin_barium_titanium_cuprate")) + IndiumTinBariumTitaniumCuprate = REGISTRATE.material("indium_tin_barium_titanium_cuprate") .ingot() .liquid(new FluidBuilder().temperature(1012)) .color(0x686760).secondaryColor(0x673300).iconSet(METALLIC) @@ -1401,7 +1400,7 @@ public static void register() { .vacuumStats(VA[LuV])) .buildAndRegister(); - UraniumRhodiumDinaquadide = new Material.Builder(GTCEu.id("uranium_rhodium_dinaquadide")) + UraniumRhodiumDinaquadide = REGISTRATE.material("uranium_rhodium_dinaquadide") .ingot() .liquid(new FluidBuilder().temperature(3410)) .color(0x232020).secondaryColor(0xff009c).iconSet(RADIOACTIVE) @@ -1414,8 +1413,8 @@ public static void register() { .buildAndRegister() .setFormula("URhNq2", true); - EnrichedNaquadahTriniumEuropiumDuranide = new Material.Builder( - GTCEu.id("enriched_naquadah_trinium_europium_duranide")) + EnrichedNaquadahTriniumEuropiumDuranide = REGISTRATE.material( + "enriched_naquadah_trinium_europium_duranide") .ingot() .liquid(new FluidBuilder().temperature(5930)) .color(0xc6b083).secondaryColor(0x45063d).iconSet(METALLIC) @@ -1427,7 +1426,7 @@ public static void register() { .vacuumStats(VA[UV], 200)) .buildAndRegister(); - RutheniumTriniumAmericiumNeutronate = new Material.Builder(GTCEu.id("ruthenium_trinium_americium_neutronate")) + RutheniumTriniumAmericiumNeutronate = REGISTRATE.material("ruthenium_trinium_americium_neutronate") .ingot() .liquid(new FluidBuilder().temperature(23691)) .color(0x897b76).secondaryColor(0x00c0ff).iconSet(RADIOACTIVE) @@ -1439,14 +1438,14 @@ public static void register() { .vacuumStats(VA[UHV], 200)) .buildAndRegister(); - InertMetalMixture = new Material.Builder(GTCEu.id("inert_metal_mixture")) + InertMetalMixture = REGISTRATE.material("inert_metal_mixture") .dust() .color(0x2b0645).secondaryColor(0x6a1600).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) .components(Rhodium, 1, Ruthenium, 1, Oxygen, 4) .buildAndRegister(); - RhodiumSulfate = new Material.Builder(GTCEu.id("rhodium_sulfate")) + RhodiumSulfate = REGISTRATE.material("rhodium_sulfate") .liquid(new FluidBuilder().temperature(1128)) .color(0xEEAA55) .flags(DISABLE_DECOMPOSITION) @@ -1454,14 +1453,14 @@ public static void register() { .buildAndRegister() .setFormula("Rh2(SO4)3", true); - RutheniumTetroxide = new Material.Builder(GTCEu.id("ruthenium_tetroxide")) + RutheniumTetroxide = REGISTRATE.material("ruthenium_tetroxide") .dust() .color(0xbeb809).secondaryColor(0x4e4e4d) .flags(DISABLE_DECOMPOSITION) .components(Ruthenium, 1, Oxygen, 4) .buildAndRegister(); - OsmiumTetroxide = new Material.Builder(GTCEu.id("osmium_tetroxide")) + OsmiumTetroxide = REGISTRATE.material("osmium_tetroxide") .dust() .color(0x578d9f).secondaryColor(0x394117).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) @@ -1469,124 +1468,124 @@ public static void register() { // TODO Osmium tetroxide poisoning .hazard(HazardProperty.HazardTrigger.ANY) .buildAndRegister(); - IridiumChloride = new Material.Builder(GTCEu.id("iridium_chloride")) + IridiumChloride = REGISTRATE.material("iridium_chloride") .dust() .color(0x41460c).secondaryColor(0x00542e).iconSet(FINE) .flags(DISABLE_DECOMPOSITION) .components(Iridium, 1, Chlorine, 3) .buildAndRegister(); - FluoroantimonicAcid = new Material.Builder(GTCEu.id("fluoroantimonic_acid")) + FluoroantimonicAcid = REGISTRATE.material("fluoroantimonic_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID).customStill()) .components(Hydrogen, 2, Antimony, 1, Fluorine, 7) .buildAndRegister(); - TitaniumTrifluoride = new Material.Builder(GTCEu.id("titanium_trifluoride")) + TitaniumTrifluoride = REGISTRATE.material("titanium_trifluoride") .dust() .color(0x8F00FF).secondaryColor(0x341465).iconSet(SHINY) .flags(DISABLE_DECOMPOSITION) .components(Titanium, 1, Fluorine, 3) .buildAndRegister(); - CalciumPhosphide = new Material.Builder(GTCEu.id("calcium_phosphide")) + CalciumPhosphide = REGISTRATE.material("calcium_phosphide") .dust() .color(0xFFF5DE).secondaryColor(0xf6baba).iconSet(METALLIC) .components(Calcium, 1, Phosphorus, 1) .buildAndRegister(); - IndiumPhosphide = new Material.Builder(GTCEu.id("indium_phosphide")) + IndiumPhosphide = REGISTRATE.material("indium_phosphide") .dust() .color(0x734d77).secondaryColor(0x2c272d).iconSet(SHINY) .flags(DISABLE_DECOMPOSITION) .components(Indium, 1, Phosphorus, 1) .buildAndRegister(); - BariumSulfide = new Material.Builder(GTCEu.id("barium_sulfide")) + BariumSulfide = REGISTRATE.material("barium_sulfide") .dust() .color(0x80784a).secondaryColor(0x2c333b).iconSet(METALLIC) .components(Barium, 1, Sulfur, 1) .buildAndRegister(); - TriniumSulfide = new Material.Builder(GTCEu.id("trinium_sulfide")) + TriniumSulfide = REGISTRATE.material("trinium_sulfide") .dust() .color(0xE68066).secondaryColor(0x6f143a).iconSet(SHINY) .flags(DISABLE_DECOMPOSITION) .components(Trinium, 1, Sulfur, 1) .buildAndRegister(); - ZincSulfide = new Material.Builder(GTCEu.id("zinc_sulfide")) + ZincSulfide = REGISTRATE.material("zinc_sulfide") .dust() .color(0xfff4d5).secondaryColor(0xdadada) .components(Zinc, 1, Sulfur, 1) .buildAndRegister(); - GalliumSulfide = new Material.Builder(GTCEu.id("gallium_sulfide")) + GalliumSulfide = REGISTRATE.material("gallium_sulfide") .dust() .color(0xffee5d).secondaryColor(0xedf008).iconSet(SHINY) .components(Gallium, 1, Sulfur, 1) .buildAndRegister(); - AntimonyTrifluoride = new Material.Builder(GTCEu.id("antimony_trifluoride")) + AntimonyTrifluoride = REGISTRATE.material("antimony_trifluoride") .dust() .color(0xfffbef).secondaryColor(0xF7EABC).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) .components(Antimony, 1, Fluorine, 3) .buildAndRegister(); - EnrichedNaquadahSulfate = new Material.Builder(GTCEu.id("enriched_naquadah_sulfate")) + EnrichedNaquadahSulfate = REGISTRATE.material("enriched_naquadah_sulfate") .dust() .color(0xff8023).secondaryColor(0x044610).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) .components(NaquadahEnriched, 1, Sulfur, 1, Oxygen, 4) .buildAndRegister(); - NaquadriaSulfate = new Material.Builder(GTCEu.id("naquadria_sulfate")) + NaquadriaSulfate = REGISTRATE.material("naquadria_sulfate") .dust() .color(0x85ff5a).secondaryColor(0x006633).iconSet(SHINY) .flags(DISABLE_DECOMPOSITION) .components(Naquadria, 1, Sulfur, 1, Oxygen, 4) .buildAndRegister(); - Pyrochlore = new Material.Builder(GTCEu.id("pyrochlore")) + Pyrochlore = REGISTRATE.material("pyrochlore") .dust().ore() .color(0x5b4838).secondaryColor(0x331400).iconSet(METALLIC) .components(Calcium, 2, Niobium, 2, Oxygen, 6, Fluorine, 1) .buildAndRegister(); - PotassiumHydroxide = new Material.Builder(GTCEu.id("potassium_hydroxide")) + PotassiumHydroxide = REGISTRATE.material("potassium_hydroxide") .dust(1) .color(0xd1c299).secondaryColor(0x85623a).iconSet(METALLIC) .hazard(HazardProperty.HazardTrigger.SKIN_CONTACT, GTMedicalConditions.CHEMICAL_BURNS) .components(Potassium, 1, Oxygen, 1, Hydrogen, 1) .buildAndRegister(); - PotassiumIodide = new Material.Builder(GTCEu.id("potassium_iodide")) + PotassiumIodide = REGISTRATE.material("potassium_iodide") .dust() .color(0xa66c71).secondaryColor(0x802d67).iconSet(METALLIC) .components(Potassium, 1, Iodine, 1) .buildAndRegister(); - PotassiumCarbonate = new Material.Builder(GTCEu.id("potassium_carbonate")) + PotassiumCarbonate = REGISTRATE.material("potassium_carbonate") .dust() .color(0xa66c71).secondaryColor(0x802d67).iconSet(METALLIC) .components(Potassium, 2, Carbon, 1, Oxygen, 3) .buildAndRegister(); - PotassiumFerrocyanide = new Material.Builder(GTCEu.id("potassium_ferrocyanide")) + PotassiumFerrocyanide = REGISTRATE.material("potassium_ferrocyanide") .dust() .color(0xc9a842).secondaryColor(0x947110).iconSet(DULL) .components(Potassium, 4, Iron, 1, Carbon, 6, Nitrogen, 6) .buildAndRegister() .setFormula("K4[Fe(CN)6]", true); - CalciumFerrocyanide = new Material.Builder(GTCEu.id("calcium_ferrocyanide")) + CalciumFerrocyanide = REGISTRATE.material("calcium_ferrocyanide") .dust() .color(0xc9a842).secondaryColor(0x947110).iconSet(DULL) .components(Calcium, 2, Iron, 1, Carbon, 6, Nitrogen, 6) .buildAndRegister() .setFormula("Ca2[Fe(CN)6]", true); - CalciumHydroxide = new Material.Builder(GTCEu.id("calcium_hydroxide")) + CalciumHydroxide = REGISTRATE.material("calcium_hydroxide") .dust() .color(0x72dbd4).secondaryColor(0x138a80).iconSet(ROUGH) .components(Calcium, 1, Oxygen, 2, Hydrogen, 2) @@ -1594,41 +1593,41 @@ public static void register() { .buildAndRegister() .setFormula("Ca(OH)2", true); - CalciumCarbonate = new Material.Builder(GTCEu.id("calcium_carbonate")) + CalciumCarbonate = REGISTRATE.material("calcium_carbonate") .dust() .color(0xd9ca9c).secondaryColor(0xad913b) .components(Calcium, 1, Carbon, 1, Oxygen, 3) .buildAndRegister(); - PotassiumCyanide = new Material.Builder(GTCEu.id("potassium_cyanide")) + PotassiumCyanide = REGISTRATE.material("potassium_cyanide") .dust() .color(0x93badb).secondaryColor(0x0c5696).iconSet(ROUGH) .components(Potassium, 1, Carbon, 1, Nitrogen, 1) .hazard(HazardProperty.HazardTrigger.ANY, GTMedicalConditions.CHEMICAL_BURNS, true) .buildAndRegister(); - HydrogenCyanide = new Material.Builder(GTCEu.id("hydrogen_cyanide")) + HydrogenCyanide = REGISTRATE.material("hydrogen_cyanide") .gas() .color(0x72dbd4) .components(Hydrogen, 1, Carbon, 1, Nitrogen, 1) .hazard(HazardProperty.HazardTrigger.ANY, GTMedicalConditions.CHEMICAL_BURNS, true) .buildAndRegister(); - FormicAcid = new Material.Builder(GTCEu.id("formic_acid")) + FormicAcid = REGISTRATE.material("formic_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0xa6a6a6) .components(Carbon, 1, Hydrogen, 2, Oxygen, 2) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CHEMICAL_BURNS) .buildAndRegister(); - PotassiumSulfate = new Material.Builder(GTCEu.id("potassium_sulfate")) + PotassiumSulfate = REGISTRATE.material("potassium_sulfate") .dust() .color(0xebab34).secondaryColor(0xb5570e) .flags(DECOMPOSITION_BY_ELECTROLYZING) .components(Potassium, 2, Sulfur, 1, Oxygen, 4) .buildAndRegister(); - PrussianBlue = new Material.Builder(GTCEu.id("prussian_blue")) + PrussianBlue = REGISTRATE.material("prussian_blue") .dust() .color(0x102e5e).secondaryColor(0x010c42) .flags(DISABLE_DECOMPOSITION) @@ -1636,7 +1635,7 @@ public static void register() { .buildAndRegister() .setFormula("Fe4[Fe(CN)6]3", true); - Formaldehyde = new Material.Builder(GTCEu.id("formaldehyde")) + Formaldehyde = REGISTRATE.material("formaldehyde") .liquid() .color(0xddeced) .flags(DECOMPOSITION_BY_ELECTROLYZING) @@ -1644,42 +1643,42 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.POISON) .buildAndRegister(); - Glycolonitrile = new Material.Builder(GTCEu.id("glycolonitrile")) + Glycolonitrile = REGISTRATE.material("glycolonitrile") .liquid() .color(0x5b8c8f) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 2, Hydrogen, 3, Nitrogen, 1, Oxygen, 1) .buildAndRegister(); - DiethylenetriaminePentaacetonitrile = new Material.Builder(GTCEu.id("diethylenetriamine_pentaacetonitrile")) + DiethylenetriaminePentaacetonitrile = REGISTRATE.material("diethylenetriamine_pentaacetonitrile") .liquid() .color(0xcbbfd6) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 14, Hydrogen, 18, Nitrogen, 8) .buildAndRegister(); - DiethylenetriaminepentaaceticAcid = new Material.Builder(GTCEu.id("diethylenetriaminepentaacetic_acid")) + DiethylenetriaminepentaaceticAcid = REGISTRATE.material("diethylenetriaminepentaacetic_acid") .dust() .color(0xe8c93c).secondaryColor(0xc99118) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 14, Hydrogen, 23, Nitrogen, 3, Oxygen, 10) .buildAndRegister(); - SodiumNitrite = new Material.Builder(GTCEu.id("sodium_nitrite")) + SodiumNitrite = REGISTRATE.material("sodium_nitrite") .dust() .color(0xcfbf65).secondaryColor(0x85600b) .flags(DECOMPOSITION_BY_ELECTROLYZING) .components(Sodium, 1, Nitrogen, 1, Oxygen, 2) .buildAndRegister(); - HydrogenPeroxide = new Material.Builder(GTCEu.id("hydrogen_peroxide")) + HydrogenPeroxide = REGISTRATE.material("hydrogen_peroxide") .liquid() .color(0x0cbdd7) .components(Hydrogen, 2, Oxygen, 2) .hazard(HazardProperty.HazardTrigger.ANY, GTMedicalConditions.CHEMICAL_BURNS, true) .buildAndRegister(); - IlmeniteSlag = new Material.Builder(GTCEu.id("ilmenite_slag")) + IlmeniteSlag = REGISTRATE.material("ilmenite_slag") .dust() .color(0x8B0000).iconSet(SAND) .buildAndRegister(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/materials/GCYMMaterials.java b/src/main/java/com/gregtechceu/gtceu/common/data/materials/GCYMMaterials.java index 1bd6c809efd..d850b99ac67 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/materials/GCYMMaterials.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/materials/GCYMMaterials.java @@ -1,19 +1,18 @@ package com.gregtechceu.gtceu.common.data.materials; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty.GasTier; import static com.gregtechceu.gtceu.api.GTValues.*; import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags.*; import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet.*; import static com.gregtechceu.gtceu.common.data.GTMaterials.*; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; public class GCYMMaterials { public static void register() { - TantalumCarbide = new Material.Builder(GTCEu.id("tantalum_carbide")) + TantalumCarbide = REGISTRATE.material("tantalum_carbide") .ingot(4).fluid() .color(0x999900).iconSet(METALLIC) .appendFlags(STD_METAL, GENERATE_PLATE) @@ -22,7 +21,7 @@ public static void register() { .blastStats(VA[EV], 1200)) .buildAndRegister(); - HSLASteel = new Material.Builder(GTCEu.id("hsla_steel")) + HSLASteel = REGISTRATE.material("hsla_steel") .langValue("HSLA Steel") .ingot(3).fluid() .color(0x686868).iconSet(METALLIC) @@ -32,7 +31,7 @@ public static void register() { .blastStats(VA[GTValues.HV], 1000)) .buildAndRegister(); - MolybdenumDisilicide = new Material.Builder(GTCEu.id("molybdenum_disilicide")) + MolybdenumDisilicide = REGISTRATE.material("molybdenum_disilicide") .ingot(2).fluid() .color(0x564A84).iconSet(METALLIC) .appendFlags(STD_METAL, GENERATE_SPRING, GENERATE_RING, GENERATE_PLATE, GENERATE_LONG_ROD) @@ -41,7 +40,7 @@ public static void register() { .blastStats(VA[EV], 800)) .buildAndRegister(); - Zeron100 = new Material.Builder(GTCEu.id("zeron_100")) + Zeron100 = REGISTRATE.material("zeron_100") .langValue("Zeron-100") .ingot(5).fluid() .color(0x294972).iconSet(METALLIC) @@ -51,7 +50,7 @@ public static void register() { .blastStats(VA[EV], 1000)) .buildAndRegister(); - WatertightSteel = new Material.Builder(GTCEu.id("watertight_steel")) + WatertightSteel = REGISTRATE.material("watertight_steel") .ingot(4).fluid() .color(0x2B4B56).iconSet(METALLIC) .appendFlags(STD_METAL, GENERATE_PLATE, GENERATE_ROD, GENERATE_FRAME) @@ -60,7 +59,7 @@ public static void register() { .blastStats(VA[EV], 800)) .buildAndRegister(); - IncoloyMA956 = new Material.Builder(GTCEu.id("incoloy_ma_956")) + IncoloyMA956 = REGISTRATE.material("incoloy_ma_956") .langValue("Incoloy MA-956") .ingot(5).fluid() .color(0x2D9B66).iconSet(METALLIC) @@ -70,7 +69,7 @@ public static void register() { .blastStats(VA[EV], 800)) .buildAndRegister(); - MaragingSteel300 = new Material.Builder(GTCEu.id("maraging_steel_300")) + MaragingSteel300 = REGISTRATE.material("maraging_steel_300") .ingot(4).fluid() .color(0x505B6E).iconSet(METALLIC) .appendFlags(STD_METAL, GENERATE_ROD, GENERATE_FRAME) @@ -79,7 +78,7 @@ public static void register() { .blastStats(VA[EV], 1000)) .buildAndRegister(); - HastelloyX = new Material.Builder(GTCEu.id("hastelloy_x")) + HastelloyX = REGISTRATE.material("hastelloy_x") .ingot(5).fluid() .color(0x5784B8).iconSet(METALLIC) .appendFlags(STD_METAL, GENERATE_PLATE, GENERATE_FRAME) @@ -88,7 +87,7 @@ public static void register() { .blastStats(VA[EV], 900)) .buildAndRegister(); - Stellite100 = new Material.Builder(GTCEu.id("stellite_100")) + Stellite100 = REGISTRATE.material("stellite_100") .langValue("Stellite-100") .ingot(4).fluid() .color(0xCFCFEE).iconSet(METALLIC) @@ -98,7 +97,7 @@ public static void register() { .blastStats(VA[EV], 1000)) .buildAndRegister(); - TitaniumCarbide = new Material.Builder(GTCEu.id("titanium_carbide")) + TitaniumCarbide = REGISTRATE.material("titanium_carbide") .ingot(3).fluid() .color(0x90092F).iconSet(METALLIC) .appendFlags(STD_METAL, GENERATE_PLATE) @@ -107,7 +106,7 @@ public static void register() { .blastStats(VA[EV], 1000)) .buildAndRegister(); - TitaniumTungstenCarbide = new Material.Builder(GTCEu.id("titanium_tungsten_carbide")) + TitaniumTungstenCarbide = REGISTRATE.material("titanium_tungsten_carbide") .ingot(6).fluid() .color(0x680B0B).iconSet(METALLIC) .appendFlags(STD_METAL, GENERATE_PLATE) @@ -116,7 +115,7 @@ public static void register() { .blastStats(VA[EV], 1000)) .buildAndRegister(); - HastelloyC276 = new Material.Builder(GTCEu.id("hastelloy_c_276")) + HastelloyC276 = REGISTRATE.material("hastelloy_c_276") .langValue("Hastelloy C-276") .ingot(6).fluid() .color(0xAB2F2F).iconSet(METALLIC) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/materials/HigherDegreeMaterials.java b/src/main/java/com/gregtechceu/gtceu/common/data/materials/HigherDegreeMaterials.java index cc7ce118a21..b8ed26ac478 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/materials/HigherDegreeMaterials.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/materials/HigherDegreeMaterials.java @@ -1,8 +1,6 @@ package com.gregtechceu.gtceu.common.data.materials; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty.GasTier; import com.gregtechceu.gtceu.api.data.chemical.material.properties.ToolProperty; import com.gregtechceu.gtceu.api.fluids.FluidBuilder; @@ -11,31 +9,32 @@ import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags.*; import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet.*; import static com.gregtechceu.gtceu.common.data.GTMaterials.*; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; public class HigherDegreeMaterials { public static void register() { - Electrotine = new Material.Builder(GTCEu.id("electrotine")) + Electrotine = REGISTRATE.material("electrotine") .dust().ore(5, 1, true) .color(0x83cbf5).secondaryColor(0x004585).iconSet(SHINY) .flags(DISABLE_DECOMPOSITION) .components(Redstone, 1, Electrum, 1) .buildAndRegister(); - EnderEye = new Material.Builder(GTCEu.id("ender_eye")) + EnderEye = REGISTRATE.material("ender_eye") .gem(1) .color(0xb5e45a).secondaryColor(0x001430).iconSet(SHINY) .flags(GENERATE_PLATE, NO_SMASHING, NO_SMELTING, DECOMPOSITION_BY_CENTRIFUGING) .components(EnderPearl, 1, Blaze, 1) .buildAndRegister(); - Diatomite = new Material.Builder(GTCEu.id("diatomite")) + Diatomite = REGISTRATE.material("diatomite") .dust(1).ore() .color(0xfffafa) .components(Flint, 8, Hematite, 1, Sapphire, 1) .buildAndRegister(); - RedSteel = new Material.Builder(GTCEu.id("red_steel")) + RedSteel = REGISTRATE.material("red_steel") .ingot(3).fluid() .color(0xa09191).secondaryColor(0x500404).iconSet(METALLIC) .appendFlags(EXT_METAL, GENERATE_GEAR, GENERATE_BOLT_SCREW, GENERATE_LONG_ROD) @@ -46,7 +45,7 @@ public static void register() { .blastStats(VA[HV], 1000)) .buildAndRegister(); - BlueSteel = new Material.Builder(GTCEu.id("blue_steel")) + BlueSteel = REGISTRATE.material("blue_steel") .ingot(3).fluid() .color(0x779ac6).secondaryColor(0x191948).iconSet(METALLIC) .appendFlags(EXT_METAL, GENERATE_FRAME, GENERATE_GEAR, GENERATE_BOLT_SCREW, GENERATE_LONG_ROD) @@ -57,35 +56,35 @@ public static void register() { .blastStats(VA[HV], 1000)) .buildAndRegister(); - Basalt = new Material.Builder(GTCEu.id("basalt")) + Basalt = REGISTRATE.material("basalt") .dust(1) .color(0x5c5c5c).secondaryColor(0x1b2632).iconSet(ROUGH) .flags(NO_SMASHING, DECOMPOSITION_BY_CENTRIFUGING) .components(Olivine, 1, Calcite, 3, Flint, 8, DarkAsh, 4) .buildAndRegister(); - GraniticMineralSand = new Material.Builder(GTCEu.id("granitic_mineral_sand")) + GraniticMineralSand = REGISTRATE.material("granitic_mineral_sand") .dust(1).ore() .color(0xd69077).secondaryColor(0x71352c).iconSet(SAND) .components(Magnetite, 1, Deepslate, 1) .flags(BLAST_FURNACE_CALCITE_DOUBLE) .buildAndRegister(); - Redrock = new Material.Builder(GTCEu.id("redrock")) + Redrock = REGISTRATE.material("redrock") .dust(1) .color(0xffa49e).secondaryColor(0x52362a).iconSet(ROUGH) .flags(NO_SMASHING, DECOMPOSITION_BY_CENTRIFUGING) .components(Calcite, 2, Flint, 1) .buildAndRegister(); - GarnetSand = new Material.Builder(GTCEu.id("garnet_sand")) + GarnetSand = REGISTRATE.material("garnet_sand") .dust(1).ore() .color(0xcc4c25).secondaryColor(0x510b04).iconSet(SAND) .flags(DECOMPOSITION_BY_CENTRIFUGING) .components(Almandine, 1, Andradite, 1, Grossular, 1, Pyrope, 1, Spessartine, 1, Uvarovite, 1) .buildAndRegister(); - HSSG = new Material.Builder(GTCEu.id("hssg")) + HSSG = REGISTRATE.material("hssg") .langValue("HSS-G") .ingot(3).fluid() .color(0x9cbabe).secondaryColor(0x032550).iconSet(METALLIC) @@ -99,7 +98,7 @@ public static void register() { .vacuumStats(VA[HV])) .buildAndRegister(); - RedAlloy = new Material.Builder(GTCEu.id("red_alloy")) + RedAlloy = REGISTRATE.material("red_alloy") .ingot(0) .liquid(new FluidBuilder().temperature(1400)) .color(0xc55252).secondaryColor(0xC80000).iconSet(METALLIC) @@ -109,14 +108,14 @@ public static void register() { .cableProperties(GTValues.V[0], 1, 0) .buildAndRegister(); - BasalticMineralSand = new Material.Builder(GTCEu.id("basaltic_mineral_sand")) + BasalticMineralSand = REGISTRATE.material("basaltic_mineral_sand") .dust(1).ore() .color(0x5c5c5c).secondaryColor(0x283228).iconSet(SAND) .components(Magnetite, 1, Basalt, 1) .flags(BLAST_FURNACE_CALCITE_DOUBLE) .buildAndRegister(); - HSSE = new Material.Builder(GTCEu.id("hsse")) + HSSE = REGISTRATE.material("hsse") .langValue("HSS-E") .ingot(4).fluid() .color(0x9d9cbe).secondaryColor(0x2b0350).iconSet(METALLIC) @@ -130,7 +129,7 @@ public static void register() { .vacuumStats(VA[HV])) .buildAndRegister(); - HSSS = new Material.Builder(GTCEu.id("hsss")) + HSSS = REGISTRATE.material("hsss") .langValue("HSS-S") .ingot(4).fluid() .color(0xa482bf).secondaryColor(0x66000e).iconSet(METALLIC) @@ -143,35 +142,35 @@ public static void register() { .vacuumStats(VA[EV], 200)) .buildAndRegister(); - IridiumMetalResidue = new Material.Builder(GTCEu.id("iridium_metal_residue")) + IridiumMetalResidue = REGISTRATE.material("iridium_metal_residue") .dust() .color(0x484a5e).secondaryColor(0x3e1c38).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) .components(Iridium, 1, Chlorine, 3, PlatinumSludgeResidue, 1) .buildAndRegister(); - Granite = new Material.Builder(GTCEu.id("granite")) + Granite = REGISTRATE.material("granite") .dust() .color(0xd69077).secondaryColor(0x71352c).iconSet(ROUGH) .flags(DECOMPOSITION_BY_CENTRIFUGING) .components(SiliconDioxide, 4, Redrock, 1) .buildAndRegister(); - Brick = new Material.Builder(GTCEu.id("brick")) + Brick = REGISTRATE.material("brick") .dust() .color(0xc76245).secondaryColor(0x2d1610).iconSet(ROUGH) .flags(EXCLUDE_BLOCK_CRAFTING_RECIPES, NO_SMELTING, DECOMPOSITION_BY_CENTRIFUGING) .components(Clay, 1) .buildAndRegister(); - Fireclay = new Material.Builder(GTCEu.id("fireclay")) + Fireclay = REGISTRATE.material("fireclay") .dust() .color(0xffeab6).secondaryColor(0x84581c).iconSet(ROUGH) .flags(DECOMPOSITION_BY_CENTRIFUGING, NO_SMELTING) .components(Clay, 1, Brick, 1) .buildAndRegister(); - Diorite = new Material.Builder(GTCEu.id("diorite")) + Diorite = REGISTRATE.material("diorite") .dust() .color(0xe9e9e9).secondaryColor(0x7b7b7b) .iconSet(ROUGH) @@ -179,7 +178,7 @@ public static void register() { .components(Mirabilite, 2, Clay, 7) .buildAndRegister(); - BlueAlloy = new Material.Builder(GTCEu.id("blue_alloy")) + BlueAlloy = REGISTRATE.material("blue_alloy") .ingot() .liquid(new FluidBuilder().temperature(1400)) .color(0x64B4FF).secondaryColor(0x3c7dba).iconSet(METALLIC) @@ -188,14 +187,14 @@ public static void register() { .cableProperties(GTValues.V[HV], 2, 1) .buildAndRegister(); - RadAway = new Material.Builder(GTCEu.id("rad_away")) + RadAway = REGISTRATE.material("rad_away") .dust() .color(0xe3a1d7).secondaryColor(0x9845a3).iconSet(ROUGH) .flags(DISABLE_DECOMPOSITION) .components(PotassiumIodide, 5, PrussianBlue, 3, DiethylenetriaminepentaaceticAcid, 5) .buildAndRegister(); - Blackstone = new Material.Builder(GTCEu.id("blackstone")) + Blackstone = REGISTRATE.material("blackstone") .dust() .color(0x3c3947).secondaryColor(0x160f10).iconSet(ROUGH) .flags(NO_SMASHING) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/materials/OrganicChemistryMaterials.java b/src/main/java/com/gregtechceu/gtceu/common/data/materials/OrganicChemistryMaterials.java index b581ac7cf73..92a7873704b 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/materials/OrganicChemistryMaterials.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/materials/OrganicChemistryMaterials.java @@ -1,7 +1,5 @@ package com.gregtechceu.gtceu.common.data.materials; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.HazardProperty; import com.gregtechceu.gtceu.api.data.chemical.material.properties.ToolProperty; import com.gregtechceu.gtceu.api.fluids.FluidBuilder; @@ -13,6 +11,7 @@ import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet.FINE; import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet.ROUGH; import static com.gregtechceu.gtceu.common.data.GTMaterials.*; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; public class OrganicChemistryMaterials { @@ -20,7 +19,7 @@ public class OrganicChemistryMaterials { * ID RANGE: 1000-1068 (incl.) */ public static void register() { - SiliconeRubber = new Material.Builder(GTCEu.id("silicone_rubber")) + SiliconeRubber = REGISTRATE.material("silicone_rubber") .polymer() .liquid(new FluidBuilder().temperature(900)) .toolStats( @@ -30,7 +29,7 @@ public static void register() { .components(Carbon, 2, Hydrogen, 6, Oxygen, 1, Silicon, 1) .buildAndRegister(); - Nitrobenzene = new Material.Builder(GTCEu.id("nitrobenzene")) + Nitrobenzene = REGISTRATE.material("nitrobenzene") .gas() .color(0x704936) .flags(DISABLE_DECOMPOSITION) @@ -38,13 +37,13 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CARCINOGEN) .buildAndRegister(); - RawRubber = new Material.Builder(GTCEu.id("raw_rubber")) + RawRubber = REGISTRATE.material("raw_rubber") .polymer() .color(0x54503D).secondaryColor(0x54403D) .components(Carbon, 5, Hydrogen, 8) .buildAndRegister(); - RawStyreneButadieneRubber = new Material.Builder(GTCEu.id("raw_styrene_butadiene_rubber")) + RawStyreneButadieneRubber = REGISTRATE.material("raw_styrene_butadiene_rubber") .dust() .color(0x54403D).secondaryColor(0x241520) .flags(DISABLE_DECOMPOSITION, FLAMMABLE) @@ -52,7 +51,7 @@ public static void register() { .buildAndRegister() .setFormula("(C4H6)3C8H8", true); - StyreneButadieneRubber = new Material.Builder(GTCEu.id("styrene_butadiene_rubber")) + StyreneButadieneRubber = REGISTRATE.material("styrene_butadiene_rubber") .polymer() .liquid(new FluidBuilder().temperature(1000)) .toolStats( @@ -63,14 +62,14 @@ public static void register() { .buildAndRegister() .setFormula("(C4H6)3C8H8", true); - PolyvinylAcetate = new Material.Builder(GTCEu.id("polyvinyl_acetate")) + PolyvinylAcetate = REGISTRATE.material("polyvinyl_acetate") .fluid() .color(0xFF9955) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 4, Hydrogen, 6, Oxygen, 2) .buildAndRegister(); - ReinforcedEpoxyResin = new Material.Builder(GTCEu.id("reinforced_epoxy_resin")) + ReinforcedEpoxyResin = REGISTRATE.material("reinforced_epoxy_resin") .polymer() .liquid(new FluidBuilder().temperature(600)) .color(0x9ecaad).secondaryColor(0xb1b2a1).iconSet(ROUGH) @@ -78,7 +77,7 @@ public static void register() { .components(Carbon, 6, Hydrogen, 4, Oxygen, 1) .buildAndRegister(); - PolyvinylChloride = new Material.Builder(GTCEu.id("polyvinyl_chloride")) + PolyvinylChloride = REGISTRATE.material("polyvinyl_chloride") .polymer() .liquid(new FluidBuilder().temperature(373)) .color(0xFF9955).secondaryColor(0x6ca5bf) @@ -87,7 +86,7 @@ public static void register() { .itemPipeProperties(512, 4) .buildAndRegister(); - PolyphenyleneSulfide = new Material.Builder(GTCEu.id("polyphenylene_sulfide")) + PolyphenyleneSulfide = REGISTRATE.material("polyphenylene_sulfide") .polymer() .liquid(new FluidBuilder().temperature(500)) .color(0x5e5e08).secondaryColor(0x2c373c) @@ -95,13 +94,13 @@ public static void register() { .components(Carbon, 6, Hydrogen, 4, Sulfur, 1) .buildAndRegister(); - GlycerylTrinitrate = new Material.Builder(GTCEu.id("glyceryl_trinitrate")) + GlycerylTrinitrate = REGISTRATE.material("glyceryl_trinitrate") .liquid(new FluidBuilder().customStill()) .flags(FLAMMABLE, EXPLOSIVE) .components(Carbon, 3, Hydrogen, 5, Nitrogen, 3, Oxygen, 9) .buildAndRegister(); - Polybenzimidazole = new Material.Builder(GTCEu.id("polybenzimidazole")) + Polybenzimidazole = REGISTRATE.material("polybenzimidazole") .polymer() .liquid(new FluidBuilder().temperature(1450)) .color(0x464441).secondaryColor(0x382e1b) @@ -113,14 +112,14 @@ public static void register() { .fluidPipeProperties(1000, 350, true) .buildAndRegister(); - Polydimethylsiloxane = new Material.Builder(GTCEu.id("polydimethylsiloxane")) + Polydimethylsiloxane = REGISTRATE.material("polydimethylsiloxane") .dust() .color(0xF5F5F5).secondaryColor(0x9d9fa1) .flags(DISABLE_DECOMPOSITION, FLAMMABLE) .components(Carbon, 2, Hydrogen, 6, Oxygen, 1, Silicon, 1) .buildAndRegister(); - Polyethylene = new Material.Builder(GTCEu.id("polyethylene")) + Polyethylene = REGISTRATE.material("polyethylene") .polymer(1) .liquid(new FluidBuilder().temperature(408)) .color(0xC8C8C8) @@ -131,7 +130,7 @@ public static void register() { .fluidPipeProperties(370, 60, true) .buildAndRegister(); - Epoxy = new Material.Builder(GTCEu.id("epoxy")) + Epoxy = REGISTRATE.material("epoxy") .polymer(1) .liquid(new FluidBuilder().temperature(400)) .color(0xf6fabd).secondaryColor(0xC88C14).iconSet(ROUGH) @@ -139,7 +138,7 @@ public static void register() { .components(Carbon, 21, Hydrogen, 25, Chlorine, 1, Oxygen, 5) .buildAndRegister(); - Polycaprolactam = new Material.Builder(GTCEu.id("polycaprolactam")) + Polycaprolactam = REGISTRATE.material("polycaprolactam") .polymer(1) .liquid(new FluidBuilder().temperature(493)) .color(0x3f3d2d).secondaryColor(0x43432e) @@ -147,7 +146,7 @@ public static void register() { .components(Carbon, 6, Hydrogen, 11, Nitrogen, 1, Oxygen, 1) .buildAndRegister(); - Polytetrafluoroethylene = new Material.Builder(GTCEu.id("polytetrafluoroethylene")) + Polytetrafluoroethylene = REGISTRATE.material("polytetrafluoroethylene") .polymer(1) .liquid(new FluidBuilder().temperature(600)) .color(0x6e6e6e).secondaryColor(0x202020) @@ -158,135 +157,135 @@ public static void register() { .fluidPipeProperties(600, 100, true, true, false, false) .buildAndRegister(); - Sugar = new Material.Builder(GTCEu.id("sugar")) + Sugar = REGISTRATE.material("sugar") .gem(1) .color(0xFFFFFF).secondaryColor(0x545468).iconSet(FINE) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 6, Hydrogen, 12, Oxygen, 6) .buildAndRegister(); - Methane = new Material.Builder(GTCEu.id("methane")) + Methane = REGISTRATE.material("methane") .gas(new FluidBuilder() .translation("gtceu.fluid.gas_generic")) .color(0xFF0078) .components(Carbon, 1, Hydrogen, 4) .buildAndRegister(); - Epichlorohydrin = new Material.Builder(GTCEu.id("epichlorohydrin")) + Epichlorohydrin = REGISTRATE.material("epichlorohydrin") .liquid(new FluidBuilder().customStill()) .color(0x712400) .components(Carbon, 3, Hydrogen, 5, Chlorine, 1, Oxygen, 1) .buildAndRegister(); - Monochloramine = new Material.Builder(GTCEu.id("monochloramine")) + Monochloramine = REGISTRATE.material("monochloramine") .gas() .color(0x3F9F80) .components(Nitrogen, 1, Hydrogen, 2, Chlorine, 1) .buildAndRegister(); - Chloroform = new Material.Builder(GTCEu.id("chloroform")) + Chloroform = REGISTRATE.material("chloroform") .fluid() .color(0x892CA0) .components(Carbon, 1, Hydrogen, 1, Chlorine, 3) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.POISON) .buildAndRegister(); - Cumene = new Material.Builder(GTCEu.id("cumene")) + Cumene = REGISTRATE.material("cumene") .gas() .color(0x552200) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 9, Hydrogen, 12) .buildAndRegister(); - Tetrafluoroethylene = new Material.Builder(GTCEu.id("tetrafluoroethylene")) + Tetrafluoroethylene = REGISTRATE.material("tetrafluoroethylene") .gas() .color(0x7D7D7D) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 2, Fluorine, 4) .buildAndRegister(); - Chloromethane = new Material.Builder(GTCEu.id("chloromethane")) + Chloromethane = REGISTRATE.material("chloromethane") .gas() .color(0xC82CA0) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 1, Hydrogen, 3, Chlorine, 1) .buildAndRegister(); - AllylChloride = new Material.Builder(GTCEu.id("allyl_chloride")) + AllylChloride = REGISTRATE.material("allyl_chloride") .fluid() .color(0x87DEAA) .components(Carbon, 2, Methane, 1, HydrochloricAcid, 1) .buildAndRegister() .setFormula("C3H5Cl", true); - Isoprene = new Material.Builder(GTCEu.id("isoprene")) + Isoprene = REGISTRATE.material("isoprene") .fluid() .color(0x141414) .components(Carbon, 5, Hydrogen, 8) .buildAndRegister(); - Propane = new Material.Builder(GTCEu.id("propane")) + Propane = REGISTRATE.material("propane") .gas() .color(0xFAE250) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 3, Hydrogen, 8) .buildAndRegister(); - Propene = new Material.Builder(GTCEu.id("propene")) + Propene = REGISTRATE.material("propene") .gas() .color(0xFFDD55) .components(Carbon, 3, Hydrogen, 6) .buildAndRegister(); - Ethane = new Material.Builder(GTCEu.id("ethane")) + Ethane = REGISTRATE.material("ethane") .gas() .color(0xC8C8FF) .components(Carbon, 2, Hydrogen, 6) .buildAndRegister(); - Butene = new Material.Builder(GTCEu.id("butene")) + Butene = REGISTRATE.material("butene") .gas() .color(0xCF5005) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 4, Hydrogen, 8) .buildAndRegister(); - Butane = new Material.Builder(GTCEu.id("butane")) + Butane = REGISTRATE.material("butane") .gas() .color(0xB6371E) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 4, Hydrogen, 10) .buildAndRegister(); - DissolvedCalciumAcetate = new Material.Builder(GTCEu.id("dissolved_calcium_acetate")) + DissolvedCalciumAcetate = REGISTRATE.material("dissolved_calcium_acetate") .fluid() .color(0xDCC8B4) .flags(DISABLE_DECOMPOSITION) .components(Calcium, 1, Carbon, 4, Oxygen, 4, Hydrogen, 6, Water, 1) .buildAndRegister(); - VinylAcetate = new Material.Builder(GTCEu.id("vinyl_acetate")) + VinylAcetate = REGISTRATE.material("vinyl_acetate") .fluid() .color(0xE1B380) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 4, Hydrogen, 6, Oxygen, 2) .buildAndRegister(); - MethylAcetate = new Material.Builder(GTCEu.id("methyl_acetate")) + MethylAcetate = REGISTRATE.material("methyl_acetate") .fluid() .color(0xEEC6AF) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 3, Hydrogen, 6, Oxygen, 2) .buildAndRegister(); - Ethenone = new Material.Builder(GTCEu.id("ethenone")) + Ethenone = REGISTRATE.material("ethenone") .fluid() .color(0x141446) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 2, Hydrogen, 2, Oxygen, 1) .buildAndRegister(); - Tetranitromethane = new Material.Builder(GTCEu.id("tetranitromethane")) + Tetranitromethane = REGISTRATE.material("tetranitromethane") .fluid() .color(0x0F2828) .flags(DISABLE_DECOMPOSITION) @@ -294,14 +293,14 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.WEAK_POISON) .buildAndRegister(); - Dimethylamine = new Material.Builder(GTCEu.id("dimethylamine")) + Dimethylamine = REGISTRATE.material("dimethylamine") .gas() .color(0x554469) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 2, Hydrogen, 7, Nitrogen, 1) .buildAndRegister(); - Dimethylhydrazine = new Material.Builder(GTCEu.id("dimethylhydrazine")) + Dimethylhydrazine = REGISTRATE.material("dimethylhydrazine") .fluid() .color(0x000055) .flags(DISABLE_DECOMPOSITION) @@ -309,48 +308,48 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CARCINOGEN) .buildAndRegister(); - DinitrogenTetroxide = new Material.Builder(GTCEu.id("dinitrogen_tetroxide")) + DinitrogenTetroxide = REGISTRATE.material("dinitrogen_tetroxide") .gas() .color(0x004184) .components(Nitrogen, 2, Oxygen, 4) .buildAndRegister(); - Dimethyldichlorosilane = new Material.Builder(GTCEu.id("dimethyldichlorosilane")) + Dimethyldichlorosilane = REGISTRATE.material("dimethyldichlorosilane") .gas() .color(0x441650) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 2, Hydrogen, 6, Chlorine, 2, Silicon, 1) .buildAndRegister(); - Styrene = new Material.Builder(GTCEu.id("styrene")) + Styrene = REGISTRATE.material("styrene") .fluid() .color(0xD2C8BE) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 8, Hydrogen, 8) .buildAndRegister(); - Butadiene = new Material.Builder(GTCEu.id("butadiene")) + Butadiene = REGISTRATE.material("butadiene") .gas() .color(0xB55A10) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 4, Hydrogen, 6) .buildAndRegister(); - Dichlorobenzene = new Material.Builder(GTCEu.id("dichlorobenzene")) + Dichlorobenzene = REGISTRATE.material("dichlorobenzene") .fluid() .color(0x004455) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 6, Hydrogen, 4, Chlorine, 2) .buildAndRegister(); - AceticAcid = new Material.Builder(GTCEu.id("acetic_acid")) + AceticAcid = REGISTRATE.material("acetic_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0xC8B4A0) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 2, Hydrogen, 4, Oxygen, 2) .buildAndRegister(); - Phenol = new Material.Builder(GTCEu.id("phenol")) + Phenol = REGISTRATE.material("phenol") .fluid() .color(0x784421) .flags(DISABLE_DECOMPOSITION) @@ -358,14 +357,14 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CARCINOGEN) .buildAndRegister(); - BisphenolA = new Material.Builder(GTCEu.id("bisphenol_a")) + BisphenolA = REGISTRATE.material("bisphenol_a") .fluid() .color(0xD4AA00) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 15, Hydrogen, 16, Oxygen, 2) .buildAndRegister(); - VinylChloride = new Material.Builder(GTCEu.id("vinyl_chloride")) + VinylChloride = REGISTRATE.material("vinyl_chloride") .gas() .color(0xE1F0F0) .flags(DISABLE_DECOMPOSITION) @@ -373,14 +372,14 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CARCINOGEN) .buildAndRegister(); - Ethylene = new Material.Builder(GTCEu.id("ethylene")) + Ethylene = REGISTRATE.material("ethylene") .gas() .color(0xE1E1E1) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 2, Hydrogen, 4) .buildAndRegister(); - Benzene = new Material.Builder(GTCEu.id("benzene")) + Benzene = REGISTRATE.material("benzene") .fluid() .color(0x1A1A1A) .flags(DISABLE_DECOMPOSITION) @@ -388,47 +387,47 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CARCINOGEN) .buildAndRegister(); - Acetone = new Material.Builder(GTCEu.id("acetone")) + Acetone = REGISTRATE.material("acetone") .fluid() .color(0xAFAFAF) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 3, Hydrogen, 6, Oxygen, 1) .buildAndRegister(); - Glycerol = new Material.Builder(GTCEu.id("glycerol")) + Glycerol = REGISTRATE.material("glycerol") .fluid() .color(0x87DE87) .components(Carbon, 3, Hydrogen, 8, Oxygen, 3) .buildAndRegister(); - Methanol = new Material.Builder(GTCEu.id("methanol")) + Methanol = REGISTRATE.material("methanol") .fluid() .color(0xAA8800) .components(Carbon, 1, Hydrogen, 4, Oxygen, 1) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.METHANOL_POISONING) .buildAndRegister(); - Ethanol = new Material.Builder(GTCEu.id("ethanol")) + Ethanol = REGISTRATE.material("ethanol") .liquid(new FluidBuilder().customStill()) .components(Carbon, 2, Hydrogen, 6, Oxygen, 1) .flags(DISABLE_DECOMPOSITION) // TODO ethanol intoxication .hazard(HazardProperty.HazardTrigger.INHALATION, .buildAndRegister(); - Toluene = new Material.Builder(GTCEu.id("toluene")) + Toluene = REGISTRATE.material("toluene") .liquid(new FluidBuilder().customStill()) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 7, Hydrogen, 8) .buildAndRegister(); - DiphenylIsophtalate = new Material.Builder(GTCEu.id("diphenyl_isophthalate")) + DiphenylIsophtalate = REGISTRATE.material("diphenyl_isophthalate") .fluid() .color(0x246E57) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 20, Hydrogen, 14, Oxygen, 4) .buildAndRegister(); - PhthalicAcid = new Material.Builder(GTCEu.id("phthalic_acid")) + PhthalicAcid = REGISTRATE.material("phthalic_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0xD1D1D1) .flags(DISABLE_DECOMPOSITION) @@ -436,7 +435,7 @@ public static void register() { .buildAndRegister() .setFormula("C6H4(CO2H)2", true); - Dimethylbenzene = new Material.Builder(GTCEu.id("dimethylbenzene")) + Dimethylbenzene = REGISTRATE.material("dimethylbenzene") .fluid() .color(0x669C40) .flags(DISABLE_DECOMPOSITION) @@ -444,7 +443,7 @@ public static void register() { .buildAndRegister() .setFormula("C6H4(CH3)2", true); - Diaminobenzidine = new Material.Builder(GTCEu.id("diaminobenzidine")) + Diaminobenzidine = REGISTRATE.material("diaminobenzidine") .fluid() .color(0x337D59) .flags(DISABLE_DECOMPOSITION) @@ -452,7 +451,7 @@ public static void register() { .buildAndRegister() .setFormula("(C6H3(NH2)2)2", true); - Dichlorobenzidine = new Material.Builder(GTCEu.id("dichlorobenzidine")) + Dichlorobenzidine = REGISTRATE.material("dichlorobenzidine") .fluid() .color(0xA1DEA6) .flags(DISABLE_DECOMPOSITION) @@ -460,14 +459,14 @@ public static void register() { .buildAndRegister() .setFormula("(C6H3Cl(NH2))2", true); - Nitrochlorobenzene = new Material.Builder(GTCEu.id("nitrochlorobenzene")) + Nitrochlorobenzene = REGISTRATE.material("nitrochlorobenzene") .fluid() .color(0x8FB51A) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 6, Hydrogen, 4, Chlorine, 1, Nitrogen, 1, Oxygen, 2) .buildAndRegister(); - Chlorobenzene = new Material.Builder(GTCEu.id("chlorobenzene")) + Chlorobenzene = REGISTRATE.material("chlorobenzene") .fluid() .color(0x326A3E) .flags(DISABLE_DECOMPOSITION) @@ -475,35 +474,35 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CARCINOGEN) .buildAndRegister(); - Octane = new Material.Builder(GTCEu.id("octane")) + Octane = REGISTRATE.material("octane") .fluid() .flags(DISABLE_DECOMPOSITION) .color(0x8A0A09) .components(Carbon, 8, Hydrogen, 18) .buildAndRegister(); - EthylTertButylEther = new Material.Builder(GTCEu.id("ethyl_tertbutyl_ether")) + EthylTertButylEther = REGISTRATE.material("ethyl_tertbutyl_ether") .fluid() .flags(DISABLE_DECOMPOSITION) .color(0xB15C06) .components(Carbon, 6, Hydrogen, 14, Oxygen, 1) .buildAndRegister(); - Ethylbenzene = new Material.Builder(GTCEu.id("ethylbenzene")) + Ethylbenzene = REGISTRATE.material("ethylbenzene") .fluid() .flags(DISABLE_DECOMPOSITION) .components(Carbon, 8, Hydrogen, 10) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CARCINOGEN) .buildAndRegister(); - Naphthalene = new Material.Builder(GTCEu.id("naphthalene")) + Naphthalene = REGISTRATE.material("naphthalene") .fluid() .flags(DISABLE_DECOMPOSITION) .color(0xF4F4D7) .components(Carbon, 10, Hydrogen, 8) .buildAndRegister(); - Rubber = new Material.Builder(GTCEu.id("rubber")) + Rubber = REGISTRATE.material("rubber") .polymer(0) .liquid(new FluidBuilder().temperature(400)) .color(0x353529).secondaryColor(0x080808) @@ -513,20 +512,20 @@ public static void register() { .components(Carbon, 5, Hydrogen, 8) .buildAndRegister(); - Cyclohexane = new Material.Builder(GTCEu.id("cyclohexane")) + Cyclohexane = REGISTRATE.material("cyclohexane") .fluid() .color(0xe8b113).secondaryColor(0x602a10) .components(Carbon, 6, Hydrogen, 12) .buildAndRegister(); - NitrosylChloride = new Material.Builder(GTCEu.id("nitrosyl_chloride")) + NitrosylChloride = REGISTRATE.material("nitrosyl_chloride") .gas() .flags(FLAMMABLE) .color(0xF3F100) .components(Nitrogen, 1, Oxygen, 1, Chlorine, 1) .buildAndRegister(); - CyclohexanoneOxime = new Material.Builder(GTCEu.id("cyclohexanone_oxime")) + CyclohexanoneOxime = REGISTRATE.material("cyclohexanone_oxime") .dust() .flags(DISABLE_DECOMPOSITION, FLAMMABLE) .color(0xEBEBF0).iconSet(ROUGH) @@ -534,7 +533,7 @@ public static void register() { .buildAndRegister() .setFormula("C6H11NO", true); - Caprolactam = new Material.Builder(GTCEu.id("caprolactam")) + Caprolactam = REGISTRATE.material("caprolactam") .dust() .flags(DISABLE_DECOMPOSITION, FLAMMABLE) .color(0xfffef8).secondaryColor(0xbab7a2) @@ -542,7 +541,7 @@ public static void register() { .buildAndRegister() .setFormula("(CH2)5C(O)NH", true); - Butyraldehyde = new Material.Builder(GTCEu.id("butyraldehyde")) + Butyraldehyde = REGISTRATE.material("butyraldehyde") .fluid() .color(0x554A3F) .flags(DISABLE_DECOMPOSITION) @@ -550,14 +549,14 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.NAUSEA, false) .buildAndRegister(); - PolyvinylButyral = new Material.Builder(GTCEu.id("polyvinyl_butyral")) + PolyvinylButyral = REGISTRATE.material("polyvinyl_butyral") .ingot().fluid() .color(0x3e7051).secondaryColor(0x535648) .flags(GENERATE_PLATE, DISABLE_DECOMPOSITION, NO_SMASHING) .components(Butyraldehyde, 1, PolyvinylAcetate, 1) .buildAndRegister(); - Biphenyl = new Material.Builder(GTCEu.id("biphenyl")) + Biphenyl = REGISTRATE.material("biphenyl") .dust() .color(0x8B8C4F).iconSet(FINE) .flags(DISABLE_DECOMPOSITION) @@ -565,7 +564,7 @@ public static void register() { .buildAndRegister() .setFormula("(C6H5)2", true); - PolychlorinatedBiphenyl = new Material.Builder(GTCEu.id("polychlorinated_biphenyl")) + PolychlorinatedBiphenyl = REGISTRATE.material("polychlorinated_biphenyl") .fluid() .color(0xCACC0E) .flags(DISABLE_DECOMPOSITION) @@ -574,7 +573,7 @@ public static void register() { .buildAndRegister() .setFormula("(C6H4Cl)2", true); - AceticAnhydride = new Material.Builder(GTCEu.id("acetic_anhydride")) + AceticAnhydride = REGISTRATE.material("acetic_anhydride") .fluid() .color(0xE0D182) .flags(DISABLE_DECOMPOSITION) @@ -582,7 +581,7 @@ public static void register() { .buildAndRegister() .setFormula("(CH3CO)2O", true); - AminoPhenol = new Material.Builder(GTCEu.id("aminophenol")) + AminoPhenol = REGISTRATE.material("aminophenol") .fluid() .color(0x784421) .flags(DISABLE_DECOMPOSITION) @@ -590,21 +589,21 @@ public static void register() { .buildAndRegister() .setFormula("H2NC6H4OH", true); - Paracetamol = new Material.Builder(GTCEu.id("paracetamol")) + Paracetamol = REGISTRATE.material("paracetamol") .dust() .color(0xF2EDCB) .flags(DISABLE_DECOMPOSITION) .components(Carbon, 8, Hydrogen, 9, Nitrogen, 1, Oxygen, 2) .buildAndRegister(); - AmmoniumFormate = new Material.Builder(GTCEu.id("ammonium_formate")) + AmmoniumFormate = REGISTRATE.material("ammonium_formate") .gas() .color(0x93badb) .components(Carbon, 1, Hydrogen, 5, Nitrogen, 1, Oxygen, 2) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.IRRITANT) .buildAndRegister(); - Formamide = new Material.Builder(GTCEu.id("formamide")) + Formamide = REGISTRATE.material("formamide") .liquid() .color(0x5cccb6) .components(Carbon, 1, Hydrogen, 3, Nitrogen, 1, Oxygen, 1) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/materials/SecondDegreeMaterials.java b/src/main/java/com/gregtechceu/gtceu/common/data/materials/SecondDegreeMaterials.java index 4ece776f76b..2104f08d17a 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/materials/SecondDegreeMaterials.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/materials/SecondDegreeMaterials.java @@ -1,7 +1,5 @@ package com.gregtechceu.gtceu.common.data.materials; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty.GasTier; import com.gregtechceu.gtceu.api.data.chemical.material.properties.HazardProperty; import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey; @@ -17,11 +15,12 @@ import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags.*; import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet.*; import static com.gregtechceu.gtceu.common.data.GTMaterials.*; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; public class SecondDegreeMaterials { public static void register() { - Glass = new Material.Builder(GTCEu.id("glass")) + Glass = REGISTRATE.material("glass") .gem(0) .liquid(new FluidBuilder() .temperature(1200) @@ -31,61 +30,61 @@ public static void register() { .components(SiliconDioxide, 1) .buildAndRegister(); - Perlite = new Material.Builder(GTCEu.id("perlite")) + Perlite = REGISTRATE.material("perlite") .dust(1) .color(0xeee0e0).secondaryColor(0xc1b9a9) .components(Obsidian, 2, Water, 1) .buildAndRegister(); - ActivatedCarbon = new Material.Builder(GTCEu.id("activated_carbon")) + ActivatedCarbon = REGISTRATE.material("activated_carbon") .dust(1) .color(0x212125).secondaryColor(0x15151a) .components(Carbon, 1) .flags(DECOMPOSITION_BY_CENTRIFUGING) .buildAndRegister(); - Borax = new Material.Builder(GTCEu.id("borax")) + Borax = REGISTRATE.material("borax") .dust(1) .color(0xFAFAFA).secondaryColor(0xd7e7e7).iconSet(FINE) .components(Sodium, 2, Boron, 4, Water, 10, Oxygen, 7) .buildAndRegister(); - SaltWater = new Material.Builder(GTCEu.id("salt_water")) + SaltWater = REGISTRATE.material("salt_water") .fluid() .color(0x0000C8) .flags(DISABLE_DECOMPOSITION) .components(Salt, 1, Water, 1) .buildAndRegister(); - Olivine = new Material.Builder(GTCEu.id("olivine")) + Olivine = REGISTRATE.material("olivine") .gem().ore(2, 1) .color(0xa7e404).secondaryColor(0x166439).iconSet(RUBY) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT) .components(Magnesium, 1, Iron, 1, SiliconDioxide, 2) .buildAndRegister(); - Opal = new Material.Builder(GTCEu.id("opal")) + Opal = REGISTRATE.material("opal") .gem().ore() .color(0xf9e3ea).secondaryColor(0x16bbe0).iconSet(OPAL) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, DECOMPOSITION_BY_CENTRIFUGING) .components(SiliconDioxide, 1) .buildAndRegister(); - Amethyst = new Material.Builder(GTCEu.id("amethyst")) + Amethyst = REGISTRATE.material("amethyst") .gem(3).ore() .color(0xcfa0f3).secondaryColor(0x734fbc).iconSet(RUBY) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, GENERATE_LENS) .components(SiliconDioxide, 4, Iron, 1) .buildAndRegister(); - EchoShard = new Material.Builder(GTCEu.id("echo_shard")) + EchoShard = REGISTRATE.material("echo_shard") .gem(3) .color(0x002b2d).iconSet(RUBY) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, GENERATE_ROD) .components(SiliconDioxide, 3, Sculk, 2) .buildAndRegister(); - Lapis = new Material.Builder(GTCEu.id("lapis")) + Lapis = REGISTRATE.material("lapis") .gem(1).ore(6, 4) .color(0x85a9ff).secondaryColor(0x2a7fff).iconSet(LAPIS) .flags(NO_SMASHING, NO_SMELTING, CRYSTALLIZABLE, NO_WORKING, DECOMPOSITION_BY_ELECTROLYZING, @@ -94,7 +93,7 @@ public static void register() { .components(Lazurite, 12, Sodalite, 2, Pyrite, 1, Calcite, 1) .buildAndRegister(); - Blaze = new Material.Builder(GTCEu.id("blaze")) + Blaze = REGISTRATE.material("blaze") .dust(1) .liquid(new FluidBuilder() .temperature(4000) @@ -104,14 +103,14 @@ public static void register() { .components(DarkAsh, 1, Sulfur, 1) .buildAndRegister(); - Apatite = new Material.Builder(GTCEu.id("apatite")) + Apatite = REGISTRATE.material("apatite") .gem(1).ore(4, 2) .color(0x06cdf1).secondaryColor(0x701c07).iconSet(DIAMOND) .flags(NO_SMASHING, NO_SMELTING, CRYSTALLIZABLE, DISABLE_DECOMPOSITION) .components(Calcium, 5, Phosphate, 3, Chlorine, 1) .buildAndRegister(); - BlackSteel = new Material.Builder(GTCEu.id("black_steel")) + BlackSteel = REGISTRATE.material("black_steel") .ingot().fluid() .color(0x666666).secondaryColor(0x1a120e).iconSet(METALLIC) .appendFlags(EXT_METAL, GENERATE_FINE_WIRE, GENERATE_GEAR, GENERATE_FRAME) @@ -120,7 +119,7 @@ public static void register() { .blast(1758, GasTier.LOW) .buildAndRegister(); - DamascusSteel = new Material.Builder(GTCEu.id("damascus_steel")) + DamascusSteel = REGISTRATE.material("damascus_steel") .ingot(3).fluid() .color(0x6E6E6E).secondaryColor(0x302222).iconSet(METALLIC) .appendFlags(EXT_METAL, GENERATE_BOLT_SCREW, GENERATE_LONG_ROD, GENERATE_GEAR) @@ -133,7 +132,7 @@ public static void register() { .blast(1500, GasTier.LOW) .buildAndRegister(); - TungstenSteel = new Material.Builder(GTCEu.id("tungsten_steel")) + TungstenSteel = REGISTRATE.material("tungsten_steel") .langValue("Tungstensteel") .ingot(4).fluid() .color(0x687ece).secondaryColor(0x03192f).iconSet(METALLIC) @@ -150,7 +149,7 @@ public static void register() { .vacuumStats(VA[HV])) .buildAndRegister(); - CobaltBrass = new Material.Builder(GTCEu.id("cobalt_brass")) + CobaltBrass = REGISTRATE.material("cobalt_brass") .ingot() .liquid(new FluidBuilder().temperature(1202)) .color(0xbaa365).secondaryColor(0x596338).iconSet(METALLIC) @@ -163,83 +162,83 @@ public static void register() { .itemPipeProperties(2048, 1) .buildAndRegister(); - TricalciumPhosphate = new Material.Builder(GTCEu.id("tricalcium_phosphate")) + TricalciumPhosphate = REGISTRATE.material("tricalcium_phosphate") .dust().ore(3, 1) .color(0xfffddb).secondaryColor(0xFFFF00).iconSet(FLINT) .flags(NO_SMASHING, NO_SMELTING, FLAMMABLE, EXPLOSIVE, DECOMPOSITION_BY_CENTRIFUGING) .components(Calcium, 3, Phosphate, 2) .buildAndRegister(); - GarnetRed = new Material.Builder(GTCEu.id("red_garnet")) + GarnetRed = REGISTRATE.material("red_garnet") .gem().ore(4, 1) .color(0x950c15).secondaryColor(0x510b04).iconSet(RUBY) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, DECOMPOSITION_BY_CENTRIFUGING) .components(Pyrope, 3, Almandine, 5, Spessartine, 8) .buildAndRegister(); - GarnetYellow = new Material.Builder(GTCEu.id("yellow_garnet")) + GarnetYellow = REGISTRATE.material("yellow_garnet") .gem().ore(4, 1) .color(0xf6ff09).secondaryColor(0xe7a800).iconSet(RUBY) .appendFlags(EXT_METAL, NO_SMASHING, NO_SMELTING, HIGH_SIFTER_OUTPUT, DECOMPOSITION_BY_CENTRIFUGING) .components(Andradite, 5, Grossular, 8, Uvarovite, 3) .buildAndRegister(); - Marble = new Material.Builder(GTCEu.id("marble")) + Marble = REGISTRATE.material("marble") .dust() .color(0xf0f5f4).secondaryColor(0xb3b3b3).iconSet(ROUGH) .flags(NO_SMASHING, DECOMPOSITION_BY_CENTRIFUGING) .components(Magnesium, 1, Calcite, 7) .buildAndRegister(); - Deepslate = new Material.Builder(GTCEu.id("deepslate")) + Deepslate = REGISTRATE.material("deepslate") .dust() .color(0x797979).secondaryColor(0x2f2f37).iconSet(ROUGH) .flags(NO_SMASHING, DECOMPOSITION_BY_CENTRIFUGING) .components(SiliconDioxide, 4, Biotite, 1) .buildAndRegister(); - GraniteRed = new Material.Builder(GTCEu.id("granite_red")) + GraniteRed = REGISTRATE.material("granite_red") .dust() .color(0xFF0080).iconSet(ROUGH) .flags(NO_SMASHING) .components(Aluminium, 2, PotassiumFeldspar, 1, Oxygen, 3) .buildAndRegister(); - VanadiumMagnetite = new Material.Builder(GTCEu.id("vanadium_magnetite")) + VanadiumMagnetite = REGISTRATE.material("vanadium_magnetite") .dust().ore() .color(0x505d70).secondaryColor(0x170322).iconSet(METALLIC) .flags(DECOMPOSITION_BY_CENTRIFUGING) .components(Magnetite, 1, Vanadium, 1) .buildAndRegister(); - QuartzSand = new Material.Builder(GTCEu.id("quartz_sand")) + QuartzSand = REGISTRATE.material("quartz_sand") .dust(1) .color(0xf8efe3).secondaryColor(0xe6c1bb).iconSet(SAND) .flags(DISABLE_DECOMPOSITION) .components(CertusQuartz, 1, Quartzite, 1) .buildAndRegister(); - Pollucite = new Material.Builder(GTCEu.id("pollucite")) + Pollucite = REGISTRATE.material("pollucite") .dust().ore() .color(0xeed9e1).secondaryColor(0x72a6a7) .components(Caesium, 2, Aluminium, 2, Silicon, 4, Water, 2, Oxygen, 12) .buildAndRegister(); - Bentonite = new Material.Builder(GTCEu.id("bentonite")) + Bentonite = REGISTRATE.material("bentonite") .dust().ore(3, 1) .color(0xede8a3).secondaryColor(0xcdb44c).iconSet(ROUGH) .flags(DISABLE_DECOMPOSITION) .components(Sodium, 1, Magnesium, 6, Silicon, 12, Hydrogen, 6, Water, 5, Oxygen, 36) .buildAndRegister(); - FullersEarth = new Material.Builder(GTCEu.id("fullers_earth")) + FullersEarth = REGISTRATE.material("fullers_earth") .langValue("Fuller's Earth") .dust().ore(2, 1) .color(0xf3efbb).secondaryColor(0xb8d066).iconSet(FINE) .components(Magnesium, 2, Silicon, 4, Oxygen, 14, Hydrogen, 4, Water, 1) .buildAndRegister(); - Pitchblende = new Material.Builder(GTCEu.id("pitchblende")) + Pitchblende = REGISTRATE.material("pitchblende") .dust(3).ore(true) .color(0xffd647).secondaryColor(0x0d1e2f) .flags(DECOMPOSITION_BY_CENTRIFUGING) @@ -247,39 +246,39 @@ public static void register() { .buildAndRegister() .setFormula("(UO2)3ThPb", true); - Monazite = new Material.Builder(GTCEu.id("monazite")) + Monazite = REGISTRATE.material("monazite") .gem(1).ore(4, 2, true) .color(0xd0ee98).secondaryColor(0x520505).iconSet(DIAMOND) .flags(NO_SMASHING, NO_SMELTING, CRYSTALLIZABLE) .components(RareEarth, 1, Phosphate, 1) .buildAndRegister(); - Mirabilite = new Material.Builder(GTCEu.id("mirabilite")) + Mirabilite = REGISTRATE.material("mirabilite") .dust() .color(0xf9e7e7).secondaryColor(0xb57a7a) .components(Sodium, 2, Sulfur, 1, Water, 10, Oxygen, 4) .buildAndRegister(); - Trona = new Material.Builder(GTCEu.id("trona")) + Trona = REGISTRATE.material("trona") .dust(1).ore(2, 1) .color(0xe6e6a5).secondaryColor(0x87875F).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) .components(Sodium, 3, Carbon, 2, Hydrogen, 1, Water, 2, Oxygen, 6) .buildAndRegister(); - Gypsum = new Material.Builder(GTCEu.id("gypsum")) + Gypsum = REGISTRATE.material("gypsum") .dust(1).ore() .color(0xfffaec).secondaryColor(0x71570a) .components(Calcium, 1, Sulfur, 1, Water, 2, Oxygen, 4) .buildAndRegister(); - Zeolite = new Material.Builder(GTCEu.id("zeolite")) + Zeolite = REGISTRATE.material("zeolite") .dust().ore(3, 1) .color(0xf2e3e0).secondaryColor(0xeabeb4) .components(Sodium, 2, Aluminium, 2, Silicon, 3, Oxygen, 10, Water, 2) .buildAndRegister(); - Concrete = new Material.Builder(GTCEu.id("concrete")) + Concrete = REGISTRATE.material("concrete") .dust() .liquid(new FluidBuilder().temperature(286)) .color(0xfaf3e8).secondaryColor(0xbbbaba).iconSet(ROUGH) @@ -287,7 +286,7 @@ public static void register() { .components(Stone, 1) .buildAndRegister(); - SteelMagnetic = new Material.Builder(GTCEu.id("magnetic_steel")) + SteelMagnetic = REGISTRATE.material("magnetic_steel") .ingot() .color(0xa7a7a7).secondaryColor(0x121c37).iconSet(MAGNETIC) .flags(GENERATE_ROD, IS_MAGNETIC, GENERATE_DENSE) @@ -298,7 +297,7 @@ public static void register() { .buildAndRegister(); Steel.getProperty(PropertyKey.INGOT).setMagneticMaterial(SteelMagnetic); - VanadiumSteel = new Material.Builder(GTCEu.id("vanadium_steel")) + VanadiumSteel = REGISTRATE.material("vanadium_steel") .ingot(3) .liquid(new FluidBuilder().temperature(2073)) .color(0xb59fcc).secondaryColor(0x19140d).iconSet(SHINY) @@ -311,7 +310,7 @@ public static void register() { .blast(1453, GasTier.LOW) .buildAndRegister(); - Potin = new Material.Builder(GTCEu.id("potin")) + Potin = REGISTRATE.material("potin") .ingot() .liquid(new FluidBuilder().temperature(1084)) .color(0xaaada3).secondaryColor(0x5e3320).iconSet(METALLIC) @@ -320,7 +319,7 @@ public static void register() { .fluidPipeProperties(1456, 40, true) .buildAndRegister(); - BorosilicateGlass = new Material.Builder(GTCEu.id("borosilicate_glass")) + BorosilicateGlass = REGISTRATE.material("borosilicate_glass") .ingot(1) .liquid(new FluidBuilder().temperature(1921)) .color(0xFAFAFA).secondaryColor(0xfaf5c0).iconSet(SHINY) @@ -328,7 +327,7 @@ public static void register() { .components(Boron, 1, SiliconDioxide, 7) .buildAndRegister(); - Andesite = new Material.Builder(GTCEu.id("andesite")) + Andesite = REGISTRATE.material("andesite") .dust() .color(0xa8aa9a).iconSet(ROUGH) .flags(DECOMPOSITION_BY_CENTRIFUGING) @@ -336,7 +335,7 @@ public static void register() { .removeHazard() .buildAndRegister(); - NaquadahAlloy = new Material.Builder(GTCEu.id("naquadah_alloy")) + NaquadahAlloy = REGISTRATE.material("naquadah_alloy") .ingot(5).fluid() .color(0x323232).secondaryColor(0x301131).iconSet(METALLIC) .appendFlags(EXT2_METAL, GENERATE_SPRING, GENERATE_RING, GENERATE_ROTOR, GENERATE_SMALL_GEAR, @@ -351,46 +350,46 @@ public static void register() { .vacuumStats(VA[IV], 300)) .buildAndRegister(); - SulfuricNickelSolution = new Material.Builder(GTCEu.id("sulfuric_nickel_solution")) + SulfuricNickelSolution = REGISTRATE.material("sulfuric_nickel_solution") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0x3EB640) .components(Nickel, 1, Oxygen, 1, SulfuricAcid, 1) .buildAndRegister(); - SulfuricCopperSolution = new Material.Builder(GTCEu.id("sulfuric_copper_solution")) + SulfuricCopperSolution = REGISTRATE.material("sulfuric_copper_solution") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0x48A5C0) .components(Copper, 1, Oxygen, 1, SulfuricAcid, 1) .buildAndRegister(); - LeadZincSolution = new Material.Builder(GTCEu.id("lead_zinc_solution")) + LeadZincSolution = REGISTRATE.material("lead_zinc_solution") .liquid(new FluidBuilder().customStill()) .flags(DECOMPOSITION_BY_CENTRIFUGING) .components(Lead, 1, Silver, 1, Zinc, 1, Sulfur, 3, Water, 1) .buildAndRegister(); - NitrationMixture = new Material.Builder(GTCEu.id("nitration_mixture")) + NitrationMixture = REGISTRATE.material("nitration_mixture") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0xE6E2AB) .flags(DISABLE_DECOMPOSITION) .components(NitricAcid, 1, SulfuricAcid, 1) .buildAndRegister(); - DilutedSulfuricAcid = new Material.Builder(GTCEu.id("diluted_sulfuric_acid")) + DilutedSulfuricAcid = REGISTRATE.material("diluted_sulfuric_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0xC07820) .flags(DISABLE_DECOMPOSITION) .components(SulfuricAcid, 2, Water, 1) .buildAndRegister(); - DilutedHydrochloricAcid = new Material.Builder(GTCEu.id("diluted_hydrochloric_acid")) + DilutedHydrochloricAcid = REGISTRATE.material("diluted_hydrochloric_acid") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0x99A7A3) .flags(DISABLE_DECOMPOSITION) .components(HydrochloricAcid, 1, Water, 1) .buildAndRegister(); - Flint = new Material.Builder(GTCEu.id("flint")) + Flint = REGISTRATE.material("flint") .gem(1) .color(0xc7c7c7).secondaryColor(0x212121).iconSet(FLINT) .flags(NO_SMASHING, MORTAR_GRINDABLE, DECOMPOSITION_BY_CENTRIFUGING) @@ -402,21 +401,21 @@ public static void register() { .enchantment(Enchantments.FIRE_ASPECT, 1).build()) .buildAndRegister(); - Air = new Material.Builder(GTCEu.id("air")) + Air = REGISTRATE.material("air") .gas(new FluidBuilder().customStill()) .color(0xA9D0F5) .flags(DISABLE_DECOMPOSITION) .components(Nitrogen, 78, Oxygen, 21, Argon, 9) .buildAndRegister(); - LiquidAir = new Material.Builder(GTCEu.id("liquid_air")) + LiquidAir = REGISTRATE.material("liquid_air") .liquid(new FluidBuilder().temperature(97)) .color(0xA9D0F5) .flags(DISABLE_DECOMPOSITION) .components(Nitrogen, 70, Oxygen, 22, CarbonDioxide, 5, Helium, 2, Argon, 1, Ice, 1) .buildAndRegister(); - NetherAir = new Material.Builder(GTCEu.id("nether_air")) + NetherAir = REGISTRATE.material("nether_air") .gas() .color(0x4C3434) .flags(DISABLE_DECOMPOSITION) @@ -424,7 +423,7 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CHEMICAL_BURNS) .buildAndRegister(); - LiquidNetherAir = new Material.Builder(GTCEu.id("liquid_nether_air")) + LiquidNetherAir = REGISTRATE.material("liquid_nether_air") .liquid(new FluidBuilder().temperature(58)) .color(0x4C3434) .flags(DISABLE_DECOMPOSITION) @@ -432,14 +431,14 @@ public static void register() { 1, Ash, 1) .buildAndRegister(); - EnderAir = new Material.Builder(GTCEu.id("ender_air")) + EnderAir = REGISTRATE.material("ender_air") .gas() .color(0x283454) .flags(DISABLE_DECOMPOSITION) .components(NitrogenDioxide, 78, Deuterium, 21, Xenon, 9) .buildAndRegister(); - LiquidEnderAir = new Material.Builder(GTCEu.id("liquid_ender_air")) + LiquidEnderAir = REGISTRATE.material("liquid_ender_air") .liquid(new FluidBuilder().temperature(36)) .color(0x283454) .flags(DISABLE_DECOMPOSITION) @@ -447,49 +446,49 @@ public static void register() { 1, EnderPearl, 1) .buildAndRegister(); - AquaRegia = new Material.Builder(GTCEu.id("aqua_regia")) + AquaRegia = REGISTRATE.material("aqua_regia") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0xFFB132) .flags(DISABLE_DECOMPOSITION) .components(NitricAcid, 1, HydrochloricAcid, 2) .buildAndRegister(); - PlatinumSludgeResidue = new Material.Builder(GTCEu.id("platinum_sludge_residue")) + PlatinumSludgeResidue = REGISTRATE.material("platinum_sludge_residue") .dust() .color(0x5e4b40).secondaryColor(0x4b403d).iconSet(FINE) .flags(DECOMPOSITION_BY_CENTRIFUGING) .components(SiliconDioxide, 2, Gold, 3) .buildAndRegister(); - PalladiumRaw = new Material.Builder(GTCEu.id("palladium_raw")) + PalladiumRaw = REGISTRATE.material("palladium_raw") .dust() .color(0x5d4e1a).secondaryColor(0x33352d).iconSet(METALLIC) .flags(DISABLE_DECOMPOSITION) .components(Palladium, 1, Ammonia, 1) .buildAndRegister(); - RarestMetalMixture = new Material.Builder(GTCEu.id("rarest_metal_mixture")) + RarestMetalMixture = REGISTRATE.material("rarest_metal_mixture") .dust() .color(0xca8832).secondaryColor(0xb21900).iconSet(SHINY) .flags(DISABLE_DECOMPOSITION) .components(Iridium, 1, Osmium, 1, Oxygen, 4, Water, 1) .buildAndRegister(); - AmmoniumChloride = new Material.Builder(GTCEu.id("ammonium_chloride")) + AmmoniumChloride = REGISTRATE.material("ammonium_chloride") .dust() .color(0x60a1c5).secondaryColor(0x48619c) .components(Ammonia, 1, HydrochloricAcid, 1) .buildAndRegister() .setFormula("NH4Cl", true); - AcidicOsmiumSolution = new Material.Builder(GTCEu.id("acidic_osmium_solution")) + AcidicOsmiumSolution = REGISTRATE.material("acidic_osmium_solution") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0xDAC5C5) .flags(DISABLE_DECOMPOSITION) .components(Osmium, 1, Oxygen, 4, Water, 1, HydrochloricAcid, 1) .buildAndRegister(); - RhodiumPlatedPalladium = new Material.Builder(GTCEu.id("rhodium_plated_palladium")) + RhodiumPlatedPalladium = REGISTRATE.material("rhodium_plated_palladium") .ingot().fluid() .color(0xd1d1d1).secondaryColor(0x000000).iconSet(SHINY) .appendFlags(EXT2_METAL, GENERATE_ROTOR, GENERATE_DENSE, GENERATE_SMALL_GEAR) @@ -500,14 +499,14 @@ public static void register() { .vacuumStats(VA[EV], 300)) .buildAndRegister(); - Clay = new Material.Builder(GTCEu.id("clay")) + Clay = REGISTRATE.material("clay") .dust(1) .color(0xbec9e8).secondaryColor(0x373944).iconSet(ROUGH) .flags(MORTAR_GRINDABLE, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES) .components(Sodium, 2, Lithium, 1, Aluminium, 2, Silicon, 2, Water, 6) .buildAndRegister(); - Redstone = new Material.Builder(GTCEu.id("redstone")) + Redstone = REGISTRATE.material("redstone") .dust().ore(5, 1, true) .liquid(new FluidBuilder().temperature(500)) .color(0xff0000).secondaryColor(0x340605).iconSet(ROUGH) @@ -517,14 +516,14 @@ public static void register() { .removeHazard() .buildAndRegister(); - Dichloroethane = new Material.Builder(GTCEu.id("dichloroethane")) + Dichloroethane = REGISTRATE.material("dichloroethane") .liquid() .color(0xafc979) .flags(DECOMPOSITION_BY_ELECTROLYZING) .components(Carbon, 2, Hydrogen, 4, Chlorine, 2) .buildAndRegister(); - Diethylenetriamine = new Material.Builder(GTCEu.id("diethylenetriamine")) + Diethylenetriamine = REGISTRATE.material("diethylenetriamine") .liquid() .color(0xa9d9a7) .flags(DISABLE_DECOMPOSITION) @@ -532,7 +531,7 @@ public static void register() { .hazard(HazardProperty.HazardTrigger.ANY, GTMedicalConditions.CHEMICAL_BURNS) .buildAndRegister(); - Tuff = new Material.Builder(GTCEu.id("tuff")) + Tuff = REGISTRATE.material("tuff") .dust() .color(0x75756a).secondaryColor(0x8a8a80).iconSet(ROUGH) .flags(NO_SMASHING) diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java b/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java index 2c0550e18f3..f76f5171e8e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java @@ -1,7 +1,5 @@ package com.gregtechceu.gtceu.common.data.materials; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.properties.HazardProperty; import com.gregtechceu.gtceu.api.data.chemical.material.properties.ToolProperty; import com.gregtechceu.gtceu.api.fluids.FluidBuilder; @@ -13,391 +11,392 @@ import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet.*; import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.*; import static com.gregtechceu.gtceu.common.data.GTMaterials.*; +import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE; public class UnknownCompositionMaterials { public static void register() { - WoodGas = new Material.Builder(GTCEu.id("wood_gas")) + WoodGas = REGISTRATE.material("wood_gas") .gas() .color(0xDECD87).secondaryColor(0xdeb287) .buildAndRegister(); - WoodVinegar = new Material.Builder(GTCEu.id("wood_vinegar")) + WoodVinegar = REGISTRATE.material("wood_vinegar") .fluid() .color(0xD45500).secondaryColor(0x905800) .buildAndRegister(); - WoodTar = new Material.Builder(GTCEu.id("wood_tar")) + WoodTar = REGISTRATE.material("wood_tar") .fluid() .color(0x3a271a).secondaryColor(0x28170B) .flags(STICKY, FLAMMABLE).buildAndRegister(); - CharcoalByproducts = new Material.Builder(GTCEu.id("charcoal_byproducts")) + CharcoalByproducts = REGISTRATE.material("charcoal_byproducts") .fluid().color(0x784421).buildAndRegister(); - Biomass = new Material.Builder(GTCEu.id("biomass")) + Biomass = REGISTRATE.material("biomass") .liquid(new FluidBuilder().customStill()).color(0x00FF00).buildAndRegister(); - BioDiesel = new Material.Builder(GTCEu.id("bio_diesel")) + BioDiesel = REGISTRATE.material("bio_diesel") .fluid().color(0xFF8000) .flags(FLAMMABLE, EXPLOSIVE).buildAndRegister(); - FermentedBiomass = new Material.Builder(GTCEu.id("fermented_biomass")) + FermentedBiomass = REGISTRATE.material("fermented_biomass") .liquid(new FluidBuilder().temperature(300)) .color(0x445500) .buildAndRegister(); - Creosote = new Material.Builder(GTCEu.id("creosote")) + Creosote = REGISTRATE.material("creosote") .liquid(new FluidBuilder().block().customStill().burnTime(6400)).color(0x804000) .flags(STICKY).buildAndRegister(); - Diesel = new Material.Builder(GTCEu.id("diesel")) + Diesel = REGISTRATE.material("diesel") .liquid(new FluidBuilder().customStill()).flags(FLAMMABLE, EXPLOSIVE).buildAndRegister(); - RocketFuel = new Material.Builder(GTCEu.id("rocket_fuel")) + RocketFuel = REGISTRATE.material("rocket_fuel") .fluid().flags(FLAMMABLE, EXPLOSIVE).color(0xBDB78C).buildAndRegister(); - Glue = new Material.Builder(GTCEu.id("glue")) + Glue = REGISTRATE.material("glue") .liquid(new FluidBuilder().customStill()).flags(STICKY).buildAndRegister(); - Lubricant = new Material.Builder(GTCEu.id("lubricant")) + Lubricant = REGISTRATE.material("lubricant") .liquid(new FluidBuilder().customStill()).buildAndRegister(); - McGuffium239 = new Material.Builder(GTCEu.id("mc_guffium_239")) + McGuffium239 = REGISTRATE.material("mc_guffium_239") .liquid(new FluidBuilder().customStill()).buildAndRegister(); - IndiumConcentrate = new Material.Builder(GTCEu.id("indium_concentrate")) + IndiumConcentrate = REGISTRATE.material("indium_concentrate") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0x0E2950).buildAndRegister(); - SeedOil = new Material.Builder(GTCEu.id("seed_oil")) + SeedOil = REGISTRATE.material("seed_oil") .liquid(new FluidBuilder().customStill()) .color(0xFFFFFF) .flags(STICKY, FLAMMABLE).buildAndRegister(); - DrillingFluid = new Material.Builder(GTCEu.id("drilling_fluid")) + DrillingFluid = REGISTRATE.material("drilling_fluid") .fluid().color(0xFFFFAA).buildAndRegister(); - ConstructionFoam = new Material.Builder(GTCEu.id("construction_foam")) + ConstructionFoam = REGISTRATE.material("construction_foam") .fluid().color(0x808080).buildAndRegister(); - SulfuricHeavyFuel = new Material.Builder(GTCEu.id("sulfuric_heavy_fuel")) + SulfuricHeavyFuel = REGISTRATE.material("sulfuric_heavy_fuel") .liquid(new FluidBuilder().customStill()).flags(FLAMMABLE).buildAndRegister(); - HeavyFuel = new Material.Builder(GTCEu.id("heavy_fuel")) + HeavyFuel = REGISTRATE.material("heavy_fuel") .liquid(new FluidBuilder().customStill()).flags(FLAMMABLE).buildAndRegister(); - LightlyHydroCrackedHeavyFuel = new Material.Builder(GTCEu.id("lightly_hydro_cracked_heavy_fuel")) + LightlyHydroCrackedHeavyFuel = REGISTRATE.material("lightly_hydro_cracked_heavy_fuel") .langValue("Lightly Hydro-Cracked Heavy Fuel") .liquid(new FluidBuilder() .temperature(775) .customStill()) .color(0xFFFF00).flags(FLAMMABLE).buildAndRegister(); - SeverelyHydroCrackedHeavyFuel = new Material.Builder(GTCEu.id("severely_hydro_cracked_heavy_fuel")) + SeverelyHydroCrackedHeavyFuel = REGISTRATE.material("severely_hydro_cracked_heavy_fuel") .langValue("Severely Hydro-Cracked Heavy Fuel") .liquid(new FluidBuilder() .temperature(775) .customStill()) .color(0xFFFF00).flags(FLAMMABLE).buildAndRegister(); - LightlySteamCrackedHeavyFuel = new Material.Builder(GTCEu.id("lightly_steam_cracked_heavy_fuel")) + LightlySteamCrackedHeavyFuel = REGISTRATE.material("lightly_steam_cracked_heavy_fuel") .langValue("Lightly Steam-Cracked Heavy Fuel") .liquid(new FluidBuilder() .temperature(775) .customStill()) .flags(FLAMMABLE).buildAndRegister(); - SeverelySteamCrackedHeavyFuel = new Material.Builder(GTCEu.id("severely_steam_cracked_heavy_fuel")) + SeverelySteamCrackedHeavyFuel = REGISTRATE.material("severely_steam_cracked_heavy_fuel") .langValue("Severely Steam-Cracked Heavy Fuel") .liquid(new FluidBuilder() .temperature(775) .customStill()) .flags(FLAMMABLE).buildAndRegister(); - SulfuricLightFuel = new Material.Builder(GTCEu.id("sulfuric_light_fuel")) + SulfuricLightFuel = REGISTRATE.material("sulfuric_light_fuel") .liquid(new FluidBuilder() .customStill()) .flags(FLAMMABLE).buildAndRegister(); - LightFuel = new Material.Builder(GTCEu.id("light_fuel")) + LightFuel = REGISTRATE.material("light_fuel") .liquid(new FluidBuilder().customStill()).flags(FLAMMABLE).buildAndRegister(); - LightlyHydroCrackedLightFuel = new Material.Builder(GTCEu.id("lightly_hydro_cracked_light_fuel")) + LightlyHydroCrackedLightFuel = REGISTRATE.material("lightly_hydro_cracked_light_fuel") .langValue("Lightly Hydro-Cracked Light Fuel") .liquid(new FluidBuilder() .temperature(775) .customStill()) .color(0xB7AF08).flags(FLAMMABLE).buildAndRegister(); - SeverelyHydroCrackedLightFuel = new Material.Builder(GTCEu.id("severely_hydro_cracked_light_fuel")) + SeverelyHydroCrackedLightFuel = REGISTRATE.material("severely_hydro_cracked_light_fuel") .langValue("Severely Hydro-Cracked Light Fuel") .liquid(new FluidBuilder() .temperature(775) .customStill()) .color(0xB7AF08).flags(FLAMMABLE).buildAndRegister(); - LightlySteamCrackedLightFuel = new Material.Builder(GTCEu.id("lightly_steam_cracked_light_fuel")) + LightlySteamCrackedLightFuel = REGISTRATE.material("lightly_steam_cracked_light_fuel") .langValue("Lightly Steam-Cracked Light Fuel") .liquid(new FluidBuilder() .temperature(775) .customStill()) .flags(FLAMMABLE).buildAndRegister(); - SeverelySteamCrackedLightFuel = new Material.Builder(GTCEu.id("severely_steam_cracked_light_fuel")) + SeverelySteamCrackedLightFuel = REGISTRATE.material("severely_steam_cracked_light_fuel") .langValue("Severely Steam-Cracked Light Fuel") .liquid(new FluidBuilder() .temperature(775) .customStill()) .flags(FLAMMABLE).buildAndRegister(); - SulfuricNaphtha = new Material.Builder(GTCEu.id("sulfuric_naphtha")) + SulfuricNaphtha = REGISTRATE.material("sulfuric_naphtha") .liquid(new FluidBuilder().customStill()).flags(FLAMMABLE).buildAndRegister(); - Naphtha = new Material.Builder(GTCEu.id("naphtha")) + Naphtha = REGISTRATE.material("naphtha") .liquid(new FluidBuilder().customStill()).flags(FLAMMABLE).buildAndRegister(); - LightlyHydroCrackedNaphtha = new Material.Builder(GTCEu.id("lightly_hydro_cracked_naphtha")) + LightlyHydroCrackedNaphtha = REGISTRATE.material("lightly_hydro_cracked_naphtha") .langValue("Lightly Hydro-Cracked Naphtha") .liquid(new FluidBuilder() .temperature(775) .customStill()) .color(0xBFB608).flags(FLAMMABLE).buildAndRegister(); - SeverelyHydroCrackedNaphtha = new Material.Builder(GTCEu.id("severely_hydro_cracked_naphtha")) + SeverelyHydroCrackedNaphtha = REGISTRATE.material("severely_hydro_cracked_naphtha") .langValue("Severely Hydro-Cracked Naphtha") .liquid(new FluidBuilder() .temperature(775) .customStill()) .color(0xBFB608).flags(FLAMMABLE).buildAndRegister(); - LightlySteamCrackedNaphtha = new Material.Builder(GTCEu.id("lightly_steam_cracked_naphtha")) + LightlySteamCrackedNaphtha = REGISTRATE.material("lightly_steam_cracked_naphtha") .langValue("Lightly Steam-Cracked Naphtha") .liquid(new FluidBuilder() .temperature(775) .customStill()) .color(0xBFB608).flags(FLAMMABLE).buildAndRegister(); - SeverelySteamCrackedNaphtha = new Material.Builder(GTCEu.id("severely_steam_cracked_naphtha")) + SeverelySteamCrackedNaphtha = REGISTRATE.material("severely_steam_cracked_naphtha") .langValue("Severely Steam-Cracked Naphtha") .liquid(new FluidBuilder() .temperature(775) .customStill()) .color(0xBFB608).flags(FLAMMABLE).buildAndRegister(); - SulfuricGas = new Material.Builder(GTCEu.id("sulfuric_gas")) + SulfuricGas = REGISTRATE.material("sulfuric_gas") .gas(new FluidBuilder().customStill()) .color(0xECDCCC).buildAndRegister(); - RefineryGas = new Material.Builder(GTCEu.id("refinery_gas")) + RefineryGas = REGISTRATE.material("refinery_gas") .gas(new FluidBuilder().customStill()) .color(0xB4B4B4) .flags(FLAMMABLE) .buildAndRegister(); - LightlyHydroCrackedGas = new Material.Builder(GTCEu.id("lightly_hydro_cracked_gas")) + LightlyHydroCrackedGas = REGISTRATE.material("lightly_hydro_cracked_gas") .langValue("Lightly Hydro-Cracked Gas") .gas(new FluidBuilder().temperature(775)) .color(0xA0A0A0) .flags(FLAMMABLE) .buildAndRegister(); - SeverelyHydroCrackedGas = new Material.Builder(GTCEu.id("severely_hydro_cracked_gas")) + SeverelyHydroCrackedGas = REGISTRATE.material("severely_hydro_cracked_gas") .langValue("Severely Hydro-Cracked Gas") .gas(new FluidBuilder().temperature(775)) .color(0xC8C8C8) .flags(FLAMMABLE) .buildAndRegister(); - LightlySteamCrackedGas = new Material.Builder(GTCEu.id("lightly_steam_cracked_gas")) + LightlySteamCrackedGas = REGISTRATE.material("lightly_steam_cracked_gas") .langValue("Lightly Steam-Cracked Gas") .gas(new FluidBuilder().temperature(775)) .color(0xE0E0E0) .flags(FLAMMABLE) .buildAndRegister(); - SeverelySteamCrackedGas = new Material.Builder(GTCEu.id("severely_steam_cracked_gas")) + SeverelySteamCrackedGas = REGISTRATE.material("severely_steam_cracked_gas") .langValue("Severely Steam-Cracked Gas") .gas(new FluidBuilder().temperature(775)) .color(0xE0E0E0).flags(FLAMMABLE).buildAndRegister(); - HydroCrackedEthane = new Material.Builder(GTCEu.id("hydro_cracked_ethane")) + HydroCrackedEthane = REGISTRATE.material("hydro_cracked_ethane") .langValue("Hydro-Cracked Ethane") .gas(new FluidBuilder().temperature(775)) .color(0x9696BC).flags(FLAMMABLE).buildAndRegister(); - HydroCrackedEthylene = new Material.Builder(GTCEu.id("hydro_cracked_ethylene")) + HydroCrackedEthylene = REGISTRATE.material("hydro_cracked_ethylene") .langValue("Hydro-Cracked Ethylene") .gas(new FluidBuilder().temperature(775)) .color(0xA3A3A0).flags(FLAMMABLE).buildAndRegister(); - HydroCrackedPropene = new Material.Builder(GTCEu.id("hydro_cracked_propene")) + HydroCrackedPropene = REGISTRATE.material("hydro_cracked_propene") .langValue("Hydro-Cracked Propene") .gas(new FluidBuilder().temperature(775)) .color(0xBEA540).flags(FLAMMABLE).buildAndRegister(); - HydroCrackedPropane = new Material.Builder(GTCEu.id("hydro_cracked_propane")) + HydroCrackedPropane = REGISTRATE.material("hydro_cracked_propane") .langValue("Hydro-Cracked Propane") .gas(new FluidBuilder().temperature(775)) .color(0xBEA540).flags(FLAMMABLE).buildAndRegister(); - HydroCrackedButane = new Material.Builder(GTCEu.id("hydro_cracked_butane")) + HydroCrackedButane = REGISTRATE.material("hydro_cracked_butane") .langValue("Hydro-Cracked Butane") .gas(new FluidBuilder().temperature(775)) .color(0x852C18).flags(FLAMMABLE).buildAndRegister(); - HydroCrackedButene = new Material.Builder(GTCEu.id("hydro_cracked_butene")) + HydroCrackedButene = REGISTRATE.material("hydro_cracked_butene") .langValue("Hydro-Cracked Butene") .gas(new FluidBuilder().temperature(775)) .color(0x993E05).flags(FLAMMABLE).buildAndRegister(); - HydroCrackedButadiene = new Material.Builder(GTCEu.id("hydro_cracked_butadiene")) + HydroCrackedButadiene = REGISTRATE.material("hydro_cracked_butadiene") .langValue("Hydro-Cracked Butadiene") .gas(new FluidBuilder().temperature(775)) .color(0xAD5203).flags(FLAMMABLE).buildAndRegister(); - SteamCrackedEthane = new Material.Builder(GTCEu.id("steam_cracked_ethane")) + SteamCrackedEthane = REGISTRATE.material("steam_cracked_ethane") .langValue("Steam-Cracked Ethane") .gas(new FluidBuilder().temperature(775)) .color(0x9696BC).flags(FLAMMABLE).buildAndRegister(); - SteamCrackedEthylene = new Material.Builder(GTCEu.id("steam_cracked_ethylene")) + SteamCrackedEthylene = REGISTRATE.material("steam_cracked_ethylene") .langValue("Steam-Cracked Ethylene") .gas(new FluidBuilder().temperature(775)) .color(0xA3A3A0).flags(FLAMMABLE).buildAndRegister(); - SteamCrackedPropene = new Material.Builder(GTCEu.id("steam_cracked_propene")) + SteamCrackedPropene = REGISTRATE.material("steam_cracked_propene") .langValue("Steam-Cracked Propene") .gas(new FluidBuilder().temperature(775)) .color(0xBEA540).flags(FLAMMABLE).buildAndRegister(); - SteamCrackedPropane = new Material.Builder(GTCEu.id("steam_cracked_propane")) + SteamCrackedPropane = REGISTRATE.material("steam_cracked_propane") .langValue("Steam-Cracked Propane") .gas(new FluidBuilder().temperature(775)) .color(0xBEA540).flags(FLAMMABLE).buildAndRegister(); - SteamCrackedButane = new Material.Builder(GTCEu.id("steam_cracked_butane")) + SteamCrackedButane = REGISTRATE.material("steam_cracked_butane") .langValue("Steam-Cracked Butane") .gas(new FluidBuilder().temperature(775)) .color(0x852C18).flags(FLAMMABLE).buildAndRegister(); - SteamCrackedButene = new Material.Builder(GTCEu.id("steam_cracked_butene")) + SteamCrackedButene = REGISTRATE.material("steam_cracked_butene") .langValue("Steam-Cracked Butene") .gas(new FluidBuilder().temperature(775)) .color(0x993E05).flags(FLAMMABLE).buildAndRegister(); - SteamCrackedButadiene = new Material.Builder(GTCEu.id("steam_cracked_butadiene")) + SteamCrackedButadiene = REGISTRATE.material("steam_cracked_butadiene") .langValue("Steam-Cracked Butadiene") .gas(new FluidBuilder().temperature(775)) .color(0xAD5203).flags(FLAMMABLE).buildAndRegister(); - LPG = new Material.Builder(GTCEu.id("lpg")) + LPG = REGISTRATE.material("lpg") .langValue("LPG") .liquid(new FluidBuilder().customStill()) .color(0xFCFCAC).flags(FLAMMABLE, EXPLOSIVE).buildAndRegister(); - RawGrowthMedium = new Material.Builder(GTCEu.id("raw_growth_medium")) + RawGrowthMedium = REGISTRATE.material("raw_growth_medium") .fluid().color(0xA47351).buildAndRegister(); - SterileGrowthMedium = new Material.Builder(GTCEu.id("sterilized_growth_medium")) + SterileGrowthMedium = REGISTRATE.material("sterilized_growth_medium") .fluid().color(0xAC876E).buildAndRegister(); - Oil = new Material.Builder(GTCEu.id("oil")) + Oil = REGISTRATE.material("oil") .liquid(new FluidBuilder().block().customStill()) .color(0x0A0A0A) .flags(STICKY, FLAMMABLE) .buildAndRegister(); - OilHeavy = new Material.Builder(GTCEu.id("oil_heavy")) + OilHeavy = REGISTRATE.material("oil_heavy") .langValue("Heavy Oil") .liquid(new FluidBuilder().block().customStill()) .color(0x0A0A0A) .flags(STICKY, FLAMMABLE) .buildAndRegister(); - RawOil = new Material.Builder(GTCEu.id("oil_medium")) + RawOil = REGISTRATE.material("oil_medium") .langValue("Raw Oil") .liquid(new FluidBuilder().block().customStill()) .color(0x0A0A0A) .flags(STICKY, FLAMMABLE) .buildAndRegister(); - OilLight = new Material.Builder(GTCEu.id("oil_light")) + OilLight = REGISTRATE.material("oil_light") .langValue("Light Oil") .liquid(new FluidBuilder().block().customStill()) .color(0x0A0A0A) .flags(STICKY, FLAMMABLE) .buildAndRegister(); - NaturalGas = new Material.Builder(GTCEu.id("natural_gas")) + NaturalGas = REGISTRATE.material("natural_gas") .gas(new FluidBuilder().block().customStill()) .flags(FLAMMABLE, EXPLOSIVE).buildAndRegister(); - Bacteria = new Material.Builder(GTCEu.id("bacteria")) + Bacteria = REGISTRATE.material("bacteria") .fluid().color(0x808000).buildAndRegister(); - BacterialSludge = new Material.Builder(GTCEu.id("bacterial_sludge")) + BacterialSludge = REGISTRATE.material("bacterial_sludge") .fluid().color(0x355E3B).buildAndRegister(); - EnrichedBacterialSludge = new Material.Builder(GTCEu.id("enriched_bacterial_sludge")) + EnrichedBacterialSludge = REGISTRATE.material("enriched_bacterial_sludge") .fluid().color(0x7FFF00).buildAndRegister(); - Mutagen = new Material.Builder(GTCEu.id("mutagen")) + Mutagen = REGISTRATE.material("mutagen") .fluid().color(0x00FF7F).buildAndRegister(); - GelatinMixture = new Material.Builder(GTCEu.id("gelatin_mixture")) + GelatinMixture = REGISTRATE.material("gelatin_mixture") .fluid().color(0x588BAE).buildAndRegister(); - RawGasoline = new Material.Builder(GTCEu.id("raw_gasoline")) + RawGasoline = REGISTRATE.material("raw_gasoline") .fluid().color(0xFF6400).flags(FLAMMABLE).buildAndRegister(); - Gasoline = new Material.Builder(GTCEu.id("gasoline")) + Gasoline = REGISTRATE.material("gasoline") .fluid().color(0xFAA500).flags(FLAMMABLE, EXPLOSIVE).buildAndRegister(); - HighOctaneGasoline = new Material.Builder(GTCEu.id("high_octane_gasoline")) + HighOctaneGasoline = REGISTRATE.material("high_octane_gasoline") .fluid().color(0xFFA500).flags(FLAMMABLE, EXPLOSIVE).buildAndRegister(); - CoalGas = new Material.Builder(GTCEu.id("coal_gas")) + CoalGas = REGISTRATE.material("coal_gas") .gas().color(0x333333).buildAndRegister(); - CoalTar = new Material.Builder(GTCEu.id("coal_tar")) + CoalTar = REGISTRATE.material("coal_tar") .fluid().color(0x1A1A1A).flags(STICKY, FLAMMABLE).buildAndRegister(); - Gunpowder = new Material.Builder(GTCEu.id("gunpowder")) + Gunpowder = REGISTRATE.material("gunpowder") .dust(0) .color(0xa4a4a4).secondaryColor(0x767676).iconSet(ROUGH) .flags(FLAMMABLE, EXPLOSIVE, NO_SMELTING, NO_SMASHING) .components(Saltpeter, 2, Sulfur, 1, Carbon, 3) .buildAndRegister(); - Oilsands = new Material.Builder(GTCEu.id("oilsands")) + Oilsands = REGISTRATE.material("oilsands") .dust(1).ore() .color(0xe3c78a).secondaryColor(0x161e22).iconSet(SAND) .flags(FLAMMABLE) .buildAndRegister(); - RareEarth = new Material.Builder(GTCEu.id("rare_earth")) + RareEarth = REGISTRATE.material("rare_earth") .dust(0) .color(0xffdc88).secondaryColor(0xe99673).iconSet(FINE) .buildAndRegister(); - Stone = new Material.Builder(GTCEu.id("stone")) + Stone = REGISTRATE.material("stone") .dust(2) .color(0x8f8f8f).secondaryColor(0x898989).iconSet(ROUGH) .flags(MORTAR_GRINDABLE, GENERATE_GEAR, NO_SMASHING, NO_SMELTING) .buildAndRegister(); - Lava = new Material.Builder(GTCEu.id("lava")) + Lava = REGISTRATE.material("lava") .fluid().color(0xFF4000).buildAndRegister(); - Netherite = new Material.Builder(GTCEu.id("netherite")) + Netherite = REGISTRATE.material("netherite") .ingot().color(0x4b4042).secondaryColor(0x474447) .flags(FIRE_RESISTANT) .toolStats(ToolProperty.Builder.of(10.0F, 4.0F, 2032, 4) .enchantability(21).build()) .buildAndRegister(); - Glowstone = new Material.Builder(GTCEu.id("glowstone")) + Glowstone = REGISTRATE.material("glowstone") .dust(1) .liquid(new FluidBuilder().temperature(500)) .color(0xfcb34c).secondaryColor(0xce7533).iconSet(SHINY) @@ -405,69 +404,69 @@ public static void register() { EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES) .buildAndRegister(); - NetherStar = new Material.Builder(GTCEu.id("nether_star")) + NetherStar = REGISTRATE.material("nether_star") .gem(4) .color(0xfeffc6).secondaryColor(0x7fd7e2) .iconSet(NETHERSTAR) .flags(NO_SMASHING, NO_SMELTING, GENERATE_LENS) .buildAndRegister(); - Endstone = new Material.Builder(GTCEu.id("endstone")) + Endstone = REGISTRATE.material("endstone") .dust(1) .color(0xf6fabd).secondaryColor(0xc5be8b).iconSet(ROUGH) .flags(NO_SMASHING) .buildAndRegister(); - Netherrack = new Material.Builder(GTCEu.id("netherrack")) + Netherrack = REGISTRATE.material("netherrack") .dust(1) .color(0x7c4249).secondaryColor(0x400b0b).iconSet(ROUGH) .flags(NO_SMASHING, FLAMMABLE) .buildAndRegister(); - CetaneBoostedDiesel = new Material.Builder(GTCEu.id("cetane_boosted_diesel")) + CetaneBoostedDiesel = REGISTRATE.material("cetane_boosted_diesel") .liquid(new FluidBuilder().customStill()) .color(0xC8FF00) .flags(FLAMMABLE, EXPLOSIVE) .buildAndRegister(); - Collagen = new Material.Builder(GTCEu.id("collagen")) + Collagen = REGISTRATE.material("collagen") .dust(1) .color(0xffadb7).secondaryColor(0x80471C).iconSet(ROUGH) .buildAndRegister(); - Gelatin = new Material.Builder(GTCEu.id("gelatin")) + Gelatin = REGISTRATE.material("gelatin") .dust(1) .color(0xfaf7cb).secondaryColor(0x693d00).iconSet(ROUGH) .buildAndRegister(); - Agar = new Material.Builder(GTCEu.id("agar")) + Agar = REGISTRATE.material("agar") .dust(1) .color(0xbdd168).secondaryColor(0x403218).iconSet(ROUGH) .buildAndRegister(); - Milk = new Material.Builder(GTCEu.id("milk")) + Milk = REGISTRATE.material("milk") .liquid(new FluidBuilder() .temperature(295) .customStill()) .color(0xfffbf0).secondaryColor(0xf6eac8).iconSet(FINE) .buildAndRegister(); - Cocoa = new Material.Builder(GTCEu.id("cocoa")) + Cocoa = REGISTRATE.material("cocoa") .dust(0) .color(0x976746).secondaryColor(0x301a0a).iconSet(FINE) .buildAndRegister(); - Wheat = new Material.Builder(GTCEu.id("wheat")) + Wheat = REGISTRATE.material("wheat") .dust(0) .color(0xdcbb65).secondaryColor(0x565138).iconSet(FINE) .buildAndRegister(); - Meat = new Material.Builder(GTCEu.id("meat")) + Meat = REGISTRATE.material("meat") .dust(1) .color(0xe85048).secondaryColor(0x470a06).iconSet(SAND) .buildAndRegister(); - Wood = new Material.Builder(GTCEu.id("wood")) + Wood = REGISTRATE.material("wood") .wood() .color(0xc29f6d).secondaryColor(0x643200).iconSet(WOOD) .fluidPipeProperties(340, 5, false) @@ -476,163 +475,163 @@ public static void register() { GENERATE_FRAME) .buildAndRegister(); - Paper = new Material.Builder(GTCEu.id("paper")) + Paper = REGISTRATE.material("paper") .dust(0) .color(0xF9F9F9).secondaryColor(0xECECEC).iconSet(DULL) .flags(GENERATE_PLATE, FLAMMABLE, NO_SMELTING, NO_SMASHING, MORTAR_GRINDABLE, EXCLUDE_PLATE_COMPRESSOR_RECIPE) .buildAndRegister(); - FishOil = new Material.Builder(GTCEu.id("fish_oil")) + FishOil = REGISTRATE.material("fish_oil") .fluid() .color(0xDCC15D) .flags(STICKY, FLAMMABLE) .buildAndRegister(); - RubySlurry = new Material.Builder(GTCEu.id("ruby_slurry")) + RubySlurry = REGISTRATE.material("ruby_slurry") .fluid().color(0xff6464).buildAndRegister(); - SapphireSlurry = new Material.Builder(GTCEu.id("sapphire_slurry")) + SapphireSlurry = REGISTRATE.material("sapphire_slurry") .fluid().color(0x6464c8).buildAndRegister(); - GreenSapphireSlurry = new Material.Builder(GTCEu.id("green_sapphire_slurry")) + GreenSapphireSlurry = REGISTRATE.material("green_sapphire_slurry") .fluid().color(0x64c882).buildAndRegister(); // These colors are much nicer looking than those in MC's EnumDyeColor - DyeBlack = new Material.Builder(GTCEu.id("black_dye")) + DyeBlack = REGISTRATE.material("black_dye") .fluid().color(0x202020).buildAndRegister(); - DyeRed = new Material.Builder(GTCEu.id("red_dye")) + DyeRed = REGISTRATE.material("red_dye") .fluid().color(0xFF0000).buildAndRegister(); - DyeGreen = new Material.Builder(GTCEu.id("green_dye")) + DyeGreen = REGISTRATE.material("green_dye") .fluid().color(0x00FF00).buildAndRegister(); - DyeBrown = new Material.Builder(GTCEu.id("brown_dye")) + DyeBrown = REGISTRATE.material("brown_dye") .fluid().color(0x604000).buildAndRegister(); - DyeBlue = new Material.Builder(GTCEu.id("blue_dye")) + DyeBlue = REGISTRATE.material("blue_dye") .fluid().color(0x0020FF).buildAndRegister(); - DyePurple = new Material.Builder(GTCEu.id("purple_dye")) + DyePurple = REGISTRATE.material("purple_dye") .fluid().color(0x800080).buildAndRegister(); - DyeCyan = new Material.Builder(GTCEu.id("cyan_dye")) + DyeCyan = REGISTRATE.material("cyan_dye") .fluid().color(0x00FFFF).buildAndRegister(); - DyeLightGray = new Material.Builder(GTCEu.id("light_gray_dye")) + DyeLightGray = REGISTRATE.material("light_gray_dye") .fluid().color(0xC0C0C0).buildAndRegister(); - DyeGray = new Material.Builder(GTCEu.id("gray_dye")) + DyeGray = REGISTRATE.material("gray_dye") .fluid().color(0x808080).buildAndRegister(); - DyePink = new Material.Builder(GTCEu.id("pink_dye")) + DyePink = REGISTRATE.material("pink_dye") .fluid().color(0xFFC0C0).buildAndRegister(); - DyeLime = new Material.Builder(GTCEu.id("lime_dye")) + DyeLime = REGISTRATE.material("lime_dye") .fluid().color(0x80FF80).buildAndRegister(); - DyeYellow = new Material.Builder(GTCEu.id("yellow_dye")) + DyeYellow = REGISTRATE.material("yellow_dye") .fluid().color(0xFFFF00).buildAndRegister(); - DyeLightBlue = new Material.Builder(GTCEu.id("light_blue_dye")) + DyeLightBlue = REGISTRATE.material("light_blue_dye") .fluid().color(0x6080FF).buildAndRegister(); - DyeMagenta = new Material.Builder(GTCEu.id("magenta_dye")) + DyeMagenta = REGISTRATE.material("magenta_dye") .fluid().color(0xFF00FF).buildAndRegister(); - DyeOrange = new Material.Builder(GTCEu.id("orange_dye")) + DyeOrange = REGISTRATE.material("orange_dye") .fluid().color(0xFF8000).buildAndRegister(); - DyeWhite = new Material.Builder(GTCEu.id("white_dye")) + DyeWhite = REGISTRATE.material("white_dye") .fluid().color(0xFFFFFF).buildAndRegister(); - ImpureEnrichedNaquadahSolution = new Material.Builder(GTCEu.id("impure_enriched_naquadah_solution")) + ImpureEnrichedNaquadahSolution = REGISTRATE.material("impure_enriched_naquadah_solution") .fluid().color(0x388438).buildAndRegister(); - EnrichedNaquadahSolution = new Material.Builder(GTCEu.id("enriched_naquadah_solution")) + EnrichedNaquadahSolution = REGISTRATE.material("enriched_naquadah_solution") .fluid().color(0x3AAD3A).buildAndRegister(); - AcidicEnrichedNaquadahSolution = new Material.Builder(GTCEu.id("acidic_enriched_naquadah_solution")) + AcidicEnrichedNaquadahSolution = REGISTRATE.material("acidic_enriched_naquadah_solution") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0x3DD63D).buildAndRegister(); - EnrichedNaquadahWaste = new Material.Builder(GTCEu.id("enriched_naquadah_waste")) + EnrichedNaquadahWaste = REGISTRATE.material("enriched_naquadah_waste") .fluid().color(0x355B35).buildAndRegister(); - ImpureNaquadriaSolution = new Material.Builder(GTCEu.id("impure_naquadria_solution")) + ImpureNaquadriaSolution = REGISTRATE.material("impure_naquadria_solution") .fluid().color(0x518451).buildAndRegister(); - NaquadriaSolution = new Material.Builder(GTCEu.id("naquadria_solution")) + NaquadriaSolution = REGISTRATE.material("naquadria_solution") .fluid().color(0x61AD61).buildAndRegister(); - AcidicNaquadriaSolution = new Material.Builder(GTCEu.id("acidic_naquadria_solution")) + AcidicNaquadriaSolution = REGISTRATE.material("acidic_naquadria_solution") .liquid(new FluidBuilder().attribute(FluidAttributes.ACID)) .color(0x70D670).buildAndRegister(); - NaquadriaWaste = new Material.Builder(GTCEu.id("naquadria_waste")) + NaquadriaWaste = REGISTRATE.material("naquadria_waste") .fluid().color(0x425B42).buildAndRegister(); - Lapotron = new Material.Builder(GTCEu.id("lapotron")) + Lapotron = REGISTRATE.material("lapotron") .gem() .color(0x7497ea).secondaryColor(0x1c0b39).iconSet(DIAMOND) .flags(DISABLE_MATERIAL_RECIPES) .ignoredTagPrefixes(dustTiny, dustSmall) .buildAndRegister(); - TreatedWood = new Material.Builder(GTCEu.id("treated_wood")) + TreatedWood = REGISTRATE.material("treated_wood") .wood() .color(0x644218).secondaryColor(0x4e0b00).iconSet(WOOD) .fluidPipeProperties(340, 10, false) .flags(GENERATE_PLATE, FLAMMABLE, GENERATE_ROD, GENERATE_FRAME) .buildAndRegister(); - UUMatter = new Material.Builder(GTCEu.id("uu_matter")) + UUMatter = REGISTRATE.material("uu_matter") .langValue("UU-Matter") .liquid(new FluidBuilder() .temperature(300) .customStill()) .buildAndRegister(); - PCBCoolant = new Material.Builder(GTCEu.id("pcb_coolant")) + PCBCoolant = REGISTRATE.material("pcb_coolant") .langValue("PCB Coolant") .fluid().color(0xD5D69C) .hazard(HazardProperty.HazardTrigger.INHALATION, GTMedicalConditions.CARCINOGEN) .buildAndRegister(); - Sculk = new Material.Builder(GTCEu.id("sculk")) + Sculk = REGISTRATE.material("sculk") .dust(1) .color(0x015a5c).secondaryColor(0x001616).iconSet(ROUGH) .buildAndRegister(); - Wax = new Material.Builder(GTCEu.id("wax")) + Wax = REGISTRATE.material("wax") .ingot().fluid() .color(0xfabf29) .flags(NO_SMELTING) .buildAndRegister(); - BauxiteSlurry = new Material.Builder(GTCEu.id("bauxite_slurry")) + BauxiteSlurry = REGISTRATE.material("bauxite_slurry") .fluid() .color(0x051650) .buildAndRegister(); - CrackedBauxiteSlurry = new Material.Builder(GTCEu.id("cracked_bauxite_slurry")) + CrackedBauxiteSlurry = REGISTRATE.material("cracked_bauxite_slurry") .liquid(new FluidBuilder() .temperature(775)) .color(0x052C50) .buildAndRegister(); - BauxiteSludge = new Material.Builder(GTCEu.id("bauxite_sludge")) + BauxiteSludge = REGISTRATE.material("bauxite_sludge") .fluid() .color(0x563D2D) .buildAndRegister(); - DecalcifiedBauxiteSludge = new Material.Builder(GTCEu.id("decalcified_bauxite_sludge")) + DecalcifiedBauxiteSludge = REGISTRATE.material("decalcified_bauxite_sludge") .fluid() .color(0x6F2DA8) .buildAndRegister(); - BauxiteSlag = new Material.Builder(GTCEu.id("bauxite_slag")) + BauxiteSlag = REGISTRATE.material("bauxite_slag") .dust() .color(0x6F2DA8).iconSet(SAND) .buildAndRegister(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/behavior/AntidoteBehavior.java b/src/main/java/com/gregtechceu/gtceu/common/item/behavior/AntidoteBehavior.java index 46d2ecb969e..f1fff06720d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/behavior/AntidoteBehavior.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/behavior/AntidoteBehavior.java @@ -16,8 +16,6 @@ import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -28,12 +26,11 @@ * @param removePercent how many 'counts' should be removed from the chosen condition(s), * as a percentage of the current 'counts' in the range [0, 100]. -1 for all. */ -public record AntidoteBehavior(Set types, int removePercent) +public record AntidoteBehavior(int removePercent, Set types) implements IInteractionItem, IAddInformation { public AntidoteBehavior(int removePercent, MedicalCondition... types) { - this(new HashSet<>(), removePercent); - this.types.addAll(Arrays.asList(types)); + this(removePercent, Set.of(types)); } @Override @@ -48,7 +45,7 @@ public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity livi if (condition == null) { continue; } - if (!this.types.contains(condition)) { + if (!types.contains(condition)) { continue; } if (removePercent == -1) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/item/behavior/CoverPlaceBehavior.java b/src/main/java/com/gregtechceu/gtceu/common/item/behavior/CoverPlaceBehavior.java index 57aee262726..f7f2be87bec 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/item/behavior/CoverPlaceBehavior.java +++ b/src/main/java/com/gregtechceu/gtceu/common/item/behavior/CoverPlaceBehavior.java @@ -8,6 +8,7 @@ import com.gregtechceu.gtceu.api.item.component.IItemComponent; import com.gregtechceu.gtceu.api.item.tool.GTToolType; +import net.minecraft.core.Holder; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.Item; @@ -18,8 +19,17 @@ import java.util.function.BooleanSupplier; import java.util.function.Predicate; +import java.util.function.Supplier; -public record CoverPlaceBehavior(CoverDefinition coverDefinition) implements IInteractionItem { +public record CoverPlaceBehavior(Supplier coverDefinition) implements IInteractionItem { + + public CoverPlaceBehavior(CoverDefinition coverDefinition) { + this(() -> coverDefinition); + } + + public CoverPlaceBehavior(Holder coverDefinitionHolder) { + this(coverDefinitionHolder.value()); + } @Override public InteractionResult onItemUseFirst(ItemStack itemStack, UseOnContext context) { @@ -31,9 +41,10 @@ public InteractionResult onItemUseFirst(ItemStack itemStack, UseOnContext contex if (coverable != null) { var coverSide = ICoverable.rayTraceCoverableSide(coverable, player); if (coverSide != null && coverable.getCoverAtSide(coverSide) == null && - coverable.canPlaceCoverOnSide(coverDefinition, coverSide)) { + coverable.canPlaceCoverOnSide(coverDefinition.get(), coverSide)) { if (player instanceof ServerPlayer serverPlayer) { - boolean result = coverable.placeCoverOnSide(coverSide, itemStack, coverDefinition, serverPlayer); + boolean result = coverable.placeCoverOnSide(coverSide, itemStack, coverDefinition.get(), + serverPlayer); if (result && !player.isCreative()) { itemStack.shrink(1); } @@ -51,7 +62,7 @@ public static boolean isCoverBehaviorItem(ItemStack itemStack, @Nullable Boolean if (item instanceof IComponentItem componentItem) { for (IItemComponent component : componentItem.getComponents()) { if (component instanceof CoverPlaceBehavior placeBehavior) { - if (canPlaceCover == null || canPlaceCover.test(placeBehavior.coverDefinition)) { + if (canPlaceCover == null || canPlaceCover.test(placeBehavior.coverDefinition.get())) { return true; } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ConverterMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ConverterMachine.java index e50d7a9157d..950604cd222 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ConverterMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/ConverterMachine.java @@ -16,6 +16,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BooleanProperty; @@ -94,12 +95,13 @@ public boolean isFacingValid(Direction facing) { @Override public @Nullable UITexture sideTips(Player player, BlockPos pos, BlockState state, Set toolTypes, + ItemStack held, Direction side) { if (toolTypes.contains(GTToolType.SOFT_MALLET)) { return this.isFeToEu() ? GTGuiTextures.TOOL_SWITCH_CONVERTER_NATIVE : GTGuiTextures.TOOL_SWITCH_CONVERTER_EU; } - return super.sideTips(player, pos, state, toolTypes, side); + return super.sideTips(player, pos, state, toolTypes, held, side); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/WorldAcceleratorMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/WorldAcceleratorMachine.java index b1293bd1c90..6503888e21e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/electric/WorldAcceleratorMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/electric/WorldAcceleratorMachine.java @@ -26,6 +26,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -218,11 +219,12 @@ public void setWorkingEnabled(boolean workingEnabled) { @Override public @Nullable UITexture sideTips(Player player, BlockPos pos, BlockState state, Set toolTypes, + ItemStack held, Direction side) { if (toolTypes.contains(GTToolType.SOFT_MALLET)) { return isWorkingEnabled ? GTGuiTextures.TOOL_PAUSE : GTGuiTextures.TOOL_START; } - return super.sideTips(player, pos, state, toolTypes, side); + return super.sideTips(player, pos, state, toolTypes, held, side); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumChestMachine.java b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumChestMachine.java index a758496f203..c64bd3e2446 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumChestMachine.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/storage/QuantumChestMachine.java @@ -307,11 +307,12 @@ private IWidget createPhantomLockeditemSlot(PanelSyncManager syncManager) { ////////////////////////////////////// @Override public @Nullable UITexture sideTips(Player player, BlockPos pos, BlockState state, Set toolTypes, + ItemStack held, Direction side) { if (toolTypes.contains(GTToolType.SOFT_MALLET)) { if (side == getFrontFacing()) return null; } - return super.sideTips(player, pos, state, toolTypes, side); + return super.sideTips(player, pos, state, toolTypes, held, side); } protected class ItemCache extends MachineTrait implements IItemHandlerModifiable { diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/AutoOutputTrait.java b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/AutoOutputTrait.java index c1971c7a971..5be843dc8bb 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/AutoOutputTrait.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/AutoOutputTrait.java @@ -311,7 +311,7 @@ public void attachRightConfigurators(Flow flow, ModularPanel panel, PanelSync @Override public @Nullable UITexture getGridOverlayIcon(Player player, BlockPos pos, BlockState state, - Set toolTypes, Direction side) { + Set toolTypes, ItemStack held, Direction side) { if (toolTypes.contains(GTToolType.WRENCH)) { if (!player.isShiftKeyDown()) { if (!getMachine().hasFrontFacing() || side != getMachine().getFrontFacing()) { diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/BedrockOreMinerLogic.java b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/BedrockOreMinerLogic.java index 963ac93d9cf..319300d137d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/BedrockOreMinerLogic.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/BedrockOreMinerLogic.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.common.machine.trait; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; @@ -11,12 +12,14 @@ import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.recipe.GTRecipe; import com.gregtechceu.gtceu.api.recipe.RecipeHelper; +import com.gregtechceu.gtceu.api.registry.GTRegistries; 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 net.minecraft.core.SectionPos; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.ItemStack; @@ -71,6 +74,12 @@ public void findAndHandleRecipe() { } } + private TagPrefix getOreDropPrefix() { + return getLevel().registryAccess().registryOrThrow(GTRegistries.Keys.TAG_PREFIX) + .getOrThrow(ResourceKey.create(GTRegistries.Keys.TAG_PREFIX, + GTCEu.id(ConfigHolder.INSTANCE.machines.bedrockOreDropTagPrefix))); + } + @Nullable private GTRecipe getOreMinerRecipe() { if (getMachine().getLevel() instanceof ServerLevel serverLevel && veinMaterials != null) { @@ -78,7 +87,7 @@ private GTRecipe getOreMinerRecipe() { if (wm == null) return null; Material material = wm.material(); ItemStack stack = GTUtil.getFirstNonEmpty( - ChemicalHelper.get(TagPrefix.get(ConfigHolder.INSTANCE.machines.bedrockOreDropTagPrefix), material), + ChemicalHelper.get(getOreDropPrefix(), material), ChemicalHelper.get(TagPrefix.crushed, material), ChemicalHelper.get(TagPrefix.gem, material), ChemicalHelper.get(TagPrefix.ore, material), diff --git a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/hazard/EnvironmentalHazardEmitterTrait.java b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/hazard/EnvironmentalHazardEmitterTrait.java index ec5805eca16..d4cdaac7155 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/machine/trait/hazard/EnvironmentalHazardEmitterTrait.java +++ b/src/main/java/com/gregtechceu/gtceu/common/machine/trait/hazard/EnvironmentalHazardEmitterTrait.java @@ -14,6 +14,8 @@ import lombok.Getter; import lombok.Setter; +import java.util.function.Supplier; + /** * trait for environmental hazard (e.g. pollution) emitters like mufflers. */ @@ -36,6 +38,10 @@ public EnvironmentalHazardEmitterTrait(MedicalCondition conditionToEmit, this.emissionStrength = emissionStrength; } + public EnvironmentalHazardEmitterTrait(Supplier conditionToEmit, float emissionStrength) { + this(conditionToEmit.get(), emissionStrength); + } + @Override public MachineTraitType getTraitType() { return TYPE; diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentBlockCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentBlockCondition.java index bf5c11bacd4..3f2acca9f08 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentBlockCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentBlockCondition.java @@ -91,7 +91,7 @@ public static AdjacentBlockCondition fromTags(TagKey... tags) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.ADJACENT_BLOCK; + return GTRecipeConditions.ADJACENT_BLOCK.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentFluidCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentFluidCondition.java index fa33a2e1344..924559640dd 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentFluidCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/AdjacentFluidCondition.java @@ -95,7 +95,7 @@ public static AdjacentFluidCondition fromTags(TagKey... tags) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.ADJACENT_FLUID; + return GTRecipeConditions.ADJACENT_FLUID.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/BiomeCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/BiomeCondition.java index bc5d111d7be..82345a7dbaf 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/BiomeCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/BiomeCondition.java @@ -43,7 +43,7 @@ public BiomeCondition(ResourceKey biome) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.BIOME; + return GTRecipeConditions.BIOME.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/BiomeTagCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/BiomeTagCondition.java index ee222756789..c11c1866d5b 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/BiomeTagCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/BiomeTagCondition.java @@ -43,7 +43,7 @@ public BiomeTagCondition(TagKey biome) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.BIOME_TAG; + return GTRecipeConditions.BIOME_TAG.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/CleanroomCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/CleanroomCondition.java index 1f145a383d3..1b83b77d48f 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/CleanroomCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/CleanroomCondition.java @@ -40,7 +40,7 @@ public CleanroomCondition(boolean isReverse, CleanroomType cleanroom) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.CLEANROOM; + return GTRecipeConditions.CLEANROOM.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DaytimeCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DaytimeCondition.java index 73e2e41f4f0..9c8d6fe28d5 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DaytimeCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DaytimeCondition.java @@ -28,7 +28,7 @@ public DaytimeCondition(boolean isReverse) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.DAYTIME; + return GTRecipeConditions.DAYTIME.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DimensionCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DimensionCondition.java index d733acb6857..3d4698b0b5b 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DimensionCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/DimensionCondition.java @@ -51,7 +51,7 @@ public DimensionCondition(boolean isReverse, ResourceKey dimension) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.DIMENSION; + return GTRecipeConditions.DIMENSION.get(); } @Override @@ -67,8 +67,10 @@ public Component getTooltips() { @Override public RecipeUIModifier modifyUI() { return (recipe, widget) -> { - DimensionMarker dimMarker = GTRegistries.DIMENSION_MARKERS.getOrDefault(this.dimension.location(), - new DimensionMarker(DimensionMarker.MAX_TIER, () -> Blocks.BARRIER, + DimensionMarker dimMarker = GTRegistries.DIMENSION_MARKERS.stream() + .filter(marker -> marker.dimension == this.dimension) + .findFirst() + .orElse(new DimensionMarker(this.dimension, DimensionMarker.MAX_TIER, () -> Blocks.BARRIER, this.dimension.toString())); ItemStack icon = dimMarker.getIcon(); String dimTier = "T" + (dimMarker.tier >= DimensionMarker.MAX_TIER ? "?" : dimMarker.tier); diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/EUToStartCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/EUToStartCondition.java index 2a9ca61e351..929f5c6f610 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/EUToStartCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/EUToStartCondition.java @@ -36,7 +36,7 @@ public EUToStartCondition(boolean isReverse, long euToStart) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.EU_TO_START; + return GTRecipeConditions.EU_TO_START.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/EnvironmentalHazardCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/EnvironmentalHazardCondition.java index c92075cb13e..7ac276f9b82 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/EnvironmentalHazardCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/EnvironmentalHazardCondition.java @@ -40,7 +40,7 @@ public EnvironmentalHazardCondition(boolean isReverse, MedicalCondition conditio @Override public RecipeConditionType getType() { - return GTRecipeConditions.ENVIRONMENTAL_HAZARD; + return GTRecipeConditions.ENVIRONMENTAL_HAZARD.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/FTBQuestCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/FTBQuestCondition.java index 47d917bc2fa..7b204ce0e65 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/FTBQuestCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/FTBQuestCondition.java @@ -47,7 +47,7 @@ private QuestObject getQuest() { @Override public RecipeConditionType getType() { - return GTRecipeConditions.FTB_QUEST; + return GTRecipeConditions.FTB_QUEST.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/GameStageCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/GameStageCondition.java index e39fb1f1ae9..cdae6c50804 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/GameStageCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/GameStageCondition.java @@ -40,7 +40,7 @@ public GameStageCondition(boolean isReverse, String stageName) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.GAMESTAGE; + return GTRecipeConditions.GAMESTAGE.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/HeraclesQuestCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/HeraclesQuestCondition.java index 75225f99bf8..e87fabf85b5 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/HeraclesQuestCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/HeraclesQuestCondition.java @@ -40,7 +40,7 @@ public HeraclesQuestCondition(boolean isReverse, String questId) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.HERACLES_QUEST; + return GTRecipeConditions.HERACLES_QUEST.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/PositionYCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/PositionYCondition.java index c167aaf2a4d..5e1700d24de 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/PositionYCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/PositionYCondition.java @@ -39,7 +39,7 @@ public PositionYCondition(boolean isReverse, int min, int max) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.POSITION_Y; + return GTRecipeConditions.POSITION_Y.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/RainingCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/RainingCondition.java index 29a34d79784..6602ff614a5 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/RainingCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/RainingCondition.java @@ -36,7 +36,7 @@ public RainingCondition(float level) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.RAINING; + return GTRecipeConditions.RAINING.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/ResearchCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/ResearchCondition.java index 27f1cbfc6f3..0f4ed0e4c97 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/ResearchCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/ResearchCondition.java @@ -40,7 +40,7 @@ public ResearchCondition(boolean isReverse, ResearchData data) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.RESEARCH; + return GTRecipeConditions.RESEARCH.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/ThunderCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/ThunderCondition.java index 72dd134679a..0d0673332dc 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/ThunderCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/ThunderCondition.java @@ -38,7 +38,7 @@ public ThunderCondition(float level) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.THUNDER; + return GTRecipeConditions.THUNDER.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/VentCondition.java b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/VentCondition.java index 653e1f56b11..63935c50842 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/VentCondition.java +++ b/src/main/java/com/gregtechceu/gtceu/common/recipe/condition/VentCondition.java @@ -25,7 +25,7 @@ public VentCondition(boolean isReverse) { @Override public RecipeConditionType getType() { - return GTRecipeConditions.VENT; + return GTRecipeConditions.VENT.get(); } @Override diff --git a/src/main/java/com/gregtechceu/gtceu/common/worldgen/modifier/RubberTreeChancePlacement.java b/src/main/java/com/gregtechceu/gtceu/common/worldgen/modifier/RubberTreeChancePlacement.java index e468a76fbc1..cec841ac32e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/worldgen/modifier/RubberTreeChancePlacement.java +++ b/src/main/java/com/gregtechceu/gtceu/common/worldgen/modifier/RubberTreeChancePlacement.java @@ -1,11 +1,8 @@ package com.gregtechceu.gtceu.common.worldgen.modifier; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.config.ConfigHolder; import net.minecraft.core.BlockPos; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.util.RandomSource; import net.minecraft.world.level.levelgen.placement.PlacementModifierType; import net.minecraft.world.level.levelgen.placement.RepeatingPlacement; @@ -14,10 +11,7 @@ public class RubberTreeChancePlacement extends RepeatingPlacement { - public static final PlacementModifierType RUBBER_TREE_CHANCE_PLACEMENT = GTRegistries - .register( - BuiltInRegistries.PLACEMENT_MODIFIER_TYPE, GTCEu.id("rubber_tree_chance"), - () -> RubberTreeChancePlacement.CODEC); + public static final PlacementModifierType RUBBER_TREE_CHANCE_PLACEMENT = () -> RubberTreeChancePlacement.CODEC; public static final RubberTreeChancePlacement INSTANCE = new RubberTreeChancePlacement(); public static final Codec CODEC = Codec.unit(INSTANCE); diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/BuiltInRegistriesAccessor.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/BuiltInRegistriesAccessor.java new file mode 100644 index 00000000000..f63eb2e842d --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/BuiltInRegistriesAccessor.java @@ -0,0 +1,16 @@ +package com.gregtechceu.gtceu.core.mixins; + +import net.minecraft.core.WritableRegistry; +import net.minecraft.core.registries.BuiltInRegistries; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(BuiltInRegistries.class) +public interface BuiltInRegistriesAccessor { + + @Accessor("WRITABLE_REGISTRY") + static WritableRegistry> gtceu$getWRITABLE_REGISTRY() { + throw new AssertionError(); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/BuiltInRegistriesMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/BuiltInRegistriesMixin.java new file mode 100644 index 00000000000..5dc91a78d21 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/BuiltInRegistriesMixin.java @@ -0,0 +1,36 @@ +package com.gregtechceu.gtceu.core.mixins; + +import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.registry.GTRegistries; + +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.function.Consumer; + +@Mixin(BuiltInRegistries.class) +public class BuiltInRegistriesMixin { + + static { + GTRegistries.init(); + } + + @WrapOperation(method = "validate", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/core/Registry;forEach(Ljava/util/function/Consumer;)V", + remap = false)) + private static > void gtceu$skipRegistryValidation(Registry instance, Consumer consumer, + Operation original) { + Consumer callback = (t) -> { + if (!t.key().location().getNamespace().equals(GTCEu.MOD_ID)) + consumer.accept(t); + }; + + original.call(instance, callback); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/ResourceKeyArgumentAccessor.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/ResourceKeyArgumentAccessor.java new file mode 100644 index 00000000000..dc4393949d3 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/ResourceKeyArgumentAccessor.java @@ -0,0 +1,24 @@ +package com.gregtechceu.gtceu.core.mixins; + +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.arguments.ResourceKeyArgument; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; + +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(ResourceKeyArgument.class) +public interface ResourceKeyArgumentAccessor { + + @Invoker + static Holder.Reference callResolveKey(CommandContext context, String argument, + ResourceKey> registryKey, + DynamicCommandExceptionType exception) throws CommandSyntaxException { + throw new AssertionError(); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/forge/GameDataMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/forge/GameDataMixin.java new file mode 100644 index 00000000000..f8ac5b3f398 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/forge/GameDataMixin.java @@ -0,0 +1,53 @@ +package com.gregtechceu.gtceu.core.mixins.forge; + +import com.gregtechceu.gtceu.GTCEu; + +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.registries.GameData; + +import com.llamalad7.mixinextras.sugar.Local; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.stream.Collectors; + +@Mixin(value = GameData.class, remap = false) +public class GameDataMixin { + + // Make GT register events fire first, even before minecraft registries. + @ModifyVariable( + method = "postRegisterEvents", + at = @At( + value = "INVOKE", + target = "Ljava/util/Set;addAll(Ljava/util/Collection;)Z", + ordinal = 1, + shift = At.Shift.AFTER), + name = "ordered") + private static Set gtceuFirst(Set ordered) { + return ordered.stream() + .sorted((a, b) -> { + boolean aGt = a.getNamespace().equals("gtceu"); + boolean bGt = b.getNamespace().equals("gtceu"); + if (aGt && !bGt) return -1; + if (!aGt && bGt) return 1; + return 0; + }) + .collect(Collectors.toCollection(LinkedHashSet::new)); + } + + @Inject(method = "postRegisterEvents", + at = @At(value = "INVOKE", + target = "Lnet/minecraftforge/fml/ModLoader;postEventWrapContainerInModOrder(Lnet/minecraftforge/eventbus/api/Event;)V", + shift = At.Shift.AFTER)) + private static void postLateRegistryEvent(CallbackInfo ci, + @Local(name = "registryKey") ResourceKey> registryKey) { + // CommonProxy.onRegisterLate(registryKey); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/kjs/RegistryEventJSMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/kjs/RegistryEventJSMixin.java new file mode 100644 index 00000000000..55f76409e90 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/kjs/RegistryEventJSMixin.java @@ -0,0 +1,49 @@ +package com.gregtechceu.gtceu.core.mixins.kjs; + +import com.gregtechceu.gtceu.GTCEu; + +import dev.latvian.mods.kubejs.registry.RegistryEventJS; +import dev.latvian.mods.kubejs.registry.RegistryInfo; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +/** + * This mixin defaults string resource locations for GT registries to use the gtceu namespace instead of the kjs + * namespace. + */ +@Mixin(value = RegistryEventJS.class, remap = false) +public class RegistryEventJSMixin { + + @Final + @Shadow + private RegistryInfo registry; + + @ModifyArg( + method = "create*", + at = @At( + value = "INVOKE", + target = "Ldev/latvian/mods/kubejs/KubeJS;appendModId(Ljava/lang/String;)Ljava/lang/String;"), + index = 0) + private String modifyId(String id) { + if (registry.key.location().getNamespace().equals("gtceu")) { + return GTCEu.appendIdString(id); + } + return id; + } + + @ModifyArg( + method = "createCustom*", + at = @At( + value = "INVOKE", + target = "Ldev/latvian/mods/kubejs/KubeJS;appendModId(Ljava/lang/String;)Ljava/lang/String;"), + index = 0) + private String modifyCustomId(String id) { + if (registry.key.location().getNamespace().equals("gtceu")) { + return GTCEu.appendIdString(id); + } + return id; + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/core/mixins/kjs/RegistryInfoMixin.java b/src/main/java/com/gregtechceu/gtceu/core/mixins/kjs/RegistryInfoMixin.java new file mode 100644 index 00000000000..64e0ed2b330 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/core/mixins/kjs/RegistryInfoMixin.java @@ -0,0 +1,39 @@ +package com.gregtechceu.gtceu.core.mixins.kjs; + +import com.gregtechceu.gtceu.integration.kjs.helpers.IGTDummyBuilder; + +import net.minecraft.resources.ResourceLocation; + +import com.llamalad7.mixinextras.sugar.Local; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryCallback; +import dev.latvian.mods.kubejs.registry.RegistryInfo; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import java.util.function.Supplier; + +/** + * Some GT builders register multiple objects (e.g. machine builders registered multiple machines for different tiers), + * or have registration behaviour that KJS cannot handle. + * This mixin handles those builders, which implement {@link IGTDummyBuilder} + */ +@Mixin(value = RegistryInfo.class, remap = false) +public abstract class RegistryInfoMixin { + + @Redirect( + method = "registerObjects", + at = @At( + value = "INVOKE", + target = "Ldev/latvian/mods/kubejs/registry/RegistryCallback;accept(Lnet/minecraft/resources/ResourceLocation;Ljava/util/function/Supplier;)V")) + private void redirectAccept( + RegistryCallback function, ResourceLocation location, Supplier supplier, + @Local(name = "builder") BuilderBase builder) { + if (builder instanceof IGTDummyBuilder b) { + b.createObject(); + } else { + function.accept(location, supplier); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/data/lang/ItemLang.java b/src/main/java/com/gregtechceu/gtceu/data/lang/ItemLang.java index 9b47bcbb63f..b6abff3be11 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/lang/ItemLang.java +++ b/src/main/java/com/gregtechceu/gtceu/data/lang/ItemLang.java @@ -2,8 +2,13 @@ import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.api.item.tool.GTToolType; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.registry.GTRegistries; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; + import com.tterrag.registrate.providers.RegistrateLangProvider; import static com.gregtechceu.gtceu.data.lang.LangHandler.multilineLang; @@ -20,8 +25,12 @@ public static void init(RegistrateLangProvider provider) { private static void initGeneratedNames(RegistrateLangProvider provider) { // RecipeTypes - for (var recipeType : GTRegistries.RECIPE_TYPES) { - provider.add(recipeType.registryName.toLanguageKey(), toEnglishName(recipeType.registryName.getPath())); + for (var recipeType : RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY) + .registryOrThrow(Registries.RECIPE_TYPE)) { + if (recipeType instanceof GTRecipeType gtRecipeType) { + provider.add(gtRecipeType.registryName.toLanguageKey(), + toEnglishName(gtRecipeType.registryName.getPath())); + } } // Recipe Categories @@ -35,7 +44,7 @@ private static void initGeneratedNames(RegistrateLangProvider provider) { provider.add("gtceu.recipe.category.ingot_molding", "Metal Molding"); // TagPrefix - for (TagPrefix tagPrefix : TagPrefix.values()) { + for (TagPrefix tagPrefix : GTRegistries.TAG_PREFIXES) { provider.add(tagPrefix.getUnlocalizedName(), tagPrefix.langValue); } // GTToolType diff --git a/src/main/java/com/gregtechceu/gtceu/data/loot/ChestGenHooks.java b/src/main/java/com/gregtechceu/gtceu/data/loot/ChestGenHooks.java index 3cf4e1b8c0c..58459822660 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/loot/ChestGenHooks.java +++ b/src/main/java/com/gregtechceu/gtceu/data/loot/ChestGenHooks.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.data.loot; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.core.mixins.LootPoolAccessor; import com.gregtechceu.gtceu.utils.GTMath; @@ -134,8 +133,7 @@ public void createItemStack(Consumer stackConsumer, LootContext lootC public static class RandomWeightLootFunction extends LootItemConditionalFunction implements LootItemFunction { - public static final LootItemFunctionType TYPE = GTRegistries.register(BuiltInRegistries.LOOT_FUNCTION_TYPE, - GTCEu.id("random_weight"), new LootItemFunctionType(new Serializer())); + public static final LootItemFunctionType TYPE = new LootItemFunctionType(new Serializer()); private final ItemStack stack; @Getter diff --git a/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicDataPack.java b/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicDataPack.java index 103ffba6b4d..58ae45b3913 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicDataPack.java +++ b/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicDataPack.java @@ -57,6 +57,10 @@ public GTDynamicDataPack(String name, Collection domains) { SERVER_DOMAINS.addAll(domains); } + public static void addNamespace(String namespace) { + SERVER_DOMAINS.add(namespace); + } + public static void clearServer() { CONTENTS.clearData(); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicResourcePack.java b/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicResourcePack.java index 986d7be8744..39c6982889b 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicResourcePack.java +++ b/src/main/java/com/gregtechceu/gtceu/data/pack/GTDynamicResourcePack.java @@ -75,6 +75,10 @@ public GTDynamicResourcePack(String name, Collection domains) { CLIENT_DOMAINS.addAll(domains); } + public static void addNamespace(String namespace) { + CLIENT_DOMAINS.add(namespace); + } + public static void clearClient() { CONTENTS.clearData(); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java index 947bd1309e9..fd612b32e99 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/GTRecipeBuilder.java @@ -1190,6 +1190,10 @@ public GTRecipeBuilder environmentalHazard(MedicalCondition condition) { return environmentalHazard(condition, false); } + public GTRecipeBuilder environmentalHazard(Supplier conditionSupplier) { + return environmentalHazard(conditionSupplier.get()); + } + public final GTRecipeBuilder adjacentFluids(Fluid... fluids) { return adjacentFluids(false, fluids); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/MaterialRecipeHandler.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/MaterialRecipeHandler.java index ac7cfe04764..c55d1165313 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/MaterialRecipeHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/MaterialRecipeHandler.java @@ -13,7 +13,6 @@ import com.gregtechceu.gtceu.config.ConfigHolder; import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper; import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; -import com.gregtechceu.gtceu.utils.FormattingUtil; import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.util.Mth; @@ -440,7 +439,7 @@ private static void processGemConversion(@NotNull Consumer provi if (material.hasFlag(MORTAR_GRINDABLE)) { VanillaRecipeHelper.addShapedRecipe(provider, String.format("gem_to_dust_%s_%s", material.getName(), - FormattingUtil.toLowerCaseUnderscore(prefix.name)), + prefix.getName()), crushedStack, "X", "m", 'X', new MaterialEntry(prefix, material)); } @@ -455,14 +454,14 @@ private static void processGemConversion(@NotNull Consumer provi } VanillaRecipeHelper.addShapelessRecipe(provider, - String.format("gem_to_gem_%s_%s", FormattingUtil.toLowerCaseUnderscore(lowerPrefix.name), + String.format("gem_to_gem_%s_%s", lowerPrefix.getName(), material.getName()), prevStack, 'h', new MaterialEntry(prefix, material)); CUTTER_RECIPES - .recipeBuilder("cut_" + material.getName() + "_" + FormattingUtil.toLowerCaseUnderscore(prefix.name) + - "_to_" + FormattingUtil.toLowerCaseUnderscore(lowerPrefix.name)) + .recipeBuilder("cut_" + material.getName() + "_" + prefix.getName() + + "_to_" + lowerPrefix.getName()) .inputItems(prefix, material) .outputItems(prevStack) .duration(20) @@ -471,8 +470,8 @@ private static void processGemConversion(@NotNull Consumer provi LASER_ENGRAVER_RECIPES .recipeBuilder( - "engrave_" + material.getName() + "_" + FormattingUtil.toLowerCaseUnderscore(prefix.name) + - "_to_" + FormattingUtil.toLowerCaseUnderscore(lowerPrefix.name)) + "engrave_" + material.getName() + "_" + prefix.getName() + + "_to_" + lowerPrefix.getName()) .inputItems(prevStack) .notConsumable(lens, MarkerMaterials.Color.White) .outputItems(prefix, material) diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/OreRecipeHandler.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/OreRecipeHandler.java index 7c1b53aa70e..f48a52e4ef7 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/OreRecipeHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/OreRecipeHandler.java @@ -62,7 +62,7 @@ private static void processMetalSmelting(@NotNull Consumer provi ItemStack ingotStack = ChemicalHelper.get(ingot, smeltingResult); if (!ingotStack.isEmpty() && doesMaterialUseNormalFurnace(smeltingResult) && !prefix.isIgnored(material)) { - String name = "smelt_" + prefix.name + "_" + material.getName() + "_to_ingot"; + String name = "smelt_" + prefix.getName() + "_" + material.getName() + "_to_ingot"; TagKey tag = ChemicalHelper.getTag(prefix, material); VanillaRecipeHelper.addSmeltingRecipe(provider, name, tag, ingotStack, 0.5f); @@ -102,7 +102,7 @@ private static void processOre(@NotNull Consumer provider, @NotN ItemStack crushedStack = ChemicalHelper.get(crushed, material); crushedStack.setCount(crushedStack.getCount() * property.getOreMultiplier()); - String prefixString = orePrefix == ore ? "" : orePrefix.name + "_"; + String prefixString = orePrefix == ore ? "" : orePrefix.getName() + "_"; if (!crushedStack.isEmpty()) { int crushedCount = property.getOreMultiplier() * oreTypeMultiplier; GTRecipeBuilder builder = FORGE_HAMMER_RECIPES diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PartsRecipeHandler.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PartsRecipeHandler.java index c7305d941f5..51aedfe3c9e 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PartsRecipeHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PartsRecipeHandler.java @@ -229,7 +229,7 @@ private static void processGear(@NotNull Consumer provider, @Not if (material.hasFluid()) { FluidStack fluidStack = material.getProperty(PropertyKey.FLUID).solidifiesFrom(L * (isSmall ? 1 : 4)); if (!fluidStack.isEmpty()) { - FLUID_SOLIDFICATION_RECIPES.recipeBuilder("solidify_" + material.getName() + "_" + prefix.name) + FLUID_SOLIDFICATION_RECIPES.recipeBuilder("solidify_" + material.getName() + "_" + prefix.getName()) .notConsumable(isSmall ? GTItems.SHAPE_MOLD_GEAR_SMALL : GTItems.SHAPE_MOLD_GEAR) .inputFluids(fluidStack) .outputItems(stack) diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PipeRecipeHandler.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PipeRecipeHandler.java index 620c66da6a1..96709eb82ab 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PipeRecipeHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PipeRecipeHandler.java @@ -59,7 +59,7 @@ private static void processRestrictivePipe(@NotNull Consumer pro return; } - ASSEMBLER_RECIPES.recipeBuilder("assemble_" + material.getName() + "_" + prefix.name) + ASSEMBLER_RECIPES.recipeBuilder("assemble_" + material.getName() + "_" + prefix.getName()) .inputItems(unrestrictive, material) .inputItems(ring, Iron, 2) .outputItems(prefix, material) diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PolarizingRecipeHandler.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PolarizingRecipeHandler.java index cb5d21ee5ab..4e7bd5729a0 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PolarizingRecipeHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/PolarizingRecipeHandler.java @@ -51,7 +51,7 @@ private static void processPolarizing(@NotNull Consumer provider if (!magneticMaterial.isNull() && (prefix.doGenerateBlock(magneticMaterial) || prefix.doGenerateItem(magneticMaterial))) { ItemStack magneticStack = ChemicalHelper.get(prefix, magneticMaterial); - POLARIZER_RECIPES.recipeBuilder("polarize_" + material.getName() + "_" + prefix.name) // polarizing + POLARIZER_RECIPES.recipeBuilder("polarize_" + material.getName() + "_" + prefix.getName()) // polarizing .inputItems(prefix, material) .outputItems(magneticStack) .duration((int) ((int) material.getMass() * prefix.getMaterialAmount(material) / M)) diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/RecyclingRecipeHandler.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/RecyclingRecipeHandler.java index ced9b2d3f83..d3bb218194e 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/RecyclingRecipeHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/RecyclingRecipeHandler.java @@ -5,6 +5,7 @@ import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey; import com.gregtechceu.gtceu.api.data.chemical.material.stack.MaterialStack; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.data.recipe.misc.RecyclingRecipes; import net.minecraft.data.recipes.FinishedRecipe; @@ -26,7 +27,7 @@ private RecyclingRecipeHandler() {} public static void run(@NotNull Consumer provider, @NotNull Material material) { // registers universal maceration recipes for specified ore prefixes - for (TagPrefix prefix : TagPrefix.values()) { + for (TagPrefix prefix : GTRegistries.TAG_PREFIXES) { if (prefix.generateRecycling()) { processCrushing(provider, prefix, material); } diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireCombiningHandler.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireCombiningHandler.java index e56abe23ca0..02eac0fb4f9 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireCombiningHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireCombiningHandler.java @@ -108,7 +108,7 @@ private static void processCableStripping(@NotNull Consumer prov return; } - PACKER_RECIPES.recipeBuilder("strip_" + material.getName() + "_" + prefix.name) + PACKER_RECIPES.recipeBuilder("strip_" + material.getName() + "_" + prefix.getName()) .inputItems(prefix, material) .outputItems(cableToWireMap.get(prefix), material) .outputItems(plate, GTMaterials.Rubber, diff --git a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireRecipeHandler.java b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireRecipeHandler.java index 8921e52e09d..0dc850f2698 100644 --- a/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireRecipeHandler.java +++ b/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/WireRecipeHandler.java @@ -1,5 +1,6 @@ package com.gregtechceu.gtceu.data.recipe.generated; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.chemical.material.Material; @@ -7,6 +8,7 @@ import com.gregtechceu.gtceu.api.data.chemical.material.properties.WireProperties; import com.gregtechceu.gtceu.api.data.chemical.material.stack.MaterialEntry; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper; import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; @@ -14,6 +16,7 @@ import net.minecraft.Util; import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.resources.ResourceKey; import it.unimi.dsi.fastutil.objects.Reference2IntMap; import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; @@ -143,7 +146,8 @@ private static void generateCableCovering(@NotNull Consumer prov } int cableAmount = (int) (prefix.getMaterialAmount(material) * 2 / M); - TagPrefix cablePrefix = TagPrefix.get("cable" + prefix.name().substring(4)); + TagPrefix cablePrefix = GTRegistries.TAG_PREFIXES.getOrThrow( + ResourceKey.create(GTRegistries.Keys.TAG_PREFIX, GTCEu.id("cable" + prefix.getName().substring(4)))); int voltageTier = GTUtil.getTierByVoltage(property.getVoltage()); int insulationAmount = INSULATION_AMOUNT.getInt(cablePrefix); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/ae2/GTAEPlaceholders.java b/src/main/java/com/gregtechceu/gtceu/integration/ae2/GTAEPlaceholders.java index 4db30093561..f7cef5ccb8b 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/ae2/GTAEPlaceholders.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/ae2/GTAEPlaceholders.java @@ -3,6 +3,7 @@ import com.gregtechceu.gtceu.api.cover.filter.ItemFilter; import com.gregtechceu.gtceu.api.placeholder.*; import com.gregtechceu.gtceu.api.placeholder.exceptions.*; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.utils.GTStringUtils; import net.minecraft.MethodsReturnNonnullByDefault; @@ -13,8 +14,11 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.material.Fluid; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import appeng.api.networking.GridHelper; import appeng.api.networking.IGrid; @@ -37,8 +41,12 @@ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault +@SuppressWarnings("unused") public class GTAEPlaceholders { + private static final DeferredRegister AE_PLACEHOLDERS = DeferredRegister + .create(GTRegistries.Keys.PLACEHOLDER, "gtceu"); + private GTAEPlaceholders() {} private static IGrid getGrid(PlaceholderContext ctx) throws PlaceholderException { @@ -47,7 +55,7 @@ private static IGrid getGrid(PlaceholderContext ctx) throws PlaceholderException if (nodeHost != null) { IGridNode node = nodeHost.getGridNode(ctx.side()); if (node != null) return node.getGrid(); - } ; + } BlockEntity blockEntity = ctx.level().getBlockEntity(ctx.pos()); if (blockEntity instanceof IGridConnectedBlockEntity gridMachine) { IGrid nullable = gridMachine.getMainNode().getGrid(); @@ -99,135 +107,152 @@ private static Vector3i getSpatialSize(IGrid grid) { return new Vector3i(tmp.getX(), tmp.getY(), tmp.getZ()).absolute(); } - public static void init() { - PlaceholderHandler.addPlaceholder(new Placeholder("ae2itemCount") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - IGrid grid = getGrid(ctx); - if (args.isEmpty()) return MultiLineComponent.literal(countItems((ItemFilter) null, grid)); - if (args.size() == 1) - return MultiLineComponent.literal(countItems(GTStringUtils.componentsToString(args.get(0)), grid)); - if (GTStringUtils.equals(args.get(0), "filter")) { - int slot = PlaceholderUtils.toInt(args.get(1)); - try { - PlaceholderUtils.checkRange("slot index", 1, 8, slot); - if (ctx.itemStackHandler() == null) throw new NotSupportedException(); - return MultiLineComponent.literal(countItems( - ItemFilter.loadFilter(ctx.itemStackHandler().getStackInSlot(slot - 1)), grid)); - } catch (NullPointerException e) { - throw new MissingItemException("filter", slot); + public static void init(IEventBus modBus) { + AE_PLACEHOLDERS.register(modBus); + } + + public static RegistryObject AE2_ITEM_COUNT = AE_PLACEHOLDERS.register("ae2_item_count", + () -> new Placeholder("ae2itemCount") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + IGrid grid = getGrid(ctx); + if (args.isEmpty()) return MultiLineComponent.literal(countItems((ItemFilter) null, grid)); + if (args.size() == 1) + return MultiLineComponent + .literal(countItems(GTStringUtils.componentsToString(args.get(0)), grid)); + if (GTStringUtils.equals(args.get(0), "filter")) { + int slot = PlaceholderUtils.toInt(args.get(1)); + try { + PlaceholderUtils.checkRange("slot index", 1, 8, slot); + if (ctx.itemStackHandler() == null) throw new NotSupportedException(); + return MultiLineComponent.literal(countItems( + ItemFilter.loadFilter(ctx.itemStackHandler().getStackInSlot(slot - 1)), grid)); + } catch (NullPointerException e) { + throw new MissingItemException("filter", slot); + } } + throw new InvalidArgsException(); } - throw new InvalidArgsException(); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("ae2fluidCount") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - IGrid grid = getGrid(ctx); - if (args.isEmpty()) return MultiLineComponent.literal(countFluids(null, grid)); - if (args.size() == 1) - return MultiLineComponent.literal(countFluids(GTStringUtils.componentsToString(args.get(0)), grid)); - throw new WrongNumberOfArgsException(1, args.size()); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("ae2power") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - IGrid grid = getGrid(ctx); - PlaceholderUtils.checkArgs(args, 0); - return MultiLineComponent.literal(grid.getEnergyService().getStoredPower()); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("ae2maxPower") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - IGrid grid = getGrid(ctx); - PlaceholderUtils.checkArgs(args, 0); - return MultiLineComponent.literal(grid.getEnergyService().getMaxStoredPower()); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("ae2powerUsage") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - IGrid grid = getGrid(ctx); - PlaceholderUtils.checkArgs(args, 0); - return MultiLineComponent.literal(grid.getEnergyService().getAvgPowerUsage()); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("ae2spatial") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - IGrid grid = getGrid(ctx); - PlaceholderUtils.checkArgs(args, 1); - if (GTStringUtils.equals(args.get(0), "power")) { - return MultiLineComponent.literal(grid.getSpatialService().requiredPower()); - } else if (GTStringUtils.equals(args.get(0), "efficiency")) { - return MultiLineComponent.literal(grid.getSpatialService().currentEfficiency()); - } else if (GTStringUtils.equals(args.get(0), "sizeX")) { - return MultiLineComponent.literal(getSpatialSize(grid).x); - } else if (GTStringUtils.equals(args.get(0), "sizeY")) { - return MultiLineComponent.literal(getSpatialSize(grid).y); - } else if (GTStringUtils.equals(args.get(0), "sizeZ")) { - return MultiLineComponent.literal(getSpatialSize(grid).z); - } else throw new InvalidArgsException(); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("ae2crafting") { - - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - IGrid grid = getGrid(ctx); - PlaceholderUtils.checkArgs(args, 1, true); - ICraftingService crafting = grid.getCraftingService(); - if (GTStringUtils.equals(args.get(0), "get")) { - if (GTStringUtils.equals(args.get(1), "amount")) - return MultiLineComponent.literal(crafting.getCpus().size()); - int index = PlaceholderUtils.toInt(args.get(1)); - int i = 0; - for (ICraftingCPU cpu : crafting.getCpus()) { - if (index - 1 == i) { - CraftingJobStatus job = cpu.getJobStatus(); - if (GTStringUtils.equals(args.get(2), "storage")) - return MultiLineComponent.literal(cpu.getAvailableStorage()); - else if (GTStringUtils.equals(args.get(2), "threads")) - return MultiLineComponent.literal(cpu.getCoProcessors()); - else if (GTStringUtils.equals(args.get(2), "name")) - return MultiLineComponent - .of(cpu.getName() == null ? Component.literal("Crafting CPU " + i) : - cpu.getName().copy()); - else if (GTStringUtils.equals(args.get(2), "selectionMode")) - return MultiLineComponent.literal(cpu.getSelectionMode().name()); - else if (job == null) return MultiLineComponent.literal(0); - else if (GTStringUtils.equals(args.get(2), "amount")) - return MultiLineComponent.literal(job.crafting().amount()); - else if (GTStringUtils.equals(args.get(2), "item")) - return MultiLineComponent.of(job.crafting().what().getDisplayName().copy()); - else if (GTStringUtils.equals(args.get(2), "progress")) - return MultiLineComponent.literal(job.progress()); - else if (GTStringUtils.equals(args.get(2), "time")) - return MultiLineComponent.literal(job.elapsedTimeNanos()); - else throw new InvalidArgsException(); + }); + + public static RegistryObject AE2_FLUID_COUNT = AE_PLACEHOLDERS.register("ae2_fluid_count", + () -> new Placeholder("ae2fluidCount") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + IGrid grid = getGrid(ctx); + if (args.isEmpty()) return MultiLineComponent.literal(countFluids(null, grid)); + if (args.size() == 1) + return MultiLineComponent + .literal(countFluids(GTStringUtils.componentsToString(args.get(0)), grid)); + throw new WrongNumberOfArgsException(1, args.size()); + } + }); + + public static RegistryObject AE2_POWER = AE_PLACEHOLDERS.register("ae2power", + () -> new Placeholder("ae2power") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + IGrid grid = getGrid(ctx); + PlaceholderUtils.checkArgs(args, 0); + return MultiLineComponent.literal(grid.getEnergyService().getStoredPower()); + } + }); + + public static RegistryObject AE2_MAX_POWER = AE_PLACEHOLDERS.register("ae2_max_power", + () -> new Placeholder("ae2maxPower") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + IGrid grid = getGrid(ctx); + PlaceholderUtils.checkArgs(args, 0); + return MultiLineComponent.literal(grid.getEnergyService().getMaxStoredPower()); + } + }); + + public static RegistryObject AE2_POWER_USAGE = AE_PLACEHOLDERS.register("ae2_power_usage", + () -> new Placeholder("ae2powerUsage") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + IGrid grid = getGrid(ctx); + PlaceholderUtils.checkArgs(args, 0); + return MultiLineComponent.literal(grid.getEnergyService().getAvgPowerUsage()); + } + }); + + public static RegistryObject AE2_SPATIAL = AE_PLACEHOLDERS.register("ae2spatial", + () -> new Placeholder("ae2spatial") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + IGrid grid = getGrid(ctx); + PlaceholderUtils.checkArgs(args, 1); + if (GTStringUtils.equals(args.get(0), "power")) { + return MultiLineComponent.literal(grid.getSpatialService().requiredPower()); + } else if (GTStringUtils.equals(args.get(0), "efficiency")) { + return MultiLineComponent.literal(grid.getSpatialService().currentEfficiency()); + } else if (GTStringUtils.equals(args.get(0), "sizeX")) { + return MultiLineComponent.literal(getSpatialSize(grid).x); + } else if (GTStringUtils.equals(args.get(0), "sizeY")) { + return MultiLineComponent.literal(getSpatialSize(grid).y); + } else if (GTStringUtils.equals(args.get(0), "sizeZ")) { + return MultiLineComponent.literal(getSpatialSize(grid).z); + } else throw new InvalidArgsException(); + } + }); + + public static RegistryObject AE2_CRAFTING = AE_PLACEHOLDERS.register("ae2crafting", + () -> new Placeholder("ae2crafting") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + IGrid grid = getGrid(ctx); + PlaceholderUtils.checkArgs(args, 1, true); + ICraftingService crafting = grid.getCraftingService(); + if (GTStringUtils.equals(args.get(0), "get")) { + if (GTStringUtils.equals(args.get(1), "amount")) + return MultiLineComponent.literal(crafting.getCpus().size()); + int index = PlaceholderUtils.toInt(args.get(1)); + int i = 0; + for (ICraftingCPU cpu : crafting.getCpus()) { + if (index - 1 == i) { + CraftingJobStatus job = cpu.getJobStatus(); + if (GTStringUtils.equals(args.get(2), "storage")) + return MultiLineComponent.literal(cpu.getAvailableStorage()); + else if (GTStringUtils.equals(args.get(2), "threads")) + return MultiLineComponent.literal(cpu.getCoProcessors()); + else if (GTStringUtils.equals(args.get(2), "name")) + return MultiLineComponent + .of(cpu.getName() == null ? Component.literal("Crafting CPU " + i) : + cpu.getName().copy()); + else if (GTStringUtils.equals(args.get(2), "selectionMode")) + return MultiLineComponent.literal(cpu.getSelectionMode().name()); + else if (job == null) return MultiLineComponent.literal(0); + else if (GTStringUtils.equals(args.get(2), "amount")) + return MultiLineComponent.literal(job.crafting().amount()); + else if (GTStringUtils.equals(args.get(2), "item")) + return MultiLineComponent.of(job.crafting().what().getDisplayName().copy()); + else if (GTStringUtils.equals(args.get(2), "progress")) + return MultiLineComponent.literal(job.progress()); + else if (GTStringUtils.equals(args.get(2), "time")) + return MultiLineComponent.literal(job.elapsedTimeNanos()); + else throw new InvalidArgsException(); + } + i++; } - i++; - } - throw new OutOfRangeException("cpu number", 1, crafting.getCpus().size(), index); - } // else if (GTStringUtils.equals(args.get(0), "request")) {} gonna implement that someday :) - throw new InvalidArgsException(); - } - }); - } + throw new OutOfRangeException("cpu number", 1, crafting.getCpus().size(), index); + } // else if (GTStringUtils.equals(args.get(0), "request")) {} gonna implement that someday :) + throw new InvalidArgsException(); + } + }); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/cctweaked/CCTweakedPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/cctweaked/CCTweakedPlugin.java index 2c08434169a..ac21357e1d3 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/cctweaked/CCTweakedPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/cctweaked/CCTweakedPlugin.java @@ -4,8 +4,12 @@ import com.gregtechceu.gtceu.api.placeholder.*; import com.gregtechceu.gtceu.api.placeholder.exceptions.NotSupportedException; import com.gregtechceu.gtceu.api.placeholder.exceptions.PlaceholderException; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.integration.cctweaked.peripherals.*; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; + import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.ForgeComputerCraftAPI; @@ -26,8 +30,10 @@ public static void init() { ForgeComputerCraftAPI.registerGenericCapability(GTCapability.CAPABILITY_COVERABLE); } - public static void initPlaceholders() { - PlaceholderHandler.addPlaceholder(new Placeholder("bufferText") { + public static void initPlaceholders(IEventBus modBus) { + var register = DeferredRegister.create(GTRegistries.Keys.PLACEHOLDER, "gtceu"); + register.register(modBus); + register.register("buffer_text", () -> new Placeholder("bufferText") { @Override public MultiLineComponent apply(PlaceholderContext ctx, diff --git a/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateDisplaySources.java b/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateDisplaySources.java index 55e9e0aa1c2..d663539d5ab 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateDisplaySources.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateDisplaySources.java @@ -25,7 +25,7 @@ private static RegistryEntry registerToAllMachines( .displaySource(GTRegistration.REGISTRATE, name, supplier); builder.onRegisterAfter( Registries.BLOCK_ENTITY_TYPE, - source -> GTRegistries.MACHINES.entries().forEach( + source -> GTRegistries.MACHINES.entrySet().forEach( (entry) -> DisplaySource.BY_BLOCK_ENTITY.add( entry.getValue().getBlockEntityType(), source))); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateDisplayTargets.java b/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateDisplayTargets.java index 9c7c0ad62f4..1e68b1d9dce 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateDisplayTargets.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateDisplayTargets.java @@ -24,7 +24,7 @@ private static RegistryEntry registerToAllMachines( .displayTarget(GTRegistration.REGISTRATE, name, supplier); builder.onRegisterAfter( Registries.BLOCK_ENTITY_TYPE, - target -> GTRegistries.MACHINES.entries().forEach( + target -> GTRegistries.MACHINES.entrySet().forEach( (entry) -> DisplayTarget.BY_BLOCK_ENTITY.register( entry.getValue().getBlockEntityType(), target))); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateIntegration.java b/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateIntegration.java index faf92574c5b..e72ccc1579b 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateIntegration.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/create/GTCreateIntegration.java @@ -2,6 +2,7 @@ import com.gregtechceu.gtceu.api.placeholder.*; import com.gregtechceu.gtceu.api.placeholder.exceptions.*; +import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate; import com.gregtechceu.gtceu.utils.GTStringUtils; @@ -10,6 +11,8 @@ import net.minecraft.core.Direction; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; import com.simibubi.create.AllItems; import com.simibubi.create.Create; @@ -20,6 +23,7 @@ import com.simibubi.create.content.redstone.link.IRedstoneLinkable; import com.simibubi.create.content.redstone.link.RedstoneLinkNetworkHandler; import com.simibubi.create.content.redstone.link.controller.LinkedControllerItem; +import org.jetbrains.annotations.ApiStatus; import java.util.ArrayList; import java.util.List; @@ -28,23 +32,17 @@ public class GTCreateIntegration { + private static final DeferredRegister CREATE_PLACEHOLDERS = DeferredRegister + .create(GTRegistries.Keys.PLACEHOLDER, "gtceu"); + private GTCreateIntegration() {} - public static void init() { + public static void init(IEventBus modBus) { + CREATE_PLACEHOLDERS.register(modBus); GTCreateDisplaySources.init(); GTCreateDisplayTargets.init(); - } - - public static void initPlaceholders() { - PlaceholderHandler.addOrOverridePlaceholder(new Placeholder("redstone") { - @Override - public MultiLineComponent apply(PlaceholderContext ctx, - List args) throws PlaceholderException { - return processRedstonePlaceholder(ctx, args); - } - }); - PlaceholderHandler.addPlaceholder(new Placeholder("displayTarget") { + CREATE_PLACEHOLDERS.register("display_target", () -> new Placeholder("displayTarget") { @Override public MultiLineComponent apply(PlaceholderContext ctx, @@ -58,6 +56,18 @@ public MultiLineComponent apply(PlaceholderContext ctx, }); } + @ApiStatus.Internal + public static Placeholder getCreateRedstonePlaceholder() { + return new Placeholder("redstone") { + + @Override + public MultiLineComponent apply(PlaceholderContext ctx, + List args) throws PlaceholderException { + return processRedstonePlaceholder(ctx, args); + } + }; + } + private static int getRedstoneLinkPower(PlaceholderContext ctx, Couple freq) throws PlaceholderException { if (ctx.pos() == null) throw new NoTargetException(); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTCEuStartupEvents.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTCEuStartupEvents.java index 59764783f61..3640ff36900 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTCEuStartupEvents.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTCEuStartupEvents.java @@ -1,31 +1,16 @@ package com.gregtechceu.gtceu.integration.kjs; -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.registry.GTRegistry; import com.gregtechceu.gtceu.integration.kjs.events.CraftingComponentsEventJS; -import com.gregtechceu.gtceu.integration.kjs.events.GTRegistryEventJS; +import com.gregtechceu.gtceu.integration.kjs.events.MaterialIconTypeEventJS; import com.gregtechceu.gtceu.integration.kjs.events.MaterialModificationEventJS; import dev.latvian.mods.kubejs.event.EventGroup; import dev.latvian.mods.kubejs.event.EventHandler; -import dev.latvian.mods.kubejs.event.Extra; public interface GTCEuStartupEvents { EventGroup GROUP = EventGroup.of("GTCEuStartupEvents"); - - Extra REGISTRY_EXTRA = Extra.REQUIRES_STRING.copy().validator(GTCEuStartupEvents::validateRegistry); - - private static boolean validateRegistry(Object o) { - try { - var id = GTCEu.id(o.toString()); - return GTRegistry.REGISTERED.containsKey(id) || GTRegistryInfo.EXTRA_IDS.contains(id); - } catch (Exception ex) { - return false; - } - } - - EventHandler REGISTRY = GROUP.startup("registry", () -> GTRegistryEventJS.class).extra(REGISTRY_EXTRA); EventHandler MATERIAL_MODIFICATION = GROUP.startup("materialModification", () -> MaterialModificationEventJS.class); EventHandler CRAFTING_COMPONENTS = GROUP.startup("craftingComponents", () -> CraftingComponentsEventJS.class); + EventHandler MATERIAL_ICON_TYPE = GROUP.startup("materialIconType", () -> MaterialIconTypeEventJS.class); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTRegistryInfo.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTRegistryInfo.java index c568f952dad..dd44d22eaa8 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTRegistryInfo.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/GTRegistryInfo.java @@ -1,163 +1,36 @@ package com.gregtechceu.gtceu.integration.kjs; -import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.data.DimensionMarker; import com.gregtechceu.gtceu.api.data.chemical.Element; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet; -import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.api.data.worldgen.IWorldGenLayer; import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.api.registry.GTRegistry; -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 net.minecraft.resources.ResourceLocation; - -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 java.util.*; -import java.util.function.Supplier; - -public class GTRegistryInfo { - - @FunctionalInterface - public interface BuilderFactory { - - BuilderBase createBuilder(ResourceLocation id); - } - - public record BuilderType(String type, Class> builderClass, - BuilderFactory factory) {} - - public static final Map> MAP = new LinkedHashMap<>(); - public static final Set EXTRA_IDS = new HashSet<>(); - - public static final Map>> POST_AT = new HashMap<>(); - public static final List> ALL_BUILDERS = new ArrayList<>(); - - // spotless:off - - public static final GTRegistryInfo ELEMENT = add(GTRegistries.ELEMENTS, Element.class); - public static final GTRegistryInfo MATERIAL = add(GTRegistries.MATERIALS, Material.class); - public static final GTRegistryInfo RECIPE_TYPE = add(GTRegistries.RECIPE_TYPES, GTRecipeType.class); - public static final GTRegistryInfo RECIPE_CATEGORY = add(GTRegistries.RECIPE_CATEGORIES, GTRecipeCategory.class); - public static final GTRegistryInfo MACHINE = add(GTRegistries.MACHINES, MachineDefinition.class); - public static final GTRegistryInfo MATERIAL_ICON_SET = add(GTRegistries.MATERIAL_ICON_SETS, MaterialIconSet.class); - public static final GTRegistryInfo MATERIAL_ICON_TYPE = add(GTCEu.id("material_icon_type"), () -> MaterialIconType.ICON_TYPES, MaterialIconType.class); - public static final GTRegistryInfo WORLD_GEN_LAYER = add(GTRegistries.WORLD_GEN_LAYERS, IWorldGenLayer.class); - public static final GTRegistryInfo TAG_PREFIX = add(GTRegistries.TAG_PREFIXES, KJSTagPrefix.class); - public static final GTRegistryInfo DIMENSION_MARKER = add(GTRegistries.DIMENSION_MARKERS, DimensionMarker.class); - - // spotless:on - - public final ResourceLocation registryKey; - public final Class objectBaseClass; - public final Map> types; - public final Map> objects; - public final Supplier> registryValues; - private BuilderType defaultType; - public BuilderBase current; - - private GTRegistryInfo(ResourceLocation key, Supplier> registryValues, Class baseClass) { - registryKey = key; - objectBaseClass = baseClass; - types = new LinkedHashMap<>(); - objects = new LinkedHashMap<>(); - this.registryValues = registryValues; - current = null; - } - - public static GTRegistryInfo add(GTRegistry key, Class baseClass) { - ResourceLocation id = key.getRegistryName(); - var types = new GTRegistryInfo<>(id, key::registry, UtilsJS.cast(baseClass)); - - if (MAP.put(id, types) != null) { - throw new IllegalStateException("Registry with id '" + id + "' already exists!"); - } - - POST_AT.computeIfAbsent(key.getRegistryName(), (k) -> new LinkedList<>()).add(types); - - return types; - } - - public static GTRegistryInfo add(ResourceLocation id, Supplier> registryValues, - Class baseClass) { - var types = new GTRegistryInfo<>(id, registryValues, UtilsJS.cast(baseClass)); - - if (MAP.put(id, types) != null || !EXTRA_IDS.add(id)) { - throw new IllegalStateException("Registry with id '" + id + "' already exists!"); - } - - POST_AT.computeIfAbsent(id, (k) -> new LinkedList<>()).add(types); - - return types; - } - - public void addType(String type, Class> builderType, BuilderFactory factory, - boolean isDefault) { - var b = new BuilderType<>(type, builderType, factory); - types.put(type, b); - - if (isDefault) { - if (defaultType != null) { - ConsoleJS.STARTUP.warn("Previous default type '" + defaultType.type + "' for registry '" + registryKey + - "' replaced with '" + type + "'!"); - } - - defaultType = b; - } - } - - public void addBuilder(BuilderBase builder) { - if (builder == null) { - throw new IllegalArgumentException("Can't add null builder in registry '" + registryKey + "'!"); - } - - if (DevProperties.get().debugInfo) { - ConsoleJS.STARTUP.info("~ " + registryKey + " | " + builder.id); - } - - if (objects.containsKey(builder.id)) { - throw new IllegalArgumentException("Duplicate key '" + builder.id + "' in registry '" + registryKey + "'!"); - } - - objects.put(builder.id, builder); - ALL_BUILDERS.add(builder); - } - - public BuilderType getDefaultType() { - if (types.isEmpty()) { - return null; - } else if (defaultType == null) { - defaultType = types.values().iterator().next(); - } - - return defaultType; - } - - public void postEvent() { - GTCEuStartupEvents.REGISTRY.post(ScriptType.STARTUP, registryKey, new GTRegistryEventJS<>(this)); - } - - public static void registerFor(ResourceLocation registry) { - for (var type : POST_AT.getOrDefault(registry, List.of())) { - type.postEvent(); - - for (var builder : type.objects.values()) { - if (DevProperties.get().debugInfo) { - ConsoleJS.STARTUP.info("+ " + registry + " | " + builder.id); - } - builder.register(); - } - } - } +import com.gregtechceu.gtceu.integration.kjs.builders.material.*; + +import dev.latvian.mods.kubejs.registry.RegistryInfo; + +public class GTRegistryInfo { + + public static final RegistryInfo ELEMENT = RegistryInfo.of(GTRegistries.Keys.ELEMENT, Element.class); + public static final RegistryInfo MATERIAL_ICON_SET = RegistryInfo + .of(GTRegistries.Keys.MATERIAL_ICON_SET, MaterialIconSet.class); + public static final RegistryInfo MATERIAL = RegistryInfo.of(GTRegistries.Keys.MATERIAL, Material.class); + public static final RegistryInfo RECIPE_TYPE = RegistryInfo.of(GTRegistries.Keys.RECIPE_TYPE, + GTRecipeType.class); + public static final RegistryInfo RECIPE_CATEGORY = RegistryInfo + .of(GTRegistries.Keys.RECIPE_CATEGORY, GTRecipeCategory.class); + + public static final RegistryInfo WORLD_GEN_LAYER = RegistryInfo + .of(GTRegistries.Keys.WORLD_GEN_LAYER, IWorldGenLayer.class); + public static final RegistryInfo TAG_PREFIX = RegistryInfo.of(GTRegistries.Keys.TAG_PREFIX, + TagPrefix.class); + public static final RegistryInfo DIMENSION_MARKER = RegistryInfo + .of(GTRegistries.Keys.DIMENSION_MARKER, DimensionMarker.class); + public static final RegistryInfo MACHINE = RegistryInfo.of(GTRegistries.Keys.MACHINE, + MachineDefinition.class); } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java index 5c6c65a08d9..2d6b5c1d1a1 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java @@ -6,7 +6,6 @@ import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; import com.gregtechceu.gtceu.api.cosmetics.CapeRegistry; -import com.gregtechceu.gtceu.api.data.DimensionMarker; import com.gregtechceu.gtceu.api.data.RotationState; import com.gregtechceu.gtceu.api.data.chemical.ChemicalHelper; import com.gregtechceu.gtceu.api.data.chemical.Element; @@ -57,8 +56,6 @@ import com.gregtechceu.gtceu.api.recipe.lookup.RecipeManagerHandler; import com.gregtechceu.gtceu.api.recipe.modifier.ModifierFunction; import com.gregtechceu.gtceu.api.registry.GTRegistries; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; -import com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder; import com.gregtechceu.gtceu.client.renderer.machine.DynamicRenderHelper; import com.gregtechceu.gtceu.common.cosmetics.GTCapes; import com.gregtechceu.gtceu.common.data.*; @@ -79,8 +76,10 @@ import com.gregtechceu.gtceu.integration.kjs.builders.block.ActiveBlockBuilder; import com.gregtechceu.gtceu.integration.kjs.builders.block.CoilBlockBuilder; import com.gregtechceu.gtceu.integration.kjs.builders.machine.*; -import com.gregtechceu.gtceu.integration.kjs.builders.prefix.BasicTagPrefixBuilder; -import com.gregtechceu.gtceu.integration.kjs.builders.prefix.OreTagPrefixBuilder; +import com.gregtechceu.gtceu.integration.kjs.builders.material.*; +import com.gregtechceu.gtceu.integration.kjs.builders.recipe.GTRecipeCategoryBuilder; +import com.gregtechceu.gtceu.integration.kjs.builders.recipe.GTRecipeTypeBuilder; +import com.gregtechceu.gtceu.integration.kjs.builders.worldgen.WorldGenLayerBuilder; import com.gregtechceu.gtceu.integration.kjs.helpers.MachineConstructors; import com.gregtechceu.gtceu.integration.kjs.helpers.MachineModifiers; import com.gregtechceu.gtceu.integration.kjs.helpers.MaterialStackWrapper; @@ -91,7 +90,13 @@ import com.gregtechceu.gtceu.integration.kjs.recipe.components.ExtendedOutputItem; import com.gregtechceu.gtceu.integration.kjs.recipe.components.GTRecipeComponents; +import net.minecraft.ResourceLocationException; +import net.minecraft.core.Holder; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.NbtOps; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; @@ -103,12 +108,10 @@ import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.registries.ForgeRegistries; +import com.google.gson.JsonPrimitive; import com.mojang.serialization.DataResult; import dev.latvian.mods.kubejs.KubeJSPlugin; import dev.latvian.mods.kubejs.block.state.BlockStatePredicate; -import dev.latvian.mods.kubejs.client.LangEventJS; -import dev.latvian.mods.kubejs.generator.AssetJsonGenerator; -import dev.latvian.mods.kubejs.generator.DataJsonGenerator; import dev.latvian.mods.kubejs.recipe.KubeJSRecipeEventHandler; import dev.latvian.mods.kubejs.recipe.RecipeJS; import dev.latvian.mods.kubejs.recipe.RecipesEventJS; @@ -125,6 +128,7 @@ import it.unimi.dsi.fastutil.chars.Char2IntMap; import it.unimi.dsi.fastutil.chars.Char2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; +import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.Map; @@ -144,49 +148,47 @@ public void initStartup() { @Override public void init() { super.init(); - GTRegistryInfo.ELEMENT.addType("basic", ElementBuilder.class, ElementBuilder::new, true); + GTRegistryInfo.ELEMENT.addType("basic", ElementBuilder.class, ElementBuilder::new, true); GTRegistryInfo.MATERIAL_ICON_SET.addType("basic", MaterialIconSetBuilder.class, MaterialIconSetBuilder::new, true); - GTRegistryInfo.MATERIAL_ICON_TYPE.addType("basic", MaterialIconTypeBuilder.class, MaterialIconTypeBuilder::new, - true); - - GTRegistryInfo.MATERIAL.addType("basic", Material.Builder.class, Material.Builder::new, true); - + GTRegistryInfo.MATERIAL.addType("basic", MaterialBuilderWrapper.class, MaterialBuilderWrapper::new, true); GTRegistryInfo.RECIPE_TYPE.addType("basic", GTRecipeTypeBuilder.class, GTRecipeTypeBuilder::new, true); GTRegistryInfo.RECIPE_CATEGORY.addType("basic", GTRecipeCategoryBuilder.class, GTRecipeCategoryBuilder::new, true); + GTRegistryInfo.WORLD_GEN_LAYER.addType("basic", WorldGenLayerBuilder.class, WorldGenLayerBuilder::new, true); + GTRegistryInfo.TAG_PREFIX.addType("basic", TagPrefixBuilder.class, TagPrefixBuilder::new, true); + GTRegistryInfo.TAG_PREFIX.addType("ore", OreTagPrefixBuilder.class, OreTagPrefixBuilder::new); + GTRegistryInfo.DIMENSION_MARKER.addType("basic", DimensionMarkerBuilder.class, DimensionMarkerBuilder::new, + true); + + RegistryInfo.BLOCK.addType("gtceu:active", ActiveBlockBuilder.class, ActiveBlockBuilder::new); + RegistryInfo.BLOCK.addType("gtceu:coil", CoilBlockBuilder.class, CoilBlockBuilder::new); + GTRegistryInfo.MACHINE.addType("simple", KJSWrappingMachineBuilder.class, (id) -> new KJSWrappingMachineBuilder(id, new KJSTieredMachineBuilder(id, SimpleTieredMachine::new, false)), true); GTRegistryInfo.MACHINE.addType("custom", KJSWrappingMachineBuilder.class, - (id) -> new KJSWrappingMachineBuilder(id, new KJSTieredMachineBuilder(id)), - false); + (id) -> new KJSWrappingMachineBuilder(id, new KJSTieredMachineBuilder(id))); GTRegistryInfo.MACHINE.addType("steam", KJSSteamMachineBuilder.class, - KJSSteamMachineBuilder::new, false); + KJSSteamMachineBuilder::new); GTRegistryInfo.MACHINE.addType("generator", KJSWrappingMachineBuilder.class, (id) -> new KJSWrappingMachineBuilder(id, - new KJSTieredMachineBuilder(id, SimpleGeneratorMachine::new, true)), - false); - GTRegistryInfo.MACHINE.addType("multiblock", - (Class>) (Class) MultiblockMachineBuilder.class, - KJSWrappingMultiblockBuilder::createKJSMulti, false); + new KJSTieredMachineBuilder(id, SimpleGeneratorMachine::new, true))); + GTRegistryInfo.MACHINE.addType("multiblock", MultiblockMachineBuilderWrapper.class, + MultiblockMachineBuilderWrapper::createKJSMulti); GTRegistryInfo.MACHINE.addType("tiered_multiblock", KJSWrappingMultiblockBuilder.class, - (id) -> new KJSWrappingMultiblockBuilder(id, new KJSTieredMultiblockBuilder(id)), false); - GTRegistryInfo.MACHINE.addType("primitive", - (Class>) (Class) MultiblockMachineBuilder.class, - (id) -> KJSWrappingMultiblockBuilder.createKJSMulti(id, PrimitiveWorkableMachine::new), - false); - - GTRegistryInfo.WORLD_GEN_LAYER.addType("basic", WorldGenLayerBuilder.class, WorldGenLayerBuilder::new, true); + KJSWrappingMultiblockBuilder::new); + GTRegistryInfo.MACHINE.addType("primitive", MultiblockMachineBuilderWrapper.class, + (id) -> MultiblockMachineBuilderWrapper.createKJSMulti(id, PrimitiveWorkableMachine::new)); - GTRegistryInfo.TAG_PREFIX.addType("basic", BasicTagPrefixBuilder.class, BasicTagPrefixBuilder::new, true); - GTRegistryInfo.TAG_PREFIX.addType("ore", OreTagPrefixBuilder.class, OreTagPrefixBuilder::new, false); - - GTRegistryInfo.DIMENSION_MARKER.addType("basic", DimensionMarker.Builder.class, DimensionMarker.Builder::new, - true); + /* + * GTRegistryInfo.MATERIAL_ICON_TYPE.addType("basic", MaterialIconTypeBuilder.class, + * MaterialIconTypeBuilder::new, + * true); + */ RegistryInfo.BLOCK.addType("gtceu:active", ActiveBlockBuilder.class, ActiveBlockBuilder::new); RegistryInfo.BLOCK.addType("gtceu:coil", CoilBlockBuilder.class, CoilBlockBuilder::new); @@ -199,29 +201,16 @@ public void registerEvents() { GTCEuServerEvents.GROUP.register(); } - @Override - public void generateDataJsons(DataJsonGenerator generator) { - GTRegistryInfo.ALL_BUILDERS.forEach(builderBase -> builderBase.generateDataJsons(generator)); - } - public static void generateMachineBlockModels() { - GTRegistryInfo.ALL_BUILDERS.forEach(builderBase -> { - try { - builderBase.generateAssetJsons(null); - } catch (IllegalStateException ignored) {} + GTRegistryInfo.MACHINE.forEach(builder -> { + if (builder instanceof IMachineBuilderKJS machineBuilder) { + try { + machineBuilder.generateMachineModels(); + } catch (IllegalStateException ignored) {} + } }); } - @Override - public void generateAssetJsons(AssetJsonGenerator generator) { - GTRegistryInfo.ALL_BUILDERS.forEach(builderBase -> builderBase.generateAssetJsons(generator)); - } - - @Override - public void generateLang(LangEventJS event) { - GTRegistryInfo.ALL_BUILDERS.forEach(builderBase -> builderBase.generateLang(event)); - } - @Override public void registerClasses(ScriptType type, ClassFilter filter) { super.registerClasses(type, filter); @@ -235,8 +224,12 @@ public void registerClasses(ScriptType type, ClassFilter filter) { public void registerRecipeSchemas(RegisterRecipeSchemasEvent event) { super.registerRecipeSchemas(event); - for (var entry : GTRegistries.RECIPE_TYPES.entries()) { - event.register(entry.getKey(), GTRecipeSchema.SCHEMA); + var recipeTypes = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY) + .registryOrThrow(Registries.RECIPE_TYPE); + for (var id : recipeTypes.keySet()) { + RecipeType type = recipeTypes.get(id); + if (!(type instanceof GTRecipeType)) continue; + event.register(id, GTRecipeSchema.SCHEMA); } var ns = event.namespace(GTCEu.MOD_ID); ns.put("shaped", new WrappingRecipeSchemaType(ns, GTCEu.id("shaped"), @@ -355,68 +348,99 @@ public void registerBindings(BindingsEvent event) { event.add("CapeRegistry", CapeRegistry.class); } + private static @Nullable ResourceLocation unwrapResourceLocation(Object o) { + ResourceLocation inner; + if (o == null) inner = null; + else if (o instanceof ResourceLocation resLoc) inner = resLoc; + else if (o instanceof ResourceKey key) inner = key.location(); + else if (o instanceof Holder holder) + inner = holder.unwrapKey().isEmpty() ? null : holder.unwrapKey().get().location(); + else { + var s = o instanceof JsonPrimitive p ? p.getAsString() : o.toString(); + s = GTCEu.appendIdString(s); + + try { + inner = ResourceLocation.tryParse(s); + } catch (ResourceLocationException ex) { + throw new RuntimeException("Could not create ID from '%s'!".formatted(s)); + } + } + return inner; + } + @Override public void registerTypeWrappers(ScriptType type, TypeWrappers typeWrappers) { super.registerTypeWrappers(type, typeWrappers); typeWrappers.registerSimple(GTRecipeType.class, o -> { - if (o instanceof Wrapper w) { - o = w.unwrap(); - } + o = Wrapper.unwrapped(o); if (o instanceof GTRecipeType recipeType) return recipeType; - if (o instanceof CharSequence chars) return GTRecipeTypes.get(chars.toString()); - return null; + ResourceLocation location = unwrapResourceLocation(o); + if (location == null) return null; + return (GTRecipeType) BuiltInRegistries.RECIPE_TYPE.get(location); }); typeWrappers.registerSimple(GTRecipeCategory.class, o -> { - if (o instanceof Wrapper w) { - o = w.unwrap(); - } + o = Wrapper.unwrapped(o); if (o instanceof GTRecipeCategory recipeCategory) return recipeCategory; - if (o instanceof CharSequence chars) return GTRecipeCategories.get(chars.toString()); - return null; + ResourceLocation location = unwrapResourceLocation(o); + if (location == null) return null; + return GTRegistries.RECIPE_CATEGORIES.get(location); }); typeWrappers.registerSimple(Element.class, o -> { + o = Wrapper.unwrapped(o); if (o instanceof Element element) return element; - if (o instanceof CharSequence chars) return GTRegistries.ELEMENTS.get(GTCEu.id(chars.toString())); - return null; + ResourceLocation location = unwrapResourceLocation(o); + if (location == null) return null; + return GTRegistries.ELEMENTS.get(location); }); typeWrappers.registerSimple(Material.class, o -> { + o = Wrapper.unwrapped(o); if (o instanceof Material material) return material; - if (o instanceof CharSequence chars) return GTMaterials.get(chars.toString()); - return null; + ResourceLocation location = unwrapResourceLocation(o); + if (location == null) return null; + return GTRegistries.MATERIALS.get(location); }); typeWrappers.registerSimple(MachineDefinition.class, o -> { + o = Wrapper.unwrapped(o); if (o instanceof MachineDefinition definition) return definition; - if (o instanceof CharSequence chars) return GTMachines.get(chars.toString()); - return null; + ResourceLocation location = unwrapResourceLocation(o); + if (location == null) return null; + return GTRegistries.MACHINES.get(location); }); typeWrappers.registerSimple(TagPrefix.class, o -> { + o = Wrapper.unwrapped(o); if (o instanceof TagPrefix tagPrefix) return tagPrefix; - if (o instanceof CharSequence chars) return GTRegistries.TAG_PREFIXES.get(GTCEu.id(chars.toString())); - return null; + ResourceLocation location = unwrapResourceLocation(o); + if (location == null) return null; + return GTRegistries.TAG_PREFIXES.get(location); }); - typeWrappers.registerSimple(MaterialEntry.class, MaterialEntry::of); + typeWrappers.registerSimple(RecipeCapability.class, o -> { + o = Wrapper.unwrapped(o); if (o instanceof RecipeCapability capability) return capability; - if (o instanceof ResourceLocation loc) return GTRegistries.RECIPE_CAPABILITIES.get(loc); - if (o instanceof CharSequence chars) - return GTRegistries.RECIPE_CAPABILITIES.get(GTCEu.id(chars.toString())); - return null; + ResourceLocation location = unwrapResourceLocation(o); + if (location == null) return null; + return GTRegistries.RECIPE_CAPABILITIES.get(location); }); typeWrappers.registerSimple(ChanceLogic.class, o -> { + o = Wrapper.unwrapped(o); if (o instanceof ChanceLogic capability) return capability; - if (o instanceof CharSequence chars) return GTRegistries.CHANCE_LOGICS.get(GTCEu.id(chars.toString())); - return null; + ResourceLocation location = unwrapResourceLocation(o); + if (location == null) return null; + return GTRegistries.CHANCE_LOGICS.get(location); }); - typeWrappers.registerSimple(ExtendedOutputItem.class, ExtendedOutputItem::of); typeWrappers.registerSimple(MaterialIconSet.class, o -> { + o = Wrapper.unwrapped(o); if (o instanceof MaterialIconSet iconSet) return iconSet; - if (o instanceof CharSequence chars) return GTRegistries.MATERIAL_ICON_SETS - .get(GTCEu.id(chars.toString())); - return null; + ResourceLocation location = unwrapResourceLocation(o); + if (location == null) return null; + return GTRegistries.MATERIAL_ICON_SETS.get(location); }); + + typeWrappers.registerSimple(MaterialEntry.class, MaterialEntry::of); + typeWrappers.registerSimple(ExtendedOutputItem.class, ExtendedOutputItem::of); typeWrappers.registerSimple(MaterialStack.class, o -> { if (o instanceof MaterialStack stack) return stack; if (o instanceof Material material) return new MaterialStack(material, 1); diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/DimensionMarkerBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/DimensionMarkerBuilder.java new file mode 100644 index 00000000000..ad475b7bb82 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/DimensionMarkerBuilder.java @@ -0,0 +1,42 @@ +package com.gregtechceu.gtceu.integration.kjs.builders; + +import com.gregtechceu.gtceu.api.data.DimensionMarker; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; + +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.Level; + +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; +import lombok.Setter; +import lombok.experimental.Accessors; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Supplier; + +@Setter +@Accessors(fluent = true, chain = true) +public class DimensionMarkerBuilder extends BuilderBase { + + private Supplier iconSupplier; + private int tier = 0; + @Nullable + private String overrideName; + private ResourceKey dimension; + + public DimensionMarkerBuilder(ResourceLocation id) { + super(id); + } + + @Override + public RegistryInfo getRegistryType() { + return GTRegistryInfo.DIMENSION_MARKER; + } + + @Override + public DimensionMarker createObject() { + return new DimensionMarker(dimension, tier, iconSupplier, overrideName); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/MaterialIconTypeBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/MaterialIconTypeBuilder.java deleted file mode 100644 index be41ad0764f..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/MaterialIconTypeBuilder.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.gregtechceu.gtceu.integration.kjs.builders; - -import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; - -import net.minecraft.resources.ResourceLocation; - -public class MaterialIconTypeBuilder extends BuilderBase { - - public MaterialIconTypeBuilder(ResourceLocation id) { - super(id); - } - - @Override - public MaterialIconType register() { - return new MaterialIconType(this.id.getPath()); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/IMachineBuilderKJS.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/IMachineBuilderKJS.java new file mode 100644 index 00000000000..bd3c446d63e --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/IMachineBuilderKJS.java @@ -0,0 +1,31 @@ +package com.gregtechceu.gtceu.integration.kjs.builders.machine; + +import com.gregtechceu.gtceu.api.block.MetaMachineBlock; +import com.gregtechceu.gtceu.api.machine.MachineDefinition; +import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; +import com.gregtechceu.gtceu.common.data.models.GTMachineModels; +import com.gregtechceu.gtceu.utils.data.RuntimeBlockstateProvider; + +import net.minecraft.world.level.block.Block; + +import com.tterrag.registrate.providers.DataGenContext; +import org.jetbrains.annotations.Nullable; + +public interface IMachineBuilderKJS { + + void generateMachineModels(); + + default void generateMachineModel(@Nullable MachineBuilder builder, @Nullable MachineDefinition definition) { + if (builder == null || definition == null) return; + if (builder.model() == null && builder.blockModel() == null) return; + + // Fake a data provider for the GT model builders + DataGenContext context = new DataGenContext<>(definition::get, + definition.getName(), definition.getId()); + if (builder.blockModel() != null) { + builder.blockModel().accept(context, RuntimeBlockstateProvider.INSTANCE); + } else { + GTMachineModels.createMachineModel(builder.model()).accept(context, RuntimeBlockstateProvider.INSTANCE); + } + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSSteamMachineBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSSteamMachineBuilder.java index 16d21bd0a9b..6c138fdb668 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSSteamMachineBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSSteamMachineBuilder.java @@ -7,21 +7,25 @@ import com.gregtechceu.gtceu.api.machine.property.GTMachineModelProperties; import com.gregtechceu.gtceu.api.machine.steam.SimpleSteamMachine; import com.gregtechceu.gtceu.api.multiblock.util.RelativeDirection; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; +import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate; import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; -import com.gregtechceu.gtceu.common.registry.GTRegistration; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; +import com.gregtechceu.gtceu.integration.kjs.helpers.IGTDummyBuilder; import com.gregtechceu.gtceu.utils.FormattingUtil; import net.minecraft.resources.ResourceLocation; import dev.latvian.mods.kubejs.client.LangEventJS; import dev.latvian.mods.kubejs.generator.AssetJsonGenerator; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.Nullable; @Accessors(fluent = true, chain = true) -public class KJSSteamMachineBuilder extends BuilderBase { +public class KJSSteamMachineBuilder extends BuilderBase + implements IMachineBuilderKJS, IGTDummyBuilder { @Setter public transient boolean hasLowPressure = true, hasHighPressure = true; @@ -30,69 +34,84 @@ public class KJSSteamMachineBuilder extends BuilderBase { @Setter public transient SteamDefinitionFunction definition = (isHP, def) -> def.tier(isHP ? 1 : 0); - private transient MachineBuilder lowPressureBuilder = null, highPressureBuilder = null; - private transient MachineDefinition hpValue = null; + private @Nullable MachineBuilder lowPressureBuilder = null, highPressureBuilder = null; + @Nullable + private MachineDefinition lpObject = null, hpObject = null; public KJSSteamMachineBuilder(ResourceLocation id) { super(id); } @Override - public MachineDefinition register() { + public RegistryInfo getRegistryType() { + return GTRegistryInfo.MACHINE; + } + + @Override + public MachineDefinition createObject() { + MachineDefinition value = null; if (hasLowPressure) { - this.lowPressureBuilder = GTRegistration.REGISTRATE.machine( - String.format("lp_%s", this.id.getPath()), - holder -> machine.create(holder, false)); - lowPressureBuilder.langValue("Low Pressure " + FormattingUtil.toEnglishName(this.id.getPath())) + this.lowPressureBuilder = GTRegistrate.createIgnoringListenerErrors(this.id.getNamespace()) + .machine(String.format("lp_%s", this.id.getPath()), + holder -> machine.create(holder, false)) + .langValue("Low Pressure " + FormattingUtil.toEnglishName(this.id.getPath())) .tier(0) .recipeModifier(SimpleSteamMachine::recipeModifier) .modelProperty(GTMachineModelProperties.VENT_DIRECTION, RelativeDirection.BACK) .workableSteamHullModel(false, id.withPrefix("block/machines/")); + definition.apply(false, lowPressureBuilder); - value = lowPressureBuilder.register(); + this.lpObject = lowPressureBuilder.register(); + value = lpObject; } if (hasHighPressure) { - this.highPressureBuilder = GTRegistration.REGISTRATE.machine( - String.format("hp_%s", this.id.getPath()), - holder -> machine.create(holder, true)); - highPressureBuilder.langValue("High Pressure " + FormattingUtil.toEnglishName(this.id.getPath())) + this.highPressureBuilder = GTRegistrate.createIgnoringListenerErrors(this.id.getNamespace()) + .machine(String.format("hp_%s", this.id.getPath()), + holder -> machine.create(holder, true)) + .langValue("High Pressure " + FormattingUtil.toEnglishName(this.id.getPath())) .tier(1) .recipeModifier(SimpleSteamMachine::recipeModifier) .modelProperty(GTMachineModelProperties.VENT_DIRECTION, RelativeDirection.BACK) .workableSteamHullModel(true, id.withPrefix("block/machines/")); + definition.apply(true, highPressureBuilder); - hpValue = highPressureBuilder.register(); + this.hpObject = highPressureBuilder.register(); + if (value == null) value = hpObject; } - return value != null ? value : hpValue; + return value; + } + + @Override + public void generateMachineModels() { + generateMachineModel(lowPressureBuilder, lpObject); + generateMachineModel(highPressureBuilder, hpObject); } @Override - public void generateAssetJsons(@Nullable AssetJsonGenerator generator) { - super.generateAssetJsons(generator); + public void generateAssetJsons(AssetJsonGenerator generator) { if (this.lowPressureBuilder != null) { - this.lowPressureBuilder.generateAssetJsons(generator); + generator.itemModel(id, gen -> gen.parent(id.withPrefix("block/machine/").toString())); } if (this.highPressureBuilder != null) { - this.highPressureBuilder.generateAssetJsons(generator); + generator.itemModel(id, gen -> gen.parent(id.withPrefix("block/machine/").toString())); } } @Override - public void generateLang(LangEventJS lang) { - super.generateLang(lang); - if (value != null) { - lang.add(GTCEu.MOD_ID, value.getDescriptionId(), value.getLangValue()); - } - if (hpValue != null) { - lang.add(GTCEu.MOD_ID, hpValue.getDescriptionId(), hpValue.getLangValue()); - } + public String getTranslationKeyGroup() { + return "block"; } @Override - public MachineDefinition get() { - return value != null ? value : hpValue; + public void generateLang(LangEventJS lang) { + if (lpObject != null) { + lang.add(GTCEu.MOD_ID, lpObject.getDescriptionId(), lpObject.getLangValue()); + } + if (hpObject != null) { + lang.add(GTCEu.MOD_ID, hpObject.getDescriptionId(), hpObject.getLangValue()); + } } @FunctionalInterface diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSTieredMachineBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSTieredMachineBuilder.java index ac1fa4bd609..dec182e9f88 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSTieredMachineBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSTieredMachineBuilder.java @@ -1,35 +1,41 @@ package com.gregtechceu.gtceu.integration.kjs.builders.machine; +import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.GTValues; import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo; import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.machine.MetaMachine; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; +import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate; import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; import com.gregtechceu.gtceu.common.data.machines.GTMachineUtils; -import com.gregtechceu.gtceu.common.registry.GTRegistration; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; +import com.gregtechceu.gtceu.integration.kjs.helpers.IGTDummyBuilder; import net.minecraft.resources.ResourceLocation; import com.google.common.base.Preconditions; import dev.latvian.mods.kubejs.client.LangEventJS; import dev.latvian.mods.kubejs.generator.AssetJsonGenerator; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import it.unimi.dsi.fastutil.ints.Int2IntFunction; import lombok.Setter; import lombok.experimental.Accessors; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.Locale; +import java.util.Objects; import static com.gregtechceu.gtceu.api.GTValues.*; import static com.gregtechceu.gtceu.utils.FormattingUtil.toEnglishName; @Accessors(fluent = true, chain = true) -public class KJSTieredMachineBuilder extends BuilderBase { +public class KJSTieredMachineBuilder extends BuilderBase + implements IMachineBuilderKJS, IGTDummyBuilder { - private final MachineBuilder[] builders = new MachineBuilder[TIER_COUNT]; + private final @Nullable MachineBuilder[] builders = new MachineBuilder[TIER_COUNT]; + private final @Nullable MachineDefinition[] machines = new MachineDefinition[TIER_COUNT]; @Setter public transient int[] tiers = GTMachineUtils.ELECTRIC_TIERS; @@ -38,7 +44,7 @@ public class KJSTieredMachineBuilder extends BuilderBase { @Setter public transient DefinitionFunction definition = (tier, def) -> def.tier(tier); @Setter - public transient Int2IntFunction tankScalingFunction = GTMachineUtils.defaultTankSizeFunction; + public transient @Nullable Int2IntFunction tankScalingFunction = GTMachineUtils.defaultTankSizeFunction; @Setter public transient boolean addDefaultTooltips = true; @Setter @@ -52,6 +58,11 @@ public KJSTieredMachineBuilder(ResourceLocation id) { this.addDefaultModel = false; } + @Override + public RegistryInfo getRegistryType() { + return GTRegistryInfo.MACHINE; + } + public KJSTieredMachineBuilder(ResourceLocation id, TieredCreationFunction machine, boolean isGenerator) { super(id); @@ -60,41 +71,53 @@ public KJSTieredMachineBuilder(ResourceLocation id, TieredCreationFunction machi } @Override - public void generateAssetJsons(@Nullable AssetJsonGenerator generator) { - super.generateAssetJsons(generator); + public void generateMachineModels() { for (int tier : this.tiers) { - MachineBuilder builder = this.builders[tier]; - if (builder != null) { - builder.generateAssetJsons(generator); - } + generateMachineModel(this.builders[tier], this.machines[tier]); } } @Override - public void generateLang(@NotNull LangEventJS lang) { + public void generateAssetJsons(AssetJsonGenerator generator) { + for (int tier : this.tiers) { + var definition = this.machines[tier]; + if (definition == null) continue; + + final ResourceLocation id = definition.getId(); + generator.itemModel(id, gen -> gen.parent(id.withPrefix("block/machine/").toString())); + } + } + + @Override + public void generateLang(LangEventJS lang) { super.generateLang(lang); for (int tier : this.tiers) { - MachineBuilder builder = this.builders[tier]; - if (builder != null) { - builder.generateLang(lang); + MachineDefinition def = this.machines[tier]; + if (def != null) { + lang.add(GTCEu.MOD_ID, def.getDescriptionId(), def.getLangValue()); } } } @Override - public @Nullable MachineDefinition @NotNull [] register() { + public MachineDefinition createObject() { Preconditions.checkNotNull(tiers, "Tiers can't be null!"); Preconditions.checkArgument(tiers.length > 0, "tiers must have at least one tier!"); Preconditions.checkNotNull(machine, "You must set a machine creation function! " + "example: `builder.machine((holder, tier) => new SimpleTieredMachine(holder, tier, t => t * 3200)`"); Preconditions.checkNotNull(definition, "You must set a definition function! " + "See GTMachines for examples"); - MachineDefinition[] definitions = new MachineDefinition[TIER_COUNT]; + + MachineDefinition anyDefinition = null; + for (final int tier : tiers) { String tierName = VN[tier].toLowerCase(Locale.ROOT); - MachineBuilder builder = GTRegistration.REGISTRATE.machine( - String.format("%s_%s", tierName, this.id.getPath()), - holder -> machine.create(holder, tier, tankScalingFunction)); + final Int2IntFunction tankFunction = Objects.requireNonNullElse(tankScalingFunction, + GTMachineUtils.defaultTankSizeFunction); + + MachineBuilder builder = GTRegistrate.createIgnoringListenerErrors(this.id.getNamespace()) + .machine(String.format("%s_%s", tierName, this.id.getPath()), + holder -> machine.create(holder, tier, tankFunction)); builder.langValue("%s %s %s".formatted(VLVH[tier], toEnglishName(this.id.getPath()), VLVT[tier])) .tier(tier); @@ -113,9 +136,10 @@ public void generateLang(@NotNull LangEventJS lang) { } this.builders[tier] = builder; - definitions[tier] = builder.register(); + this.machines[tier] = builder.register(); + anyDefinition = this.machines[tier]; } - return value = definitions; + return Objects.requireNonNull(anyDefinition); } @FunctionalInterface diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSTieredMultiblockBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSTieredMultiblockBuilder.java index 4961497b932..41321c74ba8 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSTieredMultiblockBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSTieredMultiblockBuilder.java @@ -1,33 +1,39 @@ package com.gregtechceu.gtceu.integration.kjs.builders.machine; import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo; +import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; import com.gregtechceu.gtceu.api.machine.multiblock.MultiblockControllerMachine; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; +import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate; import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; import com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder; import com.gregtechceu.gtceu.common.data.machines.GTMachineUtils; -import com.gregtechceu.gtceu.common.registry.GTRegistration; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; +import com.gregtechceu.gtceu.integration.kjs.helpers.IGTDummyBuilder; import net.minecraft.resources.ResourceLocation; import com.google.common.base.Preconditions; import dev.latvian.mods.kubejs.client.LangEventJS; import dev.latvian.mods.kubejs.generator.AssetJsonGenerator; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import lombok.Setter; import lombok.experimental.Accessors; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Locale; +import java.util.Objects; -import static com.gregtechceu.gtceu.api.GTValues.*; +import static com.gregtechceu.gtceu.api.GTValues.TIER_COUNT; +import static com.gregtechceu.gtceu.api.GTValues.VN; @Accessors(fluent = true, chain = true) -public class KJSTieredMultiblockBuilder extends BuilderBase { - - private final MultiblockMachineBuilder[] builders = new MultiblockMachineBuilder[TIER_COUNT]; +public class KJSTieredMultiblockBuilder extends BuilderBase + implements IMachineBuilderKJS, IGTDummyBuilder { + private final @Nullable MultiblockMachineBuilder[] builders = new MultiblockMachineBuilder[TIER_COUNT]; + private final @Nullable MultiblockMachineDefinition[] machines = new MultiblockMachineDefinition[TIER_COUNT]; @Setter public transient int[] tiers = GTMachineUtils.ELECTRIC_TIERS; @Setter @@ -45,49 +51,69 @@ public KJSTieredMultiblockBuilder(ResourceLocation id, TieredCreationFunction ma } @Override - public void generateAssetJsons(@Nullable AssetJsonGenerator generator) { - super.generateAssetJsons(generator); + public RegistryInfo getRegistryType() { + return GTRegistryInfo.MACHINE; + } + + @Override + public void generateMachineModels() { for (int tier : this.tiers) { - MultiblockMachineBuilder builder = this.builders[tier]; - if (builder != null) { - builder.generateAssetJsons(generator); - } + generateMachineModel(this.builders[tier], this.machines[tier]); + } + } + + @Override + public void generateAssetJsons(AssetJsonGenerator generator) { + for (int tier : this.tiers) { + MachineDefinition definition = this.machines[tier]; + if (definition == null) continue; + + final ResourceLocation id = definition.getId(); + generator.itemModel(id, gen -> gen.parent(id.withPrefix("block/machine/").toString())); } } + @Override + public String getTranslationKeyGroup() { + return "block"; + } + @Override public void generateLang(LangEventJS lang) { - super.generateLang(lang); for (int tier : tiers) { - MultiblockMachineBuilder builder = this.builders[tier]; - if (builder != null) { - builder.generateLang(lang); + MachineDefinition def = machines[tier]; + if (def != null) { + lang.add(def.getId().getNamespace(), def.getDescriptionId(), def.getLangValue()); } } } @Override - public @Nullable MultiblockMachineDefinition @NotNull [] register() { + public MultiblockMachineDefinition createObject() { Preconditions.checkNotNull(tiers, "Tiers can't be null!"); Preconditions.checkArgument(tiers.length > 0, "tiers must have at least one tier!"); Preconditions.checkNotNull(machine, "You must set a machine creation function! " + "example: `builder.machine((holder, tier) => new SimpleTieredMachine(holder, tier, t => t * 3200)`"); Preconditions.checkNotNull(definition, "You must set a definition function! " + "See GTMachines for examples"); - MultiblockMachineDefinition[] definitions = new MultiblockMachineDefinition[TIER_COUNT]; + + MultiblockMachineDefinition anyDefinition = null; + for (final int tier : tiers) { String tierName = VN[tier].toLowerCase(Locale.ROOT); - MultiblockMachineBuilder builder = GTRegistration.REGISTRATE.multiblock( - String.format("%s_%s", tierName, this.id.getPath()), - holder -> machine.create(holder, tier)); + MultiblockMachineBuilder builder = GTRegistrate + .createIgnoringListenerErrors(this.id.getNamespace()) + .multiblock(String.format("%s_%s", tierName, this.id.getPath()), + holder -> machine.create(holder, tier)); builder.workableTieredHullModel(id.withPrefix("block/machines/")) .tier(tier); this.definition.apply(tier, builder); this.builders[tier] = builder; - definitions[tier] = builder.register(); + this.machines[tier] = builder.register(); + anyDefinition = this.machines[tier]; } - return value = definitions; + return Objects.requireNonNull(anyDefinition); } @FunctionalInterface diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSWrappingMachineBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSWrappingMachineBuilder.java index 0efd04f3e62..c78172148f3 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSWrappingMachineBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSWrappingMachineBuilder.java @@ -1,22 +1,23 @@ package com.gregtechceu.gtceu.integration.kjs.builders.machine; import com.gregtechceu.gtceu.api.machine.MachineDefinition; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; +import com.gregtechceu.gtceu.integration.kjs.helpers.IGTDummyBuilder; import net.minecraft.resources.ResourceLocation; import dev.latvian.mods.kubejs.client.LangEventJS; import dev.latvian.mods.kubejs.generator.AssetJsonGenerator; import dev.latvian.mods.kubejs.generator.DataJsonGenerator; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import dev.latvian.mods.rhino.util.HideFromJS; import it.unimi.dsi.fastutil.ints.Int2IntFunction; import lombok.Getter; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; @SuppressWarnings("unused") -public class KJSWrappingMachineBuilder extends BuilderBase { +public class KJSWrappingMachineBuilder extends BuilderBase + implements IMachineBuilderKJS, IGTDummyBuilder { @HideFromJS @Getter @@ -27,6 +28,11 @@ public KJSWrappingMachineBuilder(ResourceLocation id, KJSTieredMachineBuilder ti this.tieredBuilder = tieredBuilder; } + @Override + public RegistryInfo getRegistryType() { + return GTRegistryInfo.MACHINE; + } + public KJSWrappingMachineBuilder tiers(int... tiers) { tieredBuilder.tiers(tiers); return this; @@ -68,7 +74,12 @@ public void generateDataJsons(DataJsonGenerator generator) { } @Override - public void generateAssetJsons(@Nullable AssetJsonGenerator generator) { + public void generateMachineModels() { + tieredBuilder.generateMachineModels(); + } + + @Override + public void generateAssetJsons(AssetJsonGenerator generator) { tieredBuilder.generateAssetJsons(generator); } @@ -78,15 +89,7 @@ public void generateLang(LangEventJS lang) { } @Override - public MachineDefinition register() { - tieredBuilder.register(); - for (var def : tieredBuilder.get()) { - if (def != null) { - return value = def; - } - } - // should never happen. - throw new IllegalStateException("Empty tiered machine builder " + Arrays.toString(tieredBuilder.get()) + - " With id " + tieredBuilder.id); + public MachineDefinition createObject() { + return tieredBuilder.createObject(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSWrappingMultiblockBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSWrappingMultiblockBuilder.java index dd460fae0e3..c8519407a95 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSWrappingMultiblockBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/KJSWrappingMultiblockBuilder.java @@ -1,34 +1,35 @@ package com.gregtechceu.gtceu.integration.kjs.builders.machine; -import com.gregtechceu.gtceu.api.block.MetaMachineBlock; -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.MultiblockControllerMachine; -import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; -import com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder; -import com.gregtechceu.gtceu.common.registry.GTRegistration; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; +import com.gregtechceu.gtceu.integration.kjs.helpers.IGTDummyBuilder; import net.minecraft.resources.ResourceLocation; import dev.latvian.mods.kubejs.client.LangEventJS; import dev.latvian.mods.kubejs.generator.AssetJsonGenerator; import dev.latvian.mods.kubejs.generator.DataJsonGenerator; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import dev.latvian.mods.rhino.util.HideFromJS; import lombok.Getter; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; - -public class KJSWrappingMultiblockBuilder extends BuilderBase { +public class KJSWrappingMultiblockBuilder extends BuilderBase + implements IMachineBuilderKJS, IGTDummyBuilder { @HideFromJS @Getter private final KJSTieredMultiblockBuilder tieredBuilder; - public KJSWrappingMultiblockBuilder(ResourceLocation id, KJSTieredMultiblockBuilder tieredBuilder) { + public KJSWrappingMultiblockBuilder(ResourceLocation id) { super(id); - this.tieredBuilder = tieredBuilder; + this.tieredBuilder = new KJSTieredMultiblockBuilder(this.id); + } + + @Override + public RegistryInfo getRegistryType() { + return GTRegistryInfo.MACHINE; } public KJSWrappingMultiblockBuilder tiers(int... tiers) { @@ -52,7 +53,12 @@ public void generateDataJsons(DataJsonGenerator generator) { } @Override - public void generateAssetJsons(@Nullable AssetJsonGenerator generator) { + public void generateMachineModels() { + tieredBuilder.generateMachineModels(); + } + + @Override + public void generateAssetJsons(AssetJsonGenerator generator) { tieredBuilder.generateAssetJsons(generator); } @@ -62,30 +68,7 @@ public void generateLang(LangEventJS lang) { } @Override - public MultiblockMachineDefinition register() { - tieredBuilder.register(); - for (var def : tieredBuilder.get()) { - if (def != null) { - return value = def; - } - } - // should never happen. - throw new IllegalStateException("Empty tiered multiblock builder " + Arrays.toString(tieredBuilder.get()) + - " With id " + tieredBuilder.id); - } - - public static MultiblockMachineBuilder createKJSMulti(ResourceLocation id) { - return new MultiblockMachineBuilder<>(GTRegistration.REGISTRATE, id.getPath(), - MetaMachineBlock::new, - MetaMachineItem::new, - WorkableElectricMultiblockMachine::new); - } - - public static MultiblockMachineBuilder createKJSMulti(ResourceLocation id, - KJSTieredMachineBuilder.CreationFunction machine) { - return new MultiblockMachineBuilder<>(GTRegistration.REGISTRATE, id.getPath(), - MetaMachineBlock::new, - MetaMachineItem::new, - machine::create); + public MultiblockMachineDefinition createObject() { + return tieredBuilder.createObject(); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MultiblockMachineBuilderWrapper.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MultiblockMachineBuilderWrapper.java new file mode 100644 index 00000000000..40ddb96c675 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/machine/MultiblockMachineBuilderWrapper.java @@ -0,0 +1,442 @@ +package com.gregtechceu.gtceu.integration.kjs.builders.machine; + +import com.gregtechceu.gtceu.api.block.MetaMachineBlock; +import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo; +import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability; +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.MetaMachine; +import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; +import com.gregtechceu.gtceu.api.machine.feature.IRecipeLogicMachine; +import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiPart; +import com.gregtechceu.gtceu.api.machine.multiblock.MultiblockControllerMachine; +import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility; +import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine; +import com.gregtechceu.gtceu.api.multiblock.pattern.IBlockPattern; +import com.gregtechceu.gtceu.api.recipe.GTRecipe; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; +import com.gregtechceu.gtceu.api.recipe.modifier.RecipeModifier; +import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate; +import com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder; +import com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder; +import com.gregtechceu.gtceu.api.registry.registrate.provider.GTBlockstateProvider; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; +import com.gregtechceu.gtceu.integration.kjs.helpers.IGTDummyBuilder; + +import net.minecraft.core.Direction; +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.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 com.tterrag.registrate.builders.BlockBuilder; +import com.tterrag.registrate.builders.ItemBuilder; +import com.tterrag.registrate.providers.DataGenContext; +import com.tterrag.registrate.util.nullness.NonNullBiConsumer; +import com.tterrag.registrate.util.nullness.NonNullConsumer; +import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; +import dev.latvian.mods.kubejs.client.LangEventJS; +import dev.latvian.mods.kubejs.generator.AssetJsonGenerator; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; +import it.unimi.dsi.fastutil.objects.Reference2IntMap; +import org.apache.commons.lang3.function.TriFunction; +import org.jetbrains.annotations.Nullable; + +import java.util.Comparator; +import java.util.List; +import java.util.function.*; + +@SuppressWarnings("unused") +public class MultiblockMachineBuilderWrapper extends BuilderBase + implements IMachineBuilderKJS, + IGTDummyBuilder { + + private final MultiblockMachineBuilder internal; + + public MultiblockMachineBuilderWrapper(ResourceLocation id, + MultiblockMachineBuilder internal) { + super(id); + this.internal = internal; + } + + @Override + public RegistryInfo getRegistryType() { + return GTRegistryInfo.MACHINE; + } + + public MultiblockMachineBuilderWrapper generator(boolean generator) { + internal.generator(generator); + return this; + } + + public MultiblockMachineBuilderWrapper pattern(Function pattern) { + internal.pattern(pattern); + return this; + } + + public MultiblockMachineBuilderWrapper allowFlip(boolean allowFlip) { + internal.allowFlip(allowFlip); + return this; + } + + public MultiblockMachineBuilderWrapper partSorter(Comparator partSorter) { + internal.partSorter(partSorter); + return this; + } + + public MultiblockMachineBuilderWrapper partAppearance(@Nullable TriFunction partAppearance) { + internal.partAppearance(partAppearance); + return this; + } + + public MultiblockMachineBuilderWrapper additionalDisplay(BiConsumer> additionalDisplay) { + internal.additionalDisplay(additionalDisplay); + return this; + } + + public MultiblockMachineBuilderWrapper recoveryItems(Supplier items) { + internal.recoveryItems(items); + return this; + } + + public MultiblockMachineBuilderWrapper recoveryStacks(Supplier stacks) { + internal.recoveryStacks(stacks); + return this; + } + + public MultiblockMachineBuilderWrapper definition(Function definition) { + internal.definition(definition); + return this; + } + + public MultiblockMachineBuilderWrapper blockEntityFactory(Function machine) { + internal.blockEntityFactory(machine); + return this; + } + + public MultiblockMachineBuilderWrapper model(@Nullable MachineBuilder.ModelInitializer model) { + internal.model(model); + return this; + } + + public MultiblockMachineBuilderWrapper blockModel(@Nullable NonNullBiConsumer, GTBlockstateProvider> blockModel) { + internal.blockModel(blockModel); + return this; + } + + public MultiblockMachineBuilderWrapper shape(VoxelShape shape) { + internal.shape(shape); + return this; + } + + public MultiblockMachineBuilderWrapper multiblockPreviewRenderer(boolean multiBlockWorldPreview, + boolean multiBlockXEIPreview) { + internal.multiblockPreviewRenderer(multiBlockWorldPreview, multiBlockXEIPreview); + return this; + } + + public MultiblockMachineBuilderWrapper rotationState(RotationState rotationState) { + internal.rotationState(rotationState); + return this; + } + + public MultiblockMachineBuilderWrapper hasBER(boolean hasBER) { + internal.hasBER(hasBER); + return this; + } + + public MultiblockMachineBuilderWrapper blockProp(NonNullUnaryOperator blockProp) { + internal.blockProp(blockProp); + return this; + } + + public MultiblockMachineBuilderWrapper itemProp(NonNullUnaryOperator itemProp) { + internal.itemProp(itemProp); + return this; + } + + public MultiblockMachineBuilderWrapper blockBuilder(@Nullable Consumer> blockBuilder) { + internal.blockBuilder(blockBuilder); + return this; + } + + public MultiblockMachineBuilderWrapper itemBuilder(@Nullable Consumer> itemBuilder) { + internal.itemBuilder(itemBuilder); + return this; + } + + public MultiblockMachineBuilderWrapper recipeTypes(GTRecipeType... recipeTypes) { + internal.recipeTypes(recipeTypes); + return this; + } + + public MultiblockMachineBuilderWrapper recipeType(GTRecipeType recipeTypes) { + internal.recipeType(recipeTypes); + return this; + } + + public MultiblockMachineBuilderWrapper tier(int tier) { + internal.tier(tier); + return this; + } + + public MultiblockMachineBuilderWrapper recipeOutputLimits(Reference2IntMap> map) { + internal.recipeOutputLimits(map); + return this; + } + + public MultiblockMachineBuilderWrapper addOutputLimit(RecipeCapability capability, int limit) { + internal.addOutputLimit(capability, limit); + return this; + } + + public MultiblockMachineBuilderWrapper itemColor(BiFunction itemColor) { + internal.itemColor(itemColor); + return this; + } + + public MultiblockMachineBuilderWrapper simpleModel(ResourceLocation model) { + internal.simpleModel(model); + return this; + } + + public MultiblockMachineBuilderWrapper defaultModel() { + internal.defaultModel(); + return this; + } + + public MultiblockMachineBuilderWrapper tieredHullModel(ResourceLocation model) { + internal.tieredHullModel(model); + return this; + } + + public MultiblockMachineBuilderWrapper overlayTieredHullModel(ResourceLocation overlayModel) { + internal.overlayTieredHullModel(overlayModel); + return this; + } + + public MultiblockMachineBuilderWrapper colorOverlayTieredHullModel(ResourceLocation overlay) { + internal.colorOverlayTieredHullModel(overlay); + return this; + } + + public MultiblockMachineBuilderWrapper colorOverlayTieredHullModel(ResourceLocation overlay, + @Nullable ResourceLocation pipeOverlay, + @Nullable ResourceLocation emissiveOverlay) { + internal.colorOverlayTieredHullModel(overlay, pipeOverlay, emissiveOverlay); + return this; + } + + public MultiblockMachineBuilderWrapper workableTieredHullModel(ResourceLocation workableModel) { + internal.workableTieredHullModel(workableModel); + return this; + } + + public MultiblockMachineBuilderWrapper simpleGeneratorModel(ResourceLocation workableModel) { + internal.simpleGeneratorModel(workableModel); + return this; + } + + public MultiblockMachineBuilderWrapper workableCasingModel(ResourceLocation baseCasing, + ResourceLocation overlayModel) { + internal.workableCasingModel(baseCasing, overlayModel); + return this; + } + + public MultiblockMachineBuilderWrapper sidedOverlayCasingModel(ResourceLocation baseCasing, + ResourceLocation workableModel) { + internal.sidedOverlayCasingModel(baseCasing, workableModel); + return this; + } + + public MultiblockMachineBuilderWrapper sidedWorkableCasingModel(ResourceLocation baseCasing, + ResourceLocation workableModel) { + internal.sidedWorkableCasingModel(baseCasing, workableModel); + return this; + } + + public MultiblockMachineBuilderWrapper overlaySteamHullModel(ResourceLocation overlayModel) { + internal.overlaySteamHullModel(overlayModel); + return this; + } + + public MultiblockMachineBuilderWrapper colorOverlaySteamHullModel(ResourceLocation overlay, + @Nullable ResourceLocation pipeOverlay, + @Nullable ResourceLocation emissiveOverlay) { + internal.colorOverlaySteamHullModel(overlay, pipeOverlay, emissiveOverlay); + return this; + } + + public MultiblockMachineBuilderWrapper colorOverlaySteamHullModel(ResourceLocation overlay) { + internal.colorOverlaySteamHullModel(overlay); + return this; + } + + public MultiblockMachineBuilderWrapper workableSteamHullModel(boolean isHighPressure, + ResourceLocation workableModel) { + internal.workableSteamHullModel(isHighPressure, workableModel); + return this; + } + + public MultiblockMachineBuilderWrapper tooltipBuilder(@Nullable BiConsumer> tooltipBuilder) { + internal.tooltipBuilder(tooltipBuilder); + return this; + } + + public MultiblockMachineBuilderWrapper appearance(@Nullable Supplier state) { + internal.appearance(state); + return this; + } + + public MultiblockMachineBuilderWrapper appearanceBlock(Supplier block) { + internal.appearanceBlock(block); + return this; + } + + public MultiblockMachineBuilderWrapper langValue(@Nullable String langValue) { + internal.langValue(langValue); + return this; + } + + public MultiblockMachineBuilderWrapper tooltips(Component... components) { + internal.tooltips(components); + return this; + } + + public MultiblockMachineBuilderWrapper conditionalTooltip(Component component, Supplier condition) { + internal.conditionalTooltip(component, condition.get()); + return this; + } + + public MultiblockMachineBuilderWrapper conditionalTooltip(Component component, boolean condition) { + internal.conditionalTooltip(component, condition); + return this; + } + + public MultiblockMachineBuilderWrapper abilities(PartAbility... abilities) { + internal.abilities(abilities); + return this; + } + + public MultiblockMachineBuilderWrapper paintingColor(int paintingColor) { + internal.paintingColor(paintingColor); + return this; + } + + public MultiblockMachineBuilderWrapper recipeModifier(RecipeModifier recipeModifier) { + internal.recipeModifier(recipeModifier); + return this; + } + + public MultiblockMachineBuilderWrapper recipeModifier(RecipeModifier recipeModifier, + boolean alwaysTryModifyRecipe) { + internal.recipeModifier(recipeModifier, alwaysTryModifyRecipe); + return this; + } + + public MultiblockMachineBuilderWrapper recipeModifiers(RecipeModifier... recipeModifiers) { + internal.recipeModifiers(recipeModifiers); + return this; + } + + public MultiblockMachineBuilderWrapper recipeModifiers(boolean alwaysTryModifyRecipe, + RecipeModifier... recipeModifiers) { + internal.recipeModifiers(alwaysTryModifyRecipe, recipeModifiers); + return this; + } + + public MultiblockMachineBuilderWrapper noRecipeModifier() { + internal.noRecipeModifier(); + return this; + } + + public MultiblockMachineBuilderWrapper alwaysTryModifyRecipe(boolean alwaysTryModifyRecipe) { + internal.alwaysTryModifyRecipe(alwaysTryModifyRecipe); + return this; + } + + public MultiblockMachineBuilderWrapper beforeWorking(BiPredicate beforeWorking) { + internal.beforeWorking(beforeWorking); + return this; + } + + public MultiblockMachineBuilderWrapper onWorking(Predicate onWorking) { + internal.onWorking(onWorking); + return this; + } + + public MultiblockMachineBuilderWrapper onWaiting(Consumer onWaiting) { + internal.onWaiting(onWaiting); + return this; + } + + public MultiblockMachineBuilderWrapper afterWorking(Consumer afterWorking) { + internal.afterWorking(afterWorking); + return this; + } + + public MultiblockMachineBuilderWrapper regressWhenWaiting(boolean regressWhenWaiting) { + internal.regressWhenWaiting(regressWhenWaiting); + return this; + } + + public MultiblockMachineBuilderWrapper onBlockEntityRegister(NonNullConsumer> onBlockEntityRegister) { + internal.onBlockEntityRegister(onBlockEntityRegister); + return this; + } + + public MultiblockMachineBuilderWrapper allowExtendedFacing(boolean allowExtendedFacing) { + internal.allowExtendedFacing(allowExtendedFacing); + return this; + } + + @Override + public void generateMachineModels() { + generateMachineModel(internal, object); + } + + @Override + public void generateAssetJsons(AssetJsonGenerator generator) { + final ResourceLocation id = this.id; + generator.itemModel(id, gen -> gen.parent(id.withPrefix("block/machine/").toString())); + } + + @Override + public void generateLang(LangEventJS lang) { + if (object != null) { + lang.add(id.getNamespace(), object.getDescriptionId(), object.getLangValue()); + } + } + + public MultiblockMachineDefinition createObject() { + return internal.register(); + } + + public static MultiblockMachineBuilderWrapper createKJSMulti(ResourceLocation id) { + var baseBuilder = new MultiblockMachineBuilder<>(GTRegistrate.createIgnoringListenerErrors(id.getNamespace()), + id.getPath(), + MetaMachineBlock::new, + MetaMachineItem::new, + WorkableElectricMultiblockMachine::new); + return new MultiblockMachineBuilderWrapper(id, baseBuilder); + } + + public static MultiblockMachineBuilderWrapper createKJSMulti(ResourceLocation id, + KJSTieredMachineBuilder.CreationFunction machine) { + var baseBuilder = new MultiblockMachineBuilder<>(GTRegistrate.createIgnoringListenerErrors(id.getNamespace()), + id.getPath(), + MetaMachineBlock::new, + MetaMachineItem::new, + machine::create); + return new MultiblockMachineBuilderWrapper(id, baseBuilder); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/ElementBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/ElementBuilder.java similarity index 64% rename from src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/ElementBuilder.java rename to src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/ElementBuilder.java index 2debfbccc21..de06400066b 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/ElementBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/ElementBuilder.java @@ -1,12 +1,13 @@ -package com.gregtechceu.gtceu.integration.kjs.builders; +package com.gregtechceu.gtceu.integration.kjs.builders.material; import com.gregtechceu.gtceu.api.data.chemical.Element; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; -import com.gregtechceu.gtceu.common.data.GTElements; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import lombok.Setter; import lombok.experimental.Accessors; @@ -34,8 +35,12 @@ public ElementBuilder(ResourceLocation id) { } @Override - public Element register() { - return value = GTElements.createAndRegister(id, protons, neutrons, halfLifeSeconds, decayTo, name, symbol, - isIsotope); + public RegistryInfo getRegistryType() { + return GTRegistryInfo.ELEMENT; + } + + @Override + public Element createObject() { + return new Element(protons, neutrons, halfLifeSeconds, decayTo, name, symbol, isIsotope); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/MaterialBuilderWrapper.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/MaterialBuilderWrapper.java new file mode 100644 index 00000000000..8c88b73bd23 --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/MaterialBuilderWrapper.java @@ -0,0 +1,670 @@ +package com.gregtechceu.gtceu.integration.kjs.builders.material; + +import com.gregtechceu.gtceu.api.data.chemical.Element; +import com.gregtechceu.gtceu.api.data.chemical.material.Material; +import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlag; +import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet; +import com.gregtechceu.gtceu.api.data.chemical.material.properties.BlastProperty; +import com.gregtechceu.gtceu.api.data.chemical.material.properties.HazardProperty; +import com.gregtechceu.gtceu.api.data.chemical.material.properties.ToolProperty; +import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition; +import com.gregtechceu.gtceu.api.data.tag.TagPrefix; +import com.gregtechceu.gtceu.api.fluids.FluidBuilder; +import com.gregtechceu.gtceu.api.fluids.FluidState; +import com.gregtechceu.gtceu.api.fluids.store.FluidStorageKey; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; +import com.gregtechceu.gtceu.integration.kjs.helpers.IGTDummyBuilder; +import com.gregtechceu.gtceu.integration.kjs.helpers.MaterialStackWrapper; + +import net.minecraft.resources.ResourceLocation; + +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; +import dev.latvian.mods.kubejs.typings.Info; +import dev.latvian.mods.kubejs.typings.Param; + +import java.util.Collection; +import java.util.function.UnaryOperator; + +public class MaterialBuilderWrapper extends BuilderBase implements IGTDummyBuilder { + + private final Material.Builder internal; + + public MaterialBuilderWrapper(ResourceLocation id) { + super(id); + this.internal = new Material.Builder(null, id); + } + + @Override + public RegistryInfo getRegistryType() { + return GTRegistryInfo.MATERIAL; + } + + /* + * Material Types + */ + + @Info(""" + Add a `FluidProperty` to this Material. + Will be created as a `FluidStorageKeys#LIQUID`, without a Fluid Block. + """) + public MaterialBuilderWrapper fluid() { + internal.fluid(); + return this; + } + + @Info(""" + Add a `FluidProperty` to this Material. + Will be created with the specified state a with standard `FluidBuilder` defaults. + + Can be called multiple times to add multiple fluids. + """) + public MaterialBuilderWrapper fluid(FluidStorageKey key, FluidState state) { + internal.fluid(key, state); + return this; + } + + @Info(""" + Add a `FluidProperty` to this Material. + + Can be called multiple times to add multiple fluids. + """) + public MaterialBuilderWrapper fluid(FluidStorageKey key, FluidBuilder builder) { + internal.fluid(key, builder); + return this; + } + + @Info(""" + Add a liquid for this material. + + @see #fluid(FluidStorageKey, FluidState) + """) + public MaterialBuilderWrapper liquid() { + internal.liquid(); + return this; + } + + @Info(""" + Add a liquid for this material. + + @see #fluid(FluidStorageKey, FluidState) + """) + public MaterialBuilderWrapper liquid(FluidBuilder builder) { + internal.liquid(builder); + return this; + } + + public MaterialBuilderWrapper liquid(int temp) { + internal.liquid(temp); + return this; + } + + @Info(""" + Add a plasma for this material. + + @see #fluid(FluidStorageKey, FluidState) + """) + public MaterialBuilderWrapper plasma() { + internal.plasma(); + return this; + } + + @Info(""" + Add a plasma for this material. + + @see #fluid(FluidStorageKey, FluidState) + """) + public MaterialBuilderWrapper plasma(FluidBuilder builder) { + internal.plasma(builder); + return this; + } + + public MaterialBuilderWrapper plasma(int temp) { + internal.plasma(temp); + return this; + } + + @Info(""" + Add a gas for this material. + + @see #fluid(FluidStorageKey, FluidState) + """) + public MaterialBuilderWrapper gas() { + internal.gas(); + return this; + } + + @Info(""" + Add a gas for this material. + + @see #fluid(FluidStorageKey, FluidState) + """) + public MaterialBuilderWrapper gas(FluidBuilder builder) { + internal.gas(builder); + return this; + } + + public MaterialBuilderWrapper gas(int temp) { + internal.gas(temp); + return this; + } + + @Info(""" + Add a `DustProperty` to this Material. + Will be created with a Harvest Level of 2 and no Burn Time (Furnace Fuel). + """) + public MaterialBuilderWrapper dust() { + internal.dust(); + return this; + } + + @Info(value = """ + Add a `DustProperty` to this Material. + Will be created with no Burn Time (Furnace Fuel). + """, + params = { + @Param(name = "harvestLevel", + value = """ + The Harvest Level of this block for Mining. + If this Material also has a `ToolProperty`, this value will + also be used to determine the tool's Mining level. + If this Material already had a Harvest Level defined, it will be overridden. + """) + }) + public MaterialBuilderWrapper dust(int harvestLevel) { + internal.dust(harvestLevel); + return this; + } + + @Info(value = """ + Add a `DustProperty` to this Material. + """, + params = { + @Param(name = "harvestLevel", + value = """ + The Harvest Level of this block for Mining. + If this Material also has a `ToolProperty`, this value will + also be used to determine the tool's Mining level. + If this Material already had a Harvest Level defined, it will be overridden. + """), + @Param(name = "burnTime", + value = """ + The Burn Time (in ticks) of this Material as a Furnace Fuel. + If this Material already had a Burn Time defined, it will be overridden. + """) + }) + public MaterialBuilderWrapper dust(int harvestLevel, int burnTime) { + internal.dust(harvestLevel, burnTime); + return this; + } + + @Info(""" + Add a `WoodProperty` to this Material. + Useful for marking a Material as Wood for various additional behaviors. + Will be created with a Harvest Level of 0, and a Burn Time of 300 (Furnace Fuel). + """) + public MaterialBuilderWrapper wood() { + internal.wood(); + return this; + } + + @Info(value = """ + Add a `WoodProperty` to this Material. + Useful for marking a Material as Wood for various additional behaviors. + Will be created with a Burn Time of 300 (Furnace Fuel). + """, + params = { + @Param(name = "harvestLevel", + value = """ + The Harvest Level of this block for Mining. + If this Material also has a `ToolProperty`, this value will + also be used to determine the tool's Mining level. + If this Material already had a Harvest Level defined, it will be overridden. + """) + }) + public MaterialBuilderWrapper wood(int harvestLevel) { + internal.wood(harvestLevel); + return this; + } + + @Info(value = """ + Add a `WoodProperty` to this Material. + Useful for marking a Material as Wood for various additional behaviors. + """, + params = { + @Param(name = "harvestLevel", + value = """ + The Harvest Level of this block for Mining. + If this Material also has a `ToolProperty`, this value will + also be used to determine the tool's Mining level. + If this Material already had a Harvest Level defined, it will be overridden. + """), + @Param(name = "burnTime", + value = """ + The Burn Time (in ticks) of this Material as a Furnace Fuel. + If this Material already had a Burn Time defined, it will be overridden. + """) + }) + public MaterialBuilderWrapper wood(int harvestLevel, int burnTime) { + internal.wood(harvestLevel, burnTime); + return this; + } + + @Info(""" + Add an `IngotProperty` to this Material. + Will be created with a Harvest Level of 2 and no Burn Time (Furnace Fuel). + Will automatically add a `DustProperty` to this Material if it does not already have one. + """) + public MaterialBuilderWrapper ingot() { + internal.ingot(); + return this; + } + + @Info(value = """ + Add an `IngotProperty` to this Material. + Will be created with no Burn Time (Furnace Fuel). + Will automatically add a `DustProperty` to this Material if it does not already have one. + """, + params = { + @Param(name = "harvestLevel", + value = """ + The Harvest Level of this block for Mining. + If this Material also has a `ToolProperty`, this value will + also be used to determine the tool's Mining level. + If this Material already had a Harvest Level defined, it will be overridden. + """) + }) + public MaterialBuilderWrapper ingot(int harvestLevel) { + internal.ingot(harvestLevel); + return this; + } + + @Info(value = """ + Add an `IngotProperty` to this Material. + Will automatically add a `DustProperty` to this Material if it does not already have one. + """, + params = { + @Param(name = "harvestLevel", + value = """ + The Harvest Level of this block for Mining. + If this Material also has a `ToolProperty`, this value will + also be used to determine the tool's Mining level. + If this Material already had a Harvest Level defined, it will be overridden. + """), + @Param(name = "burnTime", + value = """ + The Burn Time (in ticks) of this Material as a Furnace Fuel. + If this Material already had a Burn Time defined, it will be overridden. + """) + }) + public MaterialBuilderWrapper ingot(int harvestLevel, int burnTime) { + internal.ingot(harvestLevel, burnTime); + return this; + } + + @Info(""" + Add a `GemProperty` to this Material. + Will be created with a Harvest Level of 2 and no Burn Time (Furnace Fuel). + Will automatically add a `DustProperty` to this Material if it does not already have one. + """) + public MaterialBuilderWrapper gem() { + internal.gem(); + return this; + } + + @Info(value = """ + Add a `GemProperty` to this Material. + Will be created with no Burn Time (Furnace Fuel). + Will automatically add a `DustProperty` to this Material if it does not already have one. + """, + params = { + @Param(name = "harvestLevel", + value = """ + The Harvest Level of this block for Mining. + If this Material also has a `ToolProperty`, this value will + also be used to determine the tool's Mining level. + If this Material already had a Harvest Level defined, it will be overridden. + """) + }) + public MaterialBuilderWrapper gem(int harvestLevel) { + internal.gem(harvestLevel); + return this; + } + + @Info(value = """ + Add a `GemProperty` to this Material. + Will automatically add a `DustProperty` to this Material if it does not already have one. + """, + params = { + @Param(name = "harvestLevel", + value = """ + The Harvest Level of this block for Mining. + If this Material also has a `ToolProperty`, this value will + also be used to determine the tool's Mining level. + If this Material already had a Harvest Level defined, it will be overridden. + """), + @Param(name = "burnTime", + value = """ + The Burn Time (in ticks) of this Material as a Furnace Fuel. + If this Material already had a Burn Time defined, it will be overridden. + """) + }) + public MaterialBuilderWrapper gem(int harvestLevel, int burnTime) { + internal.gem(harvestLevel, burnTime); + return this; + } + + @Info(""" + Add a `PolymerProperty` to this Material. + Will be created with a Harvest Level of 2 and no Burn Time (Furnace Fuel). + Will automatically add a `DustProperty` to this Material if it does not already have one. + """) + public MaterialBuilderWrapper polymer() { + internal.polymer(); + return this; + } + + @Info(value = """ + Add a `PolymerProperty` to this Material. + Will automatically add a `DustProperty` to this Material if it does not already have one. + Will have a burn time of 0 + """, + params = { + @Param(name = "harvestLevel", + value = """ + The Harvest Level of this block for Mining. + If this Material also has a `ToolProperty`, this value will + also be used to determine the tool's Mining level. + If this Material already had a Harvest Level defined, it will be overridden. + """) + }) + public MaterialBuilderWrapper polymer(int harvestLevel) { + internal.polymer(harvestLevel); + return this; + } + + public MaterialBuilderWrapper burnTime(int burnTime) { + internal.burnTime(burnTime); + return this; + } + + @Info(""" + Set the Color of this Material. + Defaults to 0xFFFFFF unless `MaterialBuilderWrapper#colorAverage()` was called, where + it will be a weighted average of the components of the Material. + + @param color The RGB-formatted Color. + """) + public MaterialBuilderWrapper color(int color) { + internal.color(color); + return this; + } + + @Info(""" + Set the Color of this Material. + Defaults to 0xFFFFFF unless `MaterialBuilderWrapper#colorAverage()` was called, where + it will be a weighted average of the components of the Material. + + @param color The RGB-formatted Color. + @param hasFluidColor Whether the fluid should be colored or not. + """) + public MaterialBuilderWrapper color(int color, boolean hasFluidColor) { + internal.color(color, hasFluidColor); + return this; + } + + @Info(""" + Set the secondary color of this Material. + Defaults to 0xFFFFFF unless `MaterialBuilderWrapper#colorAverage()` was called, where + it will be a weighted average of the components of the Material. + + @param color The RGB-formatted Color. + """) + public MaterialBuilderWrapper secondaryColor(int color) { + internal.secondaryColor(color); + return this; + } + + public MaterialBuilderWrapper colorAverage() { + internal.colorAverage(); + return this; + } + + @Info(value = """ + Set the `MaterialIconSet` of this Material. + Defaults vary depending on if the Material has a: + `GemProperty`, it will default to `MaterialIconSet#GEM_VERTICAL` + `IngotProperty` or `@link DustProperty`, it will default to `MaterialIconSet#DULL` + `FluidProperty`, it will default to `MaterialIconSet#FLUID` + + Default will be determined by first-found Property in this order, unless specified. + """, + params = { + @Param(name = "iconSet", value = "The `MaterialIconSet` of this Material.") + }) + public MaterialBuilderWrapper iconSet(MaterialIconSet iconSet) { + internal.iconSet(iconSet); + return this; + } + + public MaterialBuilderWrapper components(MaterialStackWrapper... components) { + internal.kjs$components(components); + return this; + } + + @Info(""" + Add `MaterialFlags` to this Material. + Dependent Flags (for example, `MaterialFlags#GENERATE_LONG_ROD` requiring + `MaterialFlags#GENERATE_ROD`) will be automatically applied. + """) + public MaterialBuilderWrapper flags(MaterialFlag... flags) { + internal.flags(flags); + return this; + } + + @Info(value = """ + Add `MaterialFlags` to this Material. + Dependent Flags (for example, `MaterialFlags#GENERATE_LONG_ROD` requiring + `MaterialFlags#GENERATE_ROD`) will be automatically applied. + """, + params = { + @Param(name = "f1", + value = "A `Collection` of `MaterialFlag`. Provided this way for easy Flag presets to be applied."), + @Param(name = "f2", + value = "An Array of `MaterialFlag`. If no `Collection` is required, use `MaterialBuilderWrapper#flags(MaterialFlag...)`.") + }) + // rename for kjs conflicts + public MaterialBuilderWrapper appendFlags(Collection f1, MaterialFlag... f2) { + internal.appendFlags(f1, f2); + return this; + } + + @Info(""" + Added `TagPrefix` to be ignored by this Material. + """) + public MaterialBuilderWrapper ignoredTagPrefixes(TagPrefix... prefixes) { + internal.ignoredTagPrefixes(prefixes); + return this; + } + + public MaterialBuilderWrapper element(Element element) { + internal.element(element); + return this; + } + + public MaterialBuilderWrapper formula(String formula) { + internal.formula(formula); + return this; + } + + @Info(""" + Replaced the old toolStats methods which took many parameters. + Use `ToolProperty.Builder` instead to create a Tool Property. + """) + public MaterialBuilderWrapper toolStats(ToolProperty toolProperty) { + internal.toolStats(toolProperty); + return this; + } + + public MaterialBuilderWrapper rotorStats(int power, int efficiency, float damage, int durability) { + internal.rotorStats(power, efficiency, damage, durability); + return this; + } + + public MaterialBuilderWrapper blastTemp(int temp) { + internal.blast(temp); + return this; + } + + public MaterialBuilderWrapper blast(int temp) { + internal.blast(temp); + return this; + } + + public MaterialBuilderWrapper blast(int temp, BlastProperty.GasTier gasTier) { + internal.blast(temp, gasTier); + return this; + } + + public MaterialBuilderWrapper blast(UnaryOperator b) { + internal.blast(b); + return this; + } + + // Tons of shortcut functions for adding various hazard effects. + + public MaterialBuilderWrapper removeHazard() { + internal.removeHazard(); + return this; + } + + public MaterialBuilderWrapper radioactiveHazard(float multiplier) { + internal.radioactiveHazard(multiplier); + return this; + } + + public MaterialBuilderWrapper hazard(HazardProperty.HazardTrigger trigger, MedicalCondition condition) { + internal.hazard(trigger, condition); + return this; + } + + public MaterialBuilderWrapper hazard(HazardProperty.HazardTrigger trigger, MedicalCondition condition, + float progressionMultiplier) { + internal.hazard(trigger, condition, progressionMultiplier); + return this; + } + + public MaterialBuilderWrapper hazard(HazardProperty.HazardTrigger trigger, MedicalCondition condition, + float progressionMultiplier, boolean applyToDerivatives) { + internal.hazard(trigger, condition, progressionMultiplier, applyToDerivatives); + return this; + } + + public MaterialBuilderWrapper hazard(HazardProperty.HazardTrigger trigger, MedicalCondition condition, + boolean applyToDerivatives) { + internal.hazard(trigger, condition, applyToDerivatives); + return this; + } + + public MaterialBuilderWrapper ore() { + internal.ore(); + return this; + } + + public MaterialBuilderWrapper ore(boolean emissive) { + internal.ore(emissive); + return this; + } + + public MaterialBuilderWrapper ore(int oreMultiplier, int byproductMultiplier) { + internal.ore(oreMultiplier, byproductMultiplier); + return this; + } + + public MaterialBuilderWrapper ore(int oreMultiplier, int byproductMultiplier, boolean emissive) { + internal.ore(oreMultiplier, byproductMultiplier, emissive); + return this; + } + + public MaterialBuilderWrapper washedIn(Material m) { + internal.washedIn(m); + return this; + } + + public MaterialBuilderWrapper washedIn(Material m, int washedAmount) { + internal.washedIn(m, washedAmount); + return this; + } + + public MaterialBuilderWrapper separatedInto(Material... m) { + internal.separatedInto(m); + return this; + } + + public MaterialBuilderWrapper oreSmeltInto(Material m) { + internal.oreSmeltInto(m); + return this; + } + + public MaterialBuilderWrapper polarizesInto(Material m) { + internal.polarizesInto(m); + return this; + } + + public MaterialBuilderWrapper arcSmeltInto(Material m) { + internal.arcSmeltInto(m); + return this; + } + + public MaterialBuilderWrapper macerateInto(Material m) { + internal.macerateInto(m); + return this; + } + + public MaterialBuilderWrapper ingotSmeltInto(Material m) { + internal.ingotSmeltInto(m); + return this; + } + + public MaterialBuilderWrapper addOreByproducts(Material... byproducts) { + internal.addOreByproducts(byproducts); + return this; + } + + public MaterialBuilderWrapper cableProperties(long voltage, int amperage, int loss) { + internal.cableProperties(voltage, amperage, loss); + return this; + } + + public MaterialBuilderWrapper cableProperties(long voltage, int amperage, int loss, boolean isSuperCon) { + internal.cableProperties(voltage, amperage, loss, isSuperCon); + return this; + } + + public MaterialBuilderWrapper cableProperties(long voltage, int amperage, int loss, boolean isSuperCon, + int criticalTemperature) { + internal.cableProperties(voltage, amperage, loss, isSuperCon, criticalTemperature); + return this; + } + + public MaterialBuilderWrapper fluidPipeProperties(int maxTemp, int throughput, boolean gasProof) { + internal.fluidPipeProperties(maxTemp, throughput, gasProof); + return this; + } + + public MaterialBuilderWrapper fluidPipeProperties(int maxTemp, int throughput, boolean gasProof, boolean acidProof, + boolean cryoProof, boolean plasmaProof) { + internal.fluidPipeProperties(maxTemp, throughput, gasProof, acidProof, cryoProof, plasmaProof); + return this; + } + + public MaterialBuilderWrapper itemPipeProperties(int priority, float stacksPerSec) { + internal.itemPipeProperties(priority, stacksPerSec); + return this; + } + + @Override + public Material createObject() { + return internal.buildAndRegister(); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/MaterialIconSetBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/MaterialIconSetBuilder.java similarity index 53% rename from src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/MaterialIconSetBuilder.java rename to src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/MaterialIconSetBuilder.java index b52c204ca78..c07689b7d3a 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/MaterialIconSetBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/MaterialIconSetBuilder.java @@ -1,10 +1,13 @@ -package com.gregtechceu.gtceu.integration.kjs.builders; +package com.gregtechceu.gtceu.integration.kjs.builders.material; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import net.minecraft.resources.ResourceLocation; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; + public class MaterialIconSetBuilder extends BuilderBase { private transient MaterialIconSet parent; @@ -20,7 +23,12 @@ public MaterialIconSetBuilder parent(MaterialIconSet parent) { } @Override - public MaterialIconSet register() { - return value = new MaterialIconSet(this.id.getPath(), parent); + public RegistryInfo getRegistryType() { + return GTRegistryInfo.MATERIAL_ICON_SET; + } + + @Override + public MaterialIconSet createObject() { + return new MaterialIconSet(this.id, parent); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/prefix/OreTagPrefixBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/OreTagPrefixBuilder.java similarity index 53% rename from src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/prefix/OreTagPrefixBuilder.java rename to src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/OreTagPrefixBuilder.java index b5eb1d23ce8..299851f20e1 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/prefix/OreTagPrefixBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/OreTagPrefixBuilder.java @@ -1,10 +1,9 @@ -package com.gregtechceu.gtceu.integration.kjs.builders.prefix; +package com.gregtechceu.gtceu.integration.kjs.builders.material; +import com.gregtechceu.gtceu.api.block.OreBlock; import com.gregtechceu.gtceu.api.data.chemical.material.Material; +import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; -import com.gregtechceu.gtceu.common.data.GTBlocks; -import com.gregtechceu.gtceu.core.mixins.BlockBehaviourAccessor; -import com.gregtechceu.gtceu.integration.kjs.built.KJSTagPrefix; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.state.BlockBehaviour; @@ -15,7 +14,7 @@ import java.util.function.Supplier; -import static com.gregtechceu.gtceu.integration.kjs.Validator.*; +import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.Conditions.hasOreProperty; @Accessors(fluent = true, chain = true) public class OreTagPrefixBuilder extends TagPrefixBuilder { @@ -40,22 +39,20 @@ public OreTagPrefixBuilder(ResourceLocation id) { } @Override - public KJSTagPrefix create(String id) { - return KJSTagPrefix.oreTagPrefix(id); + public TagPrefix create(ResourceLocation id) { + return new TagPrefix(id) + .defaultTagPath("ores/%s") + .prefixOnlyTagPath("ores_in_ground/%s") + .unformattedTagPath("ores") + .materialIconType(MaterialIconType.ore) + .unificationEnabled(true) + .blockConstructor(OreBlock::new) + .generationCondition(hasOreProperty); } @Override - public TagPrefix register() { - validate(this.id, - errorIfNull(stateSupplier, "stateSupplier"), - onlySetDefault(templateProperties, () -> { - templateProperties = () -> GTBlocks.copy( - ((BlockBehaviourAccessor) stateSupplier.get().getBlock()).getBlockProperties(), - BlockBehaviour.Properties.of()); - }), - errorIfNull(baseModelLocation, "baseModelLocation")); - - return value = base.registerOre(stateSupplier, materialSupplier, templateProperties, baseModelLocation, + public TagPrefix createObject() { + return base.registerOre(stateSupplier, materialSupplier, templateProperties, baseModelLocation, doubleDrops, isSand, shouldDropAsItem); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/prefix/TagPrefixBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/TagPrefixBuilder.java similarity index 63% rename from src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/prefix/TagPrefixBuilder.java rename to src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/TagPrefixBuilder.java index 366cb107eee..9faf9687cfa 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/prefix/TagPrefixBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/material/TagPrefixBuilder.java @@ -1,44 +1,48 @@ -package com.gregtechceu.gtceu.integration.kjs.builders.prefix; +package com.gregtechceu.gtceu.integration.kjs.builders.material; import com.gregtechceu.gtceu.api.data.chemical.material.Material; import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; import com.gregtechceu.gtceu.api.data.chemical.material.stack.MaterialStack; import com.gregtechceu.gtceu.api.data.tag.TagPrefix; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; -import com.gregtechceu.gtceu.integration.kjs.built.KJSTagPrefix; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; -import net.minecraft.core.registries.Registries; +import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.Item; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockBehaviour; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import lombok.Getter; -import lombok.experimental.Accessors; import java.util.ArrayList; import java.util.List; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Predicate; +import java.util.function.*; -@SuppressWarnings("unused") -@Accessors(chain = true) -public abstract class TagPrefixBuilder extends BuilderBase { +public class TagPrefixBuilder extends BuilderBase { - public final KJSTagPrefix base; + public final TagPrefix base; @Getter private final List secondaryMaterials = new ArrayList<>(); public TagPrefixBuilder(ResourceLocation id) { super(id); - this.base = create(id.getPath()); + this.base = create(id); } - public abstract KJSTagPrefix create(String id); + public TagPrefix create(ResourceLocation id) { + return new TagPrefix(id); + } + + @Override + public RegistryInfo getRegistryType() { + return GTRegistryInfo.TAG_PREFIX; + } public TagPrefixBuilder idPattern(String idPattern) { base.idPattern(idPattern); @@ -60,11 +64,27 @@ public TagPrefixBuilder unificationEnabled(boolean unificationEnabled) { return this; } + public TagPrefixBuilder generateRecycling(boolean generateRecycling) { + base.generateRecycling(generateRecycling); + return this; + } + public TagPrefixBuilder generateItem(boolean generateItem) { base.generateItem(generateItem); return this; } + public TagPrefixBuilder generateBlock(boolean generateBlock) { + base.generateBlock(generateBlock); + return this; + } + + public TagPrefixBuilder blockProperties(Supplier> renderType, + UnaryOperator properties) { + base.blockProperties(new TagPrefix.BlockProperties(renderType, properties)); + return this; + } + public TagPrefixBuilder generationCondition(Predicate generationCondition) { base.generationCondition(generationCondition); return this; @@ -100,6 +120,11 @@ public TagPrefixBuilder defaultTagPath(String path) { return this; } + public TagPrefixBuilder defaultTagPath(String path, boolean isVanilla) { + base.defaultTagPath(path, isVanilla); + return this; + } + public TagPrefixBuilder prefixTagPath(String path) { base.prefixTagPath(path); return this; @@ -115,13 +140,18 @@ public TagPrefixBuilder unformattedTagPath(String path) { return this; } + public TagPrefixBuilder unformattedTagPath(String path, boolean isVanilla) { + base.unformattedTagPath(path, isVanilla); + return this; + } + public TagPrefixBuilder customTagPath(String path, BiFunction> formatter) { base.customTagPath(path, formatter); return this; } - public TagPrefixBuilder miningToolTag(String path) { - this.miningToolTag(TagKey.create(Registries.BLOCK, ResourceLocation.tryParse(path))); + public TagPrefixBuilder customTagPredicate(String path, boolean isVanilla, Predicate materialPredicate) { + base.customTagPredicate(path, isVanilla, materialPredicate); return this; } @@ -131,7 +161,7 @@ public TagPrefixBuilder miningToolTag(TagKey tag) { } @Override - public TagPrefix register() { - return value = base; + public TagPrefix createObject() { + return base; } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/prefix/BasicTagPrefixBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/prefix/BasicTagPrefixBuilder.java deleted file mode 100644 index 6243f4a4f3e..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/prefix/BasicTagPrefixBuilder.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.gregtechceu.gtceu.integration.kjs.builders.prefix; - -import com.gregtechceu.gtceu.integration.kjs.built.KJSTagPrefix; - -import net.minecraft.resources.ResourceLocation; - -public class BasicTagPrefixBuilder extends TagPrefixBuilder { - - public BasicTagPrefixBuilder(ResourceLocation id) { - super(id); - } - - @Override - public KJSTagPrefix create(String id) { - return new KJSTagPrefix(id); - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/GTRecipeCategoryBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/recipe/GTRecipeCategoryBuilder.java similarity index 67% rename from src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/GTRecipeCategoryBuilder.java rename to src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/recipe/GTRecipeCategoryBuilder.java index db48ef89f6c..1ebd37e6e03 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/GTRecipeCategoryBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/recipe/GTRecipeCategoryBuilder.java @@ -1,10 +1,9 @@ -package com.gregtechceu.gtceu.integration.kjs.builders; +package com.gregtechceu.gtceu.integration.kjs.builders.recipe; import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; -import com.gregtechceu.gtceu.common.data.GTRecipeCategories; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import com.gregtechceu.gtceu.integration.recipeviewer.CategoryIcon; import com.gregtechceu.gtceu.utils.FormattingUtil; @@ -12,6 +11,8 @@ import net.minecraft.world.item.ItemStack; import dev.latvian.mods.kubejs.client.LangEventJS; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import lombok.Setter; import lombok.experimental.Accessors; @@ -37,6 +38,11 @@ public GTRecipeCategoryBuilder(ResourceLocation id) { langValue = null; } + @Override + public RegistryInfo getRegistryType() { + return GTRegistryInfo.RECIPE_CATEGORY; + } + public GTRecipeCategoryBuilder setCustomIcon(ResourceLocation location) { this.icon = new CategoryIcon(location); return this; @@ -50,15 +56,13 @@ public GTRecipeCategoryBuilder setItemIcon(ItemStack stack) { @Override public void generateLang(LangEventJS lang) { super.generateLang(lang); - if (langValue != null) lang.add(value.getLanguageKey(), langValue); - else lang.add(GTCEu.MOD_ID, value.getLanguageKey(), FormattingUtil.toEnglishName(value.name)); + if (langValue != null) lang.add(langValue, langValue); + else lang.add(GTCEu.MOD_ID, "%s.recipe.category.%s".formatted(GTCEu.MOD_ID, name), + FormattingUtil.toEnglishName(name)); } @Override - public GTRecipeCategory register() { - var category = GTRecipeCategories.register(name, recipeType) - .setIcon(icon) - .setXEIVisible(isXEIVisible); - return value = category; + public GTRecipeCategory createObject() { + return new GTRecipeCategory(name, recipeType).setIcon(icon).setXEIVisible(isXEIVisible); } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/GTRecipeTypeBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/recipe/GTRecipeTypeBuilder.java similarity index 88% rename from src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/GTRecipeTypeBuilder.java rename to src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/recipe/GTRecipeTypeBuilder.java index 26bacbe6682..6bbb1098809 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/GTRecipeTypeBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/recipe/GTRecipeTypeBuilder.java @@ -1,15 +1,17 @@ -package com.gregtechceu.gtceu.integration.kjs.builders; +package com.gregtechceu.gtceu.integration.kjs.builders.recipe; import com.gregtechceu.gtceu.api.capability.recipe.*; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.gui.GTRecipeTypeUILayout; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; +import com.gregtechceu.gtceu.api.recipe.gui.GTRecipeTypeUILayout; import com.gregtechceu.gtceu.api.sound.SoundEntry; -import com.gregtechceu.gtceu.common.data.GTRecipeTypes; +import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.jetbrains.annotations.Nullable; @@ -44,6 +46,11 @@ public GTRecipeTypeBuilder(ResourceLocation i) { this.iconSupplier = null; } + @Override + public RegistryInfo getRegistryType() { + return GTRegistryInfo.RECIPE_TYPE; + } + public GTRecipeTypeBuilder category(String category) { this.category = category; return this; @@ -107,8 +114,8 @@ public GTRecipeTypeBuilder setIconSupplier(Supplier iconSupplier) { } @Override - public GTRecipeType register() { - var type = GTRecipeTypes.register(name, category); + public GTRecipeType createObject() { + var type = new GTRecipeType(id, category); type.maxInputs.putAll(maxInputs); type.maxOutputs.putAll(maxOutputs); if (this.layout != null) { @@ -121,6 +128,6 @@ public GTRecipeType register() { type.setMaxTooltips(maxTooltips); type.setSmallRecipeMap(smallRecipeMap); type.setIconSupplier(iconSupplier); - return value = type; + return type; } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/WorldGenLayerBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/worldgen/WorldGenLayerBuilder.java similarity index 60% rename from src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/WorldGenLayerBuilder.java rename to src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/worldgen/WorldGenLayerBuilder.java index d02a38363ca..b78364b6bf0 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/WorldGenLayerBuilder.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/builders/worldgen/WorldGenLayerBuilder.java @@ -1,12 +1,16 @@ -package com.gregtechceu.gtceu.integration.kjs.builders; +package com.gregtechceu.gtceu.integration.kjs.builders.worldgen; import com.gregtechceu.gtceu.api.data.worldgen.IWorldGenLayer; import com.gregtechceu.gtceu.api.data.worldgen.SimpleWorldGenLayer; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import dev.latvian.mods.kubejs.level.gen.ruletest.AnyMatchRuleTest; +import dev.latvian.mods.kubejs.registry.BuilderBase; +import dev.latvian.mods.kubejs.registry.RegistryInfo; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import lombok.experimental.Accessors; @@ -19,19 +23,23 @@ public class WorldGenLayerBuilder extends BuilderBase { public transient List targets = new ObjectArrayList<>(); - public transient List dimensions = new ObjectArrayList<>(); + public transient List> dimensions = new ObjectArrayList<>(); public WorldGenLayerBuilder(ResourceLocation id) { super(id); } @Override - public SimpleWorldGenLayer register() { - this.value = new SimpleWorldGenLayer( + public RegistryInfo getRegistryType() { + return null; + } + + @Override + public SimpleWorldGenLayer createObject() { + return new SimpleWorldGenLayer( this.id, () -> new AnyMatchRuleTest(targets.stream().map(IWorldGenLayer.RuleTestSupplier::get).toList()), Set.copyOf(dimensions)); - return value; } public WorldGenLayerBuilder targets(IWorldGenLayer.RuleTestSupplier... targets) { @@ -39,8 +47,14 @@ public WorldGenLayerBuilder targets(IWorldGenLayer.RuleTestSupplier... targets) return this; } - public WorldGenLayerBuilder dimensions(ResourceLocation... dimension) { + @SafeVarargs + public final WorldGenLayerBuilder dimensions(ResourceKey... dimension) { this.dimensions.addAll(Arrays.asList(dimension)); return this; } + + public WorldGenLayerBuilder dimensions(ResourceLocation... dimension) { + this.dimensions.addAll(Arrays.stream(dimension).map(m -> ResourceKey.create(Registries.DIMENSION, m)).toList()); + return this; + } } diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/built/KJSTagPrefix.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/built/KJSTagPrefix.java deleted file mode 100644 index 0a58a4276c3..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/built/KJSTagPrefix.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.gregtechceu.gtceu.integration.kjs.built; - -import com.gregtechceu.gtceu.api.block.OreBlock; -import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; -import com.gregtechceu.gtceu.api.data.tag.TagPrefix; -import com.gregtechceu.gtceu.api.data.tag.TagType; - -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; - -import lombok.experimental.Accessors; - -import java.util.function.BiFunction; -import java.util.function.Predicate; - -import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.Conditions.hasOreProperty; - -@Accessors(fluent = true, chain = true) -public class KJSTagPrefix extends TagPrefix { - - public KJSTagPrefix(String name) { - super(name); - } - - public static KJSTagPrefix oreTagPrefix(String name) { - return new KJSTagPrefix(name) - .defaultTagPath("ores/%s") - .prefixOnlyTagPath("ores_in_ground/%s") - .unformattedTagPath("ores") - .materialIconType(MaterialIconType.ore) - .unificationEnabled(true) - .blockConstructor(OreBlock::new) - .generationCondition(hasOreProperty); - } - - @Override - public KJSTagPrefix blockConstructor(BlockConstructor blockConstructor) { - super.blockConstructor(blockConstructor); - return this; - } - - @Override - public KJSTagPrefix defaultTagPath(String path) { - return this.defaultTagPath(path, false); - } - - @Override - public KJSTagPrefix defaultTagPath(String path, boolean isVanilla) { - this.tags.add(TagType.withDefaultFormatter(path, isVanilla)); - return this; - } - - @Override - public KJSTagPrefix prefixTagPath(String path) { - this.tags.add(TagType.withPrefixFormatter(path)); - return this; - } - - @Override - public KJSTagPrefix prefixOnlyTagPath(String path) { - this.tags.add(TagType.withPrefixOnlyFormatter(path)); - return this; - } - - @Override - public KJSTagPrefix unformattedTagPath(String path) { - return unformattedTagPath(path, false); - } - - @Override - public KJSTagPrefix unformattedTagPath(String path, boolean isVanilla) { - this.tags.add(TagType.withNoFormatter(path, isVanilla)); - return this; - } - - @Override - public KJSTagPrefix customTagPath(String path, BiFunction> formatter) { - this.tags.add(TagType.withCustomFormatter(path, formatter)); - return this; - } - - public KJSTagPrefix materialIconType(MaterialIconType type) { - super.materialIconType(type); - return this; - } - - public KJSTagPrefix unificationEnabled(boolean unificationEnabled) { - super.unificationEnabled(unificationEnabled); - return this; - } - - public KJSTagPrefix generationCondition(Predicate condition) { - super.generationCondition(condition); - return this; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTRegistryEventJS.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTRegistryEventJS.java deleted file mode 100644 index 0cbf73bf135..00000000000 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/GTRegistryEventJS.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.gregtechceu.gtceu.integration.kjs.events; - -import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase; -import com.gregtechceu.gtceu.integration.kjs.GTRegistryInfo; - -import dev.latvian.mods.kubejs.event.StartupEventJS; -import dev.latvian.mods.kubejs.script.ScriptType; -import dev.latvian.mods.kubejs.util.UtilsJS; - -public class GTRegistryEventJS extends StartupEventJS { - - private final GTRegistryInfo registry; - - public GTRegistryEventJS(GTRegistryInfo r) { - registry = r; - } - - public BuilderBase create(String id, String type) { - var t = registry.types.get(type); - - if (t == null) { - throw new IllegalArgumentException("Unknown type '" + type + "' for object '" + id + "'!"); - } - - var b = t.factory() - .createBuilder(UtilsJS.getMCID(ScriptType.STARTUP.manager.get().context, GTCEu.id(id))); - - 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(); - - if (t == null) { - throw new IllegalArgumentException( - "Registry for type '" + registry.registryKey + "' doesn't have any builders registered!"); - } - - var b = t.factory() - .createBuilder(UtilsJS.getMCID(ScriptType.STARTUP.manager.get().context, GTCEu.id(id))); - - if (b == null) { - throw new IllegalArgumentException("Unknown type '" + t.type() + "' for object '" + id + "'!"); - } else { - registry.addBuilder(b); - } - - return b; - } -} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/MaterialIconTypeEventJS.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/MaterialIconTypeEventJS.java new file mode 100644 index 00000000000..27291dc846f --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/events/MaterialIconTypeEventJS.java @@ -0,0 +1,14 @@ +package com.gregtechceu.gtceu.integration.kjs.events; + +import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconType; +import dev.latvian.mods.kubejs.event.StartupEventJS; +import dev.latvian.mods.kubejs.typings.Info; + +@SuppressWarnings("unused") +public class MaterialIconTypeEventJS extends StartupEventJS { + + @Info("Create a new material icon type.") + public MaterialIconType create(String name) { + return new MaterialIconType(name); + } +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/helpers/IGTDummyBuilder.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/helpers/IGTDummyBuilder.java new file mode 100644 index 00000000000..30e8bc841aa --- /dev/null +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/helpers/IGTDummyBuilder.java @@ -0,0 +1,14 @@ +package com.gregtechceu.gtceu.integration.kjs.helpers; + +import com.gregtechceu.gtceu.core.mixins.kjs.RegistryInfoMixin; + +/** + * A KJS builder that wraps an object whose registry is handled by GT. + * The standard KJS dummy builder does not work for this because its registration function is never called, + * while GT still needs these builders to be registered at the correct time, but without kjs registering the object. + * This logic is handled by {@link RegistryInfoMixin} + */ +public interface IGTDummyBuilder { + + T createObject(); +} diff --git a/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java b/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java index 147c270e8dd..393a1a8ab77 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/kjs/recipe/GTRecipeSchema.java @@ -12,6 +12,7 @@ import com.gregtechceu.gtceu.api.item.component.IDataItem; import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.machine.multiblock.CleanroomType; +import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.RecipeCondition; import com.gregtechceu.gtceu.api.recipe.ResearchData; import com.gregtechceu.gtceu.api.recipe.ResearchRecipeBuilder; @@ -20,7 +21,6 @@ import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.api.recipe.ingredient.*; import com.gregtechceu.gtceu.api.recipe.ingredient.nbtpredicate.NBTPredicate; -import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.item.behavior.IntCircuitBehaviour; import com.gregtechceu.gtceu.common.recipe.condition.*; import com.gregtechceu.gtceu.config.ConfigHolder; @@ -32,6 +32,8 @@ import com.gregtechceu.gtceu.integration.kjs.recipe.components.GTRecipeComponents; import com.gregtechceu.gtceu.utils.ResearchManager; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; @@ -131,7 +133,12 @@ public GTRecipeJS input(RecipeCapability capability, Object... obj) { map = getValue(ALL_INPUTS); } if (map != null) { - var recipeType = GTRegistries.RECIPE_TYPES.get(this.type.id); + + var type = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY) + .registryOrThrow(Registries.RECIPE_TYPE).get(this.type.id); + if (!(type instanceof GTRecipeType recipeType)) throw new IllegalStateException( + "GTRecipeJS is constructing a recipe for a non-GT recipe type, this should never happen"); + if (map.get(capability) != null && map.get(capability).length + obj.length > recipeType.getMaxInputs(capability)) { ConsoleJS.SERVER.warn(String.format( @@ -156,7 +163,11 @@ public GTRecipeJS output(RecipeCapability capability, Object... obj) { map = getValue(ALL_OUTPUTS); } if (map != null) { - var recipeType = GTRegistries.RECIPE_TYPES.get(this.type.id); + var type = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY) + .registryOrThrow(Registries.RECIPE_TYPE).get(this.type.id); + if (!(type instanceof GTRecipeType recipeType)) throw new IllegalStateException( + "GTRecipeJS is constructing a recipe for a non-GT recipe type, this should never happen"); + if (map.get(capability) != null && map.get(capability).length + obj.length > recipeType.getMaxOutputs(capability)) { ConsoleJS.SERVER.warn(String.format( diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/GTOreProcessingEmiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/GTOreProcessingEmiCategory.java index afa12cdd4e2..bf6d9a2ff37 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/GTOreProcessingEmiCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/GTOreProcessingEmiCategory.java @@ -49,7 +49,6 @@ public static void registerWorkStations(EmiRegistry registry) { CHEMICAL_BATH_RECIPES, ELECTROMAGNETIC_SEPARATOR_RECIPES, SIFTER_RECIPES }; for (MachineDefinition machine : GTRegistries.MACHINES - .values() .stream() .sorted(sortDefinition) .toList()) { diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/MultiblockInfoEmiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/MultiblockInfoEmiCategory.java index f97732716cb..d46fb37a6fc 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/MultiblockInfoEmiCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/MultiblockInfoEmiCategory.java @@ -29,7 +29,7 @@ private MultiblockInfoEmiCategory() { } public static void registerDisplays(EmiRegistry registry) { - GTRegistries.MACHINES.values().stream() + GTRegistries.MACHINES.stream() .filter(MultiblockMachineDefinition.class::isInstance) .map(MultiblockMachineDefinition.class::cast) .filter(MultiblockMachineDefinition::isRenderXEIPreview) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTRecipeEMICategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTRecipeEMICategory.java index e64dc0b0de1..bc0784e17b5 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTRecipeEMICategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/emi/recipe/GTRecipeEMICategory.java @@ -75,7 +75,6 @@ public static void registerDisplays(EmiRegistry registry) { public static void registerWorkStations(EmiRegistry registry) { for (MachineDefinition machine : GTRegistries.MACHINES - .values() .stream() .sorted(sortDefinition) .toList()) { diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/MultiblockInfoJeiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/MultiblockInfoJeiCategory.java index eeb358d82c8..7425b93d73b 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/MultiblockInfoJeiCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/jei/MultiblockInfoJeiCategory.java @@ -50,7 +50,7 @@ public MultiblockInfoJeiCategory(IJeiHelpers helpers) { } public static void registerRecipes(IRecipeRegistration registry) { - registry.addRecipes(RECIPE_TYPE, GTRegistries.MACHINES.values().stream() + registry.addRecipes(RECIPE_TYPE, GTRegistries.MACHINES.stream() .filter(MultiblockMachineDefinition.class::isInstance) .map(MultiblockMachineDefinition.class::cast) .filter(MultiblockMachineDefinition::isRenderXEIPreview) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/MultiblockInfoReiCategory.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/MultiblockInfoReiCategory.java index 8fe0ba24ec8..bf593392abd 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/MultiblockInfoReiCategory.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/rei/MultiblockInfoReiCategory.java @@ -27,7 +27,7 @@ public MultiblockInfoReiCategory() { } public static void registerDisplays(DisplayRegistry registry) { - GTRegistries.MACHINES.values().stream() + GTRegistries.MACHINES.stream() .filter(MultiblockMachineDefinition.class::isInstance) .map(MultiblockMachineDefinition.class::cast) .filter(MultiblockMachineDefinition::isRenderXEIPreview) diff --git a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/OreVeinRecipeWidget.java b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/OreVeinRecipeWidget.java index 0c020fe94d6..806077ec356 100644 --- a/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/OreVeinRecipeWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/integration/recipeviewer/widgets/OreVeinRecipeWidget.java @@ -173,9 +173,11 @@ public static List getRawMaterialList(BedrockOreDefinition bedrockOre public static DimensionMarker[] getDimensionMarkers(Set> dimensionFilter) { return dimensionFilter.stream() - .map(ResourceKey::location) - .map(loc -> GTRegistries.DIMENSION_MARKERS.getOrDefault(loc, - new DimensionMarker(DimensionMarker.MAX_TIER, () -> Blocks.BARRIER, loc.toString()))) + .map(key -> GTRegistries.DIMENSION_MARKERS.stream() + .filter(marker -> marker.dimension.equals(key)) + .findFirst() + .orElseGet(() -> new DimensionMarker(Level.OVERWORLD, DimensionMarker.MAX_TIER, + () -> Blocks.BARRIER, key.location().toString()))) .sorted(Comparator.comparingInt(DimensionMarker::getTier)) .toArray(DimensionMarker[]::new); } diff --git a/src/main/java/com/gregtechceu/gtceu/utils/ResearchManager.java b/src/main/java/com/gregtechceu/gtceu/utils/ResearchManager.java index ee070529160..c7e617f43d6 100644 --- a/src/main/java/com/gregtechceu/gtceu/utils/ResearchManager.java +++ b/src/main/java/com/gregtechceu/gtceu/utils/ResearchManager.java @@ -7,9 +7,9 @@ import com.gregtechceu.gtceu.api.item.component.IDataItem; import com.gregtechceu.gtceu.api.item.component.IItemComponent; import com.gregtechceu.gtceu.api.recipe.GTRecipe; +import com.gregtechceu.gtceu.api.recipe.GTRecipeSerializer; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.recipe.ingredient.EnergyStack; -import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.data.GTItems; import com.gregtechceu.gtceu.common.data.GTRecipeTypes; import com.gregtechceu.gtceu.config.ConfigHolder; @@ -173,7 +173,7 @@ public record ResearchItem(@NotNull String researchId, @NotNull GTRecipeType rec // spotless:off public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.STRING.fieldOf("research_id").forGetter(ResearchItem::researchId), - GTRegistries.RECIPE_TYPES.codec().fieldOf("research_type").forGetter(ResearchItem::recipeType) + GTRecipeSerializer.GT_RECIPE_TYPE_CODEC.fieldOf("research_type").forGetter(ResearchItem::recipeType) ).apply(instance, ResearchItem::new)); // spotless:on } diff --git a/src/main/resources/gtceu.mixins.json b/src/main/resources/gtceu.mixins.json index 21cba8b5880..7cf56e64d6c 100644 --- a/src/main/resources/gtceu.mixins.json +++ b/src/main/resources/gtceu.mixins.json @@ -62,6 +62,8 @@ "BlockStateAccessor", "ChunkGeneratorMixin", "EntityMixin", + "BuiltInRegistriesAccessor", + "BuiltInRegistriesMixin", "GrowingPlantBlockAccessor", "IngredientAccessor", "IntegerPropertyAccessor", @@ -81,6 +83,7 @@ "ShapedRecipeAccessor", "SidedRedstoneConnectivityMixin", "SmithingTransformRecipeMixin", + "ResourceKeyArgumentAccessor", "TagLoaderMixin", "TagManagerMixin", "TagValueAccessor", @@ -93,11 +96,14 @@ "emi.FillRecipePacketMixin", "emi.FluidEmiStackMixin", "forge.ConfiguredModelBuilderAccessor", + "forge.GameDataMixin", "forge.ConfiguredModelListAccessor", "forge.IntersectionIngredientAccessor", "forge.PartialNBTIngredientAccessor", "forge.StrictNBTIngredientAccessor", "jei.FluidHelperMixin", + "kjs.RegistryEventJSMixin", + "kjs.RegistryInfoMixin", "registrate.AbstractRegistrateAccessor", "registrate.RegistrateDataProviderAccessor", "rei.InputSlotCrafterMixin", diff --git a/src/test/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializerTest.java b/src/test/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializerTest.java index 2d883d09513..fbd7415c8ea 100644 --- a/src/test/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializerTest.java +++ b/src/test/java/com/gregtechceu/gtceu/api/recipe/GTRecipeSerializerTest.java @@ -1,7 +1,6 @@ package com.gregtechceu.gtceu.api.recipe; import com.gregtechceu.gtceu.GTCEu; -import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.recipe.condition.AdjacentBlockCondition; import com.gregtechceu.gtceu.common.recipe.condition.AdjacentFluidCondition; import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder; @@ -38,7 +37,7 @@ public static void testSerializeAdjacentFluid(GameTestHelper helper) { @SuppressWarnings("deprecation") HolderSet waterSet = HolderSet.direct(Fluids.WATER.builtInRegistryHolder(), Fluids.FLOWING_WATER.builtInRegistryHolder()); - HolderSet lavaSet = GTRegistries.builtinRegistry() + HolderSet lavaSet = helper.getLevel().registryAccess() .registryOrThrow(Registries.FLUID) .getOrCreateTag(FluidTags.LAVA); List> fluidSetIn = List.of(waterSet, lavaSet); @@ -72,7 +71,7 @@ public static void testSerializeAdjacentBlock(GameTestHelper helper) { @SuppressWarnings("deprecation") HolderSet blockSet = HolderSet.direct(Blocks.DIAMOND_BLOCK.builtInRegistryHolder(), Blocks.GOLD_BLOCK.builtInRegistryHolder()); - HolderSet oreSet = GTRegistries.builtinRegistry() + HolderSet oreSet = helper.getLevel().registryAccess() .registryOrThrow(Registries.BLOCK) .getOrCreateTag(Tags.Blocks.ORES); List> blockSetIn = List.of(blockSet, oreSet); @@ -106,7 +105,7 @@ public static void testSerializingFluidCondition(GameTestHelper helper) { HolderSet waterSet = HolderSet.direct(Fluids.WATER.builtInRegistryHolder(), Fluids.FLOWING_WATER.builtInRegistryHolder()); TagKey lavaTag = FluidTags.LAVA; - HolderSet lavaSet = GTRegistries.builtinRegistry() + HolderSet lavaSet = helper.getLevel().registryAccess() .registryOrThrow(Registries.FLUID) .getOrCreateTag(FluidTags.LAVA); @@ -130,7 +129,7 @@ public static void testSerializingBlockCondition(GameTestHelper helper) { @SuppressWarnings("deprecation") HolderSet blockSet = HolderSet.direct(Blocks.DIAMOND_BLOCK.builtInRegistryHolder(), Blocks.GOLD_BLOCK.builtInRegistryHolder()); - HolderSet oreSet = GTRegistries.builtinRegistry() + HolderSet oreSet = helper.getLevel().registryAccess() .registryOrThrow(Registries.BLOCK) .getOrCreateTag(Tags.Blocks.ORES); List> blockSetIn = List.of(blockSet, oreSet); diff --git a/src/test/java/com/gregtechceu/gtceu/gametest/util/TestUtils.java b/src/test/java/com/gregtechceu/gtceu/gametest/util/TestUtils.java index 76a6fd2904f..f8dc1892d69 100644 --- a/src/test/java/com/gregtechceu/gtceu/gametest/util/TestUtils.java +++ b/src/test/java/com/gregtechceu/gtceu/gametest/util/TestUtils.java @@ -15,15 +15,21 @@ import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.placeholder.MultiLineComponent; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; +import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.common.item.behavior.CoverPlaceBehavior; import com.gregtechceu.gtceu.utils.fakeplayer.FakeServerGamePacketListenerImpl; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.MappedRegistry; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.gametest.framework.GameTestAssertPosException; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -42,6 +48,7 @@ import net.minecraftforge.fluids.FluidStack; import com.mojang.authlib.GameProfile; +import com.mojang.serialization.Lifecycle; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -215,14 +222,22 @@ public static GTRecipeType createRecipeType(String name, GTRecipeType original) */ public static GTRecipeType createRecipeType(String name, int maxInputs, int maxOutputs, int maxFluidInputs, int maxFluidOutputs) { - GTRegistries.RECIPE_TYPES.unfreeze(); - GTRegistries.RECIPE_CATEGORIES.unfreeze(); + var access = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY); + MappedRegistry> recipeTypes = (MappedRegistry>) access + .registryOrThrow(Registries.RECIPE_TYPE); + MappedRegistry categories = (MappedRegistry) access + .registryOrThrow(GTRegistries.Keys.RECIPE_CATEGORY); + + recipeTypes.unfreeze(); + categories.unfreeze(); GTRecipeType type = new GTRecipeType(GTCEu.id(name), ELECTRIC, RecipeType.SMELTING) .setEUIO(IO.IN) .setMaxIOSize(maxInputs, maxOutputs, maxFluidInputs, maxFluidOutputs); - GTRegistries.RECIPE_CATEGORIES.freeze(); - GTRegistries.RECIPE_TYPES.freeze(); + recipeTypes.register(ResourceKey.create(Registries.RECIPE_TYPE, GTCEu.id(name)), type, Lifecycle.stable()); + + recipeTypes.freeze(); + categories.freeze(); return type; } @@ -253,7 +268,7 @@ public static CoverBehavior placeCover(GameTestHelper helper, MetaMachine machin for (IItemComponent component : componentItem.getComponents()) { if (component instanceof CoverPlaceBehavior coverPlaceBehavior) { helper.assertTrue(coverDefinition == null, "stack has multiple coverPlaceBehaviours"); - coverDefinition = coverPlaceBehavior.coverDefinition(); + coverDefinition = coverPlaceBehavior.coverDefinition().get(); } } }