Skip to content

Commit

Permalink
1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsterner committed Jul 16, 2023
1 parent e852c35 commit eaede7a
Show file tree
Hide file tree
Showing 21 changed files with 375 additions and 137 deletions.
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "curse.maven:farmersdelightfabric-482834:${project.delight_version}"

modImplementation "com.terraformersmc.terraform-api:terraform-wood-api-v1:${project.terraform_wood_api_version}"
include "com.terraformersmc.terraform-api:terraform-wood-api-v1:${project.terraform_wood_api_version}"

modCompileOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}"
modImplementation include("com.terraformersmc.terraform-api:terraform-wood-api-v1:${project.terraform_wood_api_version}")
}

processResources {
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true

# Fabric Properties
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.14.12
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21

# Mod Properties
mod_version = 0.14.9+1.19.2
mod_version = 0.14.9+1.20.1
maven_group = dev.sterner
archives_base_name = cultural-delights-fabric

# Dependencies
fabric_version=0.72.0+1.19.2
delight_version=4111426
rei_version=9.1.555
terraform_wood_api_version=4.2.0
fabric_version=0.85.0+1.20.1
delight_version=4640640
rei_version=4644023
terraform_wood_api_version=7.0.1
19 changes: 19 additions & 0 deletions src/main/java/dev/sterner/culturaldelights/CulturalDelights.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,48 @@
package dev.sterner.culturaldelights;

import com.mojang.serialization.Codec;
import dev.sterner.culturaldelights.common.registry.CDObjects;
import dev.sterner.culturaldelights.common.registry.CDWorldGenerators;
import dev.sterner.culturaldelights.common.utils.Constants;
import dev.sterner.culturaldelights.common.world.AvocadoBundleTreeDecorator;
import dev.sterner.culturaldelights.mixin.TreeDecoratorTypeInvoker;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.entry.ItemEntry;
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 net.minecraft.util.math.random.Random;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOffers;
import net.minecraft.village.VillagerProfession;
import net.minecraft.world.gen.treedecorator.TreeDecorator;
import net.minecraft.world.gen.treedecorator.TreeDecoratorType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CulturalDelights implements ModInitializer {
private static final Identifier SQUID_LOOT_TABLE_ID = EntityType.SQUID.getLootTableId();
private static final Identifier GLOW_SQUID_LOOT_TABLE_ID = EntityType.GLOW_SQUID.getLootTableId();

public static final TreeDecoratorType<AvocadoBundleTreeDecorator> AVOCADO_BUNDLE_TREE_DECORATOR_TYPE = register(Constants.id("avocado_bundle"), AvocadoBundleTreeDecorator.CODEC);

private static <P extends TreeDecorator> TreeDecoratorType<P> register(Identifier id, Codec<P> codec) {
return Registry.register(Registries.TREE_DECORATOR_TYPE, id, new TreeDecoratorType<>(codec));
}

@Override
public void onInitialize() {
CDObjects.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;

public class CornBlock extends PlantBlock implements Fertilizable {
public static final IntProperty AGE;
Expand Down Expand Up @@ -85,7 +86,7 @@ public boolean isSupportingCornUpper(BlockState topState) {


@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) {
BlockState upperState = world.getBlockState(pos.up());
if (upperState.getBlock() instanceof CornUpperBlock) {
return !((CornUpperBlock)upperState.getBlock()).isMature(upperState);
Expand All @@ -95,7 +96,7 @@ public boolean canGrow(World world, Random random, BlockPos pos, BlockState stat
}

@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
BlockState upperState = world.getBlockState(pos.up());
if (upperState.getBlock() instanceof CornUpperBlock) {
return !((CornUpperBlock)upperState.getBlock()).isMature(upperState);
Expand All @@ -104,7 +105,6 @@ public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, b
}
}


protected int getBonemealAgeIncrease(World worldIn) {
return MathHelper.nextInt(worldIn.random, 1, 4);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import dev.sterner.culturaldelights.common.utils.Constants;
import dev.sterner.culturaldelights.common.world.AvocadoPitGenerator;
import dev.sterner.culturaldelights.common.world.AvocadoSaplingGenerator;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
Expand All @@ -18,8 +19,9 @@
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.util.Identifier;
import net.minecraft.util.registry.Registry;

import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -113,7 +115,7 @@ public class CDObjects {
public static final Item EGGPLANT_SEEDS = register("eggplant_seeds", new AliasedBlockItem(EGGPLANT_CROP, settings()));

private static Item.Settings settings() {
return new Item.Settings().group(FarmersDelightMod.ITEM_GROUP);
return new Item.Settings();
}

private static <T extends Item> T register(String name, T item) {
Expand All @@ -130,8 +132,10 @@ private static <T extends Block> T register(String name, T block, Item.Settings
}

public static void init() {
BLOCKS.keySet().forEach(block -> Registry.register(Registry.BLOCK, BLOCKS.get(block), block));
ITEMS.keySet().forEach(item -> Registry.register(Registry.ITEM, ITEMS.get(item), item));
BLOCKS.keySet().forEach(block -> Registry.register(Registries.BLOCK, BLOCKS.get(block), block));
ITEMS.keySet().forEach(item -> Registry.register(Registries.ITEM, ITEMS.get(item), item));
ItemGroupEvents.modifyEntriesEvent(FarmersDelightMod.ITEM_GROUP).register(entries -> ITEMS.keySet().forEach(entries::add));


FlammableBlockRegistry flammableRegistry = FlammableBlockRegistry.getDefaultInstance();
flammableRegistry.add(AVOCADO_LEAVES, 30, 60);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package dev.sterner.culturaldelights.common.registry;

import dev.sterner.culturaldelights.common.utils.Constants;
import net.minecraft.item.Item;
import net.minecraft.tag.TagKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public class CDTags {
public static final TagKey<Item> CORN = TagKey.of(Registry.ITEM_KEY, new Identifier("c", "corn"));
public static final TagKey<Item> CORN = TagKey.of(RegistryKeys.ITEM, new Identifier("c", "corn"));
}
Original file line number Diff line number Diff line change
@@ -1,118 +1,41 @@
package dev.sterner.culturaldelights.common.registry;

import com.google.common.collect.ImmutableList;
import dev.sterner.culturaldelights.common.utils.Constants;
import dev.sterner.culturaldelights.common.world.AvocadoBundleTreeDecorator;
import dev.sterner.culturaldelights.mixin.SimpleBlockStateProviderAccessor;
import dev.sterner.culturaldelights.mixin.TreeDecoratorTypeInvoker;
import net.fabricmc.fabric.api.biome.v1.BiomeModification;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.biome.v1.ModificationPhase;
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags;
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.feature.size.FeatureSize;
import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize;
import net.minecraft.world.gen.foliage.AcaciaFoliagePlacer;
import net.minecraft.world.gen.placementmodifier.BiomePlacementModifier;
import net.minecraft.world.gen.placementmodifier.RarityFilterPlacementModifier;
import net.minecraft.world.gen.placementmodifier.SquarePlacementModifier;
import net.minecraft.world.gen.treedecorator.TreeDecoratorType;
import net.minecraft.world.gen.treedecorator.TrunkVineTreeDecorator;
import net.minecraft.world.gen.trunk.StraightTrunkPlacer;

import java.util.List;

public class CDWorldGenerators {
private static final FeatureSize EMPTY_SIZE = new TwoLayersFeatureSize(0, 0, 0);
public static final TreeDecoratorType<AvocadoBundleTreeDecorator> AVOCADO_BUNDLE_TREE_DECORATOR_TYPE = TreeDecoratorTypeInvoker.register("avocado", AvocadoBundleTreeDecorator.CODEC);

public static final RegistryEntry<ConfiguredFeature<TreeFeatureConfig, ?>> AVOCADO_TREE =
ConfiguredFeatures.register("culturaldelights:avocado_tree",
Feature.TREE,
new TreeFeatureConfig.Builder(
SimpleBlockStateProviderAccessor.callInit(CDObjects.AVOCADO_LOG.getDefaultState()),
new StraightTrunkPlacer(5, 0, 0),
SimpleBlockStateProviderAccessor.callInit(CDObjects.AVOCADO_LEAVES.getDefaultState()),
new AcaciaFoliagePlacer(ConstantIntProvider.create(3), ConstantIntProvider.create(0)),
EMPTY_SIZE)
.decorators(ImmutableList.of(new AvocadoBundleTreeDecorator(1)))
.ignoreVines()
.build());


public static final RegistryEntry<PlacedFeature> AVOCADO_PLACED =
PlacedFeatures.register("culturaldelights:avocado_tree_with_chance", AVOCADO_TREE,
VegetationPlacedFeatures.modifiersWithWouldSurvive(PlacedFeatures.createCountExtraModifier(1, 0.1f, 1),
CDObjects.AVOCADO_SAPLING));


public static final RegistryEntry<ConfiguredFeature<TreeFeatureConfig, ?>> AVOCADO_PIT =
ConfiguredFeatures.register("culturaldelights:avocado_pit",
Feature.TREE,
new TreeFeatureConfig.Builder(
SimpleBlockStateProviderAccessor.callInit(CDObjects.AVOCADO_SAPLING.getDefaultState()),
new StraightTrunkPlacer(3, 2, 0),
SimpleBlockStateProviderAccessor.callInit(CDObjects.AVOCADO_SAPLING.getDefaultState()),
new AcaciaFoliagePlacer(ConstantIntProvider.create(0), ConstantIntProvider.create(0)),
new TwoLayersFeatureSize(1, 0, 1))
.build());


public static final RegistryKey<ConfiguredFeature<?, ?>> AVOCADO = ConfiguredFeatures.of("culturaldelights:avocado");
public static final RegistryKey<PlacedFeature> TREE_AVOCADO = PlacedFeatures.of("culturaldelights:tree_avocado");

public static final RegistryEntry<ConfiguredFeature<RandomPatchFeatureConfig, ?>> WILD_CORN =
ConfiguredFeatures.register("wild_corn", Feature.FLOWER,
new RandomPatchFeatureConfig(32, 6, 2, PlacedFeatures.createEntry(Feature.SIMPLE_BLOCK,
new SimpleBlockFeatureConfig(SimpleBlockStateProviderAccessor.callInit(CDObjects.WILD_CORN.getDefaultState())))));
public static final RegistryKey<ConfiguredFeature<?, ?>> AVOCADO_PIT = ConfiguredFeatures.of("culturaldelights:avocado_pit");
public static final RegistryKey<PlacedFeature> TREE_AVOCADO_PIT = PlacedFeatures.of("culturaldelights:tree_avocado_pit");

public static final RegistryEntry<ConfiguredFeature<RandomPatchFeatureConfig, ?>> WILD_EGGPLANTS =
ConfiguredFeatures.register("wild_eggplants", Feature.FLOWER,
new RandomPatchFeatureConfig(32, 6, 2, PlacedFeatures.createEntry(Feature.SIMPLE_BLOCK,
new SimpleBlockFeatureConfig(SimpleBlockStateProviderAccessor.callInit(CDObjects.WILD_EGGPLANTS.getDefaultState())))));
public static final RegistryKey<ConfiguredFeature<?, ?>> WILD_CORN = ConfiguredFeatures.of("culturaldelights:wild_corn");
public static final RegistryKey<PlacedFeature> WILD_CORN_PLACED = PlacedFeatures.of("culturaldelights:wild_corn");

public static final RegistryEntry<ConfiguredFeature<RandomPatchFeatureConfig, ?>> WILD_CUCUMBERS =
ConfiguredFeatures.register("wild_cucumbers", Feature.FLOWER,
new RandomPatchFeatureConfig(32, 6, 2, PlacedFeatures.createEntry(Feature.SIMPLE_BLOCK,
new SimpleBlockFeatureConfig(SimpleBlockStateProviderAccessor.callInit(CDObjects.WILD_CUCUMBERS.getDefaultState())))));
public static final RegistryKey<ConfiguredFeature<?, ?>> WILD_CUCUMBERS = ConfiguredFeatures.of("culturaldelights:wild_cucumbers");
public static final RegistryKey<PlacedFeature> WILD_CUCUMBERS_PLACED = PlacedFeatures.of("culturaldelights:wild_cucumbers");

public static final RegistryEntry<PlacedFeature> WILD_CORN_PLACED = PlacedFeatures.register("wild_corn_placed",
WILD_CORN, RarityFilterPlacementModifier.of(25),
SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of());
public static final RegistryKey<ConfiguredFeature<?, ?>> WILD_EGGPLANTS = ConfiguredFeatures.of("culturaldelights:wild_eggplants");
public static final RegistryKey<PlacedFeature> WILD_EGGPLANTS_PLACED = PlacedFeatures.of("culturaldelights:wild_eggplants");

public static final RegistryEntry<PlacedFeature> WILD_EGGPLANTS_PLACED = PlacedFeatures.register("wild_eggplants_placed",
WILD_EGGPLANTS, RarityFilterPlacementModifier.of(25),
SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of());

public static final RegistryEntry<PlacedFeature> WILD_CUCUMBERS_PLACED = PlacedFeatures.register("wild_cucumbers_placed",
WILD_CUCUMBERS, RarityFilterPlacementModifier.of(25),
SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of());

public static void init() {


BiomeModification worldGen = BiomeModifications.create(Constants.id("world_features"));

worldGen.add(ModificationPhase.ADDITIONS,
BiomeSelectors.tag(ConventionalBiomeTags.JUNGLE),
context -> context.getGenerationSettings().addFeature(GenerationStep.Feature.VEGETAL_DECORATION, AVOCADO_PLACED.getKey().get()));

worldGen.add(ModificationPhase.ADDITIONS,
BiomeSelectors.tag(ConventionalBiomeTags.PLAINS),
context -> context.getGenerationSettings().addFeature(GenerationStep.Feature.VEGETAL_DECORATION, WILD_CORN_PLACED.getKey().get()));

worldGen.add(ModificationPhase.ADDITIONS,
BiomeSelectors.tag(ConventionalBiomeTags.SWAMP),
context -> {
context.getGenerationSettings().addFeature(GenerationStep.Feature.VEGETAL_DECORATION, WILD_EGGPLANTS_PLACED.getKey().get());
context.getGenerationSettings().addFeature(GenerationStep.Feature.VEGETAL_DECORATION, WILD_CUCUMBERS_PLACED.getKey().get());
});

worldGen.add(ModificationPhase.ADDITIONS,
BiomeSelectors.tag(ConventionalBiomeTags.JUNGLE),
context -> context.getGenerationSettings().addFeature(GenerationStep.Feature.VEGETAL_DECORATION, WILD_EGGPLANTS_PLACED.getKey().get()));
BiomeModifications.addFeature(BiomeSelectors.tag(ConventionalBiomeTags.JUNGLE), GenerationStep.Feature.VEGETAL_DECORATION, TREE_AVOCADO);
BiomeModifications.addFeature(BiomeSelectors.tag(ConventionalBiomeTags.PLAINS), GenerationStep.Feature.VEGETAL_DECORATION, WILD_CORN_PLACED);
BiomeModifications.addFeature(BiomeSelectors.tag(ConventionalBiomeTags.SWAMP), GenerationStep.Feature.VEGETAL_DECORATION, WILD_EGGPLANTS_PLACED);
BiomeModifications.addFeature(BiomeSelectors.tag(ConventionalBiomeTags.SWAMP), GenerationStep.Feature.VEGETAL_DECORATION, WILD_CUCUMBERS_PLACED);
BiomeModifications.addFeature(BiomeSelectors.tag(ConventionalBiomeTags.JUNGLE), GenerationStep.Feature.VEGETAL_DECORATION, WILD_EGGPLANTS_PLACED);
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
package dev.sterner.culturaldelights.common.world;

import com.mojang.serialization.Codec;
import dev.sterner.culturaldelights.CulturalDelights;
import dev.sterner.culturaldelights.common.registry.CDObjects;
import dev.sterner.culturaldelights.common.registry.CDWorldGenerators;
import net.minecraft.block.BeehiveBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.TestableWorld;
import net.minecraft.world.gen.treedecorator.BeehiveTreeDecorator;
import net.minecraft.world.gen.treedecorator.TreeDecorator;
import net.minecraft.world.gen.treedecorator.TreeDecoratorType;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class AvocadoBundleTreeDecorator extends TreeDecorator {

Expand All @@ -37,11 +26,9 @@ public AvocadoBundleTreeDecorator(float probability) {

@Override
protected TreeDecoratorType<?> getType() {
return CDWorldGenerators.AVOCADO_BUNDLE_TREE_DECORATOR_TYPE;
return CulturalDelights.AVOCADO_BUNDLE_TREE_DECORATOR_TYPE;
}



@Override
public void generate(Generator generator) {
Random random = generator.getRandom();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import dev.sterner.culturaldelights.common.registry.CDWorldGenerators;
import net.minecraft.block.sapling.SaplingGenerator;
import net.minecraft.registry.RegistryKey;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import org.jetbrains.annotations.Nullable;

public class AvocadoPitGenerator extends SaplingGenerator {

@Nullable
@Override
protected RegistryEntry<? extends ConfiguredFeature<?, ?>> getTreeFeature(Random random, boolean bees) {
protected RegistryKey<ConfiguredFeature<?, ?>> getTreeFeature(Random random, boolean bees) {
return CDWorldGenerators.AVOCADO_PIT;
}
}
Loading

0 comments on commit eaede7a

Please sign in to comment.