Fix Slot Registration Crash (#73)

This commit is contained in:
Julia authored and GitHub committed 2025-09-25 15:46:12 +02:00
1 parent d24088ea4b
commit e6c67df077
22 files changed
+115 -81

No files matched your search

@@ -115,12 +115,14 @@ public class WindowFieldKit extends Window {
@Override
public void initialiseClient() {
final NBTTagList actions = new NBTTagList();
setTitle(getName());
CraftGUI.render.stylesheet(new StyleSheetPunnett());
getWindowInventory().createSlot(0);
getWindowInventory().createSlot(1);
setupValidators();
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).create(actions);
IPoint handGlass = new IPoint(16.0f, 32.0f);
GlassControl = new ControlImage(
this,
@@ -128,8 +130,6 @@ public class WindowFieldKit extends Window {
handGlass.y(),
new StandardTexture(0, 160, 96, 96, ExtraBeeTexture.GUIPunnett));
final NBTTagList actions = new NBTTagList();
new ControlSlot(this, handGlass.x() + 54.0f, handGlass.y() + 26.0f).assign(actions, InventoryType.Window, 0);
new ControlSlot(this, 208.0f, 8.0f).assign(actions, InventoryType.Window, 1);
@@ -63,7 +63,7 @@ public class WindowGenesis extends Window {
@Override
public void initialiseClient() {
new ControlPlayerInventory(this);
new ControlPlayerInventory(this).createAndRegister();
setTitle(getName());
ControlTabBar<BreedingSystem> tabSystems = new BreedingSystemControlTabBar();
@@ -40,7 +40,6 @@ public class ControlPlayerInventory extends Control {
slots.add(slot2);
}
}
create();
}
public ControlPlayerInventory(IWidget parent) {
@@ -56,12 +55,9 @@ public class ControlPlayerInventory extends Control {
slots.add(slot);
}
}
create();
}
public void create() {
final NBTTagList actions = new NBTTagList();
public ControlPlayerInventory create(NBTTagList actions) {
for (int row = 0; row < 3; ++row) {
for (int column = 0; column < 9; ++column) {
ControlSlot slot = slots.get(column + row * 9);
@@ -74,14 +70,13 @@ public class ControlPlayerInventory extends Control {
slot2.assign(actions, InventoryType.Player, i1);
}
return this;
}
public ControlPlayerInventory createAndRegister() {
final NBTTagList actions = new NBTTagList();
create(actions);
MessageCraftGUI.sendToServer(actions);
return this;
}
public ControlSlot getSlot(int i) {
if (i < 0 || i >= slots.size()) {
return null;
}
return slots.get(i);
}
}
@@ -9,7 +9,6 @@ import net.minecraft.nbt.NBTTagList;
import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.controls.core.Control;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.network.packet.MessageCraftGUI;
public class ControlSlotArray extends Control implements Iterable<ControlSlot> {
@@ -29,13 +28,7 @@ public class ControlSlotArray extends Control implements Iterable<ControlSlot> {
return new ControlSlot(this, x, y);
}
public ControlSlotArray create(int[] index) {
return create(InventoryType.Machine, index);
}
public ControlSlotArray create(InventoryType inventoryType, int[] index) {
final NBTTagList actions = new NBTTagList();
public ControlSlotArray create(NBTTagList actions, InventoryType inventoryType, int[] index) {
int i = 0;
for (ControlSlot controlSlot : slots) {
final int slotIndex = index[i];
@@ -43,7 +36,6 @@ public class ControlSlotArray extends Control implements Iterable<ControlSlot> {
i++;
}
MessageCraftGUI.sendToServer(actions);
return this;
}
@@ -190,7 +190,11 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
for (int k = 0; k < inv.getPageSize(); ++k) {
slotsIDs[k] = i++;
}
new ControlSlotArray(thisPage, 8, 8, inv.getPageSize() / 5, 5).create(slotsIDs);
final NBTTagList actions = new NBTTagList();
new ControlSlotArray(thisPage, 8, 8, inv.getPageSize() / 5, 5)
.create(actions, InventoryType.Machine, slotsIDs);
MessageCraftGUI.sendToServer(actions);
}
x += compartmentPageWidth;
if (tabs2.length > 0) {
@@ -248,7 +252,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
setSize(new IPoint(Math.max(32 + compartmentWidth, 252), h()));
controlCompartment.setPosition(new IPoint((w() - controlCompartment.w()) / 2.0f, controlCompartment.y()));
new ControlPlayerInventory(this, true);
new ControlPlayerInventory(this, true).createAndRegister();
ControlSlide slide = new ControlSlide(this, 0.0f, 134.0f, 136.0f, 92.0f, Position.LEFT);
slide.setLabel(I18N.localise("binniecore.machine.storage.tab.properties"));
slide.setSlide(false);
@@ -370,7 +374,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
};
slotGrid = new Control(scroll, 1.0f, 1.0f, 108.0f, 18.0f);
scroll.setScrollableContent(slotGrid);
new ControlPlayerInventory(this, true);
new ControlPlayerInventory(this, true).createAndRegister();
new ControlTextEdit(this, 16.0f, 16.0f, 100.0f, 14.0f).addEventHandler(new EventTextEdit.Handler() {
@Override