From 6e67d3f422a1041f1ae96af1c25f14fd42238810 Mon Sep 17 00:00:00 2001 From: jottyfan Date: Tue, 3 Nov 2020 22:59:35 +0100 Subject: [PATCH] 1.16.4.0 --- gradle.properties | 10 +++--- .../blocks/BlockCottonplant.java | 33 ++++++++++++++++--- .../recipes/string_from_cotton.json | 13 +++++--- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index 7c542d5..31f6efc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.16.3 - yarn_mappings=1.16.3+build.1 - loader_version=0.9.3+build.207 + minecraft_version=1.16.4 + yarn_mappings=1.16.4+build.3 + loader_version=0.10.6+build.214 # Mod Properties - mod_version = 1.16.3.9 + mod_version = 1.16.4.0 maven_group = de.jottyfan.minecraft archives_base_name = quickiefabric # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.20.2+build.402-1.16 + fabric_version=0.25.1+build.416-1.16 diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/blocks/BlockCottonplant.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/blocks/BlockCottonplant.java index 1a57f17..95cbae2 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/blocks/BlockCottonplant.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/blocks/BlockCottonplant.java @@ -1,5 +1,6 @@ package de.jottyfan.minecraft.quickiefabric.blocks; +import java.util.List; import java.util.Random; import de.jottyfan.minecraft.quickiefabric.items.QuickieItems; @@ -10,6 +11,7 @@ import net.minecraft.block.CropBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; +import net.minecraft.loot.context.LootContext.Builder; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.ItemScatterer; @@ -24,6 +26,32 @@ public class BlockCottonplant extends CropBlock { super(FabricBlockSettings.copy(Blocks.WHEAT)); } + @Override + public List getDroppedStacks(BlockState state, Builder builder) { + DefaultedList list = DefaultedList.of(); + list.add(new ItemStack(getSeedsItem())); // the one from the seed + if (isMature(state)) { + list.add(new ItemStack(getSeedsItem(), new Random().nextInt(3))); + list.add(new ItemStack(QuickieItems.COTTON, new Random().nextFloat() > 0.9f ? 2 : 1)); + } + return list; + } + + private void spawnHarvested(World world, BlockPos pos, BlockState state) { + DefaultedList list = DefaultedList.of(); + getDroppedStacks(state, null).forEach(itemStack -> { + list.add(itemStack); + }); + ItemScatterer.spawn(world, pos, list); + + } + + @Override + public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) { + spawnHarvested(world, pos, state); + super.onBreak(world, pos, state, player); + } + @Override protected ItemConvertible getSeedsItem() { return QuickieItems.COTTONSEED; @@ -33,11 +61,8 @@ public class BlockCottonplant extends CropBlock { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hitResult) { if (!world.isClient && isMature(state)) { - DefaultedList list = DefaultedList.of(); - list.add(new ItemStack(getSeedsItem(), new Random().nextInt(3) + 1)); - list.add(new ItemStack(QuickieItems.COTTON, new Random().nextFloat() > 0.9f ? 2 : 1)); + spawnHarvested(world, pos, state); world.setBlockState(pos, state.with(AGE, 0)); - ItemScatterer.spawn(world, pos, list); } return super.onUse(state, world, pos, player, hand, hitResult); } diff --git a/src/main/resources/data/quickiefabric/recipes/string_from_cotton.json b/src/main/resources/data/quickiefabric/recipes/string_from_cotton.json index 6cf323f..b43cb31 100644 --- a/src/main/resources/data/quickiefabric/recipes/string_from_cotton.json +++ b/src/main/resources/data/quickiefabric/recipes/string_from_cotton.json @@ -1,10 +1,15 @@ { - "type": "minecraft:crafting_shapeless", - "ingredients": [ - { + "type": "minecraft:crafting_shaped", + "pattern": [ + "c", + "c", + "c" + ], + "key": { + "c": { "item": "quickiefabric:cotton" } - ], + }, "result": { "item": "minecraft:string", "count": 1