Skip to content

Commit

Permalink
Reorganize some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Nov 21, 2023
1 parent 60f1335 commit d098477
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.sammy.malum.registry.common.item.*;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraftforge.registries.*;

import java.util.Collection;
import java.util.Map;
Expand All @@ -17,7 +19,6 @@ public class SpiritTypeProperty extends Property<String> {
public SpiritTypeProperty(String name, Collection<MalumSpiritType> types) {
super(name, String.class);
this.values = ImmutableSet.copyOf(types.stream().map(s -> s.identifier).collect(Collectors.toList()));

for (MalumSpiritType type : types) {
if (this.types.containsKey(type.identifier)) {
throw new IllegalArgumentException("Multiple values have the same name '" + type.identifier + "'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
public class ItemRegistry {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MALUM);

public static final Map<ResourceKey<CreativeModeTab>, Set<ResourceLocation>> TAB_SORTING = new HashMap<>();
public static final Map<ResourceKey<CreativeModeTab>, List<ResourceLocation>> TAB_SORTING = new HashMap<>();

public static class LodestoneItemProperties extends Item.Properties {
public final ResourceKey<CreativeModeTab> tab;
Expand Down Expand Up @@ -110,7 +110,7 @@ public static Item.Properties HIDDEN_PROPERTIES() {
}
public static <T extends Item> RegistryObject<T> register(String name, Item.Properties properties, Function<Item.Properties, T> function) {
if (properties instanceof LodestoneItemProperties lodestoneItemProperties) {
TAB_SORTING.computeIfAbsent(lodestoneItemProperties.tab, (key) -> new HashSet<>()).add(MalumMod.malumPath(name));
TAB_SORTING.computeIfAbsent(lodestoneItemProperties.tab, (key) -> new ArrayList<>()).add(MalumMod.malumPath(name));
}
return ITEMS.register(name, () -> function.apply(properties));
}
Expand Down Expand Up @@ -351,6 +351,21 @@ public static <T extends Item> RegistryObject<T> register(String name, Item.Prop
//endregion

//region ores
public static final RegistryObject<Item> SOULSTONE_ORE = register("soulstone_ore", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.SOULSTONE_ORE.get(), p));
public static final RegistryObject<Item> DEEPSLATE_SOULSTONE_ORE = register("deepslate_soulstone_ore", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.DEEPSLATE_SOULSTONE_ORE.get(), p));
public static final RegistryObject<Item> RAW_SOULSTONE = register("raw_soulstone", DEFAULT_PROPERTIES(), Item::new);
public static final RegistryObject<Item> CRUSHED_SOULSTONE = register("crushed_soulstone", DEFAULT_PROPERTIES(), Item::new);
public static final RegistryObject<Item> BLOCK_OF_RAW_SOULSTONE = register("block_of_raw_soulstone", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.BLOCK_OF_RAW_SOULSTONE.get(), p));
public static final RegistryObject<Item> PROCESSED_SOULSTONE = register("processed_soulstone", DEFAULT_PROPERTIES(), Item::new);
public static final RegistryObject<Item> BLOCK_OF_SOULSTONE = register("block_of_soulstone", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.BLOCK_OF_SOULSTONE.get(), p));

public static final RegistryObject<Item> BRILLIANT_STONE = register("brilliant_stone", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.BRILLIANT_STONE.get(), p));
public static final RegistryObject<Item> BRILLIANT_DEEPSLATE = register("brilliant_deepslate", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.BRILLIANT_DEEPSLATE.get(), p));
public static final RegistryObject<Item> CLUSTER_OF_BRILLIANCE = register("cluster_of_brilliance", DEFAULT_PROPERTIES(), Item::new);
public static final RegistryObject<Item> CRUSHED_BRILLIANCE = register("crushed_brilliance", DEFAULT_PROPERTIES(), Item::new);
public static final RegistryObject<Item> CHUNK_OF_BRILLIANCE = register("chunk_of_brilliance", DEFAULT_PROPERTIES(), (p) -> new BrillianceChunkItem(p.food((new FoodProperties.Builder()).fast().alwaysEat().build())));
public static final RegistryObject<Item> BLOCK_OF_BRILLIANCE = register("block_of_brilliance", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.BLOCK_OF_BRILLIANCE.get(), p));

public static final RegistryObject<Item> ARCANE_CHARCOAL = register("arcane_charcoal", DEFAULT_PROPERTIES(), (p) -> new LodestoneFuelItem(p, 3200));
public static final RegistryObject<Item> ARCANE_CHARCOAL_FRAGMENT = register("arcane_charcoal_fragment", DEFAULT_PROPERTIES(), (p) -> new LodestoneFuelItem(p, 400));
public static final RegistryObject<Item> BLOCK_OF_ARCANE_CHARCOAL = register("block_of_arcane_charcoal", DEFAULT_PROPERTIES(), (p) -> new LodestoneFuelBlockItem(BlockRegistry.BLOCK_OF_ARCANE_CHARCOAL.get(), p, 32000));
Expand All @@ -363,28 +378,13 @@ public static <T extends Item> RegistryObject<T> register(String name, Item.Prop
public static final RegistryObject<Item> NATURAL_QUARTZ_ORE = register("natural_quartz_ore", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.NATURAL_QUARTZ_ORE.get(), p));
public static final RegistryObject<Item> DEEPSLATE_QUARTZ_ORE = register("deepslate_quartz_ore", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.DEEPSLATE_QUARTZ_ORE.get(), p));
public static final RegistryObject<Item> NATURAL_QUARTZ = register("natural_quartz", DEFAULT_PROPERTIES(), (p) -> new ItemNameBlockItem(BlockRegistry.NATURAL_QUARTZ_CLUSTER.get(), p));

public static final RegistryObject<Item> BRILLIANT_STONE = register("brilliant_stone", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.BRILLIANT_STONE.get(), p));
public static final RegistryObject<Item> BRILLIANT_DEEPSLATE = register("brilliant_deepslate", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.BRILLIANT_DEEPSLATE.get(), p));
public static final RegistryObject<Item> CLUSTER_OF_BRILLIANCE = register("cluster_of_brilliance", DEFAULT_PROPERTIES(), Item::new);
public static final RegistryObject<Item> CRUSHED_BRILLIANCE = register("crushed_brilliance", DEFAULT_PROPERTIES(), Item::new);
public static final RegistryObject<Item> CHUNK_OF_BRILLIANCE = register("chunk_of_brilliance", DEFAULT_PROPERTIES(), (p) -> new BrillianceChunkItem(p.food((new FoodProperties.Builder()).fast().alwaysEat().build())));
public static final RegistryObject<Item> BLOCK_OF_BRILLIANCE = register("block_of_brilliance", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.BLOCK_OF_BRILLIANCE.get(), p));

public static final RegistryObject<Item> SOULSTONE_ORE = register("soulstone_ore", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.SOULSTONE_ORE.get(), p));
public static final RegistryObject<Item> DEEPSLATE_SOULSTONE_ORE = register("deepslate_soulstone_ore", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.DEEPSLATE_SOULSTONE_ORE.get(), p));
public static final RegistryObject<Item> RAW_SOULSTONE = register("raw_soulstone", DEFAULT_PROPERTIES(), Item::new);
public static final RegistryObject<Item> CRUSHED_SOULSTONE = register("crushed_soulstone", DEFAULT_PROPERTIES(), Item::new);
public static final RegistryObject<Item> BLOCK_OF_RAW_SOULSTONE = register("block_of_raw_soulstone", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.BLOCK_OF_RAW_SOULSTONE.get(), p));
public static final RegistryObject<Item> PROCESSED_SOULSTONE = register("processed_soulstone", DEFAULT_PROPERTIES(), Item::new);
public static final RegistryObject<Item> BLOCK_OF_SOULSTONE = register("block_of_soulstone", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.BLOCK_OF_SOULSTONE.get(), p));
//endregion

//region crafting blocks
public static final RegistryObject<Item> SPIRIT_ALTAR = register("spirit_altar", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.SPIRIT_ALTAR.get(), p));
public static final RegistryObject<Item> WEAVERS_WORKBENCH = register("weavers_workbench", DEFAULT_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.WEAVERS_WORKBENCH.get(), COSMETIC_PROPERTIES()));
public static final RegistryObject<Item> WEAVERS_WORKBENCH = register("weavers_workbench", COSMETIC_PROPERTIES(), (p) -> new BlockItem(BlockRegistry.WEAVERS_WORKBENCH.get(), COSMETIC_PROPERTIES()));
public static final RegistryObject<Item> SPIRIT_JAR = register("spirit_jar", DEFAULT_PROPERTIES(), (p) -> new SpiritJarItem(BlockRegistry.SPIRIT_JAR.get(), p));
public static final RegistryObject<Item> SOUL_VIAL = register("soul_vial", DEFAULT_PROPERTIES(), (p) -> new SoulVialItem(BlockRegistry.SOUL_VIAL.get(), HIDDEN_PROPERTIES()));
public static final RegistryObject<Item> SOUL_VIAL = register("soul_vial", HIDDEN_PROPERTIES(), (p) -> new SoulVialItem(BlockRegistry.SOUL_VIAL.get(), HIDDEN_PROPERTIES()));
public static final RegistryObject<Item> RUNEWOOD_OBELISK = register("runewood_obelisk", DEFAULT_PROPERTIES(), (p) -> new MultiBlockItem(BlockRegistry.RUNEWOOD_OBELISK.get(), p, RunewoodObeliskBlockEntity.STRUCTURE));
public static final RegistryObject<Item> BRILLIANT_OBELISK = register("brilliant_obelisk", DEFAULT_PROPERTIES(), (p) -> new MultiBlockItem(BlockRegistry.BRILLIANT_OBELISK.get(), p, BrilliantObeliskBlockEntity.STRUCTURE));
public static final RegistryObject<Item> SPIRIT_CRUCIBLE = register("spirit_crucible", DEFAULT_PROPERTIES(), (p) -> new MultiBlockItem(BlockRegistry.SPIRIT_CRUCIBLE.get(), p, SpiritCrucibleCoreBlockEntity.STRUCTURE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,37 @@ public class CreativeTabRegistry {
public static final RegistryObject<CreativeModeTab> CONTENT = CREATIVE_MODE_TABS.register(MalumMod.MALUM + ".content",
() -> CreativeModeTab.builder()
.title(Component.translatable("itemGroup." + MalumMod.MALUM + "_basis_of_magic"))
.icon(() -> ItemRegistry.SPIRIT_ALTAR.get().getDefaultInstance())
.displayItems((parameters, output) -> output.accept(ItemRegistry.SPIRIT_ALTAR.get())).build()
.icon(() -> ItemRegistry.SPIRIT_ALTAR.get().getDefaultInstance()).build()
);

public static final RegistryObject<CreativeModeTab> BUILDING = CREATIVE_MODE_TABS.register(MalumMod.MALUM + ".building",
() -> CreativeModeTab.builder()
.title(Component.translatable("itemGroup." + MalumMod.MALUM + "_arcane_construct"))
.icon(() -> ItemRegistry.TAINTED_ROCK.get().getDefaultInstance())
.displayItems((parameters, output) -> output.accept(ItemRegistry.TAINTED_ROCK.get())).build()
.icon(() -> ItemRegistry.TAINTED_ROCK.get().getDefaultInstance()).build()
);

public static final RegistryObject<CreativeModeTab> NATURE = CREATIVE_MODE_TABS.register(MalumMod.MALUM + ".nature",
() -> CreativeModeTab.builder()
.title(Component.translatable("itemGroup." + MalumMod.MALUM + "_natural_wonders"))
.icon(() -> ItemRegistry.RUNEWOOD_SAPLING.get().getDefaultInstance())
.displayItems((parameters, output) -> output.accept(ItemRegistry.RUNEWOOD_SAPLING.get())).build()
.icon(() -> ItemRegistry.RUNEWOOD_SAPLING.get().getDefaultInstance()).build()
);

public static final RegistryObject<CreativeModeTab> METALLURGY = CREATIVE_MODE_TABS.register(MalumMod.MALUM + ".metallurgy",
() -> CreativeModeTab.builder()
.title(Component.translatable("itemGroup." + MalumMod.MALUM + "_metallurgic_magics"))
.icon(() -> ItemRegistry.ALCHEMICAL_IMPETUS.get().getDefaultInstance())
.displayItems((parameters, output) -> output.accept(ItemRegistry.ALCHEMICAL_IMPETUS.get())).build()
.icon(() -> ItemRegistry.ALCHEMICAL_IMPETUS.get().getDefaultInstance()).build()
);

public static final RegistryObject<CreativeModeTab> VOID = CREATIVE_MODE_TABS.register(MalumMod.MALUM + ".void",
() -> CreativeModeTab.builder()
.title(Component.translatable("itemGroup." + MalumMod.MALUM + "_void_chronicles"))
.icon(() -> ItemRegistry.STRANGE_NUCLEUS.get().getDefaultInstance())
.displayItems((parameters, output) -> output.accept(ItemRegistry.STRANGE_NUCLEUS.get())).build()
.icon(() -> ItemRegistry.STRANGE_NUCLEUS.get().getDefaultInstance()).build()
);

public static final RegistryObject<CreativeModeTab> COSMETIC = CREATIVE_MODE_TABS.register(MalumMod.MALUM + ".cosmetic",
() -> CreativeModeTab.builder()
.title(Component.translatable("itemGroup." + MalumMod.MALUM + "_cosmetics"))
.icon(() -> ItemRegistry.WEAVERS_WORKBENCH.get().getDefaultInstance())
.displayItems((parameters, output) -> output.accept(ItemRegistry.WEAVERS_WORKBENCH.get())).build()
.icon(() -> ItemRegistry.WEAVERS_WORKBENCH.get().getDefaultInstance()).build()
);

@SuppressWarnings("DataFlowIssue")
Expand Down

0 comments on commit d098477

Please sign in to comment.