Skip to content

Commit

Permalink
Merge pull request #17 from AnnsAnns/forge
Browse files Browse the repository at this point in the history
Feature Sync Forge
  • Loading branch information
AnnsAnns authored Oct 29, 2023
2 parents 6c81297 + f4511ea commit 3ec0c26
Show file tree
Hide file tree
Showing 40 changed files with 175 additions and 71 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@
*.ipr
*.iws

# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project

# idea
out
*.ipr
*.iws
*.iml
.idea

# gradle
build
.gradle

# other
eclipse
run
run-data

# IntelliJ
out/
# mpeltonen/sbt-idea plugin
Expand Down
23 changes: 23 additions & 0 deletions fabric/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project

# idea
out
*.ipr
*.iws
*.iml
.idea

# gradle
build
.gradle

# other
eclipse
run
run-data
107 changes: 72 additions & 35 deletions forge/src/main/java/eu/annsann/flower_power/FlowerPower.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,77 @@
import net.minecraftforge.registries.RegistryObject;
import org.slf4j.Logger;

import static eu.annsann.flower_power.Flowers.*;

// The value here should match an entry in the META-INF/mods.toml file
@Mod(FlowerPower.MODID)
public class FlowerPower
{
public class FlowerPower {
// Define mod id in a common place for everything to reference
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 "flower_power" 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 "flower_power" 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 "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 "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

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(() -> YELLOW_PETALS_ITEM.get().getDefaultInstance())
.displayItems((parameters, output) -> {
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()
{
// 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);

public static final RegistryObject<Block> YELLOW_PETALS_BLOCK = registerPetalBlock("yellow_petals");
public static final RegistryObject<Item> YELLOW_PETALS_ITEM = registerPetal("yellow_petals", YELLOW_PETALS_BLOCK);

public static final RegistryObject<Block> BLACK_PETALS_BLOCK = registerPetalBlock("black_petals");
public static final RegistryObject<Item> BLACK_PETALS_ITEM = registerPetal("black_petals", BLACK_PETALS_BLOCK);

public static final RegistryObject<Block> BLUE_PETALS_BLOCK = registerPetalBlock("blue_petals");
public static final RegistryObject<Item> BLUE_PETALS_ITEM = registerPetal("blue_petals", BLUE_PETALS_BLOCK);

public static final RegistryObject<Block> GREY_PETALS_BLOCK = registerPetalBlock("grey_petals");
public static final RegistryObject<Item> GREY_PETALS_ITEM = registerPetal("grey_petals", GREY_PETALS_BLOCK);

public static final RegistryObject<Block> MAGENTA_PETALS_BLOCK = registerPetalBlock("magenta_petals");
public static final RegistryObject<Item> MAGENTA_PETALS_ITEM = registerPetal("magenta_petals",
MAGENTA_PETALS_BLOCK);

public static final RegistryObject<Block> ORANGE_PETALS_BLOCK = registerPetalBlock("orange_petals");
public static final RegistryObject<Item> ORANGE_PETALS_ITEM = registerPetal("orange_petals", ORANGE_PETALS_BLOCK);

public static final RegistryObject<Block> ORCHID_PETALS_BLOCK = registerPetalBlock("orchid_petals");
public static final RegistryObject<Item> ORCHID_PETALS_ITEM = registerPetal("orchid_petals", ORCHID_PETALS_BLOCK);

public static final RegistryObject<Block> PINK_PETALS_BLOCK = registerPetalBlock("pink_petals");
public static final RegistryObject<Item> PINK_PETALS_ITEM = registerPetal("pink_petals", PINK_PETALS_BLOCK);

public static final RegistryObject<Block> RED_PETALS_BLOCK = registerPetalBlock("red_petals");
public static final RegistryObject<Item> RED_PETALS_ITEM = registerPetal("red_petals", RED_PETALS_BLOCK);

public static final RegistryObject<Block> WHITE_PETALS_BLOCK = registerPetalBlock("white_petals");
public static final RegistryObject<Item> WHITE_PETALS_ITEM = registerPetal("white_petals", WHITE_PETALS_BLOCK);

// 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(() -> YELLOW_PETALS_ITEM.get().getDefaultInstance())
.displayItems((parameters, output) -> {
output.accept(YELLOW_PETALS_ITEM.get());
output.accept(BLACK_PETALS_ITEM.get());
output.accept(BLUE_PETALS_ITEM.get());
output.accept(GREY_PETALS_ITEM.get());
output.accept(MAGENTA_PETALS_ITEM.get());
output.accept(ORANGE_PETALS_ITEM.get());
output.accept(ORCHID_PETALS_ITEM.get());
output.accept(PINK_PETALS_ITEM.get());
output.accept(RED_PETALS_ITEM.get());
output.accept(WHITE_PETALS_ITEM.get());
}).build());

public FlowerPower() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

// Register the commonSetup method for modloading
Expand All @@ -78,12 +118,12 @@ public FlowerPower()
// Register the item to a creative tab
modEventBus.addListener(this::addCreative);

// Register our mod's ForgeConfigSpec so that Forge can create and load the config file for us
// Register our mod's ForgeConfigSpec so that Forge can create and load the
// config file for us
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC);
}

private void commonSetup(final FMLCommonSetupEvent event)
{
private void commonSetup(final FMLCommonSetupEvent event) {
// Some common setup code
LOGGER.info("HELLO FROM COMMON SETUP");

Expand All @@ -93,27 +133,24 @@ private void commonSetup(final FMLCommonSetupEvent event)
}

// Add the example block item to the building blocks tab
private void addCreative(BuildCreativeModeTabContentsEvent event)
{
private void addCreative(BuildCreativeModeTabContentsEvent event) {
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
event.accept(YELLOW_PETALS_ITEM);
}

// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
public void onServerStarting(ServerStartingEvent event)
{
public void onServerStarting(ServerStartingEvent event) {
// Do something when the server starts
LOGGER.info("HELLO from server starting");
}

// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
// You can use EventBusSubscriber to automatically register all static methods
// in the class annotated with @SubscribeEvent
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class ClientModEvents
{
public static class ClientModEvents {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event)
{
public static void onClientSetup(FMLClientSetupEvent event) {
// Some client setup code
LOGGER.info("HELLO FROM CLIENT SETUP");
LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
Expand Down
21 changes: 21 additions & 0 deletions forge/src/main/java/eu/annsann/flower_power/Flowers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package eu.annsann.flower_power;

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.PinkPetalsBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraftforge.registries.RegistryObject;

import static eu.annsann.flower_power.FlowerPower.BLOCKS;
import static eu.annsann.flower_power.FlowerPower.ITEMS;

public class Flowers {
public static RegistryObject<Block> registerPetalBlock(String name) {
return BLOCKS.register(name, () -> new PinkPetalsBlock(BlockBehaviour.Properties.of().sound(SoundType.PINK_PETALS).noCollission()));
}
public static RegistryObject<Item> registerPetal(String name, RegistryObject<Block> block) {
return ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +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,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_2",
"textures": {
"render_type": "cutout",
"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,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_3",
"textures": {
"render_type": "cutout",
"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,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_4",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/black_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
2 changes: 1 addition & 1 deletion shared/assets/flower_power/models/block/blue_petals_1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_1",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/blue_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
2 changes: 1 addition & 1 deletion shared/assets/flower_power/models/block/blue_petals_2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_2",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/blue_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
2 changes: 1 addition & 1 deletion shared/assets/flower_power/models/block/blue_petals_3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_3",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/blue_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
2 changes: 1 addition & 1 deletion shared/assets/flower_power/models/block/blue_petals_4.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{
"parent": "minecraft:block/flowerbed_4",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/blue_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
2 changes: 1 addition & 1 deletion shared/assets/flower_power/models/block/grey_petals_1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_1",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/grey_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
2 changes: 1 addition & 1 deletion shared/assets/flower_power/models/block/grey_petals_2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_2",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/grey_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
2 changes: 1 addition & 1 deletion shared/assets/flower_power/models/block/grey_petals_3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_3",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/grey_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
2 changes: 1 addition & 1 deletion shared/assets/flower_power/models/block/grey_petals_4.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_4",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/grey_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_1",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/magenta_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_2",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/magenta_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_3",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/magenta_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_4",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/magenta_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_1",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/orange_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_2",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/orange_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_3",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/orange_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_4",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/orange_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:block/flowerbed_1",
"textures": {
"render_type": "cutout",
"flowerbed": "flower_power:block/orchid_petals",
"stem": "flower_power:block/red_petals_stem"
}
Expand Down
Loading

0 comments on commit 3ec0c26

Please sign in to comment.