From 6c21f1ce23921772c1fb3f384c7f32fa8bc21d92 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Sat, 13 Apr 2024 15:26:22 +0200 Subject: [PATCH] refabricated --- build.gradle | 26 ++- gradle.properties | 5 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../culturaldelights/CulturalDelights.java | 97 ++++++++++ .../CulturalDelightsClient.java | 24 +++ .../common/block/AvocadoPitBlock.java | 25 +++ .../common/block/CornBlock.java | 176 ++++++++++++++++++ .../common/block/CornUpperBlock.java | 71 +++++++ .../common/block/CucumbersBlock.java | 38 ++++ .../common/block/EggplantBlock.java | 43 +++++ .../common/block/ExoticRollMedleyBlock.java | 70 +++++++ .../common/registry/CDConfiguredFeatures.java | 42 +++++ .../common/registry/CDFoodComponents.java | 67 +++++++ .../common/registry/CDObjects.java | 169 +++++++++++++++++ .../common/registry/CDTags.java | 10 + .../common/registry/CDWorldGenerators.java | 25 +++ .../common/utils/Constants.java | 11 ++ .../world/AvocadoBundleTreeDecorator.java | 54 ++++++ .../common/world/AvocadoPitGenerator.java | 17 ++ .../common/world/AvocadoSaplingGenerator.java | 17 ++ .../SimpleBlockStateProviderAccessor.java | 14 ++ .../mixin/TreeDecoratorTypeInvoker.java | 16 ++ .../culturaldelights/CulturalDelights.java | 77 ++++---- .../CulturalDelightsClient.java | 4 +- .../common/block/AvocadoPitBlock.java | 21 ++- .../common/block/CornBlock.java | 134 ++++++------- .../common/block/CornUpperBlock.java | 60 +++--- .../common/block/CucumbersBlock.java | 41 ++-- .../common/block/EggplantBlock.java | 41 ++-- .../common/block/ExoticRollMedleyBlock.java | 49 +++-- .../common/registry/CDConfiguredFeatures.java | 30 +-- .../common/registry/CDFoodComponents.java | 112 +++++------ .../common/registry/CDObjects.java | 81 ++++---- .../common/registry/CDTags.java | 10 +- .../common/registry/CDWorldGenerators.java | 20 +- .../common/utils/Constants.java | 6 +- .../world/AvocadoBundleTreeDecorator.java | 25 ++- .../common/world/AvocadoPitGenerator.java | 12 +- .../common/world/AvocadoSaplingGenerator.java | 12 +- .../SimpleBlockStateProviderAccessor.java | 8 +- .../mixin/TreeDecoratorTypeInvoker.java | 4 +- .../assets/culturaldelights/lang/en_us.json | 4 + .../placed_feature/patch_wild_corn.json | 3 +- .../placed_feature/patch_wild_cucumbers.json | 3 +- .../placed_feature/patch_wild_eggplants.json | 3 +- 45 files changed, 1405 insertions(+), 374 deletions(-) create mode 100644 remappedSrc/dev/sterner/culturaldelights/CulturalDelights.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/CulturalDelightsClient.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/block/AvocadoPitBlock.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/block/CornBlock.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/block/CornUpperBlock.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/block/CucumbersBlock.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/block/EggplantBlock.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/block/ExoticRollMedleyBlock.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/registry/CDConfiguredFeatures.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/registry/CDFoodComponents.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/registry/CDObjects.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/registry/CDTags.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/registry/CDWorldGenerators.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/utils/Constants.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoBundleTreeDecorator.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoPitGenerator.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoSaplingGenerator.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/mixin/SimpleBlockStateProviderAccessor.java create mode 100644 remappedSrc/dev/sterner/culturaldelights/mixin/TreeDecoratorTypeInvoker.java diff --git a/build.gradle b/build.gradle index fb2fbc7..2b3f91b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.0-SNAPSHOT' + id 'fabric-loom' version '1.5-SNAPSHOT' id 'maven-publish' } @@ -11,6 +11,21 @@ version = project.mod_version group = project.maven_group repositories { + maven { + name = "Greenhouse Maven" + url = 'https://maven.greenhouseteam.dev/releases/' + } + maven { url = "https://mvn.devos.one/snapshots/" } // Porting Lib + maven { + url "https://maven.jamieswhiteshirt.com/libs-release" // Reach Entity Attributes (Required by Porting Lib) + content { + includeGroup "com.jamieswhiteshirt" + } + } + maven { + name = "Jitpack, ASM, MixinExtras" + url = "https://jitpack.io" + } maven { name "cloth config, rei" url "https://maven.shedaniel.me" @@ -24,13 +39,18 @@ repositories { dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + mappings loom.officialMojangMappings() modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation "curse.maven:farmersdelightfabric-482834:${project.delight_version}" + modImplementation("vectorwing:FarmersDelight:${fdrf_version}") { + exclude(group: "net.fabricmc") + } modImplementation include("com.terraformersmc.terraform-api:terraform-wood-api-v1:${project.terraform_wood_api_version}") + + //Fabric ASM + modImplementation include ("com.github.Chocohead:Fabric-ASM:v2.3") } processResources { diff --git a/gradle.properties b/gradle.properties index 5c59562..88adc2b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,15 +5,16 @@ org.gradle.parallel=true # Fabric Properties minecraft_version=1.20.1 yarn_mappings=1.20.1+build.9 -loader_version=0.14.21 +loader_version=0.15.9 # Mod Properties - mod_version = 0.14.11+1.20.1 + mod_version = 1.0.0+1.20.1 maven_group = dev.sterner archives_base_name = cultural-delights-fabric # Dependencies fabric_version=0.85.0+1.20.1 delight_version=4640640 +fdrf_version=1.20.1-2.0.16+refabricated rei_version=4644023 terraform_wood_api_version=7.0.1 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f398c33..c30b486 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/remappedSrc/dev/sterner/culturaldelights/CulturalDelights.java b/remappedSrc/dev/sterner/culturaldelights/CulturalDelights.java new file mode 100644 index 0000000..bef0251 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/CulturalDelights.java @@ -0,0 +1,97 @@ +package dev.sterner.culturaldelights; + +import com.mojang.serialization.Codec; +import dev.sterner.culturaldelights.common.registry.CDObjects; +import dev.sterner.culturaldelights.common.registry.CDConfiguredFeatures; +import dev.sterner.culturaldelights.common.registry.CDWorldGenerators; +import dev.sterner.culturaldelights.common.utils.Constants; +import dev.sterner.culturaldelights.common.world.AvocadoBundleTreeDecorator; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.biome.v1.BiomeModifications; +import net.fabricmc.fabric.api.loot.v2.LootTableEvents; +import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.entity.npc.VillagerTrades; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; +import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.entries.LootItem; + +public class CulturalDelights implements ModInitializer { + public static final String MOD_ID = "culturaldelights"; + private static final ResourceLocation SQUID_LOOT_TABLE_ID = EntityType.SQUID.getDefaultLootTable(); + private static final ResourceLocation GLOW_SQUID_LOOT_TABLE_ID = EntityType.GLOW_SQUID.getDefaultLootTable(); + + public static final TreeDecoratorType AVOCADO_BUNDLE_TREE_DECORATOR_TYPE = register(Constants.id("avocado_bundle"), AvocadoBundleTreeDecorator.CODEC); + + private static

TreeDecoratorType

register(ResourceLocation id, Codec

codec) { + return Registry.register(BuiltInRegistries.TREE_DECORATOR_TYPE, id, new TreeDecoratorType<>(codec)); + } + + @Override + public void onInitialize() { + CDObjects.init(); + + CDConfiguredFeatures.registerAll(); + CDWorldGenerators.init(); + + BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.PLAINS), GenerationStep.Decoration.VEGETAL_DECORATION, + CDConfiguredFeatures.PATCH_WILD_CUCUMBERS.key()); + BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.SWAMP), GenerationStep.Decoration.VEGETAL_DECORATION, + CDConfiguredFeatures.PATCH_WILD_EGGPLANTS.key()); + BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.SWAMP), GenerationStep.Decoration.VEGETAL_DECORATION, + CDConfiguredFeatures.PATCH_WILD_CUCUMBERS.key()); + BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.JUNGLE), GenerationStep.Decoration.VEGETAL_DECORATION, + CDConfiguredFeatures.PATCH_WILD_EGGPLANTS.key()); + + TradeOfferHelper.registerVillagerOffers(VillagerProfession.FARMER, 1, factories -> { + factories.add(new EmeraldToItemOffer(new ItemStack(CDObjects.CUCUMBER), 1, 10, 2, 0.2F)); + factories.add(new EmeraldToItemOffer(new ItemStack(CDObjects.EGGPLANT), 1, 10, 2, 0.2F)); + factories.add(new EmeraldToItemOffer(new ItemStack(CDObjects.CORN_COB), 1, 10, 2, 0.2F)); + factories.add(new EmeraldToItemOffer(new ItemStack(CDObjects.AVOCADO), 1, 10, 2, 0.2F)); + }); + + LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> { + if(source.isBuiltin() && SQUID_LOOT_TABLE_ID.equals(id)){ + LootPool.Builder poolBuilder = LootPool.lootPool().add(LootItem.lootTableItem(CDObjects.SQUID)); + tableBuilder.withPool(poolBuilder); + } + if(source.isBuiltin() && GLOW_SQUID_LOOT_TABLE_ID.equals(id)){ + LootPool.Builder poolBuilder = LootPool.lootPool().add(LootItem.lootTableItem(CDObjects.GLOW_SQUID)); + tableBuilder.withPool(poolBuilder); + } + }); + } + + public static class EmeraldToItemOffer implements VillagerTrades.ItemListing { + + private final ItemStack sell; + private final int price; + private final int maxUses; + private final int experience; + private final float multiplier; + + public EmeraldToItemOffer(ItemStack stack, int price, int maxUses, int experience, float multiplier) { + this.sell = stack; + this.price = price; + this.maxUses = maxUses; + this.experience = experience; + this.multiplier = multiplier; + } + + public MerchantOffer getOffer(Entity entity, RandomSource random) { + return new MerchantOffer(new ItemStack(Items.EMERALD, this.price + random.nextInt(3)), sell, this.maxUses, this.experience, this.multiplier); + } + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/CulturalDelightsClient.java b/remappedSrc/dev/sterner/culturaldelights/CulturalDelightsClient.java new file mode 100644 index 0000000..563dc99 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/CulturalDelightsClient.java @@ -0,0 +1,24 @@ +package dev.sterner.culturaldelights; + +import dev.sterner.culturaldelights.common.registry.CDObjects; +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.minecraft.client.renderer.RenderType; + +public class CulturalDelightsClient implements ClientModInitializer { + @Override + public void onInitializeClient() { + BlockRenderLayerMap.INSTANCE.putBlocks(RenderType.cutout(), + CDObjects.WILD_CUCUMBERS, + CDObjects.WILD_CORN, + CDObjects.WILD_EGGPLANTS, + CDObjects.AVOCADO_LEAVES, + CDObjects.AVOCADO_SAPLING, + CDObjects.AVOCADO_PIT, + CDObjects.CUCUMBER_CROP, + CDObjects.EGGPLANT_CROP, + CDObjects.CORN_CROP, + CDObjects.CORN_UPPER + ); + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/block/AvocadoPitBlock.java b/remappedSrc/dev/sterner/culturaldelights/common/block/AvocadoPitBlock.java new file mode 100644 index 0000000..b674dc4 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/block/AvocadoPitBlock.java @@ -0,0 +1,25 @@ +package dev.sterner.culturaldelights.common.block; + +import net.minecraft.block.*; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SaplingBlock; +import net.minecraft.world.level.block.grower.AbstractTreeGrower; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class AvocadoPitBlock extends SaplingBlock { + private static final VoxelShape SHAPE_PIT = Block.box(6, 0, 6, 10, 3, 10); + + public AvocadoPitBlock(AbstractTreeGrower treeIn, BlockBehaviour.Properties properties) { + super(treeIn, properties); + } + + @Override + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + return SHAPE_PIT; + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/block/CornBlock.java b/remappedSrc/dev/sterner/culturaldelights/common/block/CornBlock.java new file mode 100644 index 0000000..08f48d1 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/block/CornBlock.java @@ -0,0 +1,176 @@ +package dev.sterner.culturaldelights.common.block; + +import com.nhoryzon.mc.farmersdelight.block.BuddingBushBlock; +import com.nhoryzon.mc.farmersdelight.registry.BlocksRegistry; +import com.nhoryzon.mc.farmersdelight.util.BlockStateUtils; +import dev.sterner.culturaldelights.common.registry.CDObjects; +import net.minecraft.block.*; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.BonemealableBlock; +import net.minecraft.world.level.block.BushBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class CornBlock extends BushBlock implements BonemealableBlock { + public static final IntegerProperty AGE; + public static final BooleanProperty SUPPORTING; + private static final VoxelShape[] SHAPE_BY_AGE; + public static final int GROWTH_CHANCE = 10; + + public CornBlock(Properties settings) { + super(settings); + this.registerDefaultState(this.defaultBlockState().setValue(AGE, 0).setValue(SUPPORTING, false)); + } + + @Override + public BlockState updateShape(BlockState stateIn, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { + BlockState state = super.updateShape(stateIn, direction, neighborState, world, pos, neighborPos); + if (!state.isAir()) { + if (direction == Direction.UP) { + return state.setValue(SUPPORTING, this.isSupportingCornUpper(neighborState)); + } + } + return state; + } + + @Override + protected boolean mayPlaceOn(BlockState floor, BlockGetter world, BlockPos pos) { + return floor.is(Blocks.FARMLAND) || floor.is(BlocksRegistry.RICH_SOIL_FARMLAND.get()); + } + + public IntegerProperty getAgeProperty() { + return AGE; + } + + protected int getAge(BlockState state) { + return state.getValue(this.getAgeProperty()); + } + + public int getMaxAge() { + return 3; + } + + @Override + public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { + return new ItemStack(CDObjects.CORN_KERNELS); + } + + + public BlockState withAge(int age) { + return this.defaultBlockState().setValue(this.getAgeProperty(), age); + } + + public boolean isMaxAge(BlockState state) { + return (Integer)state.getValue(this.getAgeProperty()) >= this.getMaxAge(); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(AGE, SUPPORTING); + } + + public boolean isSupportingCornUpper(BlockState topState) { + return topState.getBlock() == CDObjects.CORN_UPPER; + } + + + @Override + public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state, boolean isClient) { + BlockState upperState = world.getBlockState(pos.above()); + if (upperState.getBlock() instanceof CornUpperBlock) { + return !((CornUpperBlock)upperState.getBlock()).isMaxAge(upperState); + } else { + return true; + } + } + + @Override + public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) { + BlockState upperState = world.getBlockState(pos.above()); + if (upperState.getBlock() instanceof CornUpperBlock) { + return !((CornUpperBlock)upperState.getBlock()).isMaxAge(upperState); + } else { + return true; + } + } + + protected int getBonemealAgeIncrease(Level worldIn) { + return Mth.nextInt(worldIn.random, 1, 4); + } + + @Override + public void performBonemeal(ServerLevel worldIn, RandomSource rand, BlockPos pos, BlockState state) { + int ageGrowth = Math.min(this.getAge(state) + this.getBonemealAgeIncrease(worldIn), 7); + if (ageGrowth <= this.getMaxAge()) { + worldIn.setBlockAndUpdate(pos, state.setValue(AGE, ageGrowth)); + } else { + BlockState top = worldIn.getBlockState(pos.above()); + if (top.getBlock() == CDObjects.CORN_UPPER) { + BonemealableBlock growable = (BonemealableBlock)worldIn.getBlockState(pos.above()).getBlock(); + if (growable.isValidBonemealTarget(worldIn, pos.above(), top, false)) { + growable.performBonemeal(worldIn, worldIn.random, pos.above(), top); + } + } else { + CornUpperBlock cornUpper = (CornUpperBlock) CDObjects.CORN_UPPER; + int remainingGrowth = ageGrowth - this.getMaxAge() - 1; + if (cornUpper.defaultBlockState().canSurvive(worldIn, pos.above()) && worldIn.isEmptyBlock(pos.above())) { + worldIn.setBlockAndUpdate(pos, state.setValue(AGE, this.getMaxAge())); + worldIn.setBlock(pos.above(), cornUpper.defaultBlockState().setValue(CornUpperBlock.CORN_AGE, remainingGrowth), 2); + } + } + } + + } + + @Override + public void randomTick(BlockState state, ServerLevel worldIn, BlockPos pos, RandomSource rand) { + super.randomTick(state, worldIn, pos, rand); + + if (!worldIn.hasChunksAt(pos.offset(-1, -1, -1), pos.offset(1, 1, 1))) { + return; + } + + if (worldIn.getMaxLocalRawBrightness(pos.above(), 0) >= 6 && this.getAge(state) <= this.getMaxAge() && rand.nextInt(3) == 0) { + randomGrowTick(state, worldIn, pos, rand); + } + } + + private void randomGrowTick(BlockState state, ServerLevel worldIn, BlockPos pos, RandomSource rand) { + int currentAge = this.getAge(state); + if (currentAge <= this.getMaxAge() && rand.nextInt((int) (25.0F / GROWTH_CHANCE) + 1) == 0) { + if (currentAge == this.getMaxAge()) { + CornUpperBlock cornUpper = (CornUpperBlock) CDObjects.CORN_UPPER; + if (cornUpper.defaultBlockState().canSurvive(worldIn, pos.above()) && worldIn.isEmptyBlock(pos.above())) { + worldIn.setBlockAndUpdate(pos.above(), cornUpper.defaultBlockState()); + } + } else { + worldIn.setBlockAndUpdate(pos, state.setValue(AGE, this.getAge(state)+1)); + } + } + } + + static { + AGE = BlockStateProperties.AGE_3; + SUPPORTING = BooleanProperty.create("supporting"); + SHAPE_BY_AGE = new VoxelShape[]{ + Block.box(3.0D, 0.0D, 3.0D, 13.0D, 8.0D, 13.0D), + Block.box(3.0D, 0.0D, 3.0D, 13.0D, 10.0D, 13.0D), + Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D), + Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D)}; + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/block/CornUpperBlock.java b/remappedSrc/dev/sterner/culturaldelights/common/block/CornUpperBlock.java new file mode 100644 index 0000000..5d37e93 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/block/CornUpperBlock.java @@ -0,0 +1,71 @@ +package dev.sterner.culturaldelights.common.block; + +import dev.sterner.culturaldelights.common.registry.CDObjects; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class CornUpperBlock extends CropBlock { + public static final IntegerProperty CORN_AGE; + private static final VoxelShape[] SHAPE_BY_AGE; + + public CornUpperBlock(Properties settings) { + super(settings); + } + + public IntegerProperty getAgeProperty() { + return CORN_AGE; + } + + @Override + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + return SHAPE_BY_AGE[state.getValue(this.getAgeProperty())]; + } + + public int getMaxAge() { + return 3; + } + + @Override + protected ItemLike getBaseSeedId() { + return CDObjects.CORN_KERNELS; + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(CORN_AGE); + } + + @Override + protected boolean mayPlaceOn(BlockState floor, BlockGetter world, BlockPos pos) { + return floor.getBlock() == CDObjects.CORN_CROP; + } + + + protected int getBonemealAgeIncrease(Level worldIn) { + return super.getBonemealAgeIncrease(worldIn) / 3; + } + + @Override + public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { + return (world.getRawBrightness(pos, 0) >= 8 || world.canSeeSky(pos)) && world.getBlockState(pos.below()).getBlock() == CDObjects.CORN_CROP; + } + + static { + CORN_AGE = BlockStateProperties.AGE_3; + SHAPE_BY_AGE = new VoxelShape[]{Block.box(3.0D, 0.0D, 3.0D, 13.0D, 8.0D, 13.0D), + Block.box(3.0D, 0.0D, 3.0D, 13.0D, 10.0D, 13.0D), + Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D), + Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D)}; + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/block/CucumbersBlock.java b/remappedSrc/dev/sterner/culturaldelights/common/block/CucumbersBlock.java new file mode 100644 index 0000000..98c5c4e --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/block/CucumbersBlock.java @@ -0,0 +1,38 @@ +package dev.sterner.culturaldelights.common.block; + +import dev.sterner.culturaldelights.common.registry.CDObjects; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class CucumbersBlock extends CropBlock { + private static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{ + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 3.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 5.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D) + }; + + public CucumbersBlock(Properties settings) { + super(settings); + } + + @Override + protected ItemLike getBaseSeedId() { + return CDObjects.CUCUMBER_SEEDS; + } + + @Override + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + return SHAPE_BY_AGE[state.getValue(this.getAgeProperty())]; + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/block/EggplantBlock.java b/remappedSrc/dev/sterner/culturaldelights/common/block/EggplantBlock.java new file mode 100644 index 0000000..0a86194 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/block/EggplantBlock.java @@ -0,0 +1,43 @@ +package dev.sterner.culturaldelights.common.block; + +import dev.sterner.culturaldelights.common.registry.CDObjects; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class EggplantBlock extends CropBlock { + private static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{ + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 3.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 5.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D) + }; + + public EggplantBlock(Properties settings) { + super(settings); + } + + @Override + protected ItemLike getBaseSeedId() { + return CDObjects.EGGPLANT_SEEDS; + } + + @Override + public int getMaxAge() { + return 7; + } + + @Override + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + return SHAPE_BY_AGE[state.getValue(this.getAgeProperty())]; + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/block/ExoticRollMedleyBlock.java b/remappedSrc/dev/sterner/culturaldelights/common/block/ExoticRollMedleyBlock.java new file mode 100644 index 0000000..c826301 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/block/ExoticRollMedleyBlock.java @@ -0,0 +1,70 @@ +package dev.sterner.culturaldelights.common.block; + +import com.nhoryzon.mc.farmersdelight.block.FeastBlock; +import dev.sterner.culturaldelights.common.registry.CDObjects; +import java.util.Arrays; +import java.util.List; +import java.util.function.Supplier; +import net.minecraft.core.BlockPos; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class ExoticRollMedleyBlock extends FeastBlock { + public static final IntegerProperty ROLL_SERVINGS = IntegerProperty.create("servings", 0, 8); + protected static final VoxelShape PLATE_SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 2.0, 15.0); + protected static final VoxelShape FOOD_SHAPE; + public final List riceRollServings; + + public ExoticRollMedleyBlock() { + super(Properties.copy(Blocks.CAKE), CDObjects.TROPICAL_ROLL, true); + this.riceRollServings = Arrays.asList( + CDObjects.PUFFERFISH_ROLL, + CDObjects.PUFFERFISH_ROLL, + CDObjects.TROPICAL_ROLL, + CDObjects.TROPICAL_ROLL, + CDObjects.TROPICAL_ROLL, + CDObjects.CHICKEN_ROLL_SLICE, + CDObjects.CHICKEN_ROLL_SLICE, + CDObjects.CHICKEN_ROLL_SLICE); + } + + @Override + public IntegerProperty getServingsProperty() { + return ROLL_SERVINGS; + } + + @Override + public int getMaxServings() { + return 8; + } + + @Override + public ItemStack getServingStack(BlockState state) { + return new ItemStack(riceRollServings.get(state.getValue(getServingsProperty()) - 1)); + } + + @Override + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + return state.getValue(getServingsProperty()) == 0 ? PLATE_SHAPE : FOOD_SHAPE; + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(FACING, ROLL_SERVINGS); + } + + + static { + FOOD_SHAPE = Shapes.joinUnoptimized(PLATE_SHAPE, Block.box(2.0, 2.0, 2.0, 14.0, 4.0, 14.0), BooleanOp.OR); + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/registry/CDConfiguredFeatures.java b/remappedSrc/dev/sterner/culturaldelights/common/registry/CDConfiguredFeatures.java new file mode 100644 index 0000000..2422d3c --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/registry/CDConfiguredFeatures.java @@ -0,0 +1,42 @@ +package dev.sterner.culturaldelights.common.registry; + +import dev.sterner.culturaldelights.CulturalDelights; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; + +public enum CDConfiguredFeatures { + PATCH_WILD_CORN("patch_wild_corn"), + PATCH_WILD_CUCUMBERS("patch_wild_cucumbers"), + PATCH_WILD_EGGPLANTS("patch_wild_eggplants"); + + private final ResourceLocation featureIdentifier; + private ResourceKey> configuredFeatureRegistryKey; + private ResourceKey featureRegistryKey; + + CDConfiguredFeatures(String featurePathName) { + this.featureIdentifier = new ResourceLocation(CulturalDelights.MOD_ID, featurePathName); + } + + public static void registerAll() { + for (CDConfiguredFeatures value : values()) { + value.configuredFeatureRegistryKey = ResourceKey.create(Registries.CONFIGURED_FEATURE, value.featureIdentifier); + value.featureRegistryKey = ResourceKey.create(Registries.PLACED_FEATURE, value.featureIdentifier); + } + } + + public ResourceKey> configKey() { + return configuredFeatureRegistryKey; + } + + public ResourceKey key() { + return featureRegistryKey; + } + + public ResourceLocation identifier() { + return featureIdentifier; + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/registry/CDFoodComponents.java b/remappedSrc/dev/sterner/culturaldelights/common/registry/CDFoodComponents.java new file mode 100644 index 0000000..1426739 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/registry/CDFoodComponents.java @@ -0,0 +1,67 @@ +package dev.sterner.culturaldelights.common.registry; + +import com.nhoryzon.mc.farmersdelight.item.ConsumableItem; +import com.nhoryzon.mc.farmersdelight.registry.EffectsRegistry; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.food.FoodProperties; + +public class CDFoodComponents { + //INGREDIENTS + public static final FoodProperties AVOCADO = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build(); + public static final FoodProperties CUCUMBER = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.5F).build(); + public static final FoodProperties PICKLE = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.7F).build(); + public static final FoodProperties EGGPLANT = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.2F).build(); + public static final FoodProperties SMOKED_EGGPLANT = (new FoodProperties.Builder()).nutrition(8).saturationMod(0.6F).build(); + public static final FoodProperties SMOKED_TOMATO = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build(); + public static final FoodProperties SMOKED_CORN = (new FoodProperties.Builder()).nutrition(5).saturationMod(0.7F).build(); + public static final FoodProperties SMOKED_WHITE_EGGPLANT = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).build(); + public static final FoodProperties WHITE_EGGPLANT = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).build(); + public static final FoodProperties CORN_COB = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.4F).build(); + public static final FoodProperties SQUID = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.2F).build(); + public static final FoodProperties COOKED_SQUID = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.8F).build(); + public static final FoodProperties GLOW_SQUID = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.2F) + .effect(new MobEffectInstance(MobEffects.GLOWING, 40, 1), 1.0F).fast().build(); + public static final FoodProperties RAW_CALAMARI = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.2F).build(); + public static final FoodProperties COOKED_CALAMARI = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).build(); + + public static final FoodProperties CUT_AVOCADO = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).fast().build(); + public static final FoodProperties CUT_CUCUMBER = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.3F).fast().build(); + public static final FoodProperties CUT_PICKLE = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.5F).fast().build(); + public static final FoodProperties CUT_EGGPLANT = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).fast().build(); + public static final FoodProperties SMOKED_CUT_EGGPLANT = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.4F).fast().build(); + + //SUSHI + public static final FoodProperties MIDORI_ROLL = (new FoodProperties.Builder()).nutrition(14).saturationMod(0.7F).build(); + public static final FoodProperties MIDORI_ROLL_SLICE = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.4F).fast().build(); + public static final FoodProperties EGG_ROLL = (new FoodProperties.Builder()).nutrition(5).saturationMod(0.5F).fast().build(); + public static final FoodProperties CHICKEN_ROLL = (new FoodProperties.Builder()).nutrition(16).saturationMod(0.8F).build(); + public static final FoodProperties CHICKEN_ROLL_SLICE = (new FoodProperties.Builder()).nutrition(8).saturationMod(0.6F).fast().build(); + public static final FoodProperties PUFFERFISH_ROLL = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.6F) + .effect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0), 1.0F) + .effect(new MobEffectInstance(MobEffects.HUNGER, 200, 1), 1.0F).fast().build(); + public static final FoodProperties TROPICAL_ROLL = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.6F).fast().build(); + public static final FoodProperties RICE_BALL = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).fast().build(); + public static final FoodProperties CALAMARI_ROLL = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.6F).fast().build(); + + //MEALS + public static final FoodProperties CORN_DOUGH = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).build(); + public static final FoodProperties TORTILLA = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build(); + public static final FoodProperties POPCORN = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.2F).fast().build(); + public static final FoodProperties TORTILLA_CHIPS = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).fast().build(); + public static final FoodProperties ELOTE = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.8F).build(); + public static final FoodProperties BEEF_BURRITO = (new FoodProperties.Builder()).nutrition(14).saturationMod(0.7F).build(); + public static final FoodProperties MUTTON_SANDWICH = (new FoodProperties.Builder()).nutrition(10).saturationMod(0.8F).build(); + public static final FoodProperties AVOCADO_TOAST = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.5F).build(); + public static final FoodProperties CREAMED_CORN = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.8F).build(); + public static final FoodProperties CHICKEN_TACO = (new FoodProperties.Builder()).nutrition(10).saturationMod(0.8F).build(); + public static final FoodProperties PORK_WRAP = (new FoodProperties.Builder()).nutrition(10).saturationMod(0.8F).build(); + public static final FoodProperties FISH_TACO = (new FoodProperties.Builder()).nutrition(10).saturationMod(0.8F).build(); + public static final FoodProperties HEARTY_SALAD = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.7F) + .effect(new MobEffectInstance(EffectsRegistry.NOURISHMENT.get(), ConsumableItem.LONG_DURATION, 0), 1.0F).build(); + public static final FoodProperties FRIED_EGGPLANT_PASTA = (new FoodProperties.Builder()).nutrition(12).saturationMod(0.9F) + .effect(new MobEffectInstance(EffectsRegistry.NOURISHMENT.get(), ConsumableItem.LONG_DURATION, 0), 1.0F).build(); + public static final FoodProperties EGGPLANT_BURGER = (new FoodProperties.Builder()).nutrition(12).saturationMod(0.7F).build(); + public static final FoodProperties SPICY_CURRY = (new FoodProperties.Builder()).nutrition(12).saturationMod(1.3F) + .effect(new MobEffectInstance(EffectsRegistry.NOURISHMENT.get(), ConsumableItem.LONG_DURATION, 0), 1.0F).build(); +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/registry/CDObjects.java b/remappedSrc/dev/sterner/culturaldelights/common/registry/CDObjects.java new file mode 100644 index 0000000..f98218e --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/registry/CDObjects.java @@ -0,0 +1,169 @@ +package dev.sterner.culturaldelights.common.registry; + +import com.nhoryzon.mc.farmersdelight.FarmersDelightMod; +import com.nhoryzon.mc.farmersdelight.block.WildCropBlock; +import com.nhoryzon.mc.farmersdelight.registry.BlocksRegistry; +import dev.sterner.culturaldelights.common.block.*; +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; +import net.fabricmc.fabric.api.registry.FuelRegistry; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.BowlFoodItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemNameBlockItem; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.SaplingBlock; +import java.util.LinkedHashMap; +import java.util.Map; + +public class CDObjects { + public static final Map BLOCKS = new LinkedHashMap<>(); + public static final Map ITEMS = new LinkedHashMap<>(); + + + + public static final Item AVOCADO = register("avocado", new Item(settings().food(CDFoodComponents.AVOCADO))); + public static final Item CUT_AVOCADO = register("cut_avocado", new Item(settings().food(CDFoodComponents.CUT_AVOCADO))); + public static final Item CUCUMBER = register("cucumber", new Item(settings().food(CDFoodComponents.CUCUMBER))); + public static final Item PICKLE = register("pickle", new Item(settings().food(CDFoodComponents.PICKLE))); + public static final Item CUT_CUCUMBER = register("cut_cucumber", new Item(settings().food(CDFoodComponents.CUT_CUCUMBER))); + public static final Item CUT_PICKLE = register("cut_pickle", new Item(settings().food(CDFoodComponents.CUT_PICKLE))); + public static final Item EGGPLANT = register("eggplant", new Item(settings().food(CDFoodComponents.EGGPLANT))); + public static final Item CUT_EGGPLANT = register("cut_eggplant", new Item(settings().food(CDFoodComponents.CUT_EGGPLANT))); + public static final Item SMOKED_EGGPLANT = register("smoked_eggplant", new Item(settings().food(CDFoodComponents.SMOKED_EGGPLANT))); + public static final Item SMOKED_TOMATO = register("smoked_tomato", new Item(settings().food(CDFoodComponents.SMOKED_TOMATO))); + public static final Item SMOKED_CORN = register("smoked_corn", new Item(settings().food(CDFoodComponents.SMOKED_CORN))); + public static final Item SMOKED_CUT_EGGPLANT = register("smoked_cut_eggplant", new Item(settings().food(CDFoodComponents.SMOKED_CUT_EGGPLANT))); + public static final Item SMOKED_WHITE_EGGPLANT = register("smoked_white_eggplant", new Item(settings().food(CDFoodComponents.SMOKED_WHITE_EGGPLANT))); + public static final Item WHITE_EGGPLANT = register("white_eggplant", new Item(settings().food(CDFoodComponents.WHITE_EGGPLANT))); + public static final Item CORN_COB = register("corn_cob", new Item(settings().food(CDFoodComponents.CORN_COB))); + public static final Item SQUID = register("squid", new Item(settings().food(CDFoodComponents.SQUID))); + public static final Item COOKED_SQUID = register("cooked_squid", new Item(settings().food(CDFoodComponents.COOKED_SQUID))); + public static final Item GLOW_SQUID = register("glow_squid", new Item(settings().food(CDFoodComponents.GLOW_SQUID))); + public static final Item RAW_CALAMARI = register("raw_calamari", new Item(settings().food(CDFoodComponents.RAW_CALAMARI))); + public static final Item COOKED_CALAMARI = register("cooked_calamari", new Item(settings().food(CDFoodComponents.COOKED_CALAMARI))); + + public static final Item POPCORN = register("popcorn", new Item(settings().food(CDFoodComponents.POPCORN))); + public static final Item CORN_DOUGH = register("corn_dough", new Item(settings().food(CDFoodComponents.CORN_DOUGH))); + public static final Item TORTILLA = register("tortilla", new Item(settings().food(CDFoodComponents.TORTILLA))); + public static final Item TORTILLA_CHIPS = register("tortilla_chips", new Item(settings().food(CDFoodComponents.TORTILLA_CHIPS))); + public static final Item ELOTE = register("elote", new Item(settings().food(CDFoodComponents.ELOTE))); + public static final Item HEARTY_SALAD = register("hearty_salad", new BowlFoodItem(settings().food(CDFoodComponents.HEARTY_SALAD))); + public static final Item BEEF_BURRITO = register("beef_burrito", new Item(settings().food(CDFoodComponents.BEEF_BURRITO))); + public static final Item MUTTON_SANDWICH = register("mutton_sandwich", new Item(settings().food(CDFoodComponents.MUTTON_SANDWICH))); + public static final Item FRIED_EGGPLANT_PASTA = register("fried_eggplant_pasta", new BowlFoodItem(settings().food(CDFoodComponents.FRIED_EGGPLANT_PASTA))); + public static final Item EGGPLANT_BURGER = register("eggplant_burger", new Item(settings().food(CDFoodComponents.EGGPLANT_BURGER))); + public static final Item AVOCADO_TOAST = register("avocado_toast", new Item(settings().food(CDFoodComponents.AVOCADO_TOAST))); + public static final Item CREAMED_CORN = register("creamed_corn", new BowlFoodItem(settings().food(CDFoodComponents.CREAMED_CORN))); + public static final Item CHICKEN_TACO = register("chicken_taco", new Item(settings().food(CDFoodComponents.CHICKEN_TACO))); + public static final Item SPICY_CURRY = register("spicy_curry", new BowlFoodItem(settings().food(CDFoodComponents.SPICY_CURRY))); + public static final Item PORK_WRAP = register("pork_wrap", new Item(settings().food(CDFoodComponents.PORK_WRAP))); + public static final Item FISH_TACO = register("fish_taco", new Item(settings().food(CDFoodComponents.FISH_TACO))); + public static final Item MIDORI_ROLL = register("midori_roll", new Item(settings().food(CDFoodComponents.MIDORI_ROLL))); + public static final Item MIDORI_ROLL_SLICE = register("midori_roll_slice", new Item(settings().food(CDFoodComponents.MIDORI_ROLL_SLICE))); + public static final Item EGG_ROLL = register("egg_roll", new Item(settings().food(CDFoodComponents.EGG_ROLL))); + public static final Item CHICKEN_ROLL = register("chicken_roll", new Item(settings().food(CDFoodComponents.CHICKEN_ROLL))); + public static final Item CHICKEN_ROLL_SLICE = register("chicken_roll_slice", new Item(settings().food(CDFoodComponents.CHICKEN_ROLL_SLICE))); + public static final Item PUFFERFISH_ROLL = register("pufferfish_roll", new Item(settings().food(CDFoodComponents.PUFFERFISH_ROLL))); + public static final Item TROPICAL_ROLL = register("tropical_roll", new Item(settings().food(CDFoodComponents.TROPICAL_ROLL))); + public static final Item RICE_BALL = register("rice_ball", new Item(settings().food(CDFoodComponents.RICE_BALL))); + public static final Item CALAMARI_ROLL = register("calamari_roll", new Item(settings().food(CDFoodComponents.CALAMARI_ROLL))); + + + + public static final Block AVOCADO_BUNDLE = register("avocado_bundle", new Block(FabricBlockSettings.copy(Blocks.PUMPKIN)), settings(), true); + + public static final Block WILD_CUCUMBERS = register("wild_cucumbers", new WildCropBlock(), settings(), true); + public static final Block WILD_CORN = register("wild_corn", new WildCropBlock(), settings(), true); + public static final Block WILD_EGGPLANTS = register("wild_eggplants", new WildCropBlock(), settings(), true); + + public static final Block AVOCADO_LOG = register("avocado_log", new RotatedPillarBlock(FabricBlockSettings.copy(Blocks.JUNGLE_LOG)), settings(), true); + public static final Block AVOCADO_WOOD = register("avocado_wood", new RotatedPillarBlock(FabricBlockSettings.copy(Blocks.JUNGLE_WOOD)), settings(), true); + public static final Block AVOCADO_LEAVES = register("avocado_leaves", new RotatedPillarBlock(FabricBlockSettings.copy(Blocks.JUNGLE_LEAVES)), settings(), true); + + public static final Block AVOCADO_SAPLING = register("avocado_sapling", new SaplingBlock(new AvocadoSaplingGenerator(), FabricBlockSettings.copy(Blocks.OAK_SAPLING)), settings(), true); + + public static final Block CUCUMBER_CROP = register("cucumbers", new CucumbersBlock(FabricBlockSettings.copy(Blocks.WHEAT)), settings(), false); + public static final Block EGGPLANT_CROP = register("eggplants", new EggplantBlock(FabricBlockSettings.copy(Blocks.WHEAT)), settings(), false); + + public static final Block CORN_CROP = register("corn", new CornBlock(FabricBlockSettings.copy(Blocks.WHEAT)), settings(), false); + public static final Block CORN_UPPER = register("corn_upper", new CornUpperBlock(FabricBlockSettings.copy(Blocks.WHEAT)), settings(), false); + + public static final Block AVOCADO_PIT = register("avocado_pit", new AvocadoPitBlock(new AvocadoPitGenerator(), FabricBlockSettings.copy(Blocks.OAK_SAPLING)), settings(), true); + + public static final Block AVOCADO_CRATE = register("avocado_crate", new Block(FabricBlockSettings.copy(BlocksRegistry.CARROT_CRATE.get())), settings(), true); + public static final Block CUCUMBER_CRATE = register("cucumber_crate", new Block(FabricBlockSettings.copy(BlocksRegistry.CARROT_CRATE.get())), settings(), true); + public static final Block PICKLE_CRATE = register("pickle_crate", new Block(FabricBlockSettings.copy(BlocksRegistry.CARROT_CRATE.get())), settings(), true); + public static final Block CORN_COB_CRATE = register("corn_cob_crate", new Block(FabricBlockSettings.copy(BlocksRegistry.CARROT_CRATE.get())), settings(), true); + public static final Block EGGPLANT_CRATE = register("eggplant_crate", new Block(FabricBlockSettings.copy(BlocksRegistry.CARROT_CRATE.get())), settings(), true); + + + public static final Block EXOTIC_ROLL_MEDLEY = register("exotic_roll_medley", new ExoticRollMedleyBlock(), settings(), true); + + public static final Item CUCUMBER_SEEDS = register("cucumber_seeds", new ItemNameBlockItem(CUCUMBER_CROP ,settings())); + public static final Item CORN_KERNELS = register("corn_kernels", new ItemNameBlockItem(CORN_CROP, settings())); + public static final Item EGGPLANT_SEEDS = register("eggplant_seeds", new ItemNameBlockItem(EGGPLANT_CROP, settings())); + + private static Item.Properties settings() { + return new Item.Properties(); + } + + private static T register(String name, T item) { + ITEMS.put(item, Constants.id(name)); + return item; + } + + private static T register(String name, T block, Item.Properties settings, boolean createItem) { + BLOCKS.put(block, Constants.id(name)); + if (createItem) { + ITEMS.put(new BlockItem(block, settings), BLOCKS.get(block)); + } + return block; + } + + public static void init() { + BLOCKS.keySet().forEach(block -> Registry.register(BuiltInRegistries.BLOCK, BLOCKS.get(block), block)); + ITEMS.keySet().forEach(item -> Registry.register(BuiltInRegistries.ITEM, ITEMS.get(item), item)); + ItemGroupEvents.modifyEntriesEvent(FarmersDelightMod.ITEM_GROUP).register(entries -> ITEMS.keySet().forEach(entries::accept)); + + + FlammableBlockRegistry flammableRegistry = FlammableBlockRegistry.getDefaultInstance(); + flammableRegistry.add(AVOCADO_LEAVES, 30, 60); + flammableRegistry.add(AVOCADO_LOG, 5, 5); + flammableRegistry.add(AVOCADO_WOOD, 5, 5); + + CompostingChanceRegistry compostRegistry = CompostingChanceRegistry.INSTANCE; + compostRegistry.add(CUCUMBER_SEEDS, 0.3f); + compostRegistry.add(CORN_KERNELS, 0.3f); + compostRegistry.add(EGGPLANT_SEEDS, 0.3f); + compostRegistry.add(AVOCADO_PIT, 0.3f); + + compostRegistry.add(CUT_CUCUMBER, 0.5f); + compostRegistry.add(CUT_AVOCADO, 0.5f); + compostRegistry.add(CUT_EGGPLANT, 0.5f); + + compostRegistry.add(AVOCADO, 0.65f); + compostRegistry.add(CUCUMBER, 0.65f); + compostRegistry.add(CORN_COB, 0.65f); + compostRegistry.add(EGGPLANT, 0.65f); + compostRegistry.add(WILD_CUCUMBERS, 0.65f); + compostRegistry.add(WILD_CORN, 0.65f); + compostRegistry.add(WILD_EGGPLANTS, 0.65f); + compostRegistry.add(AVOCADO_LEAVES, 0.65f); + compostRegistry.add(AVOCADO_SAPLING, 0.65f); + + compostRegistry.add(POPCORN, 0.85f); + + compostRegistry.add(AVOCADO_BUNDLE, 1f); + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/registry/CDTags.java b/remappedSrc/dev/sterner/culturaldelights/common/registry/CDTags.java new file mode 100644 index 0000000..7e6e07d --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/registry/CDTags.java @@ -0,0 +1,10 @@ +package dev.sterner.culturaldelights.common.registry; + +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; + +public class CDTags { + public static final TagKey CORN = TagKey.create(Registries.ITEM, new ResourceLocation("c", "corn")); +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/registry/CDWorldGenerators.java b/remappedSrc/dev/sterner/culturaldelights/common/registry/CDWorldGenerators.java new file mode 100644 index 0000000..cf70574 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/registry/CDWorldGenerators.java @@ -0,0 +1,25 @@ +package dev.sterner.culturaldelights.common.registry; + +import net.fabricmc.fabric.api.biome.v1.BiomeModifications; +import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; +import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags; +import net.minecraft.data.worldgen.features.FeatureUtils; +import net.minecraft.data.worldgen.placement.PlacementUtils; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.gen.feature.*; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; + +public class CDWorldGenerators { + + public static final ResourceKey> AVOCADO = FeatureUtils.createKey("culturaldelights:avocado"); + public static final ResourceKey TREE_AVOCADO = PlacementUtils.createKey("culturaldelights:tree_avocado"); + + public static final ResourceKey> AVOCADO_PIT = FeatureUtils.createKey("culturaldelights:avocado_pit"); + public static final ResourceKey TREE_AVOCADO_PIT = PlacementUtils.createKey("culturaldelights:tree_avocado_pit"); + + public static void init() { + BiomeModifications.addFeature(BiomeSelectors.tag(ConventionalBiomeTags.JUNGLE), GenerationStep.Decoration.VEGETAL_DECORATION, TREE_AVOCADO); + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/utils/Constants.java b/remappedSrc/dev/sterner/culturaldelights/common/utils/Constants.java new file mode 100644 index 0000000..d0accc7 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/utils/Constants.java @@ -0,0 +1,11 @@ +package dev.sterner.culturaldelights.common.utils; + +import net.minecraft.resources.ResourceLocation; + +public class Constants { + public static final String MOD_ID = "culturaldelights"; + + public static ResourceLocation id(String string){ + return new ResourceLocation(MOD_ID, string); + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoBundleTreeDecorator.java b/remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoBundleTreeDecorator.java new file mode 100644 index 0000000..a3a885f --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoBundleTreeDecorator.java @@ -0,0 +1,54 @@ +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 java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; + +public class AvocadoBundleTreeDecorator extends TreeDecorator { + + public static final Codec CODEC = Codec.floatRange(0.0F, 1.0F).fieldOf("probability").xmap(AvocadoBundleTreeDecorator::new, (thing) -> thing.probability).codec(); + private final float probability; + + public AvocadoBundleTreeDecorator(float probability) { + this.probability = probability; + } + + @Override + protected TreeDecoratorType type() { + return CulturalDelights.AVOCADO_BUNDLE_TREE_DECORATOR_TYPE; + } + + @Override + public void place(Context generator) { + RandomSource random = generator.random(); + if ((random.nextFloat() < this.probability)) { + List list = generator.leaves(); + if (!list.isEmpty()) { + List list3 = list.stream().filter((pos) -> generator.isAir(pos.below()) && generator.isAir(pos.below(2)) && generator.isAir(pos.below(3))).collect(Collectors.toList()); + if (!list3.isEmpty()) { + for(Direction direction : Direction.Plane.HORIZONTAL) { + if (random.nextFloat() <= 0.25F) { + Collections.shuffle(list3); + Optional optional = list3.stream().findFirst(); + if (optional.isPresent()) { + generator.setBlock(optional.get().below(), CDObjects.AVOCADO_BUNDLE.defaultBlockState()); + } + } + } + + } + } + } + + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoPitGenerator.java b/remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoPitGenerator.java new file mode 100644 index 0000000..f4b30a2 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoPitGenerator.java @@ -0,0 +1,17 @@ +package dev.sterner.culturaldelights.common.world; + +import dev.sterner.culturaldelights.common.registry.CDWorldGenerators; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.grower.AbstractTreeGrower; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import org.jetbrains.annotations.Nullable; + +public class AvocadoPitGenerator extends AbstractTreeGrower { + + @Nullable + @Override + protected ResourceKey> getConfiguredFeature(RandomSource random, boolean bees) { + return CDWorldGenerators.AVOCADO_PIT; + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoSaplingGenerator.java b/remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoSaplingGenerator.java new file mode 100644 index 0000000..68fb26b --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/common/world/AvocadoSaplingGenerator.java @@ -0,0 +1,17 @@ +package dev.sterner.culturaldelights.common.world; + +import dev.sterner.culturaldelights.common.registry.CDWorldGenerators; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.grower.AbstractTreeGrower; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import org.jetbrains.annotations.Nullable; + +public class AvocadoSaplingGenerator extends AbstractTreeGrower { + + @Nullable + @Override + protected ResourceKey> getConfiguredFeature(RandomSource random, boolean bees) { + return CDWorldGenerators.AVOCADO; + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/mixin/SimpleBlockStateProviderAccessor.java b/remappedSrc/dev/sterner/culturaldelights/mixin/SimpleBlockStateProviderAccessor.java new file mode 100644 index 0000000..d4e9eeb --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/mixin/SimpleBlockStateProviderAccessor.java @@ -0,0 +1,14 @@ +package dev.sterner.culturaldelights.mixin; + +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(SimpleStateProvider.class) +public interface SimpleBlockStateProviderAccessor { + @Invoker(value = "") + static SimpleStateProvider callInit(BlockState state) { + throw new UnsupportedOperationException(); + } +} diff --git a/remappedSrc/dev/sterner/culturaldelights/mixin/TreeDecoratorTypeInvoker.java b/remappedSrc/dev/sterner/culturaldelights/mixin/TreeDecoratorTypeInvoker.java new file mode 100644 index 0000000..9cb8388 --- /dev/null +++ b/remappedSrc/dev/sterner/culturaldelights/mixin/TreeDecoratorTypeInvoker.java @@ -0,0 +1,16 @@ +package dev.sterner.culturaldelights.mixin; + +import com.mojang.serialization.Codec; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(TreeDecoratorType.class) +public interface TreeDecoratorTypeInvoker { + + @Invoker("register") + static

TreeDecoratorType

register(String id, Codec

codec) { + throw new AssertionError(); + } +} \ No newline at end of file diff --git a/src/main/java/dev/sterner/culturaldelights/CulturalDelights.java b/src/main/java/dev/sterner/culturaldelights/CulturalDelights.java index 568b969..070b38b 100644 --- a/src/main/java/dev/sterner/culturaldelights/CulturalDelights.java +++ b/src/main/java/dev/sterner/culturaldelights/CulturalDelights.java @@ -8,35 +8,43 @@ import dev.sterner.culturaldelights.common.world.AvocadoBundleTreeDecorator; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.biome.v1.BiomeModifications; +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.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -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.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.biome.BiomeKeys; -import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.treedecorator.TreeDecorator; -import net.minecraft.world.gen.treedecorator.TreeDecoratorType; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.entity.npc.VillagerTrades; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; +import net.minecraft.world.level.storage.loot.LootPool; +import net.minecraft.world.level.storage.loot.entries.LootItem; +import vectorwing.farmersdelight.FarmersDelight; public class CulturalDelights implements ModInitializer { public static final String MOD_ID = "culturaldelights"; - private static final Identifier SQUID_LOOT_TABLE_ID = EntityType.SQUID.getLootTableId(); - private static final Identifier GLOW_SQUID_LOOT_TABLE_ID = EntityType.GLOW_SQUID.getLootTableId(); + private static final ResourceLocation SQUID_LOOT_TABLE_ID = EntityType.SQUID.getDefaultLootTable(); + private static final ResourceLocation GLOW_SQUID_LOOT_TABLE_ID = EntityType.GLOW_SQUID.getDefaultLootTable(); + + public static final ResourceKey ITEM_GROUP = ResourceKey.create(Registries.CREATIVE_MODE_TAB, new ResourceLocation(MOD_ID)); public static final TreeDecoratorType AVOCADO_BUNDLE_TREE_DECORATOR_TYPE = register(Constants.id("avocado_bundle"), AvocadoBundleTreeDecorator.CODEC); - private static

TreeDecoratorType

register(Identifier id, Codec

codec) { - return Registry.register(Registries.TREE_DECORATOR_TYPE, id, new TreeDecoratorType<>(codec)); + private static

TreeDecoratorType

register(ResourceLocation id, Codec

codec) { + return Registry.register(BuiltInRegistries.TREE_DECORATOR_TYPE, id, new TreeDecoratorType<>(codec)); } @Override @@ -46,13 +54,13 @@ public void onInitialize() { CDConfiguredFeatures.registerAll(); CDWorldGenerators.init(); - BiomeModifications.addFeature(context -> context.getBiomeKey().equals(BiomeKeys.PLAINS), GenerationStep.Feature.VEGETAL_DECORATION, + BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.PLAINS), GenerationStep.Decoration.VEGETAL_DECORATION, CDConfiguredFeatures.PATCH_WILD_CUCUMBERS.key()); - BiomeModifications.addFeature(context -> context.getBiomeKey().equals(BiomeKeys.SWAMP), GenerationStep.Feature.VEGETAL_DECORATION, + BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.SWAMP), GenerationStep.Decoration.VEGETAL_DECORATION, CDConfiguredFeatures.PATCH_WILD_EGGPLANTS.key()); - BiomeModifications.addFeature(context -> context.getBiomeKey().equals(BiomeKeys.SWAMP), GenerationStep.Feature.VEGETAL_DECORATION, + BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.SWAMP), GenerationStep.Decoration.VEGETAL_DECORATION, CDConfiguredFeatures.PATCH_WILD_CUCUMBERS.key()); - BiomeModifications.addFeature(context -> context.getBiomeKey().equals(BiomeKeys.JUNGLE), GenerationStep.Feature.VEGETAL_DECORATION, + BiomeModifications.addFeature(context -> context.getBiomeKey().equals(Biomes.JUNGLE), GenerationStep.Decoration.VEGETAL_DECORATION, CDConfiguredFeatures.PATCH_WILD_EGGPLANTS.key()); TradeOfferHelper.registerVillagerOffers(VillagerProfession.FARMER, 1, factories -> { @@ -64,17 +72,22 @@ public void onInitialize() { LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> { if(source.isBuiltin() && SQUID_LOOT_TABLE_ID.equals(id)){ - LootPool.Builder poolBuilder = LootPool.builder().with(ItemEntry.builder(CDObjects.SQUID)); - tableBuilder.pool(poolBuilder); + LootPool.Builder poolBuilder = LootPool.lootPool().add(LootItem.lootTableItem(CDObjects.SQUID)); + tableBuilder.withPool(poolBuilder); } if(source.isBuiltin() && GLOW_SQUID_LOOT_TABLE_ID.equals(id)){ - LootPool.Builder poolBuilder = LootPool.builder().with(ItemEntry.builder(CDObjects.GLOW_SQUID)); - tableBuilder.pool(poolBuilder); + LootPool.Builder poolBuilder = LootPool.lootPool().add(LootItem.lootTableItem(CDObjects.GLOW_SQUID)); + tableBuilder.withPool(poolBuilder); } }); + + Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, ITEM_GROUP, FabricItemGroup.builder() + .icon(() -> new ItemStack(CDObjects.AVOCADO)) + .title(Component.translatable(MOD_ID + ".group.main")) + .build()); } - public static class EmeraldToItemOffer implements TradeOffers.Factory { + public static class EmeraldToItemOffer implements VillagerTrades.ItemListing { private final ItemStack sell; private final int price; @@ -90,8 +103,8 @@ public EmeraldToItemOffer(ItemStack stack, int price, int maxUses, int experienc this.multiplier = multiplier; } - public TradeOffer create(Entity entity, Random random) { - return new TradeOffer(new ItemStack(Items.EMERALD, this.price + random.nextInt(3)), sell, this.maxUses, this.experience, this.multiplier); + public MerchantOffer getOffer(Entity entity, RandomSource random) { + return new MerchantOffer(new ItemStack(Items.EMERALD, this.price + random.nextInt(3)), sell, this.maxUses, this.experience, this.multiplier); } } } diff --git a/src/main/java/dev/sterner/culturaldelights/CulturalDelightsClient.java b/src/main/java/dev/sterner/culturaldelights/CulturalDelightsClient.java index 8395d15..563dc99 100644 --- a/src/main/java/dev/sterner/culturaldelights/CulturalDelightsClient.java +++ b/src/main/java/dev/sterner/culturaldelights/CulturalDelightsClient.java @@ -3,12 +3,12 @@ import dev.sterner.culturaldelights.common.registry.CDObjects; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; -import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.renderer.RenderType; public class CulturalDelightsClient implements ClientModInitializer { @Override public void onInitializeClient() { - BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), + BlockRenderLayerMap.INSTANCE.putBlocks(RenderType.cutout(), CDObjects.WILD_CUCUMBERS, CDObjects.WILD_CORN, CDObjects.WILD_EGGPLANTS, diff --git a/src/main/java/dev/sterner/culturaldelights/common/block/AvocadoPitBlock.java b/src/main/java/dev/sterner/culturaldelights/common/block/AvocadoPitBlock.java index 9dc262f..f91dacb 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/block/AvocadoPitBlock.java +++ b/src/main/java/dev/sterner/culturaldelights/common/block/AvocadoPitBlock.java @@ -1,21 +1,24 @@ package dev.sterner.culturaldelights.common.block; -import net.minecraft.block.*; -import net.minecraft.block.sapling.SaplingGenerator; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SaplingBlock; +import net.minecraft.world.level.block.grower.AbstractTreeGrower; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; public class AvocadoPitBlock extends SaplingBlock { - private static final VoxelShape SHAPE_PIT = Block.createCuboidShape(6, 0, 6, 10, 3, 10); + private static final VoxelShape SHAPE_PIT = Block.box(6, 0, 6, 10, 3, 10); - public AvocadoPitBlock(SaplingGenerator treeIn, AbstractBlock.Settings properties) { + public AvocadoPitBlock(AbstractTreeGrower treeIn, BlockBehaviour.Properties properties) { super(treeIn, properties); } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { return SHAPE_PIT; } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/block/CornBlock.java b/src/main/java/dev/sterner/culturaldelights/common/block/CornBlock.java index 3090dbd..7dd7ac3 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/block/CornBlock.java +++ b/src/main/java/dev/sterner/culturaldelights/common/block/CornBlock.java @@ -1,61 +1,61 @@ package dev.sterner.culturaldelights.common.block; -import com.nhoryzon.mc.farmersdelight.block.BuddingBushBlock; -import com.nhoryzon.mc.farmersdelight.registry.BlocksRegistry; -import com.nhoryzon.mc.farmersdelight.util.BlockStateUtils; import dev.sterner.culturaldelights.common.registry.CDObjects; -import net.minecraft.block.*; -import net.minecraft.item.ItemConvertible; -import net.minecraft.item.ItemStack; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.BooleanProperty; -import net.minecraft.state.property.IntProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.random.Random; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -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; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.BonemealableBlock; +import net.minecraft.world.level.block.BushBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.phys.shapes.VoxelShape; +import vectorwing.farmersdelight.common.registry.ModBlocks; + +public class CornBlock extends BushBlock implements BonemealableBlock { + public static final IntegerProperty AGE; public static final BooleanProperty SUPPORTING; private static final VoxelShape[] SHAPE_BY_AGE; public static final int GROWTH_CHANCE = 10; - public CornBlock(Settings settings) { + public CornBlock(Properties settings) { super(settings); - this.setDefaultState(this.getDefaultState().with(AGE, 0).with(SUPPORTING, false)); + this.registerDefaultState(this.defaultBlockState().setValue(AGE, 0).setValue(SUPPORTING, false)); } @Override - public BlockState getStateForNeighborUpdate(BlockState stateIn, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { - BlockState state = super.getStateForNeighborUpdate(stateIn, direction, neighborState, world, pos, neighborPos); + public BlockState updateShape(BlockState stateIn, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { + BlockState state = super.updateShape(stateIn, direction, neighborState, world, pos, neighborPos); if (!state.isAir()) { if (direction == Direction.UP) { - return state.with(SUPPORTING, this.isSupportingCornUpper(neighborState)); + return state.setValue(SUPPORTING, this.isSupportingCornUpper(neighborState)); } } return state; } @Override - protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { - return floor.isOf(Blocks.FARMLAND) || floor.isOf(BlocksRegistry.RICH_SOIL_FARMLAND.get()); + public boolean mayPlaceOn(BlockState floor, BlockGetter world, BlockPos pos) { + return floor.is(Blocks.FARMLAND) || floor.is(ModBlocks.RICH_SOIL_FARMLAND.get()); } - public IntProperty getAgeProperty() { + public IntegerProperty getAgeProperty() { return AGE; } protected int getAge(BlockState state) { - return state.get(this.getAgeProperty()); + return state.getValue(this.getAgeProperty()); } public int getMaxAge() { @@ -63,21 +63,21 @@ public int getMaxAge() { } @Override - public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { return new ItemStack(CDObjects.CORN_KERNELS); } public BlockState withAge(int age) { - return this.getDefaultState().with(this.getAgeProperty(), age); + return this.defaultBlockState().setValue(this.getAgeProperty(), age); } public boolean isMaxAge(BlockState state) { - return (Integer)state.get(this.getAgeProperty()) >= this.getMaxAge(); + return (Integer)state.getValue(this.getAgeProperty()) >= this.getMaxAge(); } @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(AGE, SUPPORTING); } @@ -87,47 +87,47 @@ public boolean isSupportingCornUpper(BlockState topState) { @Override - public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state, boolean isClient) { - BlockState upperState = world.getBlockState(pos.up()); + public boolean isValidBonemealTarget(LevelReader world, BlockPos pos, BlockState state, boolean isClient) { + BlockState upperState = world.getBlockState(pos.above()); if (upperState.getBlock() instanceof CornUpperBlock) { - return !((CornUpperBlock)upperState.getBlock()).isMature(upperState); + return !((CornUpperBlock)upperState.getBlock()).isMaxAge(upperState); } else { return true; } } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { - BlockState upperState = world.getBlockState(pos.up()); + public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) { + BlockState upperState = world.getBlockState(pos.above()); if (upperState.getBlock() instanceof CornUpperBlock) { - return !((CornUpperBlock)upperState.getBlock()).isMature(upperState); + return !((CornUpperBlock)upperState.getBlock()).isMaxAge(upperState); } else { return true; } } - protected int getBonemealAgeIncrease(World worldIn) { - return MathHelper.nextInt(worldIn.random, 1, 4); + protected int getBonemealAgeIncrease(Level worldIn) { + return Mth.nextInt(worldIn.random, 1, 4); } @Override - public void grow(ServerWorld worldIn, Random rand, BlockPos pos, BlockState state) { + public void performBonemeal(ServerLevel worldIn, RandomSource rand, BlockPos pos, BlockState state) { int ageGrowth = Math.min(this.getAge(state) + this.getBonemealAgeIncrease(worldIn), 7); if (ageGrowth <= this.getMaxAge()) { - worldIn.setBlockState(pos, state.with(AGE, ageGrowth)); + worldIn.setBlockAndUpdate(pos, state.setValue(AGE, ageGrowth)); } else { - BlockState top = worldIn.getBlockState(pos.up()); + BlockState top = worldIn.getBlockState(pos.above()); if (top.getBlock() == CDObjects.CORN_UPPER) { - Fertilizable growable = (Fertilizable)worldIn.getBlockState(pos.up()).getBlock(); - if (growable.isFertilizable(worldIn, pos.up(), top, false)) { - growable.grow(worldIn, worldIn.random, pos.up(), top); + BonemealableBlock growable = (BonemealableBlock)worldIn.getBlockState(pos.above()).getBlock(); + if (growable.isValidBonemealTarget(worldIn, pos.above(), top, false)) { + growable.performBonemeal(worldIn, worldIn.random, pos.above(), top); } } else { CornUpperBlock cornUpper = (CornUpperBlock) CDObjects.CORN_UPPER; int remainingGrowth = ageGrowth - this.getMaxAge() - 1; - if (cornUpper.getDefaultState().canPlaceAt(worldIn, pos.up()) && worldIn.isAir(pos.up())) { - worldIn.setBlockState(pos, state.with(AGE, this.getMaxAge())); - worldIn.setBlockState(pos.up(), cornUpper.getDefaultState().with(CornUpperBlock.CORN_AGE, remainingGrowth), 2); + if (cornUpper.defaultBlockState().canSurvive(worldIn, pos.above()) && worldIn.isEmptyBlock(pos.above())) { + worldIn.setBlockAndUpdate(pos, state.setValue(AGE, this.getMaxAge())); + worldIn.setBlock(pos.above(), cornUpper.defaultBlockState().setValue(CornUpperBlock.CORN_AGE, remainingGrowth), 2); } } } @@ -135,39 +135,39 @@ public void grow(ServerWorld worldIn, Random rand, BlockPos pos, BlockState stat } @Override - public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand) { + public void randomTick(BlockState state, ServerLevel worldIn, BlockPos pos, RandomSource rand) { super.randomTick(state, worldIn, pos, rand); - if (!worldIn.isRegionLoaded(pos.add(-1, -1, -1), pos.add(1, 1, 1))) { + if (!worldIn.hasChunksAt(pos.offset(-1, -1, -1), pos.offset(1, 1, 1))) { return; } - if (worldIn.getLightLevel(pos.up(), 0) >= 6 && this.getAge(state) <= this.getMaxAge() && rand.nextInt(3) == 0) { + if (worldIn.getMaxLocalRawBrightness(pos.above(), 0) >= 6 && this.getAge(state) <= this.getMaxAge() && rand.nextInt(3) == 0) { randomGrowTick(state, worldIn, pos, rand); } } - private void randomGrowTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand) { + private void randomGrowTick(BlockState state, ServerLevel worldIn, BlockPos pos, RandomSource rand) { int currentAge = this.getAge(state); if (currentAge <= this.getMaxAge() && rand.nextInt((int) (25.0F / GROWTH_CHANCE) + 1) == 0) { if (currentAge == this.getMaxAge()) { CornUpperBlock cornUpper = (CornUpperBlock) CDObjects.CORN_UPPER; - if (cornUpper.getDefaultState().canPlaceAt(worldIn, pos.up()) && worldIn.isAir(pos.up())) { - worldIn.setBlockState(pos.up(), cornUpper.getDefaultState()); + if (cornUpper.defaultBlockState().canSurvive(worldIn, pos.above()) && worldIn.isEmptyBlock(pos.above())) { + worldIn.setBlockAndUpdate(pos.above(), cornUpper.defaultBlockState()); } } else { - worldIn.setBlockState(pos, state.with(AGE, this.getAge(state)+1)); + worldIn.setBlockAndUpdate(pos, state.setValue(AGE, this.getAge(state)+1)); } } } static { - AGE = Properties.AGE_3; - SUPPORTING = BooleanProperty.of("supporting"); + AGE = BlockStateProperties.AGE_3; + SUPPORTING = BooleanProperty.create("supporting"); SHAPE_BY_AGE = new VoxelShape[]{ - Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 8.0D, 13.0D), - Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 10.0D, 13.0D), - Block.createCuboidShape(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D), - Block.createCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D)}; + Block.box(3.0D, 0.0D, 3.0D, 13.0D, 8.0D, 13.0D), + Block.box(3.0D, 0.0D, 3.0D, 13.0D, 10.0D, 13.0D), + Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D), + Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D)}; } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/block/CornUpperBlock.java b/src/main/java/dev/sterner/culturaldelights/common/block/CornUpperBlock.java index 4431ba7..7bbe3d6 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/block/CornUpperBlock.java +++ b/src/main/java/dev/sterner/culturaldelights/common/block/CornUpperBlock.java @@ -1,35 +1,35 @@ package dev.sterner.culturaldelights.common.block; import dev.sterner.culturaldelights.common.registry.CDObjects; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.CropBlock; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.ItemConvertible; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import net.minecraft.world.WorldView; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; public class CornUpperBlock extends CropBlock { - public static final IntProperty CORN_AGE; + public static final IntegerProperty CORN_AGE; private static final VoxelShape[] SHAPE_BY_AGE; - public CornUpperBlock(Settings settings) { + public CornUpperBlock(Properties settings) { super(settings); } - public IntProperty getAgeProperty() { + public IntegerProperty getAgeProperty() { return CORN_AGE; } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - return SHAPE_BY_AGE[state.get(this.getAgeProperty())]; + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + return SHAPE_BY_AGE[state.getValue(this.getAgeProperty())]; } public int getMaxAge() { @@ -37,35 +37,35 @@ public int getMaxAge() { } @Override - protected ItemConvertible getSeedsItem() { + protected ItemLike getBaseSeedId() { return CDObjects.CORN_KERNELS; } @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(CORN_AGE); } @Override - protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) { + public boolean mayPlaceOn(BlockState floor, BlockGetter world, BlockPos pos) { return floor.getBlock() == CDObjects.CORN_CROP; } - protected int getGrowthAmount(World worldIn) { - return super.getGrowthAmount(worldIn) / 3; + protected int getBonemealAgeIncrease(Level worldIn) { + return super.getBonemealAgeIncrease(worldIn) / 3; } @Override - public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { - return (world.getBaseLightLevel(pos, 0) >= 8 || world.isSkyVisible(pos)) && world.getBlockState(pos.down()).getBlock() == CDObjects.CORN_CROP; + public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { + return (world.getRawBrightness(pos, 0) >= 8 || world.canSeeSky(pos)) && world.getBlockState(pos.below()).getBlock() == CDObjects.CORN_CROP; } static { - CORN_AGE = Properties.AGE_3; - SHAPE_BY_AGE = new VoxelShape[]{Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 8.0D, 13.0D), - Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 10.0D, 13.0D), - Block.createCuboidShape(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D), - Block.createCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D)}; + CORN_AGE = BlockStateProperties.AGE_3; + SHAPE_BY_AGE = new VoxelShape[]{Block.box(3.0D, 0.0D, 3.0D, 13.0D, 8.0D, 13.0D), + Block.box(3.0D, 0.0D, 3.0D, 13.0D, 10.0D, 13.0D), + Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D), + Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D)}; } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/block/CucumbersBlock.java b/src/main/java/dev/sterner/culturaldelights/common/block/CucumbersBlock.java index 8dc4817..98c5c4e 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/block/CucumbersBlock.java +++ b/src/main/java/dev/sterner/culturaldelights/common/block/CucumbersBlock.java @@ -1,39 +1,38 @@ package dev.sterner.culturaldelights.common.block; import dev.sterner.culturaldelights.common.registry.CDObjects; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.CropBlock; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.ItemConvertible; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; public class CucumbersBlock extends CropBlock { private static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{ - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 3.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 5.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D) + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 3.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 5.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D) }; - public CucumbersBlock(Settings settings) { + public CucumbersBlock(Properties settings) { super(settings); } @Override - protected ItemConvertible getSeedsItem() { + protected ItemLike getBaseSeedId() { return CDObjects.CUCUMBER_SEEDS; } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - return SHAPE_BY_AGE[state.get(this.getAgeProperty())]; + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + return SHAPE_BY_AGE[state.getValue(this.getAgeProperty())]; } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/block/EggplantBlock.java b/src/main/java/dev/sterner/culturaldelights/common/block/EggplantBlock.java index 42d9683..0a86194 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/block/EggplantBlock.java +++ b/src/main/java/dev/sterner/culturaldelights/common/block/EggplantBlock.java @@ -1,34 +1,33 @@ package dev.sterner.culturaldelights.common.block; import dev.sterner.culturaldelights.common.registry.CDObjects; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.CropBlock; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.ItemConvertible; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; public class EggplantBlock extends CropBlock { private static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{ - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 3.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 5.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), - Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D) + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 3.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 5.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D), + Block.box(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D) }; - public EggplantBlock(Settings settings) { + public EggplantBlock(Properties settings) { super(settings); } @Override - protected ItemConvertible getSeedsItem() { + protected ItemLike getBaseSeedId() { return CDObjects.EGGPLANT_SEEDS; } @@ -38,7 +37,7 @@ public int getMaxAge() { } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - return SHAPE_BY_AGE[state.get(this.getAgeProperty())]; + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + return SHAPE_BY_AGE[state.getValue(this.getAgeProperty())]; } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/block/ExoticRollMedleyBlock.java b/src/main/java/dev/sterner/culturaldelights/common/block/ExoticRollMedleyBlock.java index a6fc63f..8c259e5 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/block/ExoticRollMedleyBlock.java +++ b/src/main/java/dev/sterner/culturaldelights/common/block/ExoticRollMedleyBlock.java @@ -1,33 +1,32 @@ package dev.sterner.culturaldelights.common.block; -import com.nhoryzon.mc.farmersdelight.block.FeastBlock; import dev.sterner.culturaldelights.common.registry.CDObjects; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.ShapeContext; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.state.StateManager; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.function.BooleanBiFunction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; - import java.util.Arrays; import java.util.List; import java.util.function.Supplier; +import net.minecraft.core.BlockPos; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import vectorwing.farmersdelight.common.block.FeastBlock; public class ExoticRollMedleyBlock extends FeastBlock { - public static final IntProperty ROLL_SERVINGS = IntProperty.of("servings", 0, 8); - protected static final VoxelShape PLATE_SHAPE = Block.createCuboidShape(1.0, 0.0, 1.0, 15.0, 2.0, 15.0); + public static final IntegerProperty ROLL_SERVINGS = IntegerProperty.create("servings", 0, 8); + protected static final VoxelShape PLATE_SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 2.0, 15.0); protected static final VoxelShape FOOD_SHAPE; public final List riceRollServings; public ExoticRollMedleyBlock() { - super(Settings.copy(Blocks.CAKE), CDObjects.TROPICAL_ROLL, true); + super(Properties.copy(Blocks.CAKE), () -> CDObjects.TROPICAL_ROLL, true); this.riceRollServings = Arrays.asList( CDObjects.PUFFERFISH_ROLL, CDObjects.PUFFERFISH_ROLL, @@ -40,7 +39,7 @@ public ExoticRollMedleyBlock() { } @Override - public IntProperty getServingsProperty() { + public IntegerProperty getServingsProperty() { return ROLL_SERVINGS; } @@ -50,22 +49,22 @@ public int getMaxServings() { } @Override - public ItemStack getServingStack(BlockState state) { - return new ItemStack(riceRollServings.get(state.get(getServingsProperty()) - 1)); + public ItemStack getServingItem(BlockState state) { + return new ItemStack(riceRollServings.get(state.getValue(getServingsProperty()) - 1)); } @Override - public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - return state.get(getServingsProperty()) == 0 ? PLATE_SHAPE : FOOD_SHAPE; + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + return state.getValue(getServingsProperty()) == 0 ? PLATE_SHAPE : FOOD_SHAPE; } @Override - protected void appendProperties(StateManager.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(FACING, ROLL_SERVINGS); } static { - FOOD_SHAPE = VoxelShapes.combine(PLATE_SHAPE, Block.createCuboidShape(2.0, 2.0, 2.0, 14.0, 4.0, 14.0), BooleanBiFunction.OR); + FOOD_SHAPE = Shapes.joinUnoptimized(PLATE_SHAPE, Block.box(2.0, 2.0, 2.0, 14.0, 4.0, 14.0), BooleanOp.OR); } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/registry/CDConfiguredFeatures.java b/src/main/java/dev/sterner/culturaldelights/common/registry/CDConfiguredFeatures.java index 6833dd3..2422d3c 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/registry/CDConfiguredFeatures.java +++ b/src/main/java/dev/sterner/culturaldelights/common/registry/CDConfiguredFeatures.java @@ -1,42 +1,42 @@ package dev.sterner.culturaldelights.common.registry; import dev.sterner.culturaldelights.CulturalDelights; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.util.Identifier; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.FeatureConfig; -import net.minecraft.world.gen.feature.PlacedFeature; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; public enum CDConfiguredFeatures { PATCH_WILD_CORN("patch_wild_corn"), PATCH_WILD_CUCUMBERS("patch_wild_cucumbers"), PATCH_WILD_EGGPLANTS("patch_wild_eggplants"); - private final Identifier featureIdentifier; - private RegistryKey> configuredFeatureRegistryKey; - private RegistryKey featureRegistryKey; + private final ResourceLocation featureIdentifier; + private ResourceKey> configuredFeatureRegistryKey; + private ResourceKey featureRegistryKey; CDConfiguredFeatures(String featurePathName) { - this.featureIdentifier = new Identifier(CulturalDelights.MOD_ID, featurePathName); + this.featureIdentifier = new ResourceLocation(CulturalDelights.MOD_ID, featurePathName); } public static void registerAll() { for (CDConfiguredFeatures value : values()) { - value.configuredFeatureRegistryKey = RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, value.featureIdentifier); - value.featureRegistryKey = RegistryKey.of(RegistryKeys.PLACED_FEATURE, value.featureIdentifier); + value.configuredFeatureRegistryKey = ResourceKey.create(Registries.CONFIGURED_FEATURE, value.featureIdentifier); + value.featureRegistryKey = ResourceKey.create(Registries.PLACED_FEATURE, value.featureIdentifier); } } - public RegistryKey> configKey() { + public ResourceKey> configKey() { return configuredFeatureRegistryKey; } - public RegistryKey key() { + public ResourceKey key() { return featureRegistryKey; } - public Identifier identifier() { + public ResourceLocation identifier() { return featureIdentifier; } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/registry/CDFoodComponents.java b/src/main/java/dev/sterner/culturaldelights/common/registry/CDFoodComponents.java index b19ea66..6a4ae9e 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/registry/CDFoodComponents.java +++ b/src/main/java/dev/sterner/culturaldelights/common/registry/CDFoodComponents.java @@ -1,67 +1,67 @@ package dev.sterner.culturaldelights.common.registry; -import com.nhoryzon.mc.farmersdelight.item.ConsumableItem; -import com.nhoryzon.mc.farmersdelight.registry.EffectsRegistry; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.item.FoodComponent; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.food.FoodProperties; +import vectorwing.farmersdelight.common.item.ConsumableItem; +import vectorwing.farmersdelight.common.registry.ModEffects; public class CDFoodComponents { //INGREDIENTS - public static final FoodComponent AVOCADO = (new FoodComponent.Builder()).hunger(4).saturationModifier(0.6F).build(); - public static final FoodComponent CUCUMBER = (new FoodComponent.Builder()).hunger(2).saturationModifier(0.5F).build(); - public static final FoodComponent PICKLE = (new FoodComponent.Builder()).hunger(4).saturationModifier(0.7F).build(); - public static final FoodComponent EGGPLANT = (new FoodComponent.Builder()).hunger(3).saturationModifier(0.2F).build(); - public static final FoodComponent SMOKED_EGGPLANT = (new FoodComponent.Builder()).hunger(8).saturationModifier(0.6F).build(); - public static final FoodComponent SMOKED_TOMATO = (new FoodComponent.Builder()).hunger(4).saturationModifier(0.6F).build(); - public static final FoodComponent SMOKED_CORN = (new FoodComponent.Builder()).hunger(5).saturationModifier(0.7F).build(); - public static final FoodComponent SMOKED_WHITE_EGGPLANT = (new FoodComponent.Builder()).hunger(3).saturationModifier(0.5F).build(); - public static final FoodComponent WHITE_EGGPLANT = (new FoodComponent.Builder()).hunger(1).saturationModifier(0.1F).build(); - public static final FoodComponent CORN_COB = (new FoodComponent.Builder()).hunger(2).saturationModifier(0.4F).build(); - public static final FoodComponent SQUID = (new FoodComponent.Builder()).hunger(2).saturationModifier(0.2F).build(); - public static final FoodComponent COOKED_SQUID = (new FoodComponent.Builder()).hunger(6).saturationModifier(0.8F).build(); - public static final FoodComponent GLOW_SQUID = (new FoodComponent.Builder()).hunger(2).saturationModifier(0.2F) - .statusEffect(new StatusEffectInstance(StatusEffects.GLOWING, 40, 1), 1.0F).snack().build(); - public static final FoodComponent RAW_CALAMARI = (new FoodComponent.Builder()).hunger(1).saturationModifier(0.2F).build(); - public static final FoodComponent COOKED_CALAMARI = (new FoodComponent.Builder()).hunger(3).saturationModifier(0.5F).build(); + public static final FoodProperties AVOCADO = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build(); + public static final FoodProperties CUCUMBER = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.5F).build(); + public static final FoodProperties PICKLE = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.7F).build(); + public static final FoodProperties EGGPLANT = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.2F).build(); + public static final FoodProperties SMOKED_EGGPLANT = (new FoodProperties.Builder()).nutrition(8).saturationMod(0.6F).build(); + public static final FoodProperties SMOKED_TOMATO = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build(); + public static final FoodProperties SMOKED_CORN = (new FoodProperties.Builder()).nutrition(5).saturationMod(0.7F).build(); + public static final FoodProperties SMOKED_WHITE_EGGPLANT = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).build(); + public static final FoodProperties WHITE_EGGPLANT = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).build(); + public static final FoodProperties CORN_COB = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.4F).build(); + public static final FoodProperties SQUID = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.2F).build(); + public static final FoodProperties COOKED_SQUID = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.8F).build(); + public static final FoodProperties GLOW_SQUID = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.2F) + .effect(new MobEffectInstance(MobEffects.GLOWING, 40, 1), 1.0F).fast().build(); + public static final FoodProperties RAW_CALAMARI = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.2F).build(); + public static final FoodProperties COOKED_CALAMARI = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).build(); - public static final FoodComponent CUT_AVOCADO = (new FoodComponent.Builder()).hunger(2).saturationModifier(0.3F).snack().build(); - public static final FoodComponent CUT_CUCUMBER = (new FoodComponent.Builder()).hunger(1).saturationModifier(0.3F).snack().build(); - public static final FoodComponent CUT_PICKLE = (new FoodComponent.Builder()).hunger(2).saturationModifier(0.5F).snack().build(); - public static final FoodComponent CUT_EGGPLANT = (new FoodComponent.Builder()).hunger(1).saturationModifier(0.1F).snack().build(); - public static final FoodComponent SMOKED_CUT_EGGPLANT = (new FoodComponent.Builder()).hunger(4).saturationModifier(0.4F).snack().build(); + public static final FoodProperties CUT_AVOCADO = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).fast().build(); + public static final FoodProperties CUT_CUCUMBER = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.3F).fast().build(); + public static final FoodProperties CUT_PICKLE = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.5F).fast().build(); + public static final FoodProperties CUT_EGGPLANT = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).fast().build(); + public static final FoodProperties SMOKED_CUT_EGGPLANT = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.4F).fast().build(); //SUSHI - public static final FoodComponent MIDORI_ROLL = (new FoodComponent.Builder()).hunger(14).saturationModifier(0.7F).build(); - public static final FoodComponent MIDORI_ROLL_SLICE = (new FoodComponent.Builder()).hunger(7).saturationModifier(0.4F).snack().build(); - public static final FoodComponent EGG_ROLL = (new FoodComponent.Builder()).hunger(5).saturationModifier(0.5F).snack().build(); - public static final FoodComponent CHICKEN_ROLL = (new FoodComponent.Builder()).hunger(16).saturationModifier(0.8F).build(); - public static final FoodComponent CHICKEN_ROLL_SLICE = (new FoodComponent.Builder()).hunger(8).saturationModifier(0.6F).snack().build(); - public static final FoodComponent PUFFERFISH_ROLL = (new FoodComponent.Builder()).hunger(7).saturationModifier(0.6F) - .statusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 0), 1.0F) - .statusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 200, 1), 1.0F).snack().build(); - public static final FoodComponent TROPICAL_ROLL = (new FoodComponent.Builder()).hunger(7).saturationModifier(0.6F).snack().build(); - public static final FoodComponent RICE_BALL = (new FoodComponent.Builder()).hunger(3).saturationModifier(0.5F).snack().build(); - public static final FoodComponent CALAMARI_ROLL = (new FoodComponent.Builder()).hunger(7).saturationModifier(0.6F).snack().build(); + public static final FoodProperties MIDORI_ROLL = (new FoodProperties.Builder()).nutrition(14).saturationMod(0.7F).build(); + public static final FoodProperties MIDORI_ROLL_SLICE = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.4F).fast().build(); + public static final FoodProperties EGG_ROLL = (new FoodProperties.Builder()).nutrition(5).saturationMod(0.5F).fast().build(); + public static final FoodProperties CHICKEN_ROLL = (new FoodProperties.Builder()).nutrition(16).saturationMod(0.8F).build(); + public static final FoodProperties CHICKEN_ROLL_SLICE = (new FoodProperties.Builder()).nutrition(8).saturationMod(0.6F).fast().build(); + public static final FoodProperties PUFFERFISH_ROLL = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.6F) + .effect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0), 1.0F) + .effect(new MobEffectInstance(MobEffects.HUNGER, 200, 1), 1.0F).fast().build(); + public static final FoodProperties TROPICAL_ROLL = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.6F).fast().build(); + public static final FoodProperties RICE_BALL = (new FoodProperties.Builder()).nutrition(3).saturationMod(0.5F).fast().build(); + public static final FoodProperties CALAMARI_ROLL = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.6F).fast().build(); //MEALS - public static final FoodComponent CORN_DOUGH = (new FoodComponent.Builder()).hunger(1).saturationModifier(0.1F).build(); - public static final FoodComponent TORTILLA = (new FoodComponent.Builder()).hunger(4).saturationModifier(0.6F).build(); - public static final FoodComponent POPCORN = (new FoodComponent.Builder()).hunger(1).saturationModifier(0.2F).snack().build(); - public static final FoodComponent TORTILLA_CHIPS = (new FoodComponent.Builder()).hunger(2).saturationModifier(0.3F).snack().build(); - public static final FoodComponent ELOTE = (new FoodComponent.Builder()).hunger(6).saturationModifier(0.8F).build(); - public static final FoodComponent BEEF_BURRITO = (new FoodComponent.Builder()).hunger(14).saturationModifier(0.7F).build(); - public static final FoodComponent MUTTON_SANDWICH = (new FoodComponent.Builder()).hunger(10).saturationModifier(0.8F).build(); - public static final FoodComponent AVOCADO_TOAST = (new FoodComponent.Builder()).hunger(4).saturationModifier(0.5F).build(); - public static final FoodComponent CREAMED_CORN = (new FoodComponent.Builder()).hunger(6).saturationModifier(0.8F).build(); - public static final FoodComponent CHICKEN_TACO = (new FoodComponent.Builder()).hunger(10).saturationModifier(0.8F).build(); - public static final FoodComponent PORK_WRAP = (new FoodComponent.Builder()).hunger(10).saturationModifier(0.8F).build(); - public static final FoodComponent FISH_TACO = (new FoodComponent.Builder()).hunger(10).saturationModifier(0.8F).build(); - public static final FoodComponent HEARTY_SALAD = (new FoodComponent.Builder()).hunger(7).saturationModifier(0.7F) - .statusEffect(new StatusEffectInstance(EffectsRegistry.NOURISHMENT.get(), ConsumableItem.LONG_DURATION, 0), 1.0F).build(); - public static final FoodComponent FRIED_EGGPLANT_PASTA = (new FoodComponent.Builder()).hunger(12).saturationModifier(0.9F) - .statusEffect(new StatusEffectInstance(EffectsRegistry.NOURISHMENT.get(), ConsumableItem.LONG_DURATION, 0), 1.0F).build(); - public static final FoodComponent EGGPLANT_BURGER = (new FoodComponent.Builder()).hunger(12).saturationModifier(0.7F).build(); - public static final FoodComponent SPICY_CURRY = (new FoodComponent.Builder()).hunger(12).saturationModifier(1.3F) - .statusEffect(new StatusEffectInstance(EffectsRegistry.NOURISHMENT.get(), ConsumableItem.LONG_DURATION, 0), 1.0F).build(); + public static final FoodProperties CORN_DOUGH = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.1F).build(); + public static final FoodProperties TORTILLA = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.6F).build(); + public static final FoodProperties POPCORN = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.2F).fast().build(); + public static final FoodProperties TORTILLA_CHIPS = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).fast().build(); + public static final FoodProperties ELOTE = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.8F).build(); + public static final FoodProperties BEEF_BURRITO = (new FoodProperties.Builder()).nutrition(14).saturationMod(0.7F).build(); + public static final FoodProperties MUTTON_SANDWICH = (new FoodProperties.Builder()).nutrition(10).saturationMod(0.8F).build(); + public static final FoodProperties AVOCADO_TOAST = (new FoodProperties.Builder()).nutrition(4).saturationMod(0.5F).build(); + public static final FoodProperties CREAMED_CORN = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.8F).build(); + public static final FoodProperties CHICKEN_TACO = (new FoodProperties.Builder()).nutrition(10).saturationMod(0.8F).build(); + public static final FoodProperties PORK_WRAP = (new FoodProperties.Builder()).nutrition(10).saturationMod(0.8F).build(); + public static final FoodProperties FISH_TACO = (new FoodProperties.Builder()).nutrition(10).saturationMod(0.8F).build(); + public static final FoodProperties HEARTY_SALAD = (new FoodProperties.Builder()).nutrition(7).saturationMod(0.7F) + .effect(new MobEffectInstance(ModEffects.NOURISHMENT.get(), ConsumableItem.EAT_DURATION, 0), 1.0F).build(); + public static final FoodProperties FRIED_EGGPLANT_PASTA = (new FoodProperties.Builder()).nutrition(12).saturationMod(0.9F) + .effect(new MobEffectInstance(ModEffects.NOURISHMENT.get(), ConsumableItem.EAT_DURATION, 0), 1.0F).build(); + public static final FoodProperties EGGPLANT_BURGER = (new FoodProperties.Builder()).nutrition(12).saturationMod(0.7F).build(); + public static final FoodProperties SPICY_CURRY = (new FoodProperties.Builder()).nutrition(12).saturationMod(1.3F) + .effect(new MobEffectInstance(ModEffects.NOURISHMENT.get(), ConsumableItem.EAT_DURATION, 0), 1.0F).build(); } diff --git a/src/main/java/dev/sterner/culturaldelights/common/registry/CDObjects.java b/src/main/java/dev/sterner/culturaldelights/common/registry/CDObjects.java index 769bb93..66b3c05 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/registry/CDObjects.java +++ b/src/main/java/dev/sterner/culturaldelights/common/registry/CDObjects.java @@ -1,8 +1,6 @@ package dev.sterner.culturaldelights.common.registry; -import com.nhoryzon.mc.farmersdelight.FarmersDelightMod; -import com.nhoryzon.mc.farmersdelight.block.WildCropBlock; -import com.nhoryzon.mc.farmersdelight.registry.BlocksRegistry; +import dev.sterner.culturaldelights.CulturalDelights; import dev.sterner.culturaldelights.common.block.*; import dev.sterner.culturaldelights.common.utils.Constants; import dev.sterner.culturaldelights.common.world.AvocadoPitGenerator; @@ -12,24 +10,27 @@ import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.fabricmc.fabric.api.registry.FuelRegistry; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.block.PillarBlock; -import net.minecraft.block.SaplingBlock; -import net.minecraft.item.AliasedBlockItem; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.StewItem; -import net.minecraft.registry.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.util.Identifier; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.BowlFoodItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemNameBlockItem; +import net.minecraft.world.level.block.*; +import vectorwing.farmersdelight.FarmersDelight; +import vectorwing.farmersdelight.common.block.WildCropBlock; +import vectorwing.farmersdelight.common.registry.ModBlocks; +import vectorwing.farmersdelight.common.registry.ModCreativeTabs; +import vectorwing.farmersdelight.common.registry.ModItems; import java.util.LinkedHashMap; import java.util.Map; public class CDObjects { - public static final Map BLOCKS = new LinkedHashMap<>(); - public static final Map ITEMS = new LinkedHashMap<>(); + public static final Map BLOCKS = new LinkedHashMap<>(); + public static final Map ITEMS = new LinkedHashMap<>(); @@ -59,15 +60,15 @@ public class CDObjects { public static final Item TORTILLA = register("tortilla", new Item(settings().food(CDFoodComponents.TORTILLA))); public static final Item TORTILLA_CHIPS = register("tortilla_chips", new Item(settings().food(CDFoodComponents.TORTILLA_CHIPS))); public static final Item ELOTE = register("elote", new Item(settings().food(CDFoodComponents.ELOTE))); - public static final Item HEARTY_SALAD = register("hearty_salad", new StewItem(settings().food(CDFoodComponents.HEARTY_SALAD))); + public static final Item HEARTY_SALAD = register("hearty_salad", new BowlFoodItem(settings().food(CDFoodComponents.HEARTY_SALAD))); public static final Item BEEF_BURRITO = register("beef_burrito", new Item(settings().food(CDFoodComponents.BEEF_BURRITO))); public static final Item MUTTON_SANDWICH = register("mutton_sandwich", new Item(settings().food(CDFoodComponents.MUTTON_SANDWICH))); - public static final Item FRIED_EGGPLANT_PASTA = register("fried_eggplant_pasta", new StewItem(settings().food(CDFoodComponents.FRIED_EGGPLANT_PASTA))); + public static final Item FRIED_EGGPLANT_PASTA = register("fried_eggplant_pasta", new BowlFoodItem(settings().food(CDFoodComponents.FRIED_EGGPLANT_PASTA))); public static final Item EGGPLANT_BURGER = register("eggplant_burger", new Item(settings().food(CDFoodComponents.EGGPLANT_BURGER))); public static final Item AVOCADO_TOAST = register("avocado_toast", new Item(settings().food(CDFoodComponents.AVOCADO_TOAST))); - public static final Item CREAMED_CORN = register("creamed_corn", new StewItem(settings().food(CDFoodComponents.CREAMED_CORN))); + public static final Item CREAMED_CORN = register("creamed_corn", new BowlFoodItem(settings().food(CDFoodComponents.CREAMED_CORN))); public static final Item CHICKEN_TACO = register("chicken_taco", new Item(settings().food(CDFoodComponents.CHICKEN_TACO))); - public static final Item SPICY_CURRY = register("spicy_curry", new StewItem(settings().food(CDFoodComponents.SPICY_CURRY))); + public static final Item SPICY_CURRY = register("spicy_curry", new BowlFoodItem(settings().food(CDFoodComponents.SPICY_CURRY))); public static final Item PORK_WRAP = register("pork_wrap", new Item(settings().food(CDFoodComponents.PORK_WRAP))); public static final Item FISH_TACO = register("fish_taco", new Item(settings().food(CDFoodComponents.FISH_TACO))); public static final Item MIDORI_ROLL = register("midori_roll", new Item(settings().food(CDFoodComponents.MIDORI_ROLL))); @@ -84,13 +85,13 @@ public class CDObjects { public static final Block AVOCADO_BUNDLE = register("avocado_bundle", new Block(FabricBlockSettings.copy(Blocks.PUMPKIN)), settings(), true); - public static final Block WILD_CUCUMBERS = register("wild_cucumbers", new WildCropBlock(), settings(), true); - public static final Block WILD_CORN = register("wild_corn", new WildCropBlock(), settings(), true); - public static final Block WILD_EGGPLANTS = register("wild_eggplants", new WildCropBlock(), settings(), true); + public static final Block WILD_CUCUMBERS = register("wild_cucumbers", new WildCropBlock(MobEffects.DAMAGE_BOOST, 6, FabricBlockSettings.copyOf(Blocks.TALL_GRASS)), settings(), true); + public static final Block WILD_CORN = register("wild_corn", new WildCropBlock(MobEffects.DAMAGE_BOOST, 6, FabricBlockSettings.copyOf(Blocks.TALL_GRASS)), settings(), true); + public static final Block WILD_EGGPLANTS = register("wild_eggplants", new WildCropBlock(MobEffects.DAMAGE_BOOST, 6, FabricBlockSettings.copyOf(Blocks.TALL_GRASS)), settings(), true); - public static final Block AVOCADO_LOG = register("avocado_log", new PillarBlock(FabricBlockSettings.copy(Blocks.JUNGLE_LOG)), settings(), true); - public static final Block AVOCADO_WOOD = register("avocado_wood", new PillarBlock(FabricBlockSettings.copy(Blocks.JUNGLE_WOOD)), settings(), true); - public static final Block AVOCADO_LEAVES = register("avocado_leaves", new PillarBlock(FabricBlockSettings.copy(Blocks.JUNGLE_LEAVES)), settings(), true); + public static final Block AVOCADO_LOG = register("avocado_log", new RotatedPillarBlock(FabricBlockSettings.copy(Blocks.JUNGLE_LOG)), settings(), true); + public static final Block AVOCADO_WOOD = register("avocado_wood", new RotatedPillarBlock(FabricBlockSettings.copy(Blocks.JUNGLE_WOOD)), settings(), true); + public static final Block AVOCADO_LEAVES = register("avocado_leaves", new RotatedPillarBlock(FabricBlockSettings.copy(Blocks.JUNGLE_LEAVES)), settings(), true); public static final Block AVOCADO_SAPLING = register("avocado_sapling", new SaplingBlock(new AvocadoSaplingGenerator(), FabricBlockSettings.copy(Blocks.OAK_SAPLING)), settings(), true); @@ -102,21 +103,21 @@ public class CDObjects { public static final Block AVOCADO_PIT = register("avocado_pit", new AvocadoPitBlock(new AvocadoPitGenerator(), FabricBlockSettings.copy(Blocks.OAK_SAPLING)), settings(), true); - public static final Block AVOCADO_CRATE = register("avocado_crate", new Block(FabricBlockSettings.copy(BlocksRegistry.CARROT_CRATE.get())), settings(), true); - public static final Block CUCUMBER_CRATE = register("cucumber_crate", new Block(FabricBlockSettings.copy(BlocksRegistry.CARROT_CRATE.get())), settings(), true); - public static final Block PICKLE_CRATE = register("pickle_crate", new Block(FabricBlockSettings.copy(BlocksRegistry.CARROT_CRATE.get())), settings(), true); - public static final Block CORN_COB_CRATE = register("corn_cob_crate", new Block(FabricBlockSettings.copy(BlocksRegistry.CARROT_CRATE.get())), settings(), true); - public static final Block EGGPLANT_CRATE = register("eggplant_crate", new Block(FabricBlockSettings.copy(BlocksRegistry.CARROT_CRATE.get())), settings(), true); + public static final Block AVOCADO_CRATE = register("avocado_crate", new Block(FabricBlockSettings.copy(Blocks.OAK_PLANKS).strength(2.0F, 3.0F).sound(SoundType.WOOD)), settings(), true); + public static final Block CUCUMBER_CRATE = register("cucumber_crate", new Block(FabricBlockSettings.copy(Blocks.OAK_PLANKS).strength(2.0F, 3.0F).sound(SoundType.WOOD)), settings(), true); + public static final Block PICKLE_CRATE = register("pickle_crate", new Block(FabricBlockSettings.copy(Blocks.OAK_PLANKS).strength(2.0F, 3.0F).sound(SoundType.WOOD)), settings(), true); + public static final Block CORN_COB_CRATE = register("corn_cob_crate", new Block(FabricBlockSettings.copy(Blocks.OAK_PLANKS).strength(2.0F, 3.0F).sound(SoundType.WOOD)), settings(), true); + public static final Block EGGPLANT_CRATE = register("eggplant_crate", new Block(FabricBlockSettings.copy(Blocks.OAK_PLANKS).strength(2.0F, 3.0F).sound(SoundType.WOOD)), settings(), true); public static final Block EXOTIC_ROLL_MEDLEY = register("exotic_roll_medley", new ExoticRollMedleyBlock(), settings(), true); - public static final Item CUCUMBER_SEEDS = register("cucumber_seeds", new AliasedBlockItem(CUCUMBER_CROP ,settings())); - public static final Item CORN_KERNELS = register("corn_kernels", new AliasedBlockItem(CORN_CROP, settings())); - public static final Item EGGPLANT_SEEDS = register("eggplant_seeds", new AliasedBlockItem(EGGPLANT_CROP, settings())); + public static final Item CUCUMBER_SEEDS = register("cucumber_seeds", new ItemNameBlockItem(CUCUMBER_CROP ,settings())); + public static final Item CORN_KERNELS = register("corn_kernels", new ItemNameBlockItem(CORN_CROP, settings())); + public static final Item EGGPLANT_SEEDS = register("eggplant_seeds", new ItemNameBlockItem(EGGPLANT_CROP, settings())); - private static Item.Settings settings() { - return new Item.Settings(); + private static Item.Properties settings() { + return new Item.Properties(); } private static T register(String name, T item) { @@ -124,7 +125,7 @@ private static T register(String name, T item) { return item; } - private static T register(String name, T block, Item.Settings settings, boolean createItem) { + private static T register(String name, T block, Item.Properties settings, boolean createItem) { BLOCKS.put(block, Constants.id(name)); if (createItem) { ITEMS.put(new BlockItem(block, settings), BLOCKS.get(block)); @@ -133,9 +134,9 @@ private static T register(String name, T block, Item.Settings } public static void init() { - 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)); + BLOCKS.keySet().forEach(block -> Registry.register(BuiltInRegistries.BLOCK, BLOCKS.get(block), block)); + ITEMS.keySet().forEach(item -> Registry.register(BuiltInRegistries.ITEM, ITEMS.get(item), item)); + ItemGroupEvents.modifyEntriesEvent(CulturalDelights.ITEM_GROUP).register(entries -> ITEMS.keySet().forEach(entries::accept)); FlammableBlockRegistry flammableRegistry = FlammableBlockRegistry.getDefaultInstance(); diff --git a/src/main/java/dev/sterner/culturaldelights/common/registry/CDTags.java b/src/main/java/dev/sterner/culturaldelights/common/registry/CDTags.java index a04b1e7..7e6e07d 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/registry/CDTags.java +++ b/src/main/java/dev/sterner/culturaldelights/common/registry/CDTags.java @@ -1,10 +1,10 @@ package dev.sterner.culturaldelights.common.registry; -import net.minecraft.item.Item; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.Identifier; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; public class CDTags { - public static final TagKey CORN = TagKey.of(RegistryKeys.ITEM, new Identifier("c", "corn")); + public static final TagKey CORN = TagKey.create(Registries.ITEM, new ResourceLocation("c", "corn")); } diff --git a/src/main/java/dev/sterner/culturaldelights/common/registry/CDWorldGenerators.java b/src/main/java/dev/sterner/culturaldelights/common/registry/CDWorldGenerators.java index f4c89bb..d152fb7 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/registry/CDWorldGenerators.java +++ b/src/main/java/dev/sterner/culturaldelights/common/registry/CDWorldGenerators.java @@ -3,19 +3,23 @@ import net.fabricmc.fabric.api.biome.v1.BiomeModifications; import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags; -import net.minecraft.registry.RegistryKey; -import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.feature.*; +import net.minecraft.data.worldgen.features.FeatureUtils; +import net.minecraft.data.worldgen.placement.PlacementUtils; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; +import vectorwing.farmersdelight.FarmersDelight; public class CDWorldGenerators { - public static final RegistryKey> AVOCADO = ConfiguredFeatures.of("culturaldelights:avocado"); - public static final RegistryKey TREE_AVOCADO = PlacedFeatures.of("culturaldelights:tree_avocado"); + public static final ResourceKey> AVOCADO = FeatureUtils.createKey("culturaldelights:avocado"); + public static final ResourceKey TREE_AVOCADO = PlacementUtils.createKey("culturaldelights:tree_avocado"); - public static final RegistryKey> AVOCADO_PIT = ConfiguredFeatures.of("culturaldelights:avocado_pit"); - public static final RegistryKey TREE_AVOCADO_PIT = PlacedFeatures.of("culturaldelights:tree_avocado_pit"); + public static final ResourceKey> AVOCADO_PIT = FeatureUtils.createKey("culturaldelights:avocado_pit"); + public static final ResourceKey TREE_AVOCADO_PIT = PlacementUtils.createKey("culturaldelights:tree_avocado_pit"); public static void init() { - BiomeModifications.addFeature(BiomeSelectors.tag(ConventionalBiomeTags.JUNGLE), GenerationStep.Feature.VEGETAL_DECORATION, TREE_AVOCADO); + BiomeModifications.addFeature(BiomeSelectors.tag(ConventionalBiomeTags.JUNGLE), GenerationStep.Decoration.VEGETAL_DECORATION, TREE_AVOCADO); } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/utils/Constants.java b/src/main/java/dev/sterner/culturaldelights/common/utils/Constants.java index 5ed3c1c..d0accc7 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/utils/Constants.java +++ b/src/main/java/dev/sterner/culturaldelights/common/utils/Constants.java @@ -1,11 +1,11 @@ package dev.sterner.culturaldelights.common.utils; -import net.minecraft.util.Identifier; +import net.minecraft.resources.ResourceLocation; public class Constants { public static final String MOD_ID = "culturaldelights"; - public static Identifier id(String string){ - return new Identifier(MOD_ID, string); + public static ResourceLocation id(String string){ + return new ResourceLocation(MOD_ID, string); } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoBundleTreeDecorator.java b/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoBundleTreeDecorator.java index 704d16c..a3a885f 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoBundleTreeDecorator.java +++ b/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoBundleTreeDecorator.java @@ -4,16 +4,15 @@ import dev.sterner.culturaldelights.CulturalDelights; import dev.sterner.culturaldelights.common.registry.CDObjects; import dev.sterner.culturaldelights.common.registry.CDWorldGenerators; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.random.Random; -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.Optional; import java.util.stream.Collectors; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; public class AvocadoBundleTreeDecorator extends TreeDecorator { @@ -25,24 +24,24 @@ public AvocadoBundleTreeDecorator(float probability) { } @Override - protected TreeDecoratorType getType() { + protected TreeDecoratorType type() { return CulturalDelights.AVOCADO_BUNDLE_TREE_DECORATOR_TYPE; } @Override - public void generate(Generator generator) { - Random random = generator.getRandom(); + public void place(Context generator) { + RandomSource random = generator.random(); if ((random.nextFloat() < this.probability)) { - List list = generator.getLeavesPositions(); + List list = generator.leaves(); if (!list.isEmpty()) { - List list3 = list.stream().filter((pos) -> generator.isAir(pos.down()) && generator.isAir(pos.down(2)) && generator.isAir(pos.down(3))).collect(Collectors.toList()); + List list3 = list.stream().filter((pos) -> generator.isAir(pos.below()) && generator.isAir(pos.below(2)) && generator.isAir(pos.below(3))).collect(Collectors.toList()); if (!list3.isEmpty()) { - for(Direction direction : Direction.Type.HORIZONTAL) { + for(Direction direction : Direction.Plane.HORIZONTAL) { if (random.nextFloat() <= 0.25F) { Collections.shuffle(list3); Optional optional = list3.stream().findFirst(); if (optional.isPresent()) { - generator.replace(optional.get().down(), CDObjects.AVOCADO_BUNDLE.getDefaultState()); + generator.setBlock(optional.get().below(), CDObjects.AVOCADO_BUNDLE.defaultBlockState()); } } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoPitGenerator.java b/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoPitGenerator.java index 8209698..f4b30a2 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoPitGenerator.java +++ b/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoPitGenerator.java @@ -1,17 +1,17 @@ package dev.sterner.culturaldelights.common.world; 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.world.gen.feature.ConfiguredFeature; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.grower.AbstractTreeGrower; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import org.jetbrains.annotations.Nullable; -public class AvocadoPitGenerator extends SaplingGenerator { +public class AvocadoPitGenerator extends AbstractTreeGrower { @Nullable @Override - protected RegistryKey> getTreeFeature(Random random, boolean bees) { + protected ResourceKey> getConfiguredFeature(RandomSource random, boolean bees) { return CDWorldGenerators.AVOCADO_PIT; } } diff --git a/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoSaplingGenerator.java b/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoSaplingGenerator.java index a7deca8..68fb26b 100644 --- a/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoSaplingGenerator.java +++ b/src/main/java/dev/sterner/culturaldelights/common/world/AvocadoSaplingGenerator.java @@ -1,17 +1,17 @@ package dev.sterner.culturaldelights.common.world; 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.world.gen.feature.ConfiguredFeature; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.block.grower.AbstractTreeGrower; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import org.jetbrains.annotations.Nullable; -public class AvocadoSaplingGenerator extends SaplingGenerator { +public class AvocadoSaplingGenerator extends AbstractTreeGrower { @Nullable @Override - protected RegistryKey> getTreeFeature(Random random, boolean bees) { + protected ResourceKey> getConfiguredFeature(RandomSource random, boolean bees) { return CDWorldGenerators.AVOCADO; } } diff --git a/src/main/java/dev/sterner/culturaldelights/mixin/SimpleBlockStateProviderAccessor.java b/src/main/java/dev/sterner/culturaldelights/mixin/SimpleBlockStateProviderAccessor.java index c450de4..d4e9eeb 100644 --- a/src/main/java/dev/sterner/culturaldelights/mixin/SimpleBlockStateProviderAccessor.java +++ b/src/main/java/dev/sterner/culturaldelights/mixin/SimpleBlockStateProviderAccessor.java @@ -1,14 +1,14 @@ package dev.sterner.culturaldelights.mixin; -import net.minecraft.block.BlockState; -import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; -@Mixin(SimpleBlockStateProvider.class) +@Mixin(SimpleStateProvider.class) public interface SimpleBlockStateProviderAccessor { @Invoker(value = "") - static SimpleBlockStateProvider callInit(BlockState state) { + static SimpleStateProvider callInit(BlockState state) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/dev/sterner/culturaldelights/mixin/TreeDecoratorTypeInvoker.java b/src/main/java/dev/sterner/culturaldelights/mixin/TreeDecoratorTypeInvoker.java index 73b7765..9cb8388 100644 --- a/src/main/java/dev/sterner/culturaldelights/mixin/TreeDecoratorTypeInvoker.java +++ b/src/main/java/dev/sterner/culturaldelights/mixin/TreeDecoratorTypeInvoker.java @@ -1,8 +1,8 @@ package dev.sterner.culturaldelights.mixin; import com.mojang.serialization.Codec; -import net.minecraft.world.gen.treedecorator.TreeDecorator; -import net.minecraft.world.gen.treedecorator.TreeDecoratorType; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator; +import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; diff --git a/src/main/resources/assets/culturaldelights/lang/en_us.json b/src/main/resources/assets/culturaldelights/lang/en_us.json index addcd78..bfefac6 100644 --- a/src/main/resources/assets/culturaldelights/lang/en_us.json +++ b/src/main/resources/assets/culturaldelights/lang/en_us.json @@ -1,4 +1,8 @@ { + "itemGroup.culturaldelights": "Cultural Delight", + + "culturaldelights.group.main": "Cultural Delight", + "item.culturaldelights.cucumber_seeds": "Cucumber Seeds", "item.culturaldelights.eggplant_seeds": "Eggplant Seeds", "item.culturaldelights.corn_kernels": "Corn Kernels", diff --git a/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_corn.json b/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_corn.json index e148747..28faee9 100644 --- a/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_corn.json +++ b/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_corn.json @@ -16,7 +16,8 @@ "type": "minecraft:biome" }, { - "type": "farmersdelight:biome_is_overworld" + "type": "farmersdelight:biome_tag", + "tag": "minecraft:is_overworld" } ] } \ No newline at end of file diff --git a/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_cucumbers.json b/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_cucumbers.json index cb88e69..79357f2 100644 --- a/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_cucumbers.json +++ b/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_cucumbers.json @@ -16,7 +16,8 @@ "type": "minecraft:biome" }, { - "type": "farmersdelight:biome_is_overworld" + "type": "farmersdelight:biome_tag", + "tag": "minecraft:is_overworld" } ] } \ No newline at end of file diff --git a/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_eggplants.json b/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_eggplants.json index 1b3cb46..7890ca0 100644 --- a/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_eggplants.json +++ b/src/main/resources/data/culturaldelights/worldgen/placed_feature/patch_wild_eggplants.json @@ -16,7 +16,8 @@ "type": "minecraft:biome" }, { - "type": "farmersdelight:biome_is_overworld" + "type": "farmersdelight:biome_tag", + "tag": "minecraft:is_overworld" } ] } \ No newline at end of file