mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Supplier-less
- Remove suppliers in AllItemAttributeTypes
This commit is contained in:
parent
c046d59eb9
commit
670d8f08d6
17 changed files with 25 additions and 24 deletions
|
@ -49,7 +49,7 @@ public class AllItemAttributeTypes {
|
|||
private static final DeferredRegister<ItemAttributeType> REGISTER = DeferredRegister.create(AllRegistries.Keys.ITEM_ATTRIBUTE_TYPES, Create.ID);
|
||||
private static final RecipeWrapper RECIPE_WRAPPER = new RecipeWrapper(new ItemStackHandler(1));
|
||||
|
||||
public static final Supplier<ItemAttributeType>
|
||||
public static final ItemAttributeType
|
||||
PLACEABLE = singleton("placeable", s -> s.getItem() instanceof BlockItem),
|
||||
CONSUMABLE = singleton("consumable", ItemStack::isEdible),
|
||||
FLUID_CONTAINER = singleton("fluid_container", s -> s.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM)
|
||||
|
@ -104,16 +104,17 @@ public class AllItemAttributeTypes {
|
|||
.getMaxLevel() <= e.getValue());
|
||||
}
|
||||
|
||||
private static Supplier<ItemAttributeType> singleton(String id, Predicate<ItemStack> predicate) {
|
||||
private static ItemAttributeType singleton(String id, Predicate<ItemStack> predicate) {
|
||||
return register(id, new SingletonItemAttribute.Type(type -> new SingletonItemAttribute(type, (stack, level) -> predicate.test(stack), id)));
|
||||
}
|
||||
|
||||
private static Supplier<ItemAttributeType> singleton(String id, BiPredicate<ItemStack, Level> predicate) {
|
||||
private static ItemAttributeType singleton(String id, BiPredicate<ItemStack, Level> predicate) {
|
||||
return register(id, new SingletonItemAttribute.Type(type -> new SingletonItemAttribute(type, predicate, id)));
|
||||
}
|
||||
|
||||
private static Supplier<ItemAttributeType> register(String id, ItemAttributeType type) {
|
||||
return REGISTER.register(id, () -> type);
|
||||
private static ItemAttributeType register(String id, ItemAttributeType type) {
|
||||
REGISTER.register(id, () -> type);
|
||||
return type;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
|
|
@ -58,7 +58,7 @@ public class AddedByAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.ADDED_BY.get();
|
||||
return AllItemAttributeTypes.ADDED_BY;
|
||||
}
|
||||
|
||||
public static class Type implements ItemAttributeType {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class BookAuthorAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.BOOK_AUTHOR.get();
|
||||
return AllItemAttributeTypes.BOOK_AUTHOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,7 +46,7 @@ public class BookCopyAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.BOOK_COPY.get();
|
||||
return AllItemAttributeTypes.BOOK_COPY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ColorAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.HAS_COLOR.get();
|
||||
return AllItemAttributeTypes.HAS_COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,7 +48,7 @@ public class EnchantAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.HAS_ENCHANT.get();
|
||||
return AllItemAttributeTypes.HAS_ENCHANT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,7 +62,7 @@ public class FluidContentsAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.HAS_FLUID.get();
|
||||
return AllItemAttributeTypes.HAS_FLUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,7 +66,7 @@ public class InItemGroupAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.IN_ITEM_GROUP.get();
|
||||
return AllItemAttributeTypes.IN_ITEM_GROUP;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,7 +44,7 @@ public class InTagAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.IN_TAG.get();
|
||||
return AllItemAttributeTypes.IN_TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,7 +53,7 @@ public class ItemNameAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.HAS_NAME.get();
|
||||
return AllItemAttributeTypes.HAS_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ShulkerFillLevelAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.SHULKER_FILL_LEVEL.get();
|
||||
return AllItemAttributeTypes.SHULKER_FILL_LEVEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,7 +65,7 @@ public class AstralSorceryAmuletAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.ASTRAL_AMULET.get();
|
||||
return AllItemAttributeTypes.ASTRAL_AMULET;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,7 +56,7 @@ public class AstralSorceryAttunementAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.ASTRAL_ATTUNMENT.get();
|
||||
return AllItemAttributeTypes.ASTRAL_ATTUNMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,7 +52,7 @@ public class AstralSorceryCrystalAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.ASTRAL_CRYSTAL.get();
|
||||
return AllItemAttributeTypes.ASTRAL_CRYSTAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,7 +52,7 @@ public class AstralSorceryPerkGemAttribute implements ItemAttribute {
|
|||
|
||||
@Override
|
||||
public ItemAttributeType getType() {
|
||||
return AllItemAttributeTypes.ASTRAL_PERK_GEM.get();
|
||||
return AllItemAttributeTypes.ASTRAL_PERK_GEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,9 +53,9 @@ public class AllItemAttributeLegacyDeserializers {
|
|||
createLegacyDeserializer("astralsorcery_perk_gem", AllItemAttributeTypes.ASTRAL_PERK_GEM);
|
||||
}
|
||||
|
||||
private static void createLegacyDeserializer(String nbtKey, Supplier<ItemAttributeType> type) {
|
||||
private static void createLegacyDeserializer(String nbtKey, ItemAttributeType type) {
|
||||
createLegacyDeserializer(nbtKey, tag -> {
|
||||
ItemAttribute attribute = type.get().createAttribute();
|
||||
ItemAttribute attribute = type.createAttribute();
|
||||
attribute.load(tag);
|
||||
return attribute;
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ public class StandardTraitsLegacyDeserializer implements ItemAttribute.LegacyDes
|
|||
|
||||
@Override
|
||||
public ItemAttribute readNBT(CompoundTag nbt) {
|
||||
ImmutableBiMap<String, Supplier<ItemAttributeType>> map = ImmutableBiMap.<String, Supplier<ItemAttributeType>>builder()
|
||||
ImmutableBiMap<String, ItemAttributeType> map = ImmutableBiMap.<String, ItemAttributeType>builder()
|
||||
.put("PLACEABLE", AllItemAttributeTypes.PLACEABLE)
|
||||
.put("CONSUMABLE", AllItemAttributeTypes.CONSUMABLE)
|
||||
.put("FLUID_CONTAINER", AllItemAttributeTypes.FLUID_CONTAINER)
|
||||
|
@ -40,9 +40,9 @@ public class StandardTraitsLegacyDeserializer implements ItemAttribute.LegacyDes
|
|||
.put("COMPOSTABLE", AllItemAttributeTypes.COMPOSTABLE)
|
||||
.build();
|
||||
|
||||
for (Map.Entry<String, Supplier<ItemAttributeType>> entry : map.entrySet()) {
|
||||
for (Map.Entry<String, ItemAttributeType> entry : map.entrySet()) {
|
||||
if (nbt.contains(entry.getKey())) {
|
||||
return entry.getValue().get().createAttribute();
|
||||
return entry.getValue().createAttribute();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue