From 150ef3e4979520cdeb2061779d5894ae0bb27827 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Sat, 15 Feb 2025 11:53:23 -0500 Subject: [PATCH] Non-Plural registries --- .../com/simibubi/create/AllRegistries.java | 33 ++++++++++--------- .../belt/transport/TransportedItemStack.java | 16 ++++----- .../fan/processing/AllFanProcessingTypes.java | 2 +- .../fan/processing/FanProcessing.java | 2 +- .../fan/processing/FanProcessingType.java | 2 +- .../processing/FanProcessingTypeRegistry.java | 6 ++-- .../AllArmInteractionPointTypes.java | 2 +- .../mechanicalArm/ArmInteractionPoint.java | 10 +++--- .../ArmInteractionPointType.java | 6 ++-- .../filter/AttributeFilterScreen.java | 2 +- .../attribute/AllItemAttributeTypes.java | 7 ++-- .../item/filter/attribute/ItemAttribute.java | 6 ++-- 12 files changed, 48 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllRegistries.java b/src/main/java/com/simibubi/create/AllRegistries.java index 4b7d62b443..8683ac7d7e 100644 --- a/src/main/java/com/simibubi/create/AllRegistries.java +++ b/src/main/java/com/simibubi/create/AllRegistries.java @@ -1,29 +1,30 @@ package com.simibubi.create; +import java.util.function.Supplier; + import com.simibubi.create.content.kinetics.fan.processing.FanProcessingType; import com.simibubi.create.content.kinetics.mechanicalArm.ArmInteractionPointType; import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttributeType; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; + import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.NewRegistryEvent; import net.minecraftforge.registries.RegistryBuilder; -import java.util.function.Supplier; - @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class AllRegistries { - public static Supplier> ARM_INTERACTION_POINT_TYPES; - public static Supplier> FAN_PROCESSING_TYPES; - public static Supplier> ITEM_ATTRIBUTE_TYPES; + public static Supplier> ARM_INTERACTION_POINT_TYPE; + public static Supplier> FAN_PROCESSING_TYPE; + public static Supplier> ITEM_ATTRIBUTE_TYPE; public static final class Keys { - public static final ResourceKey> ARM_INTERACTION_POINT_TYPES = key("arm_interaction_point_types"); - public static final ResourceKey> FAN_PROCESSING_TYPES = key("fan_processing_types"); - public static final ResourceKey> ITEM_ATTRIBUTE_TYPES = key("item_attribute_types"); + public static final ResourceKey> ARM_INTERACTION_POINT_TYPE = key("arm_interaction_point_type"); + public static final ResourceKey> FAN_PROCESSING_TYPE = key("fan_processing_type"); + public static final ResourceKey> ITEM_ATTRIBUTE_TYPE = key("item_attribute_type"); private static ResourceKey> key(String name) { return ResourceKey.createRegistryKey(Create.asResource(name)); @@ -32,16 +33,16 @@ public class AllRegistries { @SubscribeEvent public static void registerRegistries(NewRegistryEvent event) { - ARM_INTERACTION_POINT_TYPES = event.create(new RegistryBuilder() - .setName(Keys.ARM_INTERACTION_POINT_TYPES.location()) - .disableSaving()); - - FAN_PROCESSING_TYPES = event.create(new RegistryBuilder() - .setName(Keys.FAN_PROCESSING_TYPES.location()) + ARM_INTERACTION_POINT_TYPE = event.create(new RegistryBuilder() + .setName(Keys.ARM_INTERACTION_POINT_TYPE.location()) .disableSaving()); - ITEM_ATTRIBUTE_TYPES = event.create(new RegistryBuilder() - .setName(Keys.ITEM_ATTRIBUTE_TYPES.location()) + FAN_PROCESSING_TYPE = event.create(new RegistryBuilder() + .setName(Keys.FAN_PROCESSING_TYPE.location()) + .disableSaving()); + + ITEM_ATTRIBUTE_TYPE = event.create(new RegistryBuilder() + .setName(Keys.ITEM_ATTRIBUTE_TYPE.location()) .disableSaving()); } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/transport/TransportedItemStack.java b/src/main/java/com/simibubi/create/content/kinetics/belt/transport/TransportedItemStack.java index e982345123..b9ea5a275b 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/transport/TransportedItemStack.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/transport/TransportedItemStack.java @@ -80,16 +80,16 @@ public class TransportedItemStack implements Comparable { nbt.putInt("InSegment", insertedAt); nbt.putInt("Angle", angle); nbt.putInt("InDirection", insertedFrom.get3DDataValue()); - + if (processedBy != null && processedBy != AllFanProcessingTypes.NONE) { - ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPES.get().getKey(processedBy); + ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPE.get().getKey(processedBy); if (key == null) throw new IllegalArgumentException("Could not get id for FanProcessingType " + processedBy + "!"); - + nbt.putString("FanProcessingType", key.toString()); nbt.putInt("FanProcessingTime", processingTime); } - + if (locked) nbt.putBoolean("Locked", locked); if (lockedExternally) @@ -108,18 +108,18 @@ public class TransportedItemStack implements Comparable { stack.insertedFrom = Direction.from3DDataValue(nbt.getInt("InDirection")); stack.locked = nbt.getBoolean("Locked"); stack.lockedExternally = nbt.getBoolean("LockedExternally"); - + if (nbt.contains("FanProcessingType")) { stack.processedBy = AllFanProcessingTypes.parseLegacy(nbt.getString("FanProcessingType")); stack.processingTime = nbt.getInt("FanProcessingTime"); } - + return stack; } - + public void clearFanProcessingData() { processedBy = null; processingTime = 0; } -} \ No newline at end of file +} diff --git a/src/main/java/com/simibubi/create/content/kinetics/fan/processing/AllFanProcessingTypes.java b/src/main/java/com/simibubi/create/content/kinetics/fan/processing/AllFanProcessingTypes.java index 767a93959e..9b7c53d734 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/fan/processing/AllFanProcessingTypes.java +++ b/src/main/java/com/simibubi/create/content/kinetics/fan/processing/AllFanProcessingTypes.java @@ -60,7 +60,7 @@ import net.minecraftforge.items.wrapper.RecipeWrapper; import net.minecraftforge.registries.DeferredRegister; public class AllFanProcessingTypes { - private static final DeferredRegister REGISTER = DeferredRegister.create(AllRegistries.Keys.FAN_PROCESSING_TYPES, Create.ID); + private static final DeferredRegister REGISTER = DeferredRegister.create(AllRegistries.Keys.FAN_PROCESSING_TYPE, Create.ID); public static final NoneType NONE = register("none", new NoneType()); public static final BlastingType BLASTING = register("blasting", new BlastingType()); diff --git a/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessing.java b/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessing.java index 3933e004d0..3d027f0360 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessing.java +++ b/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessing.java @@ -95,7 +95,7 @@ public class FanProcessing { CompoundTag processing = createData.getCompound("Processing"); if (!processing.contains("Type") || AllFanProcessingTypes.parseLegacy(processing.getString("Type")) != type) { - ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPES.get().getKey(type); + ResourceLocation key = AllRegistries.FAN_PROCESSING_TYPE.get().getKey(type); if (key == null) throw new IllegalArgumentException("Could not get id for FanProcessingType " + type + "!"); diff --git a/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessingType.java b/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessingType.java index d30e56d67c..da3bf3b5de 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessingType.java +++ b/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessingType.java @@ -36,7 +36,7 @@ public interface FanProcessingType { if (id == null) { return AllFanProcessingTypes.NONE; } - FanProcessingType type = AllRegistries.FAN_PROCESSING_TYPES.get().getValue(id); + FanProcessingType type = AllRegistries.FAN_PROCESSING_TYPE.get().getValue(id); if (type == null) { return AllFanProcessingTypes.NONE; } diff --git a/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessingTypeRegistry.java b/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessingTypeRegistry.java index 5bdeb86fc1..da2f4b6d38 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessingTypeRegistry.java +++ b/src/main/java/com/simibubi/create/content/kinetics/fan/processing/FanProcessingTypeRegistry.java @@ -3,12 +3,12 @@ package com.simibubi.create.content.kinetics.fan.processing; import java.util.Collections; import java.util.List; +import org.jetbrains.annotations.UnmodifiableView; + import com.simibubi.create.AllRegistries; import it.unimi.dsi.fastutil.objects.ReferenceArrayList; -import org.jetbrains.annotations.UnmodifiableView; - public class FanProcessingTypeRegistry { private static List sortedTypes = null; @UnmodifiableView @@ -19,7 +19,7 @@ public class FanProcessingTypeRegistry { if (sortedTypes == null) { sortedTypes = new ReferenceArrayList<>(); - sortedTypes.addAll(AllRegistries.FAN_PROCESSING_TYPES.get().getValues()); + sortedTypes.addAll(AllRegistries.FAN_PROCESSING_TYPE.get().getValues()); sortedTypes.sort((t1, t2) -> t2.getPriority() - t1.getPriority()); sortedTypesView = Collections.unmodifiableList(sortedTypes); diff --git a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java index 2f6c8fb9a6..122df9608b 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java +++ b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java @@ -64,7 +64,7 @@ import net.minecraftforge.items.wrapper.SidedInvWrapper; import net.minecraftforge.registries.DeferredRegister; public class AllArmInteractionPointTypes { - private static final DeferredRegister REGISTER = DeferredRegister.create(AllRegistries.Keys.ARM_INTERACTION_POINT_TYPES, Create.ID); + private static final DeferredRegister REGISTER = DeferredRegister.create(AllRegistries.Keys.ARM_INTERACTION_POINT_TYPE, Create.ID); static { register("basin", new BasinType()); diff --git a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInteractionPoint.java b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInteractionPoint.java index 89a0e85a47..5a79b476d2 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInteractionPoint.java +++ b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInteractionPoint.java @@ -5,8 +5,8 @@ import javax.annotation.Nullable; import com.simibubi.create.AllRegistries; import com.simibubi.create.content.contraptions.StructureTransform; -import net.createmod.catnip.nbt.NBTHelper; import net.createmod.catnip.math.VecHelper; +import net.createmod.catnip.nbt.NBTHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; @@ -17,6 +17,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; + import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; @@ -89,7 +90,8 @@ public class ArmInteractionPoint { return type.canCreatePoint(level, pos, cachedState); } - public void keepAlive() {} + public void keepAlive() { + } @Nullable protected IItemHandler getHandler() { @@ -136,7 +138,7 @@ public class ArmInteractionPoint { } public final CompoundTag serialize(BlockPos anchor) { - ResourceLocation key = AllRegistries.ARM_INTERACTION_POINT_TYPES.get().getKey(type); + ResourceLocation key = AllRegistries.ARM_INTERACTION_POINT_TYPE.get().getKey(type); if (key == null) throw new IllegalArgumentException("Could not get id for ArmInteractionPointType " + type + "!"); @@ -152,7 +154,7 @@ public class ArmInteractionPoint { ResourceLocation id = ResourceLocation.tryParse(nbt.getString("Type")); if (id == null) return null; - ArmInteractionPointType type = AllRegistries.ARM_INTERACTION_POINT_TYPES.get().getValue(id); + ArmInteractionPointType type = AllRegistries.ARM_INTERACTION_POINT_TYPE.get().getValue(id); if (type == null) return null; BlockPos pos = NbtUtils.readBlockPos(nbt.getCompound("Pos")).offset(anchor); diff --git a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInteractionPointType.java b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInteractionPointType.java index 677cef13ad..a60485b3ab 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInteractionPointType.java +++ b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/ArmInteractionPointType.java @@ -6,6 +6,8 @@ import java.util.function.Consumer; import javax.annotation.Nullable; +import org.jetbrains.annotations.UnmodifiableView; + import com.simibubi.create.AllRegistries; import it.unimi.dsi.fastutil.objects.ReferenceArrayList; @@ -13,8 +15,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; -import org.jetbrains.annotations.UnmodifiableView; - public abstract class ArmInteractionPointType { private static List sortedTypes = null; @UnmodifiableView @@ -29,7 +29,7 @@ public abstract class ArmInteractionPointType { if (sortedTypes == null) { sortedTypes = new ReferenceArrayList<>(); - sortedTypes.addAll(AllRegistries.ARM_INTERACTION_POINT_TYPES.get().getValues()); + sortedTypes.addAll(AllRegistries.ARM_INTERACTION_POINT_TYPE.get().getValues()); sortedTypes.sort((t1, t2) -> t2.getPriority() - t1.getPriority()); sortedTypesView = Collections.unmodifiableList(sortedTypes); diff --git a/src/main/java/com/simibubi/create/content/logistics/filter/AttributeFilterScreen.java b/src/main/java/com/simibubi/create/content/logistics/filter/AttributeFilterScreen.java index 07aa445acd..6ee0975e35 100644 --- a/src/main/java/com/simibubi/create/content/logistics/filter/AttributeFilterScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/filter/AttributeFilterScreen.java @@ -146,7 +146,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen options = attributesOfItem.stream() .map(a -> a.format(false)) diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/AllItemAttributeTypes.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/AllItemAttributeTypes.java index 174111dd01..76218fbc0b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/AllItemAttributeTypes.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/AllItemAttributeTypes.java @@ -2,7 +2,6 @@ package com.simibubi.create.content.logistics.item.filter.attribute; import java.util.function.BiPredicate; import java.util.function.Predicate; -import java.util.function.Supplier; import org.jetbrains.annotations.ApiStatus; @@ -46,7 +45,7 @@ import net.minecraftforge.registries.DeferredRegister; // TODO - Documentation public class AllItemAttributeTypes { - private static final DeferredRegister REGISTER = DeferredRegister.create(AllRegistries.Keys.ITEM_ATTRIBUTE_TYPES, Create.ID); + private static final DeferredRegister REGISTER = DeferredRegister.create(AllRegistries.Keys.ITEM_ATTRIBUTE_TYPE, Create.ID); private static final RecipeWrapper RECIPE_WRAPPER = new RecipeWrapper(new ItemStackHandler(1)); public static final ItemAttributeType @@ -72,7 +71,7 @@ public class AllItemAttributeTypes { BLASTABLE = singleton("blastable", (s, w) -> testRecipe(s, w, RecipeType.BLASTING)), COMPOSTABLE = singleton("compostable", s -> ComposterBlock.COMPOSTABLES.containsKey(s.getItem())), - IN_TAG = register("in_tag", new InTagAttribute.Type()), + IN_TAG = register("in_tag", new InTagAttribute.Type()), IN_ITEM_GROUP = register("in_item_group", new InItemGroupAttribute.Type()), ADDED_BY = register("added_by", new AddedByAttribute.Type()), HAS_ENCHANT = register("has_enchant", new EnchantAttribute.Type()), @@ -83,7 +82,7 @@ public class AllItemAttributeTypes { BOOK_AUTHOR = register("book_author", new BookAuthorAttribute.Type()), BOOK_COPY = register("book_copy", new BookCopyAttribute.Type()), - ASTRAL_AMULET = register("astral_amulet", new AstralSorceryAmuletAttribute.Type()), + ASTRAL_AMULET = register("astral_amulet", new AstralSorceryAmuletAttribute.Type()), ASTRAL_ATTUNMENT = register("astral_attunment", new AstralSorceryAttunementAttribute.Type()), ASTRAL_CRYSTAL = register("astral_crystal", new AstralSorceryCrystalAttribute.Type()), ASTRAL_PERK_GEM = register("astral_perk_gem", new AstralSorceryPerkGemAttribute.Type()); diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ItemAttribute.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ItemAttribute.java index b17d142dab..a683d9fbca 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ItemAttribute.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/attribute/ItemAttribute.java @@ -20,7 +20,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public interface ItemAttribute { static CompoundTag saveStatic(ItemAttribute attribute) { CompoundTag nbt = new CompoundTag(); - ResourceLocation id = AllRegistries.ITEM_ATTRIBUTE_TYPES.get().getKey(attribute.getType()); + ResourceLocation id = AllRegistries.ITEM_ATTRIBUTE_TYPE.get().getKey(attribute.getType()); if (id == null) throw new IllegalArgumentException("Cannot get " + attribute.getType() + "as it does not exist in AllRegistries.ITEM_ATTRIBUTE_TYPES"); @@ -42,7 +42,7 @@ public interface ItemAttribute { if (id == null) return null; - ItemAttributeType type = AllRegistries.ITEM_ATTRIBUTE_TYPES.get().getValue(id); + ItemAttributeType type = AllRegistries.ITEM_ATTRIBUTE_TYPE.get().getValue(id); if (type == null) return null; @@ -53,7 +53,7 @@ public interface ItemAttribute { static List getAllAttributes(ItemStack stack, Level level) { List attributes = new ArrayList<>(); - for (ItemAttributeType type : AllRegistries.ITEM_ATTRIBUTE_TYPES.get()) { + for (ItemAttributeType type : AllRegistries.ITEM_ATTRIBUTE_TYPE.get()) { attributes.addAll(type.getAllAttributes(stack, level)); } return attributes;