mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 23:25:10 +01:00
🚧 WIP on REI compatiblity.
This commit is contained in:
@@ -131,6 +131,18 @@ public class LambdaControlsConfig
|
|||||||
this.config.remove("gameplay.front_block_placing");
|
this.config.remove("gameplay.front_block_placing");
|
||||||
this.config.set("gameplay.front_block_placing.enabled", DEFAULT_FRONT_BLOCK_PLACING);
|
this.config.set("gameplay.front_block_placing.enabled", DEFAULT_FRONT_BLOCK_PLACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.renamed("controller.controls.tab_left", "controller.controls.tab_back");
|
||||||
|
this.renamed("controller.controls.tab_right", "controller.controls.tab_next");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renamed(String oldPath, String newPath)
|
||||||
|
{
|
||||||
|
if (!this.config.contains(oldPath))
|
||||||
|
return;
|
||||||
|
Object raw = this.config.getRaw(oldPath);
|
||||||
|
this.config.remove(oldPath);
|
||||||
|
this.config.set(newPath, raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class LambdaControlsCompat
|
|||||||
mod.log("Adding okzoomer compatibility...");
|
mod.log("Adding okzoomer compatibility...");
|
||||||
HANDLERS.add(new OkZoomerCompat());
|
HANDLERS.add(new OkZoomerCompat());
|
||||||
}
|
}
|
||||||
if (FabricLoader.getInstance().isModLoaded("roughlyenoughitems")) {
|
if (isReiPresent()) {
|
||||||
mod.log("Adding REI compatiblity...");
|
mod.log("Adding REI compatiblity...");
|
||||||
HANDLERS.add(new ReiCompat());
|
HANDLERS.add(new ReiCompat());
|
||||||
}
|
}
|
||||||
@@ -59,4 +59,14 @@ public class LambdaControlsCompat
|
|||||||
{
|
{
|
||||||
return HANDLERS.stream().anyMatch(handler -> handler.requireMouseOnScreen(screen));
|
return HANDLERS.stream().anyMatch(handler -> handler.requireMouseOnScreen(screen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether Roughly Enough Items is present.
|
||||||
|
*
|
||||||
|
* @return True if Roughly Enough Items is present, else false.
|
||||||
|
*/
|
||||||
|
public static boolean isReiPresent()
|
||||||
|
{
|
||||||
|
return FabricLoader.getInstance().isModLoaded("roughlyenoughitems");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||||
|
*
|
||||||
|
* This file is part of LambdaControls.
|
||||||
|
*
|
||||||
|
* Licensed under the MIT license. For more information,
|
||||||
|
* see the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lambdaurora.lambdacontrols.client.compat;
|
||||||
|
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||||
|
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This plugin is only present for the conditional mixins.
|
||||||
|
*
|
||||||
|
* @author LambdAurora
|
||||||
|
* @version 1.2.0
|
||||||
|
* @since 1.2.0
|
||||||
|
*/
|
||||||
|
public class LambdaControlsMixinPlugin implements IMixinConfigPlugin
|
||||||
|
{
|
||||||
|
private final HashMap<String, Boolean> conditionalMixins = new HashMap<>();
|
||||||
|
|
||||||
|
public LambdaControlsMixinPlugin()
|
||||||
|
{
|
||||||
|
this.conditionalMixins.put("me.lambdaurora.lambdacontrols.client.compat.mixin.RecipeViewingScreenAccessor", LambdaControlsCompat.isReiPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad(String mixinPackage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRefMapperConfig()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldApplyMixin(String targetClassName, String mixinClassName)
|
||||||
|
{
|
||||||
|
return this.conditionalMixins.getOrDefault(mixinClassName, Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getMixins()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ package me.lambdaurora.lambdacontrols.client.compat;
|
|||||||
|
|
||||||
import me.lambdaurora.lambdacontrols.client.ButtonState;
|
import me.lambdaurora.lambdacontrols.client.ButtonState;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.compat.mixin.RecipeViewingScreenAccessor;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||||
import me.lambdaurora.lambdacontrols.client.controller.PressAction;
|
import me.lambdaurora.lambdacontrols.client.controller.PressAction;
|
||||||
@@ -35,18 +36,19 @@ public class ReiCompat implements CompatHandler
|
|||||||
@Override
|
@Override
|
||||||
public void handle(@NotNull LambdaControlsClient mod)
|
public void handle(@NotNull LambdaControlsClient mod)
|
||||||
{
|
{
|
||||||
InputManager.registerBinding(new ButtonBinding.Builder(new Identifier("rei", "tab_right"))
|
InputManager.registerBinding(new ButtonBinding.Builder(new Identifier("rei", "tab_back"))
|
||||||
.buttons(GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER)
|
|
||||||
.filter((client, binding) -> isViewingScreen(client.currentScreen))
|
|
||||||
.action(tabAction(true))
|
|
||||||
.cooldown(true)
|
|
||||||
.build());
|
|
||||||
InputManager.registerBinding(new ButtonBinding.Builder(new Identifier("rei", "tab_left"))
|
|
||||||
.buttons(GLFW_GAMEPAD_BUTTON_LEFT_BUMPER)
|
.buttons(GLFW_GAMEPAD_BUTTON_LEFT_BUMPER)
|
||||||
.filter((client, binding) -> isViewingScreen(client.currentScreen))
|
.filter((client, binding) -> isViewingScreen(client.currentScreen))
|
||||||
.action(tabAction(false))
|
.action(tabAction(false))
|
||||||
.cooldown(true)
|
.cooldown(true)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
InputManager.registerBinding(new ButtonBinding.Builder(new Identifier("rei", "tab_next"))
|
||||||
|
.buttons(GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER)
|
||||||
|
.filter((client, binding) -> isViewingScreen(client.currentScreen))
|
||||||
|
.action(tabAction(true))
|
||||||
|
.cooldown(true)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,14 +62,18 @@ public class ReiCompat implements CompatHandler
|
|||||||
return screen instanceof RecipeViewingScreen || screen instanceof VillagerRecipeViewingScreen;
|
return screen instanceof RecipeViewingScreen || screen instanceof VillagerRecipeViewingScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PressAction tabAction(boolean right)
|
private static PressAction tabAction(boolean next)
|
||||||
{
|
{
|
||||||
return (client, button, action) -> {
|
return (client, button, action) -> {
|
||||||
if (action == ButtonState.RELEASE)
|
if (action == ButtonState.RELEASE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (client.currentScreen instanceof RecipeViewingScreen) {
|
if (client.currentScreen instanceof RecipeViewingScreen) {
|
||||||
RecipeViewingScreen screen = (RecipeViewingScreen) client.currentScreen;
|
RecipeViewingScreenAccessor screen = (RecipeViewingScreenAccessor) client.currentScreen;
|
||||||
|
if (next)
|
||||||
|
screen.getCategoryNext().onPressed();
|
||||||
|
else
|
||||||
|
screen.getCategoryBack().onPressed();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||||
|
*
|
||||||
|
* This file is part of LambdaControls.
|
||||||
|
*
|
||||||
|
* Licensed under the MIT license. For more information,
|
||||||
|
* see the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lambdaurora.lambdacontrols.client.compat.mixin;
|
||||||
|
|
||||||
|
import me.shedaniel.rei.gui.RecipeViewingScreen;
|
||||||
|
import me.shedaniel.rei.gui.widget.ButtonWidget;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an accessor to REI's RecipeViewingScreen.
|
||||||
|
*
|
||||||
|
* @author LambdAurora
|
||||||
|
* @version 1.2.0
|
||||||
|
* @since 1.2.0
|
||||||
|
*/
|
||||||
|
@Mixin(RecipeViewingScreen.class)
|
||||||
|
public interface RecipeViewingScreenAccessor
|
||||||
|
{
|
||||||
|
@Accessor("categoryBack")
|
||||||
|
ButtonWidget getCategoryBack();
|
||||||
|
|
||||||
|
@Accessor("categoryNext")
|
||||||
|
ButtonWidget getCategoryNext();
|
||||||
|
}
|
||||||
@@ -73,9 +73,9 @@ public class ButtonBinding implements Nameable
|
|||||||
.actions(PressAction.DEFAULT_ACTION, InputHandlers::handleToggleSneak).onlyInGame().cooldown(true).register();
|
.actions(PressAction.DEFAULT_ACTION, InputHandlers::handleToggleSneak).onlyInGame().cooldown(true).register();
|
||||||
public static final ButtonBinding SPRINT = new Builder("sprint").buttons(GLFW_GAMEPAD_BUTTON_LEFT_THUMB).register();
|
public static final ButtonBinding SPRINT = new Builder("sprint").buttons(GLFW_GAMEPAD_BUTTON_LEFT_THUMB).register();
|
||||||
public static final ButtonBinding SWAP_HANDS = new Builder("swap_hands").buttons(GLFW_GAMEPAD_BUTTON_X).cooldown(true).register();
|
public static final ButtonBinding SWAP_HANDS = new Builder("swap_hands").buttons(GLFW_GAMEPAD_BUTTON_X).cooldown(true).register();
|
||||||
public static final ButtonBinding TAB_LEFT = new Builder("tab_left").buttons(GLFW_GAMEPAD_BUTTON_LEFT_BUMPER)
|
public static final ButtonBinding TAB_LEFT = new Builder("tab_back").buttons(GLFW_GAMEPAD_BUTTON_LEFT_BUMPER)
|
||||||
.action(InputHandlers.handleHotbar(false)).filter(Predicates.or(InputHandlers::inInventory, InputHandlers::inAdvancements)).cooldown(true).register();
|
.action(InputHandlers.handleHotbar(false)).filter(Predicates.or(InputHandlers::inInventory, InputHandlers::inAdvancements)).cooldown(true).register();
|
||||||
public static final ButtonBinding TAB_RIGHT = new Builder("tab_right").buttons(GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER)
|
public static final ButtonBinding TAB_RIGHT = new Builder("tab_next").buttons(GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER)
|
||||||
.action(InputHandlers.handleHotbar(true)).filter(Predicates.or(InputHandlers::inInventory, InputHandlers::inAdvancements)).cooldown(true).register();
|
.action(InputHandlers.handleHotbar(true)).filter(Predicates.or(InputHandlers::inInventory, InputHandlers::inAdvancements)).cooldown(true).register();
|
||||||
public static final ButtonBinding TOGGLE_PERSPECTIVE = new Builder("toggle_perspective").buttons(GLFW_GAMEPAD_BUTTON_DPAD_UP, GLFW_GAMEPAD_BUTTON_Y).cooldown(true).register();
|
public static final ButtonBinding TOGGLE_PERSPECTIVE = new Builder("toggle_perspective").buttons(GLFW_GAMEPAD_BUTTON_DPAD_UP, GLFW_GAMEPAD_BUTTON_Y).cooldown(true).register();
|
||||||
public static final ButtonBinding USE = new Builder("use").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_TRIGGER, true)).register();
|
public static final ButtonBinding USE = new Builder("use").buttons(axisAsButton(GLFW_GAMEPAD_AXIS_LEFT_TRIGGER, true)).register();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package me.lambdaurora.lambdacontrols.client.mixin;
|
|||||||
|
|
||||||
import me.lambdaurora.lambdacontrols.ControlsMode;
|
import me.lambdaurora.lambdacontrols.ControlsMode;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.compat.LambdaControlsCompat;
|
||||||
import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsRenderer;
|
import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsRenderer;
|
||||||
import me.lambdaurora.lambdacontrols.client.util.ContainerScreenAccessor;
|
import me.lambdaurora.lambdacontrols.client.util.ContainerScreenAccessor;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
@@ -49,7 +50,7 @@ public abstract class ContainerScreenMixin implements ContainerScreenAccessor
|
|||||||
|
|
||||||
x = LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_A}, "lambdacontrols.action.pickup_all", true, client) + 2;
|
x = LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_A}, "lambdacontrols.action.pickup_all", true, client) + 2;
|
||||||
x = LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_B}, "lambdacontrols.action.exit", true, client) + 2;
|
x = LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_B}, "lambdacontrols.action.exit", true, client) + 2;
|
||||||
if (FabricLoader.getInstance().isModLoaded("roughlyenoughitems")) {
|
if (LambdaControlsCompat.isReiPresent()) {
|
||||||
x = 2;
|
x = 2;
|
||||||
y -= 24;
|
y -= 24;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,10 +95,10 @@ auto_switch_mode = false
|
|||||||
sprint = "9"
|
sprint = "9"
|
||||||
# Swap hands control.
|
# Swap hands control.
|
||||||
swap_hands = "2"
|
swap_hands = "2"
|
||||||
# Switch to left tab control.
|
# Switch to back tab control.
|
||||||
tab_left = "4"
|
tab_back = "4"
|
||||||
# Switch to right tab control.
|
# Switch to next tab control.
|
||||||
tab_right = "5"
|
tab_next = "5"
|
||||||
# Toggle perspective control.
|
# Toggle perspective control.
|
||||||
toggle_perspective = "11+3"
|
toggle_perspective = "11+3"
|
||||||
# Toggle smooth camera control.
|
# Toggle smooth camera control.
|
||||||
|
|||||||
@@ -27,7 +27,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"lambdacontrols.mixins.json"
|
"lambdacontrols.mixins.json",
|
||||||
|
"lambdacontrols_compat.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.4.0",
|
"fabricloader": ">=0.4.0",
|
||||||
@@ -40,7 +41,8 @@
|
|||||||
"okzoomer": ">=1.0.4"
|
"okzoomer": ">=1.0.4"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
"flamingo": "*"
|
"flamingo": "*",
|
||||||
|
"roughlyenoughitems": ">=3.4.5"
|
||||||
},
|
},
|
||||||
"breaks": {
|
"breaks": {
|
||||||
"modmenu": "<1.9.0"
|
"modmenu": "<1.9.0"
|
||||||
|
|||||||
12
fabric/src/main/resources/lambdacontrols_compat.mixins.json
Normal file
12
fabric/src/main/resources/lambdacontrols_compat.mixins.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"package": "me.lambdaurora.lambdacontrols.client.compat.mixin",
|
||||||
|
"plugin": "me.lambdaurora.lambdacontrols.client.compat.LambdaControlsMixinPlugin",
|
||||||
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"client": [
|
||||||
|
"RecipeViewingScreenAccessor"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user