Fixed crashes relating to scrollbar in GUIs, fixes #1338

This commit is contained in:
Raoul Van den Berge
2017-07-03 22:00:56 +02:00
parent b669bcb97f
commit a4c5b457b5
7 changed files with 9 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
### 1.5.7 ### 1.5.7
- Exposed pattern inventory for Pattern Grid (raoulvdberge) - Exposed pattern inventory for Pattern Grid (raoulvdberge)
- Fixed crashes relating to scrollbar in GUIs (raoulvdberge)
- Added advancements (raoulvdberge) - Added advancements (raoulvdberge)
### 1.5.6 ### 1.5.6

View File

@@ -57,7 +57,7 @@ public class GuiController extends GuiBase {
int x = 33; int x = 33;
int y = 26; int y = 26;
int slot = scrollbar.getOffset() * 2; int slot = scrollbar != null ? (scrollbar.getOffset() * 2) : 0;
RenderHelper.enableGUIStandardItemLighting(); RenderHelper.enableGUIStandardItemLighting();

View File

@@ -113,7 +113,7 @@ public class GuiCraftingMonitor extends GuiBase {
drawString(7, 7, t(craftingMonitor.getGuiTitle())); drawString(7, 7, t(craftingMonitor.getGuiTitle()));
drawString(7, 137, t("container.inventory")); drawString(7, 137, t("container.inventory"));
int item = scrollbar.getOffset(); int item = scrollbar != null ? scrollbar.getOffset() : 0;
RenderHelper.enableGUIStandardItemLighting(); RenderHelper.enableGUIStandardItemLighting();
@@ -176,7 +176,7 @@ public class GuiCraftingMonitor extends GuiBase {
itemSelected = -1; itemSelected = -1;
if (mouseButton == 0 && inBounds(8, 20, 144, 90, mouseX - guiLeft, mouseY - guiTop)) { if (mouseButton == 0 && inBounds(8, 20, 144, 90, mouseX - guiLeft, mouseY - guiTop)) {
int item = scrollbar.getOffset(); int item = scrollbar != null ? scrollbar.getOffset() : 0;
for (int i = 0; i < VISIBLE_ROWS; ++i) { for (int i = 0; i < VISIBLE_ROWS; ++i) {
int ix = 8; int ix = 8;

View File

@@ -113,7 +113,7 @@ public class GuiCraftingPreview extends GuiBase {
GlStateManager.popMatrix(); GlStateManager.popMatrix();
} else { } else {
int slot = scrollbar.getOffset() * 2; int slot = scrollbar != null ? (scrollbar.getOffset() * 2) : 0;
RenderHelper.enableGUIStandardItemLighting(); RenderHelper.enableGUIStandardItemLighting();
GlStateManager.enableDepth(); GlStateManager.enableDepth();

View File

@@ -95,7 +95,7 @@ public class GuiReaderWriter extends GuiBase {
int x = 8; int x = 8;
int y = 39; int y = 39;
int item = scrollbar.getOffset(); int item = scrollbar != null ? scrollbar.getOffset() : 0;
for (int i = 0; i < VISIBLE_ROWS; ++i) { for (int i = 0; i < VISIBLE_ROWS; ++i) {
if (item < getChannels().size()) { if (item < getChannels().size()) {
@@ -128,7 +128,7 @@ public class GuiReaderWriter extends GuiBase {
if (inBounds(8, 39, 144, 73, mouseX - guiLeft, mouseY - guiTop)) { if (inBounds(8, 39, 144, 73, mouseX - guiLeft, mouseY - guiTop)) {
if (mouseButton == 0) { if (mouseButton == 0) {
int item = scrollbar.getOffset(); int item = scrollbar != null ? scrollbar.getOffset() : 0;
for (int i = 0; i < VISIBLE_ROWS; ++i) { for (int i = 0; i < VISIBLE_ROWS; ++i) {
int ix = 8; int ix = 8;

View File

@@ -459,7 +459,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
this.slotNumber = -1; this.slotNumber = -1;
int slot = scrollbar.getOffset() * 9; int slot = scrollbar != null ? (scrollbar.getOffset() * 9) : 0;
RenderHelper.enableGUIStandardItemLighting(); RenderHelper.enableGUIStandardItemLighting();

View File

@@ -25,7 +25,7 @@ public class GuiHandlerGrid implements IAdvancedGuiHandler<GuiGrid> {
mouseX -= gui.getGuiLeft(); mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop(); mouseY -= gui.getGuiTop();
if (!gui.getSearchField().isFocused() && gui.isOverSlotArea(mouseX, mouseY)) { if (gui.getScrollbar() != null && !gui.getSearchField().isFocused() && gui.isOverSlotArea(mouseX, mouseY)) {
mouseX -= 7; mouseX -= 7;
mouseY -= 19; mouseY -= 19;