Skip to content

Commit 4b768ee

Browse files
authored
Merge pull request #465 from UnicacityAddon/bugfix/medic-storage-button-not-aligned
bugfix/medic-storage-button-not-aligned
2 parents 2e9e164 + 542a366 commit 4b768ee

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/main/java/de/rettichlp/ucutils/mixin/AbstractContainerScreenMixin.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
import net.minecraft.world.inventory.Slot;
1313
import net.minecraft.world.item.component.ItemLore;
1414
import org.jspecify.annotations.NonNull;
15+
import org.spongepowered.asm.mixin.Final;
1516
import org.spongepowered.asm.mixin.Mixin;
17+
import org.spongepowered.asm.mixin.Shadow;
1618
import org.spongepowered.asm.mixin.Unique;
1719
import org.spongepowered.asm.mixin.injection.At;
1820
import org.spongepowered.asm.mixin.injection.Inject;
@@ -27,15 +29,21 @@
2729
import static de.rettichlp.ucutils.UCUtils.storage;
2830
import static java.lang.Integer.parseInt;
2931
import static java.util.regex.Pattern.compile;
30-
import static net.minecraft.client.gui.screens.inventory.BookEditScreen.BACKGROUND_TEXTURE_HEIGHT;
31-
import static net.minecraft.client.gui.screens.inventory.BookEditScreen.BACKGROUND_TEXTURE_WIDTH;
3232
import static net.minecraft.core.component.DataComponents.LORE;
3333
import static net.minecraft.network.chat.Component.literal;
3434
import static net.minecraft.world.inventory.ContainerInput.PICKUP;
3535

3636
@Mixin(AbstractContainerScreen.class)
3737
public abstract class AbstractContainerScreenMixin<T extends AbstractContainerMenu> extends Screen implements MenuAccess<T> {
3838

39+
@Shadow
40+
@Final
41+
protected int imageWidth;
42+
43+
@Shadow
44+
@Final
45+
protected int imageHeight;
46+
3947
protected AbstractContainerScreenMixin(Component title) {
4048
super(title);
4149
}
@@ -56,9 +64,9 @@ protected AbstractContainerScreenMixin(Component title) {
5664
int ingredient2StoredAmount = getStoredAmount(this, 13);
5765
int ingredient3StoredAmount = getStoredAmount(this, 15);
5866

59-
int x = (this.width - BACKGROUND_TEXTURE_WIDTH) / 2;
60-
int y = (this.height - BACKGROUND_TEXTURE_HEIGHT) / 2;
61-
int buttonX = x + BACKGROUND_TEXTURE_WIDTH + 2;
67+
int x = (this.width - this.imageWidth) / 2;
68+
int y = (this.height - this.imageHeight) / 2;
69+
int buttonX = x + this.imageWidth + 2;
6270

6371
// render button right to the inventory
6472
Button button = new Button.Builder(literal("➤"), _ -> commandService.sendCommand("f " + ingredient1StoredAmount + "x Wirkstoff | " + ingredient2StoredAmount + "x Trägerstoff | " + ingredient3StoredAmount + "x Zusatzstoff"))

0 commit comments

Comments
 (0)