aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_ChatHeight.java
blob: 3b6d8b6053d245d4565513246036e1bbd0f56577 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package org.polyfrost.chatting.mixin;

import net.minecraft.client.gui.GuiNewChat;
import org.polyfrost.chatting.Chatting;
import org.polyfrost.chatting.config.ChattingConfig;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(GuiNewChat.class)
public abstract class GuiNewChatMixin_ChatHeight {
    @Shadow public abstract boolean getChatOpen();

    @Inject(method = "getChatHeight", at = @At("HEAD"), cancellable = true)
    private void customHeight_getChatHeight(CallbackInfoReturnable<Integer> cir) {
        if (ChattingConfig.INSTANCE.getCustomChatHeight())
            cir.setReturnValue(Chatting.INSTANCE.getChatHeight(getChatOpen()));
    }
}