Port to 1.18.2 (#2824)

* Port to 1.18.2-pre1

* 1.18.2-pre3

* Fix build.

* Fixes and cleanup

* Build fix?

* Update REI
This commit is contained in:
modmuss50 2022-02-28 09:18:27 +00:00 committed by GitHub
parent 4465ffa1aa
commit f7d5139332
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 406 additions and 393 deletions

View file

@ -29,6 +29,7 @@ import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import techreborn.datagen.recipes.machine.grinder.GrinderRecipesProvider
import techreborn.datagen.recipes.smelting.SmeltingRecipesProvider
import techreborn.datagen.recipes.crafting.CraftingRecipesProvider
import techreborn.datagen.tags.TRBlockTagProvider
import techreborn.datagen.tags.TRItemTagProvider
import techreborn.datagen.tags.WaterExplosionTagProvider
@ -38,6 +39,7 @@ class TechRebornDataGen implements DataGeneratorEntrypoint {
void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
fabricDataGenerator.addProvider(WaterExplosionTagProvider.&new)
fabricDataGenerator.addProvider(TRItemTagProvider.&new)
fabricDataGenerator.addProvider(TRBlockTagProvider.&new)
// tags before all else, very important!!
fabricDataGenerator.addProvider(SmeltingRecipesProvider.&new)
fabricDataGenerator.addProvider(CraftingRecipesProvider.&new)

View file

@ -25,12 +25,12 @@
package techreborn.datagen.recipes
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipesProvider
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider
import net.minecraft.advancement.criterion.CriterionConditions
import net.minecraft.data.server.recipe.RecipeJsonProvider
import net.minecraft.item.ItemConvertible
import net.minecraft.recipe.Ingredient
import net.minecraft.tag.Tag
import net.minecraft.tag.TagKey
import net.minecraft.util.Identifier
import techreborn.datagen.recipes.machine.MachineRecipeJsonFactory
@ -38,7 +38,7 @@ import techreborn.init.ModRecipes
import java.util.function.Consumer
abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
abstract class TechRebornRecipesProvider extends FabricRecipeProvider {
protected Consumer<RecipeJsonProvider> exporter
TechRebornRecipesProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator)
@ -58,7 +58,7 @@ abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
}
if (input instanceof ItemConvertible) {
return Ingredient.ofItems(input)
} else if (input instanceof Tag.Identified) {
} else if (input instanceof TagKey) {
return Ingredient.fromTag(input)
}
@ -68,8 +68,8 @@ abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
static String getCriterionName(def input) {
if (input instanceof ItemConvertible) {
return hasItem(input)
} else if (input instanceof Tag.Identified) {
return "has_tag_" + input.getId()
} else if (input instanceof TagKey) {
return "has_tag_" + input.id()
}
throw new IllegalArgumentException()
@ -78,7 +78,7 @@ abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
static CriterionConditions getCriterionConditions(def input) {
if (input instanceof ItemConvertible) {
return conditionsFromItem(input)
} else if (input instanceof Tag.Identified) {
} else if (input instanceof TagKey) {
return conditionsFromTag(input)
}
@ -88,8 +88,8 @@ abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
static String getInputPath(def input) {
if (input instanceof ItemConvertible) {
return getItemPath(input)
} else if (input instanceof Tag.Identified) {
return input.getId().toString().replace(":", "_")
} else if (input instanceof TagKey) {
return input.id().toString().replace(":", "_")
}
throw new IllegalArgumentException()
@ -98,8 +98,8 @@ abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
static String getName(def input) {
if (input instanceof ItemConvertible) {
return getItemPath(input)
} else if (input instanceof Tag.Identified) {
String name = input.getId().toString()
} else if (input instanceof TagKey) {
String name = input.id().toString()
if (name.contains(":"))
name = name.substring(name.indexOf(":")+1)
return name
@ -113,8 +113,8 @@ abstract class TechRebornRecipesProvider extends FabricRecipesProvider {
if (input instanceof ItemConvertible) {
name = getItemPath(input)
return name.substring(0,name.indexOf("_"))
} else if (input instanceof Tag.Identified) {
name = input.getId().toString()
} else if (input instanceof TagKey) {
name = input.id().toString()
if (name.contains(":"))
name = name.substring(name.indexOf(":")+1)
return name.substring(0,name.indexOf("_"))

View file

@ -25,9 +25,9 @@
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.data.server.recipe.ShapedRecipeJsonBuilder
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder
import net.minecraft.data.server.recipe.SingleItemRecipeJsonBuilder
import net.minecraft.item.ItemConvertible
import net.minecraft.item.Items
import net.minecraft.util.Identifier
@ -192,7 +192,7 @@ class CraftingRecipesProvider extends TechRebornRecipesProvider {
}
def offerMonoShapelessRecipe(def input, int inputSize, ItemConvertible output, int outputSize, String source, prefix = "", String result = null) {
ShapelessRecipeJsonFactory.create(output, outputSize).input(createIngredient(input), inputSize)
ShapelessRecipeJsonBuilder.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)))
}
@ -207,13 +207,13 @@ class CraftingRecipesProvider extends TechRebornRecipesProvider {
}
def static createMonoShapeRecipe(def input, ItemConvertible output, char character, int outputAmount = 1) {
return ShapedRecipeJsonFactory.create(output, outputAmount)
return ShapedRecipeJsonBuilder.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)
ShapedRecipeJsonBuilder factory = ShapedRecipeJsonBuilder.create(output)
.input(char1, createIngredient(input1))
.input(char2, createIngredient(input2))
if (crit1)
@ -224,7 +224,7 @@ class CraftingRecipesProvider extends TechRebornRecipesProvider {
}
def static createStonecutterRecipe(def input, ItemConvertible output, int outputAmount = 1) {
return SingleItemRecipeJsonFactory.createStonecutting(createIngredient(input), output, outputAmount)
return SingleItemRecipeJsonBuilder.createStonecutting(createIngredient(input), output, outputAmount)
.criterion(getCriterionName(input), getCriterionConditions(input))
}

View file

@ -27,13 +27,13 @@ package techreborn.datagen.recipes.machine
import net.minecraft.item.Item
import net.minecraft.item.ItemConvertible
import net.minecraft.item.ItemStack
import net.minecraft.tag.Tag
import net.minecraft.tag.TagKey
import reborncore.common.crafting.ingredient.RebornIngredient
import reborncore.common.crafting.ingredient.StackIngredient
import reborncore.common.crafting.ingredient.TagIngredient
class IngredientBuilder {
private Tag.Identified<Item> tag
private TagKey<Item> tag
private List<ItemStack> stacks = new ArrayList<>()
private IngredientBuilder() {
@ -59,7 +59,7 @@ class IngredientBuilder {
throw new IllegalStateException()
}
def tag(Tag.Identified<Item> tag) {
def tag(TagKey<Item> tag) {
this.tag = tag
return this
}

View file

@ -29,7 +29,7 @@ import net.minecraft.data.server.recipe.RecipeJsonProvider
import net.minecraft.item.ItemConvertible
import net.minecraft.item.ItemStack
import net.minecraft.recipe.RecipeSerializer
import net.minecraft.tag.Tag
import net.minecraft.tag.TagKey
import net.minecraft.util.Identifier
import net.minecraft.util.registry.Registry
import reborncore.common.crafting.RebornRecipe
@ -68,7 +68,7 @@ class MachineRecipeJsonFactory<R extends RebornRecipe> {
ingredient {
item object
}
} else if (object instanceof Tag.Identified) {
} else if (object instanceof TagKey) {
ingredient {
tag object
}

View file

@ -25,7 +25,7 @@
package techreborn.datagen.recipes.smelting
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.minecraft.data.server.recipe.CookingRecipeJsonFactory
import net.minecraft.data.server.recipe.CookingRecipeJsonBuilder
import net.minecraft.item.ItemConvertible
import net.minecraft.item.Items
import net.minecraft.recipe.CookingRecipeSerializer
@ -75,7 +75,7 @@ class SmeltingRecipesProvider extends TechRebornRecipesProvider {
}
def offerCookingRecipe(def input, ItemConvertible output, float experience, int cookingTime, CookingRecipeSerializer<?> serializer, String prefix = "") {
CookingRecipeJsonFactory.create(createIngredient(input), output, experience, cookingTime, serializer)
CookingRecipeJsonBuilder.create(createIngredient(input), output, experience, cookingTime, serializer)
.criterion(getCriterionName(input), getCriterionConditions(input))
.offerTo(this.exporter, prefix + getInputPath(output) + "_from_" + getInputPath(input))
}

View file

@ -24,8 +24,9 @@
package techreborn.datagen.tags
import net.fabricmc.fabric.api.tag.TagFactory
import net.minecraft.tag.TagKey
import net.minecraft.util.Identifier
import net.minecraft.util.registry.Registry
class CommonTags {
static class Items {
@ -42,7 +43,7 @@ class CommonTags {
public static ironPlates = create("iron_plates")
private static def create(String path) {
return TagFactory.ITEM.create(new Identifier("c", path))
return TagKey.of(Registry.ITEM_KEY, new Identifier("c", path))
}
}
}

View file

@ -22,31 +22,31 @@
* SOFTWARE.
*/
package techreborn.utils;
package techreborn.datagen.tags
import net.minecraft.block.Block;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagGroup;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider
import net.fabricmc.fabric.api.mininglevel.v1.FabricMineableTags
import net.minecraft.tag.BlockTags
import techreborn.items.tool.DrillItem
import techreborn.items.tool.industrial.OmniToolItem
public class TagUtils {
class TRBlockTagProvider extends FabricTagProvider.BlockTagProvider {
public static <T> boolean hasTag(T type, Tag<T> tag) {
return tag.contains(type);
TRBlockTagProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator)
}
public static TagGroup<Block> getAllBlockTags(World world) {
return world.getTagManager().getOrCreateTagGroup(Registry.BLOCK_KEY);
}
@Override
protected void generateTags() {
getOrCreateTagBuilder(DrillItem.DRILL_MINEABLE)
.addOptionalTag(BlockTags.PICKAXE_MINEABLE.id())
.addOptionalTag(BlockTags.SHOVEL_MINEABLE.id())
public static TagGroup<Item> getAllItemTags(World world) {
return world.getTagManager().getOrCreateTagGroup(Registry.ITEM_KEY);
}
public static TagGroup<Fluid> getAllFluidTags(World world) {
return world.getTagManager().getOrCreateTagGroup(Registry.FLUID_KEY);
getOrCreateTagBuilder(OmniToolItem.OMNI_TOOL_MINEABLE)
.addOptionalTag(DrillItem.DRILL_MINEABLE.id())
.addOptionalTag(BlockTags.AXE_MINEABLE.id())
.addOptionalTag(FabricMineableTags.SHEARS_MINEABLE.id())
.addOptionalTag(FabricMineableTags.SWORD_MINEABLE.id())
}
}

View file

@ -26,7 +26,6 @@ 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;
@ -35,9 +34,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import net.minecraft.util.math.intprovider.UniformIntProvider;
import net.minecraft.util.registry.Registry;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import reborncore.api.blockentity.IUpgrade;
@ -397,7 +398,7 @@ public class TRContent {
}
}
public static final Tag.Identified<Item> ORES_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "ores"));
public static final TagKey<Item> ORES_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "ores"));
private final static Map<Ores, Ores> deepslateMap = new HashMap<>();
@ -437,7 +438,7 @@ public class TRContent {
public final String name;
public final Block block;
public final OreDistribution distribution;
private final Tag.Identified<Item> tag;
private final TagKey<Item> tag;
Ores(OreDistribution distribution, UniformIntProvider experienceDroppedFallback) {
name = this.toString().toLowerCase(Locale.ROOT);
@ -449,7 +450,7 @@ public class TRContent {
distribution != null ? distribution.experienceDropped : experienceDroppedFallback
);
InitUtils.setup(block, name + "_ore");
tag = TagFactory.ITEM.create(new Identifier("c",
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c",
(name.startsWith("deepslate_") ? name.substring(name.indexOf('_')+1): name) + "_ores"));
this.distribution = distribution;
}
@ -470,7 +471,7 @@ public class TRContent {
}
@Override
public Tag.Identified<Item> asTag() {
public TagKey<Item> asTag() {
return tag;
}
@ -495,7 +496,7 @@ public class TRContent {
*/
public static final String CHROME_TAG_NAME_BASE = "chromium";
public static final Tag.Identified<Item> STORAGE_BLOCK_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "storage_blocks"));
public static final TagKey<Item> STORAGE_BLOCK_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "storage_blocks"));
public enum StorageBlocks implements ItemConvertible, TagConvertible<Item> {
ADVANCED_ALLOY(5f, 6f),
@ -536,13 +537,13 @@ public class TRContent {
private final StairsBlock stairsBlock;
private final SlabBlock slabBlock;
private final WallBlock wallBlock;
private final Tag.Identified<Item> tag;
private final TagKey<Item> tag;
StorageBlocks(boolean isHot, float hardness, float resistance, String tagNameBase) {
name = this.toString().toLowerCase(Locale.ROOT);
block = new BlockStorage(isHot, hardness, resistance);
InitUtils.setup(block, name + "_storage_block");
tag = TagFactory.ITEM.create(new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_blocks"));
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_blocks"));
stairsBlock = new TechRebornStairsBlock(block.getDefaultState(), FabricBlockSettings.copyOf(block));
InitUtils.setup(stairsBlock, name + "_storage_block_stairs");
@ -572,7 +573,7 @@ public class TRContent {
}
@Override
public Tag.Identified<Item> asTag() {
public TagKey<Item> asTag() {
return tag;
}
@ -718,7 +719,7 @@ public class TRContent {
}
}
public static final Tag.Identified<Item> DUSTS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "dusts"));
public static final TagKey<Item> DUSTS_TAG = TagKey.of(Registry.ITEM_KEY, 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(CHROME_TAG_NAME_BASE),
@ -729,13 +730,13 @@ public class TRContent {
private final String name;
private final Item item;
private final Tag.Identified<Item> tag;
private final TagKey<Item> tag;
Dusts(String tagNameBase) {
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", Objects.requireNonNullElse(tagNameBase, name) + "_dusts"));
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_dusts"));
}
Dusts() {
@ -756,12 +757,12 @@ public class TRContent {
}
@Override
public Tag.Identified<Item> asTag() {
public TagKey<Item> asTag() {
return tag;
}
}
public static final Tag.Identified<Item> RAW_METALS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "raw_metals"));
public static final TagKey<Item> RAW_METALS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "raw_metals"));
public enum RawMetals implements ItemConvertible, TagConvertible<Item> {
IRIDIUM, LEAD, SILVER, TIN, TUNGSTEN;
@ -769,7 +770,7 @@ public class TRContent {
private final String name;
private final Item item;
private final ItemConvertible storageBlock;
private final Tag.Identified<Item> tag;
private final TagKey<Item> tag;
RawMetals() {
name = this.toString().toLowerCase(Locale.ROOT);
@ -783,7 +784,7 @@ public class TRContent {
}
storageBlock = blockVariant;
InitUtils.setup(item, "raw_" + name);
tag = TagFactory.ITEM.create(new Identifier("c", "raw_" + name + "_ores"));
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", "raw_" + name + "_ores"));
}
@Override
@ -792,7 +793,7 @@ public class TRContent {
}
@Override
public Tag.Identified<Item> asTag() {
public TagKey<Item> asTag() {
return tag;
}
@ -813,7 +814,7 @@ public class TRContent {
}
}
public static final Tag.Identified<Item> SMALL_DUSTS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "small_dusts"));
public static final TagKey<Item> SMALL_DUSTS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "small_dusts"));
public enum SmallDusts implements ItemConvertible, TagConvertible<Item> {
ALMANDINE, ANDESITE, ANDRADITE, ASHES, BASALT, BAUXITE, CALCITE, CHARCOAL, CHROME(CHROME_TAG_NAME_BASE),
@ -826,7 +827,7 @@ public class TRContent {
private final String name;
private final Item item;
private final ItemConvertible dust;
private final Tag.Identified<Item> tag;
private final TagKey<Item> tag;
SmallDusts(String tagNameBase, ItemConvertible dustVariant) {
name = this.toString().toLowerCase(Locale.ROOT);
@ -840,7 +841,7 @@ public class TRContent {
}
dust = dustVariant;
InitUtils.setup(item, name + "_small_dust");
tag = TagFactory.ITEM.create(new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_small_dusts"));
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_small_dusts"));
}
SmallDusts(String tagNameBase) {
@ -869,7 +870,7 @@ public class TRContent {
}
@Override
public Tag.Identified<Item> asTag() {
public TagKey<Item> asTag() {
return tag;
}
@ -893,7 +894,7 @@ public class TRContent {
}
}
public static final Tag.Identified<Item> GEMS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "gems"));
public static final TagKey<Item> GEMS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "gems"));
public enum Gems implements ItemConvertible, TagConvertible<Item> {
PERIDOT, RED_GARNET, RUBY("rubies"), SAPPHIRE("sapphires"), YELLOW_GARNET;
@ -901,7 +902,7 @@ public class TRContent {
private final String name;
private final Item item;
private final ItemConvertible storageBlock;
private final Tag.Identified<Item> tag;
private final TagKey<Item> tag;
Gems(String tagPlural) {
name = this.toString().toLowerCase(Locale.ROOT);
@ -915,7 +916,7 @@ public class TRContent {
}
storageBlock = blockVariant;
InitUtils.setup(item, name + "_gem");
tag = TagFactory.ITEM.create(new Identifier("c", tagPlural == null ? name + "_gems" : tagPlural));
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", tagPlural == null ? name + "_gems" : tagPlural));
}
Gems() {
@ -936,7 +937,7 @@ public class TRContent {
}
@Override
public Tag.Identified<Item> asTag() {
public TagKey<Item> asTag() {
return tag;
}
@ -957,7 +958,7 @@ public class TRContent {
}
}
public static final Tag.Identified<Item> INGOTS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "ingots"));
public static final TagKey<Item> INGOTS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "ingots"));
public enum Ingots implements ItemConvertible, TagConvertible<Item> {
ADVANCED_ALLOY, ALUMINUM, BRASS, BRONZE, CHROME(CHROME_TAG_NAME_BASE), ELECTRUM, HOT_TUNGSTENSTEEL, INVAR, IRIDIUM_ALLOY, IRIDIUM,
@ -966,7 +967,7 @@ public class TRContent {
private final String name;
private final Item item;
private final ItemConvertible storageBlock;
private final Tag.Identified<Item> tag;
private final TagKey<Item> tag;
Ingots(String tagNameBase) {
name = this.toString().toLowerCase(Locale.ROOT);
@ -980,7 +981,7 @@ public class TRContent {
}
storageBlock = blockVariant;
InitUtils.setup(item, name + "_ingot");
tag = TagFactory.ITEM.create(new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_ingots"));
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_ingots"));
}
Ingots() {
@ -1001,7 +1002,7 @@ public class TRContent {
}
@Override
public Tag.Identified<Item> asTag() {
public TagKey<Item> asTag() {
return tag;
}
@ -1022,7 +1023,7 @@ public class TRContent {
}
}
public static final Tag.Identified<Item> NUGGETS_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "nuggets"));
public static final TagKey<Item> NUGGETS_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "nuggets"));
public enum Nuggets implements ItemConvertible, TagConvertible<Item> {
ALUMINUM, BRASS, BRONZE, CHROME(CHROME_TAG_NAME_BASE), COPPER(Items.COPPER_INGOT, false), DIAMOND(Items.DIAMOND, true),
@ -1033,7 +1034,7 @@ public class TRContent {
private final Item item;
private final ItemConvertible ingot;
private final boolean ofGem;
private final Tag.Identified<Item> tag;
private final TagKey<Item> tag;
Nuggets(String tagNameBase, ItemConvertible ingotVariant, boolean ofGem) {
name = this.toString().toLowerCase(Locale.ROOT);
@ -1048,7 +1049,7 @@ public class TRContent {
ingot = ingotVariant;
this.ofGem = ofGem;
InitUtils.setup(item, name + "_nugget");
tag = TagFactory.ITEM.create(new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_nuggets"));
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_nuggets"));
}
Nuggets(ItemConvertible ingotVariant, boolean ofGem) {
@ -1077,7 +1078,7 @@ public class TRContent {
}
@Override
public Tag.Identified<Item> asTag() {
public TagKey<Item> asTag() {
return tag;
}
@ -1179,7 +1180,7 @@ public class TRContent {
}
}
public static final Tag.Identified<Item> PLATES_TAG = TagFactory.ITEM.create(new Identifier(TechReborn.MOD_ID, "plates"));
public static final TagKey<Item> PLATES_TAG = TagKey.of(Registry.ITEM_KEY, new Identifier(TechReborn.MOD_ID, "plates"));
public enum Plates implements ItemConvertible, TagConvertible<Item> {
ADVANCED_ALLOY, ALUMINUM, BRASS, BRONZE, CARBON, CHROME(CHROME_TAG_NAME_BASE), COAL, COPPER, DIAMOND, ELECTRUM, EMERALD, GOLD, INVAR,
@ -1189,13 +1190,13 @@ public class TRContent {
private final String name;
private final Item item;
private final Tag.Identified<Item> tag;
private final TagKey<Item> tag;
Plates(String tagNameBase) {
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", Objects.requireNonNullElse(tagNameBase, name) + "_plates"));
tag = TagKey.of(Registry.ITEM_KEY, new Identifier("c", Objects.requireNonNullElse(tagNameBase, name) + "_plates"));
}
Plates() {
@ -1216,7 +1217,7 @@ public class TRContent {
}
@Override
public Tag.Identified<Item> asTag() {
public TagKey<Item> asTag() {
return tag;
}
}

View file

@ -24,16 +24,17 @@
package techreborn.items.tool;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.*;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import reborncore.common.powerSystem.RcEnergyItem;
import reborncore.common.powerSystem.RcEnergyTier;
@ -41,7 +42,8 @@ import reborncore.common.util.ItemUtils;
import techreborn.TechReborn;
import techreborn.utils.InitUtils;
public class DrillItem extends PickaxeItem implements RcEnergyItem, DynamicAttributeTool {
public class DrillItem extends MiningToolItem implements RcEnergyItem {
public static final TagKey<Block> DRILL_MINEABLE = TagKey.of(Registry.BLOCK_KEY, new Identifier(TechReborn.MOD_ID, "mineable/drill"));
public final int maxCharge;
public final int cost;
@ -52,7 +54,7 @@ public class DrillItem extends PickaxeItem implements RcEnergyItem, DynamicAttri
public DrillItem(ToolMaterial material, int energyCapacity, RcEnergyTier tier, int cost, float poweredSpeed, float unpoweredSpeed, MiningLevel miningLevel) {
// combat stats same as for diamond pickaxe. Fix for #2468
super(material, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
super(1, -2.8F, material, DRILL_MINEABLE, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
this.maxCharge = energyCapacity;
this.cost = cost;
this.poweredSpeed = poweredSpeed;
@ -161,13 +163,4 @@ public class DrillItem extends PickaxeItem implements RcEnergyItem, DynamicAttri
public long getEnergyMaxOutput() {
return 0;
}
// DynamicAttributeTool
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.PICKAXES) || tag.equals(FabricToolTags.SHOVELS)) {
return miningLevel;
}
return 0;
}
}

View file

@ -24,31 +24,25 @@
package techreborn.items.tool;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.*;
import net.minecraft.tag.Tag;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.RcEnergyItem;
import reborncore.common.powerSystem.RcEnergyTier;
import reborncore.common.util.ItemUtils;
import techreborn.TechReborn;
import techreborn.init.TRToolMaterials;
import techreborn.utils.InitUtils;
import techreborn.utils.ToolsUtil;
import java.util.Random;
public class JackhammerItem extends PickaxeItem implements RcEnergyItem, DynamicAttributeTool {
public class JackhammerItem extends PickaxeItem implements RcEnergyItem {
public final int maxCharge;
public final RcEnergyTier tier;
public final int cost;
@ -158,13 +152,4 @@ public class JackhammerItem extends PickaxeItem implements RcEnergyItem, Dynamic
public int getItemBarColor(ItemStack stack) {
return ItemUtils.getColorForDurabilityBar(stack);
}
// DynamicAttributeTool
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.PICKAXES)) {
return MiningLevel.IRON.intLevel;
}
return 0;
}
}

View file

@ -32,7 +32,6 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.tag.BlockTags;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
@ -48,7 +47,6 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.TRToolMaterials;
import techreborn.items.tool.ChainsawItem;
import techreborn.utils.MessageIDs;
import techreborn.utils.TagUtils;
import techreborn.utils.ToolsUtil;
import java.util.ArrayList;
@ -75,10 +73,11 @@ public class IndustrialChainsawItem extends ChainsawItem {
BlockPos checkPos = pos.offset(facing);
if (!wood.contains(checkPos) && !leaves.contains(checkPos)) {
BlockState state = world.getBlockState(checkPos);
if (TagUtils.hasTag(state.getBlock(), BlockTags.LOGS)) {
if (state.isIn(BlockTags.LOGS)) {
wood.add(checkPos);
findWood(world, checkPos, wood, leaves);
} else if (TagUtils.hasTag(state.getBlock(), BlockTags.LEAVES)) {
} else if (state.isIn(BlockTags.LEAVES)) {
leaves.add(checkPos);
findWood(world, checkPos, wood, leaves);
}

View file

@ -26,8 +26,7 @@ package techreborn.items.tool.industrial;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.resource.language.I18n;
@ -35,20 +34,21 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.*;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.RcEnergyItem;
import reborncore.common.powerSystem.RcEnergyTier;
import reborncore.common.util.ItemUtils;
import reborncore.common.util.TorchHelper;
import reborncore.common.powerSystem.RcEnergyTier;
import techreborn.TechReborn;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;
@ -58,7 +58,8 @@ import techreborn.utils.InitUtils;
import java.util.List;
public class OmniToolItem extends PickaxeItem implements RcEnergyItem, DynamicAttributeTool {
public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
public static final TagKey<Block> OMNI_TOOL_MINEABLE = TagKey.of(Registry.BLOCK_KEY, new Identifier(TechReborn.MOD_ID, "mineable/omni_tool"));
public final int maxCharge = TechRebornConfig.omniToolCharge;
public int cost = TechRebornConfig.omniToolCost;
@ -67,7 +68,7 @@ public class OmniToolItem extends PickaxeItem implements RcEnergyItem, DynamicAt
// 4M FE max charge with 1k charge rate
public OmniToolItem() {
super(TRToolMaterials.OMNI_TOOL, 3, 1, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
super(3, 1, TRToolMaterials.OMNI_TOOL, OMNI_TOOL_MINEABLE, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
this.miningLevel = MiningLevel.DIAMOND.intLevel;
}
@ -169,13 +170,4 @@ public class OmniToolItem extends PickaxeItem implements RcEnergyItem, DynamicAt
public RcEnergyTier getTier() {
return RcEnergyTier.EXTREME;
}
// DynamicAttributeTool
@Override
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
if (tag.equals(FabricToolTags.PICKAXES) || tag.equals(FabricToolTags.SHOVELS) || tag.equals(FabricToolTags.AXES) || tag.equals(FabricToolTags.SHEARS) || tag.equals(FabricToolTags.SWORDS)) {
return miningLevel;
}
return 0;
}
}

View file

@ -31,10 +31,11 @@ import net.minecraft.structure.rule.RuleTest;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.gen.YOffset;
import net.minecraft.world.gen.decorator.*;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.placementmodifier.*;
import techreborn.init.TRContent;
import java.util.List;
@ -59,7 +60,7 @@ public class OreFeature {
case END -> createSimpleFeatureConfig(new BlockStateMatchRuleTest(Blocks.END_STONE.getDefaultState()));
};
ConfiguredFeature<?, ?> configuredFeature = Feature.ORE.configure(oreFeatureConfig);
ConfiguredFeature<?, ?> configuredFeature = new ConfiguredFeature<>(Feature.ORE, oreFeatureConfig);
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, getId(), configuredFeature);
return configuredFeature;
}
@ -80,7 +81,7 @@ public class OreFeature {
}
private PlacedFeature configureAndRegisterPlacedFeature() {
PlacedFeature placedFeature = configuredFeature.withPlacement(getPlacementModifiers());
PlacedFeature placedFeature = new PlacedFeature(WorldGenerator.getEntry(BuiltinRegistries.CONFIGURED_FEATURE, configuredFeature), getPlacementModifiers());
Registry.register(BuiltinRegistries.PLACED_FEATURE, getId(), placedFeature);
return placedFeature;
}

View file

@ -25,8 +25,9 @@
package techreborn.world;
import net.minecraft.block.sapling.SaplingGenerator;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.TreeFeatureConfig;
import org.jetbrains.annotations.Nullable;
import java.util.Random;
@ -34,7 +35,7 @@ import java.util.Random;
public class RubberSaplingGenerator extends SaplingGenerator {
@Nullable
@Override
protected ConfiguredFeature<TreeFeatureConfig, ?> getTreeFeature(Random random, boolean bl) {
return WorldGenerator.RUBBER_TREE_FEATURE;
protected RegistryEntry<? extends ConfiguredFeature<?, ?>> getTreeFeature(Random random, boolean bees) {
return WorldGenerator.getEntry(BuiltinRegistries.CONFIGURED_FEATURE, WorldGenerator.RUBBER_TREE_FEATURE);
}
}

View file

@ -32,15 +32,16 @@ import net.minecraft.util.math.Direction;
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.BiomePlacementModifier;
import net.minecraft.world.gen.decorator.RarityFilterPlacementModifier;
import net.minecraft.world.gen.decorator.SquarePlacementModifier;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize;
import net.minecraft.world.gen.foliage.BlobFoliagePlacer;
import net.minecraft.world.gen.placementmodifier.BiomePlacementModifier;
import net.minecraft.world.gen.placementmodifier.RarityFilterPlacementModifier;
import net.minecraft.world.gen.placementmodifier.SquarePlacementModifier;
import net.minecraft.world.gen.stateprovider.BlockStateProvider;
import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider;
import net.minecraft.world.gen.trunk.StraightTrunkPlacer;
@ -100,25 +101,29 @@ public class WorldGenerator {
Identifier patchId = new Identifier("techreborn", "rubber_tree_patch");
RUBBER_TREE_FEATURE = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, treeId,
Feature.TREE.configure(rubber().build())
new ConfiguredFeature<>(Feature.TREE, rubber().build())
);
RUBBER_TREE_PLACED_FEATURE = Registry.register(BuiltinRegistries.PLACED_FEATURE, treeId,
RUBBER_TREE_FEATURE.withWouldSurviveFilter(TRContent.RUBBER_SAPLING)
new PlacedFeature(getEntry(BuiltinRegistries.CONFIGURED_FEATURE, RUBBER_TREE_FEATURE), List.of(
PlacedFeatures.wouldSurvive(TRContent.RUBBER_SAPLING)
))
);
RUBBER_TREE_PATCH_FEATURE = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, patchId,
Feature.RANDOM_PATCH.configure(
ConfiguredFeatures.createRandomPatchFeatureConfig(6, RUBBER_TREE_PLACED_FEATURE)
new ConfiguredFeature<>(Feature.RANDOM_PATCH,
ConfiguredFeatures.createRandomPatchFeatureConfig(
6, getEntry(BuiltinRegistries.PLACED_FEATURE, RUBBER_TREE_PLACED_FEATURE)
)
)
);
RUBBER_TREE_PATCH_PLACED_FEATURE = Registry.register(BuiltinRegistries.PLACED_FEATURE, patchId,
RUBBER_TREE_PATCH_FEATURE.withPlacement(
RarityFilterPlacementModifier.of(3),
SquarePlacementModifier.of(),
PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP,
BiomePlacementModifier.of()
)
new PlacedFeature(getEntry(BuiltinRegistries.CONFIGURED_FEATURE, RUBBER_TREE_PATCH_FEATURE), List.of(
RarityFilterPlacementModifier.of(3),
SquarePlacementModifier.of(),
PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP,
BiomePlacementModifier.of())
)
);
}
@ -163,4 +168,8 @@ public class WorldGenerator {
new RubberTreeSpikeDecorator(4, BlockStateProvider.of(TRContent.RUBBER_LEAVES.getDefaultState()))
));
}
public static <T> RegistryEntry<T> getEntry(Registry<T> registry, T value) {
return registry.getEntry(registry.getKey(value).orElseThrow()).orElseThrow();
}
}

View file

@ -3,9 +3,6 @@
"power": 2,
"time": 25,
"ingredients": [
{
"item": "minecraft:air"
}
],
"results": [
{

View file

@ -33,11 +33,12 @@
]
},
"depends": {
"fabricloader": ">=0.12.12",
"fabricloader": ">=0.13.3",
"fabric": ">=0.46.1",
"reborncore": "*",
"team_reborn_energy": ">=2.2.0",
"fabric-biome-api-v1": ">=3.0.0"
"fabric-biome-api-v1": ">=3.0.0",
"minecraft": "~1.18.2-beta.1"
},
"accessWidener": "techreborn.accesswidener",
"authors": [