Skip to content

Commit

Permalink
wip: Continue port to Minecraft 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 12, 2024
1 parent d19048a commit 19e58b6
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
public class FarmingForBlockheadsConfigData implements BalmConfigData {

@Comment("List of groups to enable. 'default' is an alias for the inbuilt defaults (selling.seeds, selling.saplings and selling.fertilizers.minecraft).")
@ExpectedType(String.class)
public Set<String> includedGroups = Set.of("default");

@Comment("List of groups to disable. Has precedence over includedGroups. 'selling.seeds' for example would disable all seeds from the market.")
@ExpectedType(String.class)
public Set<String> excludedPresets = Set.of();

@ExpectedType(String.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import net.blay09.mods.balm.api.Balm;
import net.blay09.mods.balm.api.block.BalmBlocks;
import net.blay09.mods.farmingforblockheads.FarmingForBlockheads;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
Expand All @@ -21,22 +23,30 @@ public class ModBlocks {
public static Block fertilizedFarmlandStable;

public static void initialize(BalmBlocks blocks) {
blocks.register(() -> market = new MarketBlock(defaultProperties()), () -> new BlockItem(market, itemProperties()), id("market"));
blocks.register(() -> chickenNest = new ChickenNestBlock(defaultProperties()), () -> new BlockItem(chickenNest, itemProperties()), id("chicken_nest"));
blocks.register(() -> feedingTrough = new FeedingTroughBlock(defaultProperties()), () -> new BlockItem(feedingTrough, itemProperties()), id("feeding_trough"));
blocks.register(() -> fertilizedFarmlandRich = new FertilizedFarmlandBlock(defaultProperties()), () -> new BlockItem(fertilizedFarmlandRich, itemProperties()), id("fertilized_farmland_rich"));
blocks.register(() -> fertilizedFarmlandRichStable = new FertilizedFarmlandBlock(defaultProperties()), () -> new BlockItem(fertilizedFarmlandRichStable, itemProperties()), id("fertilized_farmland_rich_stable"));
blocks.register(() -> fertilizedFarmlandHealthy = new FertilizedFarmlandBlock(defaultProperties()), () -> new BlockItem(fertilizedFarmlandHealthy, itemProperties()), id("fertilized_farmland_healthy"));
blocks.register(() -> fertilizedFarmlandHealthyStable = new FertilizedFarmlandBlock(defaultProperties()), () -> new BlockItem(fertilizedFarmlandHealthyStable, itemProperties()), id("fertilized_farmland_healthy_stable"));
blocks.register(() -> fertilizedFarmlandStable = new FertilizedFarmlandBlock(defaultProperties()), () -> new BlockItem(fertilizedFarmlandStable, itemProperties()), id("fertilized_farmland_stable"));
blocks.register((identifier) -> market = new MarketBlock(defaultProperties(identifier)), (block, identifier) -> new BlockItem(block, itemProperties(identifier)), id("market"));
blocks.register((identifier) -> chickenNest = new ChickenNestBlock(defaultProperties(identifier)), (block, identifier) -> new BlockItem(block, itemProperties(identifier)), id("chicken_nest"));
blocks.register((identifier) -> feedingTrough = new FeedingTroughBlock(defaultProperties(identifier)), (block, identifier) -> new BlockItem(block, itemProperties(identifier)), id("feeding_trough"));
blocks.register((identifier) -> fertilizedFarmlandRich = new FertilizedFarmlandBlock(defaultProperties(identifier)), (block, identifier) -> new BlockItem(block, itemProperties(identifier)), id("fertilized_farmland_rich"));
blocks.register((identifier) -> fertilizedFarmlandRichStable = new FertilizedFarmlandBlock(defaultProperties(identifier)), (block, identifier) -> new BlockItem(block, itemProperties(identifier)), id("fertilized_farmland_rich_stable"));
blocks.register((identifier) -> fertilizedFarmlandHealthy = new FertilizedFarmlandBlock(defaultProperties(identifier)), (block, identifier) -> new BlockItem(block, itemProperties(identifier)), id("fertilized_farmland_healthy"));
blocks.register((identifier) -> fertilizedFarmlandHealthyStable = new FertilizedFarmlandBlock(defaultProperties(identifier)), (block, identifier) -> new BlockItem(block, itemProperties(identifier)), id("fertilized_farmland_healthy_stable"));
blocks.register((identifier) -> fertilizedFarmlandStable = new FertilizedFarmlandBlock(defaultProperties(identifier)), (block, identifier) -> new BlockItem(block, itemProperties(identifier)), id("fertilized_farmland_stable"));
}

public static Item.Properties itemProperties() {
return new Item.Properties();
private static BlockBehaviour.Properties defaultProperties(ResourceLocation identifier) {
return BlockBehaviour.Properties.of().setId(blockId(identifier));
}

private static BlockBehaviour.Properties defaultProperties() {
return Balm.getBlocks().blockProperties();
private static Item.Properties itemProperties(ResourceLocation identifier) {
return new Item.Properties().setId(itemId(identifier));
}

private static ResourceKey<Block> blockId(ResourceLocation identifier) {
return ResourceKey.create(Registries.BLOCK, identifier);
}

private static ResourceKey<Item> itemId(ResourceLocation identifier) {
return ResourceKey.create(Registries.ITEM, identifier);
}

private static ResourceLocation id(String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ private static Block getBlockForTraits(Set<FertilizerType> traits) {

private final FertilizerType fertilizerType;

public FertilizerItem(FertilizerType fertilizerType) {
super(new Item.Properties());
public FertilizerItem(Item.Properties properties, FertilizerType fertilizerType) {
super(properties);
this.fertilizerType = fertilizerType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import net.blay09.mods.balm.api.item.BalmItems;
import net.blay09.mods.farmingforblockheads.FarmingForBlockheads;
import net.blay09.mods.farmingforblockheads.block.ModBlocks;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
Expand All @@ -18,15 +20,26 @@ public class ModItems {
public static TagKey<Item> EGGS_TAG;

public static void initialize(BalmItems items) {
items.registerItem(() -> greenFertilizer = new FertilizerItem(FertilizerItem.FertilizerType.RICH), id("green_fertilizer"));
items.registerItem(() -> redFertilizer = new FertilizerItem(FertilizerItem.FertilizerType.HEALTHY), id("red_fertilizer"));
items.registerItem(() -> yellowFertilizer = new FertilizerItem(FertilizerItem.FertilizerType.STABLE), id("yellow_fertilizer"));
items.registerItem((identifier) -> greenFertilizer = new FertilizerItem(itemProperties(identifier), FertilizerItem.FertilizerType.RICH),
id("green_fertilizer"));
items.registerItem((identifier) -> redFertilizer = new FertilizerItem(itemProperties(identifier), FertilizerItem.FertilizerType.HEALTHY),
id("red_fertilizer"));
items.registerItem((identifier) -> yellowFertilizer = new FertilizerItem(itemProperties(identifier), FertilizerItem.FertilizerType.STABLE),
id("yellow_fertilizer"));

items.registerCreativeModeTab(() -> new ItemStack(ModBlocks.market), id("farmingforblockheads"));

EGGS_TAG = Balm.getRegistries().getItemTag(ResourceLocation.fromNamespaceAndPath("c", "eggs"));
}

private static Item.Properties itemProperties(ResourceLocation identifier) {
return new Item.Properties().setId(itemId(identifier));
}

private static ResourceKey<Item> itemId(ResourceLocation identifier) {
return ResourceKey.create(Registries.ITEM, identifier);
}

private static ResourceLocation id(String path) {
return ResourceLocation.fromNamespaceAndPath(FarmingForBlockheads.MOD_ID, path);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"block.farmingforblockheads.market": "Market",
"block.farmingforblockheads.chicken_nest": "Chicken Nest",
"block.farmingforblockheads.feeding_trough": "Feeding Trough",
"block.farmingforblockheads.fertilized_farmland_rich": "Fertilized Farmland",
"block.farmingforblockheads.fertilized_farmland_healthy": "Fertilized Farmland",
"block.farmingforblockheads.fertilized_farmland_stable": "Fertilized Farmland",
"block.farmingforblockheads.fertilized_farmland_rich_stable": "Fertilized Farmland",
"block.farmingforblockheads.fertilized_farmland_healthy_stable": "Fertilized Farmland",
"item.farmingforblockheads.market": "Market",
"item.farmingforblockheads.chicken_nest": "Chicken Nest",
"item.farmingforblockheads.feeding_trough": "Feeding Trough",
"item.farmingforblockheads.fertilized_farmland_rich": "Fertilized Farmland",
"item.farmingforblockheads.fertilized_farmland_healthy": "Fertilized Farmland",
"item.farmingforblockheads.fertilized_farmland_stable": "Fertilized Farmland",
"item.farmingforblockheads.fertilized_farmland_rich_stable": "Fertilized Farmland",
"item.farmingforblockheads.fertilized_farmland_healthy_stable": "Fertilized Farmland",
"item.farmingforblockheads.red_fertilizer": "Red Fertilizer",
"item.farmingforblockheads.green_fertilizer": "Green Fertilizer",
"item.farmingforblockheads.yellow_fertilizer": "Yellow Fertilizer",
Expand Down
4 changes: 3 additions & 1 deletion fabric/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ dependencies {
modCompileOnly "com.terraformersmc:modmenu:$modmenu_version"
modCompileOnly "mezz.jei:jei-$jei_minecraft_version-common-api:$jei_version"
modCompileOnly "mezz.jei:jei-$jei_minecraft_version-fabric-api:$jei_version"
modRuntimeOnly "mezz.jei:jei-$jei_minecraft_version-fabric:$jei_version"
if (jei_minecraft_version == minecraft_version) {
modRuntimeOnly "mezz.jei:jei-$jei_minecraft_version-fabric:$jei_version"
}
modCompileOnly "dev.emi:emi-fabric:$emi_version:api"
}

0 comments on commit 19e58b6

Please sign in to comment.