|
@@ -0,0 +1,47 @@
|
|
|
+/*
|
|
|
+ * Copyright 2020 shedaniel
|
|
|
+ *
|
|
|
+ * 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 me.shedaniel.architectury.mixin.fabric.client;
|
|
|
+
|
|
|
+import me.shedaniel.architectury.event.events.TextureStitchEvent;
|
|
|
+import net.minecraft.client.renderer.texture.TextureAtlas;
|
|
|
+import net.minecraft.resources.ResourceLocation;
|
|
|
+import net.minecraft.server.packs.resources.ResourceManager;
|
|
|
+import net.minecraft.util.profiling.ProfilerFiller;
|
|
|
+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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
|
+import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|
|
+
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Stream;
|
|
|
+
|
|
|
+@Mixin(TextureAtlas.class)
|
|
|
+public class MixinTextureAtlas {
|
|
|
+ @Inject(method = "prepareToStitch",
|
|
|
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", ordinal = 0,
|
|
|
+ shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD)
|
|
|
+ private void preStitch(ResourceManager resourceManager, Stream<ResourceLocation> stream, ProfilerFiller profilerFiller, int i, CallbackInfoReturnable<TextureAtlas.Preparations> cir, Set<ResourceLocation> set) {
|
|
|
+ TextureStitchEvent.PRE.invoker().stitch((TextureAtlas) (Object) this, set::add);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Inject(method = "reload", at = @At("RETURN"))
|
|
|
+ private void postStitch(TextureAtlas.Preparations preparations, CallbackInfo ci) {
|
|
|
+ TextureStitchEvent.POST.invoker().stitch((TextureAtlas) (Object) this);
|
|
|
+ }
|
|
|
+}
|