Add Accepts Label (#1007)

This commit is contained in:
slprime authored and GitHub committed 2026-08-14 22:41:15 +03:00
1 parent 75d53b12ca
commit f8d00a5445
4 files changed
+34 -3

No files matched your search

@@ -92,6 +92,11 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
this.labelColor = color;
}
public void setLabel(String label) {
this.label = label;
this.size.width = Math.max(this.columns * SLOT_SIZE, fontRenderer.getStringWidth(this.label) + 15);
}
@Override
public void draw(int x, int y) {
if (this.length == 0) return;
@@ -37,6 +37,10 @@ public class PositionedStack implements Cloneable {
protected int chance = CHANCE_FULL;
protected boolean permutated = false;
protected String acceptsLabel;
protected List<String> tooltip;
protected List<Badge> badges;
public PositionedStack(Object object, int x, int y, boolean genPerms) {
items = NEIServerUtils.extractRecipeItems(object);
relx = x;
@@ -90,12 +94,28 @@ public class PositionedStack implements Cloneable {
for (ItemStack item : items) if (item.stackSize > i) item.stackSize = i;
}
public void setAcceptsLabel(String acceptsLabel) {
this.acceptsLabel = acceptsLabel;
}
public String getAcceptsLabel() {
return this.acceptsLabel;
}
public void setBadges(List<Badge> badges) {
this.badges = badges;
}
public List<Badge> getBadges() {
return null;
return this.badges;
}
public void setTooltip(List<String> tooltip) {
this.tooltip = tooltip;
}
public List<String> getTooltip() {
return null;
return this.tooltip;
}
public int getChance() {
@@ -111,6 +131,8 @@ public class PositionedStack implements Cloneable {
PositionedStack pStack = (PositionedStack) super.clone();
pStack.items = Arrays.stream(this.items).map(ItemStack::copy).toArray(ItemStack[]::new);
pStack.item = this.item == null ? null : this.item.copy();
pStack.tooltip = this.tooltip == null ? null : new ArrayList<>(this.tooltip);
pStack.badges = this.badges == null ? null : new ArrayList<>(this.badges);
return pStack;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
@@ -15,7 +15,7 @@ public class AcceptsFollowingTooltipLineHandler extends ItemsTooltipLineHandler
public Object tooltipGUID;
public AcceptsFollowingTooltipLineHandler(Object tooltipGUID, List<ItemStack> items, ItemStack activeStack,
protected AcceptsFollowingTooltipLineHandler(Object tooltipGUID, List<ItemStack> items, ItemStack activeStack,
int maxRows) {
super(NEIClientUtils.translate("recipe.accepts"), items, false, maxRows);
this.tooltipGUID = tooltipGUID;
@@ -436,6 +436,10 @@ public class NEIRecipeWidget extends Widget {
|| this.acceptsFollowingTooltipLineHandler.tooltipGUID != hovered) {
this.acceptsFollowingTooltipLineHandler = AcceptsFollowingTooltipLineHandler
.of(hovered, this.permutations.get(hovered), hovered.item);
if (this.acceptsFollowingTooltipLineHandler != null && hovered.getAcceptsLabel() != null) {
this.acceptsFollowingTooltipLineHandler.setLabel(hovered.getAcceptsLabel());
}
}
} else if (this.acceptsFollowingTooltipLineHandler != null) {
this.acceptsFollowingTooltipLineHandler = null;