Skip to content

Commit

Permalink
fix: Only move the recipe book button on the vanilla CraftingScreen t…
Browse files Browse the repository at this point in the history
…o not mess with other mods
  • Loading branch information
BlayTheNinth committed Oct 29, 2024
1 parent 0f3ddbf commit 5111637
Showing 1 changed file with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package net.blay09.mods.craftingtweaks;

import net.blay09.mods.balm.api.Balm;
import net.blay09.mods.craftingtweaks.config.CraftingTweaksConfig;
import net.blay09.mods.craftingtweaks.config.CraftingTweaksConfigData;
import net.blay09.mods.balm.mixin.AbstractContainerScreenAccessor;
import net.blay09.mods.balm.mixin.ImageButtonAccessor;
import net.blay09.mods.balm.mixin.ScreenAccessor;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.client.gui.screens.inventory.CraftingScreen;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand All @@ -23,21 +21,10 @@ public static Button fixMistakes(AbstractContainerScreen<?> screen) {
CraftingTweaksConfigData config = CraftingTweaksConfig.getActive();
if (config.client.hideVanillaCraftingGuide) {
button.visible = false;
} else if (!(screen instanceof InventoryScreen)) {
} else if (screen instanceof CraftingScreen) {
AbstractContainerScreenAccessor accessor = (AbstractContainerScreenAccessor) screen;
button.setX(accessor.getLeftPos() + accessor.getImageWidth() - 25);

// Let's be hacky because fuck this button. Hopefully no one else adds it to their GUIs.
if (screen.getClass().getSimpleName().equals("GuiCraftingStation")) {
button.setY(accessor.getTopPos() + 37);
} else {
button.setY(accessor.getTopPos() + 5);
}

// Let's be hacky again!
if (Balm.isModLoaded("inventorytweaks")) {
button.setX(button.getX() - 15);
}
button.setY(accessor.getTopPos() + 5);
}
}
return button;
Expand Down

0 comments on commit 5111637

Please sign in to comment.