fix crash when opening stencil table with cast (#87)

added guards before setActiveButton
This commit is contained in:
Dennis authored and GitHub committed 2023-05-22 06:59:36 +02:00
1 parent 8c4d534f6f
commit f019c7d845
2 files changed
+11 -7

No files matched your search

@@ -116,15 +116,19 @@ public class StencilTableGui extends GuiContainer implements INEIGuiHandler {
// get the correct setting :I
ItemStack stack;
if (logic.getStackInSlot(1) != null) {
activeButton = StencilBuilder.getId(logic.getStackInSlot(1));
setActiveButton(activeButton);
ItemStack setting = logic.getStackInSlot(1);
int currentSetting = setting != null ? StencilBuilder.getId(setting) : -1;
if (currentSetting >= 0) {
setActiveButton(currentSetting);
stack = StencilBuilder
.getStencil(((GuiButtonStencil) this.buttonList.get(activeButton)).element.stencilIndex);
} else stack = null;
logic.setSelectedPattern(stack);
updateServer(stack);
// only set valid patterns
if (stack != null) {
logic.setSelectedPattern(stack);
updateServer(stack);
}
}
@Override