fix custom Tooltips (#2698)
* fix custom tooltip extensions not working * changelog
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
- Fixed crash when opening Controller GUI (Darkere)
|
- Fixed crash when opening Controller GUI (Darkere)
|
||||||
- Fixed dye being consumed without effect in some cases (Darkere)
|
- Fixed dye being consumed without effect in some cases (Darkere)
|
||||||
- Fixed deadlock caused by Portable Grid (Darkere)
|
- Fixed deadlock caused by Portable Grid (Darkere)
|
||||||
|
- Fixed custom tooltips not working in the Grid (Darkere)
|
||||||
|
|
||||||
### 1.9.6
|
### 1.9.6
|
||||||
- Port to Minecraft 1.16.3 (raoulvdberge)
|
- Port to Minecraft 1.16.3 (raoulvdberge)
|
||||||
|
@@ -410,7 +410,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawGridTooltip(MatrixStack matrixStack, IGridStack gridStack, int mouseX, int mouseY) {
|
private void drawGridTooltip(MatrixStack matrixStack, IGridStack gridStack, int mouseX, int mouseY) {
|
||||||
List<ITextComponent> textLines = gridStack.getTooltip();
|
List<ITextComponent> textLines = gridStack.getTooltip(true);
|
||||||
List<String> smallTextLines = Lists.newArrayList();
|
List<String> smallTextLines = Lists.newArrayList();
|
||||||
|
|
||||||
if (!gridStack.isCraftable()) {
|
if (!gridStack.isCraftable()) {
|
||||||
|
@@ -15,7 +15,7 @@ public class TooltipGridFilter implements Predicate<IGridStack> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(IGridStack stack) {
|
public boolean test(IGridStack stack) {
|
||||||
List<ITextComponent> tooltip = stack.getTooltip();
|
List<ITextComponent> tooltip = stack.getTooltip(false);
|
||||||
|
|
||||||
for (int i = 1; i < tooltip.size(); ++i) {
|
for (int i = 1; i < tooltip.size(); ++i) {
|
||||||
if (tooltip.get(i).getString().toLowerCase().contains(this.tooltip.toLowerCase())) {
|
if (tooltip.get(i).getString().toLowerCase().contains(this.tooltip.toLowerCase())) {
|
||||||
|
@@ -130,14 +130,21 @@ public class FluidGridStack implements IGridStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ITextComponent> getTooltip() {
|
public List<ITextComponent> getTooltip(boolean bypassCache) {
|
||||||
if (cachedTooltip == null) {
|
if (bypassCache || cachedTooltip == null) {
|
||||||
|
List<ITextComponent> tooltip;
|
||||||
try {
|
try {
|
||||||
cachedTooltip = Arrays.asList(stack.getDisplayName());
|
tooltip = Arrays.asList(stack.getDisplayName());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn("Could not retrieve fluid tooltip of " + stack.getFluid().getRegistryName().toString(), t);
|
logger.warn("Could not retrieve fluid tooltip of " + stack.getFluid().getRegistryName().toString(), t);
|
||||||
|
|
||||||
cachedTooltip = Arrays.asList(new StringTextComponent("<Error>"));
|
tooltip = Arrays.asList(new StringTextComponent("<Error>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bypassCache) {
|
||||||
|
return tooltip;
|
||||||
|
} else {
|
||||||
|
cachedTooltip = tooltip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ public interface IGridStack {
|
|||||||
|
|
||||||
Set<String> getTags();
|
Set<String> getTags();
|
||||||
|
|
||||||
List<ITextComponent> getTooltip();
|
List<ITextComponent> getTooltip(boolean bypassCache);
|
||||||
|
|
||||||
int getQuantity();
|
int getQuantity();
|
||||||
|
|
||||||
|
@@ -141,15 +141,22 @@ public class ItemGridStack implements IGridStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ITextComponent> getTooltip() {
|
public List<ITextComponent> getTooltip(boolean bypassCache) {
|
||||||
if (cachedTooltip == null) {
|
if (bypassCache || cachedTooltip == null) {
|
||||||
|
List<ITextComponent> tooltip;
|
||||||
try {
|
try {
|
||||||
cachedTooltip = RenderUtils.getTooltipFromItem(stack);
|
tooltip = RenderUtils.getTooltipFromItem(stack);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.warn("Could not retrieve item tooltip of " + stack.getItem().toString(), t);
|
logger.warn("Could not retrieve item tooltip of " + stack.getItem().toString(), t);
|
||||||
|
|
||||||
cachedTooltip = new ArrayList<>();
|
tooltip = new ArrayList<>();
|
||||||
cachedTooltip.add(new StringTextComponent("<Error>"));
|
tooltip.add(new StringTextComponent("<Error>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bypassCache) {
|
||||||
|
return tooltip;
|
||||||
|
} else {
|
||||||
|
cachedTooltip = tooltip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user