mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 15:25:08 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43ffd89a61 | ||
|
|
8a9866f92f | ||
|
|
b12413cbcd | ||
|
|
9f62538197 | ||
|
|
ba5143403d | ||
|
|
454afa92ec |
16
.github/ISSUE_TEMPLATE/bug_report.md
vendored
16
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
title: 'Bug: TITLE HERE'
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
@@ -21,15 +21,17 @@ Steps to reproduce the behavior:
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
If applicable, add screenshots or videos to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. Linux]
|
||||
- Minecraft [e.g. 1.14.4]
|
||||
- Fabric [e.g. fabric 0.7.2+build.174]
|
||||
- Mods [e.g. aurora_keystrokes v1.0.0, modmenu v1.7.15]
|
||||
- OS: [e.g. Windows / Linux / MacOS]
|
||||
- Minecraft [e.g. 1.20.4]
|
||||
- Modloader [e.g. Fabric Loader 0.15.6]
|
||||
- Fabric/Quilt Libraries [e.g. Fabric Api 0.96.1+1.20.4]
|
||||
- Mods [e.g. Puzzle v1.6.1, LilTaterReloaded v1.1.15]
|
||||
- Version [e.g. 1.0.0]
|
||||
- Branch [e.g. dev]
|
||||
- Remove this line if you actually completed it
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
In case of a crash, please provide the crash log.
|
||||
|
||||
40
.github/ISSUE_TEMPLATE/controller_support.md
vendored
Normal file
40
.github/ISSUE_TEMPLATE/controller_support.md
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
name: Controller support
|
||||
about: Report a problem related to a specific controller
|
||||
title: 'Controller Issues: CONTROLLER NAME HERE'
|
||||
labels: controller
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the current state**
|
||||
A clear and concise description of current state of support for the controller and the issues.
|
||||
|
||||
**To Reproduce**
|
||||
If needed, specify steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots or videos to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- Have you checked #263 for your controller? [e.g. Yes/No]
|
||||
- Connection method [e.g. Wired / Bluetooth]
|
||||
|
||||
- OS: [e.g. Windows / Linux / MacOS]
|
||||
- Minecraft [e.g. 1.20.4]
|
||||
- Modloader [e.g. Fabric Loader 0.15.6]
|
||||
- Fabric/Quilt Libraries [e.g. Fabric Api 0.96.1+1.20.4]
|
||||
- Mods [e.g. Puzzle v1.6.1, LilTaterReloaded v1.1.15]
|
||||
- Version [e.g. 1.0.0]
|
||||
- Remove this line if you actually completed it
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
In case of a crash, please provide the crash log.
|
||||
4
.github/ISSUE_TEMPLATE/feature_request.md
vendored
4
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
title: 'Feature: TITLE HERE'
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
@@ -17,4 +17,4 @@ A clear and concise description of what you want to happen.
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
Add any other context or screenshots/videos about the feature request here.
|
||||
|
||||
20
.github/ISSUE_TEMPLATE/mod_support.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/mod_support.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Mod Support
|
||||
about: Compatibility improvements with a specific mod (not for crashes)
|
||||
title: 'Mod Support: MOD NAME HERE'
|
||||
labels: mod compatibility
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your compatibility request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I've always wanted to [...]
|
||||
|
||||
**Describe the way of compatibility you'd imagine**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative mods or workarounds you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots/videos about the compatibility request here.
|
||||
@@ -64,11 +64,7 @@ After this is done, everything should be built just fine!
|
||||
|
||||
## FAQ:
|
||||
### The controller does not work, and it's name appears in orange, what can I do?
|
||||
Orange controller names indicate a missing controller mapping.
|
||||
Download [GamepadTool](https://generalarcade.com/gamepadtool/), create and copy a mapping, go to MidnightControls' Mappings File Editor and paste the string.
|
||||
Alternatively, you can use [AntiMicroX](https://github.com/AntiMicroX/antimicroX) to create the mappings, in case the Gamepad Tool is not working for you.
|
||||
If that works, you might as well consider submitting the mapping by opening a PR in this repo: https://github.com/gabomdq/SDL_GameControllerDB
|
||||
That will make sure other people using the same controller as you don't have to use gamepad-tool anymore.
|
||||
Create a custom mapping as pointed out in the [wiki](https://midnightdust.eu/wiki/midnightcontrols/)
|
||||
|
||||
[Quilt]: https://quiltmc.org
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
minecraft_version=1.20.1
|
||||
yarn_mappings=1.20.1+build.10
|
||||
loader_version=0.15.6
|
||||
minecraft_version=1.20.4
|
||||
yarn_mappings=1.20.4+build.3
|
||||
loader_version=0.15.3
|
||||
|
||||
# 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.0+1.20.1
|
||||
fabric_version=0.91.3+1.20.4
|
||||
sodium_version=mc1.19.2-0.4.4
|
||||
spruceui_version=5.0.0+1.20
|
||||
midnightlib_version=1.4.1-fabric
|
||||
spruceui_version=5.0.3+1.20.4
|
||||
midnightlib_version=1.5.3-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.1+fabric
|
||||
emi_version=1.1.1+1.20.4+fabric
|
||||
libgui_version=6.0.0+1.19
|
||||
inventorytabs_version=inventorytabs-0.9.beta-1.19.x
|
||||
clothconfig_version=7.0.72
|
||||
|
||||
@@ -28,6 +28,7 @@ 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;
|
||||
@@ -228,6 +229,7 @@ public class MidnightControlsClient extends MidnightControls implements ClientMo
|
||||
MidnightControlsConfig.enableHints = false;
|
||||
MidnightControlsConfig.save();
|
||||
}
|
||||
RainbowColor.tick();
|
||||
TouchInput.tick();
|
||||
}
|
||||
|
||||
|
||||
@@ -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, -value);
|
||||
creativeInventoryScreen.mouseScrolled(0.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, -(value * 1.5f));
|
||||
merchantScreen.mouseScrolled(0.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, -(value * 1.5f));
|
||||
stonecutterScreen.mouseScrolled(0.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, -finalValue);
|
||||
element.mouseScrolled(0.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, -finalValue);
|
||||
element.mouseScrolled(0.0, 0.0, 0, -finalValue);
|
||||
return true;
|
||||
}))
|
||||
{
|
||||
client.currentScreen.mouseScrolled(0.0, 0.0, -(value * 1.5f));
|
||||
client.currentScreen.mouseScrolled(0.0, 0.0, 0, -(value * 1.5f));
|
||||
}
|
||||
else if (isScreenInteractive(client.currentScreen) && absValue >= deadZone) {
|
||||
if (value > 0 && joystickCooldown == 0) {
|
||||
|
||||
@@ -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.options.debugEnabled = !client.options.debugEnabled; return true;}).cooldown().register();
|
||||
.action((client,binding,value,action) -> {if (action == ButtonState.PRESS) client.inGameHud.getDebugHud().toggleDebugHud(); 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)
|
||||
@@ -88,7 +88,7 @@ public class ButtonBinding {
|
||||
public static final ButtonBinding SNEAK = new Builder("sneak").buttons(GLFW_GAMEPAD_BUTTON_RIGHT_THUMB)
|
||||
.actions(InputHandlers::handleToggleSneak).onlyInGame().cooldown().register();
|
||||
public static final ButtonBinding SPRINT = new Builder("sprint").buttons(GLFW_GAMEPAD_BUTTON_LEFT_THUMB)
|
||||
.actions(InputHandlers::handleToggleSprint).onlyInGame().register();
|
||||
.actions(InputHandlers::handleToggleSprint).onlyInGame().cooldown().register();
|
||||
public static final ButtonBinding SWAP_HANDS = new Builder("swap_hands").buttons(GLFW_GAMEPAD_BUTTON_X).onlyInGame().cooldown().register();
|
||||
public static final ButtonBinding TAB_LEFT = new Builder("tab_back").buttons(GLFW_GAMEPAD_BUTTON_LEFT_BUMPER)
|
||||
.action(InputHandlers.handleHotbar(false)).filter(Predicates.or(InputHandlers::inInventory, InputHandlers::inAdvancements).or((client, binding) -> client.currentScreen != null)).cooldown().register();
|
||||
|
||||
@@ -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(), true);
|
||||
screen.getAdvancementManager().selectTab(tabs.get(nextTab).getRoot().getAdvancementEntry(), 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.openPauseMenu(false);
|
||||
client.openGameMenu(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.
|
||||
@@ -320,12 +320,12 @@ public class InputHandlers {
|
||||
boolean sprintToggled = client.options.getSprintToggled().getValue();
|
||||
if (client.player.getAbilities().flying && sprintToggled)
|
||||
client.options.getSprintToggled().setValue(false);
|
||||
else if (MidnightControlsConfig.controllerToggleSneak != sprintToggled)
|
||||
else if (MidnightControlsConfig.controllerToggleSprint != sprintToggled)
|
||||
client.options.getSprintToggled().setValue(!sprintToggled);
|
||||
binding.setPressed(button.pressed);
|
||||
if (client.player.getAbilities().flying && sprintToggled)
|
||||
client.options.getSprintToggled().setValue(true);
|
||||
else if (MidnightControlsConfig.controllerToggleSneak != sprintToggled)
|
||||
else if (MidnightControlsConfig.controllerToggleSprint != sprintToggled)
|
||||
client.options.getSprintToggled().setValue(sprintToggled);
|
||||
});
|
||||
return true;
|
||||
|
||||
@@ -20,7 +20,6 @@ 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;
|
||||
@@ -28,7 +27,10 @@ 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;
|
||||
@@ -82,7 +84,7 @@ public class TouchscreenOverlay extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackground(DrawContext context) {}
|
||||
public void renderInGameBackground(DrawContext context) {}
|
||||
|
||||
private void pauseGame() {
|
||||
assert this.client != null;
|
||||
@@ -288,11 +290,12 @@ 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.getTextureManager().getOrDefault(new Identifier(MidnightControlsConstants.NAMESPACE, "binding/"+bindName), null) != null;
|
||||
boolean hasTexture = client.getGuiAtlasManager().getSprite(new Identifier(MidnightControlsConstants.NAMESPACE, "binding/"+bindName)) != missingSprite;
|
||||
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();
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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, MatrixStack matrixStack, DrawContext drawContext) {
|
||||
private void renderVirtualCursor(float tickDelta, long startTime, boolean tick, CallbackInfo ci, boolean bl, MatrixStack matrixStack, DrawContext drawContext) {
|
||||
MidnightControlsRenderer.renderVirtualCursor(drawContext, client);
|
||||
drawContext.draw();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ 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.*;
|
||||
@@ -94,7 +95,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 = MidnightColorUtil.radialRainbow(1,1);
|
||||
if (MidnightControlsConfig.touchOutlineColorHex.isEmpty()) rgb = RainbowColor.radialRainbow(1,1);
|
||||
var pos = camera.getPos();
|
||||
matrices.push();
|
||||
var vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines());
|
||||
@@ -129,7 +130,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 = MidnightColorUtil.radialRainbow(1,1);
|
||||
if (MidnightControlsConfig.reacharoundOutlineColorHex.isEmpty()) rgb = RainbowColor.radialRainbow(1,1);
|
||||
matrices.push();
|
||||
var vertexConsumer = this.bufferBuilders.getEntityVertexConsumers().getBuffer(RenderLayer.getLines());
|
||||
drawCuboidShapeOutline(matrices, vertexConsumer, outlineShape,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user