Add automatic planting of dropped seeds.

master
dragontamerfred 2019-10-02 19:15:41 +02:00
parent 36ded4ce9f
commit 774f7d449f
5 changed files with 73 additions and 6 deletions

View File

@ -16,9 +16,18 @@ Currently included:
- 1 wool (any color) -> 4 string
- 3 leather + 2 string + 2 iron ingot -> 1 saddle
### Dropped seed planting
Automatically plants seed dropped on tilled soil.
Works for:
- Wheat
- Beetroot
- Carrot
- Potato
- Melon
- Pumpkin
## Planned tweaks
- Dynamite
- Seed drop planting
- Sign editing
- Armor stand swapping
- Nether sponge drying

View File

@ -0,0 +1,54 @@
package nl.kallestruik.vanillatweaks.SeedDropPlanting;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.plugin.java.JavaPlugin;
public class SeedDropPlanting {
public static void init(JavaPlugin plugin) {
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> {
for (World world : plugin.getServer().getWorlds()) {
for (Entity entity : world.getEntities()) {
if (entity instanceof Item) {
Item item = ((Item) entity);
Block b = world.getBlockAt(item.getLocation());
Block below = world.getBlockAt(item.getLocation().add(0, -1, 0));
if (b.getType() == Material.AIR && below.getType() == Material.FARMLAND) {
switch (item.getItemStack().getType()) {
case WHEAT_SEEDS:
b.setType(Material.WHEAT);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
break;
case BEETROOT_SEEDS:
b.setType(Material.BEETROOT);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
break;
case MELON_SEEDS:
b.setType(Material.MELON_STEM);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
break;
case PUMPKIN_SEEDS:
b.setType(Material.PUMPKIN_STEM);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
break;
case POTATO:
b.setType(Material.POTATOES);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
break;
case CARROT:
b.setType(Material.CARROTS);
world.spawnParticle(Particle.VILLAGER_HAPPY, item.getLocation(), 10);
break;
}
}
}
}
}
}, 20 * 10, 20 * 10);
}
}

View File

@ -1,6 +1,7 @@
package nl.kallestruik.vanillatweaks;
import nl.kallestruik.vanillatweaks.CraftingTweaks.CraftingTweaks;
import nl.kallestruik.vanillatweaks.SeedDropPlanting.SeedDropPlanting;
import nl.kallestruik.vanillatweaks.ToggleTrample.CommandToggletrample;
import nl.kallestruik.vanillatweaks.ToggleTrample.TrampleHandler;
import org.bukkit.configuration.InvalidConfigurationException;
@ -32,11 +33,9 @@ public final class VanillaTweaks extends JavaPlugin {
* Throwable tnt with a smaller explosion.
*/
/**
* Seed drop planting
*
* Seeds dropped on tilled soil will plant themselves after a random amount of time.
*/
if (config.SEED_DROP_PLANTING_ENABLED) {
SeedDropPlanting.init(this);
}
/**
* Sign editing

View File

@ -9,12 +9,15 @@ import java.io.IOException;
public class config {
public static boolean TOGGLE_TRAMPLE_ENABLED;
public static boolean CRAFTING_TWEAKS_ENABLED;
public static boolean CRAFTING_TWEAKS_BETTER_CHEST;
public static boolean CRAFTING_TWEAKS_NAME_TAG;
public static boolean CRAFTING_TWEAKS_WOOL_TO_STRING;
public static boolean CRAFTING_TWEAKS_SADDLE;
public static boolean SEED_DROP_PLANTING_ENABLED;
public static void load(File file) throws IOException, InvalidConfigurationException {
if (!file.getParentFile().exists())
file.getParentFile().mkdirs();

View File

@ -8,3 +8,5 @@ crafting-tweaks:
wool-to-string: true
saddle: true
seed-drop-planting:
enabled: true