mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 07:15:10 +01:00
⚡ Improve HUD, add autojump option.
This commit is contained in:
@@ -38,7 +38,7 @@ import org.lwjgl.glfw.GLFW;
|
||||
* Represents the LambdaControls client mod.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.1.0
|
||||
* @version 1.1.1
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class LambdaControlsClient extends LambdaControls implements ClientModInitializer
|
||||
|
||||
@@ -671,7 +671,7 @@ public class LambdaInput
|
||||
|
||||
public static @Nullable BlockHitResult tryFrontPlace(@NotNull MinecraftClient client)
|
||||
{
|
||||
if (client.player != null && client.crosshairTarget != null && client.crosshairTarget.getType() == HitResult.Type.MISS && client.player.onGround) {
|
||||
if (client.player != null && client.crosshairTarget != null && client.crosshairTarget.getType() == HitResult.Type.MISS && client.player.onGround && client.player.pitch > 35.0F) {
|
||||
if (client.player.isRiding())
|
||||
return null;
|
||||
BlockPos playerPos = client.player.getBlockPos().down();
|
||||
|
||||
@@ -19,6 +19,7 @@ import me.lambdaurora.spruceui.hud.Hud;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.Matrix4f;
|
||||
import net.minecraft.client.util.math.Rotation3;
|
||||
import net.minecraft.item.BlockItem;
|
||||
@@ -27,24 +28,32 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents the LambdaControls HUD.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.1.0
|
||||
* @version 1.1.1
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LambdaControlsHud extends Hud
|
||||
{
|
||||
private final LambdaControlsClient mod;
|
||||
private MinecraftClient client;
|
||||
private int widthBottom = 0;
|
||||
private int widthTop = 0;
|
||||
private int useWidth = 0;
|
||||
private int attackWidth = 0;
|
||||
private int attackWidth = 0;
|
||||
private int attackButtonWidth = 0;
|
||||
private int dropItemWidth = 0;
|
||||
private int dropItemButtonWidth = 0;
|
||||
private int inventoryWidth = 0;
|
||||
private int inventoryButtonWidth = 0;
|
||||
private int swapHandsWidth = 0;
|
||||
private int swapHandsButtonWidth = 0;
|
||||
private int useWidth = 0;
|
||||
private int useButtonWidth = 0;
|
||||
private BlockHitResult placeHitResult;
|
||||
private String placeAction = "";
|
||||
private String attackAction = "";
|
||||
private String placeAction = "";
|
||||
|
||||
public LambdaControlsHud(@NotNull LambdaControlsClient mod)
|
||||
{
|
||||
@@ -57,6 +66,14 @@ public class LambdaControlsHud extends Hud
|
||||
{
|
||||
super.init(client, screenWidth, screenHeight);
|
||||
this.client = client;
|
||||
this.inventoryWidth = this.width(ButtonBinding.INVENTORY);
|
||||
this.inventoryButtonWidth = LambdaControlsRenderer.getBindingIconWidth(ButtonBinding.INVENTORY);
|
||||
this.swapHandsWidth = this.width(ButtonBinding.SWAP_HANDS);
|
||||
this.swapHandsButtonWidth = LambdaControlsRenderer.getBindingIconWidth(ButtonBinding.SWAP_HANDS);
|
||||
this.dropItemWidth = this.width(ButtonBinding.DROP_ITEM);
|
||||
this.dropItemButtonWidth = LambdaControlsRenderer.getBindingIconWidth(ButtonBinding.DROP_ITEM);
|
||||
this.attackButtonWidth = LambdaControlsRenderer.getBindingIconWidth(ButtonBinding.ATTACK);
|
||||
this.useButtonWidth = LambdaControlsRenderer.getBindingIconWidth(ButtonBinding.USE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,35 +82,92 @@ public class LambdaControlsHud extends Hud
|
||||
public void render(float tickDelta)
|
||||
{
|
||||
if (this.mod.config.getControlsMode() == ControlsMode.CONTROLLER && this.client.currentScreen == null) {
|
||||
int y = bottom(2);
|
||||
this.renderFirstIcons(this.mod.config.getHudSide() == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
this.renderSecondIcons(this.mod.config.getHudSide() == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y);
|
||||
VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
|
||||
Matrix4f matrix4f = Rotation3.identity().getMatrix();
|
||||
this.renderFirstSection(this.mod.config.getHudSide() == HudSide.LEFT ? 10 : client.getWindow().getScaledWidth() - 10 - this.widthBottom, immediate, matrix4f);
|
||||
this.renderSecondSection(this.mod.config.getHudSide() == HudSide.RIGHT ? 10 : client.getWindow().getScaledWidth() - 10, immediate, matrix4f);
|
||||
this.renderFirstSection(this.mod.config.getHudSide() == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y, immediate, matrix4f);
|
||||
this.renderSecondSection(this.mod.config.getHudSide() == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y, immediate, matrix4f);
|
||||
immediate.draw();
|
||||
}
|
||||
}
|
||||
|
||||
public void renderFirstSection(int x, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
public void renderFirstIcons(int x, int y)
|
||||
{
|
||||
int y = bottom(10);
|
||||
x += (this.widthBottom = this.drawButtonTip(x, y, ButtonBinding.INVENTORY, true, immediate, matrix4f) + 10);
|
||||
this.widthBottom += this.drawButtonTip(x, y, ButtonBinding.SWAP_HANDS, true, immediate, matrix4f);
|
||||
this.widthTop = this.drawButtonTip(x, (y - 24), ButtonBinding.DROP_ITEM, !this.client.player.getMainHandStack().isEmpty(), immediate, matrix4f) + 10;
|
||||
}
|
||||
|
||||
public void renderSecondSection(int x, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
{
|
||||
int y = bottom(10);
|
||||
if (this.placeHitResult != null) {
|
||||
int firstX = this.mod.config.getHudSide() == HudSide.RIGHT ? x : x - this.useWidth;
|
||||
this.useWidth = this.drawButtonTip(firstX, y, ButtonBinding.USE.getButton(), this.placeAction, true, immediate, matrix4f);
|
||||
int offset = 2 + this.inventoryWidth + this.inventoryButtonWidth + 4;
|
||||
int currentX = this.mod.config.getHudSide() == HudSide.LEFT ? x : x - this.inventoryButtonWidth;
|
||||
this.drawButton(currentX, y, ButtonBinding.INVENTORY, true);
|
||||
this.drawButton(currentX += (this.mod.config.getHudSide() == HudSide.LEFT ? offset : -offset), y, ButtonBinding.SWAP_HANDS, true);
|
||||
offset = 2 + this.swapHandsWidth + this.dropItemButtonWidth + 4;
|
||||
if (this.client.options.showSubtitles && this.mod.config.getHudSide() == HudSide.RIGHT) {
|
||||
currentX += -offset;
|
||||
} else {
|
||||
currentX = this.mod.config.getHudSide() == HudSide.LEFT ? x : x - this.dropItemButtonWidth;
|
||||
y -= 24;
|
||||
}
|
||||
this.drawButton(currentX, y, ButtonBinding.DROP_ITEM, !this.client.player.getMainHandStack().isEmpty());
|
||||
}
|
||||
|
||||
int secondX = this.mod.config.getHudSide() == HudSide.RIGHT ? x : x - this.attackWidth;
|
||||
this.attackWidth = this.drawButtonTip(secondX, y, ButtonBinding.ATTACK.getButton(),
|
||||
this.client.crosshairTarget.getType() == HitResult.Type.BLOCK ? "lambdacontrols.action.hit" : ButtonBinding.ATTACK.getTranslationKey(),
|
||||
this.client.crosshairTarget.getType() != HitResult.Type.MISS, immediate, matrix4f);
|
||||
public void renderSecondIcons(int x, int y)
|
||||
{
|
||||
int offset;
|
||||
int currentX = x;
|
||||
if (!this.placeAction.isEmpty()) {
|
||||
if (this.mod.config.getHudSide() == HudSide.LEFT)
|
||||
currentX -= this.useButtonWidth;
|
||||
this.drawButton(currentX, y, ButtonBinding.USE, true);
|
||||
offset = 2 + this.useWidth + 4;
|
||||
if (this.client.options.showSubtitles && this.mod.config.getHudSide() == HudSide.LEFT) {
|
||||
currentX -= offset;
|
||||
} else {
|
||||
currentX = x;
|
||||
y -= 24;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.mod.config.getHudSide() == HudSide.LEFT)
|
||||
currentX -= this.attackButtonWidth;
|
||||
|
||||
this.drawButton(currentX, y, ButtonBinding.ATTACK, this.attackWidth != 0);
|
||||
}
|
||||
|
||||
public void renderFirstSection(int x, int y, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
{
|
||||
int currentX = this.mod.config.getHudSide() == HudSide.LEFT ? x + this.inventoryButtonWidth + 2 : x - this.inventoryButtonWidth - 2 - this.inventoryWidth;
|
||||
this.drawTip(currentX, y, ButtonBinding.INVENTORY, true, immediate, matrix4f);
|
||||
currentX += this.mod.config.getHudSide() == HudSide.LEFT ? this.inventoryWidth + 4 + this.swapHandsButtonWidth + 2
|
||||
: -this.swapHandsWidth - 2 - this.swapHandsButtonWidth - 4;
|
||||
this.drawTip(currentX, y, ButtonBinding.SWAP_HANDS, true, immediate, matrix4f);
|
||||
if (this.client.options.showSubtitles && this.mod.config.getHudSide() == HudSide.RIGHT) {
|
||||
currentX += -this.dropItemWidth - 2 - this.dropItemButtonWidth - 4;
|
||||
} else {
|
||||
y -= 24;
|
||||
currentX = this.mod.config.getHudSide() == HudSide.LEFT ? x + this.dropItemButtonWidth + 2 : x - this.dropItemButtonWidth - 2 - this.dropItemWidth;
|
||||
}
|
||||
this.drawTip(currentX, y, ButtonBinding.DROP_ITEM, !this.client.player.getMainHandStack().isEmpty(), immediate, matrix4f);
|
||||
}
|
||||
|
||||
public void renderSecondSection(int x, int y, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
{
|
||||
int currentX = x;
|
||||
|
||||
if (!this.placeAction.isEmpty()) {
|
||||
currentX += this.mod.config.getHudSide() == HudSide.RIGHT ? this.useButtonWidth + 2 : -this.useButtonWidth - 2 - this.useWidth;
|
||||
|
||||
this.drawTip(currentX, y, this.placeAction, true, immediate, matrix4f);
|
||||
|
||||
if (this.client.options.showSubtitles && this.mod.config.getHudSide() == HudSide.LEFT) {
|
||||
currentX -= 4;
|
||||
} else {
|
||||
currentX = x;
|
||||
y -= 24;
|
||||
}
|
||||
}
|
||||
|
||||
currentX += this.mod.config.getHudSide() == HudSide.RIGHT ? this.attackButtonWidth + 2 : -this.attackButtonWidth - 2 - this.attackWidth;
|
||||
|
||||
this.drawTip(currentX, y, this.attackAction, this.attackWidth != 0, immediate, matrix4f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,21 +178,41 @@ public class LambdaControlsHud extends Hud
|
||||
if (this.client.crosshairTarget == null)
|
||||
return;
|
||||
|
||||
String placeAction;
|
||||
|
||||
// Update "Use" tip status.
|
||||
if (this.client.crosshairTarget.getType() == HitResult.Type.MISS) {
|
||||
this.placeHitResult = LambdaInput.tryFrontPlace(this.client);
|
||||
this.attackAction = "";
|
||||
this.attackWidth = 0;
|
||||
} else {
|
||||
if (this.client.crosshairTarget.getType() == HitResult.Type.BLOCK)
|
||||
this.placeHitResult = (BlockHitResult) this.client.crosshairTarget;
|
||||
else
|
||||
this.placeHitResult = null;
|
||||
|
||||
this.attackAction = this.client.crosshairTarget.getType() == HitResult.Type.BLOCK ? "lambdacontrols.action.hit" : ButtonBinding.ATTACK.getTranslationKey();
|
||||
this.attackWidth = this.width(attackAction);
|
||||
}
|
||||
|
||||
if (this.placeHitResult != null) {
|
||||
ItemStack stack = this.client.player.getActiveItem();
|
||||
if (stack != null && stack.getItem() instanceof BlockItem) {
|
||||
this.placeAction = "lambdacontrols.action.place";
|
||||
ItemStack stack = this.client.player.getMainHandStack();
|
||||
if ((stack == null || stack.isEmpty()) && ((stack = this.client.player.getOffHandStack()) == null || stack.isEmpty())) {
|
||||
placeAction = "";
|
||||
} else {
|
||||
if (this.placeHitResult != null && stack.getItem() instanceof BlockItem) {
|
||||
placeAction = "lambdacontrols.action.place";
|
||||
} else {
|
||||
placeAction = ButtonBinding.USE.getTranslationKey();
|
||||
}
|
||||
}
|
||||
|
||||
this.placeAction = placeAction;
|
||||
|
||||
// Cache the "Use" tip width.
|
||||
if (this.placeAction.isEmpty())
|
||||
this.useWidth = 0;
|
||||
else
|
||||
this.useWidth = this.width(this.placeAction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,16 +224,37 @@ public class LambdaControlsHud extends Hud
|
||||
|
||||
private int bottom(int y)
|
||||
{
|
||||
return this.client.getWindow().getScaledHeight() - y - 15;
|
||||
return this.client.getWindow().getScaledHeight() - y - LambdaControlsRenderer.ICON_SIZE;
|
||||
}
|
||||
|
||||
private int drawButtonTip(int x, int y, @NotNull ButtonBinding button, boolean display, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
private int width(@NotNull ButtonBinding binding)
|
||||
{
|
||||
return LambdaControlsRenderer.drawButtonTip(x, y, button, display, this.client, immediate, matrix4f);
|
||||
return this.width(binding.getTranslationKey());
|
||||
}
|
||||
|
||||
private int drawButtonTip(int x, int y, int[] button, @NotNull String action, boolean display, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
private int width(@Nullable String text)
|
||||
{
|
||||
return LambdaControlsRenderer.drawButtonTip(x, y, button, action, display, this.client, immediate, matrix4f);
|
||||
if (text == null || text.isEmpty())
|
||||
return 0;
|
||||
return this.client.textRenderer.getStringWidth(I18n.translate(text));
|
||||
}
|
||||
|
||||
private void drawButton(int x, int y, @NotNull ButtonBinding button, boolean display)
|
||||
{
|
||||
if (display)
|
||||
LambdaControlsRenderer.drawButton(x, y, button, this.client);
|
||||
}
|
||||
|
||||
private void drawTip(int x, int y, @NotNull ButtonBinding button, boolean display, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
{
|
||||
this.drawTip(x, y, button.getTranslationKey(), display, immediate, matrix4f);
|
||||
}
|
||||
|
||||
private void drawTip(int x, int y, @NotNull String action, boolean display, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
{
|
||||
String translatedAction = I18n.translate(action);
|
||||
int textY = (LambdaControlsRenderer.ICON_SIZE / 2 - this.client.textRenderer.fontHeight / 2) + 1;
|
||||
client.textRenderer.draw(translatedAction, (float) x, (float) (y + textY), 14737632, true, matrix4f, immediate,
|
||||
false, 0, 15728880);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,17 +16,72 @@ import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.client.util.math.Matrix4f;
|
||||
import net.minecraft.client.util.math.Rotation3;
|
||||
import org.aperlambda.lambdacommon.utils.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
* Represents the LambdaControls renderer.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.1.1
|
||||
* @since 1.1.1
|
||||
*/
|
||||
public class LambdaControlsRenderer
|
||||
{
|
||||
public static final int ICON_SIZE = 20;
|
||||
private static final int BUTTON_SIZE = 15;
|
||||
private static final int AXIS_SIZE = 18;
|
||||
|
||||
public static int getButtonSize(int button)
|
||||
{
|
||||
switch (button) {
|
||||
case -1:
|
||||
return 0;
|
||||
case GLFW.GLFW_GAMEPAD_AXIS_LEFT_X + 100:
|
||||
case GLFW.GLFW_GAMEPAD_AXIS_LEFT_X + 200:
|
||||
case GLFW.GLFW_GAMEPAD_AXIS_LEFT_Y + 100:
|
||||
case GLFW.GLFW_GAMEPAD_AXIS_LEFT_Y + 200:
|
||||
case GLFW.GLFW_GAMEPAD_AXIS_RIGHT_X + 100:
|
||||
case GLFW.GLFW_GAMEPAD_AXIS_RIGHT_X + 200:
|
||||
case GLFW.GLFW_GAMEPAD_AXIS_RIGHT_Y + 100:
|
||||
case GLFW.GLFW_GAMEPAD_AXIS_RIGHT_Y + 200:
|
||||
return AXIS_SIZE;
|
||||
default:
|
||||
return BUTTON_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the binding icon width.
|
||||
*
|
||||
* @param binding The binding.
|
||||
* @return The width.
|
||||
*/
|
||||
public static int getBindingIconWidth(@NotNull ButtonBinding binding)
|
||||
{
|
||||
return getBindingIconWidth(binding.getButton());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the binding icon width.
|
||||
*
|
||||
* @param buttons The buttons.
|
||||
* @return The width.
|
||||
*/
|
||||
public static int getBindingIconWidth(int[] buttons)
|
||||
{
|
||||
int width = 0;
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
width += ICON_SIZE;
|
||||
if (i + 1 < buttons.length) {
|
||||
width += 2;
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
public static Pair<Integer, Integer> drawButton(int x, int y, @NotNull ButtonBinding button, @NotNull MinecraftClient client)
|
||||
{
|
||||
return drawButton(x, y, button.getButton(), client);
|
||||
@@ -39,10 +94,10 @@ public class LambdaControlsRenderer
|
||||
int currentX = x;
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
int btn = buttons[i];
|
||||
Pair<Integer, Integer> size = drawButton(currentX, y, btn, client);
|
||||
if (size.key > height)
|
||||
height = size.key;
|
||||
length += size.key;
|
||||
int size = drawButton(currentX, y, btn, client);
|
||||
if (size > height)
|
||||
height = size;
|
||||
length += size;
|
||||
if (i + 1 < buttons.length) {
|
||||
length += 2;
|
||||
currentX = x + length;
|
||||
@@ -52,11 +107,11 @@ public class LambdaControlsRenderer
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecated")
|
||||
public static Pair<Integer, Integer> drawButton(int x, int y, int button, @NotNull MinecraftClient client)
|
||||
public static int drawButton(int x, int y, int button, @NotNull MinecraftClient client)
|
||||
{
|
||||
boolean second = false;
|
||||
if (button == -1)
|
||||
return Pair.of(0, 0);
|
||||
return 0;
|
||||
else if (button >= 500) {
|
||||
button -= 1000;
|
||||
second = true;
|
||||
@@ -132,11 +187,16 @@ public class LambdaControlsRenderer
|
||||
client.getTextureManager().bindTexture(axis ? LambdaControlsClient.CONTROLLER_AXIS : LambdaControlsClient.CONTROLLER_BUTTONS);
|
||||
GlStateManager.disableDepthTest();
|
||||
|
||||
GlStateManager.color4f(1.0F, second ? 0.0F : 1.0F, 1.0F, 1.0F);
|
||||
DrawableHelper.blit(x, y, (float) buttonOffset, (float) (controllerType * (axis ? 18 : 15)), axis ? 18 : 15, axis ? 18 : 15, 256, 256);
|
||||
int assetSize = axis ? AXIS_SIZE : BUTTON_SIZE;
|
||||
|
||||
RenderSystem.color4f(1.0F, second ? 0.0F : 1.0F, 1.0F, 1.0F);
|
||||
DrawableHelper.blit(x + (ICON_SIZE / 2 - assetSize / 2), y + (ICON_SIZE / 2 - assetSize / 2),
|
||||
(float) buttonOffset, (float) (controllerType * (axis ? AXIS_SIZE : BUTTON_SIZE)),
|
||||
assetSize, assetSize,
|
||||
256, 256);
|
||||
GlStateManager.enableDepthTest();
|
||||
|
||||
return axis ? Pair.of(18, 18) : Pair.of(15, 15);
|
||||
return ICON_SIZE;
|
||||
}
|
||||
|
||||
public static int drawButtonTip(int x, int y, @NotNull ButtonBinding button, boolean display, @NotNull MinecraftClient client)
|
||||
@@ -145,30 +205,14 @@ public class LambdaControlsRenderer
|
||||
}
|
||||
|
||||
public static int drawButtonTip(int x, int y, int[] button, @NotNull String action, boolean display, @NotNull MinecraftClient client)
|
||||
{
|
||||
VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
|
||||
int width = drawButtonTip(x, y, button, action, display, client, immediate, Rotation3.identity().getMatrix());
|
||||
immediate.draw();
|
||||
return width;
|
||||
}
|
||||
|
||||
public static int drawButtonTip(int x, int y, @NotNull ButtonBinding button, boolean display, @NotNull MinecraftClient client, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
{
|
||||
return drawButtonTip(x, y, button.getButton(), button.getTranslationKey(), display, client, immediate, matrix4f);
|
||||
}
|
||||
|
||||
public static int drawButtonTip(int x, int y, int[] button, @NotNull String action, boolean display, @NotNull MinecraftClient client, @NotNull VertexConsumerProvider.Immediate immediate, @NotNull Matrix4f matrix4f)
|
||||
{
|
||||
if (display) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
int buttonWidth = drawButton(x, y, button, client).key;
|
||||
|
||||
String translatedAction = I18n.translate(action);
|
||||
int textY = (15 - client.textRenderer.fontHeight) / 2;
|
||||
int width = client.textRenderer.draw(translatedAction, (float) (x + buttonWidth + 5), (float) (y + textY), 14737632, true, matrix4f, immediate,
|
||||
false, 0, 15728880);
|
||||
int textY = (LambdaControlsRenderer.ICON_SIZE / 2 - client.textRenderer.fontHeight / 2) + 1;
|
||||
|
||||
return width;
|
||||
return client.textRenderer.drawWithShadow(translatedAction, (float) (x + buttonWidth + 2), (float) (y + textY), 14737632);
|
||||
}
|
||||
|
||||
return -10;
|
||||
|
||||
@@ -45,6 +45,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
private final Option mouseSpeedOption;
|
||||
private final Option resetOption;
|
||||
// Gameplay options
|
||||
private final Option autoJumpOption;
|
||||
private final Option frontBlockPlacingOption;
|
||||
private final Option flyDriftingOption;
|
||||
private final Option flyVerticalDriftingOption;
|
||||
@@ -92,6 +93,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
this.init(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
});
|
||||
// Gameplay options
|
||||
this.autoJumpOption = SpruceBooleanOption.fromVanilla("options.autoJump", Option.AUTO_JUMP, null, true);
|
||||
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.flyDriftingOption = new SpruceBooleanOption("lambdacontrols.menu.fly_drifting", this.mod.config::hasFlyDrifting,
|
||||
@@ -221,6 +223,7 @@ public class LambdaControlsSettingsScreen extends Screen
|
||||
this.list.addSingleOptionEntry(this.autoSwitchModeOption);
|
||||
// Gameplay options
|
||||
this.list.addSingleOptionEntry(new SpruceSeparatorOption("lambdacontrols.menu.title.gameplay", true, null));
|
||||
this.list.addSingleOptionEntry(this.autoJumpOption);
|
||||
this.list.addSingleOptionEntry(this.frontBlockPlacingOption);
|
||||
this.list.addSingleOptionEntry(this.flyDriftingOption);
|
||||
this.list.addSingleOptionEntry(this.flyVerticalDriftingOption);
|
||||
|
||||
@@ -13,6 +13,7 @@ import me.lambdaurora.lambdacontrols.ControlsMode;
|
||||
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
|
||||
import me.lambdaurora.lambdacontrols.client.gui.LambdaControlsRenderer;
|
||||
import me.lambdaurora.lambdacontrols.client.util.ContainerScreenAccessor;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
|
||||
import net.minecraft.container.Slot;
|
||||
@@ -44,11 +45,15 @@ public abstract class ContainerScreenMixin implements ContainerScreenAccessor
|
||||
{
|
||||
if (LambdaControlsClient.get().config.getControlsMode() == ControlsMode.CONTROLLER) {
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
int x = 10, y = client.getWindow().getScaledHeight() - 10 - 15;
|
||||
int x = 2, y = client.getWindow().getScaledHeight() - 2 - LambdaControlsRenderer.ICON_SIZE;
|
||||
|
||||
x += LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_A}, "lambdacontrols.action.pickup_all", true, client) + 10;
|
||||
x += LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_B}, "lambdacontrols.action.exit", true, client) + 10;
|
||||
x += LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_X}, "lambdacontrols.action.pickup", true, client) + 10;
|
||||
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;
|
||||
if (FabricLoader.getInstance().isModLoaded("roughlyenoughitems")) {
|
||||
x = 2;
|
||||
y -= 24;
|
||||
}
|
||||
x = LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_X}, "lambdacontrols.action.pickup", true, client) + 2;
|
||||
LambdaControlsRenderer.drawButtonTip(x, y, new int[]{GLFW.GLFW_GAMEPAD_BUTTON_Y}, "lambdacontrols.action.quick_move", true, client);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"lambdacontrols.action.pick_block": "Pick Block",
|
||||
"lambdacontrols.action.pickup": "Pickup",
|
||||
"lambdacontrols.action.pickup_all": "Pickup all",
|
||||
"lambdacontrols.action.place": "Place",
|
||||
"lambdacontrols.action.player_list": "Player List",
|
||||
"lambdacontrols.action.quick_move": "Quick move",
|
||||
"lambdacontrols.action.right": "Right",
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"lambdacontrols.action.pick_block": "Choisir le bloc",
|
||||
"lambdacontrols.action.pickup": "Prendre",
|
||||
"lambdacontrols.action.pickup_all": "Prendre tout",
|
||||
"lambdacontrols.action.place": "Placer",
|
||||
"lambdacontrols.action.player_list": "Afficher la liste des joueurs",
|
||||
"lambdacontrols.action.quick_move": "Mouvement rapide",
|
||||
"lambdacontrols.action.right": "Aller à droite",
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"lambdacontrols.action.pick_block": "Choisir le bloc",
|
||||
"lambdacontrols.action.pickup": "Prendre",
|
||||
"lambdacontrols.action.pickup_all": "Prendre tout",
|
||||
"lambdacontrols.action.place": "Placer",
|
||||
"lambdacontrols.action.player_list": "Afficher la liste des joueurs",
|
||||
"lambdacontrols.action.quick_move": "Mouvement rapide",
|
||||
"lambdacontrols.action.right": "Aller à droite",
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"fabricloader": ">=0.4.0",
|
||||
"fabric": "*",
|
||||
"minecraft": ">=1.15",
|
||||
"spruceui": ">=1.3.4"
|
||||
"spruceui": ">=1.3.5"
|
||||
},
|
||||
"recommends": {
|
||||
"modmenu": ">=1.9.0",
|
||||
|
||||
@@ -15,5 +15,5 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# Dependencies
|
||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||
fabric_version=0.4.29+build.290-1.15
|
||||
spruceui_version=1.3.4
|
||||
spruceui_version=1.3.5
|
||||
modmenu_version=1.10.1+build.30
|
||||
|
||||
Reference in New Issue
Block a user