Fix index problem for chestGUI

This commit is contained in:
zontreck 2024-01-10 01:25:57 -07:00
parent b2a2c60dfd
commit ac69c828a4
3 changed files with 11 additions and 10 deletions

View file

@ -53,7 +53,7 @@ mod_name=Zontreck Library Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3 mod_license=GPLv3
# The mod version. See https://semver.org/ # The mod version. See https://semver.org/
mod_version=1.10.011024.0005 mod_version=1.10.011024.0121
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -30,7 +30,7 @@ public class ChestGUI
private String MenuTitle = ""; private String MenuTitle = "";
private UUID player; private UUID player;
public List<ChestGUIButton> buttons = new ArrayList<>(); public List<ChestGUIButton> buttons = new ArrayList<>();
private ResourceLocation id; private ChestGUIIdentifier id;
private int page =0; private int page =0;
private boolean hasAdd = false; private boolean hasAdd = false;
private boolean hasReset = false; private boolean hasReset = false;
@ -95,7 +95,7 @@ public class ChestGUI
ChestGUIButton rem = new ChestGUIButton(remStack, ()-> { ChestGUIButton rem = new ChestGUIButton(remStack, ()-> {
onRemove.run(); onRemove.run();
}, new Vector2i(3, 3)); }, new Vector2i(2, 3));
container.setStackInSlot(rem.getSlotNum(), rem.buildIcon()); container.setStackInSlot(rem.getSlotNum(), rem.buildIcon());
} }
@ -106,7 +106,7 @@ public class ChestGUI
ChestGUIButton rem = new ChestGUIButton(resStack, ()-> { ChestGUIButton rem = new ChestGUIButton(resStack, ()-> {
onReset.run(); onReset.run();
}, new Vector2i(3, 4)); }, new Vector2i(2, 4));
container.setStackInSlot(rem.getSlotNum(), rem.buildIcon()); container.setStackInSlot(rem.getSlotNum(), rem.buildIcon());
@ -119,7 +119,7 @@ public class ChestGUI
ChestGUIButton rem = new ChestGUIButton(remStack, ()-> { ChestGUIButton rem = new ChestGUIButton(remStack, ()-> {
onAdd.run(); onAdd.run();
}, new Vector2i(3, 5)); }, new Vector2i(2, 5));
container.setStackInSlot(rem.getSlotNum(), rem.buildIcon()); container.setStackInSlot(rem.getSlotNum(), rem.buildIcon());
} }
@ -197,13 +197,13 @@ public class ChestGUI
return player.equals(ID); return player.equals(ID);
} }
public ChestGUI withGUIId(ResourceLocation id) public ChestGUI withGUIId(ChestGUIIdentifier id)
{ {
this.id = id; this.id = id;
return this; return this;
} }
public boolean matches(ResourceLocation id) public boolean matches(ChestGUIIdentifier id)
{ {
return this.id.equals(id); return this.id.equals(id);
} }

View file

@ -1,6 +1,7 @@
package dev.zontreck.libzontreck.events; package dev.zontreck.libzontreck.events;
import dev.zontreck.libzontreck.chestgui.ChestGUI; import dev.zontreck.libzontreck.chestgui.ChestGUI;
import dev.zontreck.libzontreck.chestgui.ChestGUIIdentifier;
import dev.zontreck.libzontreck.util.ServerUtilities; import dev.zontreck.libzontreck.util.ServerUtilities;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
@ -11,18 +12,18 @@ import java.util.UUID;
public class OpenGUIEvent extends Event public class OpenGUIEvent extends Event
{ {
private ResourceLocation GUIId; private ChestGUIIdentifier GUIId;
private UUID playerID; private UUID playerID;
private final ChestGUI gui; private final ChestGUI gui;
public OpenGUIEvent(ResourceLocation ID, UUID player, ChestGUI gui) public OpenGUIEvent(ChestGUIIdentifier ID, UUID player, ChestGUI gui)
{ {
GUIId = ID; GUIId = ID;
playerID = player; playerID = player;
this.gui = gui; this.gui = gui;
} }
public boolean matches(ResourceLocation id) public boolean matches(ChestGUIIdentifier id)
{ {
return GUIId.equals(id); return GUIId.equals(id);
} }