mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-14 07:35:10 +01:00
Get Fabric working again, various improvements
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
package eu.midnightdust.midnightcontrols.client.compat;
|
||||
|
||||
import me.juancarloscp52.bedrockify.client.BedrockifyClient;
|
||||
import me.juancarloscp52.bedrockify.client.BedrockifyClientSettings;
|
||||
|
||||
/**
|
||||
* Represents HQM compatibility handler.
|
||||
|
||||
@@ -19,14 +19,15 @@ public class EmotecraftCompat {
|
||||
if (client.currentScreen instanceof FastChosseScreen) {
|
||||
int x = client.getWindow().getWidth() / 2;
|
||||
int y = client.getWindow().getHeight() / 2;
|
||||
if (index == 0) InputManager.queueMousePosition(x-200, y-200);
|
||||
if (index == 1) InputManager.queueMousePosition(x, y-200);
|
||||
if (index == 2) InputManager.queueMousePosition(x+200, y-200);
|
||||
if (index == 3) InputManager.queueMousePosition(x-200, y);
|
||||
if (index == 4) InputManager.queueMousePosition(x+200, y);
|
||||
if (index == 5) InputManager.queueMousePosition(x-200, y+200);
|
||||
if (index == 6) InputManager.queueMousePosition(x, y+200);
|
||||
if (index == 7) InputManager.queueMousePosition(x+200, y+200);
|
||||
switch (index) {
|
||||
case 0, 3, 5 -> x -= 200;
|
||||
case 2, 4, 7 -> x += 200;
|
||||
}
|
||||
switch (index) {
|
||||
case 0, 1, 2 -> y -= 200;
|
||||
case 5, 6, 7 -> y += 200;
|
||||
}
|
||||
InputManager.queueMousePosition(x, y);
|
||||
|
||||
InputManager.INPUT_MANAGER.updateMousePosition(client);
|
||||
}
|
||||
|
||||
@@ -14,30 +14,37 @@ import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.option.ControlsOptionsScreen;
|
||||
import net.minecraft.client.gui.screen.option.GameOptionsScreen;
|
||||
import net.minecraft.client.gui.widget.OptionListWidget;
|
||||
import net.minecraft.client.gui.widget.TextIconButtonWidget;
|
||||
import net.minecraft.client.option.GameOptions;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* Injects the new controls settings button.
|
||||
*/
|
||||
@Mixin(ControlsOptionsScreen.class)
|
||||
public abstract class ControlsOptionsScreenMixin extends GameOptionsScreen {
|
||||
|
||||
public ControlsOptionsScreenMixin(Screen parent, GameOptions gameOptions, Text title) {
|
||||
super(parent, gameOptions, title);
|
||||
}
|
||||
@Mixin(GameOptionsScreen.class)
|
||||
public abstract class GameOptionsScreenMixin extends Screen {
|
||||
@Shadow @Nullable protected OptionListWidget body;
|
||||
@Unique TextIconButtonWidget midnightcontrols$button = TextIconButtonWidget.builder(Text.translatable("midnightcontrols.menu.title.controller"), (button -> this.client.setScreen(new MidnightControlsSettingsScreen(this, false))), true)
|
||||
.dimension(20,20).texture(Identifier.of("midnightcontrols", "icon/controller"), 20, 20).build();
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
this.midnightcontrols$setupButton();
|
||||
this.addDrawableChild(midnightcontrols$button);
|
||||
protected GameOptionsScreenMixin(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(method = "initTabNavigation", at = @At("HEAD"))
|
||||
public void addMidnightButton(CallbackInfo ci) {
|
||||
if (this.getClass().toString().equals(ControlsOptionsScreen.class.toString())) {
|
||||
this.midnightcontrols$setupButton();
|
||||
this.addDrawableChild(midnightcontrols$button);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2021 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of midnightcontrols.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package eu.midnightdust.midnightcontrols.event;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.ControlsMode;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an event callback which is fired when a player changes the controls mode.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.1.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface PlayerChangeControlsModeCallback {
|
||||
Event<PlayerChangeControlsModeCallback> EVENT = EventFactory.createArrayBacked(PlayerChangeControlsModeCallback.class, listeners -> (player, controlsMode) -> {
|
||||
for (PlayerChangeControlsModeCallback event : listeners) {
|
||||
event.apply(player, controlsMode);
|
||||
}
|
||||
});
|
||||
|
||||
void apply(@NotNull PlayerEntity player, @NotNull ControlsMode controlsMode);
|
||||
}
|
||||
Reference in New Issue
Block a user