diff options
Diffstat (limited to 'src/main/java/lv/enes/mc/eris_alchemy/ErisAlchemyRegistry.java')
| -rw-r--r-- | src/main/java/lv/enes/mc/eris_alchemy/ErisAlchemyRegistry.java | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/ErisAlchemyRegistry.java b/src/main/java/lv/enes/mc/eris_alchemy/ErisAlchemyRegistry.java new file mode 100644 index 0000000..c02a1e6 --- /dev/null +++ b/src/main/java/lv/enes/mc/eris_alchemy/ErisAlchemyRegistry.java | |||
| @@ -0,0 +1,147 @@ | |||
| 1 | package lv.enes.mc.eris_alchemy; | ||
| 2 | |||
| 3 | import lv.enes.mc.eris_alchemy.block.AlchemicalChestBlock; | ||
| 4 | import lv.enes.mc.eris_alchemy.block.entity.AlchemicalChestBlockEntity; | ||
| 5 | import lv.enes.mc.eris_alchemy.menu.AlchemicalChestMenu; | ||
| 6 | import lv.enes.mc.eris_alchemy.recipe.CovalenceRepair; | ||
| 7 | import net.minecraft.core.registries.BuiltInRegistries; | ||
| 8 | import net.minecraft.resources.ResourceLocation; | ||
| 9 | import net.minecraft.world.flag.FeatureFlags; | ||
| 10 | import net.minecraft.world.inventory.AbstractContainerMenu; | ||
| 11 | import net.minecraft.world.inventory.MenuType; | ||
| 12 | import net.minecraft.world.item.BlockItem; | ||
| 13 | import net.minecraft.world.item.Item; | ||
| 14 | import net.minecraft.world.item.Rarity; | ||
| 15 | import net.minecraft.world.item.crafting.Recipe; | ||
| 16 | import net.minecraft.world.item.crafting.RecipeSerializer; | ||
| 17 | import net.minecraft.world.level.block.Block; | ||
| 18 | import net.minecraft.world.level.block.entity.BlockEntity; | ||
| 19 | import net.minecraft.world.level.block.entity.BlockEntityType; | ||
| 20 | import org.quiltmc.qsl.block.entity.api.QuiltBlockEntityTypeBuilder; | ||
| 21 | import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings; | ||
| 22 | import org.quiltmc.qsl.item.setting.api.QuiltItemSettings; | ||
| 23 | |||
| 24 | import java.util.LinkedHashMap; | ||
| 25 | import java.util.Map; | ||
| 26 | import java.util.function.BiConsumer; | ||
| 27 | |||
| 28 | import static net.minecraft.world.level.block.Blocks.ENDER_CHEST; | ||
| 29 | |||
| 30 | public final class ErisAlchemyRegistry { | ||
| 31 | private ErisAlchemyRegistry() {} | ||
| 32 | |||
| 33 | public static final class BlockEntities { | ||
| 34 | private BlockEntities() {} | ||
| 35 | |||
| 36 | private static final Map<ResourceLocation, BlockEntityType<?>> data = new LinkedHashMap<>(); | ||
| 37 | |||
| 38 | public static final BlockEntityType<AlchemicalChestBlockEntity> ALCHEMICAL_CHEST = register( | ||
| 39 | "alchemical_chest", | ||
| 40 | QuiltBlockEntityTypeBuilder.create(AlchemicalChestBlockEntity::new, Blocks.ALCHEMICAL_CHEST) | ||
| 41 | .build() | ||
| 42 | ); | ||
| 43 | |||
| 44 | public static void consume(BiConsumer<? super ResourceLocation, ? super BlockEntityType<?>> consumer) { | ||
| 45 | data.forEach(consumer); | ||
| 46 | } | ||
| 47 | |||
| 48 | private static <T extends BlockEntity> BlockEntityType<T> register(String id, BlockEntityType<T> type) { | ||
| 49 | data.put(new ResourceLocation(ErisAlchemy.ID, id), type); | ||
| 50 | return type; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | public static final class Blocks { | ||
| 55 | private Blocks() {} | ||
| 56 | |||
| 57 | private static final Map<ResourceLocation, Block> data = new LinkedHashMap<>(); | ||
| 58 | |||
| 59 | public static final AlchemicalChestBlock ALCHEMICAL_CHEST = register( | ||
| 60 | "alchemical_chest", | ||
| 61 | new AlchemicalChestBlock(QuiltBlockSettings.copy(ENDER_CHEST)) | ||
| 62 | ); | ||
| 63 | |||
| 64 | public static void consume(BiConsumer<? super ResourceLocation, ? super Block> consumer) { | ||
| 65 | data.forEach(consumer); | ||
| 66 | } | ||
| 67 | |||
| 68 | private static <T extends Block> T register(String id, T block) { | ||
| 69 | data.put(new ResourceLocation(ErisAlchemy.ID, id), block); | ||
| 70 | return block; | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | public static final class Items { | ||
| 75 | private Items() {} | ||
| 76 | |||
| 77 | private static final Map<ResourceLocation, Item> data = new LinkedHashMap<>(); | ||
| 78 | |||
| 79 | public static final Item ALCHEMICAL_CHEST = | ||
| 80 | register(Blocks.ALCHEMICAL_CHEST, new QuiltItemSettings().rarity(Rarity.RARE)); | ||
| 81 | public static final Item LOW_COVALENCE_DUST = | ||
| 82 | register("low_covalence_dust", new Item(new QuiltItemSettings().rarity(Rarity.COMMON))); | ||
| 83 | @SuppressWarnings("unused") | ||
| 84 | public static final Item MEDIUM_COVALENCE_DUST = | ||
| 85 | register("medium_covalence_dust", new Item(new QuiltItemSettings().rarity(Rarity.UNCOMMON))); | ||
| 86 | @SuppressWarnings("unused") | ||
| 87 | public static final Item HIGH_COVALENCE_DUST = | ||
| 88 | register("high_covalence_dust", new Item(new QuiltItemSettings().rarity(Rarity.RARE))); | ||
| 89 | |||
| 90 | public static void consume(BiConsumer<? super ResourceLocation, ? super Item> consumer) { | ||
| 91 | data.forEach(consumer); | ||
| 92 | } | ||
| 93 | |||
| 94 | private static BlockItem register(Block block, QuiltItemSettings settings) { | ||
| 95 | return register(BuiltInRegistries.BLOCK.getKey(block), new BlockItem(block, settings)); | ||
| 96 | } | ||
| 97 | |||
| 98 | private static <T extends Item> T register(String id, T item) { | ||
| 99 | return register(new ResourceLocation(ErisAlchemy.ID, id), item); | ||
| 100 | } | ||
| 101 | |||
| 102 | private static <T extends Item> T register(ResourceLocation id, T item) { | ||
| 103 | data.put(id, item); | ||
| 104 | return item; | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | public static final class Menus { | ||
| 109 | private Menus() {} | ||
| 110 | |||
| 111 | private static final Map<ResourceLocation, MenuType<?>> data = new LinkedHashMap<>(); | ||
| 112 | |||
| 113 | public static final MenuType<AlchemicalChestMenu> ALCHEMICAL_CHEST = | ||
| 114 | register("alchemy_chest", AlchemicalChestMenu::new); | ||
| 115 | |||
| 116 | public static void consume(BiConsumer<? super ResourceLocation, ? super MenuType<?>> consumer) { | ||
| 117 | data.forEach(consumer); | ||
| 118 | } | ||
| 119 | |||
| 120 | private static <T extends AbstractContainerMenu> MenuType<T> register( | ||
| 121 | String id, | ||
| 122 | MenuType.MenuSupplier<T> supplier | ||
| 123 | ) { | ||
| 124 | var menuType = new MenuType<>(supplier, FeatureFlags.VANILLA_SET); | ||
| 125 | data.put(new ResourceLocation(ErisAlchemy.ID, id), menuType); | ||
| 126 | return menuType; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | public static final class RecipeSerializers { | ||
| 131 | private RecipeSerializers() {} | ||
| 132 | |||
| 133 | private static final Map<ResourceLocation, RecipeSerializer<?>> data = new LinkedHashMap<>(); | ||
| 134 | |||
| 135 | public static final RecipeSerializer<CovalenceRepair> COVALENCE_REPAIR = | ||
| 136 | register("covalence_repair", new CovalenceRepair.Serializer()); | ||
| 137 | |||
| 138 | public static void consume(BiConsumer<? super ResourceLocation, ? super RecipeSerializer<?>> consumer) { | ||
| 139 | data.forEach(consumer); | ||
| 140 | } | ||
| 141 | |||
| 142 | private static <T extends Recipe<?>> RecipeSerializer<T> register(String id, RecipeSerializer<T> serializer) { | ||
| 143 | data.put(new ResourceLocation(ErisAlchemy.ID, id), serializer); | ||
| 144 | return serializer; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | } | ||