forked from Clones/Controlify
➕ Update to Minecraft 1.20
This commit is contained in:
@ -2,7 +2,6 @@ package dev.isxander.controlify.bindings;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.isxander.controlify.Controlify;
|
||||
import dev.isxander.controlify.api.bind.BindRenderer;
|
||||
import dev.isxander.controlify.api.bind.ControllerBinding;
|
||||
@ -18,6 +17,7 @@ import dev.isxander.controlify.controller.joystick.JoystickState;
|
||||
import dev.isxander.controlify.gui.DrawSize;
|
||||
import dev.isxander.yacl.api.Option;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@ -302,8 +302,8 @@ public class ControllerBindingImpl<T extends ControllerState> implements Control
|
||||
|
||||
private record BindRendererImpl(IBind<?> bind) implements BindRenderer {
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int x, int centerY) {
|
||||
bind.draw(poseStack, x, centerY);
|
||||
public void render(GuiGraphics graphics, int x, int centerY) {
|
||||
bind.draw(graphics, x, centerY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -514,7 +514,7 @@ public class ControllerBindings<T extends ControllerState> {
|
||||
|
||||
if (Controlify.instance().currentInputMode() != InputMode.CONTROLLER)
|
||||
return;
|
||||
if (Minecraft.getInstance().screen != null && !Minecraft.getInstance().screen.passEvents)
|
||||
if (Minecraft.getInstance().screen != null)
|
||||
return;
|
||||
|
||||
for (var binding : registry().values()) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package dev.isxander.controlify.bindings;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
import dev.isxander.controlify.controller.ControllerState;
|
||||
import dev.isxander.controlify.gui.DrawSize;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
public class EmptyBind<T extends ControllerState> implements IBind<T> {
|
||||
public static final String BIND_ID = "empty";
|
||||
@ -20,7 +20,7 @@ public class EmptyBind<T extends ControllerState> implements IBind<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(PoseStack matrices, int x, int centerY) {
|
||||
public void draw(GuiGraphics graphics, int x, int centerY) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,12 @@
|
||||
package dev.isxander.controlify.bindings;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
import dev.isxander.controlify.controller.gamepad.BuiltinGamepadTheme;
|
||||
import dev.isxander.controlify.controller.gamepad.GamepadController;
|
||||
import dev.isxander.controlify.controller.gamepad.GamepadState;
|
||||
import dev.isxander.controlify.gui.DrawSize;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -31,13 +29,9 @@ public class GamepadBind implements IBind<GamepadState> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(PoseStack matrices, int x, int centerY) {
|
||||
public void draw(GuiGraphics graphics, int x, int centerY) {
|
||||
ResourceLocation texture = getTexture(gamepad.config().theme);
|
||||
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
GuiComponent.blit(matrices, x, centerY - 22 / 2, 0, 0, 22, 22, 22, 22);
|
||||
graphics.blit(texture, x, centerY - 22 / 2, 0, 0, 22, 22, 22, 22);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,11 +1,11 @@
|
||||
package dev.isxander.controlify.bindings;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.isxander.controlify.controller.*;
|
||||
import dev.isxander.controlify.controller.gamepad.GamepadController;
|
||||
import dev.isxander.controlify.controller.joystick.SingleJoystickController;
|
||||
import dev.isxander.controlify.gui.DrawSize;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
public interface IBind<S extends ControllerState> {
|
||||
float state(S state);
|
||||
@ -13,7 +13,7 @@ public interface IBind<S extends ControllerState> {
|
||||
return state(state) > controller().config().buttonActivationThreshold;
|
||||
}
|
||||
|
||||
void draw(PoseStack matrices, int x, int centerY);
|
||||
void draw(GuiGraphics graphics, int x, int centerY);
|
||||
DrawSize drawSize();
|
||||
|
||||
JsonObject toJson();
|
||||
|
@ -1,8 +1,6 @@
|
||||
package dev.isxander.controlify.bindings;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
import dev.isxander.controlify.controller.joystick.JoystickController;
|
||||
import dev.isxander.controlify.controller.joystick.JoystickState;
|
||||
@ -10,7 +8,7 @@ import dev.isxander.controlify.controller.joystick.mapping.JoystickMapping;
|
||||
import dev.isxander.controlify.controller.joystick.mapping.UnmappedJoystickMapping;
|
||||
import dev.isxander.controlify.gui.DrawSize;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -38,7 +36,7 @@ public class JoystickAxisBind implements IBind<JoystickState> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(PoseStack matrices, int x, int centerY) {
|
||||
public void draw(GuiGraphics graphics, int x, int centerY) {
|
||||
JoystickMapping mapping = joystick.mapping();
|
||||
|
||||
String type = joystick.type().themeId();
|
||||
@ -46,14 +44,12 @@ public class JoystickAxisBind implements IBind<JoystickState> {
|
||||
String direction = mapping.axes()[axisIndex].getDirectionIdentifier(axisIndex, this.direction);
|
||||
var texture = new ResourceLocation("controlify", "textures/gui/joystick/" + type + "/axis_" + axis + "_" + direction + ".png");
|
||||
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
GuiComponent.blit(matrices, x, centerY - 11, 0, 0, 22, 22, 22, 22);
|
||||
graphics.blit(texture, x, centerY - 11, 0, 0, 22, 22, 22, 22);
|
||||
|
||||
if (mapping instanceof UnmappedJoystickMapping) {
|
||||
var text = Integer.toString(axisIndex + 1);
|
||||
var font = Minecraft.getInstance().font;
|
||||
GuiComponent.drawCenteredString(matrices, font, text, x + 11, centerY - font.lineHeight / 2, 0xFFFFFF);
|
||||
graphics.drawCenteredString(font, text, x + 11, centerY - font.lineHeight / 2, 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
package dev.isxander.controlify.bindings;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
import dev.isxander.controlify.controller.joystick.JoystickController;
|
||||
import dev.isxander.controlify.controller.joystick.JoystickState;
|
||||
import dev.isxander.controlify.gui.DrawSize;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -29,14 +27,12 @@ public class JoystickButtonBind implements IBind<JoystickState> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(PoseStack matrices, int x, int centerY) {
|
||||
public void draw(GuiGraphics graphics, int x, int centerY) {
|
||||
String type = joystick.type().themeId();
|
||||
String button = joystick.mapping().buttons()[buttonIndex].identifier();
|
||||
var texture = new ResourceLocation("controlify", "textures/gui/joystick/" + type + "/button_" + button + ".png");
|
||||
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
GuiComponent.blit(matrices, x, centerY - 11, 0, 0, 22, 22, 22, 22);
|
||||
graphics.blit(texture, x, centerY - 11, 0, 0, 22, 22, 22, 22);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,13 +1,11 @@
|
||||
package dev.isxander.controlify.bindings;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
import dev.isxander.controlify.controller.joystick.JoystickController;
|
||||
import dev.isxander.controlify.controller.joystick.JoystickState;
|
||||
import dev.isxander.controlify.gui.DrawSize;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -31,7 +29,7 @@ public class JoystickHatBind implements IBind<JoystickState> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(PoseStack matrices, int x, int centerY) {
|
||||
public void draw(GuiGraphics graphics, int x, int centerY) {
|
||||
String type = joystick.type().themeId();
|
||||
String hat = joystick.mapping().hats()[hatIndex].identifier();
|
||||
String direction = "centered";
|
||||
@ -45,10 +43,7 @@ public class JoystickHatBind implements IBind<JoystickState> {
|
||||
direction = "right";
|
||||
|
||||
var texture = new ResourceLocation("controlify", "textures/gui/joystick/" + type + "/hat" + hat + "_" + direction + ".png");
|
||||
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
GuiComponent.blit(matrices, x, centerY - 11, 0, 0, 22, 22, 22, 22);
|
||||
graphics.blit(texture, x, centerY - 11, 0, 0, 22, 22, 22, 22);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user