MidnightControls 0.2.0 - Fixes, improvements, compat

- Fix #4
- Fix #3 (maybe?)
- No longer break OptiFabric
- Better XBox controller icons (#7) by @Ivanoks
- Start of reimplementing REI compat
- Hide HUD when controller is missing
This commit is contained in:
Motschen
2022-05-03 12:22:20 +02:00
parent 28d92a65d4
commit 0226bfc62f
18 changed files with 168 additions and 119 deletions

View File

@@ -26,10 +26,10 @@ import java.util.Objects;
import java.util.Optional;
/**
* Represents the midnightcontrols mod.
* Represents the MidnightControls mod.
*
* @author LambdAurora
* @version 1.7.0
* @author LambdAurora & Motschen
* @version 1.8.0
* @since 1.0.0
*/
public class MidnightControls implements ModInitializer {
@@ -40,12 +40,12 @@ public class MidnightControls implements ModInitializer {
public static final TranslatableText NOT_BOUND_TEXT = new TranslatableText("midnightcontrols.not_bound");
public final Logger logger = LogManager.getLogger("midnightcontrols");
public final Logger logger = LogManager.getLogger("MidnightControls");
@Override
public void onInitialize() {
INSTANCE = this;
this.log("Initializing midnightcontrols...");
this.log("Initializing MidnightControls...");
ServerPlayNetworking.registerGlobalReceiver(HELLO_CHANNEL, (server, player, handler, buf, responseSender) -> {
String version = buf.readString(32);
@@ -68,7 +68,7 @@ public class MidnightControls implements ModInitializer {
* @param info the message to print
*/
public void log(String info) {
this.logger.info("[midnightcontrols] " + info);
this.logger.info("[MidnightControls] " + info);
}
/**
@@ -77,7 +77,7 @@ public class MidnightControls implements ModInitializer {
* @param warning the warning to print
*/
public void warn(String warning) {
this.logger.info("[midnightcontrols] " + warning);
this.logger.info("[MidnightControls] " + warning);
}
/**
@@ -119,9 +119,9 @@ public class MidnightControls implements ModInitializer {
}
/**
* Gets the midnightcontrols instance.
* Gets the MidnightControls instance.
*
* @return the midnightcontrols instance
* @return the MidnightControls instance
*/
public static MidnightControls get() {
return INSTANCE;

View File

@@ -13,7 +13,7 @@ package eu.midnightdust.midnightcontrols;
import net.minecraft.util.Identifier;
/**
* Represents the constants used by midnightcontrols.
* Represents the constants used by MidnightControls.
*
* @author LambdAurora
* @version 1.1.0

View File

@@ -46,7 +46,6 @@ public class MidnightControlsConfig extends MidnightConfig {
@Entry public static int[] reacharoundOutlineColor = new int[]{255, 255, 255, 102};
// Controller
@Entry public static ControllerType controllerType = ControllerType.DEFAULT;
//private static final double DEFAULT_DEAD_ZONE = 0.25;
@Entry public static double rightDeadZone = 0.25;
@Entry public static double leftDeadZone = 0.25;
@Entry public static boolean invertRightYAxis = false;
@@ -124,7 +123,7 @@ public class MidnightControlsConfig extends MidnightConfig {
if (raw instanceof Number) {
if (((Number) raw).intValue() == -1)
return Optional.empty();
return Optional.of(Controller.byId((Integer) raw));
return Optional.of(Controller.byId(((Number) raw).intValue()));
} else if (raw instanceof String) {
return Optional.of(Controller.byGuid((String) raw).orElse(Controller.byId(GLFW.GLFW_JOYSTICK_1)));
}

View File

@@ -70,7 +70,7 @@ import static org.lwjgl.glfw.GLFW.*;
public class MidnightInput {
private static final Map<Integer, Integer> BUTTON_COOLDOWNS = new HashMap<>();
// Cooldowns
private int actionGuiCooldown = 0;
public int actionGuiCooldown = 0;
private boolean ignoreNextARelease = false;
private double targetYaw = 0.0;
private double targetPitch = 0.0;

View File

@@ -13,9 +13,7 @@ import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import io.github.kosmx.emotes.arch.gui.screen.ingame.FastChosseScreen;
import io.github.kosmx.emotes.main.network.ClientEmotePlay;
import net.minecraft.client.gui.screen.Screen;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;
/**
* Represents a compatibility handler for Emotecraft.

View File

@@ -31,7 +31,7 @@ import java.util.stream.Stream;
* @since 1.1.0
*/
public class MidnightControlsCompat {
private static final List<CompatHandler> HANDLERS = new ArrayList<>();
public static final List<CompatHandler> HANDLERS = new ArrayList<>();
/**
* Initializes compatibility with other mods if needed.

View File

@@ -36,7 +36,7 @@ public class MidnightControlsMixinPlugin implements IMixinConfigPlugin {
}
private void putConditionalMixin(@NotNull String path, boolean condition) {
this.conditionalMixins.put("me.lambdaurora.midnightcontrols.client.compat.mixin." + path, condition);
this.conditionalMixins.put("eu.midnightdust.midnightcontrols.client.compat.mixin." + path, condition);
}
@Override

View File

@@ -11,15 +11,39 @@ package eu.midnightdust.midnightcontrols.client.compat;
import eu.midnightdust.midnightcontrols.client.ButtonState;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.compat.mixin.EntryListWidgetAccessor;
import eu.midnightdust.midnightcontrols.client.compat.mixin.EntryWidgetAccessor;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import eu.midnightdust.midnightcontrols.client.controller.InputHandlers;
import eu.midnightdust.midnightcontrols.client.controller.PressAction;
import me.shedaniel.rei.RoughlyEnoughItemsCoreClient;
import me.shedaniel.rei.impl.client.ClientHelperImpl;
import me.shedaniel.rei.impl.client.REIRuntimeImpl;
import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
import me.shedaniel.rei.impl.client.gui.screen.CompositeDisplayViewingScreen;
import me.shedaniel.rei.impl.client.gui.screen.DefaultDisplayViewingScreen;
import me.shedaniel.rei.impl.client.gui.widget.EntryListEntryWidget;
import me.shedaniel.rei.impl.client.gui.widget.EntryWidget;
import me.shedaniel.rei.impl.client.registry.screen.ScreenRegistryImpl;
import me.shedaniel.rei.impl.common.entry.AbstractEntryStack;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.EntryListWidget;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import org.aperlambda.lambdacommon.utils.LambdaReflection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Optional;
import static eu.midnightdust.midnightcontrols.client.compat.CompatHandler.SlotPos.INVALID_SLOT;
import static org.lwjgl.glfw.GLFW.*;
/**
@@ -30,11 +54,11 @@ import static org.lwjgl.glfw.GLFW.*;
* @since 1.2.0
*/
public class ReiCompat implements CompatHandler {
//private static EntryListWidget ENTRY_LIST_WIDGET;
private static EntryListWidget ENTRY_LIST_WIDGET;
@Override
public void handle(@NotNull MidnightControlsClient mod) {
ButtonBinding.builder(new Identifier("rei", "category_back"))
/*ButtonBinding.builder(new Identifier("rei", "category_back"))
.buttons(GLFW_GAMEPAD_BUTTON_LEFT_BUMPER)
.filter((client, binding) -> isViewingScreen(client.currentScreen))
.action(handleTab(false))
@@ -87,38 +111,40 @@ public class ReiCompat implements CompatHandler {
.action(handleShowRecipeUsage(false))
.cooldown(true)
.register();
*/
}
/*
@Override
public boolean requireMouseOnScreen(Screen screen) {
return isViewingScreen(screen) /*|| screen instanceof PreRecipeViewingScreen*/;
return isViewingScreen(screen);
}
@Override
public @Nullable SlotPos getSlotAt(@NotNull Screen screen, int mouseX, int mouseY) {
/*var overlay = ScreenHelper.getOptionalOverlay();
if (overlay.isPresent() && overlay.get().isInside(mouseX, mouseY)) {
var widget = getEntryListWidget();
public @Nullable CompatHandler.SlotPos getSlotAt(@NotNull Screen screen, int mouseX, int mouseY) {
ScreenOverlayImpl overlay = ScreenOverlayImpl.getInstance();
if (overlay.isInside(mouseX, mouseY)) {
EntryListWidget widget = getEntryListWidget();
if (widget == null)
return null;
var slot = this.getSlotAt(widget, mouseX, mouseY, false);
if (slot != null && slot != INVALID_SLOT)
return slot;
return this.getSlotAt(widget, mouseX, mouseY, false);
} else if (isViewingScreen(screen)) {
for (var element : screen.children()) {
for (Element element : screen.children()) {
var slot = this.getSlotAt(element, mouseX, mouseY, true);
if (slot != null && slot != INVALID_SLOT)
if (slot != null)
return slot;
}
}*/
}
return null;
}
/*private @Nullable SlotPos getSlotAt(@NotNull Element element, int mouseX, int mouseY, boolean allowEmpty) {
if (element instanceof EntryWidget entry) {
private @Nullable CompatHandler.SlotPos getSlotAt(@NotNull Element element, int mouseX, int mouseY, boolean allowEmpty) {
if (element instanceof EntryWidget) {
EntryWidget entry = (EntryWidget) element;
if (entry.containsMouse(mouseX, mouseY)) {
if (!allowEmpty && entry.entries().isEmpty())
if (!allowEmpty && entry.getEntries().isEmpty())
return INVALID_SLOT;
return new SlotPos(entry.getBounds().getX() + 1, entry.getBounds().getY() + 1);
}
@@ -137,11 +163,10 @@ public class ReiCompat implements CompatHandler {
}
}
return null;
}*/
}
private static boolean isViewingScreen(Screen screen) {
return true;
//return screen instanceof DefaultDisplayViewingScreen || screen instanceof CompositeDisplayViewingScreen;
return screen instanceof DefaultDisplayViewingScreen || screen instanceof CompositeDisplayViewingScreen;
}
@Override
@@ -149,12 +174,12 @@ public class ReiCompat implements CompatHandler {
if (!isViewingScreen(screen))
return false;
/*MinecraftClient.getInstance().openScreen(REIRuntimeImpl.getInstance().getPreviousContainerScreen());
ScreenHelper.getLastOverlay().init();*/
MinecraftClient.getInstance().setScreen(REIRuntimeImpl.getInstance().getPreviousContainerScreen());
REIRuntimeImpl.getInstance().getLastOverlay().init();
return true;
}
/*private static EntryListWidget getEntryListWidget() {
private static EntryListWidget getEntryListWidget() {
if (ENTRY_LIST_WIDGET == null) {
ENTRY_LIST_WIDGET = LambdaReflection.getFirstFieldOfType(ContainerScreenOverlay.class, EntryListWidget.class)
.map(field -> (EntryListWidget) LambdaReflection.getFieldValue(null, field))
@@ -163,55 +188,56 @@ public class ReiCompat implements CompatHandler {
return ENTRY_LIST_WIDGET;
}
private static @Nullable EntryStack getCurrentStack(@NotNull MinecraftClient client) {
private static @Nullable AbstractEntryStack getCurrentStack(@NotNull MinecraftClient client) {
double x = client.mouse.getX() * (double) client.getWindow().getScaledWidth() / (double) client.getWindow().getWidth();
double y = client.mouse.getY() * (double) client.getWindow().getScaledHeight() / (double) client.getWindow().getHeight();
if (isViewingScreen(client.currentScreen)) {
for (var element : client.currentScreen.children()) {
var stack = getCurrentStack(element, x, y);
for (Element element : client.currentScreen.children()) {
EntryStack stack = getCurrentStack(element, x, y);
if (stack != null)
return stack;
}
}
var overlay = ScreenHelper.getOptionalOverlay();
Optional<ContainerScreenOverlay> overlay = REIRuntimeImpl.getInstance().getOverlay(false,false);
if (!overlay.isPresent())
return RecipeHelper.getInstance().getScreenFocusedStack(client.currentScreen);
var widget = getEntryListWidget();
EntryListWidget widget = getEntryListWidget();
if (widget == null)
return RecipeHelper.getInstance().getScreenFocusedStack(client.currentScreen);
return ScreenOverlayImpl.getInstance().getInstance().getOverlayMenu()..getScreenFocusedStack(client.currentScreen);
return getCurrentStack(widget, x, y);
}
private static @Nullable EntryStack getCurrentStack(@NotNull Element element, double mouseX, double mouseY) {
if (element instanceof EntryWidget entry) {
if (element instanceof EntryWidget) {
EntryWidget entry = (EntryWidget) element;
if (entry.containsMouse(mouseX, mouseY))
return ((EntryWidgetAccessor) entry).midnightcontrols_getCurrentEntry();
return ((EntryWidgetAccessor) entry).lambdacontrols_getCurrentEntry();
} else if (element instanceof EntryListWidget) {
var entries = ((EntryListWidgetAccessor) element).getEntries();
List<EntryListEntryWidget> entries = ((EntryListWidgetAccessor) element).getEntries();
for (EntryListEntryWidget entry : entries) {
if (entry.containsMouse(mouseX, mouseY)) {
return ((EntryWidgetAccessor) entry).midnightcontrols_getCurrentEntry();
return ((EntryWidgetAccessor) entry).lambdacontrols_getCurrentEntry();
}
}
} else if (!(element instanceof ButtonWidget) && element instanceof WidgetWithBounds widgetWithBounds) {
for (var child : widgetWithBounds.children()) {
var stack = getCurrentStack(child, mouseX, mouseY);
} else if (!(element instanceof ButtonWidget) && element instanceof WidgetWithBounds) {
for (Element child : ((WidgetWithBounds) element).children()) {
EntryStack stack = getCurrentStack(child, mouseX, mouseY);
if (stack != null)
return stack;
}
}
return null;
}*/
}
private static PressAction handleShowRecipeUsage(boolean usage) {
return (client, button, value, action) -> {
if (action.isUnpressed())
return false;
/*EntryStack stack = RecipeHelper.getInstance().getScreenFocusedStack(client.currentScreen);
EntryStack stack = RecipeHelper.getInstance().getScreenFocusedStack(client.currentScreen);
if (stack == null) {
stack = getCurrentStack(client);
}
@@ -223,7 +249,7 @@ public class ReiCompat implements CompatHandler {
} else {
return ClientHelper.getInstance().openView(ClientHelper.ViewSearchBuilder.builder().addRecipesFor(stack).setOutputNotice(stack).fillPreferredOpenedCategory());
}
}*/
}
return false;
};
@@ -234,11 +260,11 @@ public class ReiCompat implements CompatHandler {
if (action == ButtonState.RELEASE)
return false;
/*Optional<ContainerScreenOverlay> overlay = ScreenHelper.getOptionalOverlay();
Optional<ContainerScreenOverlay> overlay = ScreenHelper.getOptionalOverlay();
if (!overlay.isPresent())
return false;
var widget = getEntryListWidget();
EntryListWidget widget = getEntryListWidget();
if (widget == null)
return false;
@@ -246,7 +272,7 @@ public class ReiCompat implements CompatHandler {
widget.nextPage();
else
widget.previousPage();
widget.updateEntriesPosition();*/
widget.updateEntriesPosition();
return true;
};
@@ -258,27 +284,28 @@ public class ReiCompat implements CompatHandler {
* @param next True if the action is to switch to the next tab.
* @return The handler.
*/
/*
private static PressAction handleTab(boolean next) {
return (client, button, value, action) -> {
if (action != ButtonState.RELEASE)
return false;
/*if (client.currentScreen instanceof DefaultDisplayViewingScreen) {
if (client.currentScreen instanceof RecipeViewingScreen) {
RecipeViewingScreenAccessor screen = (RecipeViewingScreenAccessor) client.currentScreen;
if (next)
screen.getCategoryNext().onClick();
else
screen.getCategoryBack().onClick();
return true;
} else if (client.currentScreen instanceof CompositeDisplayViewingScreen) {
} else if (client.currentScreen instanceof VillagerRecipeViewingScreen) {
VillagerRecipeViewingScreenAccessor screen = (VillagerRecipeViewingScreenAccessor) client.currentScreen;
List<RecipeCategory<?>> categories = screen.getCategories();
int currentTab = screen.getSelectedCategoryIndex();
screen.setSelectedCategoryIndex(getNextIndex(currentTab, categories.size(), next));
screen.setSelectedRecipeIndex(0);
screen.midnightcontrols_init();
screen.lambdacontrols_init();
return true;
}*/
}
return false;
};
}
@@ -288,13 +315,15 @@ public class ReiCompat implements CompatHandler {
if (action.isUnpressed())
return false;
/*if (client.currentScreen instanceof RecipeViewingScreenAccessor screen) {
if (client.currentScreen instanceof RecipeViewingScreen) {
RecipeViewingScreenAccessor screen = (RecipeViewingScreenAccessor) client.currentScreen;
if (next)
screen.getRecipeNext().onClick();
else
screen.getRecipeBack().onClick();
return true;
} else if (client.currentScreen instanceof VillagerRecipeViewingScreenAccessor screen) {
} else if (client.currentScreen instanceof VillagerRecipeViewingScreen) {
VillagerRecipeViewingScreenAccessor screen = (VillagerRecipeViewingScreenAccessor) client.currentScreen;
List<RecipeCategory<?>> categories = screen.getCategories();
int currentTab = screen.getSelectedCategoryIndex();
List<RecipeDisplay> recipes = screen.getCategoryMap().get(categories.get(currentTab));
@@ -315,10 +344,10 @@ public class ReiCompat implements CompatHandler {
}
screen.setSelectedRecipeIndex(nextRecipe);
screen.midnightcontrols_init();
screen.lambdacontrols_init();
return true;
}*/
}
return false;
};
@@ -332,4 +361,5 @@ public class ReiCompat implements CompatHandler {
nextIndex = 0;
return nextIndex;
}
}
*/
}

View File

@@ -9,6 +9,13 @@
package eu.midnightdust.midnightcontrols.client.compat.mixin;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.widget.EntryListWidget;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
/**
* Represents an accessor to REI's EntryListWidget.
*
@@ -16,8 +23,8 @@ package eu.midnightdust.midnightcontrols.client.compat.mixin;
* @version 1.5.0
* @since 1.5.0
*/
//@Mixin(value = EntryListWidget.class, remap = false)
@Mixin(value = EntryListWidget.class, remap = false)
public interface EntryListWidgetAccessor {
/*@Accessor(value = "entries")
List<EntryListEntryWidget> getEntries();*/
@Accessor(value = "children")
List<Element> getEntries();
}

View File

@@ -14,6 +14,7 @@ import eu.midnightdust.midnightcontrols.MidnightControlsConstants;
import eu.midnightdust.midnightcontrols.client.HudSide;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
import eu.midnightdust.midnightcontrols.client.MidnightInput;
import eu.midnightdust.midnightcontrols.client.compat.MidnightControlsCompat;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import dev.lambdaurora.spruceui.hud.Hud;
@@ -77,7 +78,7 @@ public class MidnightControlsHud extends Hud {
*/
@Override
public void render(MatrixStack matrices, float tickDelta) {
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && this.client.currentScreen == null) {
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && this.client.currentScreen == null && MidnightControlsConfig.getController().isConnected() && MidnightControlsConfig.getController().isGamepad()) {
int y = bottom(2);
this.renderFirstIcons(matrices, MidnightControlsConfig.hudSide == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y);
this.renderSecondIcons(matrices, MidnightControlsConfig.hudSide == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y);

View File

@@ -9,6 +9,10 @@
package eu.midnightdust.midnightcontrols.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import dev.lambdaurora.spruceui.background.Background;
import dev.lambdaurora.spruceui.widget.SpruceWidget;
import eu.midnightdust.lib.util.MidnightColorUtil;
import eu.midnightdust.midnightcontrols.MidnightControls;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.MidnightControlsConfig;
@@ -27,6 +31,7 @@ import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.render.*;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
@@ -35,8 +40,11 @@ import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Util;
import net.minecraft.util.math.Matrix4f;
import org.lwjgl.glfw.GLFW;
import java.awt.*;
/**
* Represents the midnightcontrols settings screen.
*/
@@ -158,7 +166,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
ClientPlayNetworking.getSender().sendPacket(MidnightControls.CONTROLS_MODE_CHANNEL, this.mod.makeControlsModeBuffer(next));
}
}, option -> option.getDisplayText(new TranslatableText(MidnightControlsConfig.controlsMode.getTranslationKey())),
new TranslatableText("midnightcontrols.tooltip.controls_mode"));
new TranslatableText("midnightcontrols.tooltip.controlsMidnightColorUtil.radialRainbow(1f,1f);_mode"));
this.autoSwitchModeOption = new SpruceToggleBooleanOption("midnightcontrols.menu.auto_switch_mode", () -> MidnightControlsConfig.autoSwitchMode,
value -> MidnightControlsConfig.autoSwitchMode = value, new TranslatableText("midnightcontrols.tooltip.auto_switch_mode"));
this.rotationSpeedOption = new SpruceDoubleOption("midnightcontrols.menu.rotation_speed", 0.0, 100.0, .5f,
@@ -262,6 +270,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
var tabs = new SpruceTabbedWidget(Position.of(0, 24), this.width, this.height - 32 - 24,
null,
Math.max(116, this.width / 8), 0);
tabs.getList().setBackground(new MidnightControlsBackground());
this.addDrawableChild(tabs);
tabs.addSeparatorEntry(new TranslatableText("midnightcontrols.menu.separator.general"));
@@ -368,4 +377,35 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
public void renderTitle(MatrixStack matrices, int mouseX, int mouseY, float delta) {
drawCenteredText(matrices, this.textRenderer, I18n.translate("midnightcontrols.menu.title"), this.width / 2, 8, 16777215);
}
public static class MidnightControlsBackground implements Background {
@Override
public void render(MatrixStack matrixStack, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
fill(matrixStack, widget.getX(), widget.getY(), widget.getX() + widget.getWidth(), widget.getY() + widget.getHeight(), MidnightColorUtil.hex2Rgb("#000000"));
}
private void fill(MatrixStack matrixStack, int x2, int y2, int x1, int y1, Color color) {
matrixStack.push();
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
float r = (float)(color.getRed()) / 255.0F;
float g = (float)(color.getGreen()) / 255.0F;
float b = (float)(color.getBlue()) / 255.0F;
float t = (float)(160) / 255.0F;
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
RenderSystem.enableBlend();
RenderSystem.disableTexture();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(matrix, (float)x1, (float)y2, 0.0F).color(r, g, b, t).next();
bufferBuilder.vertex(matrix, (float)x2, (float)y2, 0.0F).color(r, g, b, t).next();
bufferBuilder.vertex(matrix, (float)x2, (float)y1, 0.0F).color(r, g, b, t).next();
bufferBuilder.vertex(matrix, (float)x1, (float)y1, 0.0F).color(r, g, b, t).next();
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
matrixStack.pop();
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -9,8 +9,8 @@
"Motschen"
],
"contact": {
"homepage": "https://github.com/TeamMidnightDust/MidnightControls",
"sources": "https://github.com/TeamMidnightDust/MidnightControls.git",
"homepage": "https://modrinth.com/mod/midnightcontrols",
"sources": "https://github.com/TeamMidnightDust/MidnightControls",
"issues": "https://github.com/TeamMidnightDust/MidnightControls/issues"
},
"license": "MIT",
@@ -37,17 +37,16 @@
"fabric": ">=0.36.0",
"minecraft": ">=1.17",
"spruceui": ">=3.2.0",
"java": ">=16"
"java": ">=17"
},
"recommends": {
"modmenu": ">=1.12.2"
},
"suggests": {
"flamingo": "*"
"quilt_loader": "*"
},
"breaks": {
"lambdacontrols": "*",
"modmenu": "<1.12.2",
"optifabric": "*"
"modmenu": "<1.12.2"
}
}

View File

@@ -1,6 +1,6 @@
{
"required": true,
"package": "dev.lambdaurora.midnightcontrols.client.compat.mixin",
"package": "eu.midnightdust.midnightcontrols.client.compat.mixin",
"plugin": "eu.midnightdust.midnightcontrols.client.compat.MidnightControlsMixinPlugin",
"compatibilityLevel": "JAVA_16",
"client": [