1.18 ayutac datagen4 (#2769)

* Added dust crafting data gen.

Generation works, but how do I get TR to recognize the existence of the new stuff?

* Added generic armor and tools to the datagen. Also resolved conflicts from the merge with recently changed datagen

* Fixed copy-paste error

by accident for second ingredient first would be taken again

* automatized tag generation

* fixed lingering bugs from previous commit

* much much more gen, for about 269 files

* wrongly deleted recipes in last commit

* Added rest of the decorative storage block variants to datagen
This commit is contained in:
Ayutac 2022-01-23 19:34:35 +01:00 committed by GitHub
parent 9f5a616b15
commit 0a5be13901
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
693 changed files with 840 additions and 7715 deletions

View file

@ -0,0 +1,42 @@
/*
* This file is part of RebornCore, licensed under the MIT License (MIT).
*
* Copyright (c) 2021 TeamReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package reborncore.common.misc;
import net.minecraft.tag.Tag;
/**
* Tells if an item, block etc. has a tag solely for compatibility with other mods.
* For example, several mods have bronze ingots, so TechReborn will tag its bronze ingot with a common tag.
* @param <T> The type of the object, like {@link net.minecraft.item.Item} or {@link net.minecraft.block.Block}.
*/
public interface TagConvertible<T> {
/**
* Returns the common tag of this object.
* @return the common tag of this object
*/
Tag.Identified<T> asTag();
}

View file

@ -27,12 +27,18 @@ package techreborn.datagen
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import techreborn.datagen.recipes.smelting.SmeltingRecipesProvider
import techreborn.datagen.recipes.crafting.CraftingRecipesProvider
import techreborn.datagen.tags.TRItemTagProvider
import techreborn.datagen.tags.WaterExplosionTagProvider
class TechRebornDataGen implements DataGeneratorEntrypoint {
@Override
void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
fabricDataGenerator.addProvider(WaterExplosionTagProvider.&new)
fabricDataGenerator.addProvider(TRItemTagProvider.&new)
// tags before all else, very important!!
fabricDataGenerator.addProvider(SmeltingRecipesProvider.&new)
fabricDataGenerator.addProvider(CraftingRecipesProvider.&new)
}
}

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.datagen.recipes.smelting
package techreborn.datagen.recipes
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipesProvider
@ -50,13 +50,16 @@ abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
abstract void generateRecipes()
static Ingredient createIngredient(def input) {
if (input instanceof Ingredient) {
return input
}
if (input instanceof ItemConvertible) {
return Ingredient.ofItems(input)
} else if (input instanceof Tag.Identified) {
return Ingredient.fromTag(input)
}
throw new UnsupportedOperationException()
throw new IllegalArgumentException()
}
static String getCriterionName(def input) {
@ -66,7 +69,7 @@ abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
return "has_tag_" + input.getId()
}
throw new UnsupportedOperationException()
throw new IllegalArgumentException()
}
static CriterionConditions getCriterionConditions(def input) {
@ -76,7 +79,7 @@ abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
return conditionsFromTag(input)
}
throw new UnsupportedOperationException()
throw new IllegalArgumentException()
}
static String getInputPath(def input) {
@ -86,7 +89,35 @@ abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
return input.getId().toString().replace(":", "_")
}
throw new UnsupportedOperationException()
throw new IllegalArgumentException()
}
static String getName(def input) {
if (input instanceof ItemConvertible) {
return getItemPath(input)
} else if (input instanceof Tag.Identified) {
String name = input.getId().toString()
if (name.contains(":"))
name = name.substring(name.indexOf(":")+1)
return name
}
throw new IllegalArgumentException()
}
static String getNamePart1(def input) {
String name
if (input instanceof ItemConvertible) {
name = getItemPath(input)
return name.substring(0,name.indexOf("_"))
} else if (input instanceof Tag.Identified) {
name = input.getId().toString()
if (name.contains(":"))
name = name.substring(name.indexOf(":")+1)
return name.substring(0,name.indexOf("_"))
}
throw new IllegalArgumentException()
}
@Override

View file

@ -0,0 +1,343 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.datagen.recipes.crafting
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.minecraft.data.server.recipe.ShapedRecipeJsonFactory
import net.minecraft.data.server.recipe.ShapelessRecipeJsonFactory
import net.minecraft.data.server.recipe.SingleItemRecipeJsonFactory
import net.minecraft.item.ItemConvertible
import net.minecraft.item.Items
import net.minecraft.util.Identifier
import techreborn.TechReborn
import techreborn.datagen.recipes.TechRebornRecipesProvider
import techreborn.init.TRContent
import java.util.function.Function
class CraftingRecipesProvider extends TechRebornRecipesProvider {
CraftingRecipesProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator)
}
@Override
void generateRecipes() {
// add dust from small dust and vice versa recipes
TRContent.SmallDusts.getSD2DMap().each { input, output ->
offerMonoShapelessRecipe(input, 4, output, 1, "small", "crafting_table/dust/")
offerMonoShapelessRecipe(output, 1, input, 4, "dust", "crafting_table/small_dust/")
}
// add storage block from raw metal and vice versa recipes
TRContent.RawMetals.getRM2SBMap().each { input, output ->
offerMonoShapelessRecipe(input, 9, output, 1, null, "crafting_table/storage_block/", "raw_" + getInputPath(output))
offerMonoShapelessRecipe(output, 1, input, 9, "block", "crafting_table/raw/")
}
// add storage block from gem and vice versa recipes
TRContent.Gems.getG2SBMap().each { input, output ->
offerMonoShapelessRecipe(input, 9, output, 1, null, "crafting_table/storage_block/", )
offerMonoShapelessRecipe(output, 1, input, 9, "block", "crafting_table/gem/")
}
// add storage block from ingot and vice versa recipes
TRContent.Ingots.getI2SBMap().each { input, output ->
offerMonoShapelessRecipe(input, 9, output, 1, null, "crafting_table/storage_block/")
offerMonoShapelessRecipe(output, 1, input, 9, "block", "crafting_table/ingot/")
}
// add ingot from nugget and vice versa recipes
TRContent.Nuggets.getN2IMap().each { input, output ->
offerMonoShapelessRecipe(input, 9, output, 1, "nugget", input.isOfGem() ? "crafting_table/gem/" : "crafting_table/ingot/")
offerMonoShapelessRecipe(output, 1, input, 9, null, "crafting_table/nugget/")
}
// add slabs, stairs and walls
TRContent.StorageBlocks.values().each {block ->
offerSlabRecipe(block.asTag(), block.getSlabBlock(), "crafting_table/storage_block/")
offerSlabRecipeStonecutter(block.asTag(), block.getSlabBlock(), "crafting_table/storage_block/")
offerStairsRecipe(block.asTag(), block.getStairsBlock(), "crafting_table/storage_block/")
offerStairsRecipeStonecutter(block.asTag(), block.getStairsBlock(), "crafting_table/storage_block/")
offerWallRecipe(block.asTag(), block.getWallBlock(), "crafting_table/storage_block/")
offerWallRecipeStonecutter(block.asTag(), block.getWallBlock(), "crafting_table/storage_block/")
}
generateToolRecipes()
generateArmorRecipes()
}
def generateToolRecipes() {
// add axes
[
(TRContent.Ingots.BRONZE.asTag()): TRContent.BRONZE_AXE,
(TRContent.Gems.PERIDOT) : TRContent.PERIDOT_AXE,
(TRContent.Gems.RUBY) : TRContent.RUBY_AXE,
(TRContent.Gems.SAPPHIRE) : TRContent.SAPPHIRE_AXE
].each { material, axe ->
offerAxeRecipe(material, axe, "crafting_table/tool/")
}
// add hoes
[
(TRContent.Ingots.BRONZE.asTag()): TRContent.BRONZE_HOE,
(TRContent.Gems.PERIDOT) : TRContent.PERIDOT_HOE,
(TRContent.Gems.RUBY) : TRContent.RUBY_HOE,
(TRContent.Gems.SAPPHIRE) : TRContent.SAPPHIRE_HOE
].each { material, hoe ->
offerHoeRecipe(material, hoe, "crafting_table/tool/")
}
// add pickaxes
[
(TRContent.Ingots.BRONZE.asTag()): TRContent.BRONZE_PICKAXE,
(TRContent.Gems.PERIDOT) : TRContent.PERIDOT_PICKAXE,
(TRContent.Gems.RUBY) : TRContent.RUBY_PICKAXE,
(TRContent.Gems.SAPPHIRE) : TRContent.SAPPHIRE_PICKAXE
].each { material, pickaxe ->
offerPickaxeRecipe(material, pickaxe, "crafting_table/tool/")
}
// add shovels
[
(TRContent.Ingots.BRONZE.asTag()): TRContent.BRONZE_SPADE,
(TRContent.Gems.PERIDOT) : TRContent.PERIDOT_SPADE,
(TRContent.Gems.RUBY) : TRContent.RUBY_SPADE,
(TRContent.Gems.SAPPHIRE) : TRContent.SAPPHIRE_SPADE
].each { material, shovel ->
offerShovelRecipe(material, shovel, "crafting_table/tool/", "spade")
}
// add swords
[
(TRContent.Ingots.BRONZE.asTag()): TRContent.BRONZE_SWORD,
(TRContent.Gems.PERIDOT) : TRContent.PERIDOT_SWORD,
(TRContent.Gems.RUBY) : TRContent.RUBY_SWORD,
(TRContent.Gems.SAPPHIRE) : TRContent.SAPPHIRE_SWORD
].each { material, sword ->
offerSwordRecipe(material, sword, "crafting_table/tool/")
}
}
def generateArmorRecipes() {
// add boots
[
(TRContent.Ingots.BRONZE.asTag()): TRContent.BRONZE_BOOTS,
(TRContent.Gems.PERIDOT) : TRContent.PERIDOT_BOOTS,
(TRContent.Gems.RUBY) : TRContent.RUBY_BOOTS,
(TRContent.Gems.SAPPHIRE) : TRContent.SAPPHIRE_BOOTS,
(TRContent.Ingots.SILVER) : TRContent.SILVER_BOOTS,
(TRContent.Ingots.STEEL) : TRContent.STEEL_BOOTS
].each { material, boots ->
offerBootsRecipe(material, boots, "crafting_table/armor/")
}
// add chestplate
[
(TRContent.Ingots.BRONZE.asTag()): TRContent.BRONZE_CHESTPLATE,
(TRContent.Gems.PERIDOT) : TRContent.PERIDOT_CHESTPLATE,
(TRContent.Gems.RUBY) : TRContent.RUBY_CHESTPLATE,
(TRContent.Gems.SAPPHIRE) : TRContent.SAPPHIRE_CHESTPLATE,
(TRContent.Ingots.SILVER) : TRContent.SILVER_CHESTPLATE,
(TRContent.Ingots.STEEL) : TRContent.STEEL_CHESTPLATE
].each { material, chestplate ->
offerChestplateRecipe(material, chestplate, "crafting_table/armor/")
}
// add helmets
[
(TRContent.Ingots.BRONZE.asTag()): TRContent.BRONZE_HELMET,
(TRContent.Gems.PERIDOT) : TRContent.PERIDOT_HELMET,
(TRContent.Gems.RUBY) : TRContent.RUBY_HELMET,
(TRContent.Gems.SAPPHIRE) : TRContent.SAPPHIRE_HELMET,
(TRContent.Ingots.SILVER) : TRContent.SILVER_HELMET,
(TRContent.Ingots.STEEL) : TRContent.STEEL_HELMET
].each { material, helmet ->
offerHelmetRecipe(material, helmet, "crafting_table/armor/")
}
// add leggings
[
(TRContent.Ingots.BRONZE.asTag()): TRContent.BRONZE_LEGGINGS,
(TRContent.Gems.PERIDOT) : TRContent.PERIDOT_LEGGINGS,
(TRContent.Gems.RUBY) : TRContent.RUBY_LEGGINGS,
(TRContent.Gems.SAPPHIRE) : TRContent.SAPPHIRE_LEGGINGS,
(TRContent.Ingots.SILVER) : TRContent.SILVER_LEGGINGS,
(TRContent.Ingots.STEEL) : TRContent.STEEL_LEGGINGS
].each { material, leggings ->
offerLeggingsRecipe(material, leggings, "crafting_table/armor/")
}
}
def static recipeNameString(String prefix, def input, def output, String source = null, String result = null) {
StringBuilder s = new StringBuilder()
s.append(prefix)
if (result == null)
s.append(getInputPath(output))
else
s.append(result)
if (source != null) {
s.append("_from_")
s.append(source)
}
return s.toString()
}
def offerMonoShapelessRecipe(def input, int inputSize, ItemConvertible output, int outputSize, String source, prefix = "", String result = null) {
ShapelessRecipeJsonFactory.create(output, outputSize).input(createIngredient(input), inputSize)
.criterion(getCriterionName(input), getCriterionConditions(input))
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, recipeNameString(prefix, input, output, source, result)))
}
def static materialTypeString(String prefix, def material, String type, Function<?, String> modifier) {
StringBuilder s = new StringBuilder()
s.append(prefix)
s.append(modifier.apply(material))
s.append('_')
s.append(type)
return s.toString()
}
def static createMonoShapeRecipe(def input, ItemConvertible output, char character, int outputAmount = 1) {
return ShapedRecipeJsonFactory.create(output, outputAmount)
.input(character, createIngredient(input))
.criterion(getCriterionName(input), getCriterionConditions(input))
}
def static createDuoShapeRecipe(def input1, def input2, ItemConvertible output, char char1, char char2, boolean crit1 = true, boolean crit2 = false) {
ShapedRecipeJsonFactory factory = ShapedRecipeJsonFactory.create(output)
.input(char1, createIngredient(input1))
.input(char2, createIngredient(input2))
if (crit1)
factory = factory.criterion(getCriterionName(input1), getCriterionConditions(input1))
if (crit2)
factory = factory.criterion(getCriterionName(input2), getCriterionConditions(input2))
return factory
}
def static createStonecutterRecipe(def input, ItemConvertible output, int outputAmount = 1) {
return SingleItemRecipeJsonFactory.createStonecutting(createIngredient(input), output, outputAmount)
.criterion(getCriterionName(input), getCriterionConditions(input))
}
def offerSlabRecipe(def material, ItemConvertible output, prefix = "") {
createMonoShapeRecipe(material, output, 'X' as char, 6)
.pattern("XXX")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, "slab", TechRebornRecipesProvider::getName)))
}
def offerSlabRecipeStonecutter(def material, ItemConvertible output, prefix = "") {
createStonecutterRecipe(material, output, 2)
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, "slab", TechRebornRecipesProvider::getName) + "_stonecutter"))
}
def offerStairsRecipe(def material, ItemConvertible output, prefix = "") {
createMonoShapeRecipe(material, output, 'X' as char, 4)
.pattern("X ")
.pattern("XX ")
.pattern("XXX")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, "stairs", TechRebornRecipesProvider::getName)))
}
def offerStairsRecipeStonecutter(def material, ItemConvertible output, prefix = "") {
createStonecutterRecipe(material, output)
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, "stairs", TechRebornRecipesProvider::getName) + "_stonecutter"))
}
def offerWallRecipe(def material, ItemConvertible output, prefix = "") {
createMonoShapeRecipe(material, output, 'X' as char, 6)
.pattern("XXX")
.pattern("XXX")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, "wall", TechRebornRecipesProvider::getName)))
}
def offerWallRecipeStonecutter(def material, ItemConvertible output, prefix = "") {
createStonecutterRecipe(material, output)
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, "wall", TechRebornRecipesProvider::getName) + "_stonecutter"))
}
def offerAxeRecipe(def material, ItemConvertible output, prefix = "", String type = "axe") {
createDuoShapeRecipe(material, Items.STICK, output,
'X' as char, '#' as char)
.pattern("XX")
.pattern("X#")
.pattern(" #")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, type, TechRebornRecipesProvider::getNamePart1)))
}
def offerHoeRecipe(def material, ItemConvertible output, prefix = "", String type = "hoe") {
createDuoShapeRecipe(material, Items.STICK, output,
'X' as char, '#' as char)
.pattern("XX")
.pattern(" #")
.pattern(" #")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, type, TechRebornRecipesProvider::getNamePart1)))
}
def offerPickaxeRecipe(def material, ItemConvertible output, prefix = "", String type = "pickaxe") {
createDuoShapeRecipe(material, Items.STICK, output,
'X' as char, '#' as char)
.pattern("XXX")
.pattern(" # ")
.pattern(" # ")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, type, TechRebornRecipesProvider::getNamePart1)))
}
def offerShovelRecipe(def material, ItemConvertible output, prefix = "", String type = "shovel") {
createDuoShapeRecipe(material, Items.STICK, output,
'X' as char, '#' as char)
.pattern("X")
.pattern("#")
.pattern("#")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, type, TechRebornRecipesProvider::getNamePart1)))
}
def offerSwordRecipe(def material, ItemConvertible output, prefix = "", String type = "sword") {
createDuoShapeRecipe(material, Items.STICK, output,
'X' as char, '#' as char)
.pattern("X")
.pattern("X")
.pattern("#")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, type, TechRebornRecipesProvider::getNamePart1)))
}
def offerBootsRecipe(def material, ItemConvertible output, prefix = "", String type = "boots") {
createMonoShapeRecipe(material, output, 'X' as char)
.pattern("X X")
.pattern("X X")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, type, TechRebornRecipesProvider::getNamePart1)))
}
def offerChestplateRecipe(def material, ItemConvertible output, prefix = "", String type = "chestplate") {
createMonoShapeRecipe(material, output, 'X' as char)
.pattern("X X")
.pattern("XXX")
.pattern("XXX")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, type, TechRebornRecipesProvider::getNamePart1)))
}
def offerHelmetRecipe(def material, ItemConvertible output, prefix = "", String type = "helmet") {
createMonoShapeRecipe(material, output, 'X' as char)
.pattern("XXX")
.pattern("X X")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, type, TechRebornRecipesProvider::getNamePart1)))
}
def offerLeggingsRecipe(def material, ItemConvertible output, prefix = "", String type = "leggings") {
createMonoShapeRecipe(material, output, 'X' as char)
.pattern("XXX")
.pattern("X X")
.pattern("X X")
.offerTo(this.exporter, new Identifier(TechReborn.MOD_ID, materialTypeString(prefix, material, type, TechRebornRecipesProvider::getNamePart1)))
}
}

View file

@ -30,6 +30,7 @@ import net.minecraft.item.ItemConvertible
import net.minecraft.item.Items
import net.minecraft.recipe.CookingRecipeSerializer
import net.minecraft.recipe.RecipeSerializer
import techreborn.datagen.recipes.TechRebornRecipesProvider
import techreborn.datagen.tags.CommonTags
import techreborn.init.TRContent
@ -43,22 +44,22 @@ class SmeltingRecipesProvider extends TechRebornRecipesProvider {
// Add smelting and blasting recipes.
[
(TRContent.Ingots.MIXED_METAL) : TRContent.Ingots.ADVANCED_ALLOY,
(CommonTags.Items.brassDusts) : TRContent.Ingots.BRASS,
(TRContent.Dusts.BRASS.asTag()) : TRContent.Ingots.BRASS,
(TRContent.Dusts.BRONZE) : TRContent.Ingots.BRONZE,
(CommonTags.Items.electrumDusts): TRContent.Ingots.ELECTRUM,
(TRContent.Dusts.ELECTRUM.asTag()): TRContent.Ingots.ELECTRUM,
(TRContent.Dusts.INVAR) : TRContent.Ingots.INVAR,
(CommonTags.Items.leadOres) : TRContent.Ingots.LEAD,
(CommonTags.Items.rawLeadOres) : TRContent.Ingots.LEAD,
(TRContent.Dusts.NICKEL) : TRContent.Ingots.NICKEL,
(CommonTags.Items.sheldoniteOres) : TRContent.Ingots.PLATINUM,
(CommonTags.Items.platinumDusts) : TRContent.Ingots.PLATINUM,
(TRContent.Dusts.PLATINUM.asTag()): TRContent.Ingots.PLATINUM,
(Items.IRON_INGOT) : TRContent.Ingots.REFINED_IRON,
(CommonTags.Items.ironPlates) : TRContent.Plates.REFINED_IRON,
(CommonTags.Items.silverOres) : TRContent.Ingots.SILVER,
(CommonTags.Items.rawSilverOres) : TRContent.Ingots.SILVER,
(CommonTags.Items.tinOres) : TRContent.Ingots.TIN,
(CommonTags.Items.rawTinOres) : TRContent.Ingots.TIN,
(CommonTags.Items.zincDusts) : TRContent.Ingots.ZINC
(TRContent.Dusts.ZINC.asTag()) : TRContent.Ingots.ZINC
].each { input, output ->
offerSmelting(input, output)
offerBlasting(input, output)

View file

@ -29,12 +29,6 @@ import net.minecraft.util.Identifier
class CommonTags {
static class Items {
public static zincIngots = create("zinc_ingots")
public static brassDusts = create("brass_dusts")
public static electrumDusts = create("electrum_dusts")
public static platinumDusts = create("platinum_dusts")
public static zincDusts = create("zinc_dusts")
public static leadOres = create("lead_ores")
public static sheldoniteOres = create("sheldonite_ores")

View file

@ -0,0 +1,75 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 TechReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package techreborn.datagen.tags
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider.ItemTagProvider
import techreborn.init.TRContent
class TRItemTagProvider extends ItemTagProvider {
TRItemTagProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator)
}
@Override
protected void generateTags() {
TRContent.Ores.values().each { ore ->
getOrCreateTagBuilder(ore.asTag()).add(ore.asItem())
getOrCreateTagBuilder(TRContent.ORES_TAG).add(ore.asItem())
}
TRContent.StorageBlocks.values().each { block ->
getOrCreateTagBuilder(block.asTag()).add(block.asItem())
getOrCreateTagBuilder(TRContent.STORAGE_BLOCK_TAG).add(block.asItem())
}
TRContent.Dusts.values().each { dust ->
getOrCreateTagBuilder(dust.asTag()).add(dust.asItem())
getOrCreateTagBuilder(TRContent.DUSTS_TAG).add(dust.asItem())
}
TRContent.RawMetals.values().each { raw ->
getOrCreateTagBuilder(raw.asTag()).add(raw.asItem())
getOrCreateTagBuilder(TRContent.RAW_METALS_TAG).add(raw.asItem())
}
TRContent.SmallDusts.values().each { smallDust ->
getOrCreateTagBuilder(smallDust.asTag()).add(smallDust.asItem())
getOrCreateTagBuilder(TRContent.SMALL_DUSTS_TAG).add(smallDust.asItem())
}
TRContent.Gems.values().each { gem ->
getOrCreateTagBuilder(gem.asTag()).add(gem.asItem())
getOrCreateTagBuilder(TRContent.GEMS_TAG).add(gem.asItem())
}
TRContent.Ingots.values().each { ingot ->
getOrCreateTagBuilder(ingot.asTag()).add(ingot.asItem())
getOrCreateTagBuilder(TRContent.INGOTS_TAG).add(ingot.asItem())
}
TRContent.Nuggets.values().each { nugget ->
getOrCreateTagBuilder(nugget.asTag()).add(nugget.asItem())
getOrCreateTagBuilder(TRContent.NUGGETS_TAG).add(nugget.asItem())
}
TRContent.Plates.values().each { plate ->
getOrCreateTagBuilder(plate.asTag()).add(plate.asItem())
getOrCreateTagBuilder(TRContent.PLATES_TAG).add(plate.asItem())
}
}
}

View file

@ -112,15 +112,15 @@ public class ModRegistry {
}
private static void registerItems() {
Arrays.stream(Ingots.values()).forEach(value -> RebornRegistry.registerItem(value.item));
Arrays.stream(Nuggets.values()).forEach(value -> RebornRegistry.registerItem(value.item));
Arrays.stream(Gems.values()).forEach(value -> RebornRegistry.registerItem(value.item));
Arrays.stream(Dusts.values()).forEach(value -> RebornRegistry.registerItem(value.item));
Arrays.stream(RawMetals.values()).forEach(value -> RebornRegistry.registerItem(value.item));
Arrays.stream(SmallDusts.values()).forEach(value -> RebornRegistry.registerItem(value.item));
Arrays.stream(Plates.values()).forEach(value -> RebornRegistry.registerItem(value.item));
Arrays.stream(Parts.values()).forEach(value -> RebornRegistry.registerItem(value.item));
Arrays.stream(Upgrades.values()).forEach(value -> RebornRegistry.registerItem(value.item));
Arrays.stream(Ingots.values()).forEach(value -> RebornRegistry.registerItem(value.asItem()));
Arrays.stream(Nuggets.values()).forEach(value -> RebornRegistry.registerItem(value.asItem()));
Arrays.stream(Gems.values()).forEach(value -> RebornRegistry.registerItem(value.asItem()));
Arrays.stream(Dusts.values()).forEach(value -> RebornRegistry.registerItem(value.asItem()));
Arrays.stream(RawMetals.values()).forEach(value -> RebornRegistry.registerItem(value.asItem()));
Arrays.stream(SmallDusts.values()).forEach(value -> RebornRegistry.registerItem(value.asItem()));
Arrays.stream(Plates.values()).forEach(value -> RebornRegistry.registerItem(value.asItem()));
Arrays.stream(Parts.values()).forEach(value -> RebornRegistry.registerItem(value.asItem()));
Arrays.stream(Upgrades.values()).forEach(value -> RebornRegistry.registerItem(value.asItem()));
RebornRegistry.registerItem(TRContent.QUANTUM_HELMET = InitUtils.setup(new QuantumSuitItem(TRArmorMaterials.QUANTUM, EquipmentSlot.HEAD), "quantum_helmet"));
RebornRegistry.registerItem(TRContent.QUANTUM_CHESTPLATE = InitUtils.setup(new QuantumSuitItem(TRArmorMaterials.QUANTUM, EquipmentSlot.CHEST), "quantum_chestplate"));

View file

@ -26,16 +26,23 @@ package techreborn.init;
import com.google.common.base.Preconditions;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tag.TagFactory;
import net.minecraft.block.*;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import net.minecraft.util.math.intprovider.UniformIntProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import reborncore.api.blockentity.IUpgrade;
import reborncore.common.fluid.FluidValue;
import reborncore.common.misc.TagConvertible;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.powerSystem.RcEnergyTier;
@ -86,6 +93,7 @@ import techreborn.world.OreDistribution;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class TRContent {
@ -389,13 +397,14 @@ public class TRContent {
}
}
public static final Tag.Identified<Item> ORES_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "ores"));
private final static Map<Ores, Ores> deepslateMap = new HashMap<>();
private final static Map<Ores, Ores> unDeepslateMap = new HashMap<>();
public enum Ores implements ItemConvertible {
// when changing ores also change data/techreborn/tags/items/ores.json for correct root advancement display
// as well as data/minecraft/tags/blocks for correct mining level
public enum Ores implements ItemConvertible, TagConvertible<Item> {
// when changing ores also change data/minecraft/tags/blocks for correct mining level
BAUXITE(OreDistribution.BAUXITE),
CINNABAR(OreDistribution.CINNABAR),
GALENA(OreDistribution.GALENA),
@ -428,6 +437,7 @@ public class TRContent {
public final String name;
public final Block block;
public final OreDistribution distribution;
private final Tag.Identified<Item> tag;
Ores(OreDistribution distribution, UniformIntProvider experienceDroppedFallback) {
name = this.toString().toLowerCase(Locale.ROOT);
@ -437,8 +447,9 @@ public class TRContent {
.strength(2f, 2f),
distribution != null ? distribution.experienceDropped : experienceDroppedFallback
);
InitUtils.setup(block, name + "_ore");
tag = TagFactory.ITEM.create(new Identifier("c",
(name.startsWith("deepslate_") ? name.substring(name.indexOf('_')+1): name) + "_ores"));
this.distribution = distribution;
}
@ -457,6 +468,11 @@ public class TRContent {
return block.asItem();
}
@Override
public Tag.Identified<Item> asTag() {
return tag;
}
public TRContent.Ores getDeepslate() {
Preconditions.checkArgument(!isDeepslate());
return deepslateMap.get(this);
@ -472,22 +488,26 @@ public class TRContent {
}
}
public enum StorageBlocks implements ItemConvertible {
public static final Tag.Identified<Item> STORAGE_BLOCK_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "storage_blocks"));
public enum StorageBlocks implements ItemConvertible, TagConvertible<Item> {
ALUMINUM, BRASS, BRONZE, CHROME, ELECTRUM, INVAR, IRIDIUM, IRIDIUM_REINFORCED_STONE,
IRIDIUM_REINFORCED_TUNGSTENSTEEL, LEAD, NICKEL, PERIDOT, PLATINUM, RAW_IRIDIUM, RAW_LEAD, RAW_SILVER, RAW_TIN,
RAW_TUNGSTEN, RED_GARNET, REFINED_IRON, RUBY, SAPPHIRE, SILVER, STEEL, TIN, TITANIUM, TUNGSTEN, TUNGSTENSTEEL,
YELLOW_GARNET, ZINC;
public final String name;
public final Block block;
public final StairsBlock stairsBlock;
public final SlabBlock slabBlock;
public final WallBlock wallBlock;
private final String name;
private final Block block;
private final StairsBlock stairsBlock;
private final SlabBlock slabBlock;
private final WallBlock wallBlock;
private final Tag.Identified<Item> tag;
StorageBlocks() {
name = this.toString().toLowerCase(Locale.ROOT);
block = new BlockStorage();
InitUtils.setup(block, name + "_storage_block");
tag = TagFactory.ITEM.create(new Identifier("c", name + "_blocks"));
stairsBlock = new TechRebornStairsBlock(block.getDefaultState(), FabricBlockSettings.copyOf(block));
InitUtils.setup(stairsBlock, name + "_storage_block_stairs");
@ -504,6 +524,27 @@ public class TRContent {
return block.asItem();
}
@Override
public Tag.Identified<Item> asTag() {
return tag;
}
public Block getBlock() {
return block;
}
public StairsBlock getStairsBlock() {
return stairsBlock;
}
public SlabBlock getSlabBlock() {
return slabBlock;
}
public WallBlock getWallBlock() {
return wallBlock;
}
public static Stream<Block> blockStream() {
return Arrays.stream(values())
.map(StorageBlocks::allBlocks)
@ -630,20 +671,24 @@ public class TRContent {
}
}
public enum Dusts implements ItemConvertible {
public static final Tag.Identified<Item> DUSTS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "dusts"));
public enum Dusts implements ItemConvertible, TagConvertible<Item> {
ALMANDINE, ALUMINUM, AMETHYST, ANDESITE, ANDRADITE, ASHES, BASALT, BAUXITE, BRASS, BRONZE, CALCITE, CHARCOAL, CHROME,
CINNABAR, CLAY, COAL, DARK_ASHES, DIAMOND, DIORITE, ELECTRUM, EMERALD, ENDER_EYE, ENDER_PEARL, ENDSTONE,
FLINT, GALENA, GRANITE, GROSSULAR, INVAR, LAZURITE, MAGNESIUM, MANGANESE, MARBLE, NETHERRACK,
NICKEL, OBSIDIAN, OLIVINE, PERIDOT, PHOSPHOROUS, PLATINUM, PYRITE, PYROPE, QUARTZ, RED_GARNET, RUBY, SALTPETER,
SAPPHIRE, SAW, SODALITE, SPESSARTINE, SPHALERITE, STEEL, SULFUR, TITANIUM, UVAROVITE, YELLOW_GARNET, ZINC;
public final String name;
public final Item item;
private final String name;
private final Item item;
private final Tag.Identified<Item> tag;
Dusts() {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
InitUtils.setup(item, name + "_dust");
tag = TagFactory.ITEM.create(new Identifier("c", name + "_dusts"));
}
public ItemStack getStack() {
@ -658,43 +703,97 @@ public class TRContent {
public Item asItem() {
return item;
}
@Override
public Tag.Identified<Item> asTag() {
return tag;
}
}
public static final Tag.Identified<Item> RAW_METALS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "raw_metals"));
public enum RawMetals implements ItemConvertible{
// when changing ores also change data/techreborn/tags/items/raw_metals.json for correct root advancement display
public enum RawMetals implements ItemConvertible, TagConvertible<Item> {
IRIDIUM, LEAD, SILVER, TIN, TUNGSTEN;
public final String name;
public final Item item;
private final String name;
private final Item item;
private final ItemConvertible storageBlock;
private final Tag.Identified<Item> tag;
RawMetals() {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
ItemConvertible blockVariant = null;
try {
blockVariant = StorageBlocks.valueOf(this.toString());
}
catch (IllegalArgumentException ex) {
TechReborn.LOGGER.warn("Raw metal {} has no storage block equivalent!", name);
}
storageBlock = blockVariant;
InitUtils.setup(item, "raw_" + name);
tag = TagFactory.ITEM.create(new Identifier("c", "raw_" + name + "_ores"));
}
@Override
public Item asItem() {
return item;
}
@Override
public Tag.Identified<Item> asTag() {
return tag;
}
public enum SmallDusts implements ItemConvertible {
public ItemConvertible getStorageBlock() {
return storageBlock;
}
/**
* Returns a map that maps the raw metals to their storage block equivalent.
* @return A non {@code null} map mapping the raw metals to their storage block equivalent.
* If a storage block equivalent doesn't exist, the raw metal will not be in the keys of this map.
*/
public static @NotNull Map<RawMetals, ItemConvertible> getRM2SBMap() {
return Arrays.stream(values())
.map(rawMetal -> new Pair<>(rawMetal, rawMetal.getStorageBlock()))
.filter(entry -> entry.getRight() != null) // ensure storage block equivalent exists
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
}
public static final Tag.Identified<Item> SMALL_DUSTS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "small_dusts"));
public enum SmallDusts implements ItemConvertible, TagConvertible<Item> {
ALMANDINE, ANDESITE, ANDRADITE, ASHES, BASALT, BAUXITE, CALCITE, CHARCOAL, CHROME,
CINNABAR, CLAY, COAL, DARK_ASHES, DIAMOND, DIORITE, ELECTRUM, EMERALD, ENDER_EYE, ENDER_PEARL, ENDSTONE,
FLINT, GALENA, GLOWSTONE, GRANITE, GROSSULAR, INVAR, LAZURITE, MAGNESIUM, MANGANESE, MARBLE,
NETHERRACK, NICKEL, OBSIDIAN, OLIVINE, PERIDOT, PHOSPHOROUS, PLATINUM, PYRITE, PYROPE, QUARTZ, REDSTONE, RED_GARNET,
RUBY, SALTPETER, SAPPHIRE, SAW, SODALITE, SPESSARTINE, SPHALERITE, STEEL, SULFUR, TITANIUM,
TUNGSTEN, UVAROVITE, YELLOW_GARNET, ZINC;
FLINT, GALENA, GLOWSTONE(Items.GLOWSTONE_DUST), GRANITE, GROSSULAR, INVAR, LAZURITE, MAGNESIUM, MANGANESE, MARBLE,
NETHERRACK, NICKEL, OBSIDIAN, OLIVINE, PERIDOT, PHOSPHOROUS, PLATINUM, PYRITE, PYROPE, QUARTZ, REDSTONE(Items.REDSTONE),
RED_GARNET, RUBY, SALTPETER, SAPPHIRE, SAW, SODALITE, SPESSARTINE, SPHALERITE, STEEL, SULFUR, TITANIUM,
TUNGSTEN(RawMetals.TUNGSTEN), UVAROVITE, YELLOW_GARNET, ZINC;
public final String name;
public final Item item;
private final String name;
private final Item item;
private final ItemConvertible dust;
private final Tag.Identified<Item> tag;
SmallDusts(ItemConvertible dustVariant) {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
if (dustVariant == null)
try {
dustVariant = Dusts.valueOf(this.toString());
}
catch (IllegalArgumentException ex) {
TechReborn.LOGGER.warn("Small dust {} has no dust equivalent!", name);
}
dust = dustVariant;
InitUtils.setup(item, name + "_small_dust");
tag = TagFactory.ITEM.create(new Identifier("c", name + "_small_dusts"));
}
SmallDusts() {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
InitUtils.setup(item, name + "_small_dust");
this(null);
}
public ItemStack getStack() {
@ -709,19 +808,59 @@ public class TRContent {
public Item asItem() {
return item;
}
@Override
public Tag.Identified<Item> asTag() {
return tag;
}
public enum Gems implements ItemConvertible {
// when changing ores also change data/techreborn/tags/items/gems.json for correct root advancement display
PERIDOT, RED_GARNET, RUBY, SAPPHIRE, YELLOW_GARNET;
public ItemConvertible getDust() {
return dust;
}
public final String name;
public final Item item;
/**
* Returns a map that maps the small dusts to their dust equivalent,
* as it was specified in the enum. Note that the dust equivalent
* doesn't have to be a TR dust (see redstone and glowstone dust)
* and also not a dust at all (see tungsten).
* @return A non {@code null} map mapping the small dusts to their dust equivalent.
* If a dust equivalent doesn't exist, the small dust will not be in the keys of this map.
*/
public static @NotNull Map<SmallDusts, ItemConvertible> getSD2DMap() {
return Arrays.stream(values())
.map(smallDust -> new Pair<>(smallDust, smallDust.getDust()))
.filter(entry -> entry.getRight() != null) // ensure dust equivalent exists
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
}
public static final Tag.Identified<Item> GEMS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "gems"));
public enum Gems implements ItemConvertible, TagConvertible<Item> {
PERIDOT, RED_GARNET, RUBY("rubies"), SAPPHIRE("sapphires"), YELLOW_GARNET;
private final String name;
private final Item item;
private final ItemConvertible storageBlock;
private final Tag.Identified<Item> tag;
Gems(String tagPlural) {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
ItemConvertible blockVariant = null;
try {
blockVariant = StorageBlocks.valueOf(this.toString());
}
catch (IllegalArgumentException ex) {
TechReborn.LOGGER.warn("Gem {} has no storage block equivalent!", name);
}
storageBlock = blockVariant;
InitUtils.setup(item, name + "_gem");
tag = TagFactory.ITEM.create(new Identifier("c", tagPlural == null ? name + "_gems" : tagPlural));
}
Gems() {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
InitUtils.setup(item, name + "_gem");
this(null);
}
public ItemStack getStack() {
@ -736,19 +875,53 @@ public class TRContent {
public Item asItem() {
return item;
}
@Override
public Tag.Identified<Item> asTag() {
return tag;
}
public enum Ingots implements ItemConvertible {
public ItemConvertible getStorageBlock() {
return storageBlock;
}
/**
* Returns a map that maps the gems to their storage block equivalent.
* @return A non {@code null} map mapping the gems to their storage block equivalent.
* If a storage block equivalent doesn't exist, the raw metal will not be in the keys of this map.
*/
public static @NotNull Map<Gems, ItemConvertible> getG2SBMap() {
return Arrays.stream(values())
.map(gem -> new Pair<>(gem, gem.getStorageBlock()))
.filter(entry -> entry.getRight() != null) // ensure storage block equivalent exists
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
}
public static final Tag.Identified<Item> INGOTS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "ingots"));
public enum Ingots implements ItemConvertible, TagConvertible<Item> {
ADVANCED_ALLOY, ALUMINUM, BRASS, BRONZE, CHROME, ELECTRUM, HOT_TUNGSTENSTEEL, INVAR, IRIDIUM_ALLOY, IRIDIUM,
LEAD, MIXED_METAL, NICKEL, PLATINUM, REFINED_IRON, SILVER, STEEL, TIN, TITANIUM, TUNGSTEN, TUNGSTENSTEEL, ZINC;
public final String name;
public final Item item;
private final String name;
private final Item item;
private final ItemConvertible storageBlock;
private final Tag.Identified<Item> tag;
Ingots() {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
ItemConvertible blockVariant = null;
try {
blockVariant = StorageBlocks.valueOf(this.toString());
}
catch (IllegalArgumentException ex) {
TechReborn.LOGGER.warn("Ingot {} has no storage block equivalent!", name);
}
storageBlock = blockVariant;
InitUtils.setup(item, name + "_ingot");
tag = TagFactory.ITEM.create(new Identifier("c", name + "_ingots"));
}
public ItemStack getStack() {
@ -763,19 +936,60 @@ public class TRContent {
public Item asItem() {
return item;
}
@Override
public Tag.Identified<Item> asTag() {
return tag;
}
public enum Nuggets implements ItemConvertible {
ALUMINUM, BRASS, BRONZE, CHROME, COPPER, DIAMOND, ELECTRUM, EMERALD, HOT_TUNGSTENSTEEL, INVAR, IRIDIUM, LEAD, NICKEL,
public ItemConvertible getStorageBlock() {
return storageBlock;
}
/**
* Returns a map that maps the ingots to their storage block equivalent.
* @return A non {@code null} map mapping the ingots to their storage block equivalent.
* If a storage block equivalent doesn't exist, the raw metal will not be in the keys of this map.
*/
public static @NotNull Map<Ingots, ItemConvertible> getI2SBMap() {
return Arrays.stream(values())
.map(ingot -> new Pair<>(ingot, ingot.getStorageBlock()))
.filter(entry -> entry.getRight() != null) // ensure storage block equivalent exists
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
}
public static final Tag.Identified<Item> NUGGETS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "nuggets"));
public enum Nuggets implements ItemConvertible, TagConvertible<Item> {
ALUMINUM, BRASS, BRONZE, CHROME, COPPER(Items.COPPER_INGOT, false), DIAMOND(Items.DIAMOND, true),
ELECTRUM, EMERALD(Items.EMERALD, true), HOT_TUNGSTENSTEEL, INVAR, IRIDIUM, LEAD, NICKEL,
PLATINUM, REFINED_IRON, SILVER, STEEL, TIN, TITANIUM, TUNGSTEN, TUNGSTENSTEEL, ZINC;
public final String name;
public final Item item;
private final String name;
private final Item item;
private final ItemConvertible ingot;
private final boolean ofGem;
private final Tag.Identified<Item> tag;
Nuggets() {
Nuggets(ItemConvertible ingotVariant, boolean ofGem) {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
if (ingotVariant == null)
try {
ingotVariant = Ingots.valueOf(this.toString());
}
catch (IllegalArgumentException ex) {
TechReborn.LOGGER.warn("Nugget {} has no ingot equivalent!", name);
}
ingot = ingotVariant;
this.ofGem = ofGem;
InitUtils.setup(item, name + "_nugget");
tag = TagFactory.ITEM.create(new Identifier("c", name + "_nuggets"));
}
Nuggets() {
this(null, false);
}
public ItemStack getStack() {
@ -790,6 +1004,33 @@ public class TRContent {
public Item asItem() {
return item;
}
@Override
public Tag.Identified<Item> asTag() {
return tag;
}
public ItemConvertible getIngot() {
return ingot;
}
public boolean isOfGem() {
return false;
}
/**
* Returns a map that maps the nuggets to their ingot equivalent,
* as it was specified in the enum. Note that the ingot equivalent
* doesn't have to be an ingot at all (see emerald and diamond).
* @return A non {@code null} map mapping the nuggets to their ingot equivalent.
* If an ingot equivalent doesn't exist, the raw metal will not be in the keys of this map.
*/
public static @NotNull Map<Nuggets, ItemConvertible> getN2IMap() {
return Arrays.stream(values())
.map(nugget -> new Pair<>(nugget, nugget.getIngot()))
.filter(entry -> entry.getRight() != null) // ensure ingot equivalent exists
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
}
public enum Parts implements ItemConvertible {
@ -867,19 +1108,23 @@ public class TRContent {
}
}
public enum Plates implements ItemConvertible {
public static final Tag.Identified<Item> PLATES_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "plates"));
public enum Plates implements ItemConvertible, TagConvertible<Item> {
ADVANCED_ALLOY, ALUMINUM, BRASS, BRONZE, CARBON, CHROME, COAL, COPPER, DIAMOND, ELECTRUM, EMERALD, GOLD, INVAR,
IRIDIUM_ALLOY, IRIDIUM, IRON, LAPIS, LAZURITE, LEAD, MAGNALIUM, NICKEL, OBSIDIAN, PERIDOT, PLATINUM, QUARTZ, RED_GARNET,
REDSTONE, REFINED_IRON, RUBY, SAPPHIRE, SILICON, SILVER, STEEL, TIN, TITANIUM, TUNGSTEN, TUNGSTENSTEEL, WOOD,
YELLOW_GARNET, ZINC;
public final String name;
public final Item item;
private final String name;
private final Item item;
private final Tag.Identified<Item> tag;
Plates() {
name = this.toString().toLowerCase(Locale.ROOT);
item = new Item(new Item.Settings().group(TechReborn.ITEMGROUP));
InitUtils.setup(item, name + "_plate");
tag = TagFactory.ITEM.create(new Identifier("c", name + "_plates"));
}
public ItemStack getStack() {
@ -894,6 +1139,11 @@ public class TRContent {
public Item asItem() {
return item;
}
@Override
public Tag.Identified<Item> asTag() {
return tag;
}
}
public enum Upgrades implements ItemConvertible {

View file

@ -80,7 +80,7 @@ public class TechRebornTemplates {
private static void process(TemplateProcessor processor) throws IOException {
processor.processSimpleBlocks("storage_blocks", Arrays.stream(TRContent.StorageBlocks.values())
.map(storageBlocks -> storageBlocks.block)
.map(TRContent.StorageBlocks::getBlock)
.collect(Collectors.toList())
);
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:advanced_alloy_ingot"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:advanced_alloy_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:almandine_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:almandine_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:aluminum_storage_block"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:aluminum_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:aluminum_ingot"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:aluminum_nugget"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:aluminum_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:amethyst_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:andesite_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:andesite_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:andradite_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:andradite_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:ashes_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:ashes_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:basalt_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:basalt_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:bauxite_dust"
]
}

View file

@ -1,7 +0,0 @@
{
"replace": false,
"values": [
"techreborn:bauxite_ore",
"techreborn:deepslate_bauxite_ore"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:bauxite_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:brass_storage_block"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:brass_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:brass_ingot"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:brass_nugget"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:brass_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:bronze_storage_block"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:bronze_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:bronze_ingot"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:bronze_nugget"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:bronze_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:calcite_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:calcite_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:carbon_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:charcoal_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:charcoal_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:chrome_storage_block"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:chrome_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:chrome_ingot"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:chrome_nugget"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:chrome_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:chrome_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:cinnabar_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:cinnabar_ore"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:cinnabar_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:clay_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:clay_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:coal_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:coal_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:coal_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:copper_nugget"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:copper_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:dark_ashes_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:dark_ashes_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:diamond_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:diamond_nugget"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:diamond_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:diamond_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:diorite_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:diorite_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:electrum_storage_block"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:electrum_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:electrum_ingot"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:electrum_nugget"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:electrum_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:electrum_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:emerald_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:emerald_nugget"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:emerald_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:emerald_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:ender_eye_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:ender_eye_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:ender_pearl_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:ender_pearl_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:endstone_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:endstone_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:flint_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:flint_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:galena_dust"
]
}

View file

@ -1,7 +0,0 @@
{
"replace": false,
"values": [
"techreborn:galena_ore",
"techreborn:deepslate_galena_ore"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:galena_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:glowstone_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:gold_plate"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:granite_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:granite_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:grossular_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:grossular_small_dust"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:hot_tungstensteel_ingot"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:hot_tungstensteel_nugget"
]
}

View file

@ -1,6 +0,0 @@
{
"replace": false,
"values": [
"techreborn:invar_storage_block"
]
}

Some files were not shown because too many files have changed in this diff Show more