added crafting recipes and blocks

This commit is contained in:
2023-11-05 22:50:04 +01:00
parent c6b2d8ae35
commit e9ae0b06e6
10 changed files with 105 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package de.slpnetwork.brewcraft;
import com.mojang.logging.LogUtils;
import de.slpnetwork.brewcraft.block.ModBlocks;
import de.slpnetwork.brewcraft.item.ModCreativeModeTabs;
import de.slpnetwork.brewcraft.item.ModItems;
import net.minecraft.world.item.CreativeModeTabs;
@ -10,9 +11,7 @@ import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@ -33,6 +32,7 @@ public class Brewcraft
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
ModItems.register(modEventBus);
ModBlocks.register(modEventBus);
ModCreativeModeTabs.register(modEventBus);
// Register the commonSetup method for modloading

View File

@ -0,0 +1,51 @@
package de.slpnetwork.brewcraft.block;
import de.slpnetwork.brewcraft.Brewcraft;
import de.slpnetwork.brewcraft.item.ModItems;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import java.util.function.Supplier;
public class ModBlocks {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Brewcraft.MODID);
// example development block
public static final RegistryObject<Block> SAPPHIRE_BLOCK = registerBlock("sapphire_block",
() -> new Block(BlockBehaviour.Properties.copy(Blocks.EMERALD_BLOCK).sound(SoundType.AMETHYST)));
/**
* Handles registering the block itself and registering it as an item
* @param name the blocks name
* @param block the blocks properties
* @return the blocks registryObject
*/
private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block){
RegistryObject<T> toReturn = BLOCKS.register(name, block);
registerBlockItem(name, toReturn);
return toReturn;
}
/**
* registers blocks as item
* @param name the blocks name
* @param block the block
* @return an item containing that block
*/
private static <T extends Block>RegistryObject<Item> registerBlockItem(String name, RegistryObject<T> block) {
return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
}
public static void register(IEventBus eventBus) {
BLOCKS.register(eventBus);
}
}

View File

@ -1,6 +1,7 @@
package de.slpnetwork.brewcraft.item;
import de.slpnetwork.brewcraft.Brewcraft;
import de.slpnetwork.brewcraft.block.ModBlocks;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
@ -23,6 +24,7 @@ public class ModCreativeModeTabs {
() -> new ItemStack(ModItems.Hop.get()))
.title(Component.translatable("creativetab.brewcraft_tab"))
.displayItems((pParameters, pOutput) -> {
pOutput.accept(ModItems.Saphire.get());
pOutput.accept(ModItems.Barley_Malt.get());
pOutput.accept(ModItems.Malt.get());
pOutput.accept(ModItems.Yeast.get());
@ -57,6 +59,7 @@ public class ModCreativeModeTabs {
pOutput.accept(ModItems.Bottle_Of_Apple_Juice.get());
pOutput.accept(ModItems.Bottle_Of_Grape_Juice.get());
pOutput.accept(ModItems.Bottle_Of_Sake.get());
pOutput.accept(ModBlocks.SAPPHIRE_BLOCK.get());
})
.build());