This commit is contained in:
modmuss50 2022-05-12 21:58:35 +01:00
parent 729842f055
commit 55e82473ab
28 changed files with 163 additions and 394 deletions

1
.gitattributes vendored
View file

@ -1 +1,2 @@
*.java text eol=lf
*.json text eol=lf

View file

@ -19,12 +19,13 @@ package net.fabricmc.fabric.mixin.command.client;
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 net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientCommandSource;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.ChatMessageSender;
import net.minecraft.network.MessageSender;
import net.minecraft.network.MessageType;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@ -41,12 +42,18 @@ abstract class ClientCommandSourceMixin implements FabricClientCommandSource {
@Override
public void sendFeedback(Text message) {
client.inGameHud.onChatMessage(Registry.field_39206.get(MessageType.SYSTEM), message, new ChatMessageSender(Util.NIL_UUID, message));
client.inGameHud.onChatMessage(getSystemMessageType(), message, new MessageSender(Util.NIL_UUID, message));
}
@Override
public void sendError(Text message) {
client.inGameHud.onChatMessage(Registry.field_39206.get(MessageType.SYSTEM), Text.literal("").append(message).formatted(Formatting.RED), new ChatMessageSender(Util.NIL_UUID, message));
client.inGameHud.onChatMessage(getSystemMessageType(), Text.literal("").append(message).formatted(Formatting.RED), new MessageSender(Util.NIL_UUID, message));
}
@Unique
private MessageType getSystemMessageType() {
Registry<MessageType> registry = client.world.getRegistryManager().get(Registry.MESSAGE_TYPE_KEY);
return registry.get(MessageType.SYSTEM);
}
@Override

View file

@ -27,7 +27,7 @@ import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags;
public class BiomeTagGenerator extends FabricTagProvider.DynamicRegistryTagProvider<Biome> {
public BiomeTagGenerator(FabricDataGenerator dataGenerator) {
super(dataGenerator, Registry.BIOME_KEY, "worldgen/biome");
super(dataGenerator, Registry.BIOME_KEY);
}
@Override

View file

@ -26,6 +26,7 @@ import com.google.common.collect.Sets;
import com.google.gson.JsonObject;
import net.minecraft.advancement.Advancement;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DataProvider;
import net.minecraft.data.DataWriter;
import net.minecraft.util.Identifier;
@ -41,9 +42,11 @@ import net.fabricmc.fabric.impl.datagen.FabricDataGenHelper;
*/
public abstract class FabricAdvancementProvider implements DataProvider {
protected final FabricDataGenerator dataGenerator;
private final DataGenerator.class_7489 pathResolver;
protected FabricAdvancementProvider(FabricDataGenerator dataGenerator) {
this.dataGenerator = dataGenerator;
this.pathResolver = dataGenerator.method_44106(DataGenerator.class_7490.DATA_PACK, "advancements");
}
/**

View file

@ -1,32 +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.datagen.v1.provider;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
/**
* @deprecated use {@link FabricAdvancementProvider} instead.
*/
@Deprecated
public abstract class FabricAdvancementsProvider extends FabricAdvancementProvider {
protected final FabricDataGenerator dataGenerator;
protected FabricAdvancementsProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator);
this.dataGenerator = dataGenerator;
}
}

View file

@ -1,32 +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.datagen.v1.provider;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
/**
* @deprecated use {@link FabricBlockLootTableProvider} instead.
*/
@Deprecated
public abstract class FabricBlockLootTablesProvider extends FabricBlockLootTableProvider {
protected final FabricDataGenerator dataGenerator;
protected FabricBlockLootTablesProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator);
this.dataGenerator = dataGenerator;
}
}

View file

@ -1,32 +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.datagen.v1.provider;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
/**
* @deprecated use {@link FabricModelProvider} instead.
*/
@Deprecated
public abstract class FabricBlockStateDefinitionProvider extends FabricModelProvider {
protected final FabricDataGenerator dataGenerator;
public FabricBlockStateDefinitionProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator);
this.dataGenerator = dataGenerator;
}
}

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.api.datagen.v1.provider;
import java.nio.file.Path;
import java.util.Set;
import java.util.function.Consumer;
@ -66,7 +65,6 @@ public abstract class FabricRecipeProvider extends RecipeProvider {
@Override
public void run(DataWriter writer) {
Path path = this.root.getOutput();
Set<Identifier> generatedRecipes = Sets.newHashSet();
generateRecipes(provider -> {
Identifier identifier = getRecipeIdentifier(provider.getRecipeId());
@ -79,12 +77,12 @@ public abstract class FabricRecipeProvider extends RecipeProvider {
ConditionJsonProvider[] conditions = FabricDataGenHelper.consumeConditions(provider);
ConditionJsonProvider.write(recipeJson, conditions);
saveRecipe(writer, recipeJson, path.resolve("data/" + identifier.getNamespace() + "/recipes/" + identifier.getPath() + ".json"));
saveRecipe(writer, recipeJson, this.field_39378.method_44107(identifier));
JsonObject advancementJson = provider.toAdvancementJson();
if (advancementJson != null) {
ConditionJsonProvider.write(advancementJson, conditions);
saveRecipeAdvancement(writer, advancementJson, path.resolve("data/" + identifier.getNamespace() + "/advancements/" + provider.getAdvancementId().getPath() + ".json"));
saveRecipeAdvancement(writer, advancementJson, this.field_39379.method_44107(getRecipeIdentifier(provider.getAdvancementId())));
}
});
}

View file

@ -1,32 +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.datagen.v1.provider;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
/**
* @deprecated use {@link FabricRecipeProvider} instead.
*/
@Deprecated
public abstract class FabricRecipesProvider extends FabricRecipeProvider {
protected final FabricDataGenerator dataGenerator;
public FabricRecipesProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator);
this.dataGenerator = dataGenerator;
}
}

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.api.datagen.v1.provider;
import java.nio.file.Path;
import java.util.Objects;
import java.util.function.Function;
@ -24,19 +23,18 @@ import com.google.common.base.Preconditions;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Block;
import net.minecraft.data.DataProvider;
import net.minecraft.data.server.AbstractTagProvider;
import net.minecraft.entity.EntityType;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
import net.minecraft.tag.BlockTags;
import net.minecraft.tag.Builder;
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.TagEntry;
import net.minecraft.tag.TagKey;
import net.minecraft.tag.TagManagerLoader;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
@ -64,7 +62,6 @@ import net.fabricmc.fabric.mixin.datagen.DynamicRegistryManagerAccessor;
*/
public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
private final FabricDataGenerator fabricDataGenerator;
private final String path;
/**
* Construct a new {@link FabricTagProvider} with the default computed path.
@ -73,26 +70,10 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
*
* @param dataGenerator The data generator instance
* @param registry The backing registry for the Tag type.
* @param name The name used for {@link DataProvider#getName()}
*/
protected FabricTagProvider(FabricDataGenerator dataGenerator, Registry<T> registry) {
this(dataGenerator, registry, TagManagerLoader.getPath(registry.getKey()));
}
/**
* Construct a new {@link FabricTagProvider}.
*
* <p>Common implementations of this class are provided. For example @see BlockTagProvider
*
* @param dataGenerator The data generator instance
* @param registry The backing registry for the Tag type.
* @param path The directory name to write the tag file names. Example: "blocks" or "items"
*/
@SuppressWarnings({"unchecked", "rawtypes"})
protected FabricTagProvider(FabricDataGenerator dataGenerator, Registry<T> registry, String path) {
public FabricTagProvider(FabricDataGenerator dataGenerator, Registry<T> registry) {
super(dataGenerator, registry);
this.fabricDataGenerator = dataGenerator;
this.path = path.startsWith("tags/") ? path : "tags/" + path;
if (!(this instanceof DynamicRegistryTagProvider) && BuiltinRegistries.REGISTRIES.contains((RegistryKey) registry.getKey())) {
throw new IllegalArgumentException("Using FabricTagProvider to generate dynamic registry tags is not supported, Use DynamicRegistryTagProvider instead.");
@ -115,11 +96,6 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
return new FabricTagBuilder<>(super.getOrCreateTagBuilder(tag));
}
@Override
protected Path getOutput(Identifier id) {
return this.root.getOutput().resolve("data/%s/%s/%s.json".formatted(id.getNamespace(), path, id.getPath()));
}
@Override
protected final void configure() {
generateTags();
@ -139,7 +115,7 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
*/
public abstract static class ItemTagProvider extends FabricTagProvider<Item> {
@Nullable
private final Function<TagKey<Block>, Tag.Builder> blockTagBuilderProvider;
private final Function<TagKey<Block>, Builder> blockTagBuilderProvider;
/**
* Construct an {@link ItemTagProvider} tag provider <b>with</b> an associated {@link BlockTagProvider} tag provider.
@ -172,9 +148,9 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
* @param itemTag The item tag to copy to.
*/
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.entry().canAdd(this.registry::containsId, (id) -> true)).forEach(itemTagBuilder::add);
Builder blockTagBuilder = Objects.requireNonNull(this.blockTagBuilderProvider, "Pass Block tag provider via constructor to use copy").apply(blockTag);
Builder itemTagBuilder = this.getTagBuilder(itemTag);
blockTagBuilder.build().stream().filter((entry) -> entry.canAdd(this.registry::containsId, (id) -> true)).forEach(itemTagBuilder::add);
}
}
@ -214,11 +190,10 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
*
* @param dataGenerator The data generator instance
* @param registryKey The registry key of the dynamic registry
* @param path The directory name to write the tag file names
* @throws IllegalArgumentException if the registry is static registry
*/
protected DynamicRegistryTagProvider(FabricDataGenerator dataGenerator, RegistryKey<? extends Registry<T>> registryKey, String path) {
super(dataGenerator, FabricDataGenHelper.getFakeDynamicRegistry(), path);
protected DynamicRegistryTagProvider(FabricDataGenerator dataGenerator, RegistryKey<? extends Registry<T>> registryKey) {
super(dataGenerator, FabricDataGenHelper.getFakeDynamicRegistry(registryKey));
Preconditions.checkArgument(DynamicRegistryManagerAccessor.getInfos().containsKey(registryKey), "Only dynamic registries are supported in this tag provider.");
}
}
@ -230,7 +205,7 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
private final AbstractTagProvider.ObjectBuilder<T> parent;
private FabricTagBuilder(ObjectBuilder<T> parent) {
super(parent.builder, parent.registry, parent.source);
super(parent.builder, parent.registry);
this.parent = parent;
}
@ -266,7 +241,7 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
* @return the {@link FabricTagBuilder} instance
*/
public FabricTagBuilder<T> add(Identifier id) {
builder.add(id, source);
builder.add(id);
return this;
}
@ -316,7 +291,7 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
*/
@Override
public FabricTagBuilder<T> addTag(TagKey<T> tag) {
builder.addTag(tag.id(), source);
builder.addTag(tag.id());
return this;
}
@ -349,7 +324,7 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
* @return the {@link FabricTagBuilder} instance
*/
public FabricTagBuilder<T> forceAddTag(TagKey<T> tag) {
builder.add(new ForcedTagEntry(new Tag.TagEntry(tag.id())), source);
builder.add(new ForcedTagEntry(TagEntry.method_43937(tag.id())));
return this;
}

View file

@ -74,21 +74,6 @@ public final class FabricDataGenHelper {
*/
private static final String ENTRYPOINT_KEY = "fabric-datagen";
/**
* A fake registry instance to be used for {@link DynamicRegistryTagProvider}.
*
* <p>In {@link AbstractTagProvider#run}, it checks for whether the registry has all the elements added to the builder.
* This would be fine for static registry, but there won't be any instance dynamic registry available.
* 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(), null) {
@Override
public boolean containsId(Identifier id) {
return true;
}
};
private FabricDataGenHelper() {
}
@ -135,9 +120,21 @@ public final class FabricDataGenHelper {
}
}
@SuppressWarnings("unchecked")
public static <T> Registry<T> getFakeDynamicRegistry() {
return FAKE_DYNAMIC_REGISTRY;
/**
* A fake registry instance to be used for {@link DynamicRegistryTagProvider}.
*
* <p>In {@link AbstractTagProvider#run}, it checks for whether the registry has all the elements added to the builder.
* This would be fine for static registry, but there won't be any instance dynamic registry available.
* Therefore, this simply return true for all {@link Registry#containsId} call.
*/
@SuppressWarnings("rawtypes")
public static <T> Registry<T> getFakeDynamicRegistry(RegistryKey<? extends Registry<T>> registryKey) {
return new SimpleRegistry<>(registryKey, Lifecycle.experimental(), null) {
@Override
public boolean containsId(Identifier id) {
return true;
}
};
}
/**

View file

@ -21,4 +21,6 @@ import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Internal
public interface FabricTagBuilder {
void fabric_setReplace(boolean replace);
boolean fabric_isReplaced();
}

View file

@ -17,23 +17,22 @@
package net.fabricmc.fabric.impl.datagen;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import com.google.gson.JsonArray;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagEntry;
import net.minecraft.util.Identifier;
public record ForcedTagEntry(Tag.Entry delegate) implements Tag.Entry {
@Override
public <T> boolean resolve(Function<Identifier, Tag<T>> tagGetter, Function<Identifier, T> objectGetter, Consumer<T> collector) {
return delegate.resolve(tagGetter, objectGetter, collector);
public class ForcedTagEntry extends TagEntry {
private final TagEntry delegate;
public ForcedTagEntry(TagEntry delegate) {
super(delegate.id, delegate.field_39267, delegate.field_39268);
this.delegate = delegate;
}
@Override
public void addToJson(JsonArray json) {
delegate.addToJson(json);
public <T> boolean resolve(TagEntry.class_7474<T> arg, Consumer<T> consumer) {
return delegate.resolve(arg, consumer);
}
@Override

View file

@ -16,23 +16,28 @@
package net.fabricmc.fabric.mixin.datagen;
import java.util.List;
import com.google.gson.JsonElement;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.data.DataWriter;
import net.minecraft.data.server.AbstractTagProvider;
import net.minecraft.tag.Builder;
import net.minecraft.util.Identifier;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.fabricmc.fabric.impl.datagen.FabricTagBuilder;
@Mixin(AbstractTagProvider.class)
public class AbstractTagProviderMixin {
@ModifyArg(method = "getOrCreateTagBuilder", index = 2, at = @At(value = "INVOKE", target = "Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder;<init>(Lnet/minecraft/tag/Tag$Builder;Lnet/minecraft/util/registry/Registry;Ljava/lang/String;)V"))
private String injectModId(String str) {
//noinspection ConstantConditions
if ((Object) (this) instanceof FabricTagProvider fabricTagProvider) {
return fabricTagProvider.getFabricDataGenerator().getModId();
@Inject(method = "method_27046", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/DataGenerator$class_7489;method_44107(Lnet/minecraft/util/Identifier;)Ljava/nio/file/Path;"), locals = LocalCapture.CAPTURE_FAILHARD)
public void addReplaced(DataWriter dataWriter, Identifier id, Builder builder, CallbackInfo ci, List list, List list2, JsonElement jsonElement) {
if (builder instanceof FabricTagBuilder fabricTagBuilder) {
jsonElement.getAsJsonObject().addProperty("replace", fabricTagBuilder.fabric_isReplaced());
}
return str;
}
}

View file

@ -21,9 +21,7 @@ import java.util.Set;
import java.util.function.Supplier;
import com.google.gson.JsonElement;
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;
@ -48,12 +46,16 @@ import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider;
@Mixin(ModelProvider.class)
public class ModelProviderMixin {
@Shadow
@Final
@Unique
private DataGenerator generator;
@Unique
private static ThreadLocal<DataGenerator> dataGeneratorThreadLocal = new ThreadLocal<>();
private static final ThreadLocal<DataGenerator> dataGeneratorThreadLocal = new ThreadLocal<>();
@Inject(method = "<init>", at = @At("RETURN"))
public void init(DataGenerator generator, CallbackInfo ci) {
this.generator = generator;
}
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/data/client/BlockStateModelGenerator;register()V"))
private void registerBlockStateModels(BlockStateModelGenerator instance) {

View file

@ -18,17 +18,15 @@ package net.fabricmc.fabric.mixin.datagen;
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.ModifyArg;
import net.minecraft.tag.Tag;
import net.minecraft.tag.Builder;
import net.fabricmc.fabric.impl.datagen.FabricTagBuilder;
/**
* Extends Tag.Builder to support setting the replace field.
*/
@Mixin(Tag.Builder.class)
@Mixin(Builder.class)
public class TagBuilderMixin implements FabricTagBuilder {
@Unique
private boolean replace = false;
@ -38,8 +36,8 @@ public class TagBuilderMixin implements FabricTagBuilder {
this.replace = replace;
}
@ModifyArg(method = "toJson", at = @At(value = "INVOKE", target = "Lcom/google/gson/JsonObject;addProperty(Ljava/lang/String;Ljava/lang/Boolean;)V"), index = 1)
public Boolean modifyReplace(Boolean replace) {
return this.replace;
@Override
public boolean fabric_isReplaced() {
return replace;
}
}

View file

@ -1,18 +1,25 @@
accessWidener v2 named
accessible field net/minecraft/data/server/RecipeProvider root Lnet/minecraft/data/DataGenerator;
accessible field net/minecraft/data/server/RecipeProvider field_39378 Lnet/minecraft/data/DataGenerator$class_7489;
accessible field net/minecraft/data/server/RecipeProvider field_39379 Lnet/minecraft/data/DataGenerator$class_7489;
extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder <init> (Lnet/minecraft/tag/Tag$Builder;Lnet/minecraft/util/registry/Registry;Ljava/lang/String;)V
accessible method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder <init> (Lnet/minecraft/tag/Builder;Lnet/minecraft/util/registry/Registry;)V
extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder add ([Ljava/lang/Object;)Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder;
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder builder Lnet/minecraft/tag/Tag$Builder;
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder builder Lnet/minecraft/tag/Builder;
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder registry Lnet/minecraft/util/registry/Registry;
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder source Ljava/lang/String;
accessible field net/minecraft/data/server/AbstractTagProvider tagBuilders Ljava/util/Map;
accessible field net/minecraft/data/server/BlockLootTableGenerator lootTables Ljava/util/Map;
accessible class net/minecraft/tag/Tag$TagEntry
extendable method net/minecraft/tag/TagEntry <init> (Lnet/minecraft/util/Identifier;ZZ)V
accessible field net/minecraft/tag/TagEntry id Lnet/minecraft/util/Identifier;
accessible field net/minecraft/tag/TagEntry field_39267 Z
accessible field net/minecraft/tag/TagEntry field_39268 Z
extendable method net/minecraft/data/DataGenerator$class_7489 <init> (Lnet/minecraft/data/DataGenerator;Lnet/minecraft/data/DataGenerator$class_7490;Ljava/lang/String;)V
accessible field net/minecraft/data/DataGenerator$class_7489 field_39365 Ljava/nio/file/Path;
accessible field net/minecraft/data/DataGenerator$class_7489 field_39366 Ljava/lang/String;
transitive-accessible method net/minecraft/data/family/BlockFamilies register (Lnet/minecraft/block/Block;)Lnet/minecraft/data/family/BlockFamily$Builder;
@ -26,7 +33,6 @@ transitive-accessible field net/minecraft/data/client/BlockStateModelGenerat
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-extendable method net/minecraft/data/server/AbstractTagProvider getOutput (Lnet/minecraft/util/Identifier;)Ljava/nio/file/Path;
transitive-extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder add ([Lnet/minecraft/util/registry/RegistryKey;)Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder;
transitive-accessible method net/minecraft/data/server/RecipeProvider saveRecipe (Lnet/minecraft/data/DataWriter;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V
@ -47,7 +53,7 @@ transitive-accessible method net/minecraft/data/server/RecipeProvider createTran
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 offerPressurePlateRecipe (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;
@ -183,7 +189,7 @@ transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator
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 registerParented (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/TextureMap;)V
transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerTorch (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V
@ -225,7 +231,7 @@ transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator g
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator cropStemDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator attachedCropStemDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator dropsWithShears (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator glowLichenDrops (Lnet/minecraft/block/Block;Lnet/minecraft/loot/condition/LootCondition$Builder;)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator multifaceGrowthDrops (Lnet/minecraft/block/Block;Lnet/minecraft/loot/condition/LootCondition$Builder;)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator leavesDrop (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;[F)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator oakLeavesDrop (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;[F)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator mangroveLeavesDrop (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder;

View file

@ -76,7 +76,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
dataGenerator.addProvider(TestBiomeTagProvider::new);
try {
new FabricTagProvider<>(dataGenerator, BuiltinRegistries.BIOME, "Biome Tags") {
new FabricTagProvider<>(dataGenerator, BuiltinRegistries.BIOME) {
@Override
protected void generateTags() {
}
@ -87,7 +87,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
}
try {
new FabricTagProvider.DynamicRegistryTagProvider<>(dataGenerator, Registry.ITEM_KEY, "items") {
new FabricTagProvider.DynamicRegistryTagProvider<>(dataGenerator, Registry.ITEM_KEY) {
@Override
protected void generateTags() {
}
@ -164,7 +164,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
private static class TestBiomeTagProvider extends FabricTagProvider.DynamicRegistryTagProvider<Biome> {
private TestBiomeTagProvider(FabricDataGenerator dataGenerator) {
super(dataGenerator, Registry.BIOME_KEY, "biomes");
super(dataGenerator, Registry.BIOME_KEY);
}
@Override

View file

@ -1,18 +1,25 @@
accessWidener v2 named
accessible field net/minecraft/data/server/RecipeProvider root Lnet/minecraft/data/DataGenerator;
accessible field net/minecraft/data/server/RecipeProvider field_39378 Lnet/minecraft/data/DataGenerator$class_7489;
accessible field net/minecraft/data/server/RecipeProvider field_39379 Lnet/minecraft/data/DataGenerator$class_7489;
extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder <init> (Lnet/minecraft/tag/Tag$Builder;Lnet/minecraft/util/registry/Registry;Ljava/lang/String;)V
accessible method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder <init> (Lnet/minecraft/tag/Builder;Lnet/minecraft/util/registry/Registry;)V
extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder add ([Ljava/lang/Object;)Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder;
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder builder Lnet/minecraft/tag/Tag$Builder;
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder builder Lnet/minecraft/tag/Builder;
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder registry Lnet/minecraft/util/registry/Registry;
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder source Ljava/lang/String;
accessible field net/minecraft/data/server/AbstractTagProvider tagBuilders Ljava/util/Map;
accessible field net/minecraft/data/server/BlockLootTableGenerator lootTables Ljava/util/Map;
accessible class net/minecraft/tag/Tag$TagEntry
extendable method net/minecraft/tag/TagEntry <init> (Lnet/minecraft/util/Identifier;ZZ)V
accessible field net/minecraft/tag/TagEntry id Lnet/minecraft/util/Identifier;
accessible field net/minecraft/tag/TagEntry field_39267 Z
accessible field net/minecraft/tag/TagEntry field_39268 Z
extendable method net/minecraft/data/DataGenerator$class_7489 <init> (Lnet/minecraft/data/DataGenerator;Lnet/minecraft/data/DataGenerator$class_7490;Ljava/lang/String;)V
accessible field net/minecraft/data/DataGenerator$class_7489 field_39365 Ljava/nio/file/Path;
accessible field net/minecraft/data/DataGenerator$class_7489 field_39366 Ljava/lang/String;
transitive-accessible method net/minecraft/data/family/BlockFamilies register (Lnet/minecraft/block/Block;)Lnet/minecraft/data/family/BlockFamily$Builder;
@ -26,5 +33,4 @@ transitive-accessible field net/minecraft/data/client/BlockStateModelGenerat
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-extendable method net/minecraft/data/server/AbstractTagProvider getOutput (Lnet/minecraft/util/Identifier;)Ljava/nio/file/Path;
transitive-extendable method net/minecraft/data/server/AbstractTagProvider$ObjectBuilder add ([Lnet/minecraft/util/registry/RegistryKey;)Lnet/minecraft/data/server/AbstractTagProvider$ObjectBuilder;

View file

@ -18,6 +18,8 @@ package net.fabricmc.fabric.api.object.builder.v1.villager;
import static com.google.common.base.Preconditions.checkState;
import java.util.function.Predicate;
import com.google.common.collect.ImmutableSet;
import org.jetbrains.annotations.Nullable;
@ -27,12 +29,12 @@ import net.minecraft.client.render.entity.feature.VillagerResourceMetadata;
import net.minecraft.item.Item;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.village.TradeOffers;
import net.minecraft.village.VillagerProfession;
import net.minecraft.world.poi.PointOfInterestType;
import net.fabricmc.fabric.mixin.object.builder.VillagerProfessionAccessor;
/**
* Allows for the creation of new {@link VillagerProfession}s.
*
@ -46,7 +48,8 @@ public final class VillagerProfessionBuilder {
private final ImmutableSet.Builder<Item> gatherableItemsBuilder = ImmutableSet.builder();
private final ImmutableSet.Builder<Block> secondaryJobSiteBlockBuilder = ImmutableSet.builder();
private Identifier identifier;
private PointOfInterestType pointOfInterestType;
private Predicate<RegistryEntry<PointOfInterestType>> pointOfInterestType;
private Predicate<RegistryEntry<PointOfInterestType>> acquirableJobSite;
@Nullable
private SoundEvent workSoundEvent;
@ -76,11 +79,27 @@ public final class VillagerProfessionBuilder {
/**
* The {@link PointOfInterestType} the Villager of this profession will search for when finding a workstation.
*
* @param type The {@link PointOfInterestType} the Villager will attempt to find.
* @param key The {@link PointOfInterestType} the Villager will attempt to find.
* @return this builder.
*/
public VillagerProfessionBuilder workstation(PointOfInterestType type) {
this.pointOfInterestType = type;
public VillagerProfessionBuilder workstation(RegistryKey<PointOfInterestType> key) {
jobSite(entry -> entry.matchesKey(key));
return workstation(entry -> entry.matchesKey(key));
}
/**
* The {@link PointOfInterestType} the Villager of this profession will search for when finding a workstation.
*
* @param predicate The {@link PointOfInterestType} the Villager will attempt to find.
* @return this builder.
*/
public VillagerProfessionBuilder workstation(Predicate<RegistryEntry<PointOfInterestType>> predicate) {
this.pointOfInterestType = predicate;
return this;
}
public VillagerProfessionBuilder jobSite(Predicate<RegistryEntry<PointOfInterestType>> predicate) {
this.acquirableJobSite = predicate;
return this;
}
@ -156,6 +175,8 @@ public final class VillagerProfessionBuilder {
public VillagerProfession build() {
checkState(this.identifier != null, "An Identifier is required to build a new VillagerProfession.");
checkState(this.pointOfInterestType != null, "A PointOfInterestType is required to build a new VillagerProfession.");
return VillagerProfessionAccessor.create(this.identifier.toString(), this.pointOfInterestType, this.gatherableItemsBuilder.build(), this.secondaryJobSiteBlockBuilder.build(), this.workSoundEvent);
checkState(this.acquirableJobSite != null, "A PointOfInterestType is required for the acquirableJobSite to build a new VillagerProfession.");
return new VillagerProfession(this.identifier.toString(), this.pointOfInterestType, this.acquirableJobSite, this.gatherableItemsBuilder.build(), this.secondaryJobSiteBlockBuilder.build(), this.workSoundEvent);
}
}

View file

@ -17,19 +17,18 @@
package net.fabricmc.fabric.api.object.builder.v1.world.poi;
import java.util.Set;
import java.util.function.Predicate;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.class_7477;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.poi.PointOfInterest;
import net.minecraft.world.poi.PointOfInterestType;
import net.fabricmc.fabric.mixin.object.builder.PointOfInterestTypeAccessor;
/**
* This class provides utilities to create a {@link PointOfInterestType}.
*
@ -59,26 +58,6 @@ public final class PointOfInterestHelper {
return register(id, ticketCount, searchDistance, builder.build());
}
/**
* Creates and registers a {@link PointOfInterestType}.
*
* @param id The id of this {@link PointOfInterestType}.
* @param ticketCount the amount of tickets.
* @param completionCondition a {@link Predicate} which determines if two {@link PointOfInterestType}s are the same.
* @param searchDistance the search distance.
* @param blocks all blocks where a {@link PointOfInterest} of this type will be present
* @return a new {@link PointOfInterestType}.
*/
public static PointOfInterestType register(Identifier id, int ticketCount, Predicate<PointOfInterestType> completionCondition, int searchDistance, Block... blocks) {
final ImmutableSet.Builder<BlockState> builder = ImmutableSet.builder();
for (Block block : blocks) {
builder.addAll(block.getStateManager().getStates());
}
return register(id, ticketCount, completionCondition, searchDistance, builder.build());
}
/**
* Creates and registers a {@link PointOfInterestType}.
*
@ -94,31 +73,9 @@ public final class PointOfInterestHelper {
return register(id, ticketCount, searchDistance, builder.addAll(blocks).build());
}
/**
* Creates and registers a {@link PointOfInterestType}.
*
* @param id the id of this {@link PointOfInterestType}.
* @param ticketCount the amount of tickets.
* @param typePredicate a {@link Predicate} which determines if two {@link PointOfInterestType}s are the same.
* @param searchDistance the search distance.
* @param states all {@link BlockState block states} where a {@link PointOfInterest} of this type will be present
* @return a new {@link PointOfInterestType}.
*/
public static PointOfInterestType register(Identifier id, int ticketCount, Predicate<PointOfInterestType> typePredicate, int searchDistance, Iterable<BlockState> states) {
final ImmutableSet.Builder<BlockState> builder = ImmutableSet.builder();
return register(id, ticketCount, typePredicate, searchDistance, builder.addAll(states).build());
}
// INTERNAL METHODS
private static PointOfInterestType register(Identifier id, int ticketCount, int searchDistance, Set<BlockState> states) {
return Registry.register(Registry.POINT_OF_INTEREST_TYPE, id, PointOfInterestTypeAccessor.callSetup(
PointOfInterestTypeAccessor.callCreate(id.toString(), states, ticketCount, searchDistance)));
}
private static PointOfInterestType register(Identifier id, int ticketCount, Predicate<PointOfInterestType> typePredicate, int searchDistance, Set<BlockState> states) {
return Registry.register(Registry.POINT_OF_INTEREST_TYPE, id, PointOfInterestTypeAccessor.callSetup(
PointOfInterestTypeAccessor.callCreate(id.toString(), states, ticketCount, typePredicate, searchDistance)));
return class_7477.method_43993(Registry.POINT_OF_INTEREST_TYPE, RegistryKey.of(Registry.POINT_OF_INTEREST_TYPE_KEY, id), states, ticketCount, searchDistance);
}
}

View file

@ -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.object.builder;
import java.util.Set;
import java.util.function.Predicate;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.block.BlockState;
import net.minecraft.world.poi.PointOfInterestType;
@Mixin(PointOfInterestType.class)
public interface PointOfInterestTypeAccessor {
@Invoker("<init>")
static PointOfInterestType callCreate(String id, Set<BlockState> blockStates, int ticketCount, Predicate<PointOfInterestType> typePredicate, int searchDistance) {
throw new AssertionError("Untransformed Accessor!");
}
@Invoker("<init>")
static PointOfInterestType callCreate(String id, Set<BlockState> blockStates, int ticketCount, int searchDistance) {
throw new AssertionError("Untransformed Accessor!");
}
@Invoker("setup")
static PointOfInterestType callSetup(PointOfInterestType pointOfInterestType) {
throw new AssertionError("Untransformed Accessor!");
}
}

View file

@ -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.mixin.object.builder;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.sound.SoundEvent;
import net.minecraft.village.VillagerProfession;
import net.minecraft.world.poi.PointOfInterestType;
@Mixin(VillagerProfession.class)
public interface VillagerProfessionAccessor {
@Invoker("<init>")
static VillagerProfession create(String id, PointOfInterestType type, ImmutableSet<Item> gatherableItems, ImmutableSet<Block> secondaryJobSites, @Nullable SoundEvent soundEvent) {
throw new AssertionError("Untransformed accessor!");
}
}

View file

@ -2,4 +2,6 @@ accessWidener v1 named
extendable method net/minecraft/block/AbstractBlock$Settings <init> (Lnet/minecraft/block/Material;Ljava/util/function/Function;)V
extendable method net/minecraft/block/AbstractBlock$Settings <init> (Lnet/minecraft/block/Material;Lnet/minecraft/block/MapColor;)V
accessible method net/minecraft/class_7477 method_43993 (Lnet/minecraft/util/registry/Registry;Lnet/minecraft/util/registry/RegistryKey;Ljava/util/Set;II)Lnet/minecraft/world/poi/PointOfInterestType;
extendable class net/minecraft/block/entity/BlockEntityType$BlockEntityFactory

View file

@ -10,10 +10,8 @@
"DefaultAttributeRegistryMixin",
"DetectorRailBlockMixin",
"MaterialBuilderAccessor",
"PointOfInterestTypeAccessor",
"SpawnRestrictionAccessor",
"TypeAwareTradeMixin",
"VillagerProfessionAccessor",
"VillagerTypeAccessor"
],
"client": [

View file

@ -16,6 +16,7 @@
package net.fabricmc.fabric.impl.resource.conditions;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -30,7 +31,6 @@ import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.tag.TagManagerLoader;
import net.minecraft.util.Identifier;
@ -140,11 +140,11 @@ public class ResourceConditionsImpl {
* - any call to {@link #tagsPopulatedMatch} will check the tags from the failed reload instead of failing directly.
* This is probably acceptable.
*/
public static final ThreadLocal<Map<RegistryKey<?>, Map<Identifier, Tag<RegistryEntry<?>>>>> LOADED_TAGS = new ThreadLocal<>();
public static final ThreadLocal<Map<RegistryKey<?>, Map<Identifier, Collection<RegistryEntry<?>>>>> LOADED_TAGS = new ThreadLocal<>();
@SuppressWarnings({"unchecked", "rawtypes"})
public static void setTags(List<TagManagerLoader.RegistryTags<?>> tags) {
Map<RegistryKey<?>, Map<Identifier, Tag<RegistryEntry<?>>>> tagMap = new HashMap<>();
Map<RegistryKey<?>, Map<Identifier, Collection<RegistryEntry<?>>>> tagMap = new HashMap<>();
for (TagManagerLoader.RegistryTags<?> registryTags : tags) {
tagMap.put(registryTags.key(), (Map) registryTags.tags());
@ -160,14 +160,14 @@ public class ResourceConditionsImpl {
public static <T> boolean tagsPopulatedMatch(JsonObject object, RegistryKey<? extends Registry<T>> registryKey) {
JsonArray array = JsonHelper.getArray(object, "values");
@Nullable
Map<RegistryKey<?>, Map<Identifier, Tag<RegistryEntry<?>>>> allTags = LOADED_TAGS.get();
Map<RegistryKey<?>, Map<Identifier, Collection<RegistryEntry<?>>>> allTags = LOADED_TAGS.get();
if (allTags == null) {
LOGGER.warn("Can't retrieve deserialized tags. Failing tags_populated resource condition check.");
return false;
}
Map<Identifier, Tag<RegistryEntry<?>>> registryTags = allTags.get(registryKey);
Map<Identifier, Collection<RegistryEntry<?>>> registryTags = allTags.get(registryKey);
if (registryTags == null) {
// No tag for this registry
@ -177,9 +177,9 @@ public class ResourceConditionsImpl {
for (JsonElement element : array) {
if (element.isJsonPrimitive()) {
Identifier id = new Identifier(element.getAsString());
Tag<RegistryEntry<?>> tag = registryTags.get(id);
Collection<RegistryEntry<?>> tags = registryTags.get(id);
if (tag == null || tag.values().isEmpty()) {
if (tags == null || tags.isEmpty()) {
return false;
}
} else {

View file

@ -1,9 +1,9 @@
org.gradle.jvmargs=-Xmx2560M
version=0.52.1
minecraft_version=22w18a
yarn_version=+build.3
loader_version=0.14.4
version=0.52.2
minecraft_version=22w19a
yarn_version=+build.1
loader_version=0.14.5
prerelease=true
@ -12,12 +12,12 @@ fabric-api-base-version=0.4.6
fabric-api-lookup-api-v1-version=1.6.2
fabric-biome-api-v1-version=9.0.6
fabric-blockrenderlayer-v1-version=1.1.14
fabric-command-api-v1-version=1.1.15
fabric-commands-v0-version=0.2.14
fabric-command-api-v1-version=1.1.16
fabric-commands-v0-version=0.2.15
fabric-containers-v0-version=0.1.23
fabric-content-registries-v0-version=3.0.10
fabric-crash-report-info-v1-version=0.1.12
fabric-data-generation-api-v1-version=3.0.5
fabric-data-generation-api-v1-version=4.0.0
fabric-dimensions-v1-version=2.1.21
fabric-entity-events-v1-version=1.4.13
fabric-events-interaction-v0-version=0.4.23
@ -34,7 +34,7 @@ fabric-mining-level-api-v1-version=2.1.2
fabric-models-v0-version=0.3.10
fabric-networking-api-v1-version=1.0.23
fabric-networking-v0-version=0.3.10
fabric-object-builder-api-v1-version=3.1.3
fabric-object-builder-api-v1-version=4.0.0
fabric-particles-v1-version=1.0.3
fabric-registry-sync-v0-version=0.9.11
fabric-renderer-api-v1-version=1.0.3
@ -44,11 +44,11 @@ fabric-rendering-data-attachment-v1-version=0.3.9
fabric-rendering-fluids-v1-version=3.0.1
fabric-rendering-v0-version=1.1.16
fabric-rendering-v1-version=1.10.10
fabric-resource-conditions-api-v1-version=2.0.4
fabric-resource-conditions-api-v1-version=2.0.5
fabric-resource-loader-v0-version=0.4.25
fabric-screen-api-v1-version=1.0.18
fabric-screen-handler-api-v1-version=1.2.2
fabric-textures-v0-version=1.0.14
fabric-transfer-api-v1-version=2.0.1
fabric-transitive-access-wideners-v1-version=1.0.3
fabric-convention-tags-v1-version=1.0.3
fabric-convention-tags-v1-version=1.0.4

View file

@ -16,7 +16,7 @@
"FabricMC"
],
"depends": {
"fabricloader": ">=0.14.3",
"fabricloader": ">=0.14.5",
"java": ">=17",
"minecraft": "~1.19-alpha.22.18.a"
},