mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Conflicting thoughts
- Fix certain attributes overriding the type id
This commit is contained in:
parent
7e0d504897
commit
a592e22df3
6 changed files with 27 additions and 17 deletions
|
@ -25,7 +25,7 @@ public interface ItemAttribute {
|
||||||
if (id == null)
|
if (id == null)
|
||||||
throw new IllegalArgumentException("Cannot get " + attribute.getType() + "as it does not exist in AllRegistries.ITEM_ATTRIBUTE_TYPES");
|
throw new IllegalArgumentException("Cannot get " + attribute.getType() + "as it does not exist in AllRegistries.ITEM_ATTRIBUTE_TYPES");
|
||||||
|
|
||||||
nbt.putString("id", id.toString());
|
nbt.putString("attributeId", id.toString());
|
||||||
attribute.save(nbt);
|
attribute.save(nbt);
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,12 +48,12 @@ public class AddedByAttribute implements ItemAttribute {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(CompoundTag nbt) {
|
public void save(CompoundTag nbt) {
|
||||||
nbt.putString("id", modId);
|
nbt.putString("modId", modId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CompoundTag nbt) {
|
public void load(CompoundTag nbt) {
|
||||||
modId = nbt.getString("id");
|
modId = nbt.getString("modId");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -85,13 +85,13 @@ public class ColorAttribute implements ItemAttribute {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(CompoundTag nbt) {
|
public void save(CompoundTag nbt) {
|
||||||
nbt.putInt("id", color.getId());
|
nbt.putInt("color", color.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CompoundTag nbt) {
|
public void load(CompoundTag nbt) {
|
||||||
if (nbt.contains("id")) {
|
if (nbt.contains("color")) {
|
||||||
color = DyeColor.byId(nbt.getInt("id"));
|
color = DyeColor.byId(nbt.getInt("color"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,13 +72,13 @@ public class FluidContentsAttribute implements ItemAttribute {
|
||||||
ResourceLocation id = ForgeRegistries.FLUIDS.getKey(fluid);
|
ResourceLocation id = ForgeRegistries.FLUIDS.getKey(fluid);
|
||||||
if (id == null)
|
if (id == null)
|
||||||
return;
|
return;
|
||||||
nbt.putString("id", id.toString());
|
nbt.putString("fluidId", id.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CompoundTag nbt) {
|
public void load(CompoundTag nbt) {
|
||||||
if (nbt.contains("id")) {
|
if (nbt.contains("fluidId")) {
|
||||||
fluid = ForgeRegistries.FLUIDS.getValue(ResourceLocation.tryParse(nbt.getString("id")));
|
fluid = ForgeRegistries.FLUIDS.getValue(ResourceLocation.tryParse(nbt.getString("fluidId")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,17 +55,17 @@ public class ShulkerFillLevelAttribute implements ItemAttribute {
|
||||||
@Override
|
@Override
|
||||||
public void save(CompoundTag nbt) {
|
public void save(CompoundTag nbt) {
|
||||||
if (levels != null)
|
if (levels != null)
|
||||||
nbt.putString("id", levels.key);
|
nbt.putString("level", levels.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CompoundTag nbt) {
|
public void load(CompoundTag nbt) {
|
||||||
if (nbt.contains("id")) {
|
if (nbt.contains("level")) {
|
||||||
levels = ShulkerLevels.fromKey(nbt.getString("id"));
|
levels = ShulkerLevels.fromKey(nbt.getString("level"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ShulkerLevels {
|
public enum ShulkerLevels {
|
||||||
EMPTY("empty", amount -> amount == 0),
|
EMPTY("empty", amount -> amount == 0),
|
||||||
PARTIAL("partial", amount -> amount > 0 && amount < Integer.MAX_VALUE),
|
PARTIAL("partial", amount -> amount > 0 && amount < Integer.MAX_VALUE),
|
||||||
FULL("full", amount -> amount == Integer.MAX_VALUE);
|
FULL("full", amount -> amount == Integer.MAX_VALUE);
|
||||||
|
|
|
@ -8,13 +8,19 @@ import org.jetbrains.annotations.ApiStatus;
|
||||||
import com.simibubi.create.content.logistics.item.filter.attribute.AllItemAttributeTypes;
|
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.ItemAttribute;
|
||||||
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttributeType;
|
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttributeType;
|
||||||
|
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.AddedByAttribute;
|
||||||
|
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.ColorAttribute;
|
||||||
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.EnchantAttribute;
|
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.EnchantAttribute;
|
||||||
|
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.FluidContentsAttribute;
|
||||||
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.InTagAttribute;
|
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.InTagAttribute;
|
||||||
|
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.ShulkerFillLevelAttribute;
|
||||||
|
import com.simibubi.create.content.logistics.item.filter.attribute.attributes.ShulkerFillLevelAttribute.ShulkerLevels;
|
||||||
|
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.ItemTags;
|
import net.minecraft.tags.ItemTags;
|
||||||
|
import net.minecraft.world.item.DyeColor;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class AllItemAttributeLegacyDeserializers {
|
public class AllItemAttributeLegacyDeserializers {
|
||||||
|
@ -28,12 +34,16 @@ public class AllItemAttributeLegacyDeserializers {
|
||||||
)))
|
)))
|
||||||
);
|
);
|
||||||
createLegacyDeserializer("in_item_group", AllItemAttributeTypes.IN_ITEM_GROUP);
|
createLegacyDeserializer("in_item_group", AllItemAttributeTypes.IN_ITEM_GROUP);
|
||||||
createLegacyDeserializer("added_by", AllItemAttributeTypes.ADDED_BY);
|
createLegacyDeserializer("added_by", tag ->
|
||||||
|
new AddedByAttribute(tag.getString("id")));
|
||||||
createLegacyDeserializer("has_enchant", tag ->
|
createLegacyDeserializer("has_enchant", tag ->
|
||||||
new EnchantAttribute(BuiltInRegistries.ENCHANTMENT.get(ResourceLocation.tryParse(tag.getString("id")))));
|
new EnchantAttribute(BuiltInRegistries.ENCHANTMENT.get(ResourceLocation.tryParse(tag.getString("id")))));
|
||||||
createLegacyDeserializer("shulker_fill_level", AllItemAttributeTypes.SHULKER_FILL_LEVEL);
|
createLegacyDeserializer("shulker_fill_level", tag ->
|
||||||
createLegacyDeserializer("has_color", AllItemAttributeTypes.HAS_COLOR);
|
new ShulkerFillLevelAttribute(ShulkerLevels.fromKey(tag.getString("id"))));
|
||||||
createLegacyDeserializer("has_fluid", AllItemAttributeTypes.HAS_FLUID);
|
createLegacyDeserializer("has_color", tag ->
|
||||||
|
new ColorAttribute(DyeColor.byId(tag.getInt("id"))));
|
||||||
|
createLegacyDeserializer("has_fluid", tag ->
|
||||||
|
new FluidContentsAttribute(BuiltInRegistries.FLUID.get(ResourceLocation.tryParse(tag.getString("id")))));
|
||||||
createLegacyDeserializer("has_name", AllItemAttributeTypes.HAS_NAME);
|
createLegacyDeserializer("has_name", AllItemAttributeTypes.HAS_NAME);
|
||||||
createLegacyDeserializer("book_author", AllItemAttributeTypes.BOOK_AUTHOR);
|
createLegacyDeserializer("book_author", AllItemAttributeTypes.BOOK_AUTHOR);
|
||||||
createLegacyDeserializer("book_copy", AllItemAttributeTypes.BOOK_COPY);
|
createLegacyDeserializer("book_copy", AllItemAttributeTypes.BOOK_COPY);
|
||||||
|
|
Loading…
Add table
Reference in a new issue