Compare commits

...

4 Commits

Author SHA1 Message Date
Martin Prokoph
aabb728303 Use EMI version for 1.20.1 2024-02-14 10:52:28 +01:00
Martin Prokoph
3b93a52568 Merge pull request #262 from TeamMidnightDust/1.20.4
Backport fixes to 1.20.1
2024-02-14 10:51:00 +01:00
Martin Prokoph
797ab519de Rebase on 1.20.1 2024-02-03 14:17:28 +01:00
Martin Prokoph
18df94c4e4 Merge pull request #259 from TeamMidnightDust/1.20.4
Backport changes from 1.9.0+
2024-02-03 13:16:41 +01:00
11 changed files with 134 additions and 44 deletions

View File

@@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.3
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.6
# Mod Properties
mod_version = 1.9.4
@@ -17,14 +17,14 @@ changelog = See changes at: https://github.com/TeamMidnightDust/MidnightControls
# 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.91.3+1.20.4
fabric_version=0.91.0+1.20.1
sodium_version=mc1.19.2-0.4.4
spruceui_version=5.0.3+1.20.4
midnightlib_version=1.5.3-fabric
spruceui_version=5.0.0+1.20
midnightlib_version=1.4.1-fabric
modmenu_version=7.0.0
emotecraft_version=2.1.3-SNAPSHOT-build.29-MC1.19-fabric
bendylib_version=2.0.+
emi_version=1.1.1+1.20.4+fabric
emi_version=1.1.1+1.20.1+fabric
libgui_version=6.0.0+1.19
inventorytabs_version=inventorytabs-0.9.beta-1.19.x
clothconfig_version=7.0.72

View File

@@ -28,7 +28,6 @@ import eu.midnightdust.midnightcontrols.client.ring.ButtonBindingRingAction;
import eu.midnightdust.midnightcontrols.client.ring.MidnightRing;
import dev.lambdaurora.spruceui.hud.HudManager;
import eu.midnightdust.midnightcontrols.client.touch.TouchInput;
import eu.midnightdust.midnightcontrols.client.util.RainbowColor;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
@@ -229,7 +228,6 @@ public class MidnightControlsClient extends MidnightControls implements ClientMo
MidnightControlsConfig.enableHints = false;
MidnightControlsConfig.save();
}
RainbowColor.tick();
TouchInput.tick();
}

View File

@@ -565,7 +565,7 @@ public class MidnightInput {
var accessor = (CreativeInventoryScreenAccessor) creativeInventoryScreen;
// @TODO allow rebinding to left stick
if (accessor.midnightcontrols$hasScrollbar() && absValue >= deadZone) {
creativeInventoryScreen.mouseScrolled(0.0, 0.0, 0, -value);
creativeInventoryScreen.mouseScrolled(0.0, 0.0, -value);
}
return;
}
@@ -573,7 +573,7 @@ public class MidnightInput {
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_Y) {
// @TODO allow rebinding to left stick
if (absValue >= deadZone) {
merchantScreen.mouseScrolled(0.0, 0.0, 0, -(value * 1.5f));
merchantScreen.mouseScrolled(0.0, 0.0, -(value * 1.5f));
}
return;
}
@@ -581,7 +581,7 @@ public class MidnightInput {
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_Y) {
// @TODO allow rebinding to left stick
if (absValue >= deadZone) {
stonecutterScreen.mouseScrolled(0.0, 0.0, 0, -(value * 1.5f));
stonecutterScreen.mouseScrolled(0.0, 0.0, -(value * 1.5f));
}
return;
}
@@ -600,7 +600,7 @@ public class MidnightInput {
.map(element -> (SpruceEntryListWidget<?>) element)
.filter(AbstractSpruceWidget::isFocusedOrHovered)
.noneMatch(element -> {
element.mouseScrolled(0.0, 0.0, 0, -finalValue);
element.mouseScrolled(0.0, 0.0, -finalValue);
return true;
})
&&
@@ -608,11 +608,11 @@ public class MidnightInput {
.map(element -> (EntryListWidget<?>) element)
.filter(element -> element.getType().isFocused())
.noneMatch(element -> {
element.mouseScrolled(0.0, 0.0, 0, -finalValue);
element.mouseScrolled(0.0, 0.0, -finalValue);
return true;
}))
{
client.currentScreen.mouseScrolled(0.0, 0.0, 0, -(value * 1.5f));
client.currentScreen.mouseScrolled(0.0, 0.0, -(value * 1.5f));
}
else if (isScreenInteractive(client.currentScreen) && absValue >= deadZone) {
if (value > 0 && joystickCooldown == 0) {

View File

@@ -76,7 +76,7 @@ public class ButtonBinding {
public static final ButtonBinding SCREENSHOT = new Builder("screenshot").buttons(GLFW_GAMEPAD_BUTTON_DPAD_UP, GLFW_GAMEPAD_BUTTON_A)
.action(InputHandlers::handleScreenshot).cooldown().register();
public static final ButtonBinding DEBUG_SCREEN = new Builder("debug_screen").buttons(GLFW_GAMEPAD_BUTTON_DPAD_UP, GLFW_GAMEPAD_BUTTON_B)
.action((client,binding,value,action) -> {if (action == ButtonState.PRESS) client.inGameHud.getDebugHud().toggleDebugHud(); return true;}).cooldown().register();
.action((client,binding,value,action) -> {if (action == ButtonState.PRESS) client.options.debugEnabled = !client.options.debugEnabled; return true;}).cooldown().register();
public static final ButtonBinding SLOT_DOWN = new Builder("slot_down").buttons(GLFW_GAMEPAD_BUTTON_DPAD_DOWN)
.action(InputHandlers.handleInventorySlotPad(1)).onlyInInventory().cooldown().register();
public static final ButtonBinding SLOT_LEFT = new Builder("slot_left").buttons(GLFW_GAMEPAD_BUTTON_DPAD_LEFT)

View File

@@ -157,7 +157,7 @@ public class InputHandlers {
nextTab = tabs.size() - 1;
else if (nextTab >= tabs.size())
nextTab = 0;
screen.getAdvancementManager().selectTab(tabs.get(nextTab).getRoot().getAdvancementEntry(), true);
screen.getAdvancementManager().selectTab(tabs.get(nextTab).getRoot(), true);
break;
}
}
@@ -276,7 +276,7 @@ public class InputHandlers {
if (action == ButtonState.PRESS) {
// If in game, then pause the game.
if (client.currentScreen == null || client.currentScreen instanceof RingScreen)
client.openGameMenu(false);
client.openPauseMenu(false);
else if (client.currentScreen instanceof HandledScreen && client.player != null) // If the current screen is a container then close it.
client.player.closeHandledScreen();
else // Else just close the current screen.

View File

@@ -20,6 +20,7 @@ import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import eu.midnightdust.midnightcontrols.client.compat.EmotecraftCompat;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
import eu.midnightdust.midnightcontrols.client.gui.widget.TextIconButtonWidget;
import eu.midnightdust.midnightcontrols.client.touch.gui.ItemUseButtonWidget;
import eu.midnightdust.midnightcontrols.client.touch.gui.SilentTexturedButtonWidget;
import eu.midnightdust.midnightcontrols.client.touch.TouchUtils;
@@ -27,10 +28,7 @@ import eu.midnightdust.midnightcontrols.client.util.KeyBindingAccessor;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.*;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.widget.TextIconButtonWidget;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.texture.MissingSprite;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.InputUtil;
import net.minecraft.item.*;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
@@ -84,7 +82,7 @@ public class TouchscreenOverlay extends Screen {
}
@Override
public void renderInGameBackground(DrawContext context) {}
public void renderBackground(DrawContext context) {}
private void pauseGame() {
assert this.client != null;
@@ -290,12 +288,11 @@ public class TouchscreenOverlay extends Screen {
assert client != null;
Identifier emptySprite = new Identifier(MidnightControlsConstants.NAMESPACE, "touch/empty");
List<String> list = left ? MidnightControlsConfig.leftTouchBinds : MidnightControlsConfig.rightTouchBinds;
Sprite missingSprite = client.getGuiAtlasManager().getSprite(MissingSprite.getMissingSpriteId());
for (int i = 0; i < list.size(); i++) {
String bindName = list.get(i);
ButtonBinding binding = InputManager.getBinding(bindName);
if (binding == null) continue;
boolean hasTexture = client.getGuiAtlasManager().getSprite(new Identifier(MidnightControlsConstants.NAMESPACE, "binding/"+bindName)) != missingSprite;
boolean hasTexture = client.getTextureManager().getOrDefault(new Identifier(MidnightControlsConstants.NAMESPACE, "binding/"+bindName), null) != null;
if (MidnightControlsConfig.debug) System.out.println(left +" "+new Identifier(MidnightControlsConstants.NAMESPACE, "binding/"+bindName)+" "+ hasTexture);
var button = TextIconButtonWidget.builder(Text.translatable(binding.getTranslationKey()), b -> binding.handle(client, 1, ButtonState.PRESS), hasTexture)
.texture(hasTexture ? new Identifier(MidnightControlsConstants.NAMESPACE, "binding/"+bindName) : emptySprite, 20, 20).dimension(20, 20).build();

View File

@@ -0,0 +1,111 @@
package eu.midnightdust.midnightcontrols.client.gui.widget;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
@Environment(EnvType.CLIENT)
public abstract class TextIconButtonWidget extends net.minecraft.client.gui.widget.ButtonWidget {
protected final Identifier texture;
protected final int textureWidth;
protected final int textureHeight;
TextIconButtonWidget(int width, int height, Text message, int textureWidth, int textureHeight, Identifier texture, net.minecraft.client.gui.widget.ButtonWidget.PressAction onPress) {
super(0, 0, width, height, message, onPress, DEFAULT_NARRATION_SUPPLIER);
this.textureWidth = textureWidth;
this.textureHeight = textureHeight;
this.texture = new Identifier(texture.getNamespace(), "textures/gui/sprites/"+texture.getPath()+".png");
}
public static Builder builder(Text text, net.minecraft.client.gui.widget.ButtonWidget.PressAction onPress, boolean hideLabel) {
return new Builder(text, onPress, hideLabel);
}
@Environment(EnvType.CLIENT)
public static class Builder {
private final Text text;
private final net.minecraft.client.gui.widget.ButtonWidget.PressAction onPress;
private final boolean hideText;
private int width = 150;
private int height = 20;
@Nullable
private Identifier texture;
private int textureWidth;
private int textureHeight;
public Builder(Text text, net.minecraft.client.gui.widget.ButtonWidget.PressAction onPress, boolean hideText) {
this.text = text;
this.onPress = onPress;
this.hideText = hideText;
}
public Builder width(int width) {
this.width = width;
return this;
}
public Builder dimension(int width, int height) {
this.width = width;
this.height = height;
return this;
}
public Builder texture(Identifier texture, int width, int height) {
this.texture = texture;
this.textureWidth = width;
this.textureHeight = height;
return this;
}
public TextIconButtonWidget build() {
if (this.texture == null) {
throw new IllegalStateException("Sprite not set");
} else {
return this.hideText ? new IconOnly(this.width, this.height, this.text, this.textureWidth, this.textureHeight, this.texture, this.onPress) : new WithText(this.width, this.height, this.text, this.textureWidth, this.textureHeight, this.texture, this.onPress);
}
}
}
@Environment(EnvType.CLIENT)
public static class WithText extends TextIconButtonWidget {
protected WithText(int i, int j, Text text, int k, int l, Identifier identifier, net.minecraft.client.gui.widget.ButtonWidget.PressAction pressAction) {
super(i, j, text, k, l, identifier, pressAction);
}
public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
super.renderButton(context, mouseX, mouseY, delta);
int i = this.getX() + this.getWidth() - this.textureWidth - 2;
int j = this.getY() + this.getHeight() / 2 - this.textureHeight / 2;
context.drawTexture(this.texture, i, j, 0, 0, this.getWidth(), this.getHeight(), this.textureWidth, this.textureHeight);
}
public void drawMessage(DrawContext context, TextRenderer textRenderer, int color) {
int i = this.getX() + 2;
int j = this.getX() + this.getWidth() - this.textureWidth - 4;
int k = this.getX() + this.getWidth() / 2;
drawScrollableText(context, textRenderer, this.getMessage(), k, i, this.getY(), j, color);
}
}
@Environment(EnvType.CLIENT)
public static class IconOnly extends TextIconButtonWidget {
protected IconOnly(int i, int j, Text text, int k, int l, Identifier identifier, ButtonWidget.PressAction pressAction) {
super(i, j, text, k, l, identifier, pressAction);
}
public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
super.renderButton(context, mouseX, mouseY, delta);
int i = this.getX() + this.getWidth() / 2 - this.textureWidth / 2;
int j = this.getY() + this.getHeight() / 2 - this.textureHeight / 2;
context.drawTexture(this.texture, i, j, 0, 0, this.getWidth(), this.getHeight(), this.textureWidth, this.textureHeight);
}
public void drawMessage(DrawContext context, TextRenderer textRenderer, int color) {
}
}
}

View File

@@ -10,10 +10,10 @@
package eu.midnightdust.midnightcontrols.client.mixin;
import eu.midnightdust.midnightcontrols.client.gui.MidnightControlsSettingsScreen;
import eu.midnightdust.midnightcontrols.client.gui.widget.TextIconButtonWidget;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.ControlsOptionsScreen;
import net.minecraft.client.gui.screen.option.GameOptionsScreen;
import net.minecraft.client.gui.widget.TextIconButtonWidget;
import net.minecraft.client.option.GameOptions;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

View File

@@ -39,7 +39,7 @@ public abstract class GameRendererMixin {
MidnightControlsClient.get().input.onPreRenderScreen(this.client, this.client.currentScreen);
}
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;draw()V", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILSOFT)
private void renderVirtualCursor(float tickDelta, long startTime, boolean tick, CallbackInfo ci, boolean bl, MatrixStack matrixStack, DrawContext drawContext) {
private void renderVirtualCursor(float tickDelta, long startTime, boolean tick, CallbackInfo ci, MatrixStack matrixStack, DrawContext drawContext) {
MidnightControlsRenderer.renderVirtualCursor(drawContext, client);
drawContext.draw();
}

View File

@@ -15,7 +15,6 @@ import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import eu.midnightdust.midnightcontrols.client.touch.TouchInput;
import eu.midnightdust.midnightcontrols.client.enums.TouchMode;
import eu.midnightdust.midnightcontrols.client.util.RainbowColor;
import net.minecraft.block.ShapeContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.*;
@@ -95,7 +94,7 @@ public abstract class WorldRendererMixin {
if (this.world.getWorldBorder().contains(blockPos) && this.client.player != null) {
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);
if (MidnightControlsConfig.touchOutlineColorHex.isEmpty()) rgb = MidnightColorUtil.radialRainbow(1,1);
var pos = camera.getPos();
matrices.push();
var vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines());
@@ -130,7 +129,7 @@ public abstract class WorldRendererMixin {
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);
if (MidnightControlsConfig.reacharoundOutlineColorHex.isEmpty()) rgb = MidnightColorUtil.radialRainbow(1,1);
matrices.push();
var vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines());
drawCuboidShapeOutline(matrices, vertexConsumer, outlineShape,

View File

@@ -1,15 +0,0 @@
package eu.midnightdust.midnightcontrols.client.util;
import java.awt.*;
public class RainbowColor {
public static float hue;
public static void tick() {
if (hue > 1) hue = 0f;
hue = hue + 0.01f;
}
public static Color radialRainbow(float saturation, float brightness) {
return Color.getHSBColor(hue, saturation, brightness);
}
}