Skip to content

Commit

Permalink
Merge pull request #5 from Motschen/1.18.2
Browse files Browse the repository at this point in the history
Migrate from LambdaControls to MidnightControls
  • Loading branch information
FoundationGames authored Aug 10, 2022
2 parents 7c6d2e5 + 8c4c2b2 commit 91f9698
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 66 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A Minecraft vehicle mod adding customizable cars. <br/><br/>
![Turbo](./md/turbo.png) <br/>

### Try it out!
Recommended to use along with [LambdaControls](https://www.curseforge.com/minecraft/mc-mods/lambdacontrols), which allows for controller support when driving an automobile. (Already loaded when using in dev environment)
Recommended to use along with [MidnightControls](https://www.curseforge.com/minecraft/mc-mods/midnightcontrols), which allows for controller support when driving an automobile. (Already loaded when using in dev environment)
<br/><br/>
There are no official releases yet. <br/>
#### If you would like to try it out:
Expand All @@ -21,7 +21,7 @@ To get an automobile in game, construct it on an Automobile Assembler using a fr
- A/D - Steer left/right
- Space - Drift

**Driving with Controller (LambdaControls):**
**Driving with Controller (MidnightControls):**
- A - Accelerate
- B - Brake/Reverse
- LStick - Steer left/right
Expand Down
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Controller Support
modApi ("dev.lambdaurora:lambdacontrols:${project.lambdacontrols_version}") {
exclude (group: "com.google.guava")
exclude (group: "net.fabricmc.fabric-api")
modImplementation "dev.lambdaurora:spruceui:${project.spruceui_version}"
modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"
modImplementation "maven.modrinth:midnightcontrols:${project.midnightcontrols_version}"
api('org.aperlambda:lambdajcommon:1.8.1') {
exclude group: 'com.google.code.gson'
exclude group: 'com.google.guava'
}

// OBJ loader
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ loader_version=0.13.3
fabric_version=0.51.1+1.18.2

# Other Dependencies
lambdacontrols_version=1.7.1+1.17
midnightcontrols_version=1.4.1-1.18
midnightlib_version=0.4.4
spruceui_version=3.3.3+1.18
myron_version=1.6.3+1.18.1
arrp_version=0.5.5
jsonem_version=0.1.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.github.foundationgames.automobility.screen.AutoMechanicTableScreenHandler;
import io.github.foundationgames.automobility.sound.AutomobilitySounds;
import io.github.foundationgames.automobility.util.AUtils;
import io.github.foundationgames.automobility.util.lambdacontrols.ControllerUtils;
import io.github.foundationgames.automobility.util.midnightcontrols.ControllerUtils;
import io.github.foundationgames.automobility.util.network.PayloadPackets;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
Expand Down Expand Up @@ -47,7 +47,7 @@ public void onInitialize() {

PayloadPackets.init();
AutomobilityData.setup();
ControllerUtils.initLCHandler();
ControllerUtils.initMidnightControlsHandler();
}

public static void initOther() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import io.github.foundationgames.automobility.sound.AutomobileSoundInstance;
import io.github.foundationgames.automobility.sound.AutomobilitySounds;
import io.github.foundationgames.automobility.util.AUtils;
import io.github.foundationgames.automobility.util.lambdacontrols.ControllerUtils;
import io.github.foundationgames.automobility.util.midnightcontrols.ControllerUtils;
import io.github.foundationgames.automobility.util.network.PayloadPackets;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.foundationgames.automobility.mixin;

import io.github.foundationgames.automobility.entity.AutomobileEntity;
import io.github.foundationgames.automobility.util.lambdacontrols.ControllerUtils;
import io.github.foundationgames.automobility.util.midnightcontrols.ControllerUtils;
import net.minecraft.client.input.Input;
import net.minecraft.client.network.ClientPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.foundationgames.automobility.mixin.lambdacontrols;
package io.github.foundationgames.automobility.mixin.midnightcontrols;

import dev.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
import dev.lambdaurora.lambdacontrols.client.controller.InputHandlers;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import eu.midnightdust.midnightcontrols.client.controller.InputHandlers;
import io.github.foundationgames.automobility.entity.AutomobileEntity;
import io.github.foundationgames.automobility.util.lambdacontrols.AutomobilityLC;
import io.github.foundationgames.automobility.util.midnightcontrols.AutomobilityMidnightControls;
import net.minecraft.client.MinecraftClient;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -21,7 +21,7 @@ public class InputHandlersMixin {
private static void automobility$makeAutomobileInputsWork(@NotNull MinecraftClient client, @NotNull ButtonBinding binding, CallbackInfoReturnable<Boolean> cir) {
var player = client.player;
if (!(player == null || !(player.getVehicle() instanceof AutomobileEntity))) {
for (ButtonBinding ab : AutomobilityLC.AUTOMOBILITY_BINDINGS) {
for (ButtonBinding ab : AutomobilityMidnightControls.AUTOMOBILITY_BINDINGS) {
if (Arrays.equals(ab.getButton(), binding.getButton())) cir.setReturnValue(false);
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package io.github.foundationgames.automobility.util.lambdacontrols;

import dev.lambdaurora.lambdacontrols.ControlsMode;
import dev.lambdaurora.lambdacontrols.client.LambdaControlsClient;
import dev.lambdaurora.lambdacontrols.client.compat.CompatHandler;
import dev.lambdaurora.lambdacontrols.client.compat.LambdaControlsCompat;
import dev.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
import dev.lambdaurora.lambdacontrols.client.controller.ButtonCategory;
import dev.lambdaurora.lambdacontrols.client.controller.InputManager;
package io.github.foundationgames.automobility.util.midnightcontrols;

import eu.midnightdust.midnightcontrols.ControlsMode;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import eu.midnightdust.midnightcontrols.client.compat.CompatHandler;
import eu.midnightdust.midnightcontrols.client.compat.MidnightControlsCompat;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import eu.midnightdust.midnightcontrols.client.controller.ButtonCategory;
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.entity.AutomobileEntity;
import net.minecraft.client.MinecraftClient;
Expand All @@ -19,12 +20,7 @@
import java.util.function.Supplier;

import static org.lwjgl.glfw.GLFW.*;

/*
* LambdaControls is discontinued and this has a nearly 100% chance of being removed in the future (once the mod is broken)
*/
//
public class AutomobilityLC implements CompatHandler {
public class AutomobilityMidnightControls implements CompatHandler {
public static final PairPredicate<MinecraftClient, ButtonBinding> ON_AUTOMOBILE = (client, button) -> client.player != null && client.player.getVehicle() instanceof AutomobileEntity;

public static final Set<ButtonBinding> AUTOMOBILITY_BINDINGS = new HashSet<>();
Expand All @@ -44,13 +40,13 @@ public class AutomobilityLC implements CompatHandler {
public static Supplier<Boolean> IN_CONTROLLER_MODE = () -> false;

public static void init() {
LambdaControlsCompat.registerCompatHandler(new AutomobilityLC());
MidnightControlsCompat.registerCompatHandler(new AutomobilityMidnightControls());
}

@Override
public void handle(@NotNull LambdaControlsClient mod) {
public void handle(@NotNull MidnightControlsClient mod) {
AUTOMOBILITY_CATEGORY.registerAllBindings(ACCELERATE, BRAKE, DRIFT);
IN_CONTROLLER_MODE = () -> mod.config.getControlsMode() == ControlsMode.CONTROLLER;
IN_CONTROLLER_MODE = () -> MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER;
}

private static ButtonBinding binding(ButtonBinding binding) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.github.foundationgames.automobility.util.midnightcontrols;

import net.fabricmc.loader.api.FabricLoader;

public enum ControllerUtils {;
public static boolean accelerating() {
return isMidnightControlsLoaded() && AutomobilityMidnightControls.ACCELERATE.isButtonDown();
}

public static boolean braking() {
return isMidnightControlsLoaded() && AutomobilityMidnightControls.BRAKE.isButtonDown();
}

public static boolean drifting() {
return isMidnightControlsLoaded() && AutomobilityMidnightControls.DRIFT.isButtonDown();
}

public static boolean inControllerMode() {
return isMidnightControlsLoaded() && AutomobilityMidnightControls.IN_CONTROLLER_MODE.get();
}

public static void initMidnightControlsHandler() {
if (isMidnightControlsLoaded()) AutomobilityMidnightControls.init();
}

public static boolean isMidnightControlsLoaded() {
return FabricLoader.getInstance().isModLoaded("midnightcontrols");
}
}
6 changes: 3 additions & 3 deletions src/main/resources/assets/automobility/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"itemGroup.automobility.automobility_prefabs": "Automobility: Prefabs",

"automobility.automobility": "Automobility",
"lambdacontrols.action.automobility.accelerate_automobile": "Accelerate",
"lambdacontrols.action.automobility.brake_automobile": "Brake/Reverse",
"lambdacontrols.action.automobility.drift_automobile": "Drift",
"midnightcontrols.action.automobility.accelerate_automobile": "Accelerate",
"midnightcontrols.action.automobility.brake_automobile": "Brake/Reverse",
"midnightcontrols.action.automobility.drift_automobile": "Drift",

"item.automobility.automobile": "Automobile",
"item.automobility.crowbar": "Crowbar",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/automobility.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"EntityRenderersMixin",
"GameRendererMixin",
"ModelElementDeserializerMixin",
"lambdacontrols.InputHandlersMixin"
"midnightcontrols.InputHandlersMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 91f9698

Please sign in to comment.