mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-14 07:35:10 +01:00
✨ Add always more features.
This commit is contained in:
@@ -21,14 +21,14 @@ import java.util.Optional;
|
|||||||
* Represents a feature.
|
* Represents a feature.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.1.1
|
* @version 1.2.0
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class LambdaControlsFeature implements Nameable
|
public class LambdaControlsFeature implements Nameable
|
||||||
{
|
{
|
||||||
private static final List<LambdaControlsFeature> FEATURES = new ArrayList<>();
|
private static final List<LambdaControlsFeature> FEATURES = new ArrayList<>();
|
||||||
public static final LambdaControlsFeature FRONT_BLOCK_PLACING = new LambdaControlsFeature("front_block_placing", true, false);
|
public static final LambdaControlsFeature FRONT_BLOCK_PLACING = new LambdaControlsFeature("front_block_placing", true, false);
|
||||||
public static final LambdaControlsFeature FAST_BLOCK_INTERACTION = new LambdaControlsFeature("fast_block_interaction", true, true);
|
public static final LambdaControlsFeature FAST_BLOCK_PLACING = new LambdaControlsFeature("fast_block_placing", true, true);
|
||||||
|
|
||||||
private final String key;
|
private final String key;
|
||||||
private final boolean defaultAllowed;
|
private final boolean defaultAllowed;
|
||||||
@@ -156,6 +156,6 @@ public class LambdaControlsFeature implements Nameable
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
FEATURES.add(FRONT_BLOCK_PLACING);
|
FEATURES.add(FRONT_BLOCK_PLACING);
|
||||||
FEATURES.add(FAST_BLOCK_INTERACTION);
|
FEATURES.add(FAST_BLOCK_PLACING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import org.lwjgl.glfw.GLFW;
|
|||||||
* Represents the LambdaControls client mod.
|
* Represents the LambdaControls client mod.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.1.1
|
* @version 1.2.0
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class LambdaControlsClient extends LambdaControls implements ClientModInitializer
|
public class LambdaControlsClient extends LambdaControls implements ClientModInitializer
|
||||||
|
|||||||
@@ -40,10 +40,11 @@ public class LambdaControlsConfig
|
|||||||
private static final boolean DEFAULT_HUD_ENABLE = true;
|
private static final boolean DEFAULT_HUD_ENABLE = true;
|
||||||
private static final HudSide DEFAULT_HUD_SIDE = HudSide.LEFT;
|
private static final HudSide DEFAULT_HUD_SIDE = HudSide.LEFT;
|
||||||
// Gameplay
|
// Gameplay
|
||||||
private static final boolean DEFAULT_FRONT_BLOCK_PLACING = false;
|
|
||||||
private static final boolean DEFAULT_FAST_BLOCK_INTERACTION = true;
|
private static final boolean DEFAULT_FAST_BLOCK_INTERACTION = true;
|
||||||
private static final boolean DEFAULT_FLY_DRIFTING = false;
|
private static final boolean DEFAULT_FLY_DRIFTING = false;
|
||||||
private static final boolean DEFAULT_FLY_VERTICAL_DRIFTING = true;
|
private static final boolean DEFAULT_FLY_VERTICAL_DRIFTING = true;
|
||||||
|
private static final boolean DEFAULT_FRONT_BLOCK_PLACING = false;
|
||||||
|
private static final boolean DEFAULT_FRONT_BLOCK_OUTLINE = true;
|
||||||
// Controller
|
// Controller
|
||||||
private static final ControllerType DEFAULT_CONTROLLER_TYPE = ControllerType.DEFAULT;
|
private static final ControllerType DEFAULT_CONTROLLER_TYPE = ControllerType.DEFAULT;
|
||||||
private static final double DEFAULT_DEAD_ZONE = 0.25;
|
private static final double DEFAULT_DEAD_ZONE = 0.25;
|
||||||
@@ -57,14 +58,17 @@ public class LambdaControlsConfig
|
|||||||
private final LambdaControlsClient mod;
|
private final LambdaControlsClient mod;
|
||||||
private ControlsMode controlsMode;
|
private ControlsMode controlsMode;
|
||||||
private ControllerType controllerType;
|
private ControllerType controllerType;
|
||||||
// HUD settings.
|
// Gameplay.
|
||||||
private boolean hudEnable;
|
private boolean shouldRenderFrontBlockOutline;
|
||||||
private HudSide hudSide;
|
private int[] frontBlockOutlineColor;
|
||||||
// Controller settings
|
// Controller settings
|
||||||
private double deadZone;
|
private double deadZone;
|
||||||
private double rotationSpeed;
|
private double rotationSpeed;
|
||||||
private double mouseSpeed;
|
private double mouseSpeed;
|
||||||
private boolean unfocusedInput;
|
private boolean unfocusedInput;
|
||||||
|
// HUD settings.
|
||||||
|
private boolean hudEnable;
|
||||||
|
private HudSide hudSide;
|
||||||
|
|
||||||
public LambdaControlsConfig(@NotNull LambdaControlsClient mod)
|
public LambdaControlsConfig(@NotNull LambdaControlsClient mod)
|
||||||
{
|
{
|
||||||
@@ -84,8 +88,10 @@ public class LambdaControlsConfig
|
|||||||
this.hudEnable = this.config.getOrElse("hud.enable", DEFAULT_HUD_ENABLE);
|
this.hudEnable = this.config.getOrElse("hud.enable", DEFAULT_HUD_ENABLE);
|
||||||
this.hudSide = HudSide.byId(this.config.getOrElse("hud.side", DEFAULT_HUD_SIDE.getName())).orElse(DEFAULT_HUD_SIDE);
|
this.hudSide = HudSide.byId(this.config.getOrElse("hud.side", DEFAULT_HUD_SIDE.getName())).orElse(DEFAULT_HUD_SIDE);
|
||||||
// Gameplay
|
// Gameplay
|
||||||
LambdaControlsFeature.FRONT_BLOCK_PLACING.setEnabled(this.config.getOrElse("gameplay.front_block_placing", DEFAULT_FRONT_BLOCK_PLACING));
|
LambdaControlsFeature.FAST_BLOCK_PLACING.setEnabled(this.config.getOrElse("gameplay.fast_block_placing", DEFAULT_FAST_BLOCK_INTERACTION));
|
||||||
LambdaControlsFeature.FAST_BLOCK_INTERACTION.setEnabled(this.config.getOrElse("gameplay.fast_block_interaction", DEFAULT_FAST_BLOCK_INTERACTION));
|
LambdaControlsFeature.FRONT_BLOCK_PLACING.setEnabled(this.config.getOrElse("gameplay.front_block_placing.enabled", DEFAULT_FRONT_BLOCK_PLACING));
|
||||||
|
this.shouldRenderFrontBlockOutline = this.config.getOrElse("gameplay.front_block_placing.outline", DEFAULT_FRONT_BLOCK_OUTLINE);
|
||||||
|
this.frontBlockOutlineColor = this.config.getOptional("gameplay.front_block_placing.outline_color").map(hex -> parseColor((String) hex)).orElse(new int[]{255, 255, 255, 102});
|
||||||
// Controller settings.
|
// Controller settings.
|
||||||
this.controllerType = ControllerType.byId(this.config.getOrElse("controller.type", DEFAULT_CONTROLLER_TYPE.getName())).orElse(DEFAULT_CONTROLLER_TYPE);
|
this.controllerType = ControllerType.byId(this.config.getOrElse("controller.type", DEFAULT_CONTROLLER_TYPE.getName())).orElse(DEFAULT_CONTROLLER_TYPE);
|
||||||
this.deadZone = this.config.getOrElse("controller.dead_zone", DEFAULT_DEAD_ZONE);
|
this.deadZone = this.config.getOrElse("controller.dead_zone", DEFAULT_DEAD_ZONE);
|
||||||
@@ -119,6 +125,12 @@ public class LambdaControlsConfig
|
|||||||
this.config.set(path, String.valueOf(raw));
|
this.config.set(path, String.valueOf(raw));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// This shouldn't happen if the configuration is new.
|
||||||
|
if (!this.config.contains("gameplay.front_block_placing.enabled") && this.config.contains("gameplay.front_block_placing")) {
|
||||||
|
this.config.remove("gameplay.front_block_placing");
|
||||||
|
this.config.set("gameplay.front_block_placing.enabled", DEFAULT_FRONT_BLOCK_PLACING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +146,7 @@ public class LambdaControlsConfig
|
|||||||
this.setHudSide(DEFAULT_HUD_SIDE);
|
this.setHudSide(DEFAULT_HUD_SIDE);
|
||||||
// Gameplay
|
// Gameplay
|
||||||
this.setFrontBlockPlacing(DEFAULT_FRONT_BLOCK_PLACING);
|
this.setFrontBlockPlacing(DEFAULT_FRONT_BLOCK_PLACING);
|
||||||
this.setFastBlockInteraction(DEFAULT_FAST_BLOCK_INTERACTION);
|
this.setFastBlockPlacing(DEFAULT_FAST_BLOCK_INTERACTION);
|
||||||
this.setFlyDrifting(DEFAULT_FLY_DRIFTING);
|
this.setFlyDrifting(DEFAULT_FLY_DRIFTING);
|
||||||
this.setFlyVerticalDrifting(DEFAULT_FLY_VERTICAL_DRIFTING);
|
this.setFlyVerticalDrifting(DEFAULT_FLY_VERTICAL_DRIFTING);
|
||||||
// Controller
|
// Controller
|
||||||
@@ -240,45 +252,24 @@ public class LambdaControlsConfig
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether fast block interaction is enabled or not.
|
* Gets whether fast block placing is enabled or not.
|
||||||
*
|
*
|
||||||
* @return True if fast block interaction is enabled, else false.
|
* @return True if fast block placing is enabled, else false.
|
||||||
*/
|
*/
|
||||||
public boolean hasFastBlockInteraction()
|
public boolean hasFastBlockPlacing()
|
||||||
{
|
{
|
||||||
return LambdaControlsFeature.FAST_BLOCK_INTERACTION.isEnabled();
|
return LambdaControlsFeature.FAST_BLOCK_PLACING.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether fast block interaction is enabled or not.
|
* Sets whether fast block placing is enabled or not.
|
||||||
*
|
*
|
||||||
* @param enable True if fast block interaction is enabled, else false.
|
* @param enable True if fast block placing is enabled, else false.
|
||||||
*/
|
*/
|
||||||
public void setFastBlockInteraction(boolean enable)
|
public void setFastBlockPlacing(boolean enable)
|
||||||
{
|
{
|
||||||
LambdaControlsFeature.FAST_BLOCK_INTERACTION.setEnabled(enable);
|
LambdaControlsFeature.FAST_BLOCK_PLACING.setEnabled(enable);
|
||||||
this.config.set("gameplay.fast_block_interaction", enable);
|
this.config.set("gameplay.fast_block_placing", enable);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether front block placing is enabled or not.
|
|
||||||
*
|
|
||||||
* @return True if front block placing is enabled, else false.
|
|
||||||
*/
|
|
||||||
public boolean hasFrontBlockPlacing()
|
|
||||||
{
|
|
||||||
return LambdaControlsFeature.FRONT_BLOCK_PLACING.isEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether front block placing is enabled or not.
|
|
||||||
*
|
|
||||||
* @param enable True if front block placing is enabled, else false.
|
|
||||||
*/
|
|
||||||
public void setFrontBlockPlacing(boolean enable)
|
|
||||||
{
|
|
||||||
LambdaControlsFeature.FRONT_BLOCK_PLACING.setEnabled(enable);
|
|
||||||
this.config.set("gameplay.front_block_placing", enable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -321,6 +312,59 @@ public class LambdaControlsConfig
|
|||||||
this.config.set("gameplay.fly.vertical_drifting", flyDrifting);
|
this.config.set("gameplay.fly.vertical_drifting", flyDrifting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether front block placing is enabled or not.
|
||||||
|
*
|
||||||
|
* @return True if front block placing is enabled, else false.
|
||||||
|
*/
|
||||||
|
public boolean hasFrontBlockPlacing()
|
||||||
|
{
|
||||||
|
return LambdaControlsFeature.FRONT_BLOCK_PLACING.isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether front block placing is enabled or not.
|
||||||
|
*
|
||||||
|
* @param enable True if front block placing is enabled, else false.
|
||||||
|
*/
|
||||||
|
public void setFrontBlockPlacing(boolean enable)
|
||||||
|
{
|
||||||
|
LambdaControlsFeature.FRONT_BLOCK_PLACING.setEnabled(enable);
|
||||||
|
this.config.set("gameplay.front_block_placing.enabled", enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether front block placing outline is enabled or not.
|
||||||
|
*
|
||||||
|
* @return True if front block placing outline is enabled, else false.
|
||||||
|
*/
|
||||||
|
public boolean shouldRenderFrontBlockOutline()
|
||||||
|
{
|
||||||
|
return this.shouldRenderFrontBlockOutline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether front block placing outline is enabled or not.
|
||||||
|
*
|
||||||
|
* @param render True if front block placing outline is enabled, else false.
|
||||||
|
*/
|
||||||
|
public void setRenderFrontBlockOutline(boolean render)
|
||||||
|
{
|
||||||
|
this.config.set("gameplay.front_block_placing.outline", this.shouldRenderFrontBlockOutline = render);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the front block placing outline color as an integer array.
|
||||||
|
* <p>
|
||||||
|
* The integer array has 4 elements: red, green, blue and alpha.
|
||||||
|
*
|
||||||
|
* @return The color as a RGBA integer array.
|
||||||
|
*/
|
||||||
|
public int[] getFrontBlockOutlineColor()
|
||||||
|
{
|
||||||
|
return this.frontBlockOutlineColor;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Controller settings
|
Controller settings
|
||||||
*/
|
*/
|
||||||
@@ -636,4 +680,32 @@ public class LambdaControlsConfig
|
|||||||
{
|
{
|
||||||
return axis == GLFW_GAMEPAD_AXIS_LEFT_Y || axis == GLFW_GAMEPAD_AXIS_LEFT_X;
|
return axis == GLFW_GAMEPAD_AXIS_LEFT_Y || axis == GLFW_GAMEPAD_AXIS_LEFT_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a color from a hexadecimal color string.
|
||||||
|
*
|
||||||
|
* @param hex The hexadecimal color.
|
||||||
|
* @return The color instance, null if invalid.
|
||||||
|
*/
|
||||||
|
private static int[] parseColor(String hex)
|
||||||
|
{
|
||||||
|
hex = hex.replace("#", "");
|
||||||
|
switch (hex.length()) {
|
||||||
|
case 6:
|
||||||
|
return new int[]{
|
||||||
|
Integer.valueOf(hex.substring(0, 2), 16),
|
||||||
|
Integer.valueOf(hex.substring(2, 4), 16),
|
||||||
|
Integer.valueOf(hex.substring(4, 6), 16),
|
||||||
|
255
|
||||||
|
};
|
||||||
|
case 8:
|
||||||
|
return new int[]{
|
||||||
|
Integer.valueOf(hex.substring(0, 2), 16),
|
||||||
|
Integer.valueOf(hex.substring(2, 4), 16),
|
||||||
|
Integer.valueOf(hex.substring(4, 6), 16),
|
||||||
|
Integer.valueOf(hex.substring(6, 8), 16)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsSettingsScreen;
|
|||||||
* Represents the API implementation of ModMenu for LambdaControls.
|
* Represents the API implementation of ModMenu for LambdaControls.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.1.1
|
* @version 1.2.0
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class LambdaControlsModMenu implements ModMenuApi
|
public class LambdaControlsModMenu implements ModMenuApi
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ import static org.lwjgl.glfw.GLFW.*;
|
|||||||
* Represents the LambdaControls' input handler.
|
* Represents the LambdaControls' input handler.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.1.1
|
* @version 1.2.0
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public class LambdaInput
|
public class LambdaInput
|
||||||
@@ -688,6 +688,9 @@ public class LambdaInput
|
|||||||
|
|
||||||
Direction direction = client.player.getHorizontalFacing();
|
Direction direction = client.player.getHorizontalFacing();
|
||||||
|
|
||||||
|
BlockState state = client.world.getBlockState(blockPos);
|
||||||
|
if (!state.isAir())
|
||||||
|
return null;
|
||||||
BlockState adjacentBlockState = client.world.getBlockState(blockPos.offset(direction.getOpposite()));
|
BlockState adjacentBlockState = client.world.getBlockState(blockPos.offset(direction.getOpposite()));
|
||||||
if (adjacentBlockState.isAir() || adjacentBlockState.getBlock() instanceof FluidBlock || (vector.getX() == 0 && vector.getZ() == 0)) {
|
if (adjacentBlockState.isAir() || adjacentBlockState.getBlock() instanceof FluidBlock || (vector.getX() == 0 && vector.getZ() == 0)) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
|||||||
* Represents some input handlers.
|
* Represents some input handlers.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.1.1
|
* @version 1.2.0
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public class InputHandlers
|
public class InputHandlers
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
* Represents the LambdaControls HUD.
|
* Represents the LambdaControls HUD.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.1.1
|
* @version 1.2.0
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public class LambdaControlsHud extends Hud
|
public class LambdaControlsHud extends Hud
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import org.lwjgl.glfw.GLFW;
|
|||||||
* Represents the LambdaControls renderer.
|
* Represents the LambdaControls renderer.
|
||||||
*
|
*
|
||||||
* @author LambdAurora
|
* @author LambdAurora
|
||||||
* @version 1.1.1
|
* @version 1.2.0
|
||||||
* @since 1.1.1
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public class LambdaControlsRenderer
|
public class LambdaControlsRenderer
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
private final Option resetOption;
|
private final Option resetOption;
|
||||||
// Gameplay options
|
// Gameplay options
|
||||||
private final Option autoJumpOption;
|
private final Option autoJumpOption;
|
||||||
|
private final Option fastBlockPlacingOption;
|
||||||
private final Option frontBlockPlacingOption;
|
private final Option frontBlockPlacingOption;
|
||||||
private final Option flyDriftingOption;
|
private final Option flyDriftingOption;
|
||||||
private final Option flyVerticalDriftingOption;
|
private final Option flyVerticalDriftingOption;
|
||||||
@@ -94,6 +95,8 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
});
|
});
|
||||||
// Gameplay options
|
// Gameplay options
|
||||||
this.autoJumpOption = SpruceBooleanOption.fromVanilla("options.autoJump", Option.AUTO_JUMP, null, true);
|
this.autoJumpOption = SpruceBooleanOption.fromVanilla("options.autoJump", Option.AUTO_JUMP, null, true);
|
||||||
|
this.fastBlockPlacingOption = new SpruceBooleanOption("lambdacontrols.menu.fast_block_placing", this.mod.config::hasFastBlockPlacing,
|
||||||
|
this.mod.config::setFastBlockPlacing, new TranslatableText("lambdacontrols.tooltip.fast_block_placing"), true);
|
||||||
this.frontBlockPlacingOption = new SpruceBooleanOption("lambdacontrols.menu.front_block_placing", this.mod.config::hasFrontBlockPlacing,
|
this.frontBlockPlacingOption = new SpruceBooleanOption("lambdacontrols.menu.front_block_placing", this.mod.config::hasFrontBlockPlacing,
|
||||||
this.mod.config::setFrontBlockPlacing, new TranslatableText("lambdacontrols.tooltip.front_block_placing"), true);
|
this.mod.config::setFrontBlockPlacing, new TranslatableText("lambdacontrols.tooltip.front_block_placing"), true);
|
||||||
this.flyDriftingOption = new SpruceBooleanOption("lambdacontrols.menu.fly_drifting", this.mod.config::hasFlyDrifting,
|
this.flyDriftingOption = new SpruceBooleanOption("lambdacontrols.menu.fly_drifting", this.mod.config::hasFlyDrifting,
|
||||||
@@ -224,7 +227,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
|||||||
// Gameplay options
|
// Gameplay options
|
||||||
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.gameplay", true, null));
|
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.gameplay", true, null));
|
||||||
this.list.addSingleOptionEntry(this.autoJumpOption);
|
this.list.addSingleOptionEntry(this.autoJumpOption);
|
||||||
this.list.addSingleOptionEntry(this.frontBlockPlacingOption);
|
this.list.addOptionEntry(this.fastBlockPlacingOption, this.frontBlockPlacingOption);
|
||||||
this.list.addSingleOptionEntry(this.flyDriftingOption);
|
this.list.addSingleOptionEntry(this.flyDriftingOption);
|
||||||
this.list.addSingleOptionEntry(this.flyVerticalDriftingOption);
|
this.list.addSingleOptionEntry(this.flyVerticalDriftingOption);
|
||||||
// Controller options
|
// Controller options
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ package me.lambdaurora.lambdacontrols.client.mixin;
|
|||||||
import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
import me.lambdaurora.lambdacontrols.LambdaControlsFeature;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.util.FrontBlockPlaceResultAccessor;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
@@ -36,7 +37,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
@Mixin(MinecraftClient.class)
|
@Mixin(MinecraftClient.class)
|
||||||
public abstract class MinecraftClientMixin
|
public abstract class MinecraftClientMixin implements FrontBlockPlaceResultAccessor
|
||||||
{
|
{
|
||||||
@Shadow
|
@Shadow
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -61,10 +62,18 @@ public abstract class MinecraftClientMixin
|
|||||||
@Shadow
|
@Shadow
|
||||||
private int itemUseCooldown;
|
private int itemUseCooldown;
|
||||||
|
|
||||||
|
private BlockHitResult lambdacontrols_frontBlockPlaceResult = null;
|
||||||
|
|
||||||
private BlockPos lambdacontrols_lastTargetPos;
|
private BlockPos lambdacontrols_lastTargetPos;
|
||||||
private Direction lambdacontrols_lockedSide;
|
private Direction lambdacontrols_lockedSide;
|
||||||
private int lambdacontrols_lockedSideCooldown;
|
private int lambdacontrols_lockedSideCooldown;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable BlockHitResult lambdacontrols_getFrontBlockPlaceResult()
|
||||||
|
{
|
||||||
|
return this.lambdacontrols_frontBlockPlaceResult;
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
private void onInit(CallbackInfo ci)
|
private void onInit(CallbackInfo ci)
|
||||||
{
|
{
|
||||||
@@ -74,9 +83,11 @@ public abstract class MinecraftClientMixin
|
|||||||
@Inject(method = "tick", at = @At("HEAD"))
|
@Inject(method = "tick", at = @At("HEAD"))
|
||||||
private void onStartTick(CallbackInfo ci)
|
private void onStartTick(CallbackInfo ci)
|
||||||
{
|
{
|
||||||
if (!LambdaControlsFeature.FAST_BLOCK_INTERACTION.isAvailable())
|
if (this.player == null)
|
||||||
|
return;
|
||||||
|
this.lambdacontrols_frontBlockPlaceResult = LambdaInput.tryFrontPlace(((MinecraftClient) (Object) this));
|
||||||
|
if (!LambdaControlsFeature.FAST_BLOCK_PLACING.isAvailable())
|
||||||
return;
|
return;
|
||||||
if (this.player != null) {
|
|
||||||
int cooldown = this.itemUseCooldown;
|
int cooldown = this.itemUseCooldown;
|
||||||
BlockHitResult hitResult;
|
BlockHitResult hitResult;
|
||||||
if (this.crosshairTarget != null && this.crosshairTarget.getType() == HitResult.Type.BLOCK && this.player.abilities.flying) {
|
if (this.crosshairTarget != null && this.crosshairTarget.getType() == HitResult.Type.BLOCK && this.player.abilities.flying) {
|
||||||
@@ -97,14 +108,13 @@ public abstract class MinecraftClientMixin
|
|||||||
|
|
||||||
this.lambdacontrols_lastTargetPos = targetPos.toImmutable();
|
this.lambdacontrols_lastTargetPos = targetPos.toImmutable();
|
||||||
} else if (this.player.isSprinting()) {
|
} else if (this.player.isSprinting()) {
|
||||||
hitResult = LambdaInput.tryFrontPlace(((MinecraftClient) (Object) this));
|
hitResult = this.lambdacontrols_frontBlockPlaceResult;
|
||||||
if (hitResult != null) {
|
if (hitResult != null) {
|
||||||
if (cooldown > 0)
|
if (cooldown > 0)
|
||||||
this.itemUseCooldown = 0;
|
this.itemUseCooldown = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "render", at = @At("HEAD"))
|
@Inject(method = "render", at = @At("HEAD"))
|
||||||
private void onRender(boolean fullRender, CallbackInfo ci)
|
private void onRender(boolean fullRender, CallbackInfo ci)
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
|
|
||||||
package me.lambdaurora.lambdacontrols.client.mixin;
|
package me.lambdaurora.lambdacontrols.client.mixin;
|
||||||
|
|
||||||
|
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||||
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
import me.lambdaurora.lambdacontrols.client.LambdaInput;
|
||||||
|
import me.lambdaurora.lambdacontrols.client.util.FrontBlockPlaceResultAccessor;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
@@ -72,9 +74,9 @@ public abstract class WorldRendererMixin
|
|||||||
Profiler profiler, Vec3d cameraPos, double x, double y, double z, Matrix4f modelMatrix, boolean bl, Frustum frustum2, boolean bl3,
|
Profiler profiler, Vec3d cameraPos, double x, double y, double z, Matrix4f modelMatrix, boolean bl, Frustum frustum2, boolean bl3,
|
||||||
VertexConsumerProvider.Immediate immediate)
|
VertexConsumerProvider.Immediate immediate)
|
||||||
{
|
{
|
||||||
if (this.client.crosshairTarget == null || this.client.crosshairTarget.getType() != HitResult.Type.MISS)
|
if (this.client.crosshairTarget == null || this.client.crosshairTarget.getType() != HitResult.Type.MISS || !LambdaControlsClient.get().config.shouldRenderFrontBlockOutline())
|
||||||
return;
|
return;
|
||||||
BlockHitResult result = LambdaInput.tryFrontPlace(client);
|
BlockHitResult result = ((FrontBlockPlaceResultAccessor) client).lambdacontrols_getFrontBlockPlaceResult();
|
||||||
if (result == null)
|
if (result == null)
|
||||||
return;
|
return;
|
||||||
BlockPos blockPos = result.getBlockPos();
|
BlockPos blockPos = result.getBlockPos();
|
||||||
@@ -90,7 +92,8 @@ public abstract class WorldRendererMixin
|
|||||||
if (placementState == null)
|
if (placementState == null)
|
||||||
return;
|
return;
|
||||||
VoxelShape outlineShape = placementState.getOutlineShape(this.client.world, blockPos, EntityContext.of(camera.getFocusedEntity()));
|
VoxelShape outlineShape = placementState.getOutlineShape(this.client.world, blockPos, EntityContext.of(camera.getFocusedEntity()));
|
||||||
drawShapeOutline(matrices, vertexConsumer, outlineShape, (double) blockPos.getX() - x, (double) blockPos.getY() - y, (double) blockPos.getZ() - z, 1.0F, 1.0F, 1.0F, 0.4F);
|
int[] color = LambdaControlsClient.get().config.getFrontBlockOutlineColor();
|
||||||
|
drawShapeOutline(matrices, vertexConsumer, outlineShape, (double) blockPos.getX() - x, (double) blockPos.getY() - y, (double) blockPos.getZ() - z, color[0] / 255.f, color[1] / 255.f, color[2] / 255.f, color[3] / 255.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.util;
|
||||||
|
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an accessor of the BlockHitResult for the front block placing feature.
|
||||||
|
* <p>
|
||||||
|
* It is implemented by {@link net.minecraft.client.MinecraftClient}.
|
||||||
|
*
|
||||||
|
* @author LambdAurora
|
||||||
|
* @version 1.2.0
|
||||||
|
* @since 1.2.0
|
||||||
|
*/
|
||||||
|
public interface FrontBlockPlaceResultAccessor
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the {@link BlockHitResult} if a block can be placed with the front block placing feature.
|
||||||
|
*
|
||||||
|
* @return If possible a {@link BlockHitResult}, else a null value.
|
||||||
|
*/
|
||||||
|
@Nullable BlockHitResult lambdacontrols_getFrontBlockPlaceResult();
|
||||||
|
}
|
||||||
@@ -80,6 +80,7 @@
|
|||||||
"lambdacontrols.menu.controller_type": "Controller Type",
|
"lambdacontrols.menu.controller_type": "Controller Type",
|
||||||
"lambdacontrols.menu.controls_mode": "Mode",
|
"lambdacontrols.menu.controls_mode": "Mode",
|
||||||
"lambdacontrols.menu.dead_zone": "Dead Zone",
|
"lambdacontrols.menu.dead_zone": "Dead Zone",
|
||||||
|
"lambdacontrols.menu.fast_block_placing": "Fast Block Placing",
|
||||||
"lambdacontrols.menu.fly_drifting": "Fly Drifting",
|
"lambdacontrols.menu.fly_drifting": "Fly Drifting",
|
||||||
"lambdacontrols.menu.fly_drifting_vertical": "Vertical Fly Drifting",
|
"lambdacontrols.menu.fly_drifting_vertical": "Vertical Fly Drifting",
|
||||||
"lambdacontrols.menu.front_block_placing": "Front Block Placing",
|
"lambdacontrols.menu.front_block_placing": "Front Block Placing",
|
||||||
@@ -106,6 +107,7 @@
|
|||||||
"lambdacontrols.tooltip.controller_type": "The controller type to display the correct buttons.",
|
"lambdacontrols.tooltip.controller_type": "The controller type to display the correct buttons.",
|
||||||
"lambdacontrols.tooltip.controls_mode": "The controls mode.",
|
"lambdacontrols.tooltip.controls_mode": "The controls mode.",
|
||||||
"lambdacontrols.tooltip.dead_zone": "The dead zone for the controller's analogue sticks.",
|
"lambdacontrols.tooltip.dead_zone": "The dead zone for the controller's analogue sticks.",
|
||||||
|
"lambdacontrols.tooltip.fast_block_placing": "While flying in creative mode, enables fast block placing depending on your speed. §cOn some servers this might be considered as cheating.",
|
||||||
"lambdacontrols.tooltip.fly_drifting": "While flying, enables Vanilla drifting/inertia.",
|
"lambdacontrols.tooltip.fly_drifting": "While flying, enables Vanilla drifting/inertia.",
|
||||||
"lambdacontrols.tooltip.fly_drifting_vertical": "While flying, enables Vanilla vertical drifting/intertia.",
|
"lambdacontrols.tooltip.fly_drifting_vertical": "While flying, enables Vanilla vertical drifting/intertia.",
|
||||||
"lambdacontrols.tooltip.front_block_placing": "Enables front block placing, §cmight be considered cheating on some servers§r.",
|
"lambdacontrols.tooltip.front_block_placing": "Enables front block placing, §cmight be considered cheating on some servers§r.",
|
||||||
|
|||||||
@@ -13,16 +13,21 @@ auto_switch_mode = false
|
|||||||
|
|
||||||
# Gameplay settings
|
# Gameplay settings
|
||||||
[gameplay]
|
[gameplay]
|
||||||
# Enables fast block interaction like in Bedrock Edition.
|
# Enables fast block placing like in Bedrock Edition.
|
||||||
fast_block_interaction = true
|
fast_block_placing = true
|
||||||
# Enables front block placing like in Bedrock Edition.
|
|
||||||
front_block_placing = false
|
|
||||||
# Fly behaviors
|
# Fly behaviors
|
||||||
[gameplay.fly]
|
[gameplay.fly]
|
||||||
# Enables fly drifting.
|
# Enables fly drifting.
|
||||||
drifting = false
|
drifting = false
|
||||||
# Enables vertical fly drifting.
|
# Enables vertical fly drifting.
|
||||||
vertical_drifting = true
|
vertical_drifting = true
|
||||||
|
[gameplay.front_block_placing]
|
||||||
|
# Enables front block placing like in Bedrock Edition.
|
||||||
|
enabled = false
|
||||||
|
# Enables front block placing outline.
|
||||||
|
outline = true
|
||||||
|
# The color in a hexadecimal format of the outline.
|
||||||
|
outline_color = "#ffffff66"
|
||||||
|
|
||||||
# Controller settings
|
# Controller settings
|
||||||
[controller]
|
[controller]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
loader_version=0.7.6+build.180
|
loader_version=0.7.6+build.180
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.1.1
|
mod_version = 1.2.0
|
||||||
maven_group = me.lambdaurora
|
maven_group = me.lambdaurora
|
||||||
archives_base_name = lambdacontrols
|
archives_base_name = lambdacontrols
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user