]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/mixin/resource/MixinResourcePackManager.java
Setup for 1.16.3 Fabric
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / mixin / resource / MixinResourcePackManager.java
1 package com.irtimaled.bbor.mixin.resource;
2
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;
15
16 import java.util.Map;
17
18 @Mixin(ResourcePackManager.class)
19 public class MixinResourcePackManager {
20     private static final String BBOR = "bbor";
21     @Shadow
22     @Final
23     private ResourcePackProfile.Factory profileFactory;
24     private ResourcePackProfile resourcePackProfile;
25
26     @Inject(method = "<init>(Lnet/minecraft/resource/ResourcePackProfile$Factory;[Lnet/minecraft/resource/ResourcePackProvider;)V",
27             at = @At("RETURN"))
28     private void afterConstructor(CallbackInfo ci) {
29         resourcePackProfile = ResourcePackProfile.of(BBOR,
30                 true,
31                 () -> new DefaultResourcePack(BBOR),
32                 this.profileFactory,
33                 ResourcePackProfile.InsertionPosition.BOTTOM,
34                 ResourcePackSource.PACK_SOURCE_BUILTIN);
35     }
36
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);
41     }
42 }