1 package com.irtimaled.bbor.mixin.resource;
3 import com.google.common.collect.ImmutableMap;
4 import net.minecraft.resource.DefaultResourcePack;
5 import net.minecraft.resource.ResourcePackManager;
6 import net.minecraft.resource.ResourcePackProfile;
7 import net.minecraft.resource.ResourcePackSource;
8 import org.spongepowered.asm.mixin.Final;
9 import org.spongepowered.asm.mixin.Mixin;
10 import org.spongepowered.asm.mixin.Shadow;
11 import org.spongepowered.asm.mixin.injection.At;
12 import org.spongepowered.asm.mixin.injection.Inject;
13 import org.spongepowered.asm.mixin.injection.Redirect;
14 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18 @Mixin(ResourcePackManager.class)
19 public class MixinResourcePackManager {
20 private static final String BBOR = "bbor";
23 private ResourcePackProfile.Factory profileFactory;
24 private ResourcePackProfile resourcePackProfile;
26 @Inject(method = "<init>(Lnet/minecraft/resource/ResourcePackProfile$Factory;[Lnet/minecraft/resource/ResourcePackProvider;)V",
28 private void afterConstructor(CallbackInfo ci) {
29 resourcePackProfile = ResourcePackProfile.of(BBOR,
31 () -> new DefaultResourcePack(BBOR),
33 ResourcePackProfile.InsertionPosition.BOTTOM,
34 ResourcePackSource.PACK_SOURCE_BUILTIN);
37 @Redirect(method = "providePackProfiles", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableMap;copyOf(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;"))
38 private ImmutableMap<String, ResourcePackProfile> beforeReturn(Map<String, ResourcePackProfile> map) {
39 map.put(BBOR, resourcePackProfile);
40 return ImmutableMap.copyOf(map);