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

import cc.woverflow.chatting.Chatting;
import cc.woverflow.chatting.config.ChattingConfig;
import net.minecraft.client.gui.GuiNewChat;
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()));
    }
}