From 126f5428a89f54fb9d2143c4c30d66b922d5ec96 Mon Sep 17 00:00:00 2001 From: Xiao-MoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Tue, 23 May 2023 00:29:55 +0800 Subject: [PATCH] 3.2.2-hotfix3 --- build.gradle | 2 +- .../api/object/loot/QualityLoot.java | 2 +- .../command/CustomCropsCommand.java | 2 +- .../customcrops/command/subcmd/Test.java | 122 ++++++++++++++++++ src/main/resources/contents/crops/tomato.yml | 7 +- 5 files changed, 126 insertions(+), 9 deletions(-) create mode 100644 src/main/java/net/momirealms/customcrops/command/subcmd/Test.java diff --git a/build.gradle b/build.gradle index 4eb9dff..fe3d023 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '3.2.2-hotfix2' +version = '3.2.2-hotfix3' repositories { mavenCentral() diff --git a/src/main/java/net/momirealms/customcrops/api/object/loot/QualityLoot.java b/src/main/java/net/momirealms/customcrops/api/object/loot/QualityLoot.java index d0ae215..3213186 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/loot/QualityLoot.java +++ b/src/main/java/net/momirealms/customcrops/api/object/loot/QualityLoot.java @@ -45,7 +45,7 @@ public class QualityLoot extends Loot { @Override public void drop(Player player, Location location) { SimpleLocation simpleLocation = SimpleLocation.getByBukkitLocation(location); - Pot pot = CustomCrops.getInstance().getWorldDataManager().getPotData(simpleLocation); + Pot pot = CustomCrops.getInstance().getWorldDataManager().getPotData(simpleLocation.add(0,-1,0)); int amount = getAmount(player); double[] qualityRatio = ConfigManager.defaultRatio; if (pot != null) { diff --git a/src/main/java/net/momirealms/customcrops/command/CustomCropsCommand.java b/src/main/java/net/momirealms/customcrops/command/CustomCropsCommand.java index ed65e13..66eabfe 100644 --- a/src/main/java/net/momirealms/customcrops/command/CustomCropsCommand.java +++ b/src/main/java/net/momirealms/customcrops/command/CustomCropsCommand.java @@ -31,7 +31,7 @@ public class CustomCropsCommand extends AbstractMainCommand { regSubCommand(MigrateCommand.INSTANCE); regSubCommand(ConvertCommand.INSTANCE); regSubCommand(FixCommand.INSTANCE); -// regSubCommand(CorruptionTest.INSTANCE); +// regSubCommand(Test.INSTANCE); // regSubCommand(PerformanceTest.INSTANCE); } } diff --git a/src/main/java/net/momirealms/customcrops/command/subcmd/Test.java b/src/main/java/net/momirealms/customcrops/command/subcmd/Test.java new file mode 100644 index 0000000..e48cbc7 --- /dev/null +++ b/src/main/java/net/momirealms/customcrops/command/subcmd/Test.java @@ -0,0 +1,122 @@ +//package net.momirealms.customcrops.command.subcmd; +// +//import dev.lone.itemsadder.api.CustomBlock; +//import net.momirealms.customcrops.CustomCrops; +//import net.momirealms.customcrops.command.AbstractSubCommand; +//import org.bukkit.Bukkit; +//import org.bukkit.Location; +//import org.bukkit.Material; +//import org.bukkit.block.Block; +//import org.bukkit.block.BlockFace; +//import org.bukkit.command.CommandSender; +//import org.bukkit.entity.Player; +//import org.bukkit.event.EventHandler; +//import org.bukkit.event.Listener; +//import org.bukkit.event.block.BlockBreakEvent; +// +//import java.util.*; +// +//public class Test extends AbstractSubCommand implements Listener { +// +// public static final Test INSTANCE = new Test(); +// +// public Test() { +// super("test"); +// Bukkit.getPluginManager().registerEvents(this, CustomCrops.getInstance()); +// } +// +// @EventHandler +// public void onBreak(BlockBreakEvent event) { +// long time1 = System.currentTimeMillis(); +// getNearbyWires(event.getBlock()); +// long time2 = System.currentTimeMillis(); +// System.out.println("method1:" + (time2 - time1) + "ms"); +// +// getNearbyWires(event.getBlock(), new HashSet<>()); +// System.out.println("method2:" + (time2 - time1) + "ms"); +// +//// getNearbyWires(event.getBlock(), new HashSet<>()); +//// System.out.println("method2:" + (time2 - time1) + "ms"); +// } +// +// @Override +// public boolean onCommand(CommandSender sender, List args) { +// if (sender instanceof Player player) { +// Location location = player.getLocation(); +// int size = Integer.parseInt(args.get(0)) / 2; +// for (int i = -size; i < size; i++) { +// for (int j = -size; j < size; j++) { +// CustomBlock.place("customcrops:tomato_stage_1", location.clone().add(i, 0, j)); +// } +// } +// } +// return true; +// } +// +// public static Collection getNearbyWires(Block startBlock) { +// Set blocks = new HashSet<>(); +// Queue queue = new LinkedList<>(); +// queue.add(startBlock); +// +// while (!queue.isEmpty()) { +// Block currentBlock = queue.remove(); +// for (BlockFace face : XZ_FACES) { +// Block b = currentBlock.getRelative(face); +// if (b.getType() == Material.TRIPWIRE && !blocks.contains(b)) { +// blocks.add(b); +// queue.add(b); +// } +// } +// } +// +// return blocks; +// } +// +// public static Collection getNearbyWires2(Block startBlock) { +// Set blocks = new HashSet<>(); +// Queue queue = new LinkedList<>(); +// queue.add(startBlock); +// +// while (!queue.isEmpty()) { +// Block currentBlock = queue.remove(); +// for (int x = -1; x <= 1; x++) { +// for (int z = -1; z <= 1; z++) { +// if ((x == 0 && z == 0) || (Math.abs(x) == 1 && Math.abs(z) == 1)) +// continue; +// Block b = currentBlock.getLocation().clone().add(x, 0, z).getBlock(); +// if (!blocks.contains(b) && b.getType() == Material.TRIPWIRE) { +// blocks.add(b); +// queue.add(b); +// } +// } +// } +// } +// +// return blocks; +// } +// +// private static final BlockFace[] XZ_FACES = { +// BlockFace.NORTH, +// BlockFace.EAST, +// BlockFace.SOUTH, +// BlockFace.WEST +// }; +// +// public static Collection getNearbyWires(Block startBlock, Set blocks) +// { +// // Avoid too much processing, i don't give a shit about far blocks. +// if (blocks.size() > 256) // 256 is ~1 chunk +// return blocks; +// +// for (BlockFace face : XZ_FACES) +// { +// Block currentBlock = startBlock.getRelative(face); +// if (currentBlock.getType() == Material.TRIPWIRE && !blocks.contains(currentBlock)) +// { +// blocks.add(currentBlock); +// blocks.addAll(getNearbyWires(currentBlock, blocks)); +// } +// } +// return blocks; +// } +//} diff --git a/src/main/resources/contents/crops/tomato.yml b/src/main/resources/contents/crops/tomato.yml index be6ed8c..9e0c4c9 100644 --- a/src/main/resources/contents/crops/tomato.yml +++ b/src/main/resources/contents/crops/tomato.yml @@ -142,18 +142,13 @@ tomato: events: break: action_1: - type: command - value: - - 'say Hello, {player}!' - chance: 0.5 - action_2: type: sound value: source: player key: minecraft:block.crop.break volume: 1 pitch: 1 - action_3: + action_2: type: drop-items value: quality-crops: