Added custom item, sapphire
This commit is contained in:
parent
a5071979c8
commit
c704a6ba51
9 changed files with 78 additions and 3 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -13,5 +13,6 @@
|
||||||
"explorer.fileNesting.patterns": {
|
"explorer.fileNesting.patterns": {
|
||||||
"gradlew": "build.gradle, gradle.properties, gradlew.bat, settings.gradle",
|
"gradlew": "build.gradle, gradle.properties, gradlew.bat, settings.gradle",
|
||||||
".gitignore": ".gitattributes, .tool-versions, LICENSE.txt, README.md"
|
".gitignore": ".gitattributes, .tool-versions, LICENSE.txt, README.md"
|
||||||
}
|
},
|
||||||
|
"workbench.iconTheme": "mc-dp-icons"
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,11 @@ import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
|
|
||||||
|
import cc.toph.tutorialmod.item.ModCreativeTabs;
|
||||||
|
import cc.toph.tutorialmod.item.ModItems;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
|
import net.minecraft.world.item.CreativeModeTabs;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
@ -31,10 +35,13 @@ public class TutorialMod {
|
||||||
|
|
||||||
public TutorialMod() {
|
public TutorialMod() {
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
||||||
// Register the commonSetup method for modloading
|
// Register the commonSetup method for modloading
|
||||||
modEventBus.addListener(this::commonSetup);
|
modEventBus.addListener(this::commonSetup);
|
||||||
|
|
||||||
|
// Register the ModItems and CreativeModeTabs class to the modEventBus
|
||||||
|
ModItems.register(modEventBus);
|
||||||
|
ModCreativeTabs.register(modEventBus);
|
||||||
|
|
||||||
// Register ourselves for server and other game events we are interested in
|
// Register ourselves for server and other game events we are interested in
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
|
@ -59,7 +66,10 @@ public class TutorialMod {
|
||||||
|
|
||||||
// Add the example block item to the building blocks tab
|
// Add the example block item to the building blocks tab
|
||||||
private void addCreative(BuildCreativeModeTabContentsEvent event) {
|
private void addCreative(BuildCreativeModeTabContentsEvent event) {
|
||||||
|
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS) {
|
||||||
|
event.accept(ModItems.SAPPHIRE);
|
||||||
|
event.accept(ModItems.RAW_SAPPHIRE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
||||||
|
|
26
src/main/java/cc/toph/tutorialmod/item/ModCreativeTabs.java
Normal file
26
src/main/java/cc/toph/tutorialmod/item/ModCreativeTabs.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package cc.toph.tutorialmod.item;
|
||||||
|
|
||||||
|
import cc.toph.tutorialmod.TutorialMod;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
|
public class ModCreativeTabs {
|
||||||
|
public static final DeferredRegister<CreativeModeTab> CREATIVE_TABS = DeferredRegister
|
||||||
|
.create(Registries.CREATIVE_MODE_TAB, TutorialMod.MODID);
|
||||||
|
|
||||||
|
public static void register(IEventBus eventBus) {
|
||||||
|
CREATIVE_TABS.register(eventBus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final RegistryObject<CreativeModeTab> TUTORIAL_MOD = CREATIVE_TABS.register("tutorial_tab",
|
||||||
|
() -> CreativeModeTab.builder().icon(() -> new ItemStack(ModItems.SAPPHIRE.get()))
|
||||||
|
.title(Component.translatable("creativetab.tutorial_tab")).displayItems((pParams, pOut) -> {
|
||||||
|
pOut.accept(ModItems.SAPPHIRE.get());
|
||||||
|
pOut.accept(ModItems.RAW_SAPPHIRE.get());
|
||||||
|
}).build());
|
||||||
|
}
|
21
src/main/java/cc/toph/tutorialmod/item/ModItems.java
Normal file
21
src/main/java/cc/toph/tutorialmod/item/ModItems.java
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package cc.toph.tutorialmod.item;
|
||||||
|
|
||||||
|
import cc.toph.tutorialmod.TutorialMod;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
|
public class ModItems {
|
||||||
|
|
||||||
|
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TutorialMod.MODID);
|
||||||
|
|
||||||
|
public static void register(IEventBus eventBus) {
|
||||||
|
ITEMS.register(eventBus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final RegistryObject<Item> SAPPHIRE = ITEMS.register("sapphire", () -> new Item(new Item.Properties()));
|
||||||
|
public static final RegistryObject<Item> RAW_SAPPHIRE = ITEMS.register("raw_sapphire",
|
||||||
|
() -> new Item(new Item.Properties()));
|
||||||
|
}
|
5
src/main/resources/assets/tutorialmod/lang/en_us.json
Normal file
5
src/main/resources/assets/tutorialmod/lang/en_us.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"item.tutorialmod.sapphire": "Sapphire",
|
||||||
|
"item.tutorialmod.raw_sapphire": "Raw Sapphire",
|
||||||
|
"creativetab.tutorial_tab": "Sapphire Tab"
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "tutorialmod:item/raw_sapphire"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "tutorialmod:item/sapphire"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 535 B |
BIN
src/main/resources/assets/tutorialmod/textures/item/sapphire.png
Normal file
BIN
src/main/resources/assets/tutorialmod/textures/item/sapphire.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 392 B |
Loading…
Add table
Reference in a new issue