added items

This commit is contained in:
2023-11-05 00:09:27 +01:00
parent 8a42516565
commit 5c6cbb7403
47 changed files with 207 additions and 0 deletions

View File

@ -1,6 +1,9 @@
package de.slpnetwork.brewcraft;
import com.mojang.logging.LogUtils;
import de.slpnetwork.brewcraft.item.ModCreativeModeTabs;
import de.slpnetwork.brewcraft.item.ModItems;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
@ -29,6 +32,9 @@ public class Brewcraft
{
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
ModItems.register(modEventBus);
ModCreativeModeTabs.register(modEventBus);
// Register the commonSetup method for modloading
modEventBus.addListener(this::commonSetup);
@ -46,6 +52,9 @@ public class Brewcraft
// Add the example block item to the building blocks tab
private void addCreative(BuildCreativeModeTabContentsEvent event)
{
if(event.getTabKey() == CreativeModeTabs.INGREDIENTS) {
event.accept(ModItems.Saphire);
}
}
// You can use SubscribeEvent and let the Event Bus discover methods to call

View File

@ -0,0 +1,50 @@
package de.slpnetwork.brewcraft.item;
import de.slpnetwork.brewcraft.Brewcraft;
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;
/**
* used to register Creative Tabs
*/
public class ModCreativeModeTabs {
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, Brewcraft.MODID);
/**
* constructs the creative mode tab and adds items to it
*/
public static final RegistryObject<CreativeModeTab> BREWCRAFT_TAB = CREATIVE_MODE_TABS.register("brewcraft_tab",
() -> CreativeModeTab.builder().icon(
() -> new ItemStack(ModItems.Hop.get()))
.title(Component.translatable("creativetab.brewcraft_tab"))
.displayItems((pParameters, pOutput) -> {
pOutput.accept(ModItems.Barley_Malt.get());
pOutput.accept(ModItems.Malt.get());
pOutput.accept(ModItems.Yeast.get());
pOutput.accept(ModItems.Cider_Yeast.get());
pOutput.accept(ModItems.Rice.get());
pOutput.accept(ModItems.Hop.get());
pOutput.accept(ModItems.Grape.get());
pOutput.accept(ModItems.Barley.get());
pOutput.accept(ModItems.Heater_Body.get());
pOutput.accept(ModItems.Heater_Element.get());
pOutput.accept(ModItems.Mashine_Body.get());
pOutput.accept(ModItems.Milling_Stone.get());
pOutput.accept(ModItems.Pressed_Iron.get());
pOutput.accept(ModItems.Pressure_Body.get());
})
.build());
/***
* registers the deferredregister
* @param eventBus the mods eventbus
*/
public static void register(IEventBus eventBus) {
CREATIVE_MODE_TABS.register(eventBus);
}
}

View File

@ -0,0 +1,39 @@
package de.slpnetwork.brewcraft.item;
import de.slpnetwork.brewcraft.Brewcraft;
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;
/**
* used to register items
*/
public class ModItems {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Brewcraft.MODID);
public static final RegistryObject<Item> Saphire = ITEMS.register("sapphire", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Yeast = ITEMS.register("yeast", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Cider_Yeast = ITEMS.register("cider-yeast", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Hop = ITEMS.register("hop", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Rice = ITEMS.register("rice", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Grape = ITEMS.register("grape", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Barley = ITEMS.register("barley", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Malt = ITEMS.register("malt", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Barley_Malt = ITEMS.register("barley_malt", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Heater_Body = ITEMS.register("heater_body", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Heater_Element = ITEMS.register("heater_element", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Mashine_Body = ITEMS.register("mashine_body", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Milling_Stone = ITEMS.register("milling_stone", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Pressed_Iron = ITEMS.register("pressed_iron", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> Pressure_Body = ITEMS.register("pressure_body", () -> new Item(new Item.Properties()));
/***
* registers the deferredregister
* @param eventBus the mods eventbus
*/
public static void register(IEventBus eventBus) {
ITEMS.register(eventBus);
}
}