Changes to TagLoader
This commit is contained in:
parent
3c5661aed9
commit
307486a32c
2 changed files with 11 additions and 10 deletions
|
@ -1,26 +1,27 @@
|
|||
package ru.bclib.mixin.common;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.TagLoader;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import ru.bclib.util.TagHelper;
|
||||
|
||||
@Mixin(TagLoader.class)
|
||||
public class TagLoaderMixin {
|
||||
@Shadow
|
||||
private String name;
|
||||
private String directory;
|
||||
|
||||
@ModifyArg(method = "prepare", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
|
||||
public Supplier<Map<ResourceLocation, Tag.Builder>> be_modifyTags(Supplier<Map<ResourceLocation, Tag.Builder>> supplier, Executor executor) {
|
||||
return () -> TagHelper.apply(name, supplier.get());
|
||||
//@ModifyArg(method = "prepare", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
|
||||
@Inject(method="load", at=@At(value="RETURN"))
|
||||
public void be_modifyTags(ResourceManager resourceManager, CallbackInfoReturnable<Map<ResourceLocation, Tag.Builder>> cir) {
|
||||
TagHelper.apply(directory, cir.getReturnValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,11 +58,11 @@ public class TagHelper {
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static Map<ResourceLocation, Tag.Builder> apply(String entry, Map<ResourceLocation, Tag.Builder> tagsMap) {
|
||||
public static Map<ResourceLocation, Tag.Builder> apply(String directory, Map<ResourceLocation, Tag.Builder> tagsMap) {
|
||||
Map<ResourceLocation, Set<ResourceLocation>> endTags = null;
|
||||
if (entry.equals("block")) {
|
||||
if ("tags/blocks".equals(directory)) {
|
||||
endTags = TAGS_BLOCK;
|
||||
} else if (entry.equals("item")) {
|
||||
} else if ("tags/items".equals(directory)) {
|
||||
endTags = TAGS_ITEM;
|
||||
}
|
||||
if (endTags != null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue