Fix bug with seed drop planting.

master
dragontamerfred 2019-10-03 18:47:23 +02:00
parent 4a1793b2e1
commit 94366f74d2
1 changed files with 16 additions and 18 deletions

View File

@ -20,34 +20,22 @@ public class SeedDropPlanting {
if (b.getType() == Material.FARMLAND && above.getType() == Material.AIR) { if (b.getType() == Material.FARMLAND && above.getType() == Material.AIR) {
switch (item.getItemStack().getType()) { switch (item.getItemStack().getType()) {
case WHEAT_SEEDS: case WHEAT_SEEDS:
above.setType(Material.WHEAT); plantSeed(item, world, above, Material.WHEAT);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
case BEETROOT_SEEDS: case BEETROOT_SEEDS:
above.setType(Material.BEETROOTS); plantSeed(item, world, above, Material.BEETROOTS);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
case MELON_SEEDS: case MELON_SEEDS:
above.setType(Material.MELON_STEM); plantSeed(item, world, above, Material.MELON_STEM);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
case PUMPKIN_SEEDS: case PUMPKIN_SEEDS:
above.setType(Material.PUMPKIN_STEM); plantSeed(item, world, above, Material.PUMPKIN_STEM);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
case POTATO: case POTATO:
above.setType(Material.POTATOES); plantSeed(item, world, above, Material.POTATOES);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
case CARROT: case CARROT:
above.setType(Material.CARROTS); plantSeed(item, world, above, Material.CARROTS);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
entity.remove();
break; break;
} }
} }
@ -57,4 +45,14 @@ public class SeedDropPlanting {
} }
}, 20 * 10, 20 * 10); }, 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);
}
}
} }