Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fluid pattern blame #161

Merged
merged 2 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,18 @@ protected boolean checkHasFluidPattern() {
return hasFluid && search; // search=false -> outputs were empty
}

protected ItemStack stampAuthor(ItemStack patternStack) {
patternStack.stackTagCompound.setString("author", getPlayerInv().player.getCommandSenderName());
return patternStack;
}

protected void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setInputs(collectInventory(this.craftingSlots));
pattern.setOutputs(collectInventory(this.outputSlots));
pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
patternSlotOUT.putStack(pattern.writeToStack());
patternSlotOUT.putStack(stampAuthor(pattern.writeToStack()));
}

protected static IAEItemStack[] collectInventory(Slot[] slots) {
Expand Down Expand Up @@ -440,6 +445,7 @@ else if (output == null) {
encodedValue.setBoolean("beSubstitute", this.beSubstitute);
encodedValue.setBoolean("prioritize", this.prioritize);
output.setTagCompound(encodedValue);
stampAuthor(output);
this.patternSlotOUT.putStack(output);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<

public FluidPatternDetails(ItemStack stack) {
this.patternStack = stack;
this.patternStackAe = Objects.requireNonNull(AEItemStack.create(stack)); // s2g
if (stack.stackTagCompound.hasKey("author")) {
Copy link
Member

@Alexdoru Alexdoru Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just got a NPE on this line when encoding a pattern @Glease , game crashed integrated server crashed

final ItemStack forComparison = this.patternStack.copy();
forComparison.stackTagCompound.removeTag("author");
this.patternStackAe = Objects.requireNonNull(AEItemStack.create(forComparison)); // s2g
} else {
this.patternStackAe = Objects.requireNonNull(AEItemStack.create(stack)); // s2g
}
}

public boolean canBeSubstitute() {
Expand Down