1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
package lv.enes.mc.eris_alchemy;
import lv.enes.mc.eris_alchemy.block.AlchemicalChestBlock;
import lv.enes.mc.eris_alchemy.block.EnergyCondenserBlock;
import lv.enes.mc.eris_alchemy.block.entity.AlchemicalChestEntity;
import lv.enes.mc.eris_alchemy.block.entity.EnergyCondenserEntity;
import lv.enes.mc.eris_alchemy.menu.AlchemicalChestMenu;
import lv.enes.mc.eris_alchemy.menu.EnergyCondenserMenu;
import lv.enes.mc.eris_alchemy.recipe.CovalenceRepair;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.resources.model.Material;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.quiltmc.qsl.block.entity.api.QuiltBlockEntityTypeBuilder;
import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings;
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import static net.minecraft.world.level.block.Blocks.ENDER_CHEST;
public final class ErisAlchemyRegistry {
private ErisAlchemyRegistry() {}
public static final class BlockEntities {
private BlockEntities() {}
private static final Map<ResourceLocation, BlockEntityType<?>> data = new LinkedHashMap<>();
public static final BlockEntityType<AlchemicalChestEntity> ALCHEMICAL_CHEST = register(
"alchemical_chest",
QuiltBlockEntityTypeBuilder.create(AlchemicalChestEntity::new, Blocks.ALCHEMICAL_CHEST)
.build()
);
public static final BlockEntityType<EnergyCondenserEntity> ENERGY_CONDENSER = register(
"energy_condenser",
QuiltBlockEntityTypeBuilder.create(EnergyCondenserEntity::new, Blocks.ENERGY_CONDENSER)
.build()
);
public static void consume(BiConsumer<? super ResourceLocation, ? super BlockEntityType<?>> consumer) {
data.forEach(consumer);
}
private static <T extends BlockEntity> BlockEntityType<T> register(String id, BlockEntityType<T> type) {
data.put(new ResourceLocation(ErisAlchemy.ID, id), type);
return type;
}
}
public static final class Blocks {
private Blocks() {}
private static final Map<ResourceLocation, Block> data = new LinkedHashMap<>();
public static final AlchemicalChestBlock ALCHEMICAL_CHEST = register(
"alchemical_chest",
new AlchemicalChestBlock(QuiltBlockSettings.copy(ENDER_CHEST))
);
public static final EnergyCondenserBlock ENERGY_CONDENSER = register(
"energy_condenser",
new EnergyCondenserBlock(QuiltBlockSettings.copy(ENDER_CHEST))
);
public static void consume(BiConsumer<? super ResourceLocation, ? super Block> consumer) {
data.forEach(consumer);
}
private static <T extends Block> T register(String id, T block) {
data.put(new ResourceLocation(ErisAlchemy.ID, id), block);
return block;
}
}
public static final class Items {
private Items() {}
private static final Map<ResourceLocation, Item> data = new LinkedHashMap<>();
public static final Item ALCHEMICAL_CHEST =
register(Blocks.ALCHEMICAL_CHEST, new QuiltItemSettings().rarity(Rarity.RARE));
@SuppressWarnings("unused")
public static final Item ENERGY_CONDENSER =
register(Blocks.ENERGY_CONDENSER, new QuiltItemSettings().rarity(Rarity.EPIC));
public static final Item LOW_COVALENCE_DUST =
register("low_covalence_dust", new Item(new QuiltItemSettings().rarity(Rarity.COMMON)));
@SuppressWarnings("unused")
public static final Item MEDIUM_COVALENCE_DUST =
register("medium_covalence_dust", new Item(new QuiltItemSettings().rarity(Rarity.UNCOMMON)));
@SuppressWarnings("unused")
public static final Item HIGH_COVALENCE_DUST =
register("high_covalence_dust", new Item(new QuiltItemSettings().rarity(Rarity.RARE)));
public static void consume(BiConsumer<? super ResourceLocation, ? super Item> consumer) {
data.forEach(consumer);
}
private static BlockItem register(Block block, QuiltItemSettings settings) {
return register(BuiltInRegistries.BLOCK.getKey(block), new BlockItem(block, settings));
}
private static <T extends Item> T register(String id, T item) {
return register(new ResourceLocation(ErisAlchemy.ID, id), item);
}
private static <T extends Item> T register(ResourceLocation id, T item) {
data.put(id, item);
return item;
}
}
public static final class Materials {
private Materials() {}
public static final Material ALCHEMICAL_CHEST = new Material(
Sheets.CHEST_SHEET,
new ResourceLocation(ErisAlchemy.ID, "entity/chest/alchemical_chest")
);
public static final Material ENERGY_CONDENSER = new Material(
Sheets.CHEST_SHEET,
new ResourceLocation(ErisAlchemy.ID, "entity/chest/energy_condenser")
);
}
public static final class Menus {
private Menus() {}
private static final Map<ResourceLocation, MenuType<?>> data = new LinkedHashMap<>();
public static final MenuType<AlchemicalChestMenu> ALCHEMICAL_CHEST =
register("alchemy_chest", AlchemicalChestMenu::new);
public static final ExtendedScreenHandlerType<EnergyCondenserMenu> ENERGY_CONDENSER =
registerExt("energy_condenser", EnergyCondenserMenu::new);
public static void consume(BiConsumer<? super ResourceLocation, ? super MenuType<?>> consumer) {
data.forEach(consumer);
}
private static <T extends AbstractContainerMenu> MenuType<T> register(
String id,
MenuType.MenuSupplier<T> supplier
) {
return registerCommon(id, new MenuType<>(supplier, FeatureFlags.VANILLA_SET));
}
private static <T extends AbstractContainerMenu> ExtendedScreenHandlerType<T> registerExt(
String id,
ExtendedScreenHandlerType.ExtendedFactory<T> supplier
) {
return registerCommon(id, new ExtendedScreenHandlerType<>(supplier));
}
private static <M extends AbstractContainerMenu, T extends MenuType<? extends M>> T registerCommon(
String id,
T menuType
) {
data.put(new ResourceLocation(ErisAlchemy.ID, id), menuType);
return menuType;
}
}
public static final class NetworkingConstants {
private NetworkingConstants() {}
public static final ResourceLocation UPDATE_SYNCED_VALUE
= new ResourceLocation(ErisAlchemy.ID, "update_synced_value");
}
public static final class RecipeSerializers {
private RecipeSerializers() {}
private static final Map<ResourceLocation, RecipeSerializer<?>> data = new LinkedHashMap<>();
public static final RecipeSerializer<CovalenceRepair> COVALENCE_REPAIR =
register("covalence_repair", new CovalenceRepair.Serializer());
public static void consume(BiConsumer<? super ResourceLocation, ? super RecipeSerializer<?>> consumer) {
data.forEach(consumer);
}
private static <T extends Recipe<?>> RecipeSerializer<T> register(String id, RecipeSerializer<T> serializer) {
data.put(new ResourceLocation(ErisAlchemy.ID, id), serializer);
return serializer;
}
}
}
|