mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 07:15:10 +01:00
✨ Add fly drifting option.
This commit is contained in:
@@ -30,8 +30,6 @@ import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.aperlambda.lambdacommon.utils.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@@ -40,6 +40,7 @@ public class LambdaControlsConfig
|
||||
private static final HudSide DEFAULT_HUD_SIDE = HudSide.LEFT;
|
||||
// Gameplay
|
||||
private static final boolean DEFAULT_FRONT_BLOCK_PLACING = false;
|
||||
private static final boolean DEFAULT_FLY_DRIFTING = false;
|
||||
// Controller
|
||||
private static final ControllerType DEFAULT_CONTROLLER_TYPE = ControllerType.DEFAULT;
|
||||
private static final double DEFAULT_DEAD_ZONE = 0.25;
|
||||
@@ -123,6 +124,7 @@ public class LambdaControlsConfig
|
||||
this.set_hud_side(DEFAULT_HUD_SIDE);
|
||||
// Gameplay
|
||||
this.set_front_block_placing(DEFAULT_FRONT_BLOCK_PLACING);
|
||||
this.set_fly_drifting(DEFAULT_FLY_DRIFTING);
|
||||
// Controller
|
||||
this.set_controller_type(DEFAULT_CONTROLLER_TYPE);
|
||||
this.set_dead_zone(DEFAULT_DEAD_ZONE);
|
||||
@@ -244,6 +246,26 @@ public class LambdaControlsConfig
|
||||
this.config.set("gameplay.front_block_placing", enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether fly drifting is enabled or not.
|
||||
*
|
||||
* @return True if fly drifting is enabled, else false.
|
||||
*/
|
||||
public boolean has_fly_drifting()
|
||||
{
|
||||
return this.config.getOrElse("gameplay.fly_drifting", DEFAULT_FLY_DRIFTING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether fly drifting is enabled or not.
|
||||
*
|
||||
* @param fly_drifting True if fly drifting is enabled, else false.
|
||||
*/
|
||||
public void set_fly_drifting(boolean fly_drifting)
|
||||
{
|
||||
this.config.set("gameplay.fly_drifting", fly_drifting);
|
||||
}
|
||||
|
||||
/*
|
||||
Controller settings
|
||||
*/
|
||||
|
||||
@@ -13,8 +13,6 @@ import io.github.joaoh1.okzoomer.OkZoomer;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import me.lambdaurora.lambdacontrols.client.controller.InputManager;
|
||||
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
|
||||
import org.aperlambda.lambdacommon.utils.LambdaReflection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
|
||||
@@ -33,11 +33,11 @@ public class LambdaControlsControlsScreen extends Screen
|
||||
private final Screen parent;
|
||||
final LambdaControlsClient mod;
|
||||
private final boolean hide_settings;
|
||||
private ControlsListWidget bindings_list_widget;
|
||||
private ButtonWidget reset_button;
|
||||
public ButtonBinding focused_binding;
|
||||
public boolean waiting = false;
|
||||
public List<Integer> current_buttons = new ArrayList<>();
|
||||
private ControlsListWidget bindings_list_widget;
|
||||
private ButtonWidget reset_button;
|
||||
public ButtonBinding focused_binding;
|
||||
public boolean waiting = false;
|
||||
public List<Integer> current_buttons = new ArrayList<>();
|
||||
|
||||
public LambdaControlsControlsScreen(@NotNull Screen parent, boolean hide_settings)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ public class LambdaControlsHud extends DrawableHelper
|
||||
private final MinecraftClient client;
|
||||
private final LambdaControlsClient mod;
|
||||
private int width_bottom = 0;
|
||||
private int width_top = 0;
|
||||
private int width_top = 0;
|
||||
|
||||
public LambdaControlsHud(@NotNull MinecraftClient client, @NotNull LambdaControlsClient mod)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
private final Option reset_option;
|
||||
// Gameplay options
|
||||
private final Option front_block_placing_option;
|
||||
private final Option fly_drifting_option;
|
||||
// Controller options
|
||||
private final Option controller_option;
|
||||
private final Option second_controller_option;
|
||||
@@ -92,6 +93,8 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
// Gameplay options
|
||||
this.front_block_placing_option = new SpruceBooleanOption("lambdacontrols.menu.front_block_placing", game_options -> this.mod.config.has_front_block_placing(),
|
||||
(game_options, new_value) -> this.mod.config.set_front_block_placing(new_value), new TranslatableText("lambdacontrols.tooltip.front_block_placing"));
|
||||
this.fly_drifting_option = new SpruceBooleanOption("lambdacontrols.menu.fly_drifting", game_options -> this.mod.config.has_fly_drifting(),
|
||||
(game_options, new_value) -> this.mod.config.set_fly_drifting(new_value), new TranslatableText("lambdacontrols.tooltip.fly_drifting"));
|
||||
// Controller options
|
||||
this.controller_option = new CyclingOption("lambdacontrols.menu.controller", (game_options, amount) -> {
|
||||
int current_id = this.mod.config.get_controller().get_id();
|
||||
@@ -210,6 +213,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
// Gameplay options
|
||||
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.gameplay", true, null));
|
||||
this.list.addSingleOptionEntry(this.front_block_placing_option);
|
||||
this.list.addSingleOptionEntry(this.fly_drifting_option);
|
||||
// Controller options
|
||||
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.controller", true, null));
|
||||
this.list.addSingleOptionEntry(this.controller_option);
|
||||
|
||||
@@ -17,7 +17,6 @@ import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen;
|
||||
import net.minecraft.container.Slot;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
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.Redirect;
|
||||
|
||||
/**
|
||||
* Injects the anti fly drifting feature.
|
||||
*/
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
|
||||
{
|
||||
private boolean lambdacontrols_drifting_prevented = false;
|
||||
|
||||
// Can be mapped as `hasMovementInput` for example.
|
||||
@Shadow
|
||||
protected abstract boolean method_22120();
|
||||
|
||||
public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile)
|
||||
{
|
||||
super(world, profile);
|
||||
}
|
||||
|
||||
@Redirect(method = "move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;move(Lnet/minecraft/entity/MovementType;Lnet/minecraft/util/math/Vec3d;)V"))
|
||||
public void lambdacontrols_move(AbstractClientPlayerEntity player, MovementType type, Vec3d movement)
|
||||
{
|
||||
LambdaControlsClient mod = LambdaControlsClient.get();
|
||||
if (type == MovementType.SELF) {
|
||||
if (player.abilities.flying && !mod.config.has_fly_drifting()) {
|
||||
if (!this.method_22120()) {
|
||||
if (!this.lambdacontrols_drifting_prevented) {
|
||||
this.setVelocity(this.getVelocity().multiply(0, 1.0, 0));
|
||||
}
|
||||
this.lambdacontrols_drifting_prevented = true;
|
||||
} else
|
||||
this.lambdacontrols_drifting_prevented = false;
|
||||
}
|
||||
}
|
||||
super.move(type, movement);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import me.lambdaurora.lambdacontrols.ControlsMode;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.gui.TouchscreenOverlay;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
@@ -24,7 +23,6 @@ import net.minecraft.client.util.Window;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
@@ -32,7 +30,6 @@ import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
"lambdacontrols.menu.controller_type": "Controller Type",
|
||||
"lambdacontrols.menu.controls_mode": "Mode",
|
||||
"lambdacontrols.menu.dead_zone": "Dead Zone",
|
||||
"lambdacontrols.menu.fly_drifting": "Fly Drifting",
|
||||
"lambdacontrols.menu.front_block_placing": "Front Block Placing",
|
||||
"lambdacontrols.menu.hud_enable": "Enable HUD",
|
||||
"lambdacontrols.menu.hud_side": "HUD Side",
|
||||
@@ -102,7 +103,8 @@
|
||||
"lambdacontrols.tooltip.controller_type": "The controller type to display the correct buttons.",
|
||||
"lambdacontrols.tooltip.controls_mode": "The controls mode.",
|
||||
"lambdacontrols.tooltip.dead_zone": "The dead zone for the controller's analogue sticks.",
|
||||
"lambdacontrols.tooltip.front_block_placing": "Enable front block placing, §cmight be considered cheating on some servers§r.",
|
||||
"lambdacontrols.tooltip.fly_drifting": "While flying, enables drifting/inertia.",
|
||||
"lambdacontrols.tooltip.front_block_placing": "Enables front block placing, §cmight be considered cheating on some servers§r.",
|
||||
"lambdacontrols.tooltip.hud_enable": "Toggles the on-screen controller button indicator.",
|
||||
"lambdacontrols.tooltip.hud_side": "The position of the HUD.",
|
||||
"lambdacontrols.tooltip.mouse_speed": "The controller's emulated mouse speed.",
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
"lambdacontrols.menu.controller_type": "Type de manette",
|
||||
"lambdacontrols.menu.controls_mode": "Mode",
|
||||
"lambdacontrols.menu.dead_zone": "Zone morte",
|
||||
"lambdacontrols.menu.fly_drifting": "Inertie de vol",
|
||||
"lambdacontrols.menu.front_block_placing": "Placement avant de bloc",
|
||||
"lambdacontrols.menu.hud_enable": "Activer le HUD",
|
||||
"lambdacontrols.menu.hud_side": "Côté du HUD",
|
||||
@@ -91,6 +92,7 @@
|
||||
"lambdacontrols.menu.title": "LambdaControls - Paramètres",
|
||||
"lambdacontrols.menu.title.controller": "Options de manettes",
|
||||
"lambdacontrols.menu.title.controller_controls": "Contrôles de la manette",
|
||||
"lambdacontrols.menu.title.gameplay": "Options de Gameplay",
|
||||
"lambdacontrols.menu.title.general": "Options générales",
|
||||
"lambdacontrols.menu.title.hud": "Options du HUD",
|
||||
"lambdacontrols.menu.unbound": "Délier",
|
||||
@@ -101,6 +103,7 @@
|
||||
"lambdacontrols.tooltip.controller_type": "Le type de contrôle n'influe que sur les boutons affichés.",
|
||||
"lambdacontrols.tooltip.controls_mode": "Change le mode de contrôle.",
|
||||
"lambdacontrols.tooltip.dead_zone": "Zone morte des axes de la manette.",
|
||||
"lambdacontrols.tooltip.fly_drifting": "Pendant que le joueur vole, active le glissement.",
|
||||
"lambdacontrols.tooltip.front_block_placing": "Active le placement avant de blocs, §cpeut être considérer comme de la trice sur certains serveurs§r.",
|
||||
"lambdacontrols.tooltip.hud_enable": "Détermine si l'indicateur des buttons de la manette doit être affiché ou non.",
|
||||
"lambdacontrols.tooltip.hud_side": "Change la position du HUD.",
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
"lambdacontrols.menu.controller_type": "Type de manette",
|
||||
"lambdacontrols.menu.controls_mode": "Mode",
|
||||
"lambdacontrols.menu.dead_zone": "Zone morte",
|
||||
"lambdacontrols.menu.fly_drifting": "Inertie de vol",
|
||||
"lambdacontrols.menu.front_block_placing": "Placement avant de bloc",
|
||||
"lambdacontrols.menu.hud_enable": "Activer le HUD",
|
||||
"lambdacontrols.menu.hud_side": "Côté du HUD",
|
||||
@@ -91,6 +92,7 @@
|
||||
"lambdacontrols.menu.title": "LambdaControls - Paramètres",
|
||||
"lambdacontrols.menu.title.controller": "Options de manettes",
|
||||
"lambdacontrols.menu.title.controller_controls": "Contrôles de la manette",
|
||||
"lambdacontrols.menu.title.gameplay": "Options de Gameplay",
|
||||
"lambdacontrols.menu.title.general": "Options générales",
|
||||
"lambdacontrols.menu.title.hud": "Options du HUD",
|
||||
"lambdacontrols.menu.unbound": "Délier",
|
||||
@@ -101,6 +103,7 @@
|
||||
"lambdacontrols.tooltip.controller_type": "Le type de contrôle n'influe que sur les boutons affichés.",
|
||||
"lambdacontrols.tooltip.controls_mode": "Change le mode de contrôle.",
|
||||
"lambdacontrols.tooltip.dead_zone": "Zone morte des axes de la manette.",
|
||||
"lambdacontrols.tooltip.fly_drifting": "Pendant que le joueur vole, active le glissement.",
|
||||
"lambdacontrols.tooltip.front_block_placing": "Active le placement avant de blocs, §cpeut être considérer comme de la trice sur certains serveurs§r.",
|
||||
"lambdacontrols.tooltip.hud_enable": "Détermine si l'indicateur des buttons de la manette doit être affiché ou non.",
|
||||
"lambdacontrols.tooltip.hud_side": "Change la position du HUD.",
|
||||
|
||||
@@ -13,7 +13,10 @@ auto_switch_mode = false
|
||||
|
||||
# Gameplay settings
|
||||
[gameplay]
|
||||
# Enables front block placing like in Bedrock Edition.
|
||||
front_block_placing = false
|
||||
# Enables fly drifting.
|
||||
fly_drifting = false
|
||||
|
||||
# Controller settings
|
||||
[controller]
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"client": [
|
||||
"AbstractButtonWidgetAccessor",
|
||||
"AbstractContainerScreenMixin",
|
||||
"ClientPlayerEntityMixin",
|
||||
"ControlsOptionsScreenMixin",
|
||||
"CreativeInventoryScreenAccessor",
|
||||
"EntryListWidgetAccessor",
|
||||
|
||||
@@ -4,11 +4,11 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
minecraft_version=1.15.1
|
||||
yarn_mappings=1.15.1+build.3:v2
|
||||
yarn_mappings=1.15.1+build.35:v2
|
||||
loader_version=0.7.2+build.174
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.1.0-test5
|
||||
mod_version = 1.1.0-test6
|
||||
maven_group = me.lambdaurora
|
||||
archives_base_name = lambdacontrols
|
||||
|
||||
|
||||
Reference in New Issue
Block a user