From 94366f74d28d8befb17e0ee62805548c38da8c00 Mon Sep 17 00:00:00 2001 From: dragontamerfred Date: Thu, 3 Oct 2019 18:47:23 +0200 Subject: [PATCH] Fix bug with seed drop planting. --- .../SeedDropPlanting/SeedDropPlanting.java | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/main/java/nl/kallestruik/vanillatweaks/SeedDropPlanting/SeedDropPlanting.java b/src/main/java/nl/kallestruik/vanillatweaks/SeedDropPlanting/SeedDropPlanting.java index 288a3a1..0de4b1a 100644 --- a/src/main/java/nl/kallestruik/vanillatweaks/SeedDropPlanting/SeedDropPlanting.java +++ b/src/main/java/nl/kallestruik/vanillatweaks/SeedDropPlanting/SeedDropPlanting.java @@ -20,34 +20,22 @@ public class SeedDropPlanting { if (b.getType() == Material.FARMLAND && above.getType() == Material.AIR) { switch (item.getItemStack().getType()) { case WHEAT_SEEDS: - above.setType(Material.WHEAT); - world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); - entity.remove(); + plantSeed(item, world, above, Material.WHEAT); break; case BEETROOT_SEEDS: - above.setType(Material.BEETROOTS); - world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); - entity.remove(); + plantSeed(item, world, above, Material.BEETROOTS); break; case MELON_SEEDS: - above.setType(Material.MELON_STEM); - world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); - entity.remove(); + plantSeed(item, world, above, Material.MELON_STEM); break; case PUMPKIN_SEEDS: - above.setType(Material.PUMPKIN_STEM); - world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); - entity.remove(); + plantSeed(item, world, above, Material.PUMPKIN_STEM); break; case POTATO: - above.setType(Material.POTATOES); - world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); - entity.remove(); + plantSeed(item, world, above, Material.POTATOES); break; case CARROT: - above.setType(Material.CARROTS); - world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10); - entity.remove(); + plantSeed(item, world, above, Material.CARROTS); break; } } @@ -57,4 +45,14 @@ public class SeedDropPlanting { } }, 20 * 10, 20 * 10); } + + private static void plantSeed(Item entity, World world, Block block, Material material) { + block.setType(material); + world.spawnParticle(Particle.VILLAGER_HAPPY, entity.getLocation(), 10); + if (entity.getItemStack().getAmount() == 1) { + entity.remove(); + } else { + entity.getItemStack().setAmount(entity.getItemStack().getAmount() - 1); + } + } }