diff --git a/fabric-biome-api-v1/build.gradle b/fabric-biome-api-v1/build.gradle index b001ee1fa..a15a6c3b5 100644 --- a/fabric-biome-api-v1/build.gradle +++ b/fabric-biome-api-v1/build.gradle @@ -8,5 +8,4 @@ loom { dependencies { testmodImplementation project(path: ':fabric-api-base', configuration: 'namedElements') testmodImplementation project(path: ':fabric-resource-loader-v0', configuration: 'namedElements') - testmodImplementation project(path: ':fabric-tag-extensions-v0', configuration: 'namedElements') } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeModifications.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeModifications.java index 5616a9313..0700cc50d 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeModifications.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeModifications.java @@ -20,7 +20,6 @@ import java.util.function.Predicate; import com.google.common.base.Preconditions; -import net.minecraft.world.gen.feature.PlacedFeature; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; import net.minecraft.util.Identifier; @@ -30,6 +29,7 @@ import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.carver.ConfiguredCarver; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; +import net.minecraft.world.gen.feature.PlacedFeature; /** * Provides an API to modify Biomes after they have been loaded and before they are used in the World. @@ -45,9 +45,9 @@ public final class BiomeModifications { * * @see BiomeSelectors */ - public static void addFeature(Predicate<BiomeSelectionContext> biomeSelector, GenerationStep.Feature step, RegistryKey<PlacedFeature> configuredFeatureKey) { - create(configuredFeatureKey.getValue()).add(ModificationPhase.ADDITIONS, biomeSelector, context -> { - context.getGenerationSettings().addFeature(step, configuredFeatureKey); + public static void addFeature(Predicate<BiomeSelectionContext> biomeSelector, GenerationStep.Feature step, RegistryKey<PlacedFeature> placedFeatureRegistryKey) { + create(placedFeatureRegistryKey.getValue()).add(ModificationPhase.ADDITIONS, biomeSelector, context -> { + context.getGenerationSettings().addFeature(step, placedFeatureRegistryKey); }); } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeSelectionContext.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeSelectionContext.java index 285bb50a1..277bcfee2 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeSelectionContext.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeSelectionContext.java @@ -18,14 +18,15 @@ package net.fabricmc.fabric.api.biome.v1; import java.util.List; import java.util.Optional; -import java.util.function.Supplier; -import net.minecraft.world.dimension.DimensionOptions; -import net.minecraft.world.gen.feature.PlacedFeature; +import net.minecraft.util.registry.RegistryEntry; +import net.minecraft.util.registry.RegistryEntryList; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; +import net.minecraft.world.dimension.DimensionOptions; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; +import net.minecraft.world.gen.feature.PlacedFeature; import net.fabricmc.fabric.impl.biome.modification.BuiltInRegistryKeys; @@ -67,11 +68,11 @@ public interface BiomeSelectionContext { * Returns true if this biome contains a placed feature referencing a configured feature with the given key. */ default boolean hasFeature(RegistryKey<ConfiguredFeature<?, ?>> key) { - List<List<Supplier<PlacedFeature>>> featureSteps = getBiome().getGenerationSettings().getFeatures(); + List<RegistryEntryList<PlacedFeature>> featureSteps = getBiome().getGenerationSettings().getFeatures(); - for (List<Supplier<PlacedFeature>> featureSuppliers : featureSteps) { - for (Supplier<PlacedFeature> featureSupplier : featureSuppliers) { - if (featureSupplier.get().getDecoratedFeatures().anyMatch(cf -> getFeatureKey(cf).orElse(null) == key)) { + for (RegistryEntryList<PlacedFeature> featureSuppliers : featureSteps) { + for (RegistryEntry<PlacedFeature> featureSupplier : featureSuppliers) { + if (featureSupplier.value().getDecoratedFeatures().anyMatch(cf -> getFeatureKey(cf).orElse(null) == key)) { return true; } } @@ -84,11 +85,11 @@ public interface BiomeSelectionContext { * Returns true if this biome contains a placed feature with the given key. */ default boolean hasPlacedFeature(RegistryKey<PlacedFeature> key) { - List<List<Supplier<PlacedFeature>>> featureSteps = getBiome().getGenerationSettings().getFeatures(); + List<RegistryEntryList<PlacedFeature>> featureSteps = getBiome().getGenerationSettings().getFeatures(); - for (List<Supplier<PlacedFeature>> featureSuppliers : featureSteps) { - for (Supplier<PlacedFeature> featureSupplier : featureSuppliers) { - if (getPlacedFeatureKey(featureSupplier.get()).orElse(null) == key) { + for (RegistryEntryList<PlacedFeature> featureSuppliers : featureSteps) { + for (RegistryEntry<PlacedFeature> featureSupplier : featureSuppliers) { + if (getPlacedFeatureKey(featureSupplier.value()).orElse(null) == key) { return true; } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeSelectors.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeSelectors.java index 19d044dbf..0c46e16ff 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeSelectors.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/BiomeSelectors.java @@ -24,9 +24,9 @@ import java.util.function.Predicate; import com.google.common.collect.ImmutableSet; +import net.minecraft.tag.TagKey; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; -import net.minecraft.tag.Tag; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; @@ -98,8 +98,8 @@ public final class BiomeSelectors { * * @see net.fabricmc.fabric.api.tag.TagFactory#BIOME */ - public static Predicate<BiomeSelectionContext> tag(Tag<Biome> tag) { - return context -> tag.contains(context.getBiome()); + public static Predicate<BiomeSelectionContext> tag(TagKey<Biome> tag) { + return context -> BuiltinRegistries.BIOME.containsTag(tag); } /** @@ -177,6 +177,6 @@ public final class BiomeSelectors { Set<Biome.Category> categorySet = EnumSet.noneOf(Biome.Category.class); Collections.addAll(categorySet, categories); - return context -> categorySet.contains(context.getBiome().getCategory()); + return context -> categorySet.contains(context.getBiome().category); } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/TheEndBiomes.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/TheEndBiomes.java index 8396d732c..7070a582a 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/TheEndBiomes.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1/TheEndBiomes.java @@ -103,12 +103,4 @@ public final class TheEndBiomes { public static void addBarrensBiome(RegistryKey<Biome> highlands, RegistryKey<Biome> barrens, double weight) { TheEndBiomeData.addEndBarrensReplacement(highlands, barrens, weight); } - - /** - * Returns true if the given biome can generate in the end, considering the Vanilla end biomes, - * and any biomes added to The End by mods. - */ - public static boolean canGenerateInTheEnd(RegistryKey<Biome> biome) { - return TheEndBiomeData.canGenerateInTheEnd(biome); - } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/NetherBiomeData.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/NetherBiomeData.java index 8078c65f5..b6b0e3ab0 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/NetherBiomeData.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/NetherBiomeData.java @@ -24,6 +24,7 @@ import java.util.Set; import com.google.common.base.Preconditions; import org.jetbrains.annotations.ApiStatus; +import net.minecraft.util.registry.RegistryEntry; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; @@ -59,8 +60,8 @@ public final class NetherBiomeData { if (NETHER_BIOMES.isEmpty()) { MultiNoiseBiomeSource source = MultiNoiseBiomeSource.Preset.NETHER.getBiomeSource(BuiltinRegistries.BIOME); - for (Biome netherBiome : source.getBiomes()) { - BuiltinRegistries.BIOME.getKey(netherBiome).ifPresent(NETHER_BIOMES::add); + for (RegistryEntry<Biome> entry : source.getBiomes().toList()) { + BuiltinRegistries.BIOME.getKey(entry.value()).ifPresent(NETHER_BIOMES::add); } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/TheEndBiomeData.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/TheEndBiomeData.java index f5589983b..1258ec7cd 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/TheEndBiomeData.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/TheEndBiomeData.java @@ -16,119 +16,135 @@ package net.fabricmc.fabric.impl.biome; -import java.util.HashSet; import java.util.IdentityHashMap; import java.util.Map; -import java.util.Set; import com.google.common.base.Preconditions; import org.jetbrains.annotations.ApiStatus; import net.minecraft.util.math.noise.PerlinNoiseSampler; -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.biome.BiomeKeys; import net.minecraft.world.biome.source.TheEndBiomeSource; +import net.minecraft.world.gen.random.AtomicSimpleRandom; +import net.minecraft.world.gen.random.ChunkRandom; /** * Internal data for modding Vanilla's {@link TheEndBiomeSource}. */ @ApiStatus.Internal public final class TheEndBiomeData { - // Cached sets of the biomes that would generate from Vanilla's default biome source without consideration - // for data packs (as those would be distinct biome sources). - private static final Set<RegistryKey<Biome>> THE_END_BIOMES = new HashSet<>(); - - private static final Map<RegistryKey<Biome>, WeightedBiomePicker> END_BIOMES_MAP = new IdentityHashMap<>(); - private static final Map<RegistryKey<Biome>, WeightedBiomePicker> END_MIDLANDS_MAP = new IdentityHashMap<>(); - private static final Map<RegistryKey<Biome>, WeightedBiomePicker> END_BARRENS_MAP = new IdentityHashMap<>(); + private static final Map<RegistryKey<Biome>, WeightedPicker<RegistryKey<Biome>>> END_BIOMES_MAP = new IdentityHashMap<>(); + private static final Map<RegistryKey<Biome>, WeightedPicker<RegistryKey<Biome>>> END_MIDLANDS_MAP = new IdentityHashMap<>(); + private static final Map<RegistryKey<Biome>, WeightedPicker<RegistryKey<Biome>>> END_BARRENS_MAP = new IdentityHashMap<>(); static { - END_BIOMES_MAP.computeIfAbsent(BiomeKeys.THE_END, key -> new WeightedBiomePicker()).addBiome(BiomeKeys.THE_END, 1.0); - END_BIOMES_MAP.computeIfAbsent(BiomeKeys.END_HIGHLANDS, key -> new WeightedBiomePicker()).addBiome(BiomeKeys.END_HIGHLANDS, 1.0); - END_BIOMES_MAP.computeIfAbsent(BiomeKeys.SMALL_END_ISLANDS, key -> new WeightedBiomePicker()).addBiome(BiomeKeys.SMALL_END_ISLANDS, 1.0); + END_BIOMES_MAP.computeIfAbsent(BiomeKeys.THE_END, key -> new WeightedPicker<>()) + .add(BiomeKeys.THE_END, 1.0); + END_BIOMES_MAP.computeIfAbsent(BiomeKeys.END_HIGHLANDS, key -> new WeightedPicker<>()) + .add(BiomeKeys.END_HIGHLANDS, 1.0); + END_BIOMES_MAP.computeIfAbsent(BiomeKeys.SMALL_END_ISLANDS, key -> new WeightedPicker<>()) + .add(BiomeKeys.SMALL_END_ISLANDS, 1.0); - END_MIDLANDS_MAP.computeIfAbsent(BiomeKeys.END_HIGHLANDS, key -> new WeightedBiomePicker()).addBiome(BiomeKeys.END_MIDLANDS, 1.0); - END_BARRENS_MAP.computeIfAbsent(BiomeKeys.END_HIGHLANDS, key -> new WeightedBiomePicker()).addBiome(BiomeKeys.END_BARRENS, 1.0); + END_MIDLANDS_MAP.computeIfAbsent(BiomeKeys.END_HIGHLANDS, key -> new WeightedPicker<>()) + .add(BiomeKeys.END_MIDLANDS, 1.0); + END_BARRENS_MAP.computeIfAbsent(BiomeKeys.END_HIGHLANDS, key -> new WeightedPicker<>()) + .add(BiomeKeys.END_BARRENS, 1.0); } private TheEndBiomeData() { } public static void addEndBiomeReplacement(RegistryKey<Biome> replaced, RegistryKey<Biome> variant, double weight) { - Preconditions.checkNotNull(replaced, "replaced biome is null"); - Preconditions.checkNotNull(variant, "variant biome is null"); + Preconditions.checkNotNull(replaced, "replaced entry is null"); + Preconditions.checkNotNull(variant, "variant entry is null"); Preconditions.checkArgument(weight > 0.0, "Weight is less than or equal to 0.0 (got %s)", weight); - END_BIOMES_MAP.computeIfAbsent(replaced, key -> new WeightedBiomePicker()).addBiome(variant, weight); - clearBiomeSourceCache(); + END_BIOMES_MAP.computeIfAbsent(replaced, key -> new WeightedPicker<>()).add(variant, weight); } public static void addEndMidlandsReplacement(RegistryKey<Biome> highlands, RegistryKey<Biome> midlands, double weight) { - Preconditions.checkNotNull(highlands, "highlands biome is null"); - Preconditions.checkNotNull(midlands, "midlands biome is null"); + Preconditions.checkNotNull(highlands, "highlands entry is null"); + Preconditions.checkNotNull(midlands, "midlands entry is null"); Preconditions.checkArgument(weight > 0.0, "Weight is less than or equal to 0.0 (got %s)", weight); - END_MIDLANDS_MAP.computeIfAbsent(highlands, key -> new WeightedBiomePicker()).addBiome(midlands, weight); - clearBiomeSourceCache(); + END_MIDLANDS_MAP.computeIfAbsent(highlands, key -> new WeightedPicker<>()).add(midlands, weight); } public static void addEndBarrensReplacement(RegistryKey<Biome> highlands, RegistryKey<Biome> barrens, double weight) { - Preconditions.checkNotNull(highlands, "highlands biome is null"); - Preconditions.checkNotNull(barrens, "midlands biome is null"); + Preconditions.checkNotNull(highlands, "highlands entry is null"); + Preconditions.checkNotNull(barrens, "midlands entry is null"); Preconditions.checkArgument(weight > 0.0, "Weight is less than or equal to 0.0 (got %s)", weight); - END_BARRENS_MAP.computeIfAbsent(highlands, key -> new WeightedBiomePicker()).addBiome(barrens, weight); - clearBiomeSourceCache(); + END_BARRENS_MAP.computeIfAbsent(highlands, key -> new WeightedPicker<>()).add(barrens, weight); } - public static Map<RegistryKey<Biome>, WeightedBiomePicker> getEndBiomesMap() { - return END_BIOMES_MAP; + public static Overrides createOverrides(Registry<Biome> biomeRegistry, long seed) { + return new Overrides(biomeRegistry, seed); } - public static Map<RegistryKey<Biome>, WeightedBiomePicker> getEndMidlandsMap() { - return END_MIDLANDS_MAP; - } + /** + * An instance of this class is attached to each {@link TheEndBiomeSource}. + */ + public static class Overrides { + private final PerlinNoiseSampler sampler; - public static Map<RegistryKey<Biome>, WeightedBiomePicker> getEndBarrensMap() { - return END_BARRENS_MAP; - } + // Vanilla entries to compare against + private final RegistryEntry<Biome> endMidlands; + private final RegistryEntry<Biome> endBarrens; + private final RegistryEntry<Biome> endHighlands; - public static boolean canGenerateInTheEnd(RegistryKey<Biome> biome) { - if (THE_END_BIOMES.isEmpty()) { - for (Biome endBiome : new TheEndBiomeSource(BuiltinRegistries.BIOME, 0).getBiomes()) { - BuiltinRegistries.BIOME.getKey(endBiome).ifPresent(THE_END_BIOMES::add); - } + // Maps where the keys have been resolved to actual entries + private final Map<RegistryEntry<Biome>, WeightedPicker<RegistryEntry<Biome>>> endBiomesMap; + private final Map<RegistryEntry<Biome>, WeightedPicker<RegistryEntry<Biome>>> endMidlandsMap; + private final Map<RegistryEntry<Biome>, WeightedPicker<RegistryEntry<Biome>>> endBarrensMap; + + public Overrides(Registry<Biome> biomeRegistry, long seed) { + this.sampler = new PerlinNoiseSampler(new ChunkRandom(new AtomicSimpleRandom(seed))); + this.endMidlands = biomeRegistry.entryOf(BiomeKeys.END_MIDLANDS); + this.endBarrens = biomeRegistry.entryOf(BiomeKeys.END_BARRENS); + this.endHighlands = biomeRegistry.entryOf(BiomeKeys.END_HIGHLANDS); + + this.endBiomesMap = resolveOverrides(biomeRegistry, END_BIOMES_MAP); + this.endMidlandsMap = resolveOverrides(biomeRegistry, END_MIDLANDS_MAP); + this.endBarrensMap = resolveOverrides(biomeRegistry, END_BARRENS_MAP); } - return THE_END_BIOMES.contains(biome); - } + // Resolves all RegistryKey instances to RegistryEntries + private Map<RegistryEntry<Biome>, WeightedPicker<RegistryEntry<Biome>>> resolveOverrides(Registry<Biome> biomeRegistry, Map<RegistryKey<Biome>, WeightedPicker<RegistryKey<Biome>>> overrides) { + var result = new IdentityHashMap<RegistryEntry<Biome>, WeightedPicker<RegistryEntry<Biome>>>(overrides.size()); - private static void clearBiomeSourceCache() { - THE_END_BIOMES.clear(); // Clear cached biome source data - } + for (var entry : overrides.entrySet()) { + result.put(biomeRegistry.entryOf(entry.getKey()), entry.getValue().map(biomeRegistry::entryOf)); + } - public static RegistryKey<Biome> pickEndBiome(int biomeX, int biomeY, int biomeZ, PerlinNoiseSampler sampler, RegistryKey<Biome> vanillaKey) { - RegistryKey<Biome> replacementKey; + return result; + } - // The x and z of the biome are divided by 64 to ensure custom biomes are large enough; going larger than this] - // seems to make custom biomes too hard to find. - if (vanillaKey == BiomeKeys.END_MIDLANDS || vanillaKey == BiomeKeys.END_BARRENS) { - // Since the highlands picker is statically populated by InternalBiomeData, picker will never be null. - WeightedBiomePicker highlandsPicker = TheEndBiomeData.getEndBiomesMap().get(BiomeKeys.END_HIGHLANDS); - RegistryKey<Biome> highlandsKey = highlandsPicker.pickFromNoise(sampler, biomeX / 64.0, 0, biomeZ / 64.0); + public RegistryEntry<Biome> pick(int x, int y, int z, RegistryEntry<Biome> vanillaBiome) { + RegistryEntry<Biome> replacementKey; - if (vanillaKey == BiomeKeys.END_MIDLANDS) { - WeightedBiomePicker midlandsPicker = TheEndBiomeData.getEndMidlandsMap().get(highlandsKey); - replacementKey = (midlandsPicker == null) ? vanillaKey : midlandsPicker.pickFromNoise(sampler, biomeX / 64.0, 0, biomeZ / 64.0); + // The x and z of the entry are divided by 64 to ensure custom biomes are large enough; going larger than this] + // seems to make custom biomes too hard to find. + if (vanillaBiome == endMidlands || vanillaBiome == endBarrens) { + // Since the highlands picker is statically populated by InternalBiomeData, picker will never be null. + var highlandsPicker = endBiomesMap.get(endHighlands); + RegistryEntry<Biome> highlandsKey = highlandsPicker.pickFromNoise(sampler, x / 64.0, 0, z / 64.0); + + if (vanillaBiome == endMidlands) { + var midlandsPicker = endMidlandsMap.get(highlandsKey); + replacementKey = (midlandsPicker == null) ? vanillaBiome : midlandsPicker.pickFromNoise(sampler, x / 64.0, 0, z / 64.0); + } else { + var barrensPicker = endBarrensMap.get(highlandsKey); + replacementKey = (barrensPicker == null) ? vanillaBiome : barrensPicker.pickFromNoise(sampler, x / 64.0, 0, z / 64.0); + } } else { - WeightedBiomePicker barrensPicker = TheEndBiomeData.getEndBarrensMap().get(highlandsKey); - replacementKey = (barrensPicker == null) ? vanillaKey : barrensPicker.pickFromNoise(sampler, biomeX / 64.0, 0, biomeZ / 64.0); + // Since the main island and small islands pickers are statically populated by InternalBiomeData, picker will never be null. + var picker = endBiomesMap.get(vanillaBiome); + replacementKey = picker.pickFromNoise(sampler, x / 64.0, 0, z / 64.0); } - } else { - // Since the main island and small islands pickers are statically populated by InternalBiomeData, picker will never be null. - WeightedBiomePicker picker = TheEndBiomeData.getEndBiomesMap().get(vanillaKey); - replacementKey = picker.pickFromNoise(sampler, biomeX / 64.0, 0, biomeZ / 64.0); - } - return replacementKey; + return replacementKey; + } } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/WeightedBiomeEntry.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/WeightedBiomeEntry.java deleted file mode 100644 index b5e0f7f82..000000000 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/WeightedBiomeEntry.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.biome; - -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.biome.Biome; - -/** - * Represents a modded biome in The End, and its corresponding weight. - * - * @param biome the biome - * @param weight how often a biome will be chosen - * @param upperWeightBound the upper weight bound within the context of the other entries, used for the binary search - */ -record WeightedBiomeEntry(RegistryKey<Biome> biome, double weight, double upperWeightBound) { -} diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/WeightedBiomePicker.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/WeightedPicker.java similarity index 52% rename from fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/WeightedBiomePicker.java rename to fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/WeightedPicker.java index aa47f2d1e..f5201f3f4 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/WeightedBiomePicker.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/WeightedPicker.java @@ -18,39 +18,54 @@ package net.fabricmc.fabric.impl.biome; import java.util.ArrayList; import java.util.List; +import java.util.function.Function; import com.google.common.base.Preconditions; import net.minecraft.util.math.noise.PerlinNoiseSampler; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.biome.Biome; /** - * Picks biomes with arbitrary double weights using a binary search. + * Picks entries with arbitrary double weights using a binary search. */ -public final class WeightedBiomePicker { +public final class WeightedPicker<T> { private double currentTotal; - private final List<WeightedBiomeEntry> entries; + private final List<WeightedEntry<T>> entries; - WeightedBiomePicker() { - currentTotal = 0; - entries = new ArrayList<>(); + WeightedPicker() { + this(0, new ArrayList<>()); } - void addBiome(final RegistryKey<Biome> biome, final double weight) { + private WeightedPicker(double currentTotal, List<WeightedEntry<T>> entries) { + this.currentTotal = currentTotal; + this.entries = entries; + } + + void add(T biome, final double weight) { currentTotal += weight; - entries.add(new WeightedBiomeEntry(biome, weight, currentTotal)); + entries.add(new WeightedEntry<>(biome, weight, currentTotal)); } double getCurrentWeightTotal() { return currentTotal; } - public RegistryKey<Biome> pickFromNoise(PerlinNoiseSampler sampler, double x, double y, double z) { + public T pickFromNoise(PerlinNoiseSampler sampler, double x, double y, double z) { double target = Math.abs(sampler.sample(x, y, z)) * getCurrentWeightTotal(); - return search(target).biome(); + return search(target).entry(); + } + + /** + * Applies a mapping function to each entry and returns a picker with otherwise equivalent settings. + */ + <U> WeightedPicker<U> map(Function<T, U> mapper) { + return new WeightedPicker<U>( + currentTotal, + entries.stream() + .map(e -> new WeightedEntry<>(mapper.apply(e.entry), e.weight, e.upperWeightBound)) + .toList() + ); } /** @@ -59,10 +74,10 @@ public final class WeightedBiomePicker { * @param target The target value, must satisfy the constraint 0 <= target <= currentTotal * @return The result of the search */ - WeightedBiomeEntry search(final double target) { + WeightedEntry<T> search(final double target) { // Sanity checks, fail fast if stuff is going wrong. - Preconditions.checkArgument(target <= currentTotal, "The provided target value for biome selection must be less than or equal to the weight total"); - Preconditions.checkArgument(target >= 0, "The provided target value for biome selection cannot be negative"); + Preconditions.checkArgument(target <= currentTotal, "The provided target value for entry selection must be less than or equal to the weight total"); + Preconditions.checkArgument(target >= 0, "The provided target value for entry selection cannot be negative"); int low = 0; int high = entries.size() - 1; @@ -79,4 +94,14 @@ public final class WeightedBiomePicker { return entries.get(low); } + + /** + * Represents a modded entry in a list, and its corresponding weight. + * + * @param entry the entry + * @param weight how often an entry will be chosen + * @param upperWeightBound the upper weight bound within the context of the other entries, used for the binary search + */ + record WeightedEntry<T>(T entry, double weight, double upperWeightBound) { + } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationContextImpl.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationContextImpl.java index 8b45e2ae2..e63d18695 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationContextImpl.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationContextImpl.java @@ -17,23 +17,24 @@ package net.fabricmc.fabric.impl.biome.modification; import java.util.ArrayList; +import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.function.BiPredicate; -import java.util.function.Supplier; +import java.util.stream.Collectors; +import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import net.minecraft.world.gen.feature.PlacedFeature; +import net.minecraft.util.registry.RegistryEntry; +import net.minecraft.util.registry.RegistryEntryList; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; import net.minecraft.sound.BiomeAdditionsSound; @@ -51,9 +52,9 @@ import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.carver.ConfiguredCarver; -import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.PlacedFeature; import net.minecraft.world.gen.feature.StructureFeature; import net.fabricmc.fabric.api.biome.v1.BiomeModificationContext; @@ -205,6 +206,8 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { private final Registry<ConfiguredStructureFeature<?, ?>> structures = registries.get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY); private final GenerationSettings generationSettings = biome.getGenerationSettings(); + private boolean rebuildFlowerFeatures; + /** * Unfreeze the immutable lists found in the generation settings, and make sure they're filled up to every * possible step if they're dense lists. @@ -212,42 +215,19 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { GenerationSettingsContextImpl() { unfreezeCarvers(); unfreezeFeatures(); - unfreezeFlowerFeatures(); + + rebuildFlowerFeatures = false; } private void unfreezeCarvers() { - Map<GenerationStep.Carver, List<Supplier<ConfiguredCarver<?>>>> carversByStep = new EnumMap<>(GenerationStep.Carver.class); + Map<GenerationStep.Carver, RegistryEntryList<ConfiguredCarver<?>>> carversByStep = new EnumMap<>(GenerationStep.Carver.class); carversByStep.putAll(generationSettings.carvers); - for (GenerationStep.Carver step : GenerationStep.Carver.values()) { - List<Supplier<ConfiguredCarver<?>>> carvers = carversByStep.get(step); - - if (carvers == null) { - carvers = new ArrayList<>(); - } else { - carvers = new ArrayList<>(carvers); - } - - carversByStep.put(step, carvers); - } - generationSettings.carvers = carversByStep; } private void unfreezeFeatures() { - List<List<Supplier<PlacedFeature>>> features = generationSettings.features; - features = new ArrayList<>(features); - - for (int i = 0; i < features.size(); i++) { - features.set(i, new ArrayList<>(features.get(i))); - } - - generationSettings.features = features; - generationSettings.allowedFeatures = new HashSet<>(generationSettings.allowedFeatures); - } - - private void unfreezeFlowerFeatures() { - generationSettings.flowerFeatures = new ArrayList<>(generationSettings.flowerFeatures); + generationSettings.features = new ArrayList<>(generationSettings.features); } /** @@ -256,32 +236,31 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { public void freeze() { freezeCarvers(); freezeFeatures(); - freezeFlowerFeatures(); + + if (rebuildFlowerFeatures) { + rebuildFlowerFeatures(); + } } private void freezeCarvers() { - Map<GenerationStep.Carver, List<Supplier<ConfiguredCarver<?>>>> carversByStep = generationSettings.carvers; - - for (GenerationStep.Carver step : GenerationStep.Carver.values()) { - carversByStep.put(step, ImmutableList.copyOf(carversByStep.get(step))); - } - - generationSettings.carvers = ImmutableMap.copyOf(carversByStep); + generationSettings.carvers = ImmutableMap.copyOf(generationSettings.carvers); } private void freezeFeatures() { - List<List<Supplier<PlacedFeature>>> featureSteps = generationSettings.features; - - for (int i = 0; i < featureSteps.size(); i++) { - featureSteps.set(i, ImmutableList.copyOf(featureSteps.get(i))); - } - - generationSettings.features = ImmutableList.copyOf(featureSteps); - generationSettings.allowedFeatures = (Set.copyOf(generationSettings.allowedFeatures)); + generationSettings.features = ImmutableList.copyOf(generationSettings.features); + // Replace the supplier to force a rebuild next time its called. + generationSettings.allowedFeatures = Suppliers.memoize(() -> { + return generationSettings.features.stream().flatMap(RegistryEntryList::stream).map(RegistryEntry::value).collect(Collectors.toSet()); + }); } - private void freezeFlowerFeatures() { - generationSettings.flowerFeatures = ImmutableList.copyOf(generationSettings.flowerFeatures); + private void rebuildFlowerFeatures() { + // Replace the supplier to force a rebuild next time its called. + generationSettings.flowerFeatures = Suppliers.memoize(() -> { + return generationSettings.features.stream().flatMap(RegistryEntryList::stream).map(RegistryEntry::value).flatMap(PlacedFeature::getDecoratedFeatures).filter((configuredFeature) -> { + return configuredFeature.feature() == Feature.FLOWER; + }).collect(ImmutableList.toImmutableList()); + }); } @Override @@ -289,16 +268,19 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { PlacedFeature configuredFeature = features.getOrThrow(placedFeatureKey); int stepIndex = step.ordinal(); - List<List<Supplier<PlacedFeature>>> featureSteps = generationSettings.features; + List<RegistryEntryList<PlacedFeature>> featureSteps = generationSettings.features; if (stepIndex >= featureSteps.size()) { return false; // The step was not populated with any features yet } - List<Supplier<PlacedFeature>> featuresInStep = featureSteps.get(stepIndex); + RegistryEntryList<PlacedFeature> featuresInStep = featureSteps.get(stepIndex); + List<RegistryEntry<PlacedFeature>> features = new ArrayList<>(featuresInStep.stream().toList()); + + if (features.removeIf(feature -> feature.value() == configuredFeature)) { + featureSteps.set(stepIndex, RegistryEntryList.of(features)); + rebuildFlowerFeatures = true; - if (featuresInStep.removeIf(supplier -> supplier.get() == configuredFeature)) { - rebuildFlowerFeatures(); return true; } @@ -306,36 +288,38 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { } @Override - public void addFeature(GenerationStep.Feature step, RegistryKey<PlacedFeature> placedFeatureKey) { - // We do not need to delay evaluation of this since the registries are already fully built - PlacedFeature placedFeature = features.getOrThrow(placedFeatureKey); - - List<List<Supplier<PlacedFeature>>> featureSteps = generationSettings.features; + public void addFeature(GenerationStep.Feature step, RegistryKey<PlacedFeature> entry) { + List<RegistryEntryList<PlacedFeature>> featureSteps = generationSettings.features; int index = step.ordinal(); // Add new empty lists for the generation steps that have no features yet while (index >= featureSteps.size()) { - featureSteps.add(new ArrayList<>()); + featureSteps.add(RegistryEntryList.of(Collections.emptyList())); } - featureSteps.get(index).add(() -> placedFeature); - generationSettings.allowedFeatures.add(placedFeature); + featureSteps.set(index, plus(featureSteps.get(index), features.getEntry(entry).orElseThrow())); // Ensure the list of flower features is up to date - rebuildFlowerFeatures(); + rebuildFlowerFeatures = true; } @Override - public void addCarver(GenerationStep.Carver step, RegistryKey<ConfiguredCarver<?>> carverKey) { + public void addCarver(GenerationStep.Carver step, RegistryKey<ConfiguredCarver<?>> entry) { // We do not need to delay evaluation of this since the registries are already fully built - ConfiguredCarver<?> carver = carvers.getOrThrow(carverKey); - generationSettings.carvers.get(step).add(() -> carver); + generationSettings.carvers.put(step, plus(generationSettings.carvers.get(step), carvers.getEntry(entry).orElseThrow())); } @Override public boolean removeCarver(GenerationStep.Carver step, RegistryKey<ConfiguredCarver<?>> configuredCarverKey) { ConfiguredCarver<?> carver = carvers.getOrThrow(configuredCarverKey); - return generationSettings.carvers.get(step).removeIf(supplier -> supplier.get() == carver); + List<RegistryEntry<ConfiguredCarver<?>>> genCarvers = new ArrayList<>(generationSettings.carvers.get(step).stream().toList()); + + if (genCarvers.removeIf(entry -> entry.value() == carver)) { + generationSettings.carvers.put(step, RegistryEntryList.of(genCarvers)); + return true; + } + + return false; } @Override @@ -357,20 +341,10 @@ public class BiomeModificationContextImpl implements BiomeModificationContext { return BiomeStructureStartsImpl.removeStructureStarts(registries, structure, biomeKey); } - /** - * See the constructor of {@link GenerationSettings} for reference. - */ - private void rebuildFlowerFeatures() { - List<ConfiguredFeature<?, ?>> flowerFeatures = generationSettings.flowerFeatures; - flowerFeatures.clear(); - - for (List<Supplier<PlacedFeature>> features : generationSettings.features) { - for (Supplier<PlacedFeature> supplier : features) { - supplier.get().getDecoratedFeatures() - .filter(configuredFeature -> configuredFeature.feature == Feature.FLOWER) - .forEachOrdered(flowerFeatures::add); - } - } + private <T> RegistryEntryList<T> plus(RegistryEntryList<T> values, RegistryEntry<T> entry) { + List<RegistryEntry<T>> list = new ArrayList<>(values.stream().toList()); + list.add(entry); + return RegistryEntryList.of(list); } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationImpl.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationImpl.java index f4df12950..7801d0fe7 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationImpl.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeModificationImpl.java @@ -26,11 +26,13 @@ import java.util.function.Consumer; import java.util.function.Predicate; import com.google.common.base.Stopwatch; -import org.slf4j.LoggerFactory; -import org.slf4j.Logger; +import com.google.common.base.Suppliers; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.TestOnly; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import net.minecraft.util.registry.RegistryEntry; import net.minecraft.util.Identifier; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.Registry; @@ -105,13 +107,13 @@ public class BiomeModificationImpl { } @SuppressWarnings("ConstantConditions") - public void finalizeWorldGen(DynamicRegistryManager.Impl impl, LevelProperties levelProperties) { + public void finalizeWorldGen(DynamicRegistryManager impl, LevelProperties levelProperties) { Stopwatch sw = Stopwatch.createStarted(); // Now that we apply biome modifications inside the MinecraftServer constructor, we should only ever do // this once for a dynamic registry manager. Marking the dynamic registry manager as modified ensures a crash // if the precondition is violated. - BiomeModificationMarker modificationTracker = (BiomeModificationMarker) (Object) impl; + BiomeModificationMarker modificationTracker = (BiomeModificationMarker) impl; modificationTracker.fabric_markModified(); Registry<Biome> biomes = impl.get(Registry.BIOME_KEY); @@ -166,7 +168,11 @@ public class BiomeModificationImpl { // The Biome source has a total ordering of feature generation that might have changed // by us adding or removing features from biomes. BiomeSource biomeSource = dimension.getChunkGenerator().getBiomeSource(); - biomeSource.field_34469 = biomeSource.method_39525(new ArrayList<>(biomeSource.getBiomes()), true); + + // Replace the Supplier to force it to rebuild on next call + biomeSource.field_34469 = Suppliers.memoize(() -> { + return biomeSource.method_39525(biomeSource.biomes.stream().map(RegistryEntry::value).toList(), true); + }); } LOGGER.info("Applied {} biome modifications to {} of {} new biomes in {}", modifiersApplied, biomesChanged, diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeSelectionContextImpl.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeSelectionContextImpl.java index 4e45e005c..09046559e 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeSelectionContextImpl.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeSelectionContextImpl.java @@ -25,7 +25,7 @@ import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; import net.minecraft.world.dimension.DimensionOptions; -import net.minecraft.world.gen.chunk.StructuresConfig; +import net.minecraft.world.gen.chunk.placement.StructuresConfig; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; import net.minecraft.world.gen.feature.PlacedFeature; @@ -82,7 +82,7 @@ public class BiomeSelectionContextImpl implements BiomeSelectionContext { for (DimensionOptions dimension : levelProperties.getGeneratorOptions().getDimensions()) { StructuresConfig structuresConfig = dimension.getChunkGenerator().getStructuresConfig(); - if (structuresConfig.getConfiguredStructureFeature(instance.feature).get(instance).contains(getBiomeKey())) { + if (structuresConfig.getConfiguredStructureFeature(instance.feature).get(key).contains(getBiomeKey())) { return true; } } @@ -104,6 +104,6 @@ public class BiomeSelectionContextImpl implements BiomeSelectionContext { return false; } - return dimension.getChunkGenerator().getBiomeSource().getBiomes().contains(biome); + return dimension.getChunkGenerator().getBiomeSource().getBiomes().anyMatch(entry -> entry.value() == biome); } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeStructureStartsImpl.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeStructureStartsImpl.java index 32a173062..1c0851513 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeStructureStartsImpl.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BiomeStructureStartsImpl.java @@ -50,18 +50,15 @@ public final class BiomeStructureStartsImpl { RegistryKey<Biome> biome ) { changeStructureStarts(registries, structureMap -> { - Multimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>> configuredMap = structureMap.computeIfAbsent(configuredStructure.feature, k -> HashMultimap.create()); + Multimap<RegistryKey<ConfiguredStructureFeature<?, ?>>, RegistryKey<Biome>> configuredMap = structureMap.computeIfAbsent(configuredStructure.feature, k -> HashMultimap.create()); // This is tricky, the keys might be either from builtin (Vanilla) or dynamic registries (modded) RegistryKey<ConfiguredStructureFeature<?, ?>> configuredStructureKey = registries.get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).getKey(configuredStructure).orElseThrow(); - ConfiguredStructureFeature<?, ?> mapKey = BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.get(configuredStructureKey); - - if (mapKey == null) { - // This means the configured structure passed in is not a (potentially modified) Vanilla entry, - // but rather a modded one. In this case, this will create a new entry in the map. - mapKey = configuredStructure; - } + RegistryKey<ConfiguredStructureFeature<?, ?>> mapKey = registries.get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).getKey(configuredStructure) + .orElse(configuredStructureKey); + // orElse means the configured structure passed in is not a (potentially modified) Vanilla entry, + // but rather a modded one. In this case, this will create a new entry in the map. configuredMap.put(mapKey, biome); }); } @@ -74,7 +71,7 @@ public final class BiomeStructureStartsImpl { AtomicBoolean result = new AtomicBoolean(false); changeStructureStarts(registries, structureMap -> { - Multimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>> configuredMap = structureMap.get(configuredStructure.feature); + Multimap<RegistryKey<ConfiguredStructureFeature<?, ?>>, RegistryKey<Biome>> configuredMap = structureMap.get(configuredStructure.feature); if (configuredMap == null) { return; @@ -106,7 +103,7 @@ public final class BiomeStructureStartsImpl { AtomicBoolean result = new AtomicBoolean(false); changeStructureStarts(registries, structureMap -> { - Multimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>> configuredMap = structureMap.get(structure); + Multimap<RegistryKey<ConfiguredStructureFeature<?, ?>>, RegistryKey<Biome>> configuredMap = structureMap.get(structure); if (configuredMap == null) { return; @@ -120,11 +117,11 @@ public final class BiomeStructureStartsImpl { return result.get(); } - private static void changeStructureStarts(DynamicRegistryManager registries, Consumer<Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>>>> modifier) { + private static void changeStructureStarts(DynamicRegistryManager registries, Consumer<Map<StructureFeature<?>, Multimap<RegistryKey<ConfiguredStructureFeature<?, ?>>, RegistryKey<Biome>>>> modifier) { Registry<ChunkGeneratorSettings> chunkGenSettingsRegistry = registries.get(Registry.CHUNK_GENERATOR_SETTINGS_KEY); for (Map.Entry<RegistryKey<ChunkGeneratorSettings>, ChunkGeneratorSettings> entry : chunkGenSettingsRegistry.getEntries()) { - Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>>> structureMap = unfreeze(entry.getValue()); + Map<StructureFeature<?>, Multimap<RegistryKey<ConfiguredStructureFeature<?, ?>>, RegistryKey<Biome>>> structureMap = unfreeze(entry.getValue()); modifier.accept(structureMap); @@ -132,18 +129,18 @@ public final class BiomeStructureStartsImpl { } } - private static Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>>> unfreeze(ChunkGeneratorSettings settings) { - ImmutableMap<StructureFeature<?>, ImmutableMultimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>>> frozenMap = settings.getStructuresConfig().configuredStructures; - Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>>> result = new HashMap<>(frozenMap.size()); + private static Map<StructureFeature<?>, Multimap<RegistryKey<ConfiguredStructureFeature<?, ?>>, RegistryKey<Biome>>> unfreeze(ChunkGeneratorSettings settings) { + ImmutableMap<StructureFeature<?>, ImmutableMultimap<RegistryKey<ConfiguredStructureFeature<?, ?>>, RegistryKey<Biome>>> frozenMap = settings.getStructuresConfig().configuredStructures; + Map<StructureFeature<?>, Multimap<RegistryKey<ConfiguredStructureFeature<?, ?>>, RegistryKey<Biome>>> result = new HashMap<>(frozenMap.size()); - for (Map.Entry<StructureFeature<?>, ImmutableMultimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>>> entry : frozenMap.entrySet()) { + for (Map.Entry<StructureFeature<?>, ImmutableMultimap<RegistryKey<ConfiguredStructureFeature<?, ?>>, RegistryKey<Biome>>> entry : frozenMap.entrySet()) { result.put(entry.getKey(), HashMultimap.create(entry.getValue())); } return result; } - private static void freeze(ChunkGeneratorSettings settings, Map<StructureFeature<?>, Multimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>>> structureStarts) { + private static void freeze(ChunkGeneratorSettings settings, Map<StructureFeature<?>, Multimap<RegistryKey<ConfiguredStructureFeature<?, ?>>, RegistryKey<Biome>>> structureStarts) { settings.getStructuresConfig().configuredStructures = structureStarts.entrySet().stream() .collect(ImmutableMap.toImmutableMap( Map.Entry::getKey, diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BuiltInRegistryKeys.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BuiltInRegistryKeys.java index d77924fa5..afe5ad0cc 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BuiltInRegistryKeys.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/impl/biome/modification/BuiltInRegistryKeys.java @@ -18,12 +18,12 @@ package net.fabricmc.fabric.impl.biome.modification; import org.jetbrains.annotations.ApiStatus; -import net.minecraft.world.gen.feature.PlacedFeature; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.gen.carver.ConfiguredCarver; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredStructureFeature; +import net.minecraft.world.gen.feature.PlacedFeature; /** * Utility class for getting the registry keys of built-in worldgen objects and throwing proper exceptions if they diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MixinMultiNoiseBiomeSource.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MixinMultiNoiseBiomeSource.java index f6f5d92ff..47ac08e04 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MixinMultiNoiseBiomeSource.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MixinMultiNoiseBiomeSource.java @@ -18,7 +18,6 @@ package net.fabricmc.fabric.mixin.biome; import java.util.ArrayList; import java.util.List; -import java.util.function.Supplier; import com.mojang.datafixers.util.Pair; import org.spongepowered.asm.mixin.Mixin; @@ -27,6 +26,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.RegistryEntry; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.MultiNoiseBiomeSource; import net.minecraft.world.biome.source.util.MultiNoiseUtil; @@ -40,15 +40,13 @@ import net.fabricmc.fabric.impl.biome.NetherBiomeData; public class MixinMultiNoiseBiomeSource { // NOTE: This is a lambda-function in the NETHER preset field initializer @Inject(method = "method_31088", at = @At("RETURN"), cancellable = true) - private static void appendNetherBiomes(Registry<Biome> registry, CallbackInfoReturnable<MultiNoiseUtil.Entries<Supplier<Biome>>> cri) { - MultiNoiseUtil.Entries<Supplier<Biome>> biomes = cri.getReturnValue(); - List<Pair<MultiNoiseUtil.NoiseHypercube, Supplier<Biome>>> entries = new ArrayList<>(biomes.getEntries()); + private static void appendNetherBiomes(Registry<Biome> registry, CallbackInfoReturnable<MultiNoiseUtil.Entries<RegistryEntry<Biome>>> cri) { + MultiNoiseUtil.Entries<RegistryEntry<Biome>> biomes = cri.getReturnValue(); + List<Pair<MultiNoiseUtil.NoiseHypercube, RegistryEntry<Biome>>> entries = new ArrayList<>(biomes.getEntries()); // add fabric biome noise point data to list && BiomeSource biome list NetherBiomeData.getNetherBiomeNoisePoints().forEach((biomeKey, noisePoint) -> { - Biome biome = registry.getOrThrow(biomeKey); - // NOTE: Even though we have to pass in suppliers, BiomeSource's ctor will resolve them immediately - entries.add(Pair.of(noisePoint, () -> biome)); + entries.add(Pair.of(noisePoint, registry.entryOf(biomeKey))); }); cri.setReturnValue(new MultiNoiseUtil.Entries<>(entries)); diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MixinTheEndBiomeSource.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MixinTheEndBiomeSource.java index ddd5239e8..54d5318be 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MixinTheEndBiomeSource.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/MixinTheEndBiomeSource.java @@ -16,44 +16,33 @@ package net.fabricmc.fabric.mixin.biome; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.util.math.noise.PerlinNoiseSampler; import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; +import net.minecraft.util.registry.RegistryEntry; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.TheEndBiomeSource; import net.minecraft.world.biome.source.util.MultiNoiseUtil; -import net.minecraft.world.gen.random.ChunkRandom; -import net.minecraft.world.gen.random.AtomicSimpleRandom; import net.fabricmc.fabric.impl.biome.TheEndBiomeData; @Mixin(TheEndBiomeSource.class) public class MixinTheEndBiomeSource { - @Shadow - @Final - private Registry<Biome> biomeRegistry; - @Shadow - @Final - private long seed; @Unique - private PerlinNoiseSampler sampler = new PerlinNoiseSampler(new ChunkRandom(new AtomicSimpleRandom(seed))); + private TheEndBiomeData.Overrides overrides; + + @Inject(method = "<init>", at = @At("RETURN")) + private void init(Registry<Biome> biomeRegistry, long seed, CallbackInfo ci) { + overrides = TheEndBiomeData.createOverrides(biomeRegistry, seed); + } @Inject(method = "getBiome", at = @At("RETURN"), cancellable = true) - private void getWeightedEndBiome(int biomeX, int biomeY, int biomeZ, MultiNoiseUtil.MultiNoiseSampler multiNoiseSampler, CallbackInfoReturnable<Biome> cir) { - Biome vanillaBiome = cir.getReturnValue(); - - // Since all vanilla biomes are added to the registry, this will never fail. - RegistryKey<Biome> vanillaKey = biomeRegistry.getKey(vanillaBiome).get(); - RegistryKey<Biome> replacementKey = TheEndBiomeData.pickEndBiome(biomeX, biomeY, biomeZ, sampler, vanillaKey); - - cir.setReturnValue(biomeRegistry.get(replacementKey)); + private void getWeightedEndBiome(int biomeX, int biomeY, int biomeZ, MultiNoiseUtil.MultiNoiseSampler multiNoiseSampler, CallbackInfoReturnable<RegistryEntry<Biome>> cir) { + cir.setReturnValue(overrides.pick(biomeX, biomeY, biomeZ, cir.getReturnValue())); } } diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/DynamicRegistryManagerImplMixin.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/DynamicRegistryManagerImplMixin.java index 7ba074755..5aff7c2ef 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/DynamicRegistryManagerImplMixin.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/DynamicRegistryManagerImplMixin.java @@ -27,7 +27,7 @@ import net.fabricmc.fabric.impl.biome.modification.BiomeModificationMarker; * This Mixin allows us to keep backup copies of biomes for * {@link net.fabricmc.fabric.impl.biome.modification.BiomeModificationImpl} on a per-DynamicRegistryManager basis. */ -@Mixin(DynamicRegistryManager.Impl.class) +@Mixin(DynamicRegistryManager.class_6891.class) public class DynamicRegistryManagerImplMixin implements BiomeModificationMarker { @Unique private boolean modified; diff --git a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/MinecraftServerMixin.java b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/MinecraftServerMixin.java index e22afd8a6..8e469eacc 100644 --- a/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/MinecraftServerMixin.java +++ b/fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/mixin/biome/modification/MinecraftServerMixin.java @@ -30,19 +30,19 @@ import net.minecraft.world.level.LevelProperties; import net.fabricmc.fabric.impl.biome.modification.BiomeModificationImpl; @Mixin(MinecraftServer.class) -public class MinecraftServerMixin { - @Shadow - private DynamicRegistryManager.Impl registryManager; - +public abstract class MinecraftServerMixin { @Shadow private SaveProperties saveProperties; + @Shadow + public abstract DynamicRegistryManager.class_6890 getRegistryManager(); + @Inject(method = "<init>", at = @At(value = "RETURN")) private void finalizeWorldGen(CallbackInfo ci) { if (!(saveProperties instanceof LevelProperties levelProperties)) { throw new RuntimeException("Incompatible SaveProperties passed to MinecraftServer: " + saveProperties); } - BiomeModificationImpl.INSTANCE.finalizeWorldGen(registryManager, levelProperties); + BiomeModificationImpl.INSTANCE.finalizeWorldGen(getRegistryManager(), levelProperties); } } diff --git a/fabric-biome-api-v1/src/main/resources/fabric-biome-api-v1.accesswidener b/fabric-biome-api-v1/src/main/resources/fabric-biome-api-v1.accesswidener index df09cbabe..4c41cebd9 100644 --- a/fabric-biome-api-v1/src/main/resources/fabric-biome-api-v1.accesswidener +++ b/fabric-biome-api-v1/src/main/resources/fabric-biome-api-v1.accesswidener @@ -1,12 +1,13 @@ accessWidener v1 named accessible class net/minecraft/world/biome/Biome$Weather -accessible field net/minecraft/world/gen/chunk/StructuresConfig configuredStructures Lcom/google/common/collect/ImmutableMap; -mutable field net/minecraft/world/gen/chunk/StructuresConfig configuredStructures Lcom/google/common/collect/ImmutableMap; +accessible field net/minecraft/world/gen/chunk/placement/StructuresConfig configuredStructures Lcom/google/common/collect/ImmutableMap; +mutable field net/minecraft/world/gen/chunk/placement/StructuresConfig configuredStructures Lcom/google/common/collect/ImmutableMap; # Rebuilding biome source feature lists accessible method net/minecraft/world/biome/source/BiomeSource method_39525 (Ljava/util/List;Z)Ljava/util/List; -accessible field net/minecraft/world/biome/source/BiomeSource field_34469 Ljava/util/List; -mutable field net/minecraft/world/biome/source/BiomeSource field_34469 Ljava/util/List; +accessible field net/minecraft/world/biome/source/BiomeSource biomes Ljava/util/Set; +accessible field net/minecraft/world/biome/source/BiomeSource field_34469 Ljava/util/function/Supplier; +mutable field net/minecraft/world/biome/source/BiomeSource field_34469 Ljava/util/function/Supplier; # Top-Level Biome Fields Access accessible field net/minecraft/world/biome/Biome weather Lnet/minecraft/world/biome/Biome$Weather; @@ -66,7 +67,7 @@ accessible field net/minecraft/world/biome/GenerationSettings carvers Ljava/util mutable field net/minecraft/world/biome/GenerationSettings carvers Ljava/util/Map; accessible field net/minecraft/world/biome/GenerationSettings features Ljava/util/List; mutable field net/minecraft/world/biome/GenerationSettings features Ljava/util/List; -accessible field net/minecraft/world/biome/GenerationSettings flowerFeatures Ljava/util/List; -mutable field net/minecraft/world/biome/GenerationSettings flowerFeatures Ljava/util/List; -accessible field net/minecraft/world/biome/GenerationSettings allowedFeatures Ljava/util/Set; -mutable field net/minecraft/world/biome/GenerationSettings allowedFeatures Ljava/util/Set; +accessible field net/minecraft/world/biome/GenerationSettings flowerFeatures Ljava/util/function/Supplier; +mutable field net/minecraft/world/biome/GenerationSettings flowerFeatures Ljava/util/function/Supplier; +accessible field net/minecraft/world/biome/GenerationSettings allowedFeatures Ljava/util/function/Supplier; +mutable field net/minecraft/world/biome/GenerationSettings allowedFeatures Ljava/util/function/Supplier; diff --git a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java index 7d2b9bb70..488c87342 100644 --- a/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java +++ b/fabric-biome-api-v1/src/testmod/java/net/fabricmc/fabric/test/biome/FabricBiomeTest.java @@ -16,6 +16,10 @@ package net.fabricmc.fabric.test.biome; +import java.util.List; + +import net.minecraft.tag.TagKey; +import net.minecraft.util.registry.RegistryEntry; import net.minecraft.sound.BiomeMoodSound; import net.minecraft.util.Identifier; import net.minecraft.util.registry.BuiltinRegistries; @@ -30,15 +34,15 @@ import net.minecraft.world.biome.SpawnSettings; import net.minecraft.world.biome.TheNetherBiomeCreator; import net.minecraft.world.biome.source.util.MultiNoiseUtil; import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.placementmodifier.BiomePlacementModifier; -import net.minecraft.world.gen.placementmodifier.SquarePlacementModifier; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.DefaultBiomeFeatures; +import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.EndPlacedFeatures; import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.gen.feature.PlacedFeature; import net.minecraft.world.gen.feature.PlacedFeatures; +import net.minecraft.world.gen.placementmodifier.BiomePlacementModifier; +import net.minecraft.world.gen.placementmodifier.SquarePlacementModifier; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.biome.v1.BiomeModifications; @@ -46,7 +50,6 @@ import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; import net.fabricmc.fabric.api.biome.v1.ModificationPhase; import net.fabricmc.fabric.api.biome.v1.NetherBiomes; import net.fabricmc.fabric.api.biome.v1.TheEndBiomes; -import net.fabricmc.fabric.api.tag.TagFactory; /** * <b>NOTES FOR TESTING:</b> @@ -94,11 +97,12 @@ public class FabricBiomeTest implements ModInitializer { TheEndBiomes.addMidlandsBiome(TEST_END_HIGHLANDS, TEST_END_MIDLANDS, 1.0); TheEndBiomes.addBarrensBiome(TEST_END_HIGHLANDS, TEST_END_BARRRENS, 1.0); - ConfiguredFeature<?, ?> COMMON_DESERT_WELL = Feature.DESERT_WELL.configure(FeatureConfig.DEFAULT); + ConfiguredFeature<?, ?> COMMON_DESERT_WELL = new ConfiguredFeature<>(Feature.DESERT_WELL, DefaultFeatureConfig.INSTANCE); Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(MOD_ID, "fab_desert_well"), COMMON_DESERT_WELL); + RegistryEntry<ConfiguredFeature<?, ?>> featureEntry = BuiltinRegistries.CONFIGURED_FEATURE.getOrCreateEntry(BuiltinRegistries.CONFIGURED_FEATURE.getKey(COMMON_DESERT_WELL).orElseThrow()); // The placement config is taken from the vanilla desert well, but no randomness - PlacedFeature PLACED_COMMON_DESERT_WELL = COMMON_DESERT_WELL.withPlacement(SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of()); + PlacedFeature PLACED_COMMON_DESERT_WELL = new PlacedFeature(featureEntry, List.of(SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of())); Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(MOD_ID, "fab_desert_well"), PLACED_COMMON_DESERT_WELL); BiomeModifications.create(new Identifier("fabric:test_mod")) @@ -109,11 +113,11 @@ public class FabricBiomeTest implements ModInitializer { BiomeSelectors.categories(Biome.Category.DESERT), context -> { context.getGenerationSettings().addFeature(GenerationStep.Feature.TOP_LAYER_MODIFICATION, - BuiltinRegistries.PLACED_FEATURE.getKey(PLACED_COMMON_DESERT_WELL).get() + BuiltinRegistries.PLACED_FEATURE.getKey(PLACED_COMMON_DESERT_WELL).orElseThrow() ); }) .add(ModificationPhase.ADDITIONS, - BiomeSelectors.tag(TagFactory.BIOME.create(new Identifier(MOD_ID, "tag_selector_test"))), + BiomeSelectors.tag(TagKey.intern(Registry.BIOME_KEY, new Identifier(MOD_ID, "tag_selector_test"))), context -> context.getEffects().setSkyColor(0x770000)); } diff --git a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/util/Item2ObjectMap.java b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/util/Item2ObjectMap.java index b7bdca8dc..24ba584e0 100644 --- a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/util/Item2ObjectMap.java +++ b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/util/Item2ObjectMap.java @@ -16,22 +16,22 @@ package net.fabricmc.fabric.api.util; +import net.minecraft.tag.TagKey; import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; -import net.minecraft.tag.Tag; public interface Item2ObjectMap<V> { V get(ItemConvertible item); void add(ItemConvertible item, V value); - void add(Tag<Item> tag, V value); + void add(TagKey<Item> tag, V value); void remove(ItemConvertible item); - void remove(Tag<Item> tag); + void remove(TagKey<Item> tag); void clear(ItemConvertible item); - void clear(Tag<Item> tag); + void clear(TagKey<Item> tag); } diff --git a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/impl/content/registry/CompostingChanceRegistryImpl.java b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/impl/content/registry/CompostingChanceRegistryImpl.java index 3d416979d..54b6c60d2 100644 --- a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/impl/content/registry/CompostingChanceRegistryImpl.java +++ b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/impl/content/registry/CompostingChanceRegistryImpl.java @@ -17,9 +17,9 @@ package net.fabricmc.fabric.impl.content.registry; import net.minecraft.block.ComposterBlock; +import net.minecraft.tag.TagKey; import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; -import net.minecraft.tag.Tag; import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; @@ -35,7 +35,7 @@ public class CompostingChanceRegistryImpl implements CompostingChanceRegistry { } @Override - public void add(Tag<Item> tag, Float value) { + public void add(TagKey<Item> tag, Float value) { throw new UnsupportedOperationException("Tags currently not supported!"); } @@ -45,7 +45,7 @@ public class CompostingChanceRegistryImpl implements CompostingChanceRegistry { } @Override - public void remove(Tag<Item> tag) { + public void remove(TagKey<Item> tag) { throw new UnsupportedOperationException("Tags currently not supported!"); } @@ -55,7 +55,7 @@ public class CompostingChanceRegistryImpl implements CompostingChanceRegistry { } @Override - public void clear(Tag<Item> tag) { + public void clear(TagKey<Item> tag) { throw new UnsupportedOperationException("CompostingChanceRegistry operates directly on the vanilla map - clearing not supported!"); } } diff --git a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/impl/content/registry/FuelRegistryImpl.java b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/impl/content/registry/FuelRegistryImpl.java index 0f21f64a7..660400ee2 100644 --- a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/impl/content/registry/FuelRegistryImpl.java +++ b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/impl/content/registry/FuelRegistryImpl.java @@ -21,13 +21,15 @@ import java.util.Map; import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; -import org.slf4j.LoggerFactory; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; +import net.minecraft.tag.TagKey; +import net.minecraft.util.registry.RegistryEntry; import net.minecraft.item.Item; import net.minecraft.item.ItemConvertible; -import net.minecraft.tag.Tag; +import net.minecraft.util.registry.Registry; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.registry.FuelRegistry; @@ -36,7 +38,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry; public final class FuelRegistryImpl implements FuelRegistry { private static final Logger LOGGER = LoggerFactory.getLogger(FuelRegistryImpl.class); private final Object2IntMap<ItemConvertible> itemCookTimes = new Object2IntLinkedOpenHashMap<>(); - private final Object2IntMap<Tag<Item>> tagCookTimes = new Object2IntLinkedOpenHashMap<>(); + private final Object2IntMap<TagKey<Item>> tagCookTimes = new Object2IntLinkedOpenHashMap<>(); private volatile Map<Item, Integer> fuelTimeCache = null; // thread safe via copy-on-write mechanism public FuelRegistryImpl() { @@ -73,7 +75,7 @@ public final class FuelRegistryImpl implements FuelRegistry { } @Override - public void add(Tag<Item> tag, Integer cookTime) { + public void add(TagKey<Item> tag, Integer cookTime) { if (cookTime > 32767) { LOGGER.warn("Tried to register an overly high cookTime: " + cookTime + " > 32767! (" + getTagName(tag) + ")"); } @@ -89,7 +91,7 @@ public final class FuelRegistryImpl implements FuelRegistry { } @Override - public void remove(Tag<Item> tag) { + public void remove(TagKey<Item> tag) { add(tag, 0); resetCache(); } @@ -101,19 +103,20 @@ public final class FuelRegistryImpl implements FuelRegistry { } @Override - public void clear(Tag<Item> tag) { + public void clear(TagKey<Item> tag) { tagCookTimes.removeInt(tag); resetCache(); } public void apply(Map<Item, Integer> map) { // tags take precedence before blocks - for (Tag<Item> tag : tagCookTimes.keySet()) { + for (TagKey<Item> tag : tagCookTimes.keySet()) { int time = tagCookTimes.getInt(tag); if (time <= 0) { - for (Item i : tag.values()) { - map.remove(i); + for (RegistryEntry<Item> key : Registry.ITEM.method_40286(tag)) { + final Item item = key.value(); + map.remove(item); } } else { AbstractFurnaceBlockEntity.addFuel(map, tag, time); @@ -131,12 +134,8 @@ public final class FuelRegistryImpl implements FuelRegistry { } } - private static String getTagName(Tag<?> tag) { - if (tag instanceof Tag.Identified) { - return ((Tag.Identified<?>) tag).getId().toString(); - } - - return tag.toString(); + private static String getTagName(TagKey<?> tag) { + return tag.id().toString(); } public void resetCache() { diff --git a/fabric-content-registries-v0/src/main/resources/fabric-content-registries-v0.accesswidener b/fabric-content-registries-v0/src/main/resources/fabric-content-registries-v0.accesswidener index dc2450d69..2db403ec3 100644 --- a/fabric-content-registries-v0/src/main/resources/fabric-content-registries-v0.accesswidener +++ b/fabric-content-registries-v0/src/main/resources/fabric-content-registries-v0.accesswidener @@ -1,4 +1,4 @@ accessWidener v1 named -accessible method net/minecraft/block/entity/AbstractFurnaceBlockEntity addFuel (Ljava/util/Map;Lnet/minecraft/tag/Tag;I)V +accessible method net/minecraft/block/entity/AbstractFurnaceBlockEntity addFuel (Ljava/util/Map;Lnet/minecraft/tag/TagKey;I)V accessible method net/minecraft/block/entity/AbstractFurnaceBlockEntity addFuel (Ljava/util/Map;Lnet/minecraft/item/ItemConvertible;I)V diff --git a/fabric-data-generation-api-v1/build.gradle b/fabric-data-generation-api-v1/build.gradle index 032e4cc83..2b7365277 100644 --- a/fabric-data-generation-api-v1/build.gradle +++ b/fabric-data-generation-api-v1/build.gradle @@ -9,7 +9,6 @@ moduleDependencies(project, [ ]) dependencies { - testmodImplementation project(path: ':fabric-tag-extensions-v0', configuration: 'namedElements') } sourceSets { @@ -60,18 +59,17 @@ import java.util.zip.ZipFile task generateAccessWidener() { doLast { - // This is using loom internals, dont copy from this. - File inputJar = loom.mappingsProvider.mappedProvider.baseMappedJar + File inputJar = loom.namedMinecraftProvider.parentMinecraftProvider.mergedJar.toFile() String accessWidener = file("template.accesswidener").text + "\n" - visitMethods(inputJar, "net/minecraft/data/server/RecipesProvider.class") { name, desc, owner -> + visitMethods(inputJar, "net/minecraft/data/server/RecipeProvider.class") { name, desc, owner -> if (it.name == "generate") return accessWidener += "transitive-accessible\tmethod\t${owner}\t${name}\t${desc}\n" } - visitMethods(inputJar, "net/minecraft/data/client/model/BlockStateModelGenerator.class") { name, desc, owner -> + visitMethods(inputJar, "net/minecraft/data/client/BlockStateModelGenerator.class") { name, desc, owner -> if (desc == "()V") // Skip over methods that dont take any arguments, as they are specific to minecraft. return @@ -89,6 +87,7 @@ task generateAccessWidener() { def visitMethods(File input, String className, closure) { def clazz = getClassNode(input, className) + clazz.methods.forEach { if ((it.access & Opcodes.ACC_SYNTHETIC) != 0 || (it.access & Opcodes.ACC_PUBLIC) != 0) return @@ -101,9 +100,7 @@ def visitMethods(File input, String className, closure) { } ClassNode getClassNode(File input, String className) { - File inputJar = loom.mappingsProvider.mappedProvider.baseMappedJar - - new ZipFile(inputJar).withCloseable { ZipFile zip -> + new ZipFile(input).withCloseable { ZipFile zip -> zip.getInputStream(zip.getEntry(className)).withCloseable { is -> ClassReader reader = new ClassReader(is) ClassNode classNode = new ClassNode() diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricModelProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricModelProvider.java index b5d4abe85..1f77b94ab 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricModelProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricModelProvider.java @@ -16,9 +16,9 @@ package net.fabricmc.fabric.api.datagen.v1.provider; -import net.minecraft.data.client.BlockStateDefinitionProvider; +import net.minecraft.data.client.BlockStateModelGenerator; import net.minecraft.data.client.ItemModelGenerator; -import net.minecraft.data.client.model.BlockStateModelGenerator; +import net.minecraft.data.client.ModelProvider; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; @@ -27,7 +27,7 @@ import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; * * <p>Register an instance of the class with {@link FabricDataGenerator#addProvider} in a {@link net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint} */ -public abstract class FabricModelProvider extends BlockStateDefinitionProvider { +public abstract class FabricModelProvider extends ModelProvider { protected final FabricDataGenerator dataGenerator; public FabricModelProvider(FabricDataGenerator dataGenerator) { diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricRecipeProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricRecipeProvider.java index 24fad4af7..bd0713e34 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricRecipeProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricRecipeProvider.java @@ -25,10 +25,10 @@ import com.google.common.collect.Sets; import com.google.gson.JsonObject; import net.minecraft.data.DataCache; -import net.minecraft.data.server.RecipesProvider; +import net.minecraft.data.server.RecipeProvider; import net.minecraft.data.server.recipe.RecipeJsonProvider; -import net.minecraft.data.server.recipe.ShapedRecipeJsonFactory; -import net.minecraft.data.server.recipe.ShapelessRecipeJsonFactory; +import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder; +import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder; import net.minecraft.util.Identifier; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; @@ -40,7 +40,7 @@ import net.fabricmc.fabric.impl.datagen.FabricDataGenHelper; * * <p>Register an instance of the class with {@link FabricDataGenerator#addProvider} in a {@link net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint} */ -public abstract class FabricRecipeProvider extends RecipesProvider { +public abstract class FabricRecipeProvider extends RecipeProvider { protected final FabricDataGenerator dataGenerator; public FabricRecipeProvider(FabricDataGenerator dataGenerator) { @@ -49,7 +49,7 @@ public abstract class FabricRecipeProvider extends RecipesProvider { } /** - * Implement this method and then use the range of methods in {@link RecipesProvider} or from one of the recipe json factories such as {@link ShapedRecipeJsonFactory} & {@link ShapelessRecipeJsonFactory}. + * Implement this method and then use the range of methods in {@link RecipeProvider} or from one of the recipe json factories such as {@link ShapedRecipeJsonBuilder} & {@link ShapelessRecipeJsonBuilder}. */ protected abstract void generateRecipes(Consumer<RecipeJsonProvider> exporter); diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricTagProvider.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricTagProvider.java index c1bfc2077..b9284f7c3 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricTagProvider.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricTagProvider.java @@ -24,6 +24,7 @@ import com.google.common.base.Preconditions; import org.jetbrains.annotations.Nullable; import net.minecraft.block.Block; +import net.minecraft.tag.TagKey; import net.minecraft.data.DataProvider; import net.minecraft.data.server.AbstractTagProvider; import net.minecraft.entity.EntityType; @@ -44,7 +45,6 @@ import net.minecraft.world.event.GameEvent; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; import net.fabricmc.fabric.impl.datagen.FabricDataGenHelper; import net.fabricmc.fabric.mixin.datagen.DynamicRegistryManagerAccessor; -import net.fabricmc.fabric.impl.datagen.FabricTagEntry; /** * Implement this class (or one of the inner classes) to generate a tag list. @@ -97,7 +97,7 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> { * @return The {@link FabricTagBuilder} instance */ @Override - protected FabricTagBuilder<T> getOrCreateTagBuilder(Tag.Identified<T> tag) { + protected FabricTagBuilder<T> getOrCreateTagBuilder(TagKey<T> tag) { return new FabricTagBuilder<>(super.getOrCreateTagBuilder(tag)); } @@ -130,7 +130,7 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> { */ public abstract static class ItemTagProvider extends FabricTagProvider<Item> { @Nullable - private final Function<Tag.Identified<Block>, Tag.Builder> blockTagBuilderProvider; + private final Function<TagKey<Block>, Tag.Builder> blockTagBuilderProvider; /** * Construct an {@link ItemTagProvider} tag provider <b>with</b> an associated {@link BlockTagProvider} tag provider. @@ -162,10 +162,10 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> { * @param blockTag The block tag to copy from. * @param itemTag The item tag to copy to. */ - public void copy(Tag.Identified<Block> blockTag, Tag.Identified<Item> itemTag) { + public void copy(TagKey<Block> blockTag, TagKey<Item> itemTag) { Tag.Builder blockTagBuilder = Objects.requireNonNull(this.blockTagBuilderProvider, "Pass Block tag provider via constructor to use copy").apply(blockTag); Tag.Builder itemTagBuilder = this.getTagBuilder(itemTag); - blockTagBuilder.streamEntries().filter((entry) -> entry.getEntry().canAdd(this.registry::containsId, (id) -> true)).forEach(itemTagBuilder::add); + blockTagBuilder.streamEntries().filter((entry) -> entry.entry().canAdd(this.registry::containsId, (id) -> true)).forEach(itemTagBuilder::add); } } @@ -288,7 +288,7 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> { * <p><b>Note:</b> any vanilla tags can be added to the builder, * but other tags can only be added if it has a builder registered in the same provider. * - * <p>Use {@link #forceAddTag(Tag.Identified)} to force add any tag. + * <p>Use {@link #forceAddTag(TagKey)} to force add any tag. * * @return the {@link FabricTagBuilder} instance * @see BlockTags @@ -298,19 +298,8 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> { * @see ItemTags */ @Override - public FabricTagBuilder<T> addTag(Tag.Identified<T> tag) { - builder.add(new FabricTagEntry<>(registry, tag.getId(), false), source); - return this; - } - - /** - * Add another tag to this tag. - * - * @return the {@link FabricTagBuilder} instance - * @throws ClassCastException if tag is not {@linkplain Tag.Identified identified} - */ - public FabricTagBuilder<T> addTag(Tag<T> tag) { - parent.addTag((Tag.Identified<T>) tag); + public FabricTagBuilder<T> addTag(TagKey<T> tag) { + builder.add(tag.id(), source); return this; } @@ -333,8 +322,8 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> { * * @return the {@link FabricTagBuilder} instance */ - public FabricTagBuilder<T> forceAddTag(Tag.Identified<T> tag) { - builder.add(new FabricTagEntry<>(registry, tag.getId(), true), source); + public FabricTagBuilder<T> forceAddTag(TagKey<T> tag) { + builder.add(tag.id(), source); return this; } diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataGenHelper.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataGenHelper.java index fce3b560f..305ce0370 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataGenHelper.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricDataGenHelper.java @@ -82,7 +82,7 @@ public final class FabricDataGenHelper { * Therefore, this simply return true for all {@link Registry#containsId} call. */ @SuppressWarnings("rawtypes") - private static final Registry FAKE_DYNAMIC_REGISTRY = new SimpleRegistry<>(RegistryKey.ofRegistry(new Identifier("fabric:fake_dynamic_registry")), Lifecycle.experimental()) { + private static final Registry FAKE_DYNAMIC_REGISTRY = new SimpleRegistry<>(RegistryKey.ofRegistry(new Identifier("fabric:fake_dynamic_registry")), Lifecycle.experimental(), null) { @Override public boolean containsId(Identifier id) { return true; diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricTagEntry.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricTagEntry.java deleted file mode 100644 index 978926460..000000000 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/FabricTagEntry.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.datagen; - -import java.util.function.Predicate; - -import net.minecraft.tag.RequiredTagListRegistry; -import net.minecraft.tag.Tag; -import net.minecraft.tag.TagGroup; -import net.minecraft.tag.TagManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; - -public class FabricTagEntry<T> extends Tag.TagEntry { - private static final TagManager TAG_MANAGER = RequiredTagListRegistry.createBuiltinTagManager(); - - private final Registry<T> registry; - private final Identifier id; - private final boolean allowNonVanilla; - - public FabricTagEntry(Registry<T> registry, Identifier id, boolean allowNonVanilla) { - super(id); - - this.registry = registry; - this.id = id; - this.allowNonVanilla = allowNonVanilla; - } - - @Override - public boolean canAdd(Predicate<Identifier> existenceTest, Predicate<Identifier> duplicationTest) { - if (allowNonVanilla) { - return true; - } - - TagGroup<T> tagGroup = TAG_MANAGER.getOrCreateTagGroup(registry.getKey()); - return tagGroup.contains(id) || super.canAdd(existenceTest, duplicationTest); - } -} diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/ModelProviderMixin.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/ModelProviderMixin.java index 5b146f513..00820acb0 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/ModelProviderMixin.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/mixin/datagen/ModelProviderMixin.java @@ -35,18 +35,18 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import net.minecraft.block.Block; import net.minecraft.data.DataCache; import net.minecraft.data.DataGenerator; -import net.minecraft.data.client.BlockStateDefinitionProvider; +import net.minecraft.data.client.BlockStateModelGenerator; +import net.minecraft.data.client.BlockStateSupplier; import net.minecraft.data.client.ItemModelGenerator; -import net.minecraft.data.client.model.BlockStateModelGenerator; -import net.minecraft.data.client.model.BlockStateSupplier; +import net.minecraft.data.client.ModelProvider; import net.minecraft.item.Item; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; -@Mixin(BlockStateDefinitionProvider.class) +@Mixin(ModelProvider.class) public class ModelProviderMixin { @Shadow @Final @@ -55,7 +55,7 @@ public class ModelProviderMixin { @Unique private static ThreadLocal<DataGenerator> dataGeneratorThreadLocal = new ThreadLocal<>(); - @Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/client/model/BlockStateModelGenerator;register()V")) + @Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/client/BlockStateModelGenerator;register()V")) private void registerBlockStateModels(BlockStateModelGenerator instance) { if (((Object) this) instanceof FabricModelProvider fabricModelProvider) { fabricModelProvider.generateBlockStateModels(instance); @@ -100,7 +100,7 @@ public class ModelProviderMixin { } } - @Inject(method = "method_25741", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/client/model/ModelIds;getItemModelId(Lnet/minecraft/item/Item;)Lnet/minecraft/util/Identifier;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) + @Inject(method = "method_25741", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/client/ModelIds;getItemModelId(Lnet/minecraft/item/Item;)Lnet/minecraft/util/Identifier;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD) private static void filterItemsForProcessingMod(Set<Item> set, Map<Identifier, Supplier<JsonElement>> map, Block block, CallbackInfo ci, Item item) { if (dataGeneratorThreadLocal.get() instanceof FabricDataGenerator dataGenerator) { if (!dataGenerator.isStrictValidationEnabled()) { diff --git a/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener b/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener index 56ece3bc9..58fd9fa06 100644 --- a/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener +++ b/fabric-data-generation-api-v1/src/main/resources/fabric-data-generation-api-v1.accesswidener @@ -1,6 +1,6 @@ accessWidener v2 named -accessible field net/minecraft/data/server/RecipesProvider root Lnet/minecraft/data/DataGenerator; +accessible field net/minecraft/data/server/RecipeProvider root Lnet/minecraft/data/DataGenerator; extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder <init> (Lnet/minecraft/tag/Tag$Builder;Lnet/minecraft/util/registry/Registry;Ljava/lang/String;)V extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder add ([Ljava/lang/Object;)Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder; @@ -14,181 +14,181 @@ accessible field net/minecraft/data/server/BlockLootTableGenerator lootTabl transitive-accessible method net/minecraft/data/family/BlockFamilies register (Lnet/minecraft/block/Block;)Lnet/minecraft/data/family/BlockFamily$Builder; -transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/data/client/model/Model;)V -transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/data/client/model/Model;)V -transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Ljava/lang/String;Lnet/minecraft/data/client/model/Model;)V +transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/data/client/Model;)V +transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/data/client/Model;)V +transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Ljava/lang/String;Lnet/minecraft/data/client/Model;)V -transitive-accessible field net/minecraft/data/client/model/BlockStateModelGenerator blockStateCollector Ljava/util/function/Consumer; -transitive-accessible field net/minecraft/data/client/model/BlockStateModelGenerator modelCollector Ljava/util/function/BiConsumer; +transitive-accessible field net/minecraft/data/client/BlockStateModelGenerator blockStateCollector Ljava/util/function/Consumer; +transitive-accessible field net/minecraft/data/client/BlockStateModelGenerator modelCollector Ljava/util/function/BiConsumer; -transitive-accessible method net/minecraft/data/client/model/TextureKey of (Ljava/lang/String;)Lnet/minecraft/data/client/model/TextureKey; -transitive-accessible method net/minecraft/data/client/model/TextureKey of (Ljava/lang/String;Lnet/minecraft/data/client/model/TextureKey;)Lnet/minecraft/data/client/model/TextureKey; +transitive-accessible method net/minecraft/data/client/TextureKey of (Ljava/lang/String;)Lnet/minecraft/data/client/TextureKey; +transitive-accessible method net/minecraft/data/client/TextureKey of (Ljava/lang/String;Lnet/minecraft/data/client/TextureKey;)Lnet/minecraft/data/client/TextureKey; -transitive-accessible method net/minecraft/data/server/RecipesProvider saveRecipe (Lnet/minecraft/data/DataCache;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider saveRecipeAdvancement (Lnet/minecraft/data/DataCache;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider generate (Ljava/util/function/Consumer;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerSingleOutputShapelessRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerShapelessRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;I)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerSmelting (Ljava/util/function/Consumer;Ljava/util/List;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerBlasting (Ljava/util/function/Consumer;Ljava/util/List;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerMultipleOptions (Ljava/util/function/Consumer;Lnet/minecraft/recipe/CookingRecipeSerializer;Ljava/util/List;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerNetheriteUpgradeRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerPlanksRecipe2 (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/tag/Tag;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerPlanksRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/tag/Tag;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerBarkBlockRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerBoatRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider createTransmutationRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonFactory; -transitive-accessible method net/minecraft/data/server/RecipesProvider createDoorRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonFactory; -transitive-accessible method net/minecraft/data/server/RecipesProvider createFenceRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonFactory; -transitive-accessible method net/minecraft/data/server/RecipesProvider createFenceGateRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonFactory; -transitive-accessible method net/minecraft/data/server/RecipesProvider createPressurePlateRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider createPressurePlateRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonFactory; -transitive-accessible method net/minecraft/data/server/RecipesProvider offerSlabRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider createSlabRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonFactory; -transitive-accessible method net/minecraft/data/server/RecipesProvider createStairsRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonFactory; -transitive-accessible method net/minecraft/data/server/RecipesProvider createTrapdoorRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonFactory; -transitive-accessible method net/minecraft/data/server/RecipesProvider createSignRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonFactory; -transitive-accessible method net/minecraft/data/server/RecipesProvider offerWoolDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerCarpetRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerCarpetDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerBedRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerBedDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerBannerRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerStainedGlassDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerStainedGlassPaneRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerStainedGlassPaneDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerTerracottaDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerConcretePowderDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerStonecuttingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerStonecuttingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;I)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerCrackingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerReversibleCompactingRecipes (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerReversibleCompactingRecipesWithCompactedItemGroup (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerReversibleCompactingRecipesWithInputItemGroup (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerReversibleCompactingRecipes (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider generateCookingRecipes (Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/recipe/CookingRecipeSerializer;I)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerCookingRecipe (Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/recipe/CookingRecipeSerializer;ILnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;F)V -transitive-accessible method net/minecraft/data/server/RecipesProvider offerWaxingRecipes (Ljava/util/function/Consumer;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider generateFamily (Ljava/util/function/Consumer;Lnet/minecraft/data/family/BlockFamily;)V -transitive-accessible method net/minecraft/data/server/RecipesProvider getVariantRecipeInput (Lnet/minecraft/data/family/BlockFamily;Lnet/minecraft/data/family/BlockFamily$Variant;)Lnet/minecraft/block/Block; -transitive-accessible method net/minecraft/data/server/RecipesProvider requireEnteringFluid (Lnet/minecraft/block/Block;)Lnet/minecraft/advancement/criterion/EnterBlockCriterion$Conditions; -transitive-accessible method net/minecraft/data/server/RecipesProvider conditionsFromItem (Lnet/minecraft/predicate/NumberRange$IntRange;Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; -transitive-accessible method net/minecraft/data/server/RecipesProvider conditionsFromItem (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; -transitive-accessible method net/minecraft/data/server/RecipesProvider conditionsFromTag (Lnet/minecraft/tag/Tag;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; -transitive-accessible method net/minecraft/data/server/RecipesProvider conditionsFromItemPredicates ([Lnet/minecraft/predicate/item/ItemPredicate;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; -transitive-accessible method net/minecraft/data/server/RecipesProvider hasItem (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/server/RecipesProvider getItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/server/RecipesProvider getRecipeName (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/server/RecipesProvider convertBetween (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/server/RecipesProvider getSmeltingItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/server/RecipesProvider getBlastingItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createStoneState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/model/Texture;Ljava/util/function/BiConsumer;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createDeepslateState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/model/Texture;Ljava/util/function/BiConsumer;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator excludeFromSimpleItemModelGeneration (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerParentedItemModel (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerParentedItemModel (Lnet/minecraft/item/Item;Lnet/minecraft/util/Identifier;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerItemModel (Lnet/minecraft/item/Item;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerItemModel (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerItemModel (Lnet/minecraft/block/Block;Ljava/lang/String;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createNorthDefaultHorizontalRotationStates ()Lnet/minecraft/data/client/model/BlockStateVariantMap; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createSouthDefaultHorizontalRotationStates ()Lnet/minecraft/data/client/model/BlockStateVariantMap; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createEastDefaultHorizontalRotationStates ()Lnet/minecraft/data/client/model/BlockStateVariantMap; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createNorthDefaultRotationStates ()Lnet/minecraft/data/client/model/BlockStateVariantMap; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createBlockStateWithRandomHorizontalRotations (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/VariantsBlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createModelVariantWithRandomHorizontalRotations (Lnet/minecraft/util/Identifier;)[Lnet/minecraft/data/client/model/BlockStateVariant; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createBlockStateWithTwoModelAndRandomInversion (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/VariantsBlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createBooleanModelMap (Lnet/minecraft/state/property/BooleanProperty;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateVariantMap; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerMirrorable (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerRotatable (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createButtonBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator fillDoorVariantMap (Lnet/minecraft/data/client/model/BlockStateVariantMap$QuadrupleProperty;Lnet/minecraft/block/enums/DoubleBlockHalf;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateVariantMap$QuadrupleProperty; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createDoorBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createFenceBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createWallBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createFenceGateBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createStairsBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createOrientableTrapdoorBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createTrapdoorBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createSingletonBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/VariantsBlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createAxisRotatedVariantMap ()Lnet/minecraft/data/client/model/BlockStateVariantMap; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createAxisRotatedBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerAxisRotated (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerAxisRotated (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/TexturedModel$Factory;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerNorthDefaultHorizontalRotated (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/TexturedModel$Factory;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createAxisRotatedBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerAxisRotated (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/TexturedModel$Factory;Lnet/minecraft/data/client/model/TexturedModel$Factory;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createSubModel (Lnet/minecraft/block/Block;Ljava/lang/String;Lnet/minecraft/data/client/model/Model;Ljava/util/function/Function;)Lnet/minecraft/util/Identifier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createPressurePlateBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createSlabBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateSupplier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerSimpleCubeAll (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerSingleton (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/TexturedModel$Factory;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerSingleton (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/Texture;Lnet/minecraft/data/client/model/Model;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerCubeAllModelTexturePool (Lnet/minecraft/block/Block;)Lnet/minecraft/data/client/model/BlockStateModelGenerator$BlockTexturePool; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerDoor (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerOrientableTrapdoor (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerTrapdoor (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerLog (Lnet/minecraft/block/Block;)Lnet/minecraft/data/client/model/BlockStateModelGenerator$LogTexturePool; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerSimpleState (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerStateWithModelReference (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerTintableCross (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/BlockStateModelGenerator$TintType;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerTintableCross (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/BlockStateModelGenerator$TintType;Lnet/minecraft/data/client/model/Texture;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerTintableCrossBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/BlockStateModelGenerator$TintType;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerTintableCrossBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/BlockStateModelGenerator$TintType;Lnet/minecraft/data/client/model/Texture;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerFlowerPotPlant (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/BlockStateModelGenerator$TintType;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerCoralFan (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerGourd (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerCoral (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerDoubleBlock (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/BlockStateModelGenerator$TintType;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerDoubleBlock (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerTurnableRail (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerStraightRail (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerBuiltin (Lnet/minecraft/util/Identifier;Lnet/minecraft/block/Block;)Lnet/minecraft/data/client/model/BlockStateModelGenerator$BuiltinModelPool; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerBuiltin (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Lnet/minecraft/data/client/model/BlockStateModelGenerator$BuiltinModelPool; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerBuiltinWithParticle (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerBuiltinWithParticle (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerCarpet (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerRandomHorizontalRotations (Lnet/minecraft/data/client/model/TexturedModel$Factory;[Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerSouthDefaultHorizontalFacing (Lnet/minecraft/data/client/model/TexturedModel$Factory;[Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerGlassPane (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerCommandBlock (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerAnvil (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator getBambooBlockStateVariants (I)Ljava/util/List; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createUpDefaultFacingVariantMap ()Lnet/minecraft/data/client/model/BlockStateVariantMap; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator createValueFencedModelMap (Lnet/minecraft/state/property/Property;Ljava/lang/Comparable;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/model/BlockStateVariantMap; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerBeehive (Lnet/minecraft/block/Block;Ljava/util/function/Function;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerCrop (Lnet/minecraft/block/Block;Lnet/minecraft/state/property/Property;[I)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerCooker (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/TexturedModel$Factory;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerCampfire ([Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerAzalea (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerPottedAzaleaBush (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerMushroomBlock (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerCubeWithCustomTexture (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Ljava/util/function/BiFunction;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerNorthDefaultHorizontalRotatable (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/Texture;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerFurnaceLikeOrientable (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerAmethyst (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator getDripstoneVariant (Lnet/minecraft/util/math/Direction;Lnet/minecraft/block/enums/Thickness;)Lnet/minecraft/data/client/model/BlockStateVariant; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerNetherrackBottomCustomTop (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerRod (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator getFireFloorModels (Lnet/minecraft/block/Block;)Ljava/util/List; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator getFireSideModels (Lnet/minecraft/block/Block;)Ljava/util/List; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator getFireUpModels (Lnet/minecraft/block/Block;)Ljava/util/List; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator buildBlockStateVariants (Ljava/util/List;Ljava/util/function/UnaryOperator;)Ljava/util/List; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerLantern (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerTopSoil (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/model/BlockStateVariant;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerPressurePlate (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerInfested (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerNorthDefaultHorizontalRotation (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerPiston (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/model/Texture;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerTorch (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator getTurtleEggModel (ILjava/lang/String;Lnet/minecraft/data/client/model/Texture;)Lnet/minecraft/util/Identifier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator getTurtleEggModel (Ljava/lang/Integer;Ljava/lang/Integer;)Lnet/minecraft/util/Identifier; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerWallPlant (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerShulkerBox (Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerPlantPart (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/BlockStateModelGenerator$TintType;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerBed (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerRoots (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator addJigsawOrientationToVariant (Lnet/minecraft/block/enums/JigsawOrientation;Lnet/minecraft/data/client/model/BlockStateVariant;)Lnet/minecraft/data/client/model/BlockStateVariant; -transitive-accessible method net/minecraft/data/client/model/BlockStateModelGenerator registerCandle (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider saveRecipe (Lnet/minecraft/data/DataCache;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider saveRecipeAdvancement (Lnet/minecraft/data/DataCache;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider generate (Ljava/util/function/Consumer;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerSingleOutputShapelessRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerShapelessRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;I)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerSmelting (Ljava/util/function/Consumer;Ljava/util/List;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerBlasting (Ljava/util/function/Consumer;Ljava/util/List;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerMultipleOptions (Ljava/util/function/Consumer;Lnet/minecraft/recipe/CookingRecipeSerializer;Ljava/util/List;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerNetheriteUpgradeRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerPlanksRecipe2 (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/tag/TagKey;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerPlanksRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/tag/TagKey;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerBarkBlockRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerBoatRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider createTransmutationRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/RecipeProvider createDoorRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/RecipeProvider createFenceRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/RecipeProvider createFenceGateRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/RecipeProvider createPressurePlateRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider createPressurePlateRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/RecipeProvider offerSlabRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider createSlabRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/RecipeProvider createStairsRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/RecipeProvider createTrapdoorRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/RecipeProvider createSignRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder; +transitive-accessible method net/minecraft/data/server/RecipeProvider offerWoolDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerCarpetRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerCarpetDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerBedRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerBedDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerBannerRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerStainedGlassDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerStainedGlassPaneRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerStainedGlassPaneDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerTerracottaDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerConcretePowderDyeingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerStonecuttingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerStonecuttingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;I)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerCrackingRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerReversibleCompactingRecipes (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerReversibleCompactingRecipesWithCompactingRecipeGroup (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerReversibleCompactingRecipesWithReverseRecipeGroup (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerReversibleCompactingRecipes (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider generateCookingRecipes (Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/recipe/CookingRecipeSerializer;I)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerCookingRecipe (Ljava/util/function/Consumer;Ljava/lang/String;Lnet/minecraft/recipe/CookingRecipeSerializer;ILnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;F)V +transitive-accessible method net/minecraft/data/server/RecipeProvider offerWaxingRecipes (Ljava/util/function/Consumer;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider generateFamily (Ljava/util/function/Consumer;Lnet/minecraft/data/family/BlockFamily;)V +transitive-accessible method net/minecraft/data/server/RecipeProvider getVariantRecipeInput (Lnet/minecraft/data/family/BlockFamily;Lnet/minecraft/data/family/BlockFamily$Variant;)Lnet/minecraft/block/Block; +transitive-accessible method net/minecraft/data/server/RecipeProvider requireEnteringFluid (Lnet/minecraft/block/Block;)Lnet/minecraft/advancement/criterion/EnterBlockCriterion$Conditions; +transitive-accessible method net/minecraft/data/server/RecipeProvider conditionsFromItem (Lnet/minecraft/predicate/NumberRange$IntRange;Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; +transitive-accessible method net/minecraft/data/server/RecipeProvider conditionsFromItem (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; +transitive-accessible method net/minecraft/data/server/RecipeProvider conditionsFromTag (Lnet/minecraft/tag/TagKey;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; +transitive-accessible method net/minecraft/data/server/RecipeProvider conditionsFromItemPredicates ([Lnet/minecraft/predicate/item/ItemPredicate;)Lnet/minecraft/advancement/criterion/InventoryChangedCriterion$Conditions; +transitive-accessible method net/minecraft/data/server/RecipeProvider hasItem (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/RecipeProvider getItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/RecipeProvider getRecipeName (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/RecipeProvider convertBetween (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/RecipeProvider getSmeltingItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/server/RecipeProvider getBlastingItemPath (Lnet/minecraft/item/ItemConvertible;)Ljava/lang/String; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createStoneState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/model/TextureMap;Ljava/util/function/BiConsumer;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createDeepslateState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/model/TextureMap;Ljava/util/function/BiConsumer;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator excludeFromSimpleItemModelGeneration (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerParentedItemModel (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerParentedItemModel (Lnet/minecraft/item/Item;Lnet/minecraft/util/Identifier;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerItemModel (Lnet/minecraft/item/Item;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerItemModel (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerItemModel (Lnet/minecraft/block/Block;Ljava/lang/String;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createNorthDefaultHorizontalRotationStates ()Lnet/minecraft/data/client/BlockStateVariantMap; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createSouthDefaultHorizontalRotationStates ()Lnet/minecraft/data/client/BlockStateVariantMap; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createEastDefaultHorizontalRotationStates ()Lnet/minecraft/data/client/BlockStateVariantMap; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createNorthDefaultRotationStates ()Lnet/minecraft/data/client/BlockStateVariantMap; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createBlockStateWithRandomHorizontalRotations (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/VariantsBlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createModelVariantWithRandomHorizontalRotations (Lnet/minecraft/util/Identifier;)[Lnet/minecraft/data/client/BlockStateVariant; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createBlockStateWithTwoModelAndRandomInversion (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/VariantsBlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createBooleanModelMap (Lnet/minecraft/state/property/BooleanProperty;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateVariantMap; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerMirrorable (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerRotatable (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createButtonBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator fillDoorVariantMap (Lnet/minecraft/data/client/BlockStateVariantMap$QuadrupleProperty;Lnet/minecraft/block/enums/DoubleBlockHalf;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateVariantMap$QuadrupleProperty; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createDoorBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createFenceBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createWallBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createFenceGateBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createStairsBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createOrientableTrapdoorBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createTrapdoorBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createSingletonBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/VariantsBlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createAxisRotatedVariantMap ()Lnet/minecraft/data/client/BlockStateVariantMap; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createAxisRotatedBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerAxisRotated (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerAxisRotated (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/TexturedModel$Factory;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerNorthDefaultHorizontalRotated (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/TexturedModel$Factory;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createAxisRotatedBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerAxisRotated (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/TexturedModel$Factory;Lnet/minecraft/data/client/TexturedModel$Factory;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createSubModel (Lnet/minecraft/block/Block;Ljava/lang/String;Lnet/minecraft/data/client/Model;Ljava/util/function/Function;)Lnet/minecraft/util/Identifier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createPressurePlateBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createSlabBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateSupplier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerSimpleCubeAll (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerSingleton (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/TexturedModel$Factory;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerSingleton (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/TextureMap;Lnet/minecraft/data/client/Model;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCubeAllModelTexturePool (Lnet/minecraft/block/Block;)Lnet/minecraft/data/client/BlockStateModelGenerator$BlockTexturePool; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerDoor (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerOrientableTrapdoor (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerTrapdoor (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerLog (Lnet/minecraft/block/Block;)Lnet/minecraft/data/client/BlockStateModelGenerator$LogTexturePool; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerSimpleState (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerStateWithModelReference (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerTintableCross (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/BlockStateModelGenerator$TintType;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerTintableCross (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/BlockStateModelGenerator$TintType;Lnet/minecraft/data/client/model/TextureMap;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerTintableCrossBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/BlockStateModelGenerator$TintType;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerTintableCrossBlockState (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/BlockStateModelGenerator$TintType;Lnet/minecraft/data/client/model/TextureMap;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerFlowerPotPlant (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/data/client/BlockStateModelGenerator$TintType;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCoralFan (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerGourd (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCoral (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerDoubleBlock (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/BlockStateModelGenerator$TintType;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerDoubleBlock (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerTurnableRail (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerStraightRail (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerBuiltin (Lnet/minecraft/util/Identifier;Lnet/minecraft/block/Block;)Lnet/minecraft/data/client/BlockStateModelGenerator$BuiltinModelPool; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerBuiltin (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Lnet/minecraft/data/client/BlockStateModelGenerator$BuiltinModelPool; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerBuiltinWithParticle (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerBuiltinWithParticle (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerWoolAndCarpet (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerRandomHorizontalRotations (Lnet/minecraft/data/client/TexturedModel$Factory;[Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerSouthDefaultHorizontalFacing (Lnet/minecraft/data/client/TexturedModel$Factory;[Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerGlassPane (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCommandBlock (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerAnvil (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator getBambooBlockStateVariants (I)Ljava/util/List; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createUpDefaultFacingVariantMap ()Lnet/minecraft/data/client/BlockStateVariantMap; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator createValueFencedModelMap (Lnet/minecraft/state/property/Property;Ljava/lang/Comparable;Lnet/minecraft/util/Identifier;Lnet/minecraft/util/Identifier;)Lnet/minecraft/data/client/BlockStateVariantMap; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerBeehive (Lnet/minecraft/block/Block;Ljava/util/function/Function;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCrop (Lnet/minecraft/block/Block;Lnet/minecraft/state/property/Property;[I)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCooker (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/TexturedModel$Factory;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCampfire ([Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerAzalea (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerPottedAzaleaBush (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerMushroomBlock (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCubeWithCustomTextures (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Ljava/util/function/BiFunction;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerNorthDefaultHorizontalRotatable (Lnet/minecraft/block/Block;Lnet/minecraft/data/client/model/TextureMap;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerDispenserLikeOrientable (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerAmethyst (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator getDripstoneVariant (Lnet/minecraft/util/math/Direction;Lnet/minecraft/block/enums/Thickness;)Lnet/minecraft/data/client/BlockStateVariant; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerNetherrackBottomCustomTop (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerRod (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator getFireFloorModels (Lnet/minecraft/block/Block;)Ljava/util/List; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator getFireSideModels (Lnet/minecraft/block/Block;)Ljava/util/List; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator getFireUpModels (Lnet/minecraft/block/Block;)Ljava/util/List; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator buildBlockStateVariants (Ljava/util/List;Ljava/util/function/UnaryOperator;)Ljava/util/List; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerLantern (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerTopSoil (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/BlockStateVariant;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerPressurePlate (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerInfested (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerNorthDefaultHorizontalRotation (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerPiston (Lnet/minecraft/block/Block;Lnet/minecraft/util/Identifier;Lnet/minecraft/data/client/model/TextureMap;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerTorch (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator getTurtleEggModel (ILjava/lang/String;Lnet/minecraft/data/client/model/TextureMap;)Lnet/minecraft/util/Identifier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator getTurtleEggModel (Ljava/lang/Integer;Ljava/lang/Integer;)Lnet/minecraft/util/Identifier; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerWallPlant (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerShulkerBox (Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerPlantPart (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/data/client/BlockStateModelGenerator$TintType;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerBed (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerRoots (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator addJigsawOrientationToVariant (Lnet/minecraft/block/enums/JigsawOrientation;Lnet/minecraft/data/client/BlockStateVariant;)Lnet/minecraft/data/client/BlockStateVariant; +transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCandle (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator applyExplosionDecay (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/function/LootFunctionConsumingBuilder;)Ljava/lang/Object; transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator addSurvivesExplosionCondition (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/condition/LootConditionConsumingBuilder;)Ljava/lang/Object; transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator drops (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; diff --git a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java index fc19a1fdb..bb8c6e0e6 100644 --- a/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java +++ b/fabric-data-generation-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java @@ -26,10 +26,11 @@ import java.util.function.Consumer; import net.minecraft.advancement.Advancement; import net.minecraft.advancement.AdvancementFrame; import net.minecraft.advancement.criterion.OnKilledCriterion; +import net.minecraft.data.client.BlockStateModelGenerator; +import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder; +import net.minecraft.tag.TagKey; import net.minecraft.data.client.ItemModelGenerator; -import net.minecraft.data.client.model.BlockStateModelGenerator; import net.minecraft.data.server.recipe.RecipeJsonProvider; -import net.minecraft.data.server.recipe.ShapelessRecipeJsonFactory; import net.minecraft.item.Items; import net.minecraft.loot.LootPool; import net.minecraft.loot.LootTable; @@ -45,7 +46,6 @@ import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeKeys; -import net.minecraft.world.biome.BuiltinBiomes; import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; @@ -57,7 +57,6 @@ import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableProvider; import net.fabricmc.fabric.api.resource.conditions.v1.ConditionJsonProvider; import net.fabricmc.fabric.api.resource.conditions.v1.DefaultResourceConditions; -import net.fabricmc.fabric.api.tag.TagFactory; public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { private static final ConditionJsonProvider NEVER_LOADED = DefaultResourceConditions.allModsLoaded("a"); @@ -117,8 +116,8 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { @Override protected void generateRecipes(Consumer<RecipeJsonProvider> exporter) { - ShapelessRecipeJsonFactory.create(Items.GOLD_INGOT).input(Items.DIRT).criterion("has_dirt", conditionsFromItem(Items.DIRT)).offerTo(withConditions(exporter, NEVER_LOADED)); - ShapelessRecipeJsonFactory.create(Items.DIAMOND).input(Items.STICK).criterion("has_stick", conditionsFromItem(Items.STICK)).offerTo(withConditions(exporter, ALWAYS_LOADED)); + ShapelessRecipeJsonBuilder.create(Items.GOLD_INGOT).input(Items.DIRT).criterion("has_dirt", conditionsFromItem(Items.DIRT)).offerTo(withConditions(exporter, NEVER_LOADED)); + ShapelessRecipeJsonBuilder.create(Items.DIAMOND).input(Items.STICK).criterion("has_stick", conditionsFromItem(Items.STICK)).offerTo(withConditions(exporter, ALWAYS_LOADED)); } } @@ -170,12 +169,12 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { @Override protected void generateTags() { - FabricTagBuilder<Biome> builder = getOrCreateTagBuilder(TagFactory.BIOME.create(new Identifier(MOD_ID, "biome_tag_test"))) + FabricTagBuilder<Biome> builder = getOrCreateTagBuilder(TagKey.intern(Registry.BIOME_KEY, new Identifier(MOD_ID, "biome_tag_test"))) .add(BiomeKeys.BADLANDS, BiomeKeys.BAMBOO_JUNGLE) .add(BiomeKeys.BASALT_DELTAS); try { - builder.add(BuiltinBiomes.PLAINS); + builder.add(BuiltinRegistries.BIOME.get(BiomeKeys.PLAINS)); throw new AssertionError("Adding built-in entry to dynamic registry tag builder didn't throw an exception!"); } catch (UnsupportedOperationException e) { // no-op @@ -190,7 +189,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { @Override public void generateAdvancement(Consumer<Advancement> consumer) { - Advancement root = Advancement.Task.create() + Advancement root = Advancement.Builder.create() .display( SIMPLE_BLOCK, new TranslatableText("advancements.test.root.title"), @@ -200,7 +199,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint { false, false, false) .criterion("killed_something", OnKilledCriterion.Conditions.createPlayerKilledEntity()) .build(consumer, MOD_ID + ":test/root"); - Advancement rootNotLoaded = Advancement.Task.create() + Advancement rootNotLoaded = Advancement.Builder.create() .display( SIMPLE_BLOCK, new TranslatableText("advancements.test.root_not_loaded.title"), diff --git a/fabric-data-generation-api-v1/template.accesswidener b/fabric-data-generation-api-v1/template.accesswidener index 5a88b3189..6943da23d 100644 --- a/fabric-data-generation-api-v1/template.accesswidener +++ b/fabric-data-generation-api-v1/template.accesswidener @@ -1,6 +1,6 @@ accessWidener v2 named -accessible field net/minecraft/data/server/RecipesProvider root Lnet/minecraft/data/DataGenerator; +accessible field net/minecraft/data/server/RecipeProvider root Lnet/minecraft/data/DataGenerator; extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder <init> (Lnet/minecraft/tag/Tag$Builder;Lnet/minecraft/util/registry/Registry;Ljava/lang/String;)V extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder add ([Ljava/lang/Object;)Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder; @@ -14,12 +14,12 @@ accessible field net/minecraft/data/server/BlockLootTableGenerator lootTabl transitive-accessible method net/minecraft/data/family/BlockFamilies register (Lnet/minecraft/block/Block;)Lnet/minecraft/data/family/BlockFamily$Builder; -transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/data/client/model/Model;)V -transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/data/client/model/Model;)V -transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Ljava/lang/String;Lnet/minecraft/data/client/model/Model;)V +transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/data/client/Model;)V +transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/data/client/Model;)V +transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Ljava/lang/String;Lnet/minecraft/data/client/Model;)V -transitive-accessible field net/minecraft/data/client/model/BlockStateModelGenerator blockStateCollector Ljava/util/function/Consumer; -transitive-accessible field net/minecraft/data/client/model/BlockStateModelGenerator modelCollector Ljava/util/function/BiConsumer; +transitive-accessible field net/minecraft/data/client/BlockStateModelGenerator blockStateCollector Ljava/util/function/Consumer; +transitive-accessible field net/minecraft/data/client/BlockStateModelGenerator modelCollector Ljava/util/function/BiConsumer; -transitive-accessible method net/minecraft/data/client/model/TextureKey of (Ljava/lang/String;)Lnet/minecraft/data/client/model/TextureKey; -transitive-accessible method net/minecraft/data/client/model/TextureKey of (Ljava/lang/String;Lnet/minecraft/data/client/model/TextureKey;)Lnet/minecraft/data/client/model/TextureKey; +transitive-accessible method net/minecraft/data/client/TextureKey of (Ljava/lang/String;)Lnet/minecraft/data/client/TextureKey; +transitive-accessible method net/minecraft/data/client/TextureKey of (Ljava/lang/String;Lnet/minecraft/data/client/TextureKey;)Lnet/minecraft/data/client/TextureKey; diff --git a/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/ServerBugfixMixin.java b/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/ServerBugfixMixin.java index 3eac05d32..68fe93409 100644 --- a/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/ServerBugfixMixin.java +++ b/fabric-dimensions-v1/src/main/java/net/fabricmc/fabric/mixin/dimension/ServerBugfixMixin.java @@ -16,22 +16,9 @@ package net.fabricmc.fabric.mixin.dimension; -import com.mojang.serialization.Lifecycle; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.Redirect; -import net.minecraft.nbt.NbtElement; -import net.minecraft.resource.DataPackSettings; import net.minecraft.server.Main; -import net.minecraft.util.dynamic.RegistryOps; -import net.minecraft.util.registry.DynamicRegistryManager; -import net.minecraft.world.gen.GeneratorOptions; -import net.minecraft.world.level.LevelInfo; -import net.minecraft.world.level.LevelProperties; -import net.minecraft.world.level.storage.LevelStorage; /** * This Mixin aims to solve a Minecraft Vanilla bug where datapacks are ignored during creation of the @@ -52,41 +39,5 @@ import net.minecraft.world.level.storage.LevelStorage; */ @Mixin(value = Main.class) public class ServerBugfixMixin { - @Unique - private static LevelStorage.Session fabric_session; - - @Unique - private static DynamicRegistryManager.Impl fabric_dynamicRegistry; - - @Unique - private static RegistryOps<NbtElement> fabric_registryOps; - - @ModifyVariable(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/registry/DynamicRegistryManager;create()Lnet/minecraft/util/registry/DynamicRegistryManager$Impl;"), method = "main", allow = 1) - private static DynamicRegistryManager.Impl captureDynamicRegistry(DynamicRegistryManager.Impl value) { - fabric_dynamicRegistry = value; - return value; - } - - @ModifyVariable(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/storage/LevelStorage;createSession(Ljava/lang/String;)Lnet/minecraft/world/level/storage/LevelStorage$Session;"), method = "main", allow = 1) - private static LevelStorage.Session captureSession(LevelStorage.Session value) { - fabric_session = value; - return value; - } - - @ModifyVariable(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/dynamic/RegistryOps;ofLoaded(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/registry/DynamicRegistryManager;)Lnet/minecraft/util/dynamic/RegistryOps;"), method = "main", allow = 1) - private static RegistryOps<NbtElement> captureRegistryOps(RegistryOps<NbtElement> value) { - fabric_registryOps = value; - return value; - } - - @Redirect(method = "main", at = @At(value = "NEW", target = "net/minecraft/world/level/LevelProperties"), allow = 1) - private static LevelProperties onCreateNewLevelProperties(LevelInfo levelInfo, GeneratorOptions generatorOptions, Lifecycle lifecycle) { - DataPackSettings dataPackSettings = levelInfo.getDataPackSettings(); - - // Save the level.dat file - fabric_session.backupLevelDataFile(fabric_dynamicRegistry, new LevelProperties(levelInfo, generatorOptions, lifecycle)); - - // And reload it again, and replace the actual level properties with it - return (LevelProperties) fabric_session.readLevelProperties(fabric_registryOps, dataPackSettings); - } + // TODO fix me 22w06a } diff --git a/fabric-dimensions-v1/src/main/resources/fabric.mod.json b/fabric-dimensions-v1/src/main/resources/fabric.mod.json index b4966c895..27e7d0b54 100644 --- a/fabric-dimensions-v1/src/main/resources/fabric.mod.json +++ b/fabric-dimensions-v1/src/main/resources/fabric.mod.json @@ -15,7 +15,7 @@ "FabricMC" ], "depends": { - "fabricloader": ">=0.4.0", + "fabricloader": ">=0.12.0", "minecraft": ">=1.16-rc.3", "fabric-api-base": "*" }, diff --git a/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/FabricDimensionTest.java b/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/FabricDimensionTest.java index 9fe2294e8..6cd338918 100644 --- a/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/FabricDimensionTest.java +++ b/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/FabricDimensionTest.java @@ -74,6 +74,11 @@ public class FabricDimensionTest implements ModInitializer { } ServerLifecycleEvents.SERVER_STARTED.register(server -> { + if (true) { + // TODO 22w06a ServerBugfixMixin + return; + } + ServerWorld overworld = server.getWorld(World.OVERWORLD); ServerWorld world = server.getWorld(WORLD_KEY); diff --git a/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/VoidChunkGenerator.java b/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/VoidChunkGenerator.java index 53c07d3de..2eb5696aa 100644 --- a/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/VoidChunkGenerator.java +++ b/fabric-dimensions-v1/src/testmod/java/net/fabricmc/fabric/test/dimension/VoidChunkGenerator.java @@ -23,7 +23,6 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.block.BlockState; -import net.minecraft.world.gen.chunk.Blender; import net.minecraft.world.ChunkRegion; import net.minecraft.world.HeightLimitView; import net.minecraft.world.Heightmap; @@ -33,9 +32,10 @@ import net.minecraft.world.biome.source.util.MultiNoiseUtil; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.StructureAccessor; +import net.minecraft.world.gen.chunk.Blender; import net.minecraft.world.gen.chunk.ChunkGenerator; -import net.minecraft.world.gen.chunk.StructuresConfig; import net.minecraft.world.gen.chunk.VerticalBlockSample; +import net.minecraft.world.gen.chunk.placement.StructuresConfig; public class VoidChunkGenerator extends ChunkGenerator { // Just an example of adding a custom boolean diff --git a/fabric-dimensions-v1/src/testmod/resources/data/fabric_dimension/dimension_type/void_type.json b/fabric-dimensions-v1/src/testmod/resources/data/fabric_dimension/dimension_type/void_type.json index 23731ec3f..560a019fd 100644 --- a/fabric-dimensions-v1/src/testmod/resources/data/fabric_dimension/dimension_type/void_type.json +++ b/fabric-dimensions-v1/src/testmod/resources/data/fabric_dimension/dimension_type/void_type.json @@ -5,7 +5,7 @@ "ambient_light": 0.1, "has_skylight": true, "has_ceiling": false, - "infiniburn": "minecraft:infiniburn_overworld", + "infiniburn": "#minecraft:infiniburn_overworld", "logical_height" : 256, "has_raids" : false, "respawn_anchor_works": false, diff --git a/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/impl/gametest/FabricGameTestHelper.java b/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/impl/gametest/FabricGameTestHelper.java index ebe8a6ada..73f24116c 100644 --- a/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/impl/gametest/FabricGameTestHelper.java +++ b/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/impl/gametest/FabricGameTestHelper.java @@ -25,11 +25,10 @@ import java.util.function.Consumer; import javax.xml.parsers.ParserConfigurationException; -import org.slf4j.LoggerFactory; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import net.minecraft.resource.ResourcePackManager; -import net.minecraft.resource.ServerResourceManager; import net.minecraft.server.MinecraftServer; import net.minecraft.test.GameTestBatch; import net.minecraft.test.TestContext; @@ -40,7 +39,6 @@ import net.minecraft.test.TestServer; import net.minecraft.test.TestUtil; import net.minecraft.test.XmlReportingTestCompletionListener; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.level.storage.LevelStorage; import net.fabricmc.fabric.api.gametest.v1.FabricGameTest; @@ -53,7 +51,7 @@ public final class FabricGameTestHelper { private FabricGameTestHelper() { } - public static void runHeadlessServer(LevelStorage.Session session, ResourcePackManager resourcePackManager, ServerResourceManager serverResourceManager, DynamicRegistryManager.Impl registryManager) { + public static void runHeadlessServer(LevelStorage.Session session, ResourcePackManager resourcePackManager) { String reportPath = System.getProperty("fabric-api.gametest.report-file"); if (reportPath != null) { @@ -66,8 +64,7 @@ public final class FabricGameTestHelper { LOGGER.info("Starting test server"); MinecraftServer server = TestServer.startServer(thread -> { - TestServer testServer = new TestServer(thread, session, resourcePackManager, serverResourceManager, getBatches(), BlockPos.ORIGIN, registryManager); - return testServer; + return TestServer.create(thread, session, resourcePackManager, getBatches(), BlockPos.ORIGIN); }); } diff --git a/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/server/MainMixin.java b/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/server/MainMixin.java index ffd6f47dd..e55fc4239 100644 --- a/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/server/MainMixin.java +++ b/fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest/server/MainMixin.java @@ -18,7 +18,6 @@ package net.fabricmc.fabric.mixin.gametest.server; import java.io.File; import java.nio.file.Path; -import java.util.concurrent.CompletableFuture; import com.mojang.authlib.GameProfileRepository; import com.mojang.authlib.minecraft.MinecraftSessionService; @@ -33,15 +32,14 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import net.minecraft.resource.DataPackSettings; +import net.minecraft.class_6904; import net.minecraft.resource.ResourcePackManager; -import net.minecraft.resource.ServerResourceManager; import net.minecraft.server.Main; import net.minecraft.server.dedicated.EulaReader; import net.minecraft.server.dedicated.ServerPropertiesLoader; import net.minecraft.util.UserCache; -import net.minecraft.util.dynamic.RegistryOps; import net.minecraft.util.registry.DynamicRegistryManager; +import net.minecraft.world.SaveProperties; import net.minecraft.world.level.storage.LevelStorage; import net.minecraft.world.level.storage.LevelSummary; @@ -54,10 +52,10 @@ public class MainMixin { return FabricGameTestHelper.ENABLED || reader.isEulaAgreedTo(); } - @Inject(method = "main", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/LevelStorage$Session;readLevelProperties(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/resource/DataPackSettings;)Lnet/minecraft/world/SaveProperties;")) - private static void main(String[] args, CallbackInfo info, OptionParser optionParser, OptionSpec o1, OptionSpec o2, OptionSpec o3, OptionSpec o4, OptionSpec o5, OptionSpec o6, OptionSpec o7, OptionSpec o8, OptionSpec o9, OptionSpec o10, OptionSpec o11, OptionSpec o12, OptionSpec o13, OptionSpec o14, OptionSpec o15, OptionSet optionSet, DynamicRegistryManager.Impl impl, Path path, ServerPropertiesLoader serverPropertiesLoader, Path path2, EulaReader eulaReader, File file, YggdrasilAuthenticationService yggdrasilAuthenticationService, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, UserCache userCache, String string, LevelStorage levelStorage, LevelStorage.Session session, LevelSummary levelSummary, DataPackSettings dataPackSettings, boolean bl, ResourcePackManager resourcePackManager, DataPackSettings dataPackSettings2, CompletableFuture completableFuture, ServerResourceManager serverResourceManager, RegistryOps registryOps) { + @Inject(method = "main", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;startServer(Ljava/util/function/Function;)Lnet/minecraft/server/MinecraftServer;")) + private static void main(String[] args, CallbackInfo info, OptionParser optionParser, OptionSpec optionSpec, OptionSpec optionSpec2, OptionSpec optionSpec3, OptionSpec optionSpec4, OptionSpec optionSpec5, OptionSpec optionSpec6, OptionSpec optionSpec7, OptionSpec optionSpec8, OptionSpec optionSpec9, OptionSpec optionSpec10, OptionSpec optionSpec11, OptionSpec optionSpec12, OptionSpec optionSpec13, OptionSpec optionSpec14, OptionSpec optionSpec15, OptionSet optionSet, Path path, ServerPropertiesLoader serverPropertiesLoader, Path path2, EulaReader eulaReader, File file, YggdrasilAuthenticationService yggdrasilAuthenticationService, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, UserCache userCache, String string, LevelStorage levelStorage, LevelStorage.Session session, LevelSummary levelSummary, boolean bl, ResourcePackManager resourcePackManager, class_6904 lv2, DynamicRegistryManager.class_6890 lv3, SaveProperties saveProperties) { if (FabricGameTestHelper.ENABLED) { - FabricGameTestHelper.runHeadlessServer(session, resourcePackManager, serverResourceManager, impl); + FabricGameTestHelper.runHeadlessServer(session, resourcePackManager); info.cancel(); // Do not progress in starting the normal dedicated server } } diff --git a/fabric-lifecycle-events-v1/build.gradle b/fabric-lifecycle-events-v1/build.gradle index 16b42c905..8a6959fb9 100644 --- a/fabric-lifecycle-events-v1/build.gradle +++ b/fabric-lifecycle-events-v1/build.gradle @@ -1,6 +1,10 @@ archivesBaseName = "fabric-lifecycle-events-v1" version = getSubprojectVersion(project) +loom { + accessWidenerPath = file("src/main/resources/fabric-lifecycle-events-v1.accesswidener") +} + moduleDependencies(project, [ 'fabric-api-base' ]) diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MinecraftServerMixin.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MinecraftServerMixin.java index 229c20cb8..71b272a98 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MinecraftServerMixin.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MinecraftServerMixin.java @@ -42,7 +42,7 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents; @Mixin(MinecraftServer.class) public abstract class MinecraftServerMixin { @Shadow - private ServerResourceManager serverResourceManager; + private MinecraftServer.class_6897 serverResourceManager; @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setupServer()Z"), method = "runServer") private void beforeSetupServer(CallbackInfo info) { @@ -91,14 +91,14 @@ public abstract class MinecraftServerMixin { @Inject(method = "reloadResources", at = @At("HEAD")) private void startResourceReload(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> cir) { - ServerLifecycleEvents.START_DATA_PACK_RELOAD.invoker().startDataPackReload((MinecraftServer) (Object) this, this.serverResourceManager); + ServerLifecycleEvents.START_DATA_PACK_RELOAD.invoker().startDataPackReload((MinecraftServer) (Object) this, (ServerResourceManager) this.serverResourceManager.resourceManager()); } @Inject(method = "reloadResources", at = @At("TAIL")) private void endResourceReload(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> cir) { cir.getReturnValue().handleAsync((value, throwable) -> { // Hook into fail - ServerLifecycleEvents.END_DATA_PACK_RELOAD.invoker().endDataPackReload((MinecraftServer) (Object) this, this.serverResourceManager, throwable == null); + ServerLifecycleEvents.END_DATA_PACK_RELOAD.invoker().endDataPackReload((MinecraftServer) (Object) this, (ServerResourceManager) this.serverResourceManager.resourceManager(), throwable == null); return value; }, (MinecraftServer) (Object) this); } diff --git a/fabric-lifecycle-events-v1/src/main/resources/fabric-lifecycle-events-v1.accesswidener b/fabric-lifecycle-events-v1/src/main/resources/fabric-lifecycle-events-v1.accesswidener new file mode 100644 index 000000000..25d555080 --- /dev/null +++ b/fabric-lifecycle-events-v1/src/main/resources/fabric-lifecycle-events-v1.accesswidener @@ -0,0 +1,3 @@ +accessWidener v2 named + +accessible class net/minecraft/server/MinecraftServer$class_6897 diff --git a/fabric-lifecycle-events-v1/src/main/resources/fabric.mod.json b/fabric-lifecycle-events-v1/src/main/resources/fabric.mod.json index 05ce7a7f7..139083d4c 100644 --- a/fabric-lifecycle-events-v1/src/main/resources/fabric.mod.json +++ b/fabric-lifecycle-events-v1/src/main/resources/fabric.mod.json @@ -33,5 +33,6 @@ "description": "Events for the game's lifecycle.", "custom": { "fabric-api:module-lifecycle": "stable" - } + }, + "accessWidener": "fabric-lifecycle-events-v1.accesswidener" } diff --git a/fabric-mining-level-api-v1/build.gradle b/fabric-mining-level-api-v1/build.gradle index e4d63320f..8230fc30c 100644 --- a/fabric-mining-level-api-v1/build.gradle +++ b/fabric-mining-level-api-v1/build.gradle @@ -3,8 +3,7 @@ version = getSubprojectVersion(project) moduleDependencies(project, [ 'fabric-api-base', - 'fabric-resource-loader-v0', - 'fabric-tag-extensions-v0' + 'fabric-resource-loader-v0' ]) dependencies { diff --git a/fabric-mining-level-api-v1/src/main/java/net/fabricmc/fabric/api/mininglevel/v1/FabricMineableTags.java b/fabric-mining-level-api-v1/src/main/java/net/fabricmc/fabric/api/mininglevel/v1/FabricMineableTags.java index 9b9a07631..b7454d81b 100644 --- a/fabric-mining-level-api-v1/src/main/java/net/fabricmc/fabric/api/mininglevel/v1/FabricMineableTags.java +++ b/fabric-mining-level-api-v1/src/main/java/net/fabricmc/fabric/api/mininglevel/v1/FabricMineableTags.java @@ -17,10 +17,9 @@ package net.fabricmc.fabric.api.mininglevel.v1; import net.minecraft.block.Block; -import net.minecraft.tag.Tag; +import net.minecraft.tag.TagKey; import net.minecraft.util.Identifier; - -import net.fabricmc.fabric.api.tag.TagFactory; +import net.minecraft.util.registry.Registry; /** * Defines additional {@code mineable} tags for vanilla tools not covered by vanilla. @@ -36,17 +35,17 @@ public final class FabricMineableTags { * <p>As swords have materials and mining levels, the mining level tags described in * {@link MiningLevelManager} also apply. */ - public static final Tag.Identified<Block> SWORD_MINEABLE = register("mineable/sword"); + public static final TagKey<Block> SWORD_MINEABLE = register("mineable/sword"); /** * Blocks in this tag ({@code #fabric:mineable/shears}) can be effectively mined with shears. */ - public static final Tag.Identified<Block> SHEARS_MINEABLE = register("mineable/shears"); + public static final TagKey<Block> SHEARS_MINEABLE = register("mineable/shears"); private FabricMineableTags() { } - private static Tag.Identified<Block> register(String id) { - return TagFactory.BLOCK.create(new Identifier("fabric", id)); + private static TagKey<Block> register(String id) { + return TagKey.intern(Registry.BLOCK_KEY, new Identifier("fabric", id)); } } diff --git a/fabric-mining-level-api-v1/src/main/java/net/fabricmc/fabric/impl/mininglevel/MiningLevelManagerImpl.java b/fabric-mining-level-api-v1/src/main/java/net/fabricmc/fabric/impl/mininglevel/MiningLevelManagerImpl.java index d0b2105b9..e4ff5eaaf 100644 --- a/fabric-mining-level-api-v1/src/main/java/net/fabricmc/fabric/impl/mininglevel/MiningLevelManagerImpl.java +++ b/fabric-mining-level-api-v1/src/main/java/net/fabricmc/fabric/impl/mininglevel/MiningLevelManagerImpl.java @@ -21,14 +21,13 @@ import java.util.regex.Pattern; import it.unimi.dsi.fastutil.objects.Reference2IntMap; import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; -import org.slf4j.LoggerFactory; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.tag.TagKey; import net.minecraft.tag.BlockTags; -import net.minecraft.tag.TagGroup; -import net.minecraft.util.Identifier; import net.fabricmc.yarn.constants.MiningLevels; @@ -44,16 +43,15 @@ public final class MiningLevelManagerImpl { public static int getRequiredMiningLevel(BlockState state) { return CACHE.get().computeIntIfAbsent(state, s -> { - TagGroup<Block> blockTags = BlockTags.getTagGroup(); int miningLevel = MiningLevels.HAND; // Handle #fabric:needs_tool_level_N - for (Identifier tagId : blockTags.getTagsFor(state.getBlock())) { - if (!tagId.getNamespace().equals(TOOL_TAG_NAMESPACE)) { + for (TagKey<Block> tagId : state.method_40144().toList()) { + if (!tagId.id().getNamespace().equals(TOOL_TAG_NAMESPACE)) { continue; } - Matcher matcher = TOOL_TAG_PATTERN.matcher(tagId.getPath()); + Matcher matcher = TOOL_TAG_PATTERN.matcher(tagId.id().getPath()); if (matcher.matches()) { try { diff --git a/fabric-mining-level-api-v1/src/main/resources/fabric.mod.json b/fabric-mining-level-api-v1/src/main/resources/fabric.mod.json index a976c6fdc..7dc6e60c9 100644 --- a/fabric-mining-level-api-v1/src/main/resources/fabric.mod.json +++ b/fabric-mining-level-api-v1/src/main/resources/fabric.mod.json @@ -23,8 +23,7 @@ "depends": { "fabricloader": ">=0.4.0", "fabric-api-base": "*", - "fabric-resource-loader-v0": "*", - "fabric-tag-extensions-v0": "*" + "fabric-resource-loader-v0": "*" }, "description": "Adds support for custom mining levels.", "mixins": [ diff --git a/fabric-mining-levels-v0/build.gradle b/fabric-mining-levels-v0/build.gradle deleted file mode 100644 index b9d19b94a..000000000 --- a/fabric-mining-levels-v0/build.gradle +++ /dev/null @@ -1,8 +0,0 @@ -archivesBaseName = "fabric-mining-levels-v0" -version = getSubprojectVersion(project) - -moduleDependencies(project, [ - 'fabric-api-base', - 'fabric-tag-extensions-v0', - 'fabric-tool-attribute-api-v1' -]) diff --git a/fabric-mining-levels-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricItemTags.java b/fabric-mining-levels-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricItemTags.java deleted file mode 100644 index ae6cc17ad..000000000 --- a/fabric-mining-levels-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricItemTags.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tag; - -import net.minecraft.item.Item; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; - -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; - -/** - * Item tags provided by Fabric. - * - * @deprecated Use dedicated classes, such as {@link FabricToolTags} - */ -@Deprecated -public class FabricItemTags { - public static final Tag<Item> AXES = FabricToolTags.AXES; - public static final Tag<Item> HOES = FabricToolTags.HOES; - public static final Tag<Item> PICKAXES = FabricToolTags.PICKAXES; - public static final Tag<Item> SHOVELS = FabricToolTags.SHOVELS; - public static final Tag<Item> SWORDS = FabricToolTags.SWORDS; - - private FabricItemTags() { } - - private static Tag<Item> register(String id) { - return TagRegistry.item(new Identifier("fabric", id)); - } -} diff --git a/fabric-mining-levels-v0/src/main/java/net/fabricmc/fabric/api/tools/FabricToolTags.java b/fabric-mining-levels-v0/src/main/java/net/fabricmc/fabric/api/tools/FabricToolTags.java deleted file mode 100644 index 62aa3684f..000000000 --- a/fabric-mining-levels-v0/src/main/java/net/fabricmc/fabric/api/tools/FabricToolTags.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tools; - -import net.minecraft.item.Item; -import net.minecraft.tag.Tag; - -/** - * Tool item tags provided by Fabric. - * - * @deprecated Use the moved {@link net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags} class instead - */ -@Deprecated -public class FabricToolTags { - public static final Tag<Item> AXES = net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags.AXES; - public static final Tag<Item> HOES = net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags.HOES; - public static final Tag<Item> PICKAXES = net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags.PICKAXES; - public static final Tag<Item> SHOVELS = net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags.SHOVELS; - public static final Tag<Item> SWORDS = net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags.SWORDS; - - private FabricToolTags() { } -} diff --git a/fabric-mining-levels-v0/src/main/resources/assets/fabric-mining-levels-v0/icon.png b/fabric-mining-levels-v0/src/main/resources/assets/fabric-mining-levels-v0/icon.png deleted file mode 100644 index 2931efbf6..000000000 Binary files a/fabric-mining-levels-v0/src/main/resources/assets/fabric-mining-levels-v0/icon.png and /dev/null differ diff --git a/fabric-mining-levels-v0/src/main/resources/fabric.mod.json b/fabric-mining-levels-v0/src/main/resources/fabric.mod.json deleted file mode 100644 index c7bfd8097..000000000 --- a/fabric-mining-levels-v0/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "schemaVersion": 1, - "id": "fabric-mining-levels-v0", - "name": "Fabric Mining Levels (v0)", - "version": "${version}", - "environment": "*", - "license": "Apache-2.0", - "icon": "assets/fabric-mining-levels-v0/icon.png", - "contact": { - "homepage": "https://fabricmc.net", - "irc": "irc://irc.esper.net:6667/fabric", - "issues": "https://github.com/FabricMC/fabric/issues", - "sources": "https://github.com/FabricMC/fabric" - }, - "authors": [ - "FabricMC" - ], - "depends": { - "fabricloader": ">=0.4.0", - "fabric-api-base": "*", - "fabric-tag-extensions-v0": "*", - "fabric-tool-attribute-api-v1": "*" - }, - "description": "Block mining level tags for tools. Deprecated and replaced by fabric-tool-attribute-v1.", - "custom": { - "fabric-api:module-lifecycle": "deprecated" - } -} diff --git a/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/channeltest/ChannelScreen.java b/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/channeltest/ChannelScreen.java index fabecb18f..0bcf6a4ba 100644 --- a/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/channeltest/ChannelScreen.java +++ b/fabric-networking-api-v1/src/testmod/java/net/fabricmc/fabric/test/networking/channeltest/ChannelScreen.java @@ -46,7 +46,7 @@ final class ChannelScreen extends Screen { this.c2sButton = this.addDrawableChild(new ButtonWidget(this.width / 2 + 5, 5, 50, 20, new LiteralText("C2S"), this::toC2S, (button, matrices, mouseX, mouseY) -> { this.renderTooltip(matrices, new LiteralText("Packets the server can receive"), mouseX, mouseY); })); - this.closeButton = this.addDrawableChild(new ButtonWidget(this.width / 2 - 60, this.height - 25, 120, 20, new LiteralText("Close"), button -> this.onClose())); + this.closeButton = this.addDrawableChild(new ButtonWidget(this.width / 2 - 60, this.height - 25, 120, 20, new LiteralText("Close"), button -> this.close())); this.channelList = this.addDrawable(new ChannelList(this.client, this.width, this.height - 60, 30, this.height - 30, this.textRenderer.fontHeight + 2)); } diff --git a/fabric-object-builder-api-v1/build.gradle b/fabric-object-builder-api-v1/build.gradle index d814b477e..9cb38d9f0 100644 --- a/fabric-object-builder-api-v1/build.gradle +++ b/fabric-object-builder-api-v1/build.gradle @@ -7,9 +7,7 @@ dependencies { moduleDependencies(project, [ 'fabric-api-base', - 'fabric-resource-loader-v0', - 'fabric-tag-extensions-v0', - 'fabric-tool-attribute-api-v1' + 'fabric-resource-loader-v0' ]) loom { diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java index f64a824cd..0a48998a8 100644 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java +++ b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/block/FabricBlockSettings.java @@ -24,14 +24,10 @@ import net.minecraft.block.BlockState; import net.minecraft.block.MapColor; import net.minecraft.block.Material; import net.minecraft.entity.EntityType; -import net.minecraft.item.Item; import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.tag.Tag; import net.minecraft.util.DyeColor; import net.minecraft.util.Identifier; -import net.fabricmc.fabric.impl.object.builder.BlockSettingsInternals; -import net.fabricmc.fabric.impl.object.builder.FabricBlockInternals; import net.fabricmc.fabric.mixin.object.builder.AbstractBlockAccessor; import net.fabricmc.fabric.mixin.object.builder.AbstractBlockSettingsAccessor; @@ -68,14 +64,6 @@ public class FabricBlockSettings extends AbstractBlock.Settings { thisAccessor.setOpaque(otherAccessor.getOpaque()); thisAccessor.setIsAir(otherAccessor.getIsAir()); thisAccessor.setToolRequired(otherAccessor.isToolRequired()); - - // Now attempt to copy fabric specific data - BlockSettingsInternals otherInternals = (BlockSettingsInternals) settings; - FabricBlockInternals.ExtraData extraData = otherInternals.getExtraData(); - - if (extraData != null) { // If present, populate the extra data on our new settings - ((BlockSettingsInternals) this).setExtraData(extraData); - } } public static FabricBlockSettings of(Material material) { @@ -301,37 +289,4 @@ public class FabricBlockSettings extends AbstractBlock.Settings { ((AbstractBlockSettingsAccessor) this).setCollidable(collidable); return this; } - - /* FABRIC HELPERS */ - - /** - * Makes the block breakable by any tool if {@code breakByHand} is set to true. - */ - public FabricBlockSettings breakByHand(boolean breakByHand) { - FabricBlockInternals.computeExtraData(this).breakByHand(breakByHand); - return this; - } - - /** - * Please make the block require a tool if you plan to disable drops and slow the breaking down using the - * incorrect tool by using {@link FabricBlockSettings#requiresTool()}. - * - * @deprecated Replaced by {@code mineable} tags. See fabric-mining-level-api-v1 for further details. - */ - @Deprecated(forRemoval = true) - public FabricBlockSettings breakByTool(Tag<Item> tag, int miningLevel) { - FabricBlockInternals.computeExtraData(this).addMiningLevel(tag, miningLevel); - return this; - } - - /** - * Please make the block require a tool if you plan to disable drops and slow the breaking down using the - * incorrect tool by using {@link FabricBlockSettings#requiresTool()}. - * - * @deprecated Replaced by {@code mineable} tags. See fabric-mining-level-api-v1 for further details.S - */ - @Deprecated(forRemoval = true) - public FabricBlockSettings breakByTool(Tag<Item> tag) { - return this.breakByTool(tag, 0); - } } diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/BlockSettingsInternals.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/BlockSettingsInternals.java deleted file mode 100644 index 5a1687532..000000000 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/BlockSettingsInternals.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.object.builder; - -public interface BlockSettingsInternals { - FabricBlockInternals.ExtraData getExtraData(); - - void setExtraData(FabricBlockInternals.ExtraData extraData); -} diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricBlockInternals.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricBlockInternals.java deleted file mode 100644 index 826a4eaf3..000000000 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/impl/object/builder/FabricBlockInternals.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.object.builder; - -import java.util.ArrayList; -import java.util.List; - -import org.jetbrains.annotations.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.tag.Tag; - -import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; - -public final class FabricBlockInternals { - private FabricBlockInternals() { - } - - public static ExtraData computeExtraData(Block.Settings settings) { - BlockSettingsInternals internals = (BlockSettingsInternals) settings; - - if (internals.getExtraData() == null) { - internals.setExtraData(new ExtraData(settings)); - } - - return internals.getExtraData(); - } - - public static void onBuild(Block.Settings settings, Block block) { - // TODO: Load only if fabric-tool-attribute-api present - ExtraData data = ((BlockSettingsInternals) settings).getExtraData(); - - if (data != null) { - if (data.breakByHand != null) { - ToolManagerImpl.entry(block).setBreakByHand(data.breakByHand); - } - - for (MiningLevel tml : data.miningLevels) { - ToolManagerImpl.entry(block).putBreakByTool(tml.tag, tml.level); - } - } - } - - public static final class ExtraData { - private final List<MiningLevel> miningLevels = new ArrayList<>(); - @Nullable - private Boolean breakByHand; - - public ExtraData(Block.Settings settings) { - } - - public void breakByHand(boolean breakByHand) { - this.breakByHand = breakByHand; - } - - public void addMiningLevel(Tag<Item> tag, int level) { - miningLevels.add(new MiningLevel(tag, level)); - } - } - - public static final class MiningLevel { - private final Tag<Item> tag; - private final int level; - - MiningLevel(Tag<Item> tag, int level) { - this.tag = tag; - this.level = level; - } - } -} diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsMixin.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsMixin.java deleted file mode 100644 index 8b3b36be5..000000000 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/AbstractBlockSettingsMixin.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.object.builder; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -import net.minecraft.block.AbstractBlock; - -import net.fabricmc.fabric.impl.object.builder.BlockSettingsInternals; -import net.fabricmc.fabric.impl.object.builder.FabricBlockInternals; - -@Mixin(AbstractBlock.Settings.class) -public abstract class AbstractBlockSettingsMixin implements BlockSettingsInternals { - @Unique - private FabricBlockInternals.ExtraData fabricExtraData; - - @Override - public FabricBlockInternals.ExtraData getExtraData() { - return this.fabricExtraData; - } - - @Override - public void setExtraData(FabricBlockInternals.ExtraData extraData) { - this.fabricExtraData = extraData; - } -} diff --git a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/MixinBlock.java b/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/MixinBlock.java deleted file mode 100644 index 72e114606..000000000 --- a/fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder/MixinBlock.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.object.builder; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import net.minecraft.block.Block; -import net.minecraft.block.AbstractBlock; - -import net.fabricmc.fabric.impl.object.builder.FabricBlockInternals; - -@Mixin(Block.class) -public abstract class MixinBlock { - @Inject(method = "<init>(Lnet/minecraft/block/AbstractBlock$Settings;)V", at = @At("RETURN")) - public void fabric_init(AbstractBlock.Settings builder, CallbackInfo info) { - FabricBlockInternals.onBuild(builder, (Block) (Object) this); - } -} diff --git a/fabric-object-builder-api-v1/src/main/resources/fabric-object-builder-v1.mixins.json b/fabric-object-builder-api-v1/src/main/resources/fabric-object-builder-v1.mixins.json index 25f89f21c..a97266dcf 100644 --- a/fabric-object-builder-api-v1/src/main/resources/fabric-object-builder-v1.mixins.json +++ b/fabric-object-builder-api-v1/src/main/resources/fabric-object-builder-v1.mixins.json @@ -5,13 +5,11 @@ "mixins": [ "AbstractBlockAccessor", "AbstractBlockSettingsAccessor", - "AbstractBlockSettingsMixin", "CriteriaAccessor", "DefaultAttributeRegistryAccessor", "DefaultAttributeRegistryMixin", "DetectorRailBlockMixin", "MaterialBuilderAccessor", - "MixinBlock", "PointOfInterestTypeAccessor", "SpawnRestrictionAccessor", "TypeAwareTradeMixin", diff --git a/fabric-object-builder-api-v1/src/main/resources/fabric.mod.json b/fabric-object-builder-api-v1/src/main/resources/fabric.mod.json index 6f07272be..156455342 100644 --- a/fabric-object-builder-api-v1/src/main/resources/fabric.mod.json +++ b/fabric-object-builder-api-v1/src/main/resources/fabric.mod.json @@ -17,8 +17,7 @@ ], "depends": { "fabricloader": ">=0.8.2", - "fabric-api-base": "*", - "fabric-tool-attribute-api-v1": "*" + "fabric-api-base": "*" }, "description": "Builders for objects vanilla has locked down.", "mixins": [ diff --git a/fabric-object-builders-v0/build.gradle b/fabric-object-builders-v0/build.gradle deleted file mode 100644 index 8b1e8a4cb..000000000 --- a/fabric-object-builders-v0/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -archivesBaseName = "fabric-object-builders" -version = getSubprojectVersion(project) - -moduleDependencies(project, [ - 'fabric-api-base', - 'fabric-object-builder-api-v1' -]) diff --git a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/block/BlockSettingsExtensions.java b/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/block/BlockSettingsExtensions.java deleted file mode 100644 index 39acdf381..000000000 --- a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/block/BlockSettingsExtensions.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.block; - -import net.minecraft.block.AbstractBlock.Settings; -import net.minecraft.block.MapColor; -import net.minecraft.item.Item; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; - -import net.fabricmc.fabric.impl.object.builder.FabricBlockInternals; -import net.fabricmc.fabric.mixin.object.builder.AbstractBlockSettingsAccessor; - -/** - * @deprecated Please migrate to v1. Please use methods in {@link net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings} instead. - */ -@Deprecated -public final class BlockSettingsExtensions { - private BlockSettingsExtensions() { - } - - public static void breakByHand(Settings settings, boolean breakByHand) { - FabricBlockInternals.computeExtraData(settings).breakByHand(breakByHand); - } - - public static void breakByTool(Settings settings, Tag<Item> tag, int miningLevel) { - FabricBlockInternals.computeExtraData(settings).addMiningLevel(tag, miningLevel); - } - - public static void hardness(Settings settings, float hardness) { - ((AbstractBlockSettingsAccessor) settings).setHardness(hardness); - } - - public static void resistance(Settings settings, float resistance) { - ((AbstractBlockSettingsAccessor) settings).setResistance(Math.max(0.0F, resistance)); - } - - public static void collidable(Settings settings, boolean collidable) { - ((AbstractBlockSettingsAccessor) settings).setCollidable(collidable); - } - - public static void materialColor(Settings settings, MapColor color) { - ((AbstractBlockSettingsAccessor) settings).setMapColorProvider(ignored -> color); - } - - public static void drops(Settings settings, Identifier dropTableId) { - ((AbstractBlockSettingsAccessor) settings).setLootTableId(dropTableId); - } - - public static void sounds(Settings settings, BlockSoundGroup soundGroup) { - ((AbstractBlockSettingsAccessor) settings).invokeSounds(soundGroup); - } - - public static void lightLevel(Settings settings, int lightLevel) { - ((AbstractBlockSettingsAccessor) settings).setLuminanceFunction(ignored -> lightLevel); - } - - public static void breakInstantly(Settings settings) { - ((AbstractBlockSettingsAccessor) settings).invokeBreakInstantly(); - } - - public static void strength(Settings settings, float strength) { - ((AbstractBlockSettingsAccessor) settings).invokeStrength(strength); - } - - public static void ticksRandomly(Settings settings) { - ((AbstractBlockSettingsAccessor) settings).invokeTicksRandomly(); - } - - public static void dynamicBounds(Settings settings) { - // Thanks Mixin - ((AbstractBlockSettingsAccessor) settings).setDynamicBounds(true); - } - - public static void dropsNothing(Settings settings) { - ((AbstractBlockSettingsAccessor) settings).invokeDropsNothing(); - } -} diff --git a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/block/FabricBlockSettings.java b/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/block/FabricBlockSettings.java deleted file mode 100644 index 3c9f8ed98..000000000 --- a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/block/FabricBlockSettings.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.block; - -import java.util.function.Function; - -import net.minecraft.block.Block; -import net.minecraft.block.MapColor; -import net.minecraft.block.Material; -import net.minecraft.item.Item; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.tag.Tag; -import net.minecraft.util.DyeColor; -import net.minecraft.util.Identifier; - -/** - * @deprecated Please migrate to v1. Please use {@link net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings} instead - */ -@Deprecated -public class FabricBlockSettings { - protected final net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings delegate; - - protected FabricBlockSettings(Material material, MapColor color) { - this(Block.Settings.of(material, color)); - } - - protected FabricBlockSettings(Block base) { - this(Block.Settings.copy(base)); - } - - protected FabricBlockSettings(final Block.Settings delegate) { - this.delegate = net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings.copyOf(delegate); - } - - public static FabricBlockSettings of(Material material) { - return of(material, material.getColor()); - } - - public static FabricBlockSettings of(Material material, MapColor color) { - return new FabricBlockSettings(material, color); - } - - public static FabricBlockSettings of(Material material, DyeColor color) { - return new FabricBlockSettings(material, color.getMapColor()); - } - - public static FabricBlockSettings copy(Block base) { - return new FabricBlockSettings(base); - } - - public static FabricBlockSettings copyOf(Block.Settings settings) { - return new FabricBlockSettings(settings); - } - - /* FABRIC HELPERS */ - - /** - * Makes the block breakable by any tool if {@code breakByHand} is set to true. - */ - public FabricBlockSettings breakByHand(boolean breakByHand) { - this.delegate.breakByHand(breakByHand); - return this; - } - - /** - * Please make the block require a tool if you plan to disable drops and slow the breaking down using the - * incorrect tool by using {@link net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings#requiresTool()}. - */ - public FabricBlockSettings breakByTool(Tag<Item> tag, int miningLevel) { - this.delegate.breakByTool(tag, miningLevel); - return this; - } - - /** - * Please make the block require a tool if you plan to disable drops and slow the breaking down using the - * incorrect tool by using {@link net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings#requiresTool()}. - */ - public FabricBlockSettings breakByTool(Tag<Item> tag) { - this.delegate.breakByTool(tag); - return this; - } - - /* DELEGATE WRAPPERS */ - - public FabricBlockSettings materialColor(MapColor color) { - this.delegate.materialColor(color); - return this; - } - - public FabricBlockSettings materialColor(DyeColor color) { - this.delegate.materialColor(color.getMapColor()); - return this; - } - - public FabricBlockSettings collidable(boolean collidable) { - this.delegate.collidable(collidable); - return this; - } - - public FabricBlockSettings noCollision() { - this.delegate.noCollision(); - return this; - } - - public FabricBlockSettings nonOpaque() { - this.delegate.nonOpaque(); - return this; - } - - public FabricBlockSettings sounds(BlockSoundGroup group) { - this.delegate.sounds(group); - return this; - } - - public FabricBlockSettings ticksRandomly() { - this.delegate.ticksRandomly(); - return this; - } - - public FabricBlockSettings lightLevel(int lightLevel) { - this.delegate.lightLevel(lightLevel); - return this; - } - - public FabricBlockSettings hardness(float hardness) { - this.delegate.hardness(hardness); - return this; - } - - public FabricBlockSettings resistance(float resistance) { - this.delegate.resistance(resistance); - return this; - } - - public FabricBlockSettings strength(float hardness, float resistance) { - this.delegate.strength(hardness, resistance); - return this; - } - - public FabricBlockSettings breakInstantly() { - this.delegate.breakInstantly(); - return this; - } - - public FabricBlockSettings dropsNothing() { - this.delegate.dropsNothing(); - return this; - } - - public FabricBlockSettings dropsLike(Block block) { - this.delegate.dropsLike(block); - return this; - } - - public FabricBlockSettings drops(Identifier dropTableId) { - this.delegate.drops(dropTableId); - return this; - } - - @Deprecated - public FabricBlockSettings friction(float friction) { - this.delegate.slipperiness(friction); - return this; - } - - public FabricBlockSettings slipperiness(float value) { - this.delegate.slipperiness(value); - return this; - } - - public FabricBlockSettings dynamicBounds() { - this.delegate.dynamicBounds(); - return this; - } - - /* BUILDING LOGIC */ - - public Block.Settings build() { - return this.delegate; - } - - public <T> T build(Function<Block.Settings, T> function) { - return function.apply(this.delegate); - } -} diff --git a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/block/FabricMaterialBuilder.java b/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/block/FabricMaterialBuilder.java deleted file mode 100644 index ab477d6f6..000000000 --- a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/block/FabricMaterialBuilder.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.block; - -import net.minecraft.block.MapColor; -import net.minecraft.block.Material; -import net.minecraft.block.piston.PistonBehavior; -import net.minecraft.util.DyeColor; - -/** - * @deprecated Please migrate to v1. Please use {@link net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder} instead. - */ -@Deprecated -public class FabricMaterialBuilder extends Material.Builder { - private net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder delegate; - - public FabricMaterialBuilder(MapColor color) { - super(color); - this.delegate = new net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder(color); - } - - public FabricMaterialBuilder(DyeColor color) { - this(color.getMapColor()); - } - - @Override - public FabricMaterialBuilder burnable() { - this.delegate.burnable(); - return this; - } - - public FabricMaterialBuilder pistonBehavior(PistonBehavior behavior) { - this.delegate.pistonBehavior(behavior); - return this; - } - - public FabricMaterialBuilder lightPassesThrough() { - this.delegate.lightPassesThrough(); - return this; - } - - @Override - public FabricMaterialBuilder destroyedByPiston() { - this.delegate.destroyedByPiston(); - return this; - } - - @Override - public FabricMaterialBuilder blocksPistons() { - this.delegate.blocksPistons(); - return this; - } - - @Override - public FabricMaterialBuilder allowsMovement() { - this.delegate.allowsMovement(); - return this; - } - - @Override - public FabricMaterialBuilder liquid() { - this.delegate.liquid(); - return this; - } - - @Override - public FabricMaterialBuilder notSolid() { - this.delegate.notSolid(); - return this; - } - - @Override - public FabricMaterialBuilder replaceable() { - this.delegate.replaceable(); - return this; - } - - @Override - public Material build() { - return this.delegate.build(); - } -} diff --git a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/entity/EntityTrackingRegistry.java b/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/entity/EntityTrackingRegistry.java deleted file mode 100644 index 45fb7231e..000000000 --- a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/entity/EntityTrackingRegistry.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.entity; - -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.LoggerFactory; -import org.slf4j.Logger; - -import net.minecraft.entity.EntityType; -import net.minecraft.util.registry.Registry; - -/** - * Registry for server->client entity tracking values. - * - * @deprecated Use FabricEntityTypeBuilder methods - */ -@SuppressWarnings("deprecation") -@Deprecated -public class EntityTrackingRegistry { - private static final Logger LOGGER = LoggerFactory.getLogger(EntityTrackingRegistry.class); - - @Deprecated - public static class Entry { - private final int trackingDistance; - private final int updateIntervalTicks; - private final boolean alwaysUpdateVelocity; - - public Entry(int trackingDistance, int updateIntervalTicks, boolean alwaysUpdateVelocity) { - this.trackingDistance = trackingDistance; - this.updateIntervalTicks = updateIntervalTicks; - this.alwaysUpdateVelocity = alwaysUpdateVelocity; - } - - public int getTrackingDistance() { - return trackingDistance; - } - - public int getUpdateIntervalTicks() { - return updateIntervalTicks; - } - - public boolean alwaysUpdateVelocity() { - return alwaysUpdateVelocity; - } - } - - @Deprecated - public static final EntityTrackingRegistry INSTANCE = new EntityTrackingRegistry(); - private final Map<EntityType, Entry> entries = new HashMap<>(); - - private EntityTrackingRegistry() { } - - @Deprecated - public Entry get(EntityType type) { - return entries.get(type); - } - - @Deprecated - public void register(EntityType type, int trackingDistance, int updateIntervalTicks) { - register(type, trackingDistance, updateIntervalTicks, true); - } - - @Deprecated - public void register(EntityType type, int trackingDistance, int updateIntervalTicks, boolean alwaysUpdateVelocity) { - LOGGER.warn("Deprecation warning: As of February 2019, registering tracking via EntityTrackingRegistry is no longer effective. Use FabricEntityTypeBuilder. (Entity: " + Registry.ENTITY_TYPE.getId(type) + ")"); - entries.put(type, new Entry(trackingDistance, updateIntervalTicks, alwaysUpdateVelocity)); - } -} diff --git a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/entity/FabricDefaultAttributeRegistry.java b/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/entity/FabricDefaultAttributeRegistry.java deleted file mode 100644 index ae7154c30..000000000 --- a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/entity/FabricDefaultAttributeRegistry.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.entity; - -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.DefaultAttributeContainer; - -/** - * @deprecated Please use {@link net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry} instead. - */ -@Deprecated -public final class FabricDefaultAttributeRegistry { - /** - * @deprecated Please {@link net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry#register(EntityType, DefaultAttributeContainer.Builder)} instead. - */ - @Deprecated - public static void register(EntityType<? extends LivingEntity> type, DefaultAttributeContainer.Builder builder) { - net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry.register(type, builder); - } -} diff --git a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/entity/FabricEntityTypeBuilder.java b/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/entity/FabricEntityTypeBuilder.java deleted file mode 100644 index 67c55b598..000000000 --- a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/entity/FabricEntityTypeBuilder.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.entity; - -import java.util.function.Function; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.SpawnGroup; -import net.minecraft.entity.EntityDimensions; -import net.minecraft.entity.EntityType; -import net.minecraft.world.World; - -/** - * @deprecated Please migrate to v1. Please use {@link net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder} instead. - */ -@Deprecated -public class FabricEntityTypeBuilder<T extends Entity> { - private final net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder<T> delegate; - - protected FabricEntityTypeBuilder(SpawnGroup spawnGroup, EntityType.EntityFactory<T> function) { - this.delegate = net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder.create(spawnGroup, function); - } - - public static <T extends Entity> FabricEntityTypeBuilder<T> create(SpawnGroup spawnGroup) { - return new FabricEntityTypeBuilder<>(spawnGroup, (t, w) -> null); - } - - /** - * @deprecated Use {@link FabricEntityTypeBuilder#create(SpawnGroup, EntityType.EntityFactory)} - */ - @Deprecated - public static <T extends Entity> FabricEntityTypeBuilder<T> create(SpawnGroup spawnGroup, Function<? super World, ? extends T> function) { - return create(spawnGroup, (t, w) -> function.apply(w)); - } - - public static <T extends Entity> FabricEntityTypeBuilder<T> create(SpawnGroup spawnGroup, EntityType.EntityFactory<T> function) { - return new FabricEntityTypeBuilder<>(spawnGroup, function); - } - - public FabricEntityTypeBuilder<T> disableSummon() { - this.delegate.disableSummon(); - return this; - } - - public FabricEntityTypeBuilder<T> disableSaving() { - this.delegate.disableSaving(); - return this; - } - - public FabricEntityTypeBuilder<T> setImmuneToFire() { - this.delegate.fireImmune(); - return this; - } - - /** - * @deprecated Use {@link FabricEntityTypeBuilder#size(EntityDimensions)} - */ - @Deprecated - public FabricEntityTypeBuilder<T> size(float width, float height) { - this.delegate.dimensions(EntityDimensions.changing(width, height)); - return this; - } - - public FabricEntityTypeBuilder<T> size(EntityDimensions size) { - this.delegate.dimensions(size); - return this; - } - - public FabricEntityTypeBuilder<T> trackable(int trackingDistanceBlocks, int updateIntervalTicks) { - this.delegate.trackRangeBlocks(trackingDistanceBlocks).trackedUpdateRate(updateIntervalTicks).forceTrackedVelocityUpdates(true); - return this; - } - - public FabricEntityTypeBuilder<T> trackable(int trackingDistanceBlocks, int updateIntervalTicks, boolean alwaysUpdateVelocity) { - this.delegate.trackRangeBlocks(trackingDistanceBlocks).trackedUpdateRate(updateIntervalTicks).forceTrackedVelocityUpdates(alwaysUpdateVelocity); - return this; - } - - public EntityType<T> build() { - return this.delegate.build(); - } -} diff --git a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/event/registry/BlockConstructedCallback.java b/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/event/registry/BlockConstructedCallback.java deleted file mode 100644 index 45ef3222e..000000000 --- a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/event/registry/BlockConstructedCallback.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.event.registry; - -import net.minecraft.block.Block; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; - -/** - * @deprecated Please migrate to v1. Please use registry events instead. - */ -@Deprecated -public interface BlockConstructedCallback { - Event<BlockConstructedCallback> EVENT = EventFactory.createArrayBacked(BlockConstructedCallback.class, - (listeners) -> (settings, builtBlock) -> { - for (BlockConstructedCallback callback : listeners) { - callback.building(settings, builtBlock); - } - } - ); - - void building(Block.Settings settings, Block builtBlock); -} diff --git a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/event/registry/ItemConstructedCallback.java b/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/event/registry/ItemConstructedCallback.java deleted file mode 100644 index 5ff408c5f..000000000 --- a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/api/event/registry/ItemConstructedCallback.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.event.registry; - -import net.minecraft.item.Item; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; - -/** - * @deprecated Please migrate to v1. Please use Please use registry events instead. - */ -@Deprecated -public interface ItemConstructedCallback { - Event<ItemConstructedCallback> EVENT = EventFactory.createArrayBacked(ItemConstructedCallback.class, - (listeners) -> (settings, builtItem) -> { - for (ItemConstructedCallback callback : listeners) { - callback.building(settings, builtItem); - } - } - ); - - void building(Item.Settings settings, Item builtItem); -} diff --git a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/mixin/object/builder/OldMixinItem.java b/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/mixin/object/builder/OldMixinItem.java deleted file mode 100644 index 0cff01043..000000000 --- a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/mixin/object/builder/OldMixinItem.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.object.builder; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import net.minecraft.item.Item; - -import net.fabricmc.fabric.api.event.registry.ItemConstructedCallback; - -@Mixin(Item.class) -@Deprecated -public class OldMixinItem { - @Inject(method = "<init>(Lnet/minecraft/item/Item$Settings;)V", at = @At("RETURN")) - public void init(Item.Settings builder, CallbackInfo info) { - ItemConstructedCallback.EVENT.invoker().building(builder, (Item) (Object) this); - } -} diff --git a/fabric-object-builders-v0/src/main/resources/assets/fabric-object-builders-v0/icon.png b/fabric-object-builders-v0/src/main/resources/assets/fabric-object-builders-v0/icon.png deleted file mode 100644 index 2931efbf6..000000000 Binary files a/fabric-object-builders-v0/src/main/resources/assets/fabric-object-builders-v0/icon.png and /dev/null differ diff --git a/fabric-object-builders-v0/src/main/resources/fabric-object-builders-v0.mixins.json b/fabric-object-builders-v0/src/main/resources/fabric-object-builders-v0.mixins.json deleted file mode 100644 index 2bf18ff36..000000000 --- a/fabric-object-builders-v0/src/main/resources/fabric-object-builders-v0.mixins.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required": true, - "package": "net.fabricmc.fabric.mixin.object.builder", - "compatibilityLevel": "JAVA_16", - "mixins": [ - "OldMixinBlock", - "OldMixinItem" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/fabric-object-builders-v0/src/main/resources/fabric.mod.json b/fabric-object-builders-v0/src/main/resources/fabric.mod.json deleted file mode 100644 index f3a301595..000000000 --- a/fabric-object-builders-v0/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "schemaVersion": 1, - "id": "fabric-object-builders-v0", - "name": "Fabric Object Builders (v0)", - "version": "${version}", - "environment": "*", - "license": "Apache-2.0", - "icon": "assets/fabric-object-builders-v0/icon.png", - "contact": { - "homepage": "https://fabricmc.net", - "irc": "irc://irc.esper.net:6667/fabric", - "issues": "https://github.com/FabricMC/fabric/issues", - "sources": "https://github.com/FabricMC/fabric" - }, - "authors": [ - "FabricMC" - ], - "depends": { - "fabricloader": ">=0.8.2", - "fabric-api-base": "*", - "fabric-object-builder-api-v1": "*" - }, - "description": "Legacy builders for objects vanilla has locked down, superseded by fabric-object-builder-api-v1.", - "mixins": [ - "fabric-object-builders-v0.mixins.json" - ], - "custom": { - "fabric-api:module-lifecycle": "deprecated" - } -} diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/api/event/registry/FabricRegistryBuilder.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/api/event/registry/FabricRegistryBuilder.java index 65e41d72f..d5f666051 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/api/event/registry/FabricRegistryBuilder.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/api/event/registry/FabricRegistryBuilder.java @@ -64,7 +64,7 @@ public final class FabricRegistryBuilder<T, R extends MutableRegistry<T>> { * @return An instance of FabricRegistryBuilder */ public static <T> FabricRegistryBuilder<T, SimpleRegistry<T>> createSimple(Class<T> type, Identifier registryId) { - return from(new SimpleRegistry<T>(RegistryKey.ofRegistry(registryId), Lifecycle.stable())); + return from(new SimpleRegistry<T>(RegistryKey.ofRegistry(registryId), Lifecycle.stable(), null)); } /** @@ -76,7 +76,7 @@ public final class FabricRegistryBuilder<T, R extends MutableRegistry<T>> { * @return An instance of FabricRegistryBuilder */ public static <T> FabricRegistryBuilder<T, DefaultedRegistry<T>> createDefaulted(Class<T> type, Identifier registryId, Identifier defaultId) { - return from(new DefaultedRegistry<T>(defaultId.toString(), RegistryKey.ofRegistry(registryId), Lifecycle.stable())); + return from(new DefaultedRegistry<T>(defaultId.toString(), RegistryKey.ofRegistry(registryId), Lifecycle.stable(), null)); } private final R registry; diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/DynamicRegistrySync.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/DynamicRegistrySync.java index 2ddb07a0f..acff193c0 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/DynamicRegistrySync.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/DynamicRegistrySync.java @@ -41,7 +41,7 @@ public class DynamicRegistrySync { * should be the <em>built-in</em> manager. It is never destroyed. We don't ever have to unregister * the registry events. */ - public static void setupSync(DynamicRegistryManager.Impl template) { + public static void setupSync(DynamicRegistryManager template) { LOGGER.debug("Setting up synchronisation of new BuiltinRegistries entries to the built-in DynamicRegistryManager"); BuiltinRegistries.REGISTRIES.stream().forEach(source -> setupSync(source, template)); } @@ -50,7 +50,7 @@ public class DynamicRegistrySync { * Sets up an event registration for the source registy that will ensure all entries added from now on * are also added to the template for dynamic registry managers. */ - private static <T> void setupSync(Registry<T> source, DynamicRegistryManager.Impl template) { + private static <T> void setupSync(Registry<T> source, DynamicRegistryManager template) { @SuppressWarnings("unchecked") AccessorRegistry<T> sourceAccessor = (AccessorRegistry<T>) source; RegistryKey<? extends Registry<T>> sourceKey = source.getKey(); MutableRegistry<T> target = (MutableRegistry<T>) template.get(sourceKey); diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinBootstrap.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinBootstrap.java index c033799ba..64f6bfcb9 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinBootstrap.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinBootstrap.java @@ -19,6 +19,7 @@ package net.fabricmc.fabric.mixin.registry.sync; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import net.minecraft.Bootstrap; @@ -60,4 +61,9 @@ public class MixinBootstrap { RegistrySyncManager.bootstrapRegistries(); } + + @Redirect(method = "initialize", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/registry/Registry;method_40292()V")) + private static void skipFreeze() { + // Don't freeze + } } diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinDynamicRegistryManager.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinDynamicRegistryManager.java index 0fcdec8dc..b1fb18870 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinDynamicRegistryManager.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinDynamicRegistryManager.java @@ -17,29 +17,29 @@ package net.fabricmc.fabric.mixin.registry.sync; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import net.minecraft.util.registry.DynamicRegistryManager; +import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback; import net.fabricmc.fabric.impl.registry.sync.DynamicRegistrySync; @Mixin(DynamicRegistryManager.class) -public class MixinDynamicRegistryManager { - // This is the "template" for all subsequent built-in dynamic registry managers, - // but it still contains the same objects as BuiltinRegistries, while the subsequent - // managers built from this template will contain copies. - @Shadow - private static DynamicRegistryManager.Impl BUILTIN; +public interface MixinDynamicRegistryManager { + @Inject(method = "method_40314", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/dynamic/EntryLoader$Impl;<init>()V"), locals = LocalCapture.CAPTURE_FAILHARD) + private static void onCreateImpl(CallbackInfoReturnable<DynamicRegistryManager.class_6893> cir, DynamicRegistryManager.class_6893 registryManager) { + DynamicRegistrySetupCallback.EVENT.invoker().onRegistrySetup(registryManager); + } /** * Ensures that any registrations made into {@link net.minecraft.util.registry.BuiltinRegistries} after * {@link DynamicRegistryManager} has been class-loaded are still propagated. */ - @Inject(method = "<clinit>", at = @At(value = "TAIL")) - private static void setupBuiltInSync(CallbackInfo ci) { - DynamicRegistrySync.setupSync(BUILTIN); + @Inject(method = "method_40327()Lnet/minecraft/util/registry/DynamicRegistryManager$class_6890;", at = @At(value = "RETURN")) + private static void setupBuiltInSync(CallbackInfoReturnable<DynamicRegistryManager.class_6890> cir) { + DynamicRegistrySync.setupSync(cir.getReturnValue()); } } diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinIdRegistry.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinIdRegistry.java index 2adca5ee2..bfeeea584 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinIdRegistry.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinIdRegistry.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Optional; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; @@ -31,8 +32,9 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectList; -import org.slf4j.LoggerFactory; +import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -41,6 +43,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import net.minecraft.util.registry.RegistryEntry; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; @@ -60,18 +63,25 @@ import net.fabricmc.fabric.impl.registry.sync.RemappableRegistry; public abstract class MixinIdRegistry<T> extends Registry<T> implements RemappableRegistry, ListenableRegistry<T> { @Shadow @Final - private ObjectList<T> rawIdToEntry; + private ObjectList<RegistryEntry.Reference<T>> rawIdToEntry; @Shadow @Final private Object2IntMap<T> entryToRawId; @Shadow @Final - private BiMap<Identifier, T> idToEntry; + private Map<Identifier, RegistryEntry.Reference<T>> idToEntry; @Shadow @Final - private BiMap<RegistryKey<T>, T> keyToEntry; + private Map<RegistryKey<T>, RegistryEntry.Reference<T>> keyToEntry; @Shadow private int nextId; + + @Shadow + public abstract Optional<RegistryKey<T>> getKey(T entry); + + @Shadow + public abstract @Nullable T get(@Nullable Identifier id); + @Unique private static Logger FABRIC_LOGGER = LoggerFactory.getLogger(MixinIdRegistry.class); @@ -109,7 +119,7 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab @Unique private Object2IntMap<Identifier> fabric_prevIndexedEntries; @Unique - private BiMap<Identifier, T> fabric_prevEntries; + private BiMap<Identifier, RegistryEntry.Reference<T>> fabric_prevEntries; @Override public Event<RegistryEntryAddedCallback<T>> fabric_getAddObjectEvent() { @@ -130,7 +140,7 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab @Unique private boolean fabric_isObjectNew = false; - @Inject(method = "set(ILnet/minecraft/util/registry/RegistryKey;Ljava/lang/Object;Lcom/mojang/serialization/Lifecycle;Z)Ljava/lang/Object;", at = @At("HEAD")) + @Inject(method = "set(ILnet/minecraft/util/registry/RegistryKey;Ljava/lang/Object;Lcom/mojang/serialization/Lifecycle;Z)Lnet/minecraft/util/registry/RegistryEntry;", at = @At("HEAD")) public void setPre(int id, RegistryKey<T> registryId, T object, Lifecycle lifecycle, boolean checkDuplicateKeys, CallbackInfoReturnable<T> info) { int indexedEntriesId = entryToRawId.getInt(object); @@ -141,7 +151,7 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab if (!idToEntry.containsKey(registryId.getValue())) { fabric_isObjectNew = true; } else { - T oldObject = idToEntry.get(registryId.getValue()); + RegistryEntry.Reference<T> oldObject = idToEntry.get(registryId.getValue()); if (oldObject != null && oldObject != object) { int oldId = entryToRawId.getInt(oldObject); @@ -150,7 +160,7 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab throw new RuntimeException("Attempted to register ID " + registryId + " at different raw IDs (" + oldId + ", " + id + ")! If you're trying to override an item, use .set(), not .register()!"); } - fabric_removeObjectEvent.invoker().onEntryRemoved(oldId, registryId.getValue(), oldObject); + fabric_removeObjectEvent.invoker().onEntryRemoved(oldId, registryId.getValue(), oldObject.value()); fabric_isObjectNew = true; } else { fabric_isObjectNew = false; @@ -158,7 +168,7 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab } } - @Inject(method = "set(ILnet/minecraft/util/registry/RegistryKey;Ljava/lang/Object;Lcom/mojang/serialization/Lifecycle;Z)Ljava/lang/Object;", at = @At("RETURN")) + @Inject(method = "set(ILnet/minecraft/util/registry/RegistryKey;Ljava/lang/Object;Lcom/mojang/serialization/Lifecycle;Z)Lnet/minecraft/util/registry/RegistryEntry;", at = @At("RETURN")) public void setPost(int id, RegistryKey<T> registryId, T object, Lifecycle lifecycle, boolean checkDuplicateKeys, CallbackInfoReturnable<T> info) { if (fabric_isObjectNew) { fabric_addObjectEvent.invoker().onEntryAdded(id, registryId.getValue(), object); @@ -300,9 +310,9 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab Int2IntMap idMap = new Int2IntOpenHashMap(); - for (T o : rawIdToEntry) { - Identifier id = getId(o); - int rid = getRawId(o); + for (RegistryEntry.Reference<T> o : rawIdToEntry) { + Identifier id = getId(o.value()); + int rid = getRawId(o.value()); // see above note if (remoteIndexedEntries.containsKey(id)) { @@ -320,7 +330,7 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab for (Identifier identifier : orderedRemoteEntries) { int id = remoteIndexedEntries.getInt(identifier); - T object = idToEntry.get(identifier); + RegistryEntry.Reference<T> object = idToEntry.get(identifier); // Warn if an object is missing from the local registry. // This should only happen in AUTHORITATIVE mode, and as such we @@ -338,7 +348,7 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab // Add the new object, increment nextId to match. rawIdToEntry.size(Math.max(this.rawIdToEntry.size(), id + 1)); rawIdToEntry.set(id, object); - entryToRawId.put(object, id); + entryToRawId.put(object.value(), id); if (nextId <= id) { nextId = id + 1; @@ -366,7 +376,7 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab idToEntry.putAll(fabric_prevEntries); - for (Map.Entry<Identifier, T> entry : fabric_prevEntries.entrySet()) { + for (Map.Entry<Identifier, RegistryEntry.Reference<T>> entry : fabric_prevEntries.entrySet()) { RegistryKey<T> entryKey = RegistryKey.of(getKey(), entry.getKey()); keyToEntry.put(entryKey, entry.getValue()); } @@ -374,7 +384,7 @@ public abstract class MixinIdRegistry<T> extends Registry<T> implements Remappab remap(name, fabric_prevIndexedEntries, RemapMode.AUTHORITATIVE); for (Identifier id : addedIds) { - fabric_getAddObjectEvent().invoker().onEntryAdded(entryToRawId.getInt(idToEntry.get(id)), id, idToEntry.get(id)); + fabric_getAddObjectEvent().invoker().onEntryAdded(entryToRawId.getInt(idToEntry.get(id)), id, get(id)); } fabric_prevIndexedEntries = null; diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/DynamicRegistryManagerMixin.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinMinecraftServer.java similarity index 52% rename from fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/DynamicRegistryManagerMixin.java rename to fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinMinecraftServer.java index d4da62923..e3a030540 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/DynamicRegistryManagerMixin.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/MixinMinecraftServer.java @@ -16,20 +16,31 @@ package net.fabricmc.fabric.mixin.registry.sync; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.util.registry.DynamicRegistryManager; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.registry.Registry; -import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback; +import net.fabricmc.api.EnvType; +import net.fabricmc.loader.api.FabricLoader; -@Mixin(DynamicRegistryManager.class) -public class DynamicRegistryManagerMixin { - @Inject(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/dynamic/EntryLoader$Impl;<init>()V"), locals = LocalCapture.CAPTURE_FAILHARD) - private static void onCreateImpl(CallbackInfoReturnable<DynamicRegistryManager.Impl> cir, DynamicRegistryManager.Impl registryManager) { - DynamicRegistrySetupCallback.EVENT.invoker().onRegistrySetup(registryManager); +@Mixin(MinecraftServer.class) +public class MixinMinecraftServer { + @Unique + private static Logger FABRIC_LOGGER = LoggerFactory.getLogger(MixinMinecraftServer.class); + + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setupServer()Z"), method = "runServer") + private void beforeSetupServer(CallbackInfo info) { + if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) { + // Freeze the registries on the server + FABRIC_LOGGER.debug("Freezing registries"); + Registry.method_40292(); + } } } diff --git a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/client/MixinMinecraftClient.java b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/client/MixinMinecraftClient.java index 163b62d5f..cdaac9982 100644 --- a/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/client/MixinMinecraftClient.java +++ b/fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/client/MixinMinecraftClient.java @@ -16,8 +16,8 @@ package net.fabricmc.fabric.mixin.registry.sync.client; -import org.slf4j.LoggerFactory; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -26,6 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.util.registry.Registry; import net.fabricmc.fabric.impl.registry.sync.RegistrySyncManager; import net.fabricmc.fabric.impl.registry.sync.RemapException; @@ -44,4 +45,11 @@ public class MixinMinecraftClient { FABRIC_LOGGER.warn("Failed to unmap Fabric registries!", e); } } + + @Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;thread:Ljava/lang/Thread;", shift = At.Shift.AFTER, ordinal = 0), method = "run") + private void onStart(CallbackInfo ci) { + // Freeze the registries on the client + FABRIC_LOGGER.debug("Freezing registries"); + Registry.method_40292(); + } } diff --git a/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.mixins.json b/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.mixins.json index 75710a229..b06d768e4 100644 --- a/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.mixins.json +++ b/fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.mixins.json @@ -11,8 +11,8 @@ "MixinIdRegistry", "MixinLevelStorageSession", "MixinRegistry", - "MixinSimpleRegistry", - "DynamicRegistryManagerMixin" + "MixinMinecraftServer", + "MixinSimpleRegistry" ], "client": [ "client.MixinBlockColorMap", diff --git a/fabric-registry-sync-v0/src/main/resources/fabric.mod.json b/fabric-registry-sync-v0/src/main/resources/fabric.mod.json index c57dea4b7..aa069be5c 100644 --- a/fabric-registry-sync-v0/src/main/resources/fabric.mod.json +++ b/fabric-registry-sync-v0/src/main/resources/fabric.mod.json @@ -16,7 +16,7 @@ "FabricMC" ], "depends": { - "fabricloader": ">=0.9.2", + "fabricloader": ">=0.13.2", "fabric-api-base": "*", "fabric-networking-api-v1": "*" }, diff --git a/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTest.java b/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTest.java index 1c19224fc..ddf38cf01 100644 --- a/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTest.java +++ b/fabric-registry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/RegistrySyncTest.java @@ -136,19 +136,19 @@ public class RegistrySyncTest implements ModInitializer { System.out.println("Checking built-in registry sync..."); // Register a configured feature before force-loading the dynamic registry manager - ConfiguredFeature<DefaultFeatureConfig, ?> cf1 = Feature.BASALT_PILLAR.configure(DefaultFeatureConfig.INSTANCE); + ConfiguredFeature<DefaultFeatureConfig, ?> cf1 = new ConfiguredFeature<>(Feature.BASALT_PILLAR, DefaultFeatureConfig.INSTANCE); Identifier f1Id = new Identifier("registry_sync", "f1"); Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, f1Id, cf1); // Force-Initialize the dynamic registry manager, doing this in a Mod initializer would cause // further registrations into BuiltInRegistries to _NOT_ propagate into DynamicRegistryManager.BUILTIN - checkFeature(DynamicRegistryManager.create(), f1Id); + checkFeature(DynamicRegistryManager.method_40314(), f1Id); - ConfiguredFeature<DefaultFeatureConfig, ?> cf2 = Feature.DESERT_WELL.configure(DefaultFeatureConfig.INSTANCE); + ConfiguredFeature<DefaultFeatureConfig, ?> cf2 = new ConfiguredFeature<>(Feature.DESERT_WELL, DefaultFeatureConfig.INSTANCE); Identifier f2Id = new Identifier("registry_sync", "f2"); Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, f2Id, cf2); - DynamicRegistryManager.Impl impl2 = DynamicRegistryManager.create(); + DynamicRegistryManager impl2 = DynamicRegistryManager.method_40314(); checkFeature(impl2, f1Id); checkFeature(impl2, f2Id); } @@ -172,7 +172,7 @@ public class RegistrySyncTest implements ModInitializer { throw new IllegalStateException("Expected that the built-in entry and dynamic entry don't have object identity because the dynamic entry is created by serializing the built-in entry to JSON and back."); } - if (builtInEntry.feature != entry.feature) { + if (builtInEntry.feature() != entry.feature()) { throw new IllegalStateException("Expected both entries to reference the same feature since it's only in Registry and is never copied"); } } diff --git a/fabric-renderer-api-v1/build.gradle b/fabric-renderer-api-v1/build.gradle index e58f5c300..2a78b41f7 100644 --- a/fabric-renderer-api-v1/build.gradle +++ b/fabric-renderer-api-v1/build.gradle @@ -12,6 +12,4 @@ dependencies { testmodImplementation project(path: ':fabric-renderer-indigo', configuration: 'namedElements') testmodImplementation project(path: ':fabric-rendering-data-attachment-v1', configuration: 'namedElements') testmodImplementation project(path: ':fabric-resource-loader-v0', configuration: 'namedElements') - testmodImplementation project(path: ':fabric-tag-extensions-v0', configuration: 'namedElements') - testmodImplementation project(path: ':fabric-tool-attribute-api-v1', configuration: 'namedElements') } diff --git a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/api/resource/conditions/v1/DefaultResourceConditions.java b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/api/resource/conditions/v1/DefaultResourceConditions.java index bef3d4386..03c0ca419 100644 --- a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/api/resource/conditions/v1/DefaultResourceConditions.java +++ b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/api/resource/conditions/v1/DefaultResourceConditions.java @@ -20,9 +20,9 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import net.minecraft.block.Block; +import net.minecraft.tag.TagKey; import net.minecraft.fluid.Fluid; import net.minecraft.item.Item; -import net.minecraft.tag.Tag; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; import net.minecraft.util.registry.Registry; @@ -90,21 +90,21 @@ public final class DefaultResourceConditions { /** * Create a condition that returns true if each of the passed block tags exists and has at least one element. */ - public static ConditionJsonProvider blockTagsPopulated(Tag.Identified<Block>... tags) { + public static ConditionJsonProvider blockTagsPopulated(TagKey<Block>... tags) { return ResourceConditionsImpl.tagsPopulated(BLOCK_TAGS_POPULATED, tags); } /** * Create a condition that returns true if each of the passed fluid tags exists and has at least one element. */ - public static ConditionJsonProvider fluidTagsPopulated(Tag.Identified<Fluid>... tags) { + public static ConditionJsonProvider fluidTagsPopulated(TagKey<Fluid>... tags) { return ResourceConditionsImpl.tagsPopulated(FLUID_TAGS_POPULATED, tags); } /** * Create a condition that returns true if each of the passed item tags exists and has at least one element. */ - public static ConditionJsonProvider itemTagsPopulated(Tag.Identified<Item>... tags) { + public static ConditionJsonProvider itemTagsPopulated(TagKey<Item>... tags) { return ResourceConditionsImpl.tagsPopulated(ITEM_TAGS_POPULATED, tags); } diff --git a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/impl/resource/conditions/ResourceConditionsImpl.java b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/impl/resource/conditions/ResourceConditionsImpl.java index 80a50fa13..7fa1fc9d8 100644 --- a/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/impl/resource/conditions/ResourceConditionsImpl.java +++ b/fabric-resource-conditions-api-v1/src/main/java/net/fabricmc/fabric/impl/resource/conditions/ResourceConditionsImpl.java @@ -21,12 +21,11 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import org.slf4j.LoggerFactory; -import org.slf4j.Logger; import org.jetbrains.annotations.ApiStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import net.minecraft.tag.ServerTagManagerHolder; -import net.minecraft.tag.Tag; +import net.minecraft.tag.TagKey; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; import net.minecraft.util.registry.Registry; @@ -85,7 +84,7 @@ public class ResourceConditionsImpl { }; } - public static <T> ConditionJsonProvider tagsPopulated(Identifier id, Tag.Identified<T>... tags) { + public static <T> ConditionJsonProvider tagsPopulated(Identifier id, TagKey<T>... tags) { Preconditions.checkArgument(tags.length > 0, "Must register at least one tag."); return new ConditionJsonProvider() { @@ -98,8 +97,8 @@ public class ResourceConditionsImpl { public void writeParameters(JsonObject object) { JsonArray array = new JsonArray(); - for (Tag.Identified<T> tag : tags) { - array.add(tag.getId().toString()); + for (TagKey<T> tag : tags) { + array.add(tag.id().toString()); } object.add("values", array); @@ -131,9 +130,11 @@ public class ResourceConditionsImpl { for (JsonElement element : array) { if (element.isJsonPrimitive()) { Identifier id = new Identifier(element.getAsString()); - Tag<T> tag = ServerTagManagerHolder.getTagManager().getOrCreateTagGroup(registryKey).getTagOrEmpty(id); + // TODO 22w06a check me later + TagKey<T> tag = TagKey.intern(registryKey, id); + Registry<T> registry = (Registry<T>) Registry.REGISTRIES.get(registryKey.getValue()); - if (tag.values().isEmpty()) { + if (!registry.containsTag(tag)) { return false; } } else { diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/FabricTagHooks.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricLifecycledResourceManager.java similarity index 76% rename from fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/FabricTagHooks.java rename to fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricLifecycledResourceManager.java index 9349a2a92..3585fa2b4 100644 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/FabricTagHooks.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricLifecycledResourceManager.java @@ -14,8 +14,10 @@ * limitations under the License. */ -package net.fabricmc.fabric.impl.tag.extension; +package net.fabricmc.fabric.impl.resource.loader; -public interface FabricTagHooks { - void fabric_setExtraData(int clearCount); +import net.minecraft.resource.ResourceType; + +public interface FabricLifecycledResourceManager { + ResourceType fabric_getResourceType(); } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java index 2c1a43da6..5aa7736a5 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java @@ -18,6 +18,8 @@ package net.fabricmc.fabric.impl.resource.loader; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -113,12 +115,20 @@ public class ResourceManagerHelperImpl implements ResourceManagerHelper { } } - public static void sort(ResourceType type, List<ResourceReloader> listeners) { + public static List<ResourceReloader> sort(ResourceType type, List<ResourceReloader> listeners) { + if (type == null) { + return listeners; + } + ResourceManagerHelperImpl instance = get(type); if (instance != null) { - instance.sort(listeners); + List<ResourceReloader> mutable = new ArrayList<>(listeners); + instance.sort(mutable); + return Collections.unmodifiableList(mutable); } + + return listeners; } protected void sort(List<ResourceReloader> listeners) { diff --git a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/mixin/object/builder/OldMixinBlock.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/LifecycledResourceManagerImplMixin.java similarity index 52% rename from fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/mixin/object/builder/OldMixinBlock.java rename to fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/LifecycledResourceManagerImplMixin.java index 88a39ce4e..758eb6793 100644 --- a/fabric-object-builders-v0/src/main/java/net/fabricmc/fabric/mixin/object/builder/OldMixinBlock.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/LifecycledResourceManagerImplMixin.java @@ -14,23 +14,34 @@ * limitations under the License. */ -package net.fabricmc.fabric.mixin.object.builder; +package net.fabricmc.fabric.mixin.resource.loader; + +import java.util.List; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.block.Block; -import net.minecraft.block.AbstractBlock; +import net.minecraft.class_6861; +import net.minecraft.resource.ResourcePack; +import net.minecraft.resource.ResourceType; -import net.fabricmc.fabric.api.event.registry.BlockConstructedCallback; +import net.fabricmc.fabric.impl.resource.loader.FabricLifecycledResourceManager; -@Mixin(Block.class) -@Deprecated -public class OldMixinBlock { - @Inject(method = "<init>(Lnet/minecraft/block/AbstractBlock$Settings;)V", at = @At("RETURN")) - public void init(AbstractBlock.Settings builder, CallbackInfo info) { - BlockConstructedCallback.EVENT.invoker().building(builder, (Block) (Object) this); +@Mixin(class_6861.class) +public class LifecycledResourceManagerImplMixin implements FabricLifecycledResourceManager { + @Unique + private ResourceType fabric_ResourceType; + + @Inject(method = "<init>", at = @At("TAIL")) + private void init(ResourceType resourceType, List<ResourcePack> list, CallbackInfo ci) { + this.fabric_ResourceType = resourceType; + } + + @Override + public ResourceType fabric_getResourceType() { + return fabric_ResourceType; } } diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ReloadableResourceManagerImplMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ReloadableResourceManagerImplMixin.java index 7adbb7318..80ae55c5a 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ReloadableResourceManagerImplMixin.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ReloadableResourceManagerImplMixin.java @@ -17,42 +17,20 @@ package net.fabricmc.fabric.mixin.resource.loader; import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; import java.util.stream.Collectors; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.resource.ReloadableResourceManagerImpl; import net.minecraft.resource.ResourcePack; -import net.minecraft.resource.ResourceReloader; -import net.minecraft.resource.ResourceType; -import net.minecraft.resource.ResourceReload; -import net.minecraft.util.Unit; import net.fabricmc.fabric.impl.resource.loader.GroupResourcePack; -import net.fabricmc.fabric.impl.resource.loader.ResourceManagerHelperImpl; @Mixin(ReloadableResourceManagerImpl.class) public class ReloadableResourceManagerImplMixin { - @Final - @Shadow - private ResourceType type; - - @Shadow - @Final - private List<ResourceReloader> reloaders; - - @Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;isDebugEnabled()Z", remap = false), method = "reload") - private void reload(Executor prepareExecutor, Executor applyExecutor, CompletableFuture<Unit> initialStage, List<ResourcePack> packs, CallbackInfoReturnable<ResourceReload> info) { - ResourceManagerHelperImpl.sort(type, this.reloaders); - } - // private static synthetic method_29491(Ljava/util/List;)Ljava/lang/Object; // Supplier lambda in beginMonitoredReload method. @Inject(method = "method_29491", at = @At("HEAD"), cancellable = true) diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/SimpleResourceReloadMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/SimpleResourceReloadMixin.java new file mode 100644 index 000000000..011dcbe18 --- /dev/null +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/SimpleResourceReloadMixin.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016, 2017, 2018, 2019 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.fabricmc.fabric.mixin.resource.loader; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import net.minecraft.resource.ProfiledResourceReload; +import net.minecraft.resource.ResourceManager; +import net.minecraft.resource.ResourceReload; +import net.minecraft.resource.ResourceReloader; +import net.minecraft.resource.ResourceType; +import net.minecraft.resource.SimpleResourceReload; +import net.minecraft.util.Unit; + +import net.fabricmc.fabric.impl.resource.loader.FabricLifecycledResourceManager; +import net.fabricmc.fabric.impl.resource.loader.ResourceManagerHelperImpl; + +@Mixin(SimpleResourceReload.class) +public class SimpleResourceReloadMixin { + @Unique + private static final ThreadLocal<ResourceType> fabric_resourceType = new ThreadLocal<>(); + + @Inject(method = "method_40087", at = @At("HEAD")) + private static void method_40087(ResourceManager resourceManager, List<ResourceReloader> list, Executor executor, Executor executor2, CompletableFuture<Unit> completableFuture, boolean bl, CallbackInfoReturnable<ResourceReload> cir) { + if (resourceManager instanceof FabricLifecycledResourceManager flrm) { + fabric_resourceType.set(flrm.fabric_getResourceType()); + } + } + + @ModifyArg(method = "method_40087", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/SimpleResourceReload;create(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;Ljava/util/concurrent/CompletableFuture;)Lnet/minecraft/resource/SimpleResourceReload;")) + private static List<ResourceReloader> sortSimple(List<ResourceReloader> reloaders) { + List<ResourceReloader> sorted = ResourceManagerHelperImpl.sort(fabric_resourceType.get(), reloaders); + fabric_resourceType.set(null); + return sorted; + } + + @Redirect(method = "method_40087", at = @At(value = "NEW", target = "Lnet/minecraft/resource/ProfiledResourceReload;<init>")) + private static ProfiledResourceReload sortProfiled(ResourceManager manager, List<ResourceReloader> reloaders, Executor prepareExecutor, Executor applyExecutor, CompletableFuture<Unit> initialStage) { + List<ResourceReloader> sorted = ResourceManagerHelperImpl.sort(fabric_resourceType.get(), reloaders); + fabric_resourceType.set(null); + return new ProfiledResourceReload(manager, sorted, prepareExecutor, applyExecutor, initialStage); + } +} diff --git a/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json b/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json index e6dde5ac7..77222b848 100644 --- a/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json +++ b/fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json @@ -6,13 +6,15 @@ "FileResourcePackProviderAccessor", "DefaultResourcePackMixin", "KeyedResourceReloadListenerMixin", + "LifecycledResourceManagerImplMixin", "MinecraftServerMixin", "NamespaceResourceManagerAccessor", "NamespaceResourceManagerMixin", "ReloadableResourceManagerImplMixin", "ResourcePackManagerMixin", "ResourcePackManagerAccessor", - "ResourcePackProfileAccessor" + "ResourcePackProfileAccessor", + "SimpleResourceReloadMixin" ], "client": [ "client.ClientBuiltinResourcePackProviderMixin", diff --git a/fabric-screen-api-v1/src/main/java/net/fabricmc/fabric/mixin/screen/MinecraftClientMixin.java b/fabric-screen-api-v1/src/main/java/net/fabricmc/fabric/mixin/screen/MinecraftClientMixin.java index 26533fabc..7d662994c 100644 --- a/fabric-screen-api-v1/src/main/java/net/fabricmc/fabric/mixin/screen/MinecraftClientMixin.java +++ b/fabric-screen-api-v1/src/main/java/net/fabricmc/fabric/mixin/screen/MinecraftClientMixin.java @@ -67,7 +67,7 @@ abstract class MinecraftClientMixin { // The LevelLoadingScreen is the odd screen that isn't ticked by the main tick loop, so we fire events for this screen. // We Coerce the package-private inner class representing the world load action so we don't need an access widener. - @Inject(method = "startIntegratedServer(Ljava/lang/String;Lnet/minecraft/util/registry/DynamicRegistryManager$Impl;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/client/MinecraftClient$WorldLoadAction;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/LevelLoadingScreen;tick()V")) + @Inject(method = "startIntegratedServer(Ljava/lang/String;Ljava/util/function/Function;Ljava/util/function/Function;ZLnet/minecraft/client/MinecraftClient$WorldLoadAction;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/LevelLoadingScreen;tick()V")) private void beforeLoadingScreenTick(CallbackInfo ci) { // Store the screen in a variable in case someone tries to change the screen during this before tick event. // If someone changes the screen, the after tick event will likely have class cast exceptions or throw a NPE. @@ -75,7 +75,7 @@ abstract class MinecraftClientMixin { ScreenEvents.beforeTick(this.tickingScreen).invoker().beforeTick(this.tickingScreen); } - @Inject(method = "startIntegratedServer(Ljava/lang/String;Lnet/minecraft/util/registry/DynamicRegistryManager$Impl;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/client/MinecraftClient$WorldLoadAction;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;render(Z)V")) + @Inject(method = "startIntegratedServer(Ljava/lang/String;Ljava/util/function/Function;Ljava/util/function/Function;ZLnet/minecraft/client/MinecraftClient$WorldLoadAction;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;render(Z)V")) private void afterLoadingScreenTick(CallbackInfo ci) { ScreenEvents.afterTick(this.tickingScreen).invoker().afterTick(this.tickingScreen); // Finally set the currently ticking screen to null diff --git a/fabric-screen-api-v1/src/testmod/java/net/fabricmc/fabric/test/screen/SoundButton.java b/fabric-screen-api-v1/src/testmod/java/net/fabricmc/fabric/test/screen/SoundButton.java index 607eb286b..13e83d610 100644 --- a/fabric-screen-api-v1/src/testmod/java/net/fabricmc/fabric/test/screen/SoundButton.java +++ b/fabric-screen-api-v1/src/testmod/java/net/fabricmc/fabric/test/screen/SoundButton.java @@ -18,8 +18,7 @@ package net.fabricmc.fabric.test.screen; import java.util.Random; -import org.jetbrains.annotations.Nullable; - +import net.minecraft.util.registry.RegistryEntry; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.widget.PressableWidget; @@ -28,7 +27,6 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.SimpleRegistry; class SoundButton extends PressableWidget { private static final Random RANDOM = new Random(); @@ -39,11 +37,8 @@ class SoundButton extends PressableWidget { @Override public void onPress() { - // Upcast on registry is fine - @Nullable - final SoundEvent event = ((SimpleRegistry<SoundEvent>) Registry.SOUND_EVENT).getRandom(RANDOM); - - MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(event != null ? event : SoundEvents.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0F)); + final SoundEvent event = Registry.SOUND_EVENT.getRandom(RANDOM).map(RegistryEntry::value).orElse(SoundEvents.ENTITY_GENERIC_EXPLODE); + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(event, 1.0F, 1.0F)); } @Override diff --git a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/api/structure/v1/FabricStructureBuilder.java b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/api/structure/v1/FabricStructureBuilder.java index 40d7a3a38..f5c09e3d9 100644 --- a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/api/structure/v1/FabricStructureBuilder.java +++ b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/api/structure/v1/FabricStructureBuilder.java @@ -20,10 +20,12 @@ import java.util.Objects; import com.google.common.collect.ImmutableList; +import net.minecraft.world.gen.chunk.placement.RandomSpreadStructurePlacement; +import net.minecraft.world.gen.chunk.placement.SpreadType; +import net.minecraft.world.gen.chunk.placement.StructurePlacement; import net.minecraft.util.Identifier; import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.chunk.StructureConfig; -import net.minecraft.world.gen.chunk.StructuresConfig; +import net.minecraft.world.gen.chunk.placement.StructuresConfig; import net.minecraft.world.gen.feature.FeatureConfig; import net.minecraft.world.gen.feature.StructureFeature; @@ -52,7 +54,7 @@ public final class FabricStructureBuilder<FC extends FeatureConfig, S extends St private final Identifier id; private final S structure; private GenerationStep.Feature step; - private StructureConfig defaultConfig; + private StructurePlacement defaultConfig; private boolean generateInSuperflat = false; private boolean adjustsSurface = false; @@ -90,19 +92,19 @@ public final class FabricStructureBuilder<FC extends FeatureConfig, S extends St } /** - * Sets the default {@linkplain StructureConfig} for this structure. See the alternative + * Sets the default {@linkplain StructurePlacement} for this structure. See the alternative * {@linkplain #defaultConfig(int, int, int)} for details. * * <p>This is a required option.</p> */ - public FabricStructureBuilder<FC, S> defaultConfig(StructureConfig config) { + public FabricStructureBuilder<FC, S> defaultConfig(StructurePlacement config) { Objects.requireNonNull(config, "config must not be null"); this.defaultConfig = config; return this; } /** - * Sets the default {@linkplain StructureConfig} for this structure. This sets the default configuration of where in + * Sets the default {@linkplain StructurePlacement} for this structure. This sets the default configuration of where in * the world to place structures. * * <p>Note: the {@code spacing} and {@code separation} options are subject to other checks for whether the structure @@ -115,10 +117,10 @@ public final class FabricStructureBuilder<FC extends FeatureConfig, S extends St * @param separation The minimum distance between 2 structures of this type. * @param salt The random salt of the structure. This does not affect how common the structure is, but every * structure must have an unique {@code salt} in order to spawn in different places. - * @see #defaultConfig(StructureConfig) + * @see #defaultConfig(StructurePlacement) */ public FabricStructureBuilder<FC, S> defaultConfig(int spacing, int separation, int salt) { - return defaultConfig(new StructureConfig(spacing, separation, salt)); + return defaultConfig(new RandomSpreadStructurePlacement(spacing, separation, SpreadType.LINEAR, salt)); } /** @@ -147,7 +149,7 @@ public final class FabricStructureBuilder<FC extends FeatureConfig, S extends St Objects.requireNonNull(defaultConfig, "Structure \"" + id + "\" is missing a default config"); // Ensure StructuresConfig class is initialized, so the assertion in its static {} block doesn't fail - StructuresConfig.DEFAULT_STRUCTURES.size(); + StructuresConfig.DEFAULT_PLACEMENTS.size(); StructureFeatureAccessor.callRegister(id.toString(), structure, step); diff --git a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/impl/structure/FabricStructureImpl.java b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/impl/structure/FabricStructureImpl.java index f8ab6a83c..4a072078c 100644 --- a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/impl/structure/FabricStructureImpl.java +++ b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/impl/structure/FabricStructureImpl.java @@ -21,7 +21,7 @@ import java.util.Map; import com.google.common.collect.ImmutableMap; -import net.minecraft.world.gen.chunk.StructureConfig; +import net.minecraft.world.gen.chunk.placement.StructurePlacement; import net.minecraft.world.gen.feature.StructureFeature; import net.fabricmc.api.ModInitializer; @@ -30,22 +30,22 @@ import net.fabricmc.fabric.mixin.structure.StructuresConfigAccessor; public class FabricStructureImpl implements ModInitializer { //Keeps a map of structures to structure configs for purposes of initializing the flat chunk generator - public static final Map<StructureFeature<?>, StructureConfig> FLAT_STRUCTURE_TO_CONFIG_MAP = new HashMap<>(); + public static final Map<StructureFeature<?>, StructurePlacement> FLAT_STRUCTURE_TO_CONFIG_MAP = new HashMap<>(); //Keeps a map of structures to structure configs. - public static final Map<StructureFeature<?>, StructureConfig> STRUCTURE_TO_CONFIG_MAP = new HashMap<>(); + public static final Map<StructureFeature<?>, StructurePlacement> STRUCTURE_TO_CONFIG_MAP = new HashMap<>(); @Override public void onInitialize() { ServerWorldEvents.LOAD.register((server, world) -> { // Need temp map as some mods use custom chunk generators with immutable maps in themselves. - Map<StructureFeature<?>, StructureConfig> tempMap = new HashMap<>(world.getChunkManager().getChunkGenerator().getStructuresConfig().getStructures()); + Map<StructureFeature<?>, StructurePlacement> tempMap = new HashMap<>(world.getChunkManager().getChunkGenerator().getStructuresConfig().getStructures()); tempMap.putAll(STRUCTURE_TO_CONFIG_MAP); //Make it immutable again - ImmutableMap<StructureFeature<?>, StructureConfig> immutableMap = ImmutableMap.copyOf(tempMap); - ((StructuresConfigAccessor) world.getChunkManager().getChunkGenerator().getStructuresConfig()).setStructures(immutableMap); + ImmutableMap<StructureFeature<?>, StructurePlacement> immutableMap = ImmutableMap.copyOf(tempMap); + ((StructuresConfigAccessor) world.getChunkManager().getChunkGenerator().getStructuresConfig()).setPlacements(immutableMap); }); } } diff --git a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/ChunkSerializerMixin.java b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/ChunkSerializerMixin.java index 1fae24e2a..38f46a8f7 100644 --- a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/ChunkSerializerMixin.java +++ b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/ChunkSerializerMixin.java @@ -62,7 +62,7 @@ abstract class ChunkSerializerMixin { if (ChunkSerializerMixin.CHUNK_NEEDS_SAVING.get()) { ChunkSerializerMixin.CHUNK_NEEDS_SAVING.set(false); // Make the chunk save as soon as possible - chunk.setShouldSave(true); + chunk.setNeedsSaving(true); } // Replicate vanilla logic diff --git a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/DynamicRegistryManagerMixin.java b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/DynamicRegistryManagerMixin.java index 687f64a24..c6c381bdb 100644 --- a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/DynamicRegistryManagerMixin.java +++ b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/DynamicRegistryManagerMixin.java @@ -16,15 +16,16 @@ package net.fabricmc.fabric.mixin.structure; +import com.google.gson.JsonElement; +import com.mojang.serialization.DynamicOps; +import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.spongepowered.asm.mixin.Mixin; +import net.minecraft.class_6900; import net.minecraft.structure.pool.StructurePool; -import net.minecraft.util.dynamic.RegistryOps; import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; @@ -33,11 +34,13 @@ import net.fabricmc.fabric.api.structure.v1.StructurePoolAddCallback; import net.fabricmc.fabric.impl.structure.FabricStructurePoolImpl; @Mixin(DynamicRegistryManager.class) -public abstract class DynamicRegistryManagerMixin { - @Inject(method = "load(Lnet/minecraft/util/dynamic/RegistryOps;Lnet/minecraft/util/registry/DynamicRegistryManager;Lnet/minecraft/util/registry/DynamicRegistryManager$Info;)V", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD) - private static <E> void load(RegistryOps<?> ops, DynamicRegistryManager manager, @Coerce Object info, CallbackInfo ci, RegistryKey<? extends Registry<E>> registryKey) { +public interface DynamicRegistryManagerMixin { + @Inject(method = "load(Lcom/mojang/serialization/DynamicOps;Lnet/minecraft/class_6900$class_6901;Lnet/minecraft/util/registry/DynamicRegistryManager$Info;)V", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD) + private static <E> void load(DynamicOps<JsonElement> dynamicOps, class_6900.class_6901 arg, DynamicRegistryManager.Info<E> info, CallbackInfo ci) { + RegistryKey<? extends Registry<E>> registryKey = info.registry(); + if (registryKey.equals(Registry.STRUCTURE_POOL_KEY)) { - for (E registryEntry : manager.get(registryKey)) { + for (E registryEntry : arg.access().get(registryKey)) { if (registryEntry instanceof StructurePool pool) { StructurePoolAddCallback.EVENT.invoker().onAdd(new FabricStructurePoolImpl(pool)); } diff --git a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/FlatChunkGeneratorConfigMixin.java b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/FlatChunkGeneratorConfigMixin.java index e122e987a..042ab34e6 100644 --- a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/FlatChunkGeneratorConfigMixin.java +++ b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/FlatChunkGeneratorConfigMixin.java @@ -16,13 +16,19 @@ package net.fabricmc.fabric.mixin.structure; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.world.gen.chunk.FlatChunkGeneratorConfig; -import net.minecraft.world.gen.chunk.StructuresConfig; +import net.minecraft.world.gen.chunk.placement.StructurePlacement; +import net.minecraft.world.gen.chunk.placement.StructuresConfig; +import net.minecraft.world.gen.feature.StructureFeature; import net.fabricmc.fabric.impl.structure.FabricStructureImpl; @@ -31,6 +37,10 @@ public class FlatChunkGeneratorConfigMixin { @Inject(method = "getDefaultConfig", at = @At(value = "RETURN")) private static void createDefaultConfig(CallbackInfoReturnable<FlatChunkGeneratorConfig> cir) { StructuresConfig structuresConfig = cir.getReturnValue().getStructuresConfig(); - structuresConfig.getStructures().putAll(FabricStructureImpl.FLAT_STRUCTURE_TO_CONFIG_MAP); + StructuresConfigAccessor structuresConfigAccessor = (StructuresConfigAccessor) structuresConfig; + + Map<StructureFeature<?>, StructurePlacement> placements = new HashMap<>(structuresConfig.getStructures()); + placements.putAll(FabricStructureImpl.FLAT_STRUCTURE_TO_CONFIG_MAP); + structuresConfigAccessor.setPlacements(Collections.unmodifiableMap(placements)); } } diff --git a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/StructuresConfigAccessor.java b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/StructuresConfigAccessor.java index 552b92658..41ad812fe 100644 --- a/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/StructuresConfigAccessor.java +++ b/fabric-structure-api-v1/src/main/java/net/fabricmc/fabric/mixin/structure/StructuresConfigAccessor.java @@ -22,13 +22,13 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; -import net.minecraft.world.gen.chunk.StructureConfig; -import net.minecraft.world.gen.chunk.StructuresConfig; +import net.minecraft.world.gen.chunk.placement.StructurePlacement; +import net.minecraft.world.gen.chunk.placement.StructuresConfig; import net.minecraft.world.gen.feature.StructureFeature; @Mixin(StructuresConfig.class) public interface StructuresConfigAccessor { @Mutable - @Accessor("structures") - void setStructures(Map<StructureFeature<?>, StructureConfig> structures); + @Accessor("placements") + void setPlacements(Map<StructureFeature<?>, StructurePlacement> structures); } diff --git a/fabric-structure-api-v1/src/main/resources/fabric.mod.json b/fabric-structure-api-v1/src/main/resources/fabric.mod.json index 0ab3ef44c..11be598ed 100644 --- a/fabric-structure-api-v1/src/main/resources/fabric.mod.json +++ b/fabric-structure-api-v1/src/main/resources/fabric.mod.json @@ -21,7 +21,7 @@ ] }, "depends": { - "fabricloader": ">=0.8.0", + "fabricloader": ">=0.13.2", "fabric-api-base": "*", "fabric-lifecycle-events-v1": "*" }, diff --git a/fabric-structure-api-v1/src/testmod/java/net/fabricmc/fabric/test/structure/StructureTest.java b/fabric-structure-api-v1/src/testmod/java/net/fabricmc/fabric/test/structure/StructureTest.java index 0666aaf31..af5f4b1a4 100644 --- a/fabric-structure-api-v1/src/testmod/java/net/fabricmc/fabric/test/structure/StructureTest.java +++ b/fabric-structure-api-v1/src/testmod/java/net/fabricmc/fabric/test/structure/StructureTest.java @@ -20,10 +20,11 @@ import java.util.Optional; import java.util.Random; import com.mojang.serialization.Codec; -import org.slf4j.LoggerFactory; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import net.minecraft.block.Blocks; +import net.minecraft.util.registry.RegistryEntry; import net.minecraft.nbt.NbtCompound; import net.minecraft.structure.ShiftableStructurePiece; import net.minecraft.structure.StructureGeneratorFactory; @@ -36,6 +37,7 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; import net.minecraft.world.Heightmap; import net.minecraft.world.StructureWorldAccess; @@ -53,7 +55,11 @@ public class StructureTest { private static final Logger LOGGER = LoggerFactory.getLogger(StructureTest.class); public static final StructureFeature<DefaultFeatureConfig> STRUCTURE = new TestStructureFeature(DefaultFeatureConfig.CODEC); - public static final ConfiguredStructureFeature<DefaultFeatureConfig, ? extends StructureFeature<DefaultFeatureConfig>> CONFIGURED_STRUCTURE = STRUCTURE.configure(new DefaultFeatureConfig()); + public static final RegistryEntry<ConfiguredStructureFeature<?, ?>> CONFIGURED_STRUCTURE = BuiltinRegistries.add( + BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, + new Identifier("fabric", "test_structure"), + STRUCTURE.configure(new DefaultFeatureConfig()) + ); public static final StructurePieceType.Simple PIECE = TestStructureGenerator::new; static { diff --git a/fabric-structure-api-v1/src/testmod/java/net/fabricmc/fabric/test/structure/mixin/MixinConfiguredStructureFeatures.java b/fabric-structure-api-v1/src/testmod/java/net/fabricmc/fabric/test/structure/mixin/MixinConfiguredStructureFeatures.java index 174151355..1402ffd9f 100644 --- a/fabric-structure-api-v1/src/testmod/java/net/fabricmc/fabric/test/structure/mixin/MixinConfiguredStructureFeatures.java +++ b/fabric-structure-api-v1/src/testmod/java/net/fabricmc/fabric/test/structure/mixin/MixinConfiguredStructureFeatures.java @@ -16,13 +16,13 @@ package net.fabricmc.fabric.test.structure.mixin; -import java.util.function.BiConsumer; - import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import net.minecraft.util.registry.RegistryEntry; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeKeys; @@ -32,9 +32,14 @@ import net.minecraft.world.gen.feature.ConfiguredStructureFeatures; import net.fabricmc.fabric.test.structure.StructureTest; @Mixin(ConfiguredStructureFeatures.class) -public class MixinConfiguredStructureFeatures { +public abstract class MixinConfiguredStructureFeatures { + @Shadow + private static void register(ConfiguredStructureFeatures.class_6896 arg, RegistryEntry<? extends ConfiguredStructureFeature<?, ?>> arg2, RegistryKey<Biome> biome) { + throw new AssertionError(); + } + @Inject(method = "registerAll", at = @At("TAIL")) - private static void addStructuresToBiomes(BiConsumer<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>> consumer, CallbackInfo ci) { - consumer.accept(StructureTest.CONFIGURED_STRUCTURE, BiomeKeys.PLAINS); + private static void addStructuresToBiomes(ConfiguredStructureFeatures.class_6896 arg, CallbackInfo ci) { + register(arg, StructureTest.CONFIGURED_STRUCTURE, BiomeKeys.PLAINS); } } diff --git a/fabric-tag-extensions-v0/build.gradle b/fabric-tag-extensions-v0/build.gradle deleted file mode 100644 index ac1e92332..000000000 --- a/fabric-tag-extensions-v0/build.gradle +++ /dev/null @@ -1,13 +0,0 @@ -archivesBaseName = "fabric-tag-extensions-v0" -version = getSubprojectVersion(project) - -moduleDependencies(project, [ - 'fabric-api-base', - 'fabric-resource-loader-v0' -]) - -dependencies { - testmodImplementation project(path: ':fabric-command-api-v1', configuration: 'namedElements') - testmodImplementation project(path: ':fabric-key-binding-api-v1', configuration: 'namedElements') - testmodImplementation project(path: ':fabric-lifecycle-events-v1', configuration: 'namedElements') -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricDataGeneratorTagBuilder.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricDataGeneratorTagBuilder.java deleted file mode 100644 index 8e491cf08..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricDataGeneratorTagBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tag; - -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; - -/** - * Interface implemented by {@link net.minecraft.data.server.AbstractTagProvider.ObjectBuilder} instances when - * Fabric API is present. Useful for data generators. - */ -public interface FabricDataGeneratorTagBuilder<T> { - /** - * Add an optional entry of type {@code <T>} to the tag. - * The object identified by {@code id} is not required to be present on load, - * which is useful for integration with other mods. - * @param id The ID of the object to add - * @see net.minecraft.data.server.AbstractTagProvider.ObjectBuilder#add(T) for the non-optional version of this method. - */ - void addOptionalObject(Identifier id); - - /** - * Add an optional tag entry to the tag. - * The tag identified by {@code id} is not required to be present on load, - * which is useful for integration with other mods. - * @param id The ID of the tag to add - * @see net.minecraft.data.server.AbstractTagProvider.ObjectBuilder#addTag(Tag.Identified) for the non-optional version of this method. - */ - void addOptionalTag(Identifier id); -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricTag.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricTag.java deleted file mode 100644 index c57b7c220..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricTag.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tag; - -/** - * Interface implemented by {@link net.minecraft.tag.Tag} instances when - * Fabric API is present. - * - * @param <T> - */ -public interface FabricTag<T> { - /** - * @return True if the given tag has been "replaced" by a datapack at least once. - */ - boolean hasBeenReplaced(); -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricTagBuilder.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricTagBuilder.java deleted file mode 100644 index 1943a67bd..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/FabricTagBuilder.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tag; - -/** - * Interface implemented by {@link net.minecraft.tag.Tag.Builder} instances when - * Fabric API is present. - * - * @param <T> - */ -public interface FabricTagBuilder<T> { - /** - * Clear the contained entries and mark the tag as replaced. - */ - void clearTagEntries(); -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/TagFactory.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/TagFactory.java deleted file mode 100644 index 1b5f4fffb..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/TagFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tag; - -import java.util.function.Supplier; - -import net.minecraft.block.Block; -import net.minecraft.entity.EntityType; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.Item; -import net.minecraft.tag.BlockTags; -import net.minecraft.tag.EntityTypeTags; -import net.minecraft.tag.FluidTags; -import net.minecraft.tag.GameEventTags; -import net.minecraft.tag.ItemTags; -import net.minecraft.tag.Tag; -import net.minecraft.tag.TagGroup; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.event.GameEvent; - -import net.fabricmc.fabric.impl.tag.extension.TagFactoryImpl; - -/** - * A factory for accessing datapack tags. - */ -public interface TagFactory<T> { - TagFactory<Item> ITEM = of(ItemTags::getTagGroup); - TagFactory<Block> BLOCK = of(BlockTags::getTagGroup); - TagFactory<Fluid> FLUID = of(FluidTags::getTagGroup); - TagFactory<GameEvent> GAME_EVENT = of(GameEventTags::getTagGroup); - TagFactory<EntityType<?>> ENTITY_TYPE = of(EntityTypeTags::getTagGroup); - TagFactory<Biome> BIOME = of(Registry.BIOME_KEY, "tags/biomes"); - - /** - * Create a new tag factory for specified registry. - * - * @param registryKey the key of the registry. - * @param dataType the data type of this tag group, vanilla uses "tags/[plural]" format for built-in groups. - */ - static <T> TagFactory<T> of(RegistryKey<? extends Registry<T>> registryKey, String dataType) { - return TagFactoryImpl.of(registryKey, dataType); - } - - static <T> TagFactory<T> of(Supplier<TagGroup<T>> tagGroupSupplier) { - return TagFactoryImpl.of(tagGroupSupplier); - } - - Tag.Identified<T> create(Identifier id); -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/TagRegistry.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/TagRegistry.java deleted file mode 100644 index 9e0dccf7d..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/TagRegistry.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tag; - -import java.util.function.Supplier; - -import net.minecraft.block.Block; -import net.minecraft.entity.EntityType; -import net.minecraft.fluid.Fluid; -import net.minecraft.item.Item; -import net.minecraft.tag.Tag; -import net.minecraft.tag.TagGroup; -import net.minecraft.util.Identifier; - -import net.fabricmc.fabric.impl.tag.extension.TagDelegate; - -/** - * Helper methods for registering Tags. - * - * @deprecated use {@link TagFactory} instead. - */ -@Deprecated -public final class TagRegistry { - private TagRegistry() { } - - public static <T> Tag.Identified<T> create(Identifier id, Supplier<TagGroup<T>> containerSupplier) { - return new TagDelegate<>(id, containerSupplier); - } - - /** - * @deprecated use {@link TagFactory#BLOCK} - */ - @Deprecated - public static Tag<Block> block(Identifier id) { - return TagFactory.BLOCK.create(id); - } - - /** - * @deprecated use {@link TagFactory#ENTITY_TYPE} - */ - @Deprecated - public static Tag<EntityType<?>> entityType(Identifier id) { - return TagFactory.ENTITY_TYPE.create(id); - } - - /** - * @deprecated use {@link TagFactory#FLUID} - */ - @Deprecated - public static Tag<Fluid> fluid(Identifier id) { - return TagFactory.FLUID.create(id); - } - - /** - * @deprecated use {@link TagFactory#ITEM} - */ - @Deprecated - public static Tag<Item> item(Identifier id) { - return TagFactory.ITEM.create(id); - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/FabricTagManagerHooks.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/FabricTagManagerHooks.java deleted file mode 100644 index 005a473c2..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/FabricTagManagerHooks.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tag.extension; - -import net.minecraft.tag.TagGroup; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; - -public interface FabricTagManagerHooks { - void fabric_addTagGroup(RegistryKey<? extends Registry<?>> registryKey, TagGroup<?> tagGroup); -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/TagDelegate.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/TagDelegate.java deleted file mode 100644 index db6ebbe31..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/TagDelegate.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tag.extension; - -import java.util.List; -import java.util.function.Supplier; - -import net.minecraft.tag.TagGroup; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; - -import net.fabricmc.fabric.api.tag.FabricTag; - -public final class TagDelegate<T> implements Tag.Identified<T>, FabricTag<T>, FabricTagHooks { - private final Identifier id; - private final Supplier<TagGroup<T>> containerSupplier; - private volatile Target<T> target; - private int clearCount; - - public TagDelegate(Identifier id, Supplier<TagGroup<T>> containerSupplier) { - this.id = id; - this.containerSupplier = containerSupplier; - } - - @Override - public boolean contains(T var1) { - return getTag().contains(var1); - } - - @Override - public List<T> values() { - return getTag().values(); - } - - /** - * Retrieve the tag this delegate is pointing to, computing it if missing or outdated. - * - * <p>Thread safety is being ensured by using an immutable holder object for consistently retrieving both result - * and condition, volatile for safe publishing and assuming TagContainer.getOrCreate is safe to call concurrently. - * - * <p>It should be possible to exploit a benign data race on this.target by removing volatile, but this option - * hasn't been chosen yet since a performance problem in the area is yet to be proven. - */ - private Tag<T> getTag() { - Target<T> target = this.target; - TagGroup<T> reqContainer = containerSupplier.get(); - Tag<T> ret; - - if (target == null || target.container != reqContainer) { - ret = reqContainer.getTagOrEmpty(getId()); - this.target = new Target<>(reqContainer, ret); - } else { - ret = target.tag; - } - - return ret; - } - - @Override - public Identifier getId() { - return id; - } - - @Override - public boolean hasBeenReplaced() { - return clearCount > 0; - } - - @Override - public void fabric_setExtraData(int clearCount) { - this.clearCount = clearCount; - } - - private static final class Target<T> { - Target(TagGroup<T> container, Tag<T> tag) { - this.container = container; - this.tag = tag; - } - - final TagGroup<T> container; - final Tag<T> tag; - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/TagFactoryImpl.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/TagFactoryImpl.java deleted file mode 100644 index 94fea8f15..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/impl/tag/extension/TagFactoryImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tag.extension; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Supplier; - -import com.google.common.base.Preconditions; -import com.google.common.base.Stopwatch; -import org.slf4j.LoggerFactory; -import org.slf4j.Logger; - -import net.minecraft.resource.ResourceManager; -import net.minecraft.resource.ServerResourceManager; -import net.minecraft.server.Main; -import net.minecraft.tag.RequiredTagList; -import net.minecraft.tag.RequiredTagListRegistry; -import net.minecraft.tag.ServerTagManagerHolder; -import net.minecraft.tag.Tag; -import net.minecraft.tag.TagGroup; -import net.minecraft.tag.TagGroupLoader; -import net.minecraft.util.Identifier; -import net.minecraft.util.dynamic.RegistryOps; -import net.minecraft.util.registry.DynamicRegistryManager; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; - -import net.fabricmc.fabric.api.tag.TagFactory; -import net.fabricmc.fabric.mixin.tag.extension.DynamicRegistryManagerAccessor; - -@SuppressWarnings("ClassCanBeRecord") -public final class TagFactoryImpl<T> implements TagFactory<T> { - private static final Logger LOGGER = LoggerFactory.getLogger(TagFactoryImpl.class); - - public static final Map<RegistryKey<? extends Registry<?>>, RequiredTagList<?>> TAG_LISTS = new HashMap<>(); - - public static <T> TagFactory<T> of(Supplier<TagGroup<T>> tagGroupSupplier) { - return new TagFactoryImpl<>(tagGroupSupplier); - } - - @SuppressWarnings("unchecked") - public static <T> TagFactory<T> of(RegistryKey<? extends Registry<T>> registryKey, String dataType) { - RequiredTagList<T> tagList; - - // Use already registered tag list for the registry if it has the same dataType, in case multiple mods tried to do it. - if (TAG_LISTS.containsKey(registryKey)) { - tagList = (RequiredTagList<T>) TAG_LISTS.get(registryKey); - // Throw an exception if the tagList has different dataType. - Preconditions.checkArgument(tagList.getDataType().equals(dataType), "Tag list for registry %s is already existed with data type %s", registryKey.getValue(), tagList.getDataType()); - } else { - tagList = RequiredTagListRegistry.register(registryKey, dataType); - TAG_LISTS.put(registryKey, tagList); - } - - return of(tagList::getGroup); - } - - /** - * Manually load tags for dynamic registries and add the resulting tag group to the tag list. - * - * <p>Minecraft loads the resource manager before dynamic registries, making tags for them fail to load - * if it mentions datapack entries. The solution is to manually load tags after the registry is loaded. - * - * <p>Look at server's {@link Main#main} function calls for {@link ServerResourceManager#reload} and - * {@link RegistryOps#ofLoaded} for the relevant code. - */ - public static void loadDynamicRegistryTags(DynamicRegistryManager registryManager, ResourceManager resourceManager) { - Stopwatch stopwatch = Stopwatch.createStarted(); - int loadedTags = 0; - - for (RequiredTagList<?> tagList : TAG_LISTS.values()) { - if (isDynamic(tagList)) { - RegistryKey<? extends Registry<?>> registryKey = tagList.getRegistryKey(); - Registry<?> registry = registryManager.get(registryKey); - TagGroupLoader<?> tagGroupLoader = new TagGroupLoader<>(registry::getOrEmpty, tagList.getDataType()); - TagGroup<?> tagGroup = tagGroupLoader.load(resourceManager); - ((FabricTagManagerHooks) ServerTagManagerHolder.getTagManager()).fabric_addTagGroup(registryKey, tagGroup); - tagList.updateTagManager(ServerTagManagerHolder.getTagManager()); - loadedTags += tagGroup.getTags().size(); - } - } - - if (loadedTags > 0) { - LOGGER.info("Loaded {} dynamic registry tags in {}", loadedTags, stopwatch); - } - } - - public static boolean isDynamic(RequiredTagList<?> tagList) { - return DynamicRegistryManagerAccessor.getInfos().containsKey(tagList.getRegistryKey()); - } - - private final Supplier<TagGroup<T>> tagGroupSupplier; - - private TagFactoryImpl(Supplier<TagGroup<T>> tagGroupSupplier) { - this.tagGroupSupplier = tagGroupSupplier; - } - - @Override - public Tag.Identified<T> create(Identifier id) { - return new TagDelegate<>(id, tagGroupSupplier); - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/DynamicRegistryManagerAccessor.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/DynamicRegistryManagerAccessor.java deleted file mode 100644 index 614221590..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/DynamicRegistryManagerAccessor.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tag.extension; - -import java.util.Map; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import net.minecraft.util.registry.DynamicRegistryManager; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; - -@Mixin(DynamicRegistryManager.class) -public interface DynamicRegistryManagerAccessor { - @Accessor("INFOS") - static Map<RegistryKey<? extends Registry<?>>, ?> getInfos() { - throw new AssertionError(); - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinMinecraftServer.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinMinecraftServer.java deleted file mode 100644 index 4a23e1312..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinMinecraftServer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tag.extension; - -import java.util.Collection; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import net.minecraft.resource.ServerResourceManager; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.registry.DynamicRegistryManager; - -import net.fabricmc.fabric.impl.tag.extension.TagFactoryImpl; - -@Mixin(MinecraftServer.class) -public abstract class MixinMinecraftServer { - @Shadow - @Final - protected DynamicRegistryManager.Impl registryManager; - - @SuppressWarnings("UnresolvedMixinReference") - @Inject(method = "method_29440", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ServerResourceManager;loadRegistryTags()V", shift = At.Shift.AFTER)) - private void method_29440(Collection<?> collection, ServerResourceManager serverResourceManager, CallbackInfo ci) { - // Load dynamic registry tags on datapack reload. - TagFactoryImpl.loadDynamicRegistryTags(registryManager, serverResourceManager.getResourceManager()); - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinObjectBuilder.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinObjectBuilder.java deleted file mode 100644 index 045a45c56..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinObjectBuilder.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tag.extension; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; - -import net.fabricmc.fabric.api.tag.FabricDataGeneratorTagBuilder; - -@Mixin(targets = "net.minecraft.data.server.AbstractTagProvider$ObjectBuilder") -public class MixinObjectBuilder<T> implements FabricDataGeneratorTagBuilder<T> { - @Shadow - @Final private Tag.Builder field_23960; - - @Shadow - @Final private String field_23962; - - @Override - public void addOptionalObject(Identifier id) { - field_23960.add(new Tag.OptionalObjectEntry(id), field_23962); - } - - @Override - public void addOptionalTag(Identifier id) { - field_23960.add(new Tag.OptionalTagEntry(id), field_23962); - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinRegistryOps.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinRegistryOps.java deleted file mode 100644 index d2ece30fc..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinRegistryOps.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tag.extension; - -import com.mojang.serialization.DynamicOps; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.dynamic.RegistryOps; -import net.minecraft.util.registry.DynamicRegistryManager; - -import net.fabricmc.fabric.impl.tag.extension.TagFactoryImpl; - -/** - * This mixin loads dynamic registry tags right after datapack entries loaded. - * Needs a higher priority so it will be called before biome modifications. - */ -@Mixin(value = RegistryOps.class, priority = 900) -public class MixinRegistryOps { - @Inject(method = "ofLoaded", at = @At("RETURN")) - private static <T> void afterDynamicRegistryLoaded(DynamicOps<T> dynamicOps, ResourceManager resourceManager, DynamicRegistryManager registryManager, CallbackInfoReturnable<RegistryOps<T>> cir) { - TagFactoryImpl.loadDynamicRegistryTags(registryManager, resourceManager); - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinRequiredTagListRegistry.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinRequiredTagListRegistry.java deleted file mode 100644 index eec8f6254..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinRequiredTagListRegistry.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tag.extension; - -import java.util.HashSet; -import java.util.Set; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.tag.RequiredTagList; -import net.minecraft.tag.RequiredTagListRegistry; - -import net.fabricmc.fabric.impl.tag.extension.TagFactoryImpl; - -@Mixin(RequiredTagListRegistry.class) -public class MixinRequiredTagListRegistry { - @Inject(method = "getBuiltinTags", at = @At("TAIL"), cancellable = true) - private static void getBuiltinTags(CallbackInfoReturnable<Set<RequiredTagList<?>>> cir) { - // Add tag lists registered on fabric to the map. - Set<RequiredTagList<?>> set = new HashSet<>(cir.getReturnValue()); - set.addAll(TagFactoryImpl.TAG_LISTS.values()); - cir.setReturnValue(set); - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagBuilder.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagBuilder.java deleted file mode 100644 index b74f5c919..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagBuilder.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tag.extension; - -import java.util.Collection; -import java.util.List; - -import com.google.gson.JsonObject; -import com.mojang.datafixers.util.Either; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.tag.Tag; - -import net.fabricmc.fabric.api.tag.FabricTagBuilder; -import net.fabricmc.fabric.impl.tag.extension.FabricTagHooks; - -@Mixin(Tag.Builder.class) -public class MixinTagBuilder<T> implements FabricTagBuilder<T> { - @Shadow - private List<Tag.TrackedEntry> entries; - - @Unique - private int fabric_clearCount; - - @Redirect(method = "build", at = @At(value = "INVOKE", target = "Lcom/mojang/datafixers/util/Either;right(Ljava/lang/Object;)Lcom/mojang/datafixers/util/Either;")) - private Either<Collection<Tag.TrackedEntry>, Object> build(Object tagObj) { - ((FabricTagHooks) tagObj).fabric_setExtraData(fabric_clearCount); - return Either.right(tagObj); - } - - @Inject(at = @At(value = "INVOKE", target = "Ljava/util/List;clear()V"), method = "read") - public void onFromJsonClear(JsonObject json, String packName, CallbackInfoReturnable<Tag.Builder> info) { - fabric_clearCount++; - } - - @Override - public void clearTagEntries() { - entries.clear(); - fabric_clearCount++; - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagImpl.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagImpl.java deleted file mode 100644 index cd93dd71d..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tag.extension; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -import net.minecraft.tag.Tag; -import net.minecraft.tag.SetTag; - -import net.fabricmc.fabric.api.tag.FabricTag; -import net.fabricmc.fabric.impl.tag.extension.FabricTagHooks; - -@Mixin(value = {SetTag.class}, targets = {"net.minecraft.tag.RequiredTagList$TagWrapper"}) -public abstract class MixinTagImpl<T> implements FabricTag<T>, FabricTagHooks, Tag<T> { - @Unique - private int fabric_clearCount; - - @Override - public boolean hasBeenReplaced() { - return fabric_clearCount > 0; - } - - @Override - public void fabric_setExtraData(int clearCount) { - this.fabric_clearCount = clearCount; - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagManager.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagManager.java deleted file mode 100644 index e3b6b6497..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagManager.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tag.extension; - -import java.util.HashMap; -import java.util.Map; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import net.minecraft.tag.TagGroup; -import net.minecraft.tag.TagManager; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; - -import net.fabricmc.fabric.impl.tag.extension.FabricTagManagerHooks; - -@Mixin(TagManager.class) -public class MixinTagManager implements FabricTagManagerHooks { - @Shadow - @Mutable - @Final - private Map<RegistryKey<? extends Registry<?>>, TagGroup<?>> tagGroups; - - @Inject(method = "<init>", at = @At("TAIL")) - private void init(Map<RegistryKey<? extends Registry<?>>, TagGroup<?>> tagGroups, CallbackInfo ci) { - // Make it mutable so we can add dynamic registry tags later. - this.tagGroups = new HashMap<>(tagGroups); - } - - @Override - public void fabric_addTagGroup(RegistryKey<? extends Registry<?>> registryKey, TagGroup<?> tagGroup) { - tagGroups.put(registryKey, tagGroup); - } -} diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagManagerLoader.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagManagerLoader.java deleted file mode 100644 index 98c806272..000000000 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/mixin/tag/extension/MixinTagManagerLoader.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tag.extension; - -import java.util.List; -import java.util.concurrent.Executor; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import net.minecraft.resource.ResourceManager; -import net.minecraft.tag.RequiredTagList; -import net.minecraft.tag.TagManagerLoader; - -import net.fabricmc.fabric.impl.tag.extension.TagFactoryImpl; - -@Mixin(TagManagerLoader.class) -public abstract class MixinTagManagerLoader { - // RequiredTagListRegistry.forEach in reload. - @SuppressWarnings("UnresolvedMixinReference") - @Inject(method = "method_33179", at = @At("HEAD"), cancellable = true) - private void method_33179(ResourceManager resourceManager, Executor executor, List<?> list, RequiredTagList<?> requiredTagList, CallbackInfo ci) { - // Don't load dynamic registry tags now, we need to load them after the dynamic registry. - if (TagFactoryImpl.isDynamic(requiredTagList)) { - ci.cancel(); - } - } -} diff --git a/fabric-tag-extensions-v0/src/main/resources/assets/fabric-tag-extensions-v0/icon.png b/fabric-tag-extensions-v0/src/main/resources/assets/fabric-tag-extensions-v0/icon.png deleted file mode 100644 index 2931efbf6..000000000 Binary files a/fabric-tag-extensions-v0/src/main/resources/assets/fabric-tag-extensions-v0/icon.png and /dev/null differ diff --git a/fabric-tag-extensions-v0/src/main/resources/fabric-tag-extensions-v0.mixins.json b/fabric-tag-extensions-v0/src/main/resources/fabric-tag-extensions-v0.mixins.json deleted file mode 100644 index 4822ac834..000000000 --- a/fabric-tag-extensions-v0/src/main/resources/fabric-tag-extensions-v0.mixins.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "required": true, - "package": "net.fabricmc.fabric.mixin.tag.extension", - "compatibilityLevel": "JAVA_16", - "mixins": [ - "DynamicRegistryManagerAccessor", - "MixinMinecraftServer", - "MixinObjectBuilder", - "MixinRegistryOps", - "MixinRequiredTagListRegistry", - "MixinTagBuilder", - "MixinTagImpl", - "MixinTagManager", - "MixinTagManagerLoader" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/fabric-tag-extensions-v0/src/main/resources/fabric.mod.json b/fabric-tag-extensions-v0/src/main/resources/fabric.mod.json deleted file mode 100644 index fae990293..000000000 --- a/fabric-tag-extensions-v0/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "schemaVersion": 1, - "id": "fabric-tag-extensions-v0", - "name": "Fabric Tag Extensions (v0)", - "version": "${version}", - "environment": "*", - "license": "Apache-2.0", - "icon": "assets/fabric-tag-extensions-v0/icon.png", - "contact": { - "homepage": "https://fabricmc.net", - "irc": "irc://irc.esper.net:6667/fabric", - "issues": "https://github.com/FabricMC/fabric/issues", - "sources": "https://github.com/FabricMC/fabric" - }, - "authors": [ - "FabricMC" - ], - "depends": { - "fabricloader": ">=0.4.0", - "fabric-api-base": "*", - "fabric-resource-loader-v0": "*" - }, - "description": "Hooks for tags.", - "mixins": [ - "fabric-tag-extensions-v0.mixins.json" - ], - "custom": { - "fabric-api:module-lifecycle": "stable" - } -} diff --git a/fabric-tag-extensions-v0/src/testmod/java/net/fabricmc/fabric/test/tag/extension/TagExtensionTest.java b/fabric-tag-extensions-v0/src/testmod/java/net/fabricmc/fabric/test/tag/extension/TagExtensionTest.java deleted file mode 100644 index b080c794f..000000000 --- a/fabric-tag-extensions-v0/src/testmod/java/net/fabricmc/fabric/test/tag/extension/TagExtensionTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.test.tag.extension; - -import static net.minecraft.server.command.CommandManager.literal; - -import java.util.Map; -import java.util.Optional; - -import net.minecraft.tag.Tag; -import net.minecraft.text.LiteralText; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.biome.Biome; - -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; -import net.fabricmc.fabric.api.tag.TagFactory; - -public class TagExtensionTest implements ModInitializer { - static final Tag<Biome> FACTORY_TEST = TagFactory.BIOME.create(new Identifier("fabric-tag-extensions-v0-testmod:factory_test")); - - @Override - public void onInitialize() { - CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> dispatcher.register(literal("biome_tag_test") - .then(literal("factory").executes(context -> { - FACTORY_TEST.values().forEach(biome -> { - Identifier id = context.getSource().getRegistryManager().get(Registry.BIOME_KEY).getId(biome); - context.getSource().sendFeedback(new LiteralText(id.toString()), false); - }); - return 1; - })) - .then(literal("list_all").executes(context -> { - Map<Identifier, Tag<Biome>> tags = context.getSource().getServer().getTagManager().getOrCreateTagGroup(Registry.BIOME_KEY).getTags(); - tags.forEach((tagId, tag) -> { - LiteralText text = new LiteralText(tagId.toString() + ":"); - tag.values().forEach(biome -> { - Optional<RegistryKey<Biome>> biomeKey = context.getSource().getRegistryManager().get(Registry.BIOME_KEY).getKey(biome); - biomeKey.ifPresent(key -> text.append(" " + key.getValue())); - }); - context.getSource().sendFeedback(text, false); - }); - return 1; - })))); - } -} diff --git a/fabric-tag-extensions-v0/src/testmod/java/net/fabricmc/fabric/test/tag/extension/TagExtensionTestClient.java b/fabric-tag-extensions-v0/src/testmod/java/net/fabricmc/fabric/test/tag/extension/TagExtensionTestClient.java deleted file mode 100644 index 22295a972..000000000 --- a/fabric-tag-extensions-v0/src/testmod/java/net/fabricmc/fabric/test/tag/extension/TagExtensionTestClient.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.test.tag.extension; - -import org.lwjgl.glfw.GLFW; - -import net.minecraft.client.option.KeyBinding; -import net.minecraft.text.LiteralText; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; - -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; - -public class TagExtensionTestClient implements ClientModInitializer { - static final KeyBinding KEY_BINDING = KeyBindingHelper.registerKeyBinding(new KeyBinding("tag_test", GLFW.GLFW_KEY_EQUAL, "tag_test")); - - @Override - public void onInitializeClient() { - ClientTickEvents.END_CLIENT_TICK.register(client -> { - if (KEY_BINDING.isPressed()) { - TagExtensionTest.FACTORY_TEST.values().forEach(biome -> { - Identifier id = client.getNetworkHandler().getRegistryManager().get(Registry.BIOME_KEY).getId(biome); - client.player.sendMessage(new LiteralText(id.toString()), false); - }); - } - }); - } -} diff --git a/fabric-tag-extensions-v0/src/testmod/resources/data/fabric-tag-extensions-v0-testmod/tags/biomes/factory_test.json b/fabric-tag-extensions-v0/src/testmod/resources/data/fabric-tag-extensions-v0-testmod/tags/biomes/factory_test.json deleted file mode 100644 index f6fea9b4f..000000000 --- a/fabric-tag-extensions-v0/src/testmod/resources/data/fabric-tag-extensions-v0-testmod/tags/biomes/factory_test.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:plains", - "minecraft:desert", - "fabric-tag-extensions-v0-testmod:test" - ] -} diff --git a/fabric-tag-extensions-v0/src/testmod/resources/data/fabric-tag-extensions-v0-testmod/tags/biomes/json_only_test.json b/fabric-tag-extensions-v0/src/testmod/resources/data/fabric-tag-extensions-v0-testmod/tags/biomes/json_only_test.json deleted file mode 100644 index 06552ac6a..000000000 --- a/fabric-tag-extensions-v0/src/testmod/resources/data/fabric-tag-extensions-v0-testmod/tags/biomes/json_only_test.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:forest", - "minecraft:taiga" - ] -} diff --git a/fabric-tag-extensions-v0/src/testmod/resources/data/fabric-tag-extensions-v0-testmod/worldgen/biome/test.json b/fabric-tag-extensions-v0/src/testmod/resources/data/fabric-tag-extensions-v0-testmod/worldgen/biome/test.json deleted file mode 100644 index c3aefe3a1..000000000 --- a/fabric-tag-extensions-v0/src/testmod/resources/data/fabric-tag-extensions-v0-testmod/worldgen/biome/test.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "surface_builder": "minecraft:grass", - "depth": 0.125, - "scale": 0.05, - "temperature": 0.8, - "downfall": 0.4, - "precipitation": "rain", - "category": "plains", - "effects": { - "sky_color": 7907327, - "fog_color": 12638463, - "water_color": 4159204, - "water_fog_color": 329011 - }, - "starts": [], - "spawners": {}, - "spawn_costs": {}, - "carvers": {}, - "features": [] -} diff --git a/fabric-tag-extensions-v0/src/testmod/resources/fabric.mod.json b/fabric-tag-extensions-v0/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 4c94b66df..000000000 --- a/fabric-tag-extensions-v0/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "schemaVersion": 1, - "id": "fabric-tag-extensions-v0-testmod", - "name": "Fabric Tag Extensions (v0) Test Mod", - "version": "1.0.0", - "environment": "*", - "license": "Apache-2.0", - "depends": { - "fabric-tag-extensions-v0": "*" - }, - "entrypoints": { - "main": [ - "net.fabricmc.fabric.test.tag.extension.TagExtensionTest" - ], - "client": [ - "net.fabricmc.fabric.test.tag.extension.TagExtensionTestClient" - ] - } -} diff --git a/fabric-tool-attribute-api-v1/build.gradle b/fabric-tool-attribute-api-v1/build.gradle deleted file mode 100644 index 08f02c480..000000000 --- a/fabric-tool-attribute-api-v1/build.gradle +++ /dev/null @@ -1,14 +0,0 @@ -archivesBaseName = "fabric-tool-attribute-api-v1" -version = getSubprojectVersion(project) - -dependencies { - testmodImplementation project(path: ':fabric-object-builder-api-v1', configuration: 'namedElements') - testmodImplementation project(path: ':fabric-lifecycle-events-v1', configuration: 'namedElements') - testmodImplementation project(path: ':fabric-resource-loader-v0', configuration: 'namedElements') -} - -moduleDependencies(project, [ - 'fabric-api-base', - 'fabric-mining-level-api-v1', - 'fabric-tag-extensions-v0' -]) diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/DynamicAttributeTool.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/DynamicAttributeTool.java deleted file mode 100644 index a4b1da30a..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/DynamicAttributeTool.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tool.attribute.v1; - -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Multimap; -import org.jetbrains.annotations.Nullable; - -import net.minecraft.block.BlockState; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tag.Tag; - -/** - * Interface for adding various tool attributes to items. - * - * <p> Functions in this interface will provide user context if it is available. - * These context parameters are provided on a best-effort basis, and implementations should not fail hard if they are absent.</p> - */ -public interface DynamicAttributeTool { - Multimap<EntityAttribute, EntityAttributeModifier> EMPTY = ImmutableSetMultimap.of(); - - /** - * Determines the mining level of the passed stack, which is used for calculating what blocks this tool is allowed to break. - * - * @param stack The item stack being used to mine the block - * @param user The current user of the tool, or null if there isn't any - * @return The mining level of the item. 3 is equal to a diamond pick. - * @deprecated Use {@link #getMiningLevel(Tag, BlockState, ItemStack, LivingEntity)} to detect tag and block. - */ - @Deprecated - default int getMiningLevel(ItemStack stack, @Nullable LivingEntity user) { - return 0; - } - - /** - * Determines the mining level of the passed stack, which is used for calculating what blocks this tool is allowed to break. - * - * @param tag The tool tag the item stack is being compared to - * @param state The block to mine - * @param stack The item stack being used to mine the block - * @param user The current user of the tool, or null if there isn't any - * @return The mining level of the item. 3 is equal to a diamond pick. - */ - default int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) { - return getMiningLevel(stack, user); - } - - /** - * Determines the mining speed multiplier of the passed stack, which is one factor in overall mining speed. - * - * @param stack The item stack being used to mine the block - * @param user The current user of the tool, or null if there isn't any - * @return The mining speed multiplier of the item. 8.0 is equal to a diamond pick. - * @deprecated Use {@link #getMiningSpeedMultiplier(Tag, BlockState, ItemStack, LivingEntity)} to detect tag and block. - */ - @Deprecated - default float getMiningSpeedMultiplier(ItemStack stack, @Nullable LivingEntity user) { - return 1.0F; - } - - /** - * Determines the mining speed multiplier of the passed stack, which is one factor in overall mining speed. - * - * @param tag The tool tag the item stack is being compared to - * @param state The block to mine - * @param stack The item stack being used to mine the block - * @param user The current user of the tool, or null if there isn't any - * @return The mining speed multiplier of the item. 8.0 is equal to a diamond pick. - */ - default float getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) { - return getMiningSpeedMultiplier(stack, user); - } - - /** - * Post process the mining speed, this takes place after the mining speed has been calculated. - * - * <p>This allows bypassing the regular computation formula. - * - * @param tag The tool tag the item stack is handled by - * @param state The block to mine - * @param stack The item stack being used to mine the block - * @param user The current user of the tool, or null if there isn't any - * @param currentSpeed The mining speed before post process - * @param isEffective whether the tool has been handled - * @return the speed after post processing - */ - default float postProcessMiningSpeed(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user, float currentSpeed, boolean isEffective) { - return currentSpeed; - } - - /** - * Add modifiers for any {@link net.minecraft.entity.attribute.EntityAttributes} your item should give when equipped, based on the stack. - * - * <p>Appends to either attribute modifier NBT or the result from {@link net.minecraft.item.Item#getAttributeModifiers(EquipmentSlot)}. - * The attributes returned from this method will only be applied to an entity when the {@link ItemStack} providing the attributes is modified, or the player re-selects the stack in their hotbar. - * If your attribute relies on data from outside the stack, such as the user's age, you will need to modify the stack in some way to re-assign attributes to the entity. - * A fix for this may be provided in the future.</p> - * - * @param slot The equipment slot this item is equipped in. - * @param stack The stack that's equipped. - * @param user The current user of the tool, if available. - * @return The dynamic modifiers to add on top of other modifiers on this stack. If none, return {@link #EMPTY}. - */ - default Multimap<EntityAttribute, EntityAttributeModifier> getDynamicModifiers(EquipmentSlot slot, ItemStack stack, @Nullable LivingEntity user) { - return EMPTY; - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/FabricToolTags.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/FabricToolTags.java deleted file mode 100644 index 854d52fa9..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/FabricToolTags.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tool.attribute.v1; - -import net.minecraft.item.Item; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; - -import net.fabricmc.fabric.api.tag.TagRegistry; - -/** - * Tool item tags provided by Fabric. - */ -public class FabricToolTags { - public static final Tag<Item> AXES = register("axes"); - public static final Tag<Item> HOES = register("hoes"); - public static final Tag<Item> PICKAXES = register("pickaxes"); - public static final Tag<Item> SHOVELS = register("shovels"); - public static final Tag<Item> SWORDS = register("swords"); - public static final Tag<Item> SHEARS = register("shears"); - - private FabricToolTags() { } - - private static Tag<Item> register(String id) { - return TagRegistry.item(new Identifier("fabric", id)); - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/ToolManager.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/ToolManager.java deleted file mode 100644 index cee41dfb3..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/api/tool/attribute/v1/ToolManager.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tool.attribute.v1; - -import org.jetbrains.annotations.Nullable; - -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; - -import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; - -/** - * API facing part to register tool handlers and get information about how tools are handled. - * Implement {@link DynamicAttributeTool} to change the mining level or speed of your tool depending on the {@link ItemStack}. - */ -public final class ToolManager { - /** - * Handles if the tool is effective on a block. - * - * @param state the block state to break - * @param stack the item stack involved with breaking the block - * @param user the user involved in breaking the block, null if not applicable. - * @return whether the tool is effective - */ - public static boolean handleIsEffectiveOn(BlockState state, ItemStack stack, @Nullable LivingEntity user) { - return stack.isSuitableFor(state) || handleIsEffectiveOnIgnoresVanilla(state, stack, user, false); - } - - /** - * Handles if the tool is effective on a block, ignores vanilla tools on vanilla blocks. - * - * @param state the block state to break - * @param stack the item stack involved with breaking the block - * @param user the user involved in breaking the block, null if not applicable. - * @param vanillaResult whether the tool is considered effective by vanilla - * @return whether the tool is effective - */ - public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemStack stack, @Nullable LivingEntity user, boolean vanillaResult) { - return ToolManagerImpl.handleIsEffectiveOnIgnoresVanilla(state, stack, user, vanillaResult); - } - - /** - * Handles if the tool is effective on a block, ignores vanilla tools on vanilla blocks. - * - * @param state the block state to break - * @param stack the item stack involved with breaking the block - * @param user the user involved in breaking the block, null if not applicable. - * @return whether the tool is effective - */ - public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemStack stack, @Nullable LivingEntity user) { - return ToolManagerImpl.handleIsEffectiveOnIgnoresVanilla(state, stack, user, false); - } - - /** - * Handles the breaking speed breaking a block. - * - * @param state the block state to break - * @param stack the item stack involved with breaking the block - * @param user the user involved in breaking the block, null if not applicable. - * @return the speed multiplier in breaking the block, 1.0 if no change. - */ - public static float handleBreakingSpeed(BlockState state, ItemStack stack, @Nullable LivingEntity user) { - return Math.max(stack.getMiningSpeedMultiplier(state), handleBreakingSpeedIgnoresVanilla(state, stack, user)); - } - - /** - * Handles the breaking speed breaking a block, ignores vanilla tools on vanilla blocks. - * - * @param state the block state to break - * @param stack the item stack involved with breaking the block - * @param user the user involved in breaking the block, null if not applicable. - * @return the speed multiplier in breaking the block, 1.0 if no change. - */ - public static float handleBreakingSpeedIgnoresVanilla(BlockState state, ItemStack stack, @Nullable LivingEntity user) { - return ToolManagerImpl.handleBreakingSpeedIgnoresVanilla(state, stack, user); - } - - private ToolManager() { - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ItemStackContext.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ItemStackContext.java deleted file mode 100644 index 147bd7018..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ItemStackContext.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tool.attribute; - -import org.jetbrains.annotations.Nullable; - -import net.minecraft.entity.LivingEntity; - -public interface ItemStackContext { - void fabricToolAttributes_setContext(@Nullable LivingEntity contextEntity); -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ToolHandlers.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ToolHandlers.java deleted file mode 100644 index e60801889..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ToolHandlers.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tool.attribute; - -import java.util.Arrays; - -import net.minecraft.item.Items; -import net.minecraft.tag.BlockTags; - -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.mininglevel.v1.FabricMineableTags; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.fabricmc.fabric.impl.tool.attribute.handlers.ModdedToolsModdedBlocksToolHandler; -import net.fabricmc.fabric.impl.tool.attribute.handlers.ModdedToolsVanillaBlocksToolHandler; -import net.fabricmc.fabric.impl.tool.attribute.handlers.ShearsVanillaBlocksToolHandler; -import net.fabricmc.fabric.impl.tool.attribute.handlers.TaggedToolsModdedBlocksToolHandler; -import net.fabricmc.fabric.impl.tool.attribute.handlers.TaggedToolsTaggedBlocksToolHandler; -import net.fabricmc.fabric.impl.tool.attribute.handlers.VanillaToolsModdedBlocksToolHandler; - -/** - * Entrypoint to register the default tool handlers. - */ -public class ToolHandlers implements ModInitializer { - @Override - public void onInitialize() { - ToolManagerImpl.general().register(new ModdedToolsModdedBlocksToolHandler()); - ToolManagerImpl.general().register(new VanillaToolsModdedBlocksToolHandler()); - ToolManagerImpl.general().register(new TaggedToolsModdedBlocksToolHandler()); - ToolManagerImpl.tag(FabricToolTags.PICKAXES).register(new ModdedToolsVanillaBlocksToolHandler( - Arrays.asList( - Items.WOODEN_PICKAXE, - Items.STONE_PICKAXE, - Items.IRON_PICKAXE, - Items.DIAMOND_PICKAXE, - Items.NETHERITE_PICKAXE - ) - )); - ToolManagerImpl.tag(FabricToolTags.AXES).register(new ModdedToolsVanillaBlocksToolHandler( - Arrays.asList( - Items.WOODEN_AXE, - Items.STONE_AXE, - Items.IRON_AXE, - Items.DIAMOND_AXE, - Items.NETHERITE_AXE - ) - )); - ToolManagerImpl.tag(FabricToolTags.SHOVELS).register(new ModdedToolsVanillaBlocksToolHandler( - Arrays.asList( - Items.WOODEN_SHOVEL, - Items.STONE_SHOVEL, - Items.IRON_SHOVEL, - Items.DIAMOND_SHOVEL, - Items.NETHERITE_SHOVEL - ) - )); - ToolManagerImpl.tag(FabricToolTags.HOES).register(new ModdedToolsVanillaBlocksToolHandler( - Arrays.asList( - Items.WOODEN_HOE, - Items.STONE_HOE, - Items.IRON_HOE, - Items.DIAMOND_HOE, - Items.NETHERITE_HOE - ) - )); - ToolManagerImpl.tag(FabricToolTags.SWORDS).register(new ModdedToolsVanillaBlocksToolHandler( - Arrays.asList( - Items.WOODEN_SWORD, - Items.STONE_SWORD, - Items.IRON_SWORD, - Items.DIAMOND_SWORD, - Items.NETHERITE_SWORD - ) - )); - ToolManagerImpl.tag(FabricToolTags.SHEARS).register(new ShearsVanillaBlocksToolHandler()); - ToolManagerImpl.tag(FabricToolTags.AXES).register(new TaggedToolsTaggedBlocksToolHandler(BlockTags.AXE_MINEABLE)); - ToolManagerImpl.tag(FabricToolTags.HOES).register(new TaggedToolsTaggedBlocksToolHandler(BlockTags.HOE_MINEABLE)); - ToolManagerImpl.tag(FabricToolTags.PICKAXES).register(new TaggedToolsTaggedBlocksToolHandler(BlockTags.PICKAXE_MINEABLE)); - ToolManagerImpl.tag(FabricToolTags.SHEARS).register(new TaggedToolsTaggedBlocksToolHandler(FabricMineableTags.SHEARS_MINEABLE)); - ToolManagerImpl.tag(FabricToolTags.SHOVELS).register(new TaggedToolsTaggedBlocksToolHandler(BlockTags.SHOVEL_MINEABLE)); - ToolManagerImpl.tag(FabricToolTags.SWORDS).register(new TaggedToolsTaggedBlocksToolHandler(FabricMineableTags.SWORD_MINEABLE)); - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ToolManagerImpl.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ToolManagerImpl.java deleted file mode 100644 index 705870eaf..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/ToolManagerImpl.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tool.attribute; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Objects; - -import com.google.common.collect.ImmutableMap; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tag.BlockTags; -import net.minecraft.tag.Tag; -import net.minecraft.util.ActionResult; -import net.minecraft.util.TypedActionResult; - -import net.fabricmc.fabric.api.event.Event; -import net.fabricmc.fabric.api.event.EventFactory; -import net.fabricmc.fabric.api.mininglevel.v1.FabricMineableTags; -import net.fabricmc.fabric.api.mininglevel.v1.MiningLevelManager; -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.fabricmc.fabric.api.util.TriState; - -public final class ToolManagerImpl { - private static final Map<Tag<Item>, Tag<Block>> MINEABLE_TAG_BY_TOOL = ImmutableMap.<Tag<Item>, Tag<Block>>builder() - // Vanilla mineable tags - .put(FabricToolTags.AXES, BlockTags.AXE_MINEABLE) - .put(FabricToolTags.HOES, BlockTags.HOE_MINEABLE) - .put(FabricToolTags.PICKAXES, BlockTags.PICKAXE_MINEABLE) - .put(FabricToolTags.SHOVELS, BlockTags.SHOVEL_MINEABLE) - // Fabric mineable tags - .put(FabricToolTags.SHEARS, FabricMineableTags.SHEARS_MINEABLE) - .put(FabricToolTags.SWORDS, FabricMineableTags.SWORD_MINEABLE) - .build(); - - public interface Entry { - void setBreakByHand(boolean value); - - void putBreakByTool(Tag<Item> tag, int miningLevel); - - int getMiningLevel(Tag<Item> tag); - } - - private static class EntryImpl implements Entry { - private final Block block; - private Tag<Item>[] tags = new Tag[0]; - private int[] tagLevels = new int[0]; - private TriState defaultValue = TriState.DEFAULT; - - private EntryImpl(Block block) { - this.block = block; - } - - @Override - public void setBreakByHand(boolean value) { - this.defaultValue = TriState.of(value); - } - - @Override - public void putBreakByTool(Tag<Item> tag, int miningLevel) { - tag(tag); // Generate tag entry - - for (int i = 0; i < tags.length; i++) { - if (tags[i] == tag) { - tagLevels[i] = miningLevel; - return; - } - } - - tags = Arrays.copyOf(tags, tags.length + 1); - tags[tags.length - 1] = tag; - - tagLevels = Arrays.copyOf(tagLevels, tagLevels.length + 1); - tagLevels[tagLevels.length - 1] = miningLevel; - } - - @Override - public int getMiningLevel(Tag<Item> tag) { - // Implementation detail: the actual logic does not check the state. - // TODO: This should be changed some day to respect the block state, - // but the entry code is quite coupled in blocks instead of states. - int miningLevel = MiningLevelManager.getRequiredMiningLevel(block.getDefaultState()); - - for (int i = 0; i < tags.length; i++) { - if (tags[i] == tag) { - miningLevel = Math.max(miningLevel, tagLevels[i]); - } - } - - for (Tag<Item> key : MINEABLE_TAG_BY_TOOL.keySet()) { - if (tag == key && MINEABLE_TAG_BY_TOOL.get(key).contains(block)) { - miningLevel = Math.max(miningLevel, 0); - } - } - - return miningLevel; - } - } - - private static final Map<Tag<Item>, Event<ToolHandler>> HANDLER_MAP = new HashMap<>(); - private static final Event<ToolHandler> GENERAL_TOOLS_HANDLER = EventFactory.createArrayBacked(ToolHandler.class, ToolManagerImpl::toolHandlerInvoker); - - private static final Map<Block, EntryImpl> ENTRIES = new IdentityHashMap<>(); - - /** - * Returns a event for the tag provided, creates a new event if it does not exist. - * - * @param tag the tag provided for the tool - * @return the event callback. - */ - public static Event<ToolHandler> tag(Tag<Item> tag) { - for (Map.Entry<Tag<Item>, Event<ToolHandler>> entry : HANDLER_MAP.entrySet()) { - if ((tag instanceof Tag.Identified ? (((Tag.Identified<Item>) entry.getKey()).getId().equals(((Tag.Identified<Item>) tag).getId())) : entry.getKey().equals(tag))) { - return entry.getValue(); - } - } - - HANDLER_MAP.put(tag, EventFactory.createArrayBacked(ToolHandler.class, ToolManagerImpl::toolHandlerInvoker)); - return HANDLER_MAP.get(tag); - } - - /** - * Returns a event used for every tag registered. - * - * @return the event callback. - */ - public static Event<ToolHandler> general() { - return GENERAL_TOOLS_HANDLER; - } - - private static ToolHandler toolHandlerInvoker(ToolHandler[] toolHandlers) { - return new ToolHandler() { - @NotNull - @Override - public ActionResult isEffectiveOn(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - for (ToolHandler toolHandler : toolHandlers) { - ActionResult effectiveOn = Objects.requireNonNull(toolHandler.isEffectiveOn(tag, state, stack, user)); - - if (effectiveOn != ActionResult.PASS) { - return effectiveOn; - } - } - - return ActionResult.PASS; - } - - @NotNull - @Override - public TypedActionResult<Float> getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - for (ToolHandler toolHandler : toolHandlers) { - TypedActionResult<Float> miningSpeedMultiplier = Objects.requireNonNull(toolHandler.getMiningSpeedMultiplier(tag, state, stack, user)); - - if (miningSpeedMultiplier.getResult() != ActionResult.PASS) { - return miningSpeedMultiplier; - } - } - - return TypedActionResult.pass(1f); - } - }; - } - - public static Entry entry(Block block) { - return ENTRIES.computeIfAbsent(block, (bb) -> new EntryImpl(block)); - } - - @Nullable - public static Entry entryNullable(Block block) { - return ENTRIES.get(block); - } - - @Deprecated - public static void registerBreakByHand(Block block, boolean value) { - entry(block).setBreakByHand(value); - } - - @Deprecated - public static void registerBreakByTool(Block block, Tag<Item> tag, int miningLevel) { - entry(block).putBreakByTool(tag, miningLevel); - } - - /** - * Hook for ItemStack.isEffectiveOn and similar methods. - */ - public static boolean handleIsEffectiveOnIgnoresVanilla(BlockState state, ItemStack stack, @Nullable LivingEntity user, boolean vanillaResult) { - for (Map.Entry<Tag<Item>, Event<ToolHandler>> eventEntry : HANDLER_MAP.entrySet()) { - if (stack.isIn(eventEntry.getKey())) { - ActionResult effective = eventEntry.getValue().invoker().isEffectiveOn(eventEntry.getKey(), state, stack, user); - if (effective.isAccepted()) return true; - effective = general().invoker().isEffectiveOn(eventEntry.getKey(), state, stack, user); - if (effective.isAccepted()) return true; - } - } - - EntryImpl entry = (EntryImpl) entryNullable(state.getBlock()); - - return (entry != null && entry.defaultValue.get()) || (entry == null && vanillaResult); - } - - public static float handleBreakingSpeedIgnoresVanilla(BlockState state, ItemStack stack, @Nullable LivingEntity user) { - float breakingSpeed = 0f; - Tag<Item> handledTag = null; - boolean handled = false; - - for (Map.Entry<Tag<Item>, Event<ToolHandler>> eventEntry : HANDLER_MAP.entrySet()) { - if (stack.isIn(eventEntry.getKey())) { - TypedActionResult<Float> speedMultiplier = Objects.requireNonNull(eventEntry.getValue().invoker().getMiningSpeedMultiplier(eventEntry.getKey(), state, stack, user)); - - if (speedMultiplier.getResult().isAccepted()) { - handled = true; - - if (speedMultiplier.getValue() > breakingSpeed) { - breakingSpeed = speedMultiplier.getValue(); - handledTag = eventEntry.getKey(); - } - } - - speedMultiplier = Objects.requireNonNull(general().invoker().getMiningSpeedMultiplier(eventEntry.getKey(), state, stack, user)); - - if (speedMultiplier.getResult().isAccepted()) { - handled = true; - - if (speedMultiplier.getValue() > breakingSpeed) { - breakingSpeed = speedMultiplier.getValue(); - handledTag = eventEntry.getKey(); - } - } - } - } - - // Give it a default speed if it is not handled. - breakingSpeed = handled ? breakingSpeed : 1f; - - if (stack.getItem() instanceof DynamicAttributeTool) { - breakingSpeed = ((DynamicAttributeTool) stack.getItem()).postProcessMiningSpeed(handledTag, state, stack, user, breakingSpeed, handled); - } - - return breakingSpeed; - } - - /** - * The handler to handle tool speed and effectiveness. - * - * @see net.fabricmc.fabric.impl.tool.attribute.ToolHandlers for default handlers. - */ - public interface ToolHandler { - /** - * Determines whether this handler is active and effective of the tools. - * - * @param tag the tag involved - * @param state the block state to break - * @param stack the item stack breaking the block - * @param user the user involved in breaking the block, null if not applicable. - * @return the result of effectiveness - */ - @NotNull - default ActionResult isEffectiveOn(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) { - return ActionResult.PASS; - } - - /** - * Determines the mining speed multiplier of the tools. - * - * @param tag the tag involved - * @param state the block state to break - * @param stack the item stack breaking the block - * @param user the user involved in breaking the block, null if not applicable. - * @return the result of mining speed. - */ - @NotNull - default TypedActionResult<Float> getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) { - return TypedActionResult.pass(1.0F); - } - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/ModdedToolsModdedBlocksToolHandler.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/ModdedToolsModdedBlocksToolHandler.java deleted file mode 100644 index f72454e50..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/ModdedToolsModdedBlocksToolHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tool.attribute.handlers; - -import org.jetbrains.annotations.NotNull; - -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tag.Tag; -import net.minecraft.util.ActionResult; -import net.minecraft.util.TypedActionResult; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; -import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; - -/** - * This handler handles items that are an subclass of {@link DynamicAttributeTool} by comparing their mining level - * using {@link DynamicAttributeTool#getMiningLevel(Tag, BlockState, ItemStack, LivingEntity)} and the block mining level. - * - * <p>Only applicable to modded blocks that are registered, as only they have the registered required mining level.</p> - */ -public class ModdedToolsModdedBlocksToolHandler implements ToolManagerImpl.ToolHandler { - @NotNull - @Override - public ActionResult isEffectiveOn(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - if (stack.getItem() instanceof DynamicAttributeTool) { - ToolManagerImpl.Entry entry = ToolManagerImpl.entryNullable(state.getBlock()); - - if (entry != null) { - int miningLevel = ((DynamicAttributeTool) stack.getItem()).getMiningLevel(tag, state, stack, user); - int requiredMiningLevel = entry.getMiningLevel(tag); - - return requiredMiningLevel >= 0 && miningLevel >= 0 && miningLevel >= requiredMiningLevel ? ActionResult.SUCCESS : ActionResult.PASS; - } - } - - return ActionResult.PASS; - } - - @NotNull - @Override - public TypedActionResult<Float> getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - if (stack.getItem() instanceof DynamicAttributeTool) { - ToolManagerImpl.Entry entry = ToolManagerImpl.entryNullable(state.getBlock()); - - if (entry != null && entry.getMiningLevel(tag) >= 0) { - float multiplier = ((DynamicAttributeTool) stack.getItem()).getMiningSpeedMultiplier(tag, state, stack, user); - if (multiplier != 1.0F) return TypedActionResult.success(multiplier); - } - } - - return TypedActionResult.pass(1.0F); - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/ModdedToolsVanillaBlocksToolHandler.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/ModdedToolsVanillaBlocksToolHandler.java deleted file mode 100644 index ad8e16445..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/ModdedToolsVanillaBlocksToolHandler.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tool.attribute.handlers; - -import java.util.List; - -import org.jetbrains.annotations.NotNull; - -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ToolItem; -import net.minecraft.tag.Tag; -import net.minecraft.util.ActionResult; -import net.minecraft.util.TypedActionResult; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; -import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; - -/** - * This handler handles items that are a subclass of {@link DynamicAttributeTool} by using the - * vanilla {@link Item#isSuitableFor(BlockState)} with a custom fake tool material to use the mining level - * from {@link DynamicAttributeTool#getMiningLevel(Tag, BlockState, ItemStack, LivingEntity)}. - * - * <p>Only applicable to blocks that are vanilla or share the material that is handled by their vanilla tool.</p> - */ -public class ModdedToolsVanillaBlocksToolHandler implements ToolManagerImpl.ToolHandler { - private final List<Item> vanillaItems; - - public ModdedToolsVanillaBlocksToolHandler(List<Item> vanillaItems) { - this.vanillaItems = vanillaItems; - } - - private ToolItem getVanillaItem(int miningLevel) { - if (miningLevel < 0) return (ToolItem) vanillaItems.get(0); - if (miningLevel >= vanillaItems.size()) return (ToolItem) vanillaItems.get(vanillaItems.size() - 1); - return (ToolItem) vanillaItems.get(miningLevel); - } - - @NotNull - @Override - public ActionResult isEffectiveOn(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - if (stack.getItem() instanceof DynamicAttributeTool) { - if (ToolManagerImpl.entryNullable(state.getBlock()) != null) { - // Block is a modded block, and we should ignore it - return ActionResult.PASS; - } - - // Gets the mining level from our modded tool - int miningLevel = ((DynamicAttributeTool) stack.getItem()).getMiningLevel(tag, state, stack, user); - if (miningLevel < 0) return ActionResult.PASS; - - ToolItem vanillaItem = getVanillaItem(miningLevel); - return vanillaItem.isSuitableFor(state) ? ActionResult.SUCCESS : ActionResult.PASS; - } - - return ActionResult.PASS; - } - - @NotNull - @Override - public TypedActionResult<Float> getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - if (stack.getItem() instanceof DynamicAttributeTool) { - // Gets the mining level from our modded tool - int miningLevel = ((DynamicAttributeTool) stack.getItem()).getMiningLevel(tag, state, stack, user); - if (miningLevel < 0) return null; - - float moddedToolSpeed = ((DynamicAttributeTool) stack.getItem()).getMiningSpeedMultiplier(tag, state, stack, user); - ToolItem firstVanillaItem = getVanillaItem(miningLevel); - ToolItem secondVanillaItem = getVanillaItem(miningLevel + 1 >= vanillaItems.size() ? vanillaItems.size() - 2 : miningLevel + 1); - - float firstSpeed = firstVanillaItem.getMiningSpeedMultiplier(new ItemStack(firstVanillaItem, 1), state); - float secondSpeed = secondVanillaItem.getMiningSpeedMultiplier(new ItemStack(secondVanillaItem, 1), state); - boolean hasForcedSpeed = firstSpeed == secondSpeed && firstSpeed >= 1.0F; - - // Has forced speed, which as actions like swords breaking cobwebs. - if (hasForcedSpeed) { - return secondSpeed != 1.0F ? TypedActionResult.success(secondSpeed) : TypedActionResult.pass(1.0F); - } - - // We adjust the mining speed according to the ratio for the closest tool. - float adjustedMiningSpeed = firstSpeed / firstVanillaItem.getMaterial().getMiningSpeedMultiplier() * moddedToolSpeed; - return adjustedMiningSpeed != 1.0F ? TypedActionResult.success(adjustedMiningSpeed) : TypedActionResult.pass(1.0F); - } - - return TypedActionResult.pass(1.0F); - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/ShearsVanillaBlocksToolHandler.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/ShearsVanillaBlocksToolHandler.java deleted file mode 100644 index fc4267433..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/ShearsVanillaBlocksToolHandler.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tool.attribute.handlers; - -import org.jetbrains.annotations.NotNull; - -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.ShearsItem; -import net.minecraft.tag.Tag; -import net.minecraft.util.ActionResult; -import net.minecraft.util.TypedActionResult; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; - -/** - * This handler handles items that are registered in the {@link FabricToolTags#SHEARS} by using the - * vanilla {@link Item#isSuitableFor(BlockState)} using the vanilla shears or the item itself if the item - * is a subclass of {@link ShearsItem}. - * - * <p>Only applicable to items that are not a subclass of {@link DynamicAttributeTool}</p> - * <p>Only applicable to blocks that are vanilla or share the material that is handled by their vanilla tool.</p> - */ -public class ShearsVanillaBlocksToolHandler implements ToolManagerImpl.ToolHandler { - private final Item vanillaItem = Items.SHEARS; - - @NotNull - @Override - public ActionResult isEffectiveOn(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - if (ToolManagerImpl.entryNullable(state.getBlock()) != null) { - // Block is a modded block, and we should ignore it - return ActionResult.PASS; - } - - if (!(stack.getItem() instanceof DynamicAttributeTool)) { - if (!(stack.getItem() instanceof ShearsItem)) { - return vanillaItem.isSuitableFor(state) ? ActionResult.SUCCESS : ActionResult.PASS; - } else { - return stack.getItem().isSuitableFor(state) ? ActionResult.SUCCESS : ActionResult.PASS; - } - } - - return ActionResult.PASS; - } - - @NotNull - @Override - public TypedActionResult<Float> getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - float speed = 1.0F; - - if (!(stack.getItem() instanceof DynamicAttributeTool)) { - if (!(stack.getItem() instanceof ShearsItem)) { - speed = vanillaItem.getMiningSpeedMultiplier(new ItemStack(vanillaItem), state); - } else { - speed = stack.getItem().getMiningSpeedMultiplier(stack, state); - } - } - - return speed != 1.0F ? TypedActionResult.success(speed) : TypedActionResult.pass(1.0F); - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/TaggedToolsModdedBlocksToolHandler.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/TaggedToolsModdedBlocksToolHandler.java deleted file mode 100644 index 70fcc1cef..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/TaggedToolsModdedBlocksToolHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tool.attribute.handlers; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ToolItem; -import net.minecraft.tag.Tag; -import net.minecraft.util.ActionResult; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; -import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; - -/** - * This handler handles items that are registered in a tool tag, - * but aren't any known tool items in code. For that reason, we use a few callback values: - * The mining level of this kind of item is always 0, and the mining speed multiplier is always 1. - * - * <p>Only applicable to items that are not a subclass of {@link DynamicAttributeTool} or {@link ToolItem}</p> - */ -public class TaggedToolsModdedBlocksToolHandler implements ToolManagerImpl.ToolHandler { - @NotNull - @Override - public ActionResult isEffectiveOn(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) { - if (!(stack.getItem() instanceof DynamicAttributeTool) && !(stack.getItem() instanceof ToolItem)) { - @Nullable ToolManagerImpl.Entry entry = ToolManagerImpl.entryNullable(state.getBlock()); - - if (entry != null) { - int requiredMiningLevel = entry.getMiningLevel(tag); - // (requiredMiningLevel == 0) is equivalent to - // (requiredMiningLevel >= 0 && toolMiningLevel >= requiredMiningLevel), which is used in other handlers. - // Since the tool mining level of these is always 0 (in the absence of better info), the condition - // simplifies to (== 0). The compiler couldn't optimise the other one... :( - return requiredMiningLevel == 0 ? ActionResult.SUCCESS : ActionResult.PASS; - } - } - - return ActionResult.PASS; - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/TaggedToolsTaggedBlocksToolHandler.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/TaggedToolsTaggedBlocksToolHandler.java deleted file mode 100644 index 83d94e250..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/TaggedToolsTaggedBlocksToolHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tool.attribute.handlers; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ToolItem; -import net.minecraft.tag.Tag; -import net.minecraft.util.ActionResult; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; -import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; - -/** - * This handler handles items that are registered in a tool tag, - * but aren't any known tool items in code. For that reason, we use a few callback values: - * The mining level of this kind of item is always 0, and the mining speed multiplier is always 1. - * - * <p>Only applicable to items that are not a subclass of {@link DynamicAttributeTool} or {@link ToolItem}</p> - */ -public class TaggedToolsTaggedBlocksToolHandler implements ToolManagerImpl.ToolHandler { - private final Tag<Block> mineableTag; - - public TaggedToolsTaggedBlocksToolHandler(Tag<Block> mineableTag) { - this.mineableTag = mineableTag; - } - - @NotNull - @Override - public ActionResult isEffectiveOn(Tag<Item> tag, BlockState state, ItemStack stack, @Nullable LivingEntity user) { - if (!(stack.getItem() instanceof DynamicAttributeTool) && !(stack.getItem() instanceof ToolItem)) { - if (state.isIn(mineableTag)) { - return ActionResult.SUCCESS; - } - } - - return ActionResult.PASS; - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/VanillaToolsModdedBlocksToolHandler.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/VanillaToolsModdedBlocksToolHandler.java deleted file mode 100644 index 71dde018c..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/VanillaToolsModdedBlocksToolHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.tool.attribute.handlers; - -import org.jetbrains.annotations.NotNull; - -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ToolItem; -import net.minecraft.item.ToolMaterial; -import net.minecraft.tag.Tag; -import net.minecraft.util.ActionResult; -import net.minecraft.util.TypedActionResult; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; -import net.fabricmc.fabric.impl.tool.attribute.ToolManagerImpl; - -/** - * This handler handles items that are not a subclass of {@link DynamicAttributeTool} by - * comparing their mining level using {@link ToolMaterial#getMiningLevel()} and the block mining level. - * - * <p>Only applicable to modded blocks that are registered, as only they have the registered required mining level.</p> - */ -public class VanillaToolsModdedBlocksToolHandler implements ToolManagerImpl.ToolHandler { - @NotNull - @Override - public ActionResult isEffectiveOn(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - if (!(stack.getItem() instanceof DynamicAttributeTool)) { - ToolManagerImpl.Entry entry = ToolManagerImpl.entryNullable(state.getBlock()); - - if (entry != null) { - int miningLevel = stack.getItem() instanceof ToolItem ? ((ToolItem) stack.getItem()).getMaterial().getMiningLevel() : -1; - int requiredMiningLevel = entry.getMiningLevel(tag); - return requiredMiningLevel >= 0 && miningLevel >= 0 && miningLevel >= requiredMiningLevel ? ActionResult.SUCCESS : ActionResult.PASS; - } - } - - return ActionResult.PASS; - } - - @NotNull - @Override - public TypedActionResult<Float> getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - if (!(stack.getItem() instanceof DynamicAttributeTool)) { - ToolManagerImpl.Entry entry = ToolManagerImpl.entryNullable(state.getBlock()); - - if (entry != null && entry.getMiningLevel(tag) >= 0) { - float multiplier = stack.getItem() instanceof ToolItem ? ((ToolItem) stack.getItem()).getMaterial().getMiningSpeedMultiplier() : stack.getItem().getMiningSpeedMultiplier(stack, state); - if (multiplier != 1.0F) return TypedActionResult.success(multiplier); - } - } - - return TypedActionResult.pass(1.0F); - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/package-info.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/package-info.java deleted file mode 100644 index d05b632c3..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/handlers/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Implementation handlers of the fabric tool attribute module. - */ -@ApiStatus.Internal -package net.fabricmc.fabric.impl.tool.attribute.handlers; - -import org.jetbrains.annotations.ApiStatus; - diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/package-info.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/package-info.java deleted file mode 100644 index 11f2bc03f..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/impl/tool/attribute/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Implementation of the fabric tool attribute module. - */ -@ApiStatus.Internal -package net.fabricmc.fabric.impl.tool.attribute; - -import org.jetbrains.annotations.ApiStatus; - diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/BambooBlockMixin.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/BambooBlockMixin.java deleted file mode 100644 index b7a9508b8..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/BambooBlockMixin.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tool.attribute; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.block.BambooBlock; -import net.minecraft.block.BambooSaplingBlock; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; - -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; - -@Mixin({BambooBlock.class, BambooSaplingBlock.class}) -public abstract class BambooBlockMixin { - /** - * When the player is holding a {@link net.minecraft.item.SwordItem SwordItem}, Bamboo returns {@code 1.0F} and is instantly mined. - * - * <p>This injection provides that same functionality when mining with items that are in the {@link net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags#SWORDS fabric:swords} tag. - */ - @Inject(at = @At("HEAD"), method = "calcBlockBreakingDelta", cancellable = true) - private void onCalcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos, CallbackInfoReturnable<Float> info) { - if (FabricToolTags.SWORDS.contains(player.getMainHandStack().getItem())) { - info.setReturnValue(1.0F); - } - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/LivingEntityMixin.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/LivingEntityMixin.java deleted file mode 100644 index a3826239d..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/LivingEntityMixin.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tool.attribute; - -import java.util.Map; - -import com.google.common.collect.Multimap; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.AttributeContainer; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.item.ItemStack; - -import net.fabricmc.fabric.impl.tool.attribute.ItemStackContext; - -@Mixin(LivingEntity.class) -public class LivingEntityMixin { - @Nullable - @Unique private ItemStack stackContext = null; - @Nullable - @Unique private EquipmentSlot slotContext = null; - - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/attribute/AttributeContainer;removeModifiers(Lcom/google/common/collect/Multimap;)V"), method = "getEquipmentChanges", locals = LocalCapture.CAPTURE_FAILHARD) - private void storeRemoveStackContext(CallbackInfoReturnable<Map> cir, Map map, EquipmentSlot[] var2, int var3, int var4, EquipmentSlot equipmentSlot, ItemStack oldStack, ItemStack newStack) { - stackContext = oldStack; - slotContext = equipmentSlot; - } - - @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/attribute/AttributeContainer;removeModifiers(Lcom/google/common/collect/Multimap;)V"), method = "getEquipmentChanges") - private void setupRemoveModifierContext(AttributeContainer attributeContainer, Multimap<EntityAttribute, EntityAttributeModifier> oldModifiers) { - ((ItemStackContext) (Object) stackContext).fabricToolAttributes_setContext((LivingEntity) (Object) this); - Multimap<EntityAttribute, EntityAttributeModifier> attributeModifiers = stackContext.getAttributeModifiers(slotContext); - ((ItemStackContext) (Object) stackContext).fabricToolAttributes_setContext(null); - attributeContainer.removeModifiers(attributeModifiers); - } - - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/attribute/AttributeContainer;addTemporaryModifiers(Lcom/google/common/collect/Multimap;)V"), method = "getEquipmentChanges", locals = LocalCapture.CAPTURE_FAILHARD) - private void storeAddStackContext(CallbackInfoReturnable<Map> cir, Map map, EquipmentSlot[] var2, int var3, int var4, EquipmentSlot equipmentSlot, ItemStack oldStack, ItemStack newStack) { - stackContext = newStack; - slotContext = equipmentSlot; - } - - @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/attribute/AttributeContainer;addTemporaryModifiers(Lcom/google/common/collect/Multimap;)V"), method = "getEquipmentChanges") - private void setupAddModifierContext(AttributeContainer attributeContainer, Multimap<EntityAttribute, EntityAttributeModifier> oldModifiers) { - ((ItemStackContext) (Object) stackContext).fabricToolAttributes_setContext((LivingEntity) (Object) this); - Multimap<EntityAttribute, EntityAttributeModifier> attributeModifiers = stackContext.getAttributeModifiers(slotContext); - ((ItemStackContext) (Object) stackContext).fabricToolAttributes_setContext(null); - attributeContainer.addTemporaryModifiers(attributeModifiers); - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/MixinItemStack.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/MixinItemStack.java deleted file mode 100644 index 940ff0992..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/MixinItemStack.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tool.attribute; - -import java.util.List; - -import com.google.common.collect.LinkedListMultimap; -import com.google.common.collect.Multimap; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import net.minecraft.block.BlockState; -import net.minecraft.client.item.TooltipContext; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.text.Text; - -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.ToolManager; -import net.fabricmc.fabric.impl.tool.attribute.ItemStackContext; - -@Mixin(ItemStack.class) -public abstract class MixinItemStack implements ItemStackContext { - @Unique - @Nullable - private LivingEntity contextEntity = null; - - @Inject(at = @At("RETURN"), method = "isSuitableFor", cancellable = true) - public void isEffectiveOn(BlockState state, CallbackInfoReturnable<Boolean> info) { - info.setReturnValue(ToolManager.handleIsEffectiveOnIgnoresVanilla(state, (ItemStack) (Object) this, null, info.getReturnValueZ())); - } - - @Inject(at = @At("RETURN"), method = "getMiningSpeedMultiplier", cancellable = true) - public void getMiningSpeedMultiplier(BlockState state, CallbackInfoReturnable<Float> info) { - float customSpeed = ToolManager.handleBreakingSpeedIgnoresVanilla(state, (ItemStack) (Object) this, null); - - if (info.getReturnValueF() < customSpeed) { - info.setReturnValue(customSpeed); - } - } - - // This inject stores context about the player viewing an ItemStack's tooltip before attributes are calculated. - @Environment(EnvType.CLIENT) - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getAttributeModifiers(Lnet/minecraft/entity/EquipmentSlot;)Lcom/google/common/collect/Multimap;"), method = "getTooltip") - private void storeTooltipAttributeEntityContext(PlayerEntity player, TooltipContext context, CallbackInfoReturnable<List<Text>> cir) { - contextEntity = player; - } - - // This inject removes context specified in the previous inject. - // This is done to prevent issues with other mods calling getAttributeModifiers. - @Environment(EnvType.CLIENT) - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getAttributeModifiers(Lnet/minecraft/entity/EquipmentSlot;)Lcom/google/common/collect/Multimap;", shift = At.Shift.AFTER), method = "getTooltip") - private void revokeTooltipAttributeEntityContext(PlayerEntity player, TooltipContext context, CallbackInfoReturnable<List<Text>> cir) { - contextEntity = null; - } - - @ModifyVariable(method = "getAttributeModifiers", at = @At(value = "RETURN", shift = At.Shift.BEFORE)) - public Multimap<EntityAttribute, EntityAttributeModifier> modifyAttributeModifiersMap(Multimap<EntityAttribute, EntityAttributeModifier> multimap, EquipmentSlot slot) { - ItemStack stack = (ItemStack) (Object) this; - - // Only perform our custom operations if the tool being operated on is dynamic. - if (stack.getItem() instanceof DynamicAttributeTool) { - // The Multimap passed in is not ordered, so we need to re-assemble the vanilla and modded attributes - // into a custom, ordered Multimap. If this step is not done, and both vanilla + modded attributes - // exist at once, the item tooltip attribute lines will randomly switch positions. - LinkedListMultimap<EntityAttribute, EntityAttributeModifier> orderedAttributes = LinkedListMultimap.create(); - // First, add all vanilla attributes to our ordered Multimap. - orderedAttributes.putAll(multimap); - // Second, calculate the dynamic attributes, and add them at the end of our Multimap. - DynamicAttributeTool holder = (DynamicAttributeTool) stack.getItem(); - orderedAttributes.putAll(holder.getDynamicModifiers(slot, stack, contextEntity)); - return orderedAttributes; - } - - return multimap; - } - - @Override - public void fabricToolAttributes_setContext(@Nullable LivingEntity contextEntity) { - this.contextEntity = contextEntity; - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/MixinToolItem.java b/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/MixinToolItem.java deleted file mode 100644 index 4f6c7874a..000000000 --- a/fabric-tool-attribute-api-v1/src/main/java/net/fabricmc/fabric/mixin/tool/attribute/MixinToolItem.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.mixin.tool.attribute; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ToolItem; -import net.minecraft.item.ToolMaterial; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; - -@Mixin(ToolItem.class) -public abstract class MixinToolItem extends Item implements DynamicAttributeTool { - @Shadow - public abstract ToolMaterial getMaterial(); - - public MixinToolItem(Settings settings) { - super(settings); - } - - @Override - public int getMiningLevel(ItemStack stack, LivingEntity user) { - return this.getMaterial().getMiningLevel(); - } - - @Override - public float getMiningSpeedMultiplier(ItemStack stack, LivingEntity user) { - return this.getMaterial().getMiningSpeedMultiplier(); - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/resources/assets/fabric-tool-attribute-api-v1/icon.png b/fabric-tool-attribute-api-v1/src/main/resources/assets/fabric-tool-attribute-api-v1/icon.png deleted file mode 100644 index 2931efbf6..000000000 Binary files a/fabric-tool-attribute-api-v1/src/main/resources/assets/fabric-tool-attribute-api-v1/icon.png and /dev/null differ diff --git a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/axes.json b/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/axes.json deleted file mode 100644 index b5d6782f0..000000000 --- a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/axes.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:wooden_axe", - "minecraft:stone_axe", - "minecraft:iron_axe", - "minecraft:golden_axe", - "minecraft:diamond_axe", - "minecraft:netherite_axe" - ] -} \ No newline at end of file diff --git a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/hoes.json b/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/hoes.json deleted file mode 100644 index 6f968f802..000000000 --- a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/hoes.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:wooden_hoe", - "minecraft:stone_hoe", - "minecraft:iron_hoe", - "minecraft:golden_hoe", - "minecraft:diamond_hoe", - "minecraft:netherite_hoe" - ] -} \ No newline at end of file diff --git a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/pickaxes.json b/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/pickaxes.json deleted file mode 100644 index 430221785..000000000 --- a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/pickaxes.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:wooden_pickaxe", - "minecraft:stone_pickaxe", - "minecraft:iron_pickaxe", - "minecraft:golden_pickaxe", - "minecraft:diamond_pickaxe", - "minecraft:netherite_pickaxe" - ] -} \ No newline at end of file diff --git a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/shears.json b/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/shears.json deleted file mode 100644 index 7aeb6cb47..000000000 --- a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/shears.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:shears" - ] -} \ No newline at end of file diff --git a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/shovels.json b/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/shovels.json deleted file mode 100644 index b3e644571..000000000 --- a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/shovels.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:wooden_shovel", - "minecraft:stone_shovel", - "minecraft:iron_shovel", - "minecraft:golden_shovel", - "minecraft:diamond_shovel", - "minecraft:netherite_shovel" - ] -} \ No newline at end of file diff --git a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/swords.json b/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/swords.json deleted file mode 100644 index d5b18200e..000000000 --- a/fabric-tool-attribute-api-v1/src/main/resources/data/fabric/tags/items/swords.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:wooden_sword", - "minecraft:stone_sword", - "minecraft:iron_sword", - "minecraft:golden_sword", - "minecraft:diamond_sword", - "minecraft:netherite_sword" - ] -} \ No newline at end of file diff --git a/fabric-tool-attribute-api-v1/src/main/resources/fabric-tool-attribute-api-v1.mixins.json b/fabric-tool-attribute-api-v1/src/main/resources/fabric-tool-attribute-api-v1.mixins.json deleted file mode 100644 index 12540e3ce..000000000 --- a/fabric-tool-attribute-api-v1/src/main/resources/fabric-tool-attribute-api-v1.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "package": "net.fabricmc.fabric.mixin.tool.attribute", - "compatibilityLevel": "JAVA_16", - "mixins": [ - "BambooBlockMixin", - "LivingEntityMixin", - "MixinItemStack" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/fabric-tool-attribute-api-v1/src/main/resources/fabric.mod.json b/fabric-tool-attribute-api-v1/src/main/resources/fabric.mod.json deleted file mode 100644 index e02a9a30d..000000000 --- a/fabric-tool-attribute-api-v1/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "schemaVersion": 1, - "id": "fabric-tool-attribute-api-v1", - "name": "Fabric Tool Attribute API (v1)", - "version": "${version}", - "environment": "*", - "license": "Apache-2.0", - "icon": "assets/fabric-tool-attribute-api-v1/icon.png", - "contact": { - "homepage": "https://fabricmc.net", - "irc": "irc://irc.esper.net:6667/fabric", - "issues": "https://github.com/FabricMC/fabric/issues", - "sources": "https://github.com/FabricMC/fabric" - }, - "authors": [ - "FabricMC" - ], - "depends": { - "fabricloader": ">=0.4.0", - "fabric-api-base": "*", - "fabric-mining-level-api-v1": "*", - "fabric-tag-extensions-v0": "*" - }, - "entrypoints": { - "main": [ - "net.fabricmc.fabric.impl.tool.attribute.ToolHandlers" - ] - }, - "description": "Dynamic atttributes for tools.", - "mixins": [ - "fabric-tool-attribute-api-v1.mixins.json" - ], - "custom": { - "fabric-api:module-lifecycle": "stable" - } -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/ToolAttributeTest.java b/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/ToolAttributeTest.java deleted file mode 100644 index 72b5232e8..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/ToolAttributeTest.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.test.tool.attribute; - -import java.util.HashSet; -import java.util.List; -import java.util.function.BiFunction; - -import com.google.common.collect.LinkedHashMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.MapColor; -import net.minecraft.block.Material; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.ToolItem; -import net.minecraft.item.ToolMaterials; -import net.minecraft.server.MinecraftServer; -import net.minecraft.sound.BlockSoundGroup; -import net.minecraft.tag.Tag; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; - -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder; -import net.fabricmc.fabric.api.tag.TagRegistry; -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; -import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; -import net.fabricmc.fabric.test.tool.attribute.item.TestDynamicCancelItem; -import net.fabricmc.fabric.test.tool.attribute.item.TestDynamicSwordItem; -import net.fabricmc.fabric.test.tool.attribute.item.TestDynamicToolItem; -import net.fabricmc.fabric.test.tool.attribute.item.TestNullableItem; - -public class ToolAttributeTest implements ModInitializer { - private static final float DEFAULT_BREAK_SPEED = 1.0F; - private static final float TOOL_BREAK_SPEED = 10.0F; - // A custom tool type, taters - private static final Tag<Item> TATER = TagRegistry.item(new Identifier("fabric-tool-attribute-api-v1-testmod", "taters")); - - private boolean hasValidated = false; - - Block gravelBlock; - Block stoneBlock; - Item testShovel; - Item testPickaxe; - Item testSword; - - Item testStoneLevelTater; - Item testStoneDynamicLevelTater; - Item testDiamondLevelTater; - Item testDiamondDynamicLevelTater; - Block taterEffectiveBlock; - - // Simple blocks that only need a tool without a specific mining level (legacy technique using block settings) - Block needsShears; - Block needsSword; - Block needsPickaxe; - Block needsAxe; - Block needsHoe; - Block needsShovel; - - // Simple blocks that only need a tool without a specific mining level (mineable tags) - Block needsShearsTagged; - Block needsSwordTagged; - Block needsPickaxeTagged; - Block needsAxeTagged; - Block needsHoeTagged; - Block needsShovelTagged; - - // These items are only tagged, but are not actual ToolItems or DynamicAttributeTools. - Item fakeShears; - Item fakeSword; - Item fakePickaxe; - Item fakeAxe; - Item fakeHoe; - Item fakeShovel; - - @Override - public void onInitialize() { - // Register a custom shovel that has a mining level of 2 (iron) dynamically. - testShovel = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "test_shovel"), new TestTool(new Item.Settings(), FabricToolTags.SHOVELS, 2)); - //Register a custom pickaxe that has a mining level of 2 (iron) dynamically. - testPickaxe = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "test_pickaxe"), new TestTool(new Item.Settings(), FabricToolTags.PICKAXES, 2)); - //Register a custom sword that has a mining level of 2 (iron) dynamically. - testSword = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "test_sword"), new TestTool(new Item.Settings(), FabricToolTags.SWORDS, 2)); - // Register a block that requires a shovel that is as strong or stronger than an iron one. - gravelBlock = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "hardened_gravel_block"), - new Block(FabricBlockSettings.of(new FabricMaterialBuilder(MapColor.PALE_YELLOW).build(), MapColor.STONE_GRAY) - .breakByTool(FabricToolTags.SHOVELS, 2) - .requiresTool() - .strength(0.6F) - .sounds(BlockSoundGroup.GRAVEL))); - Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "hardened_gravel_block"), new BlockItem(gravelBlock, new Item.Settings())); - // Register a block that requires a pickaxe that is as strong or stronger than an iron one. - stoneBlock = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "hardened_stone_block"), - new Block(FabricBlockSettings.of(Material.STONE, MapColor.STONE_GRAY) - .breakByTool(FabricToolTags.PICKAXES, 2) - .requiresTool() - .strength(0.6F) - .sounds(BlockSoundGroup.STONE))); - Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "hardened_stone_block"), new BlockItem(stoneBlock, new Item.Settings())); - - // Register a tater that has a mining level of 1 (stone). - testStoneLevelTater = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "test_stone_level_tater"), new ToolItem(ToolMaterials.STONE, new Item.Settings())); - // Register a tater that has a mining level of 1 (stone) dynamically. - testStoneDynamicLevelTater = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "test_stone_dynamic_level_tater"), new TestTool(new Item.Settings(), TATER, 1)); - //Register a tater that has a mining level of 3 (diamond). - testDiamondLevelTater = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "test_diamond_level_tater"), new ToolItem(ToolMaterials.DIAMOND, new Item.Settings())); - //Register a tater that has a mining level of 3 (diamond) dynamically. - testDiamondDynamicLevelTater = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "test_diamond_dynamic_level_tater"), new TestTool(new Item.Settings(), TATER, 3)); - - taterEffectiveBlock = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "tater_effective_block"), - new Block(FabricBlockSettings.of(Material.ORGANIC_PRODUCT, MapColor.ORANGE) - .breakByTool(TATER, 2) // requires iron tater - .requiresTool() - .strength(0.6F) - .sounds(BlockSoundGroup.CROP))); - Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "tater_effective_block"), new BlockItem(taterEffectiveBlock, new Item.Settings())); - - // DYNAMIC ATTRIBUTE MODIFIERS - // The Dynamic Sword tests to make sure standard vanilla attributes can co-exist with dynamic attributes. - Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "dynamic_sword"), new TestDynamicSwordItem(new Item.Settings())); - // The Dynamic Tool ensures a tool can have dynamic attributes (with no vanilla atributes). It applies 2 layers of speed reduction to the player. - Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "dynamic_tool"), new TestDynamicToolItem(new Item.Settings())); - // Test cancels-out attributes - Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "cancel_item"), new TestDynamicCancelItem(new Item.Settings())); - // Test parameter nullability - Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "null_test"), new TestNullableItem(new Item.Settings())); - - needsShears = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_shears"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1).breakByTool(FabricToolTags.SHEARS))); - needsSword = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_sword"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1).breakByTool(FabricToolTags.SWORDS))); - needsPickaxe = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_pickaxe"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1).breakByTool(FabricToolTags.PICKAXES))); - needsAxe = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_axe"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1).breakByTool(FabricToolTags.AXES))); - needsHoe = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_hoe"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1).breakByTool(FabricToolTags.HOES))); - needsShovel = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_shovel"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1).breakByTool(FabricToolTags.SHOVELS))); - - needsShearsTagged = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_shears_tagged"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1))); - needsSwordTagged = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_sword_tagged"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1))); - needsPickaxeTagged = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_pickaxe_tagged"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1))); - needsAxeTagged = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_axe_tagged"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1))); - needsHoeTagged = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_hoe_tagged"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1))); - needsShovelTagged = Registry.register(Registry.BLOCK, new Identifier("fabric-tool-attribute-api-v1-testmod", "needs_shovel_tagged"), new Block(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1, 1))); - - // "Fake" tools, see explanation above - fakeShears = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "fake_shears"), new Item(new Item.Settings())); - fakeSword = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "fake_sword"), new Item(new Item.Settings())); - fakePickaxe = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "fake_pickaxe"), new Item(new Item.Settings())); - fakeAxe = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "fake_axe"), new Item(new Item.Settings())); - fakeHoe = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "fake_hoe"), new Item(new Item.Settings())); - fakeShovel = Registry.register(Registry.ITEM, new Identifier("fabric-tool-attribute-api-v1-testmod", "fake_shovel"), new Item(new Item.Settings())); - - ServerTickEvents.START_SERVER_TICK.register(this::validate); - } - - private void validate(MinecraftServer server) { - if (hasValidated) { - return; - } - - hasValidated = true; - - if (FabricToolTags.PICKAXES.values().isEmpty()) { - throw new AssertionError("Failed to load tool tags"); - } - - //Test we haven't broken vanilla behavior - testToolOnBlock(new ItemStack(Items.STONE_PICKAXE), Blocks.GRAVEL, false, 1.0F); - testToolOnBlock(new ItemStack(Items.IRON_PICKAXE), Blocks.STONE, true, ((ToolItem) Items.IRON_PICKAXE).getMaterial().getMiningSpeedMultiplier()); - testToolOnBlock(new ItemStack(Items.IRON_PICKAXE), Blocks.OBSIDIAN, false, ((ToolItem) Items.IRON_PICKAXE).getMaterial().getMiningSpeedMultiplier()); - testToolOnBlock(new ItemStack(Items.STONE_SHOVEL), Blocks.STONE, false, 1.0F); - testToolOnBlock(new ItemStack(Items.STONE_SHOVEL), Blocks.GRAVEL, true, ((ToolItem) Items.STONE_SHOVEL).getMaterial().getMiningSpeedMultiplier()); - - //Test vanilla tools don't bypass fabric mining levels - testToolOnBlock(new ItemStack(Items.STONE_PICKAXE), stoneBlock, false, ((ToolItem) Items.STONE_PICKAXE).getMaterial().getMiningSpeedMultiplier()); - testToolOnBlock(new ItemStack(Items.IRON_PICKAXE), stoneBlock, true, ((ToolItem) Items.IRON_PICKAXE).getMaterial().getMiningSpeedMultiplier()); - testToolOnBlock(new ItemStack(Items.STONE_SHOVEL), gravelBlock, false, ((ToolItem) Items.STONE_SHOVEL).getMaterial().getMiningSpeedMultiplier()); - testToolOnBlock(new ItemStack(Items.IRON_SHOVEL), gravelBlock, true, ((ToolItem) Items.IRON_SHOVEL).getMaterial().getMiningSpeedMultiplier()); - - //Test vanilla tools respect fabric mining tags - testToolOnBlock(new ItemStack(Items.IRON_PICKAXE), gravelBlock, false, DEFAULT_BREAK_SPEED); - testToolOnBlock(new ItemStack(Items.IRON_SHOVEL), stoneBlock, false, DEFAULT_BREAK_SPEED); - - //Test dynamic tools don't bypass mining level - testToolOnBlock(new ItemStack(testPickaxe), Blocks.OBSIDIAN, false, TOOL_BREAK_SPEED); - - //Test dynamic tools respect fabric mining tags - testToolOnBlock(new ItemStack(testPickaxe), gravelBlock, false, DEFAULT_BREAK_SPEED); - testToolOnBlock(new ItemStack(testShovel), stoneBlock, false, DEFAULT_BREAK_SPEED); - - //Test dynamic tools on vanilla blocks - testToolOnBlock(new ItemStack(testShovel), Blocks.STONE, false, DEFAULT_BREAK_SPEED); - testToolOnBlock(new ItemStack(testShovel), Blocks.GRAVEL, true, TOOL_BREAK_SPEED); - testToolOnBlock(new ItemStack(testPickaxe), Blocks.GRAVEL, false, DEFAULT_BREAK_SPEED); - testToolOnBlock(new ItemStack(testPickaxe), Blocks.STONE, true, TOOL_BREAK_SPEED); - - //Test taters respect our tater block - testToolOnBlock(new ItemStack(testDiamondDynamicLevelTater), taterEffectiveBlock, true, TOOL_BREAK_SPEED); - testToolOnBlock(new ItemStack(testDiamondLevelTater), taterEffectiveBlock, true, ToolMaterials.DIAMOND.getMiningSpeedMultiplier()); - testToolOnBlock(new ItemStack(testStoneDynamicLevelTater), taterEffectiveBlock, false, TOOL_BREAK_SPEED); - testToolOnBlock(new ItemStack(testStoneLevelTater), taterEffectiveBlock, false, ToolMaterials.STONE.getMiningSpeedMultiplier()); - - //Test other tools on our tater block - testToolOnBlock(new ItemStack(testPickaxe), taterEffectiveBlock, false, DEFAULT_BREAK_SPEED); - testToolOnBlock(new ItemStack(testShovel), taterEffectiveBlock, false, DEFAULT_BREAK_SPEED); - testToolOnBlock(new ItemStack(Items.IRON_PICKAXE), taterEffectiveBlock, false, DEFAULT_BREAK_SPEED); - testToolOnBlock(new ItemStack(Items.IRON_SHOVEL), taterEffectiveBlock, false, DEFAULT_BREAK_SPEED); - - //Test vanilla tools on blocks - testToolOnBlock(new ItemStack(Items.SHEARS), needsShears, true, DEFAULT_BREAK_SPEED); - testToolOnBlock(new ItemStack(Items.IRON_SWORD), needsSword, true, ToolMaterials.IRON.getMiningSpeedMultiplier()); - testToolOnBlock(new ItemStack(Items.IRON_AXE), needsAxe, true, ToolMaterials.IRON.getMiningSpeedMultiplier()); - testToolOnBlock(new ItemStack(Items.IRON_PICKAXE), needsPickaxe, true, ToolMaterials.IRON.getMiningSpeedMultiplier()); - testToolOnBlock(new ItemStack(Items.IRON_HOE), needsHoe, true, ToolMaterials.IRON.getMiningSpeedMultiplier()); - testToolOnBlock(new ItemStack(Items.IRON_SHOVEL), needsShovel, true, ToolMaterials.IRON.getMiningSpeedMultiplier()); - - //Test fake tools on corresponding and invalid blocks - // Note: using LinkedHashMultimap to ensure the same order (this makes it more predictable when debugging) - Multimap<Item, Block> fakeToolsToEffectiveBlocks = LinkedHashMultimap.create(6, 2); - fakeToolsToEffectiveBlocks.put(fakeShears, needsShears); - fakeToolsToEffectiveBlocks.put(fakeShears, needsShearsTagged); - fakeToolsToEffectiveBlocks.put(fakeSword, needsSword); - fakeToolsToEffectiveBlocks.put(fakeSword, needsSwordTagged); - fakeToolsToEffectiveBlocks.put(fakeAxe, needsAxe); - fakeToolsToEffectiveBlocks.put(fakeAxe, needsAxeTagged); - fakeToolsToEffectiveBlocks.put(fakePickaxe, needsPickaxe); - fakeToolsToEffectiveBlocks.put(fakePickaxe, needsPickaxeTagged); - fakeToolsToEffectiveBlocks.put(fakeHoe, needsHoe); - fakeToolsToEffectiveBlocks.put(fakeHoe, needsHoeTagged); - fakeToolsToEffectiveBlocks.put(fakeShovel, needsShovel); - fakeToolsToEffectiveBlocks.put(fakeShovel, needsShovelTagged); - testExclusivelyEffective(fakeToolsToEffectiveBlocks, (tool, block) -> { - if (tool == fakeShears && block == needsShearsTagged) { - // The mining level API gives the tagged block the speed 5.0 - // when mined with shears (see ShearsItemMixin in that module), - // and ShearsVanillaBlocksToolHandler gets the speeds from the vanilla shears item. - return 5.0f; - } - - return DEFAULT_BREAK_SPEED; - }); - - //Test fake tools on corresponding and invalid blocks - Multimap<Item, Block> dynamicToolsToEffectiveBlocks = LinkedHashMultimap.create(3, 2); - dynamicToolsToEffectiveBlocks.put(testSword, needsSword); - dynamicToolsToEffectiveBlocks.put(testSword, needsSwordTagged); - dynamicToolsToEffectiveBlocks.put(testPickaxe, needsPickaxe); - dynamicToolsToEffectiveBlocks.put(testPickaxe, needsPickaxeTagged); - dynamicToolsToEffectiveBlocks.put(testShovel, needsShovel); - dynamicToolsToEffectiveBlocks.put(testShovel, needsShovelTagged); - testExclusivelyEffective(dynamicToolsToEffectiveBlocks, (tool, block) -> TOOL_BREAK_SPEED); - } - - private void testExclusivelyEffective(Multimap<Item, Block> itemsToEffectiveBlocks, BiFunction<Item, Block, Float> effectiveSpeed) { - for (List<ItemConvertible> pair : Sets.cartesianProduct(itemsToEffectiveBlocks.keySet(), new HashSet<>(itemsToEffectiveBlocks.values()))) { - Item item = (Item) pair.get(0); - Block block = (Block) pair.get(1); - - if (itemsToEffectiveBlocks.get(item).contains(block)) { - testToolOnBlock(new ItemStack(item), block, true, effectiveSpeed.apply(item, block)); - } else { - testToolOnBlock(new ItemStack(item), block, false, DEFAULT_BREAK_SPEED); - } - } - } - - private void testToolOnBlock(ItemStack item, Block block, boolean inEffective, float inSpeed) { - boolean effective = item.isSuitableFor(block.getDefaultState()); - float speed = item.getMiningSpeedMultiplier(block.getDefaultState()); - - if (inEffective != effective) { - throw new AssertionError("Effective check incorrect for " + Registry.ITEM.getId(item.getItem()) + " breaking " + Registry.BLOCK.getId(block) + " got " + effective); - } else if (inSpeed != speed) { - throw new AssertionError("Speed check incorrect for " + Registry.ITEM.getId(item.getItem()) + " breaking " + Registry.BLOCK.getId(block) + " got " + speed); - } - } - - private static class TestTool extends Item implements DynamicAttributeTool { - final Tag<Item> toolType; - final int miningLevel; - - private TestTool(Settings settings, Tag<Item> toolType, int miningLevel) { - super(settings); - this.toolType = toolType; - this.miningLevel = miningLevel; - } - - @Override - public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - if (tag.equals(toolType)) { - return this.miningLevel; - } - - return 0; - } - - @Override - public float getMiningSpeedMultiplier(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) { - if (tag.equals(toolType)) { - return TOOL_BREAK_SPEED; - } - - return DEFAULT_BREAK_SPEED; - } - } -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestDynamicCancelItem.java b/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestDynamicCancelItem.java deleted file mode 100644 index 28071fa42..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestDynamicCancelItem.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.test.tool.attribute.item; - -import java.util.UUID; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import org.jetbrains.annotations.Nullable; - -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; - -public class TestDynamicCancelItem extends Item implements DynamicAttributeTool { - public static final UUID TEST_UUID = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); - - public TestDynamicCancelItem(Settings settings) { - super(settings); - } - - @Override - public Multimap<EntityAttribute, EntityAttributeModifier> getDynamicModifiers(EquipmentSlot slot, ItemStack stack, @Nullable LivingEntity user) { - if (slot.equals(EquipmentSlot.MAINHAND)) { - ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder(); - builder.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(TEST_UUID, "TEST", -1.0, EntityAttributeModifier.Operation.ADDITION)); - builder.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(TEST_UUID, "TEST", 1.0, EntityAttributeModifier.Operation.ADDITION)); - return builder.build(); - } else { - return EMPTY; - } - } -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestDynamicSwordItem.java b/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestDynamicSwordItem.java deleted file mode 100644 index 6996badf7..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestDynamicSwordItem.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.test.tool.attribute.item; - -import java.util.UUID; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import org.jetbrains.annotations.Nullable; - -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.item.ItemStack; -import net.minecraft.item.SwordItem; -import net.minecraft.item.ToolMaterials; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; - -public class TestDynamicSwordItem extends SwordItem implements DynamicAttributeTool { - public static final UUID TEST_UUID = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); - - public TestDynamicSwordItem(Settings settings) { - super(ToolMaterials.DIAMOND, 6, -2.4f, settings); - } - - @Override - public Multimap<EntityAttribute, EntityAttributeModifier> getDynamicModifiers(EquipmentSlot slot, ItemStack stack, @Nullable LivingEntity user) { - if (slot.equals(EquipmentSlot.MAINHAND)) { - ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder(); - builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(TEST_UUID, "TEST", 2.0, EntityAttributeModifier.Operation.MULTIPLY_TOTAL)); - builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(TEST_UUID, "TEST2", 2.0, EntityAttributeModifier.Operation.MULTIPLY_TOTAL)); - return builder.build(); - } else { - return EMPTY; - } - } -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestDynamicToolItem.java b/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestDynamicToolItem.java deleted file mode 100644 index f89d177f9..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestDynamicToolItem.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.test.tool.attribute.item; - -import java.util.UUID; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import org.jetbrains.annotations.Nullable; - -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; - -public class TestDynamicToolItem extends Item implements DynamicAttributeTool { - public static final UUID TEST_UUID = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); - - public TestDynamicToolItem(Settings settings) { - super(settings); - } - - @Override - public Multimap<EntityAttribute, EntityAttributeModifier> getDynamicModifiers(EquipmentSlot slot, ItemStack stack, @Nullable LivingEntity user) { - if (slot.equals(EquipmentSlot.MAINHAND)) { - ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder(); - builder.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(TEST_UUID, "TEST", -1.0, EntityAttributeModifier.Operation.ADDITION)); - builder.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(TEST_UUID, "TEST", -1.0, EntityAttributeModifier.Operation.ADDITION)); - return builder.build(); - } else { - return EMPTY; - } - } -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestNullableItem.java b/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestNullableItem.java deleted file mode 100644 index 5b7e1b5af..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/java/net/fabricmc/fabric/test/tool/attribute/item/TestNullableItem.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.test.tool.attribute.item; - -import java.util.UUID; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import org.jetbrains.annotations.Nullable; - -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool; - -public class TestNullableItem extends Item implements DynamicAttributeTool { - public static final UUID TEST_UUID = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); - - public TestNullableItem(Settings settings) { - super(settings); - } - - @Override - public Multimap<EntityAttribute, EntityAttributeModifier> getDynamicModifiers(EquipmentSlot slot, ItemStack stack, @Nullable LivingEntity user) { - if (slot.equals(EquipmentSlot.MAINHAND)) { - ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder(); - builder.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(TEST_UUID, "Increasing speed", user == null ? 0 : user.age * 0.001, EntityAttributeModifier.Operation.ADDITION)); - return builder.build(); - } else { - return EMPTY; - } - } -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/blockstates/hardened_gravel_block.json b/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/blockstates/hardened_gravel_block.json deleted file mode 100644 index fab9f0a06..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/blockstates/hardened_gravel_block.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "variants": { - "": { "model": "block/gravel" } - } -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/blockstates/hardened_stone_block.json b/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/blockstates/hardened_stone_block.json deleted file mode 100644 index a99df56e8..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/blockstates/hardened_stone_block.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "variants": { - "": { "model": "block/stone" } - } -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/hardened_gravel_block.json b/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/hardened_gravel_block.json deleted file mode 100644 index 2a38b147b..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/hardened_gravel_block.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "block/gravel" -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/hardened_stone_block.json b/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/hardened_stone_block.json deleted file mode 100644 index e664fbe59..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/hardened_stone_block.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "block/stone" -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/test_pickaxe.json b/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/test_pickaxe.json deleted file mode 100644 index f0f76884b..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/test_pickaxe.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "item/apple" - } -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/test_shovel.json b/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/test_shovel.json deleted file mode 100644 index f0f76884b..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/assets/fabric-tool-attribute-api-v1-testmod/models/item/test_shovel.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "item/apple" - } -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric-tool-attribute-api-v1-testmod/loot_tables/blocks/hardened_gravel_block.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric-tool-attribute-api-v1-testmod/loot_tables/blocks/hardened_gravel_block.json deleted file mode 100644 index acbbe77fe..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric-tool-attribute-api-v1-testmod/loot_tables/blocks/hardened_gravel_block.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "fabric-tool-attribute-api-v1-testmod:hardened_gravel_block" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric-tool-attribute-api-v1-testmod/loot_tables/blocks/hardened_stone_block.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric-tool-attribute-api-v1-testmod/loot_tables/blocks/hardened_stone_block.json deleted file mode 100644 index e7c9a5689..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric-tool-attribute-api-v1-testmod/loot_tables/blocks/hardened_stone_block.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "fabric-tool-attribute-api-v1-testmod:hardened_stone_block" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric-tool-attribute-api-v1-testmod/tags/items/taters.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric-tool-attribute-api-v1-testmod/tags/items/taters.json deleted file mode 100644 index d2d6a9250..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric-tool-attribute-api-v1-testmod/tags/items/taters.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:test_stone_level_tater", - "fabric-tool-attribute-api-v1-testmod:test_stone_dynamic_level_tater", - "fabric-tool-attribute-api-v1-testmod:test_diamond_level_tater", - "fabric-tool-attribute-api-v1-testmod:test_diamond_dynamic_level_tater" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/blocks/mineable/shears.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/blocks/mineable/shears.json deleted file mode 100644 index 997b5f2c5..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/blocks/mineable/shears.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:needs_shears_tagged" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/blocks/mineable/sword.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/blocks/mineable/sword.json deleted file mode 100644 index 0639be51c..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/blocks/mineable/sword.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:needs_sword_tagged" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/axes.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/axes.json deleted file mode 100644 index 36a0a3d4f..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/axes.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:fake_axe" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/hoes.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/hoes.json deleted file mode 100644 index a3c32b5fc..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/hoes.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:fake_hoe" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/pickaxes.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/pickaxes.json deleted file mode 100644 index 18e814a1a..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/pickaxes.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:fake_pickaxe", - "fabric-tool-attribute-api-v1-testmod:test_pickaxe" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/shears.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/shears.json deleted file mode 100644 index eef645155..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/shears.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:fake_shears" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/shovels.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/shovels.json deleted file mode 100644 index 3951fdd26..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/shovels.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:fake_shovel", - "fabric-tool-attribute-api-v1-testmod:test_shovel" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/swords.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/swords.json deleted file mode 100644 index 1a4748620..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/fabric/tags/items/swords.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:fake_sword", - "fabric-tool-attribute-api-v1-testmod:test_sword" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/axe.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/axe.json deleted file mode 100644 index 9b29a2e53..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/axe.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:needs_axe_tagged" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/hoe.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/hoe.json deleted file mode 100644 index c3c35c461..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/hoe.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:needs_hoe_tagged" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/pickaxe.json deleted file mode 100644 index 86d7753a3..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/pickaxe.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:needs_pickaxe_tagged" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/shovel.json b/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/shovel.json deleted file mode 100644 index 070ab57d1..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/data/minecraft/tags/blocks/mineable/shovel.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "fabric-tool-attribute-api-v1-testmod:needs_shovel_tagged" - ] -} diff --git a/fabric-tool-attribute-api-v1/src/testmod/resources/fabric.mod.json b/fabric-tool-attribute-api-v1/src/testmod/resources/fabric.mod.json deleted file mode 100644 index f77a1cecc..000000000 --- a/fabric-tool-attribute-api-v1/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "schemaVersion": 1, - "id": "fabric-tool-attribute-api-v1-testmod", - "name": "Fabric Tool Attribute API (v1) Test Mod", - "version": "1.0.0", - "environment": "*", - "license": "Apache-2.0", - "depends": { - "fabric-tool-attribute-api-v1": "*" - }, - "entrypoints": { - "main": [ - "net.fabricmc.fabric.test.tool.attribute.ToolAttributeTest" - ] - } -} diff --git a/fabric-transfer-api-v1/build.gradle b/fabric-transfer-api-v1/build.gradle index bfa13e02f..df1187261 100644 --- a/fabric-transfer-api-v1/build.gradle +++ b/fabric-transfer-api-v1/build.gradle @@ -13,6 +13,4 @@ dependencies { testmodImplementation project(path: ':fabric-object-builder-api-v1', configuration: 'namedElements') testmodImplementation project(path: ':fabric-rendering-v1', configuration: 'namedElements') testmodImplementation project(path: ':fabric-resource-loader-v0', configuration: 'namedElements') - testmodImplementation project(path: ':fabric-tag-extensions-v0', configuration: 'namedElements') - testmodImplementation project(path: ':fabric-tool-attribute-api-v1', configuration: 'namedElements') } diff --git a/fabric-transfer-api-v1/src/main/resources/fabric-transfer-api-v1.mixins.json b/fabric-transfer-api-v1/src/main/resources/fabric-transfer-api-v1.mixins.json index f084d4d06..c7507a16f 100644 --- a/fabric-transfer-api-v1/src/main/resources/fabric-transfer-api-v1.mixins.json +++ b/fabric-transfer-api-v1/src/main/resources/fabric-transfer-api-v1.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "net.fabricmc.fabric.mixin.transfer", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_16", "mixins": [ "BucketItemAccessor", "DoubleInventoryAccessor", diff --git a/gradle.properties b/gradle.properties index 6a70dec70..692122b0b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ org.gradle.jvmargs=-Xmx2560M version=0.46.4 -minecraft_version=22w05a -yarn_version=+build.1 -loader_version=0.12.12 +minecraft_version=22w06a +yarn_version=+build.8 +loader_version=0.13.2 prerelease=true diff --git a/settings.gradle b/settings.gradle index e6f3090ff..fad735325 100644 --- a/settings.gradle +++ b/settings.gradle @@ -35,12 +35,10 @@ include 'fabric-key-binding-api-v1' include 'fabric-lifecycle-events-v1' include 'fabric-loot-tables-v1' include 'fabric-mining-level-api-v1' -include 'fabric-mining-levels-v0' include 'fabric-models-v0' include 'fabric-networking-v0' include 'fabric-networking-api-v1' include 'fabric-object-builder-api-v1' -include 'fabric-object-builders-v0' include 'fabric-particles-v1' include 'fabric-registry-sync-v0' include 'fabric-renderer-api-v1' @@ -55,7 +53,5 @@ include 'fabric-resource-loader-v0' include 'fabric-screen-api-v1' include 'fabric-screen-handler-api-v1' include 'fabric-structure-api-v1' -include 'fabric-tag-extensions-v0' include 'fabric-textures-v0' -include 'fabric-tool-attribute-api-v1' include 'fabric-transfer-api-v1' diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7fa992889..8391565ea 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -16,7 +16,7 @@ "FabricMC" ], "depends": { - "fabricloader": ">=0.12.12", + "fabricloader": ">=0.13.2", "java": ">=17", "minecraft": "~1.18.2-alpha.22.5.a" },