Skip to content

Commit

Permalink
fix: all the bugs (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu authored and ghzdude committed Jul 20, 2024
1 parent c09fdca commit f4e1615
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,13 @@ public ItemStack findSubstitute(int craftingIndex, ItemStack stack) {

boolean matchedPreviously = false;
if (map.containsKey(itemStack)) {
if (!map.get(itemStack)) {
continue;
if (map.get(itemStack)) {
// cant return here before checking if:
// The item is available for extraction
// The recipe output is still the same, as depending on
// the ingredient, the output NBT may change
matchedPreviously = true;
}
// cant return here before checking if:
// The item is available for extraction
// The recipe output is still the same, as depending on
// the ingredient, the output NBT may change
matchedPreviously = true;
}

if (!matchedPreviously) {
Expand Down Expand Up @@ -351,6 +350,7 @@ public void detectAndSendChanges(boolean init) {
var slotStack = slot.getStack();
if (slotStack.isEmpty()) {
slot.hasIngredients = true;
map.put(slot.getIndex(), slot.hasIngredients);
continue;
}

Expand Down Expand Up @@ -427,6 +427,7 @@ public void readOnServer(int id, PacketBuffer buf) {
try {
this.craftingMatrix.setInventorySlotContents(i, buf.readItemStack());
} catch (IOException ignore) {}
this.updateCurrentRecipe();
}
} else if (id == 4) {
int slot = buf.readVarInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public void writeRecipes(PacketBuffer buf) {
buf.writeByte(recipe.index);
buf.writeItemStack(recipe.recipeResult);
buf.writeInt(recipe.timesUsed);
buf.writeBoolean(recipe.isRecipeLocked());
}
}

Expand All @@ -197,6 +198,7 @@ public void readRecipes(PacketBuffer buf) {

memorizedRecipes[index].recipeResult = readStackSafe(buf);
memorizedRecipes[index].timesUsed = buf.readInt();
memorizedRecipes[index].recipeLocked = buf.readBoolean();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@ public void draw(GuiContext context, WidgetTheme widgetTheme) {
ItemStack itemstack = this.syncHandler.getStack();
if (itemstack.isEmpty()) return;

if (!this.hasIngredients) {
RenderUtil.renderRect(0, 0, 18, 18, 100, 0x80FF0000);
}

guiScreen.setZ(100f);
guiScreen.getItemRenderer().zLevel = 100f;
RenderUtil.renderItemInGUI(itemstack, 1, 1);
guiScreen.getItemRenderer().zLevel = 0.0F;
guiScreen.setZ(0f);
RenderUtil.renderItemInGUI(itemstack, 1, 1);

if (!this.hasIngredients) {
RenderUtil.renderRect(0, 0, 18, 18, 200, 0x80FF0000);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import gregtech.client.utils.RenderUtil;
import gregtech.common.metatileentities.storage.CraftingRecipeMemory;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;

import com.cleanroommc.modularui.api.drawable.IKey;
Expand Down Expand Up @@ -49,8 +50,11 @@ public void draw(GuiContext context, WidgetTheme widgetTheme) {
RenderUtil.renderItemInGUI(itemstack, 1, 1);
itemstack.setCount(cachedCount);

if (this.memory.getRecipeAtIndex(this.index).isRecipeLocked())
if (this.memory.getRecipeAtIndex(this.index).isRecipeLocked()) {
GlStateManager.disableDepth();
GTGuiTextures.RECIPE_LOCK.draw(context, 10, 1, 8, 8, widgetTheme);
GlStateManager.enableDepth();
}

guiScreen.getItemRenderer().zLevel = 0.0F;
guiScreen.setZ(0f);
Expand Down

0 comments on commit f4e1615

Please sign in to comment.