mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Bugs in the filters 🐛
- Fix crash when using enchant attribute - Fix gametest - Add nullcheck before inserting attributes
This commit is contained in:
parent
669435e849
commit
3a9f7d591c
6 changed files with 15 additions and 9 deletions
|
@ -137,7 +137,9 @@ public class AttributeFilterMenu extends AbstractFilterMenu {
|
|||
.getList("MatchedAttributes", Tag.TAG_COMPOUND);
|
||||
attributes.forEach(inbt -> {
|
||||
CompoundTag compound = (CompoundTag) inbt;
|
||||
selectedAttributes.add(Pair.of(ItemAttribute.loadStatic(compound), compound.getBoolean("Inverted")));
|
||||
ItemAttribute attribute = ItemAttribute.loadStatic(compound);
|
||||
if (attribute != null)
|
||||
selectedAttributes.add(Pair.of(attribute, compound.getBoolean("Inverted")));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ public interface ItemAttribute {
|
|||
}
|
||||
|
||||
ResourceLocation id = ResourceLocation.tryParse(nbt.getString("id"));
|
||||
if (id == null) {
|
||||
if (id == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemAttributeType type = AllRegistries.ITEM_ATTRIBUTE_TYPES.get().getValue(id);
|
||||
if (type == null) {
|
||||
return null;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.item.filter.attribute.attributes;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.createmod.catnip.utility.NBTHelper;
|
||||
import net.createmod.catnip.utility.lang.Components;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -57,13 +58,13 @@ public class EnchantAttribute implements ItemAttribute {
|
|||
ResourceLocation id = ForgeRegistries.ENCHANTMENTS.getKey(enchantment);
|
||||
if (id == null)
|
||||
return;
|
||||
nbt.putString("id", id.toString());
|
||||
NBTHelper.writeResourceLocation(nbt, "enchantId", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
if (nbt.contains("id")) {
|
||||
enchantment = ForgeRegistries.ENCHANTMENTS.getValue(ResourceLocation.tryParse(nbt.getString("id")));
|
||||
if (nbt.contains("enchantId")) {
|
||||
enchantment = ForgeRegistries.ENCHANTMENTS.getValue(NBTHelper.readResourceLocation(nbt, "enchantId"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,10 @@ import org.jetbrains.annotations.ApiStatus;
|
|||
import com.simibubi.create.content.logistics.item.filter.attribute.AllItemAttributeTypes;
|
||||
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttribute;
|
||||
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttributeType;
|
||||
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.EnchantAttribute;
|
||||
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.InTagAttribute;
|
||||
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
|
@ -27,7 +29,8 @@ public class AllItemAttributeLegacyDeserializers {
|
|||
);
|
||||
createLegacyDeserializer("in_item_group", AllItemAttributeTypes.IN_ITEM_GROUP);
|
||||
createLegacyDeserializer("added_by", AllItemAttributeTypes.ADDED_BY);
|
||||
createLegacyDeserializer("has_enchant", AllItemAttributeTypes.HAS_ENCHANT);
|
||||
createLegacyDeserializer("has_enchant", tag ->
|
||||
new EnchantAttribute(BuiltInRegistries.ENCHANTMENT.get(ResourceLocation.tryParse(tag.getString("id")))));
|
||||
createLegacyDeserializer("shulker_fill_level", AllItemAttributeTypes.SHULKER_FILL_LEVEL);
|
||||
createLegacyDeserializer("has_color", AllItemAttributeTypes.HAS_COLOR);
|
||||
createLegacyDeserializer("has_fluid", AllItemAttributeTypes.HAS_FLUID);
|
||||
|
|
Binary file not shown.
Loading…
Add table
Reference in a new issue