Skip to content

Commit

Permalink
First working Forge version
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnsAnns committed Oct 27, 2023
1 parent ae38199 commit 6e20ad0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.annsann.flowerpower;
package eu.annsann.flower_power;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package eu.annsann.flowerpower;
package eu.annsann.flower_power;

import com.mojang.logging.LogUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
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.PinkPetalsBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.MapColor;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
Expand All @@ -37,24 +37,25 @@ public class FlowerPower
public static final String MODID = "flower_power";
// Directly reference a slf4j logger
private static final Logger LOGGER = LogUtils.getLogger();
// Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace
// Create a Deferred Register to hold Blocks which will all be registered under the "flower_power" namespace
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
// Create a Deferred Register to hold Items which will all be registered under the "examplemod" namespace
// Create a Deferred Register to hold Items which will all be registered under the "flower_power" namespace
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
// Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "examplemod" namespace
// Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "flower_power" namespace
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);

// Creates a new Block with the id "examplemod:example_block", combining the namespace and path
public static final RegistryObject<Block> EXAMPLE_BLOCK = BLOCKS.register("yellow_petals", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
// Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path
public static final RegistryObject<Item> EXAMPLE_BLOCK_ITEM = ITEMS.register("yellow_petals", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties()));
// Creates a new Block with the id "flower_power:example_block", combining the namespace and path
public static final RegistryObject<Block> YELLOW_PETALS_BLOCK = BLOCKS.register("yellow_petals", () -> new PinkPetalsBlock(BlockBehaviour.Properties.of().sound(SoundType.PINK_PETALS).noCollission()));
// Creates a new BlockItem with the id "flower_power:example_block", combining the namespace and path

// Creates a creative tab with the id "examplemod:example_tab" for the example item, that is placed after the combat tab
public static final RegistryObject<CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("flower_power", () -> CreativeModeTab.builder()
public static final RegistryObject<Item> YELLOW_PETALS_ITEM = ITEMS.register("yellow_petals", () -> new BlockItem(YELLOW_PETALS_BLOCK.get(), new Item.Properties()));

// Creates a creative tab with the id "flower_power:example_tab" for the example item, that is placed after the combat tab
public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = CREATIVE_MODE_TABS.register("flower_power", () -> CreativeModeTab.builder()
.withTabsBefore(CreativeModeTabs.COMBAT)
.icon(() -> EXAMPLE_BLOCK_ITEM.get().getDefaultInstance())
.icon(() -> YELLOW_PETALS_ITEM.get().getDefaultInstance())
.displayItems((parameters, output) -> {
output.accept(EXAMPLE_BLOCK_ITEM.get()); // Add the example item to the tab. For your own tabs, this method is preferred over the event
output.accept(YELLOW_PETALS_ITEM.get()); // Add the example item to the tab. For your own tabs, this method is preferred over the event
}).build());

public FlowerPower()
Expand Down Expand Up @@ -95,7 +96,7 @@ private void commonSetup(final FMLCommonSetupEvent event)
private void addCreative(BuildCreativeModeTabContentsEvent event)
{
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
event.accept(EXAMPLE_BLOCK_ITEM);
event.accept(YELLOW_PETALS_ITEM);
}

// You can use SubscribeEvent and let the Event Bus discover methods to call
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"parent": "minecraft:block/flowerbed_1",
"render_type": "cutout",
"textures": {
"flowerbed": "flower_power:block/black_petals",
"stem": "flower_power:block/red_petals_stem"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"parent": "minecraft:block/flowerbed_1",
"render_type": "cutout",
"textures": {
"flowerbed": "flower_power:block/yellow_petals",
"stem": "flower_power:block/red_petals_stem"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"parent": "minecraft:block/flowerbed_2",
"render_type": "cutout",
"textures": {
"flowerbed": "flower_power:block/yellow_petals",
"stem": "flower_power:block/red_petals_stem"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"parent": "minecraft:block/flowerbed_3",
"render_type": "cutout",
"textures": {
"flowerbed": "flower_power:block/yellow_petals",
"stem": "flower_power:block/red_petals_stem"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"parent": "minecraft:block/flowerbed_4",
"render_type": "cutout",
"textures": {
"flowerbed": "flower_power:block/yellow_petals",
"stem": "flower_power:block/red_petals_stem"
Expand Down

0 comments on commit 6e20ad0

Please sign in to comment.