Skip to content

Commit

Permalink
Merge pull request #21 from AnnsAnns/1.20.5
Browse files Browse the repository at this point in the history
Minecraft 1.21 Support
  • Loading branch information
AnnsAnns authored Jun 13, 2024
2 parents ce66b47 + 0411369 commit a788bd5
Show file tree
Hide file tree
Showing 40 changed files with 153 additions and 11 deletions.
12 changes: 6 additions & 6 deletions fabric/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
loader_version=0.15.10
minecraft_version=1.21
yarn_mappings=1.21+build.1
loader_version=0.15.11

#Fabric api
fabric_version=0.97.6+1.20.5
# Fabric API
fabric_version=0.100.1+1.21

# Mod Properties
mod_version=2.2.0
mod_version=2.3.0
maven_group=eu.annsann
archives_base_name=flower_power
modid=flower_power
48 changes: 48 additions & 0 deletions fabric/remappedSrc/eu/annsann/flowerpower/FlowerPower.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package eu.annsann.flowerpower;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.block.*;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

import java.util.Arrays;

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

public class FlowerPower implements ModInitializer {
public static final String MOD_NAME = "flower_power";
public static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(
RegistryKeys.ITEM_GROUP,
new Identifier(MOD_NAME, MOD_NAME + "_group")
);

/**
* Runs the mod initializer.
*/
@Override
public void onInitialize() {
GenericPetalHelper.registerPetal("red_petals", RED_PETALS);
GenericPetalHelper.registerPetal("yellow_petals", YELLOW_PETALS);
GenericPetalHelper.registerPetal("blue_petals", BLUE_PETALS);
GenericPetalHelper.registerPetal("orchid_petals", ORCHID_PETALS);
GenericPetalHelper.registerPetal("orange_petals", ORANGE_PETALS);
GenericPetalHelper.registerPetal("grey_petals", GREY_PETALS);
GenericPetalHelper.registerPetal("pink_petals", PINK_PETALS);
GenericPetalHelper.registerPetal("white_petals", WHITE_PETALS);
GenericPetalHelper.registerPetal("magenta_petals", MAGENTA_PETALS);
GenericPetalHelper.registerPetal("black_petals", BLACK_PETALS);

Registry.register(Registries.ITEM_GROUP, ITEM_GROUP, FabricItemGroup.builder()
.displayName(Text.translatable("itemGroup.flower_power.flower_power"))
.icon(() -> new ItemStack(Blocks.TORCHFLOWER))
.entries((context, entries) -> Arrays.stream(Petals).forEach(entries::add))
.build());
}
}
33 changes: 33 additions & 0 deletions fabric/remappedSrc/eu/annsann/flowerpower/Flowers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package eu.annsann.flowerpower;

import net.minecraft.block.Block;
import net.minecraft.block.FlowerbedBlock;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;

public class Flowers {
public static final FlowerbedBlock RED_PETALS = GenericPetalHelper.createNewPetal();
public static final FlowerbedBlock YELLOW_PETALS = GenericPetalHelper.createNewPetal();
public static final FlowerbedBlock BLUE_PETALS = GenericPetalHelper.createNewPetal();
public static final FlowerbedBlock ORCHID_PETALS = GenericPetalHelper.createNewPetal();
public static final FlowerbedBlock ORANGE_PETALS = GenericPetalHelper.createNewPetal();
public static final FlowerbedBlock GREY_PETALS = GenericPetalHelper.createNewPetal();
public static final FlowerbedBlock PINK_PETALS = GenericPetalHelper.createNewPetal();
public static final FlowerbedBlock WHITE_PETALS = GenericPetalHelper.createNewPetal();
public static final FlowerbedBlock MAGENTA_PETALS = GenericPetalHelper.createNewPetal();
public static final FlowerbedBlock BLACK_PETALS = GenericPetalHelper.createNewPetal();

public static final Block[] Petals = {
RED_PETALS,
YELLOW_PETALS,
BLUE_PETALS,
ORCHID_PETALS,
ORANGE_PETALS,
GREY_PETALS,
PINK_PETALS,
WHITE_PETALS,
MAGENTA_PETALS,
BLACK_PETALS
};
}
37 changes: 37 additions & 0 deletions fabric/remappedSrc/eu/annsann/flowerpower/GenericPetalHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package eu.annsann.flowerpower;

import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.FlowerbedBlock;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.item.AliasedBlockItem;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;

import static eu.annsann.flowerpower.FlowerPower.*;

public class GenericPetalHelper {
public static FlowerbedBlock createNewPetal() {
return new FlowerbedBlock(
AbstractBlock.Settings
.create()
.noCollision()
.sounds(BlockSoundGroup.PINK_PETALS)
.pistonBehavior(PistonBehavior.DESTROY)
);
}

public static void registerPetal(String name, FlowerbedBlock entry) {
Registry.register(Registries.BLOCK,
new Identifier(MOD_NAME, name),
entry);
Registry.register(Registries.ITEM,
new Identifier(MOD_NAME, name),
new BlockItem(entry, new Item.Settings()));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package eu.annsann.flowerpower.client;

import eu.annsann.flowerpower.FlowerPower;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.block.Block;
import net.minecraft.client.render.RenderLayer;

import java.util.Arrays;

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

public class FlowerPowerClient implements ClientModInitializer {
/**
* Runs the mod initializer on the client environment.
*/

@Override
public void onInitializeClient() {
Arrays.stream(Petals).forEach(
block -> BlockRenderLayerMap.INSTANCE.putBlock(block, RenderLayer.getCutout())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class FlowerPower implements ModInitializer {
public static final String MOD_NAME = "flower_power";
public static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(
RegistryKeys.ITEM_GROUP,
new Identifier(MOD_NAME, MOD_NAME + "_group")
Identifier.of(MOD_NAME, MOD_NAME + "_group")
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public static FlowerbedBlock createNewPetal() {

public static void registerPetal(String name, FlowerbedBlock entry) {
Registry.register(Registries.BLOCK,
new Identifier(MOD_NAME, name),
Identifier.of(MOD_NAME, name),
entry);
Registry.register(Registries.ITEM,
new Identifier(MOD_NAME, name),
Identifier.of(MOD_NAME, name),
new BlockItem(entry, new Item.Settings()));
}

Expand Down
4 changes: 2 additions & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
]
},
"depends": {
"fabricloader": ">=0.15.10",
"minecraft": "~1.20.5",
"fabricloader": ">=0.15.11",
"minecraft": "~1.21.0",
"java": ">=21",
"fabric-api": "*"
}
Expand Down

0 comments on commit a788bd5

Please sign in to comment.