|
5 | 5 | import com.simibubi.create.AllItems;
|
6 | 6 | import com.simibubi.create.content.schematics.SchematicItem;
|
7 | 7 | import com.tterrag.registrate.util.entry.ItemEntry;
|
8 |
| -import net.minecraft.core.HolderGetter; |
9 | 8 | import net.minecraft.world.item.Item;
|
10 | 9 | import net.minecraft.world.item.ItemStack;
|
11 |
| -import net.minecraft.world.level.block.Block; |
12 | 10 |
|
13 | 11 | import java.util.Arrays;
|
14 | 12 | import java.util.List;
|
15 | 13 |
|
16 | 14 | public enum SchematicUploadItemSource {
|
17 |
| - |
18 |
| - DEFAULT(SchematicItem::create, 0, List.of( |
19 |
| - AllItems.EMPTY_SCHEMATIC, |
20 |
| - AllItems.SCHEMATIC_AND_QUILL, |
21 |
| - AllItems.SCHEMATIC |
22 |
| - ) ), |
23 |
| - PATTERN(PatternSchematicItem::create, 1, List.of( |
24 |
| - PatternSchematicsRegistry.EMPTY_PATTERN_SCHEMATIC, |
25 |
| - PatternSchematicsRegistry.PATTERN_SCHEMATIC |
26 |
| - )) |
27 |
| - ; |
28 |
| - |
29 |
| - final SchematicItemFactory factory; |
30 |
| - final int nbtValue; |
31 |
| - final List<ItemEntry<? extends Item>> schematicSourceItem; |
32 |
| - |
33 |
| - SchematicUploadItemSource(SchematicItemFactory factory, int nbtValue, List<ItemEntry<? extends Item>> schematicSourceItem) { |
34 |
| - this.factory = factory; |
35 |
| - this.nbtValue = nbtValue; |
36 |
| - this.schematicSourceItem = schematicSourceItem; |
37 |
| - } |
38 |
| - |
39 |
| - public SchematicItemFactory getFactory() { |
40 |
| - return factory; |
41 |
| - } |
42 |
| - |
43 |
| - public int getNbtValue() { |
44 |
| - return nbtValue; |
45 |
| - } |
46 |
| - |
47 |
| - public List<ItemEntry<? extends Item>> getSchematicSourceItems() { |
48 |
| - return schematicSourceItem; |
49 |
| - } |
50 |
| - |
51 |
| - public static SchematicUploadItemSource tryFromItemStack(ItemStack stack) { |
52 |
| - return Arrays.stream(values()) |
53 |
| - .filter(source -> source.getSchematicSourceItems() |
54 |
| - .stream().anyMatch(sourceItem -> sourceItem.isIn(stack))) |
55 |
| - .findAny().orElse(null); |
56 |
| - } |
57 |
| - |
58 |
| - public static SchematicUploadItemSource tryFromInt(int nbtValue) { |
59 |
| - return Arrays.stream(values()) |
60 |
| - .filter(source -> source.getNbtValue() == nbtValue) |
61 |
| - .findAny().orElse(null); |
62 |
| - } |
63 |
| - |
64 |
| - public static interface SchematicItemFactory { |
65 |
| - ItemStack create(HolderGetter<Block> lookup, String schematic, String owner); |
66 |
| - } |
67 |
| - |
| 15 | + |
| 16 | + DEFAULT(SchematicItem::create, 0, List.of( |
| 17 | + AllItems.EMPTY_SCHEMATIC, |
| 18 | + AllItems.SCHEMATIC_AND_QUILL, |
| 19 | + AllItems.SCHEMATIC |
| 20 | + )), |
| 21 | + PATTERN(PatternSchematicItem::create, 1, List.of( |
| 22 | + PatternSchematicsRegistry.EMPTY_PATTERN_SCHEMATIC, |
| 23 | + PatternSchematicsRegistry.PATTERN_SCHEMATIC |
| 24 | + )); |
| 25 | + |
| 26 | + final SchematicItemFactory factory; |
| 27 | + final int nbtValue; |
| 28 | + final List<ItemEntry<? extends Item>> schematicSourceItem; |
| 29 | + |
| 30 | + SchematicUploadItemSource(SchematicItemFactory factory, int nbtValue, List<ItemEntry<? extends Item>> schematicSourceItem) { |
| 31 | + this.factory = factory; |
| 32 | + this.nbtValue = nbtValue; |
| 33 | + this.schematicSourceItem = schematicSourceItem; |
| 34 | + } |
| 35 | + |
| 36 | + public SchematicItemFactory getFactory() { |
| 37 | + return factory; |
| 38 | + } |
| 39 | + |
| 40 | + public int getNbtValue() { |
| 41 | + return nbtValue; |
| 42 | + } |
| 43 | + |
| 44 | + public List<ItemEntry<? extends Item>> getSchematicSourceItems() { |
| 45 | + return schematicSourceItem; |
| 46 | + } |
| 47 | + |
| 48 | + public static SchematicUploadItemSource tryFromItemStack(ItemStack stack) { |
| 49 | + return Arrays.stream(values()) |
| 50 | + .filter(source -> source.getSchematicSourceItems() |
| 51 | + .stream().anyMatch(sourceItem -> sourceItem.isIn(stack))) |
| 52 | + .findAny().orElse(null); |
| 53 | + } |
| 54 | + |
| 55 | + public static SchematicUploadItemSource tryFromInt(int nbtValue) { |
| 56 | + return Arrays.stream(values()) |
| 57 | + .filter(source -> source.getNbtValue() == nbtValue) |
| 58 | + .findAny().orElse(null); |
| 59 | + } |
| 60 | + |
| 61 | + public static interface SchematicItemFactory { |
| 62 | + |
| 63 | + ItemStack create(String schematic, String owner); |
| 64 | + |
| 65 | + } |
| 66 | + |
68 | 67 | }
|
0 commit comments