Added protection for other mods causing crashes when drawing an item or display name
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
- Added Project E integration for the External Storage on the Transmutation Table (raoulvdberge)
|
- Added Project E integration for the External Storage on the Transmutation Table (raoulvdberge)
|
||||||
- Added Project E integration for the energy values of Solderer items (raoulvdberge)
|
- Added Project E integration for the energy values of Solderer items (raoulvdberge)
|
||||||
- Added support for more than 4 grid tabs in the Grid by putting filters IN filters (raoulvdberge)
|
- Added support for more than 4 grid tabs in the Grid by putting filters IN filters (raoulvdberge)
|
||||||
|
- Added protection for other mods causing crashes when drawing an item or display name (raoulvdberge)
|
||||||
- Fixed network not disconnecting when Controller is broken (raoulvdberge)
|
- Fixed network not disconnecting when Controller is broken (raoulvdberge)
|
||||||
- Fixed bug where when multiple Fortune Upgrades are inserted, it chooses the first Fortune Upgrade instead of the highest one (raoulvdberge)
|
- Fixed bug where when multiple Fortune Upgrades are inserted, it chooses the first Fortune Upgrade instead of the highest one (raoulvdberge)
|
||||||
- Fixed some translations having too big "Craft" text (raoulvdberge)
|
- Fixed some translations having too big "Craft" text (raoulvdberge)
|
||||||
|
|||||||
@@ -261,7 +261,11 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
zLevel = 200.0F;
|
zLevel = 200.0F;
|
||||||
itemRender.zLevel = 200.0F;
|
itemRender.zLevel = 200.0F;
|
||||||
|
|
||||||
itemRender.renderItemIntoGUI(stack, x, y);
|
try {
|
||||||
|
itemRender.renderItemIntoGUI(stack, x, y);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
if (withOverlay) {
|
if (withOverlay) {
|
||||||
drawItemOverlay(stack, text, x, y);
|
drawItemOverlay(stack, text, x, y);
|
||||||
@@ -272,7 +276,11 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawItemOverlay(ItemStack stack, @Nullable String text, int x, int y) {
|
public void drawItemOverlay(ItemStack stack, @Nullable String text, int x, int y) {
|
||||||
itemRender.renderItemOverlayIntoGUI(fontRenderer, stack, x, y, "");
|
try {
|
||||||
|
itemRender.renderItemOverlayIntoGUI(fontRenderer, stack, x, y, "");
|
||||||
|
} catch (Throwable t) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
drawQuantity(x, y, text);
|
drawQuantity(x, y, text);
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ public class GridStackItem implements IGridStack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return stack.getDisplayName();
|
try {
|
||||||
|
return stack.getDisplayName();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,7 +73,11 @@ public class GridStackItem implements IGridStack {
|
|||||||
@Override
|
@Override
|
||||||
public String[] getOreIds() {
|
public String[] getOreIds() {
|
||||||
if (oreIds == null) {
|
if (oreIds == null) {
|
||||||
oreIds = Arrays.stream(OreDictionary.getOreIDs(stack)).mapToObj(OreDictionary::getOreName).collect(Collectors.toList()).toArray(new String[0]);
|
if (stack.isEmpty()) {
|
||||||
|
oreIds = new String[]{};
|
||||||
|
} else {
|
||||||
|
oreIds = Arrays.stream(OreDictionary.getOreIDs(stack)).mapToObj(OreDictionary::getOreName).collect(Collectors.toList()).toArray(new String[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return oreIds;
|
return oreIds;
|
||||||
@@ -77,22 +85,26 @@ public class GridStackItem implements IGridStack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTooltip(boolean quantity) {
|
public String getTooltip(boolean quantity) {
|
||||||
List<String> lines = stack.getTooltip(Minecraft.getMinecraft().player, Minecraft.getMinecraft().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL);
|
try {
|
||||||
|
List<String> lines = stack.getTooltip(Minecraft.getMinecraft().player, Minecraft.getMinecraft().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL);
|
||||||
|
|
||||||
// From GuiScreen#renderToolTip
|
// From GuiScreen#renderToolTip
|
||||||
for (int i = 0; i < lines.size(); ++i) {
|
for (int i = 0; i < lines.size(); ++i) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
lines.set(i, stack.getRarity().rarityColor + lines.get(i));
|
lines.set(i, stack.getRarity().rarityColor + lines.get(i));
|
||||||
} else {
|
} else {
|
||||||
lines.set(i, TextFormatting.GRAY + lines.get(i));
|
lines.set(i, TextFormatting.GRAY + lines.get(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (quantity && !lines.isEmpty()) {
|
if (quantity && !lines.isEmpty()) {
|
||||||
lines.set(0, lines.get(0) + " " + TextFormatting.GRAY + "(" + RenderUtils.QUANTITY_FORMATTER_UNFORMATTED.format(stack.getCount()) + "x)" + TextFormatting.RESET);
|
lines.set(0, lines.get(0) + " " + TextFormatting.GRAY + "(" + RenderUtils.QUANTITY_FORMATTER_UNFORMATTED.format(stack.getCount()) + "x)" + TextFormatting.RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines.stream().collect(Collectors.joining("\n"));
|
return lines.stream().collect(Collectors.joining("\n"));
|
||||||
|
} catch (Throwable t) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user