Merge remote-tracking branch 'slprime/fix_favorite_state' into dev

This commit is contained in:
Dream Master committed 2025-10-31 13:29:15 +01:00
commit 9e43ae0088
3 files changed
+24 -10

No files matched your search

@@ -72,7 +72,7 @@ public class GuiFavoriteButton extends GuiRecipeButton {
}
public boolean isFavorite() {
return favorite;
return this.favorite;
}
public void toggleFavorite() {
@@ -86,6 +86,11 @@ public class GuiFavoriteButton extends GuiRecipeButton {
.setFavorite(this.favoriteResult.getItemStack(), this.favorite ? this.recipe.getRecipeId() : null);
}
@Override
public void update() {
this.favorite = this.favorite && FavoriteRecipes.getFavorite(this.recipe.getRecipeId()) != null;
}
@Override
protected void drawContent(Minecraft minecraft, int y, int x, boolean mouseOver) {
final DrawableResource icon = isFavorite() ? ICON_STATE_ON : ICON_STATE_OFF;
@@ -61,6 +61,10 @@ public abstract class GuiRecipeButton extends GuiNEIButton {
public abstract void drawItemOverlay();
public void update() {
}
public boolean mouseScrolled(int scroll) {
return false;
}
@@ -37,9 +37,9 @@ public class NEIRecipeWidget extends Widget {
protected AcceptsFollowingTooltipLineHandler acceptsFollowingTooltipLineHandler;
protected final WeakHashMap<PositionedStack, List<ItemStack>> permutations = new WeakHashMap<>();
protected boolean needUpdate = true;
protected boolean update = true;
protected int cycleticks = 0;
protected int lastcycle = 0;
protected int lastcycle = -1;
protected final RecipeHandlerRef handlerRef;
protected final HandlerInfo handlerInfo;
@@ -67,10 +67,7 @@ public class NEIRecipeWidget extends Widget {
this.h += this.handlerInfo.getYShift();
}
if (!this.needUpdate && !NEIClientUtils.shiftKey() && (this.cycleticks++) / 20 != this.lastcycle) {
this.lastcycle = this.cycleticks / 20;
this.needUpdate = true;
}
this.update = true;
}
public List<GuiRecipeButton> getRecipeButtons() {
@@ -165,9 +162,17 @@ public class NEIRecipeWidget extends Widget {
public void draw(int mouseX, int mouseY) {
final int yShift = this.handlerInfo.getYShift();
if (this.needUpdate) {
this.needUpdate = false;
updatePermutations();
if (this.update) {
this.update = false;
if (!NEIClientUtils.shiftKey() && (this.cycleticks++) / 20 != this.lastcycle || this.lastcycle == -1) {
this.lastcycle = this.cycleticks / 20;
updatePermutations();
}
for (GuiRecipeButton button : getRecipeButtons()) {
button.update();
}
}
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);