diff --git a/CHANGELOG.md b/CHANGELOG.md index 37e846ead..51b9270e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ * Reinforced fix for drills breaking in certain circumstances. * Fix for drill not dropping block contents for certain mods. * Fixed the Farmer not making sounds when planting. +* Overhauled AA crop drop tables to be more in line with 1.12 numbers. +* Re-added native right click harvesting to AA crops. # 1.3.10+mc1.21.1 * Fixed Fluid placer not being harvestable. diff --git a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d index db93f64b8..650be86be 100644 --- a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d +++ b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d @@ -1,4 +1,4 @@ -// 1.21.1 2024-11-30T14:28:45.6232631 Loot Tables +// 1.21.1 2024-12-01T15:57:03.7596243 Loot Tables ef11aa79a2f96a47250f46811f8491fd34d627f9 data/actuallyadditions/loot_table/blocks/atomic_reconstructor.json e15c868b26b669c30365bfb93e7d9274e07df16d data/actuallyadditions/loot_table/blocks/battery_box.json 745d64af3b0203a138f9eca7de21ed4988b35c95 data/actuallyadditions/loot_table/blocks/bio_reactor.json @@ -16,14 +16,14 @@ c49b30e8d893f67866d0a47cf8682502468e9864 data/actuallyadditions/loot_table/block e4f42700948abba5991c961ee5b2c0ab6839d437 data/actuallyadditions/loot_table/blocks/black_quartz_stair.json 0d7396ec2071fcdd2df045b20c9b5a5a2692cc80 data/actuallyadditions/loot_table/blocks/black_quartz_wall.json 721df65869084716c4e8dded76f9a691dbf6f165 data/actuallyadditions/loot_table/blocks/breaker.json -6543b2f46d8c4e81c3b3efb8aff3cb3216c4acda data/actuallyadditions/loot_table/blocks/canola.json +c40d97a5b17a4b94c343ff298b61db21f9d2b3ce data/actuallyadditions/loot_table/blocks/canola.json 363f70b76c9ceea3bfbe62656523acc52178803c data/actuallyadditions/loot_table/blocks/canola_press.json 37edff6a4dd2975276e73be28cf2490bd91700a9 data/actuallyadditions/loot_table/blocks/chiseled_black_quartz_block.json 967afd8eaa3169037502ac72985ddba7b3670087 data/actuallyadditions/loot_table/blocks/chiseled_black_quartz_slab.json b598ece027ef00e9ed0457a7f9542ebe8b89538c data/actuallyadditions/loot_table/blocks/chiseled_black_quartz_stair.json 584c40d2867ad0376823c1a4f37f1d901721ae4f data/actuallyadditions/loot_table/blocks/chiseled_black_quartz_wall.json 7d23a0c906af2f6b3fecaba91f776385db5a50bc data/actuallyadditions/loot_table/blocks/coal_generator.json -afab93747299dba6783292e5949ea7e0cd5d5b13 data/actuallyadditions/loot_table/blocks/coffee.json +be0627c013316cc2b7729e7fdbf2778ca10e7ea2 data/actuallyadditions/loot_table/blocks/coffee.json 3d8c1c296df957964e41065f4d2c0814eee29282 data/actuallyadditions/loot_table/blocks/coffee_machine.json 7c7a4028f6fe02446d1557f72ad494ab363a8409 data/actuallyadditions/loot_table/blocks/crusher.json cbd5456165eaf299685aab50dc3bce38d99a1cf8 data/actuallyadditions/loot_table/blocks/crusher_double.json @@ -57,7 +57,7 @@ d4eeacb9036343a75ba390acb912c294db3bbdb6 data/actuallyadditions/loot_table/block 4f60395b41acdd21a5e8e8592fb6141a230ffdde data/actuallyadditions/loot_table/blocks/feeder.json 25ef94eb9b94c7707d8ae5df2b4e9f52378ee6f7 data/actuallyadditions/loot_table/blocks/fermenting_barrel.json c02726c670fccfa57d403272b9c96e3ad9cf4cc9 data/actuallyadditions/loot_table/blocks/firework_box.json -4bd34fdd919b12992acbfe81b6aa79cadb7f2774 data/actuallyadditions/loot_table/blocks/flax.json +af51485c31b2fe83b3aa6a43cfeceeb3487fe94f data/actuallyadditions/loot_table/blocks/flax.json 306b4cb3da4065ba83240b24e0e6c3a067b99d73 data/actuallyadditions/loot_table/blocks/fluid_collector.json 1216c21d9f3805de5988ba3c65997b3b78d70abc data/actuallyadditions/loot_table/blocks/fluid_placer.json 8f15a45992ecb1be2ce326702c204c190a0aad14 data/actuallyadditions/loot_table/blocks/greenhouse_glass.json @@ -108,7 +108,7 @@ e030d31981f02c0ed25d08fcaf8d8e7c89016247 data/actuallyadditions/loot_table/block 8f51bc016a6797bfdf81973a21509e14bd47f245 data/actuallyadditions/loot_table/blocks/ranged_collector.json 0cff315b834058c90a7f26425565e086fb833305 data/actuallyadditions/loot_table/blocks/restonia_crystal_block.json d1c8ca548cefbb4f33d4763606a7e0c909319717 data/actuallyadditions/loot_table/blocks/restonia_crystal_cluster.json -247ec0004cfa51a635f305aed06f6a8f2d0cd0c4 data/actuallyadditions/loot_table/blocks/rice.json +21c7f764086ad1f4add6853f182e16324c498fa2 data/actuallyadditions/loot_table/blocks/rice.json d9337537495eb5b2d5288c6df81125594522e5b7 data/actuallyadditions/loot_table/blocks/shock_suppressor.json a534077796cbfbcf0c66f986db3abd037c2d14d6 data/actuallyadditions/loot_table/blocks/smooth_black_quartz_block.json 5018c69cc3e6c87b0080ed3ea914e47744088ab7 data/actuallyadditions/loot_table/blocks/smooth_black_quartz_slab.json diff --git a/src/generated/resources/data/actuallyadditions/loot_table/blocks/canola.json b/src/generated/resources/data/actuallyadditions/loot_table/blocks/canola.json index e502ca0d5..d1d306e09 100644 --- a/src/generated/resources/data/actuallyadditions/loot_table/blocks/canola.json +++ b/src/generated/resources/data/actuallyadditions/loot_table/blocks/canola.json @@ -23,6 +23,25 @@ } } ], + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 5.0, + "min": 2.0 + }, + "function": "minecraft:set_count" + }, + { + "enchantment": "minecraft:fortune", + "formula": "minecraft:uniform_bonus_count", + "function": "minecraft:apply_bonus", + "parameters": { + "bonusMultiplier": 1 + } + } + ], "name": "actuallyadditions:canola" }, { @@ -36,26 +55,34 @@ }, { "bonus_rolls": 0.0, - "conditions": [ - { - "block": "actuallyadditions:canola", - "condition": "minecraft:block_state_property", - "properties": { - "age": "7" - } - } - ], "entries": [ { "type": "minecraft:item", + "conditions": [ + { + "block": "actuallyadditions:canola", + "condition": "minecraft:block_state_property", + "properties": { + "age": "7" + } + } + ], "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 2.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + }, { "enchantment": "minecraft:fortune", - "formula": "minecraft:binomial_with_bonus_count", + "formula": "minecraft:uniform_bonus_count", "function": "minecraft:apply_bonus", "parameters": { - "extra": 3, - "probability": 0.5714286 + "bonusMultiplier": 1 } } ], diff --git a/src/generated/resources/data/actuallyadditions/loot_table/blocks/coffee.json b/src/generated/resources/data/actuallyadditions/loot_table/blocks/coffee.json index b5f14e0e1..e9355092b 100644 --- a/src/generated/resources/data/actuallyadditions/loot_table/blocks/coffee.json +++ b/src/generated/resources/data/actuallyadditions/loot_table/blocks/coffee.json @@ -23,6 +23,25 @@ } } ], + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 4.0, + "min": 2.0 + }, + "function": "minecraft:set_count" + }, + { + "enchantment": "minecraft:fortune", + "formula": "minecraft:uniform_bonus_count", + "function": "minecraft:apply_bonus", + "parameters": { + "bonusMultiplier": 1 + } + } + ], "name": "actuallyadditions:coffee_beans" }, { @@ -36,26 +55,34 @@ }, { "bonus_rolls": 0.0, - "conditions": [ - { - "block": "actuallyadditions:coffee", - "condition": "minecraft:block_state_property", - "properties": { - "age": "7" - } - } - ], "entries": [ { "type": "minecraft:item", + "conditions": [ + { + "block": "actuallyadditions:coffee", + "condition": "minecraft:block_state_property", + "properties": { + "age": "7" + } + } + ], "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 2.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + }, { "enchantment": "minecraft:fortune", - "formula": "minecraft:binomial_with_bonus_count", + "formula": "minecraft:uniform_bonus_count", "function": "minecraft:apply_bonus", "parameters": { - "extra": 3, - "probability": 0.5714286 + "bonusMultiplier": 1 } } ], diff --git a/src/generated/resources/data/actuallyadditions/loot_table/blocks/flax.json b/src/generated/resources/data/actuallyadditions/loot_table/blocks/flax.json index b138746e8..b5807b8ce 100644 --- a/src/generated/resources/data/actuallyadditions/loot_table/blocks/flax.json +++ b/src/generated/resources/data/actuallyadditions/loot_table/blocks/flax.json @@ -23,6 +23,25 @@ } } ], + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 6.0, + "min": 2.0 + }, + "function": "minecraft:set_count" + }, + { + "enchantment": "minecraft:fortune", + "formula": "minecraft:uniform_bonus_count", + "function": "minecraft:apply_bonus", + "parameters": { + "bonusMultiplier": 1 + } + } + ], "name": "minecraft:string" }, { @@ -36,26 +55,34 @@ }, { "bonus_rolls": 0.0, - "conditions": [ - { - "block": "actuallyadditions:flax", - "condition": "minecraft:block_state_property", - "properties": { - "age": "7" - } - } - ], "entries": [ { "type": "minecraft:item", + "conditions": [ + { + "block": "actuallyadditions:flax", + "condition": "minecraft:block_state_property", + "properties": { + "age": "7" + } + } + ], "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 2.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + }, { "enchantment": "minecraft:fortune", - "formula": "minecraft:binomial_with_bonus_count", + "formula": "minecraft:uniform_bonus_count", "function": "minecraft:apply_bonus", "parameters": { - "extra": 3, - "probability": 0.5714286 + "bonusMultiplier": 1 } } ], diff --git a/src/generated/resources/data/actuallyadditions/loot_table/blocks/rice.json b/src/generated/resources/data/actuallyadditions/loot_table/blocks/rice.json index f9c6a2600..649c19333 100644 --- a/src/generated/resources/data/actuallyadditions/loot_table/blocks/rice.json +++ b/src/generated/resources/data/actuallyadditions/loot_table/blocks/rice.json @@ -23,6 +23,25 @@ } } ], + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 3.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + }, + { + "enchantment": "minecraft:fortune", + "formula": "minecraft:uniform_bonus_count", + "function": "minecraft:apply_bonus", + "parameters": { + "bonusMultiplier": 1 + } + } + ], "name": "actuallyadditions:rice" }, { @@ -36,26 +55,34 @@ }, { "bonus_rolls": 0.0, - "conditions": [ - { - "block": "actuallyadditions:rice", - "condition": "minecraft:block_state_property", - "properties": { - "age": "7" - } - } - ], "entries": [ { "type": "minecraft:item", + "conditions": [ + { + "block": "actuallyadditions:rice", + "condition": "minecraft:block_state_property", + "properties": { + "age": "7" + } + } + ], "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 2.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + }, { "enchantment": "minecraft:fortune", - "formula": "minecraft:binomial_with_bonus_count", + "formula": "minecraft:uniform_bonus_count", "function": "minecraft:apply_bonus", "parameters": { - "extra": 3, - "probability": 0.5714286 + "bonusMultiplier": 1 } } ], diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/LootTableGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/LootTableGenerator.java index bbcaa0345..a0a6cb721 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/LootTableGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/LootTableGenerator.java @@ -11,6 +11,7 @@ import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; import net.minecraft.advancements.critereon.StatePropertiesPredicate; import net.minecraft.core.HolderLookup; import net.minecraft.core.WritableRegistry; +import net.minecraft.core.registries.Registries; import net.minecraft.data.PackOutput; import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.data.loot.LootTableProvider; @@ -20,6 +21,7 @@ import net.minecraft.util.ProblemReporter; import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; +import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.CropBlock; import net.minecraft.world.level.storage.loot.LootPool; @@ -27,6 +29,7 @@ import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.ValidationContext; import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.entries.TagEntry; +import net.minecraft.world.level.storage.loot.functions.ApplyBonusCount; import net.minecraft.world.level.storage.loot.functions.CopyComponentsFunction; import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; @@ -200,16 +203,28 @@ public class LootTableGenerator extends LootTableProvider { add(ActuallyBlocks.BLACK_QUARTZ_ORE.get(), createOreDrop(ActuallyBlocks.BLACK_QUARTZ_ORE.getBlock(), ActuallyItems.BLACK_QUARTZ.get())); - addCrop(ActuallyBlocks.CANOLA, ActuallyItems.CANOLA, ActuallyItems.CANOLA_SEEDS); - addCrop(ActuallyBlocks.RICE, ActuallyItems.RICE, ActuallyItems.RICE_SEEDS); - addCrop(ActuallyBlocks.FLAX, () -> Items.STRING, ActuallyItems.FLAX_SEEDS); - addCrop(ActuallyBlocks.COFFEE, ActuallyItems.COFFEE_BEANS, ActuallyItems.COFFEE_BEANS); + addCrop(ActuallyBlocks.CANOLA, ActuallyItems.CANOLA, 2, 3, ActuallyItems.CANOLA_SEEDS); + addCrop(ActuallyBlocks.RICE, ActuallyItems.RICE, 1, 2, ActuallyItems.RICE_SEEDS); + addCrop(ActuallyBlocks.FLAX, () -> Items.STRING, 2, 4, ActuallyItems.FLAX_SEEDS); + addCrop(ActuallyBlocks.COFFEE, ActuallyItems.COFFEE_BEANS, 2, 2, ActuallyItems.COFFEE_BEANS); } - private void addCrop(Supplier block, Supplier item, Supplier seed) { - add(block.get(), createCropDrops(block.get(), item.get(), seed.get(), - LootItemBlockStatePropertyCondition.hasBlockStateProperties(block.get()).setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(CropBlock.AGE, 7)))); + private void addCrop(Supplier block, Supplier item, int min, int bonus, Supplier seed) { + var registry = registries.lookupOrThrow(Registries.ENCHANTMENT); + LootItemBlockStatePropertyCondition.Builder cropCondition = LootItemBlockStatePropertyCondition.hasBlockStateProperties(block.get()).setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(CropBlock.AGE, 7)); + var table = LootTable.lootTable() + .withPool(LootPool.lootPool().add(LootItem + .lootTableItem(item.get()).when(cropCondition) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(min, min + bonus))) + .apply(ApplyBonusCount.addUniformBonusCount(registry.getOrThrow(Enchantments.FORTUNE))) + .otherwise(LootItem.lootTableItem(seed.get()))) + ) + .withPool(LootPool.lootPool().add(LootItem.lootTableItem(seed.get()).when(cropCondition) + .apply(SetItemCountFunction.setCount(UniformGenerator.between(1.0F, 2.0F))) + .apply(ApplyBonusCount.addUniformBonusCount(registry.getOrThrow(Enchantments.FORTUNE))))); + + add(block.get(), applyExplosionDecay(block.get(), table)); } private void dropComponents(Supplier blockSupplier, Consumer lootFunctionProvider) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/AACrops.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/AACrops.java index b826e63cd..de02106c1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/AACrops.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/AACrops.java @@ -1,19 +1,28 @@ package de.ellpeck.actuallyadditions.mod.blocks.base; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.WorldGenRegion; import net.minecraft.tags.BlockTags; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.ItemInteractionResult; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; 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.BooleanProperty; +import net.minecraft.world.phys.BlockHitResult; +import net.neoforged.neoforge.items.ItemHandlerHelper; import javax.annotation.Nonnull; +import java.util.List; import java.util.function.Supplier; public class AACrops extends CropBlock { @@ -52,4 +61,32 @@ public class AACrops extends CropBlock { protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(AGE, PERSISTENT); } + + @Nonnull + @Override + protected ItemInteractionResult useItemOn(@Nonnull ItemStack pStack, @Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull BlockHitResult pHitResult) { + if (this.getAge(state) < 7) { + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + } + + if (!world.isClientSide) { + List drops = Block.getDrops(state, (ServerLevel) world, pos, null, player, pStack); + boolean deductedSeedSize = false; + for (ItemStack drop : drops) { + if (!drop.isEmpty()) { + if (drop.getItem() == this.itemSupplier.get() && !deductedSeedSize) { + drop.shrink(1); + deductedSeedSize = true; + } + if (!drop.isEmpty()) { + ItemHandlerHelper.giveItemToPlayer(player, drop); + } + } + } + + world.setBlockAndUpdate(pos, this.defaultBlockState().setValue(AGE, 0)); + } + + return super.useItemOn(pStack, state, world, pos, player, hand, pHitResult); + } }