Skip to content

Commit

Permalink
Small fix for game crashing when authme is installed and getting kicked
Browse files Browse the repository at this point in the history
  • Loading branch information
hexadecimal233 authored and Wide-Cat committed Aug 9, 2023
1 parent 6b430c0 commit e517a9a
Showing 1 changed file with 3 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

@Mixin(DisconnectedScreen.class)
public abstract class DisconnectedScreenMixin extends Screen {
@Unique private GridWidget grid;
@Unique private ButtonWidget reconnectBtn;
@Unique private double time = Modules.get().get(AutoReconnect.class).time.get() * 20;

Expand All @@ -37,19 +36,13 @@ protected DisconnectedScreenMixin(Text title) {
}

@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget;refreshPositions()V", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD)
private void onInit_before(CallbackInfo info, GridWidget.Adder adder) {
private void addButtons(CallbackInfo info, GridWidget.Adder adder) {
AutoReconnect autoReconnect = Modules.get().get(AutoReconnect.class);

if (autoReconnect.lastServerConnection != null) {
grid = new GridWidget();
adder.add(grid);
reconnectBtn = adder.add(new ButtonWidget.Builder(Text.literal(getText()), button -> tryConnecting()).build());

grid.setRowSpacing(2);
GridWidget.Adder myAdder = grid.createAdder(1);

reconnectBtn = myAdder.add(new ButtonWidget.Builder(Text.literal(getText()), button -> tryConnecting()).build());

myAdder.add(
adder.add(
new ButtonWidget.Builder(Text.literal("Toggle Auto Reconnect"), button -> {
autoReconnect.toggle();
reconnectBtn.setMessage(Text.literal(getText()));
Expand All @@ -59,14 +52,6 @@ private void onInit_before(CallbackInfo info, GridWidget.Adder adder) {
}
}

@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget;refreshPositions()V", shift = At.Shift.AFTER))
private void onInit_after(CallbackInfo info) {
if (grid != null) {
grid.refreshPositions();
grid.forEachChild(this::addDrawableChild);
}
}

@Override
public void tick() {
AutoReconnect autoReconnect = Modules.get().get(AutoReconnect.class);
Expand Down

0 comments on commit e517a9a

Please sign in to comment.