|
1 | 1 | package simpleclient.mixin; |
2 | 2 |
|
| 3 | +import com.mojang.blaze3d.platform.Window; |
3 | 4 | import net.minecraft.SharedConstants; |
4 | 5 | import net.minecraft.client.Minecraft; |
| 6 | +import net.minecraft.client.main.GameConfig; |
5 | 7 | import net.minecraft.resources.ResourceLocation; |
| 8 | +import net.minecraft.server.packs.PackResources; |
| 9 | +import net.minecraft.server.packs.VanillaPackResources; |
6 | 10 | import net.minecraft.server.packs.resources.IoSupplier; |
| 11 | +import org.spongepowered.asm.mixin.Final; |
7 | 12 | import org.spongepowered.asm.mixin.Mixin; |
| 13 | +import org.spongepowered.asm.mixin.Shadow; |
8 | 14 | import org.spongepowered.asm.mixin.injection.At; |
9 | 15 | import org.spongepowered.asm.mixin.injection.Inject; |
| 16 | +import org.spongepowered.asm.mixin.injection.Redirect; |
| 17 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
10 | 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
11 | 19 | import simpleclient.SimpleClient; |
12 | 20 |
|
| 21 | +import java.io.IOException; |
13 | 22 | import java.io.InputStream; |
14 | 23 |
|
15 | 24 | @Mixin(Minecraft.class) |
16 | 25 | public abstract class MinecraftMixin { |
| 26 | + @Shadow @Final private Window window; |
| 27 | + |
| 28 | + @Shadow protected abstract IoSupplier<InputStream> getIconFile(String... par1) throws IOException; |
| 29 | + |
17 | 30 | @Inject(at = @At("HEAD"), method = "createTitle", cancellable = true) |
18 | 31 | public void createTitle(CallbackInfoReturnable<String> cir) { |
19 | 32 | cir.setReturnValue("Minecraft " + SharedConstants.getCurrentVersion().getName() + " | SimpleClient " + SimpleClient.VERSION); |
20 | 33 | } |
21 | 34 |
|
| 35 | + @Redirect(at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/Window;setIcon(Lnet/minecraft/server/packs/resources/IoSupplier;Lnet/minecraft/server/packs/resources/IoSupplier;)V"), method = "<init>") |
| 36 | + public void setIcon(Window instance, IoSupplier ioSupplier, IoSupplier ioSupplier2) {} |
| 37 | + |
| 38 | + @Inject(at = @At("TAIL"), method = "<init>") |
| 39 | + public void init(GameConfig gameConfig, CallbackInfo ci) { |
| 40 | + try { |
| 41 | + window.setIcon(getIconFile("icons", "icon_16x16.png"), getIconFile("icons", "icon_32x32.png")); |
| 42 | + } catch (Exception e) {e.printStackTrace();} |
| 43 | + } |
| 44 | + |
22 | 45 | @Inject(at = @At("HEAD"), method = "getIconFile", cancellable = true) |
23 | 46 | public void getIconFile(String[] strings, CallbackInfoReturnable<IoSupplier<InputStream>> cir) { |
24 | 47 | cir.setReturnValue(() -> Minecraft.getInstance().getResourceManager().open(new ResourceLocation("simpleclient", "textures/" + String.join("/", strings)))); |
|
0 commit comments