Skip to content

Commit

Permalink
Fixed more models, added oxygen tank and added item group
Browse files Browse the repository at this point in the history
  • Loading branch information
JunePrimavera committed Sep 1, 2023
1 parent b7507a2 commit 24bb01e
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 25 deletions.
64 changes: 41 additions & 23 deletions src/main/java/io/github/teampropulsive/Items.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"variants": {
"": { "model": "propulsive:block/aluminum_ore" }
"parent": "block/cube_all",
"textures": {
"all": "propulsive:block/aluminum_ore"
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "propulsive:item/hydrogen_canister"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "propulsive:item/methane_canister"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "propulsive:item/oxygen_canister"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "propulsive:item/oxygen_tank"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 24bb01e

Please sign in to comment.