From 24bb01e68dcb9c60769b474bf9356d39b27153f5 Mon Sep 17 00:00:00 2001 From: Juniper <86971433+JuneDeveloper@users.noreply.github.com> Date: Sat, 2 Sep 2023 00:52:36 +0100 Subject: [PATCH] Fixed more models, added oxygen tank and added item group --- .../java/io/github/teampropulsive/Items.java | 64 +++++++++++------- .../propulsive/models/block/aluminum_ore.json | 5 +- .../models/item/hydrogen_canister.json | 6 ++ .../models/item/methane_canister.json | 6 ++ .../models/item/oxygen_canister.json | 6 ++ .../propulsive/models/item/oxygen_tank.json | 6 ++ .../propulsive/textures/item/oxygen_tank.png | Bin 0 -> 452 bytes 7 files changed, 68 insertions(+), 25 deletions(-) create mode 100644 src/main/resources/assets/propulsive/models/item/hydrogen_canister.json create mode 100644 src/main/resources/assets/propulsive/models/item/methane_canister.json create mode 100644 src/main/resources/assets/propulsive/models/item/oxygen_canister.json create mode 100644 src/main/resources/assets/propulsive/models/item/oxygen_tank.json create mode 100644 src/main/resources/assets/propulsive/textures/item/oxygen_tank.png diff --git a/src/main/java/io/github/teampropulsive/Items.java b/src/main/java/io/github/teampropulsive/Items.java index e29b8e3..9b67652 100644 --- a/src/main/java/io/github/teampropulsive/Items.java +++ b/src/main/java/io/github/teampropulsive/Items.java @@ -4,17 +4,21 @@ import io.github.teampropulsive.armor.SpaceArmorMaterial; import io.github.teampropulsive.types.GasCanister; import net.fabricmc.fabric.api.item.v1.FabricItemSettings; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.block.Block; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; +import net.minecraft.item.*; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.text.Text; import net.minecraft.util.Identifier; import static io.github.teampropulsive.util.Gases.*; public class Items { + public static final Item OXYGEN_TANK = new GasCanister(new FabricItemSettings(), OXYGEN, 1000); public static final Item OXYGEN_CANISTER = new GasCanister(new FabricItemSettings(), OXYGEN, 1000); public static final Item METHANE_CANISTER = new GasCanister(new FabricItemSettings(), METHANE, 1000); public static final Item HYDROGEN_CANISTER = new GasCanister(new FabricItemSettings(), HYDROGEN, 1000); @@ -25,36 +29,50 @@ public class Items { public static final ArmorItem SPACE_CHESTPLATE = new ArmorItem(SpaceArmorMaterial.INSTANCE, ArmorItem.Type.CHESTPLATE, new FabricItemSettings()); public static final ArmorItem SPACE_LEGGINGS = new ArmorItem(SpaceArmorMaterial.INSTANCE, ArmorItem.Type.LEGGINGS, new FabricItemSettings()); public static final ArmorItem SPACE_BOOTS = new ArmorItem(SpaceArmorMaterial.INSTANCE, ArmorItem.Type.BOOTS, new FabricItemSettings()); + private static final ItemGroup PROPULSIVE_ITEMS = FabricItemGroup.builder() + .icon(() -> new ItemStack(OXYGEN_TANK)) + .displayName(Text.translatable("itemGroup.propulsive.item")) + .build(); + public static void register() { + Registry.register(Registries.ITEM_GROUP, Propulsive.id("propulsive_items"), PROPULSIVE_ITEMS); // Canisters - registerItem("oxygen_canister", OXYGEN_CANISTER); - registerItem("methane_canister", METHANE_CANISTER); - registerItem("hydrogen_canister", HYDROGEN_CANISTER); + registerItem("oxygen_tank", OXYGEN_TANK, true); + registerItem("oxygen_canister", OXYGEN_CANISTER, true); + registerItem("methane_canister", METHANE_CANISTER, true); + registerItem("hydrogen_canister", HYDROGEN_CANISTER, true); // Space suit - registerItem("space_helmet", SPACE_HELMET); - registerItem("space_chestplate", SPACE_CHESTPLATE); - registerItem("space_leggings", SPACE_LEGGINGS); - registerItem("space_boots", SPACE_BOOTS); + registerItem("space_helmet", SPACE_HELMET, true); + registerItem("space_chestplate", SPACE_CHESTPLATE, true); + registerItem("space_leggings", SPACE_LEGGINGS, true); + registerItem("space_boots", SPACE_BOOTS, true); // Moon blocks - registerBlockItem("lunar_regolith", Blocks.MOON_REGOLITH); - registerBlockItem("volcanic_lunar_regolith", Blocks.VOLCANIC_MOON_REGOLITH); - registerBlockItem("anorthosite", Blocks.ANORTHOSITE); + registerBlockItem("lunar_regolith", Blocks.MOON_REGOLITH, true); + registerBlockItem("volcanic_lunar_regolith", Blocks.VOLCANIC_MOON_REGOLITH, true); + registerBlockItem("anorthosite", Blocks.ANORTHOSITE, true); // Aluminum - registerItem("raw_aluminum", RAW_ALUMINUM); - registerItem("aluminum_ingot", ALUMINUM_INGOT); - registerItem("aluminum_nugget", ALUMINUM_NUGGET); - registerBlockItem("aluminum_block", Blocks.ALUMINUM_BLOCK); - registerBlockItem("aluminum_ore_block", Blocks.ALUMINUM_ORE_BLOCK); - registerBlockItem("aluminum_ore", Blocks.ALUMINUM_ORE); - registerBlockItem("aluminum_deepslate_ore", Blocks.ALUMINUM_DEEPSLATE_ORE); + registerItem("raw_aluminum", RAW_ALUMINUM, true); + registerItem("aluminum_ingot", ALUMINUM_INGOT, true); + registerItem("aluminum_nugget", ALUMINUM_NUGGET, true); + registerBlockItem("aluminum_block", Blocks.ALUMINUM_BLOCK, true); + registerBlockItem("aluminum_ore_block", Blocks.ALUMINUM_ORE_BLOCK, true); + registerBlockItem("aluminum_ore", Blocks.ALUMINUM_ORE, true); + registerBlockItem("deepslate_aluminum_ore", Blocks.ALUMINUM_DEEPSLATE_ORE, true); } - private static void registerItem(String path, Item item) { + private static void registerItem(String path, Item item, boolean addToItemGroup) { Registry.register(Registries.ITEM, Propulsive.id(path), item); + if (addToItemGroup) { + ItemGroupEvents.modifyEntriesEvent(RegistryKey.of(RegistryKeys.ITEM_GROUP, Propulsive.id("propulsive_items"))).register(content -> { + content.add(item); + }); + } + } - private static void registerBlockItem(String path, Block block) { - Registry.register(Registries.ITEM, Propulsive.id(path), new BlockItem(block, new FabricItemSettings())); + private static void registerBlockItem(String path, Block block, boolean addToItemGroup) { + BlockItem item = new BlockItem(block, new FabricItemSettings()); + registerItem(path, item, addToItemGroup); } } diff --git a/src/main/resources/assets/propulsive/models/block/aluminum_ore.json b/src/main/resources/assets/propulsive/models/block/aluminum_ore.json index 2d664f3..d787608 100644 --- a/src/main/resources/assets/propulsive/models/block/aluminum_ore.json +++ b/src/main/resources/assets/propulsive/models/block/aluminum_ore.json @@ -1,6 +1,7 @@ { - "variants": { - "": { "model": "propulsive:block/aluminum_ore" } + "parent": "block/cube_all", + "textures": { + "all": "propulsive:block/aluminum_ore" } } diff --git a/src/main/resources/assets/propulsive/models/item/hydrogen_canister.json b/src/main/resources/assets/propulsive/models/item/hydrogen_canister.json new file mode 100644 index 0000000..fe7c978 --- /dev/null +++ b/src/main/resources/assets/propulsive/models/item/hydrogen_canister.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "propulsive:item/hydrogen_canister" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/propulsive/models/item/methane_canister.json b/src/main/resources/assets/propulsive/models/item/methane_canister.json new file mode 100644 index 0000000..0c34171 --- /dev/null +++ b/src/main/resources/assets/propulsive/models/item/methane_canister.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "propulsive:item/methane_canister" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/propulsive/models/item/oxygen_canister.json b/src/main/resources/assets/propulsive/models/item/oxygen_canister.json new file mode 100644 index 0000000..91e5f83 --- /dev/null +++ b/src/main/resources/assets/propulsive/models/item/oxygen_canister.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "propulsive:item/oxygen_canister" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/propulsive/models/item/oxygen_tank.json b/src/main/resources/assets/propulsive/models/item/oxygen_tank.json new file mode 100644 index 0000000..3c92009 --- /dev/null +++ b/src/main/resources/assets/propulsive/models/item/oxygen_tank.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "propulsive:item/oxygen_tank" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/propulsive/textures/item/oxygen_tank.png b/src/main/resources/assets/propulsive/textures/item/oxygen_tank.png new file mode 100644 index 0000000000000000000000000000000000000000..e02c9c9638e22cc0ebd1f801de803de44ea5426b GIT binary patch literal 452 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WChBFc)B=-SokNWC*#cnZOrq_)hJDC)YDil0E*86|ivSt4rYb0h% zu42lyat?C{+>VZz5U^jbC-GK?P?gZ z^Rly(D?UHtJ^b?Wa>Q$>G%;GCyn4oMg>$!19L4{avNpXTpMmlV7}j%i3-g!NA$Tdg3Y%laIpLxVX3gz06sT z4V)s=4IEab2{0UAzJ9&_6mG`E#KZ?nygZC$8h9c%Cb3E!HsTEFQfRo{u%zSIcMG+$o^Eg+i%h(X{|@MI9>>FVdQ&MBb@01$Sxxc~qF literal 0 HcmV?d00001