fix: enchantments getting trimmed from non-filter items (#7216)

This commit is contained in:
VoidLeech 2025-01-10 18:20:13 +01:00 committed by GitHub
parent 507829443f
commit fc94c75866
Failed to generate hash of commit

View file

@ -23,14 +23,15 @@ public class FilterItemStack {
public static FilterItemStack of(ItemStack filter) { public static FilterItemStack of(ItemStack filter) {
if (filter.hasTag()) { 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); return new ListFilterItemStack(filter);
if (AllItems.ATTRIBUTE_FILTER.isIn(filter)) }
if (AllItems.ATTRIBUTE_FILTER.isIn(filter)){
trimFilterTag(filter);
return new AttributeFilterItemStack(filter); return new AttributeFilterItemStack(filter);
}
} }
return new FilterItemStack(filter); return new FilterItemStack(filter);
@ -39,11 +40,17 @@ public class FilterItemStack {
public static FilterItemStack of(CompoundTag tag) { public static FilterItemStack of(CompoundTag tag) {
return of(ItemStack.of(tag)); return of(ItemStack.of(tag));
} }
public static FilterItemStack empty() { public static FilterItemStack empty() {
return of(ItemStack.EMPTY); return of(ItemStack.EMPTY);
} }
private static void trimFilterTag(ItemStack filter){
CompoundTag stackTag = filter.getTag();
stackTag.remove("Enchantments");
stackTag.remove("AttributeModifiers");
}
public boolean isEmpty() { public boolean isEmpty() {
return filterItemStack.isEmpty(); return filterItemStack.isEmpty();
} }
@ -51,16 +58,16 @@ public class FilterItemStack {
public CompoundTag serializeNBT() { public CompoundTag serializeNBT() {
return filterItemStack.serializeNBT(); return filterItemStack.serializeNBT();
} }
public ItemStack item() { public ItemStack item() {
return filterItemStack; return filterItemStack;
} }
public FluidStack fluid(Level level) { public FluidStack fluid(Level level) {
resolveFluid(level); resolveFluid(level);
return filterFluidStack; return filterFluidStack;
} }
public boolean isFilterItem() { public boolean isFilterItem() {
return filterItemStack.getItem() instanceof FilterItem; return filterItemStack.getItem() instanceof FilterItem;
} }
@ -98,7 +105,7 @@ public class FilterItemStack {
} }
// //
private void resolveFluid(Level world) { private void resolveFluid(Level world) {
if (!fluidExtracted) { if (!fluidExtracted) {
fluidExtracted = true; fluidExtracted = true;