Skip to content

Commit

Permalink
Move all items to registrate
Browse files Browse the repository at this point in the history
  • Loading branch information
yuesha-yc committed Dec 6, 2024
1 parent dd97b63 commit 79e1619
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 19 deletions.
5 changes: 5 additions & 0 deletions src/generated/resources/assets/frostedheart/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@
"item.frostedheart.electrum_wire": "ǝɹıM ɯnɹʇɔǝןƎ",
"item.frostedheart.energy_core": "ǝɹoƆ ʎbɹǝuƎ",
"item.frostedheart.fire_clay_ball": "ןןɐᗺ ʎɐןƆ ǝɹıℲ",
"item.frostedheart.fluid_bottle": "ǝןʇʇoᗺ pınןℲ",
"item.frostedheart.frozen_seeds": "spǝǝS uǝzoɹℲ",
"item.frostedheart.gambeson": "uosǝqɯɐ⅁",
"item.frostedheart.generator_ash": "ɥsⱯ ɹoʇɐɹǝuǝ⅁",
Expand Down Expand Up @@ -458,6 +459,7 @@
"item.frostedheart.invar_ingot": "ʇobuI ɹɐʌuI",
"item.frostedheart.invar_nugget": "ʇǝbbnN ɹɐʌuI",
"item.frostedheart.invar_sheet": "ʇǝǝɥS ɹɐʌuI",
"item.frostedheart.iron_bottle": "ǝןʇʇoᗺ uoɹI",
"item.frostedheart.iron_core_spade": "ǝpɐdS ǝɹoƆ uoɹI",
"item.frostedheart.iron_geologists_hammer": "ɹǝɯɯɐH sʇsıboןoǝ⅁ uoɹI",
"item.frostedheart.iron_pro_pick": "ʞɔıԀ oɹԀ uoɹI",
Expand All @@ -473,6 +475,7 @@
"item.frostedheart.lead_oxide_dust": "ʇsnᗡ ǝpıxO pɐǝꞀ",
"item.frostedheart.lead_sheet": "ʇǝǝɥS pɐǝꞀ",
"item.frostedheart.lead_slurry": "ʎɹɹnןS pɐǝꞀ",
"item.frostedheart.leather_water_bag": "bɐᗺ ɹǝʇɐM ɹǝɥʇɐǝꞀ",
"item.frostedheart.light_blue_advanced_thermos": "soɯɹǝɥ⟘ pǝɔuɐʌpⱯ ǝnןᗺ ʇɥbıꞀ",
"item.frostedheart.light_blue_thermos": "soɯɹǝɥ⟘ ǝnןᗺ ʇɥbıꞀ",
"item.frostedheart.light_gray_advanced_thermos": "soɯɹǝɥ⟘ pǝɔuɐʌpⱯ ʎɐɹ⅁ ʇɥbıꞀ",
Expand Down Expand Up @@ -601,6 +604,8 @@
"item.frostedheart.weather_radar": "ɹɐpɐᴚ ɹǝɥʇɐǝM",
"item.frostedheart.white_advanced_thermos": "soɯɹǝɥ⟘ pǝɔuɐʌpⱯ ǝʇıɥM",
"item.frostedheart.white_thermos": "soɯɹǝɥ⟘ ǝʇıɥM",
"item.frostedheart.wooden_cup": "dnƆ uǝpooM",
"item.frostedheart.wooden_cup_drink": "ʞuıɹᗡ ɥʇıM dnƆ uǝpooM",
"item.frostedheart.wool_boots": "sʇooᗺ ןooM",
"item.frostedheart.wool_cloth": "ɥʇoןƆ ןooM",
"item.frostedheart.wool_hat": "ʇɐH ןooM",
Expand Down
5 changes: 5 additions & 0 deletions src/generated/resources/assets/frostedheart/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@
"item.frostedheart.electrum_wire": "Electrum Wire",
"item.frostedheart.energy_core": "Energy Core",
"item.frostedheart.fire_clay_ball": "Fire Clay Ball",
"item.frostedheart.fluid_bottle": "Fluid Bottle",
"item.frostedheart.frozen_seeds": "Frozen Seeds",
"item.frostedheart.gambeson": "Gambeson",
"item.frostedheart.generator_ash": "Generator Ash",
Expand Down Expand Up @@ -458,6 +459,7 @@
"item.frostedheart.invar_ingot": "Invar Ingot",
"item.frostedheart.invar_nugget": "Invar Nugget",
"item.frostedheart.invar_sheet": "Invar Sheet",
"item.frostedheart.iron_bottle": "Iron Bottle",
"item.frostedheart.iron_core_spade": "Iron Core Spade",
"item.frostedheart.iron_geologists_hammer": "Iron Geologists Hammer",
"item.frostedheart.iron_pro_pick": "Iron Pro Pick",
Expand All @@ -473,6 +475,7 @@
"item.frostedheart.lead_oxide_dust": "Lead Oxide Dust",
"item.frostedheart.lead_sheet": "Lead Sheet",
"item.frostedheart.lead_slurry": "Lead Slurry",
"item.frostedheart.leather_water_bag": "Leather Water Bag",
"item.frostedheart.light_blue_advanced_thermos": "Light Blue Advanced Thermos",
"item.frostedheart.light_blue_thermos": "Light Blue Thermos",
"item.frostedheart.light_gray_advanced_thermos": "Light Gray Advanced Thermos",
Expand Down Expand Up @@ -601,6 +604,8 @@
"item.frostedheart.weather_radar": "Weather Radar",
"item.frostedheart.white_advanced_thermos": "White Advanced Thermos",
"item.frostedheart.white_thermos": "White Thermos",
"item.frostedheart.wooden_cup": "Wooden Cup",
"item.frostedheart.wooden_cup_drink": "Wooden Cup With Drink",
"item.frostedheart.wool_boots": "Wool Boots",
"item.frostedheart.wool_cloth": "Wool Cloth",
"item.frostedheart.wool_hat": "Wool Hat",
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/com/teammoeg/frostedheart/FHBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,22 @@

public class FHBlocks {

static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, FHMain.MODID);
protected static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, FHMain.MODID);

public static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block, String itemName, Function<T, Item> item) {
@Deprecated
protected static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block, String itemName, Function<T, Item> item) {
RegistryObject<T> blk = BLOCKS.register(name, block);
FHItems.ITEMS.register(itemName, () -> item.apply(blk.get()));
return blk;
}

public static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block) {
@Deprecated
protected static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block) {
return register(name, block, name, FHBlockItem::new);
}

public static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block, Function<T, Item> item) {
@Deprecated
protected static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block, Function<T, Item> item) {
return register(name, block, name, item);
}

Expand Down
57 changes: 42 additions & 15 deletions src/main/java/com/teammoeg/frostedheart/FHItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,19 @@
*/
public class FHItems {

public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, FHMain.MODID);
protected static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, FHMain.MODID);

// helper method: use FHBaseItem as the item class
public static RegistryObject<Item> register(String name) {
@Deprecated
protected static RegistryObject<Item> register(String name) {
return register(name, n -> new FHBaseItem(createProps()));
}

static <T extends Item> RegistryObject<T> register(String name, Function<String, T> supplier) {
return ITEMS.register(name, () -> {
//item.setRegistryName(FHMain.MODID, name);
return supplier.apply(name);
});
@Deprecated
protected static <T extends Item> RegistryObject<T> register(String name, Function<String, T> supplier) {
return ITEMS.register(name, () -> supplier.apply(name));
}

static Properties createProps() {
protected static Properties createProps() {
return new Item.Properties();
}

Expand Down Expand Up @@ -1449,10 +1447,39 @@ public static String fromIdToDisplay(String color) {
.tag(ItemTags.PICKAXES, forgeItemTag("hammers"), forgeItemTag("hammers/bronze"))
.register();

//WaterSource section
public final static RegistryObject<Item> fluid_bottle = register("fluid_bottle", (s) -> new FluidBottleItem(new Item.Properties().stacksTo(16)));
public final static RegistryObject<Item> wooden_cup = register("wooden_cup", (s) -> new WoodenCupItem(new Item.Properties(), 250) {@Override public ICapabilityProvider initCapabilities(@Nonnull ItemStack stack, @Nullable CompoundTag nbt) {return super.initCapabilities(new ItemStack(wooden_cup_drink.get()), nbt);}});
public final static RegistryObject<Item> wooden_cup_drink = register("wooden_cup_drink", (s) -> new WoodenCupItem(new Item.Properties().stacksTo(1), 250));
public final static RegistryObject<Item> LEATHER_WATER_BAG = register("leather_water_bag", (s) -> new LeatherWaterBagItem(new Item.Properties().stacksTo(1).setNoRepair(), 1500));
public final static RegistryObject<Item> IRON_BOTTLE = register("iron_bottle", (s) -> new IronBottleItem(new Item.Properties().stacksTo(1).setNoRepair(), 1500));
public static ItemEntry<FluidBottleItem> fluid_bottle = REGISTRATE
.item("fluid_bottle", FluidBottleItem::new)
.properties(p -> p.stacksTo(16))
.model(AssetLookup.existingItemModel())
.register();
public static ItemEntry<WoodenCupItem> wooden_cup = REGISTRATE
.item("wooden_cup", p -> new WoodenCupItem(new Item.Properties(), 250)
/* TODO: @yuqijun I can't add this somehow. Any other way to avoid this kind of definition?
{
@Override
public ICapabilityProvider initCapabilities(@Nonnull ItemStack stack, @Nullable CompoundTag nbt) {
return super.initCapabilities(new ItemStack(wooden_cup_drink.get()), nbt);
}
}
*/
)
.model(AssetLookup.existingItemModel())
.lang("Wooden Cup")
.register();
public static ItemEntry<WoodenCupItem> wooden_cup_drink = REGISTRATE
.item("wooden_cup_drink", p -> new WoodenCupItem(new Item.Properties().stacksTo(1), 250))
.model(AssetLookup.existingItemModel())
.lang("Wooden Cup With Drink")
.register();
public static ItemEntry<LeatherWaterBagItem> LEATHER_WATER_BAG = REGISTRATE
.item("leather_water_bag", p -> new LeatherWaterBagItem(new Item.Properties().stacksTo(1).setNoRepair(), 1500))
.model(AssetLookup.existingItemModel())
.lang("Leather Water Bag")
.register();
public static ItemEntry<IronBottleItem> IRON_BOTTLE = REGISTRATE
.item("iron_bottle", p -> new IronBottleItem(new Item.Properties().stacksTo(1).setNoRepair(), 1500))
.model(AssetLookup.existingItemModel())
.lang("Iron Bottle")
.register();

}

0 comments on commit 79e1619

Please sign in to comment.