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

Fix enchantments getting trimmed from non-filter items #7216

Open
wants to merge 1 commit into
base: mc1.20.1/dev
Choose a base branch
from
Open
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 @@ -23,14 +23,15 @@ public class FilterItemStack {

public static FilterItemStack of(ItemStack filter) {
if (filter.hasTag()) {
CompoundTag stackTag = filter.getTag();
stackTag.remove("Enchantments");
stackTag.remove("AttributeModifiers");

if (AllItems.FILTER.isIn(filter))
if (AllItems.FILTER.isIn(filter)){
trimFilterTag(filter);
return new ListFilterItemStack(filter);
if (AllItems.ATTRIBUTE_FILTER.isIn(filter))
}
if (AllItems.ATTRIBUTE_FILTER.isIn(filter)){
trimFilterTag(filter);
return new AttributeFilterItemStack(filter);
}
}

return new FilterItemStack(filter);
Expand All @@ -39,28 +40,34 @@ public static FilterItemStack of(ItemStack filter) {
public static FilterItemStack of(CompoundTag tag) {
return of(ItemStack.of(tag));
}

public static FilterItemStack empty() {
return of(ItemStack.EMPTY);
}

private static void trimFilterTag(ItemStack filter){
CompoundTag stackTag = filter.getTag();
stackTag.remove("Enchantments");
stackTag.remove("AttributeModifiers");
}

public boolean isEmpty() {
return filterItemStack.isEmpty();
}

public CompoundTag serializeNBT() {
return filterItemStack.serializeNBT();
}

public ItemStack item() {
return filterItemStack;
}

public FluidStack fluid(Level level) {
resolveFluid(level);
return filterFluidStack;
}

public boolean isFilterItem() {
return filterItemStack.getItem() instanceof FilterItem;
}
Expand Down Expand Up @@ -98,7 +105,7 @@ public boolean test(Level world, FluidStack stack, boolean matchNBT) {
}

//

private void resolveFluid(Level world) {
if (!fluidExtracted) {
fluidExtracted = true;
Expand Down
Loading