mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 15:25:08 +01:00
Compare commits
2 Commits
architectu
...
architectu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13adff2e26 | ||
|
|
381d715fa8 |
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "1.11-SNAPSHOT" apply false
|
||||
id "dev.architectury.loom" version "1.13-SNAPSHOT" apply false
|
||||
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ package eu.midnightdust.midnightcontrols;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.object.AtlasTextObjectContents;
|
||||
import net.minecraft.util.Atlases;
|
||||
import net.minecraft.util.TranslatableOption;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -27,7 +27,7 @@ import static eu.midnightdust.midnightcontrols.MidnightControls.id;
|
||||
* @version 1.7.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public enum ControlsMode implements TranslatableOption {
|
||||
public enum ControlsMode implements StringIdentifiable {
|
||||
DEFAULT("icon/keyboard_mouse"),
|
||||
CONTROLLER("icon/controller"),
|
||||
TOUCHSCREEN("icon/touchscreen");
|
||||
@@ -49,15 +49,10 @@ public enum ControlsMode implements TranslatableOption {
|
||||
return v[this.ordinal() + 1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getText() {
|
||||
return Text.object(new AtlasTextObjectContents(Atlases.GUI, id(emoji))).append(" ").append(Text.translatable(getTranslationKey()));
|
||||
}
|
||||
// @Override
|
||||
// public Text getText() {
|
||||
// return Text.object(new AtlasTextObjectContents(Atlases.GUI, id(emoji))).append(" ").append(Text.translatable(getTranslationKey()));
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the translation key of this controls mode.
|
||||
@@ -83,4 +78,9 @@ public enum ControlsMode implements TranslatableOption {
|
||||
public static Optional<ControlsMode> byId(@NotNull String id) {
|
||||
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asString() {
|
||||
return getTranslationKey();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public class MidnightControlsClient extends MidnightControls {
|
||||
client = MinecraftClient.getInstance();
|
||||
if (screen == null && MidnightControlsConfig.controlsMode == ControlsMode.TOUCHSCREEN) {
|
||||
screen = new TouchscreenOverlay();
|
||||
screen.init(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
screen.init(client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
client.skipGameRender = false;
|
||||
client.currentScreen = screen;
|
||||
} else if (screen != null) {
|
||||
|
||||
@@ -94,9 +94,9 @@ public class InputHandlers {
|
||||
nextTab = tabs.size() - 1;
|
||||
else if (nextTab >= tabs.size())
|
||||
nextTab = 0;
|
||||
currentTab.setToggled(false);
|
||||
currentTab.active = false;
|
||||
recipeBookAccessor.setCurrentTab(currentTab = tabs.get(nextTab));
|
||||
currentTab.setToggled(true);
|
||||
currentTab.active = true;
|
||||
recipeBookScreen.refreshRecipeBook();
|
||||
return true;
|
||||
} else if (client.currentScreen instanceof AdvancementsScreenAccessor screen) {
|
||||
|
||||
@@ -221,7 +221,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
|
||||
this.resetOption = SpruceSimpleActionOption.reset(btn -> {
|
||||
MidnightControlsConfig.reset();
|
||||
var client = MinecraftClient.getInstance();
|
||||
this.init(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
this.init(client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
});
|
||||
// Gameplay options
|
||||
this.analogMovementOption = new SpruceToggleBooleanOption("midnightcontrols.menu.analog_movement",
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ReloadControllerMappingsOption {
|
||||
before.accept(btn);
|
||||
Controller.updateMappings();
|
||||
if (client.currentScreen instanceof MidnightControlsSettingsScreen)
|
||||
client.currentScreen.init(client, client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
client.currentScreen.init(client.getWindow().getScaledWidth(), client.getWindow().getScaledHeight());
|
||||
client.getToastManager().add(SystemToast.create(client, SystemToast.Type.PERIODIC_NOTIFICATION,
|
||||
Text.translatable("midnightcontrols.controller.mappings.updated"), Text.empty()));
|
||||
}, TooltipData.builder().text(Text.translatable("midnightcontrols.tooltip.reload_controller_mappings")).build());
|
||||
|
||||
@@ -11,7 +11,7 @@ import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
|
||||
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
|
||||
import eu.midnightdust.midnightcontrols.client.gui.MidnightControlsRenderer;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.font.DrawnTextConsumer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.tooltip.Tooltip;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
@@ -36,7 +36,7 @@ public class ControllerBindingButton extends ButtonWidget implements ControlsInp
|
||||
|
||||
public static void add(ButtonBinding binding, MidnightConfigListWidget list, MidnightConfigScreen screen) {
|
||||
ControllerBindingButton editButton = new ControllerBindingButton(screen.width - 185 + 22, 0, 128, 20, binding);
|
||||
TextIconButtonWidget resetButton = TextIconButtonWidget.builder(Text.translatable("controls.reset"), (button -> {
|
||||
TextIconButtonWidget resetButton = TextIconButtonWidget.builder(net.minecraft.text.Text.translatable("controls.reset"), (button -> {
|
||||
MidnightControlsConfig.setButtonBinding(binding, binding.getDefaultButton());
|
||||
MidnightControlsClient.input.beginControlsInput(null);
|
||||
editButton.updateMessage(false);
|
||||
@@ -46,7 +46,7 @@ public class ControllerBindingButton extends ButtonWidget implements ControlsInp
|
||||
editButton.updateMessage(false);
|
||||
EntryInfo info = new EntryInfo(null, screen.modid);
|
||||
|
||||
TextIconButtonWidget unbindButton = TextIconButtonWidget.builder(Text.translatable("midnightcontrols.narrator.unbound", binding.getText()), (button -> {
|
||||
TextIconButtonWidget unbindButton = TextIconButtonWidget.builder(net.minecraft.text.Text.translatable("midnightcontrols.narrator.unbound", binding.getText()), (button -> {
|
||||
MidnightControlsConfig.setButtonBinding(binding, UNBOUND);
|
||||
MidnightControlsClient.input.beginControlsInput(null);
|
||||
editButton.updateMessage(false);
|
||||
@@ -56,7 +56,7 @@ public class ControllerBindingButton extends ButtonWidget implements ControlsInp
|
||||
unbindButton.active = !binding.isNotBound();
|
||||
editButton.unbindButton = unbindButton;
|
||||
|
||||
list.addButton(Lists.newArrayList(editButton, resetButton, unbindButton), Text.translatable(binding.getTranslationKey()), info);
|
||||
list.addButton(Lists.newArrayList(editButton, resetButton, unbindButton), net.minecraft.text.Text.translatable(binding.getTranslationKey()), info);
|
||||
}
|
||||
|
||||
private final ButtonBinding binding;
|
||||
@@ -64,7 +64,7 @@ public class ControllerBindingButton extends ButtonWidget implements ControlsInp
|
||||
private @Nullable ClickableWidget unbindButton;
|
||||
public ControllerBindingButton(int x, int y, int width, int height, ButtonBinding binding) {
|
||||
super(x, y, width, height, binding.getText(), (button) -> {},
|
||||
(textSupplier) -> binding.isNotBound() ? Text.translatable("narrator.controls.unbound", binding.getTranslationKey()) : Text.translatable("narrator.controls.bound", binding.getTranslationKey(), textSupplier.get()));
|
||||
(textSupplier) -> binding.isNotBound() ? net.minecraft.text.Text.translatable("narrator.controls.unbound", binding.getTranslationKey()) : net.minecraft.text.Text.translatable("narrator.controls.bound", binding.getTranslationKey(), textSupplier.get()));
|
||||
this.binding = binding;
|
||||
updateMessage(false);
|
||||
}
|
||||
@@ -78,8 +78,8 @@ public class ControllerBindingButton extends ButtonWidget implements ControlsInp
|
||||
|
||||
public void updateMessage(boolean focused) {
|
||||
AtomicBoolean hasConflicts = new AtomicBoolean(false);
|
||||
MutableText conflictingBindings = Text.empty();
|
||||
if (focused) this.setMessage(Text.literal("> ").append(getTranslatedButtons().copy().formatted(Formatting.WHITE, Formatting.UNDERLINE)).append(" <").formatted(Formatting.YELLOW));
|
||||
MutableText conflictingBindings = net.minecraft.text.Text.empty();
|
||||
if (focused) this.setMessage(net.minecraft.text.Text.literal("> ").append(getTranslatedButtons().copy().formatted(Formatting.WHITE, Formatting.UNDERLINE)).append(" <").formatted(Formatting.YELLOW));
|
||||
else {
|
||||
this.setMessage(getTranslatedButtons());
|
||||
|
||||
@@ -89,7 +89,7 @@ public class ControllerBindingButton extends ButtonWidget implements ControlsInp
|
||||
if (hasConflicts.get()) conflictingBindings.append(", ");
|
||||
|
||||
hasConflicts.set(true);
|
||||
conflictingBindings.append(Text.translatable(keyBinding.getTranslationKey()));
|
||||
conflictingBindings.append(net.minecraft.text.Text.translatable(keyBinding.getTranslationKey()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -99,26 +99,25 @@ public class ControllerBindingButton extends ButtonWidget implements ControlsInp
|
||||
if (this.unbindButton != null) this.unbindButton.active = !binding.isNotBound();
|
||||
|
||||
if (hasConflicts.get()) {
|
||||
this.setMessage(Text.literal("[ ").append(this.getMessage().copy().formatted(Formatting.WHITE)).append(" ]").formatted(Formatting.RED));
|
||||
this.setTooltip(Tooltip.of(Text.translatable("controls.keybinds.duplicateKeybinds", conflictingBindings)));
|
||||
this.setMessage(net.minecraft.text.Text.literal("[ ").append(this.getMessage().copy().formatted(Formatting.WHITE)).append(" ]").formatted(Formatting.RED));
|
||||
this.setTooltip(Tooltip.of(net.minecraft.text.Text.translatable("controls.keybinds.duplicateKeybinds", conflictingBindings)));
|
||||
} else {
|
||||
this.setTooltip(null);
|
||||
}
|
||||
}
|
||||
|
||||
private Text getTranslatedButtons() {
|
||||
private net.minecraft.text.Text getTranslatedButtons() {
|
||||
return this.binding.isNotBound() ? SpruceTexts.NOT_BOUND.copy() :
|
||||
(binding.getButton().length > 0 ? ButtonBinding.getLocalizedButtonName(binding.getButton()[0]) : Text.literal("..."));
|
||||
(binding.getButton().length > 0 ? ButtonBinding.getLocalizedButtonName(binding.getButton()[0]) : net.minecraft.text.Text.literal("..."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawMessage(DrawContext context, TextRenderer textRenderer, int color) {
|
||||
if (this.binding.getButton().length < 2) super.drawMessage(context, textRenderer, color);
|
||||
public void drawLabel(DrawnTextConsumer consumer) {
|
||||
if (this.binding.getButton().length < 2) super.drawLabel(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
|
||||
super.renderWidget(context, mouseX, mouseY, deltaTicks);
|
||||
protected void drawIcon(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
|
||||
int x = this.getX();
|
||||
if (this.binding.getButton().length > 1) {
|
||||
x += (this.width / 2 - iconWidth / 2) - 4;
|
||||
|
||||
@@ -19,6 +19,7 @@ public abstract class CursorRenderer {
|
||||
|
||||
public static void drawUnalignedTexturedQuad(RenderPipeline pipeline, Identifier texture, DrawContext context, float x1, float x2, float y1, float y2, float u1, float u2, float v1, float v2) {
|
||||
DrawContextAccessor accessor = (DrawContextAccessor) context;
|
||||
accessor.getState().addSimpleElement(new UnalignedTexturedQuadGuiElementRenderState(pipeline, TextureSetup.withoutGlTexture(client.getTextureManager().getTexture(texture).getGlTextureView()), new Matrix3x2f(context.getMatrices()), x1, y1, x2, y2, u1, u2, v1, v2, 0xffffffff, accessor.getScissorStack().peekLast()));
|
||||
var tex = client.getTextureManager().getTexture(texture);
|
||||
accessor.getState().addSimpleElement(new UnalignedTexturedQuadGuiElementRenderState(pipeline, TextureSetup.of(tex.getGlTextureView(), tex.getSampler()), new Matrix3x2f(context.getMatrices()), x1, y1, x2, y2, u1, u2, v1, v2, 0xffffffff, accessor.getScissorStack().peekLast()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ public abstract class ScreenMixin {
|
||||
|
||||
@Shadow public int width;
|
||||
|
||||
@Inject(method = "init(Lnet/minecraft/client/MinecraftClient;II)V", at = @At("TAIL"))
|
||||
public void midnightcontrols$addCloseButton(MinecraftClient client, int width, int height, CallbackInfo ci) {
|
||||
@Inject(method = "init(II)V", at = @At("TAIL"))
|
||||
public void midnightcontrols$addCloseButton(int width, int height, CallbackInfo ci) {
|
||||
if (MidnightControlsConfig.controlsMode == ControlsMode.TOUCHSCREEN && (MidnightControlsConfig.closeButtonScreens.stream().anyMatch(s -> this.getClass().getName().startsWith(s) || ((Object)this) instanceof HandledScreen<?>))) {
|
||||
this.addDrawableChild(new SilentTexturedButtonWidget(Position.of(this.width - 30, 10), 20, 20, Text.empty(), btn ->
|
||||
InputHandlers.handleExit().press(client, ButtonBinding.BACK, 0f, ButtonState.PRESS), 20, 160, 20, WIDGETS_LOCATION));
|
||||
InputHandlers.handleExit().press(MinecraftClient.getInstance(), ButtonBinding.BACK, 0f, ButtonState.PRESS), 20, 160, 20, WIDGETS_LOCATION));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ public abstract class WorldRendererMixin {
|
||||
var outlineShape = this.world.getBlockState(blockPos).getOutlineShape(this.client.world, blockPos, ShapeContext.of(camera.getFocusedEntity()));
|
||||
Color rgb = MidnightColorUtil.hex2Rgb(MidnightControlsConfig.touchOutlineColorHex);
|
||||
if (MidnightControlsConfig.touchOutlineColorHex.isEmpty()) rgb = RainbowColor.radialRainbow(1,1);
|
||||
var pos = camera.getPos();
|
||||
var pos = camera.getCameraPos();
|
||||
matrices.push();
|
||||
var vertexConsumer = immediate.getBuffer(RenderLayer.getLines());
|
||||
var vertexConsumer = immediate.getBuffer(RenderLayers.lines());
|
||||
VertexRendering.drawOutline(matrices, vertexConsumer, outlineShape, blockPos.getX() - pos.getX(), blockPos.getY() - pos.getY(), blockPos.getZ() - pos.getZ(),
|
||||
ColorHelper.withAlpha(MidnightControlsConfig.touchOutlineColorAlpha, rgb.getRGB()));
|
||||
ColorHelper.withAlpha(MidnightControlsConfig.touchOutlineColorAlpha, rgb.getRGB()), 4);
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
@@ -105,15 +105,15 @@ public abstract class WorldRendererMixin {
|
||||
var placementState = block.getPlacementState(context);
|
||||
if (placementState == null)
|
||||
return;
|
||||
var pos = camera.getPos();
|
||||
var pos = camera.getCameraPos();
|
||||
|
||||
var outlineShape = placementState.getOutlineShape(this.client.world, blockPos, ShapeContext.of(camera.getFocusedEntity()));
|
||||
Color rgb = MidnightColorUtil.hex2Rgb(MidnightControlsConfig.reacharoundOutlineColorHex);
|
||||
if (MidnightControlsConfig.reacharoundOutlineColorHex.isEmpty()) rgb = RainbowColor.radialRainbow(1,1);
|
||||
matrices.push();
|
||||
var vertexConsumer = immediate.getBuffer(RenderLayer.getLines());
|
||||
var vertexConsumer = immediate.getBuffer(RenderLayers.lines());
|
||||
VertexRendering.drawOutline(matrices, vertexConsumer, outlineShape, blockPos.getX() - pos.getX(), blockPos.getY() - pos.getY(), blockPos.getZ() - pos.getZ(),
|
||||
ColorHelper.withAlpha(MidnightControlsConfig.touchOutlineColorAlpha, rgb.getRGB()));
|
||||
ColorHelper.withAlpha(MidnightControlsConfig.touchOutlineColorAlpha, rgb.getRGB()), 4);
|
||||
matrices.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class TouchUtils {
|
||||
.unproject((float) x / displayWidth * viewport[2],
|
||||
(float) (displayHeight - y) / displayHeight * viewport[3], (float) d, viewport, target);
|
||||
|
||||
return new Vec3d(target.x, target.y, target.z).add(camera.getPos());
|
||||
return new Vec3d(target.x, target.y, target.z).add(camera.getCameraPos());
|
||||
}
|
||||
|
||||
public static boolean hasInWorldUseAction(ItemStack stack) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 15,
|
||||
"supported_formats": [15, 999],
|
||||
"supported_formats": [15, 255],
|
||||
"min_format": 15,
|
||||
"max_format": 255,
|
||||
"description": "Makes controller tooltips use similar icons to Bedrock Edition"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 15,
|
||||
"supported_formats": [15, 999],
|
||||
"supported_formats": [15, 255],
|
||||
"min_format": 15,
|
||||
"max_format": 255,
|
||||
"description": "Makes controller icons look similar to Legacy Console Edit."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric")
|
||||
modImplementation include ("dev.lambdaurora:spruceui:${project.spruceui_version}")
|
||||
include("dev.yumi.mc.core:yumi-mc-foundation:1.0.0-alpha.15+1.21.1")
|
||||
modImplementation ("dev.lambdaurora:spruceui:${project.spruceui_version}")
|
||||
include("dev.yumi.mc.core:yumi-mc-foundation:1.0.0-beta.1+1.21.11")
|
||||
include 'org.aperlambda:lambdajcommon:1.8.1'
|
||||
modCompileOnly "maven.modrinth:emi:${project.emi_version}"
|
||||
|
||||
|
||||
@@ -2,25 +2,25 @@
|
||||
org.gradle.parallel=true
|
||||
org.gradle.jvmargs=-Xmx2048M
|
||||
|
||||
minecraft_version=1.21.9
|
||||
supported_versions=1.21.10
|
||||
yarn_mappings=1.21.9+build.1
|
||||
minecraft_version=1.21.11
|
||||
supported_versions=
|
||||
yarn_mappings=1.21.11+build.2
|
||||
enabled_platforms=fabric,neoforge
|
||||
|
||||
archives_base_name=midnightcontrols
|
||||
mod_version=1.11.3-beta.3
|
||||
mod_version=1.11.4-alpha.1
|
||||
maven_group=eu.midnightdust
|
||||
release_type=beta
|
||||
modrinth_id = bXX9h73M
|
||||
curseforge_id = 621768
|
||||
# Configure the IDs here after creating the projects on the websites
|
||||
|
||||
midnightlib_version=1.8.3+1.21.9
|
||||
midnightlib_version=1.9.2+1.21.11
|
||||
|
||||
fabric_loader_version=0.17.2
|
||||
fabric_api_version=0.133.13+1.21.9
|
||||
fabric_loader_version=0.18.2
|
||||
fabric_api_version=0.139.4+1.21.11
|
||||
|
||||
neoforge_version=21.9.3-beta
|
||||
neoforge_version=21.11.3-beta
|
||||
yarn_mappings_patch_neoforge_version = 1.21+build.4
|
||||
|
||||
quilt_loader_version=0.19.0-beta.18
|
||||
|
||||
Reference in New Issue
Block a user