9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-27 19:09:09 +00:00

fix drop naturally

This commit is contained in:
XiaoMoMi
2025-02-05 20:59:06 +08:00
parent 771d79834b
commit 224d9b52de
3 changed files with 16 additions and 2 deletions

View File

@@ -33,6 +33,7 @@ import net.momirealms.customcrops.api.misc.value.MathValue;
import net.momirealms.customcrops.api.util.EventUtils;
import net.momirealms.customcrops.api.util.LocationUtils;
import net.momirealms.customcrops.api.util.PlayerUtils;
import net.momirealms.customcrops.common.helper.VersionHelper;
import net.momirealms.customcrops.common.util.RandomUtils;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -88,7 +89,11 @@ public class ActionDropItem<T> extends AbstractBuiltInAction<T> {
if (toInv && player != null) {
PlayerUtils.giveItem(player, itemToDrop, itemToDrop.getAmount());
} else {
location.getWorld().dropItemNaturally(LocationUtils.toBlockCenterLocation(location), itemToDrop);
if (VersionHelper.isVersionNewerThan1_21_2()) {
location.getWorld().dropItemNaturally(LocationUtils.toBlockCenterLocation(location), itemToDrop);
} else {
location.getWorld().dropItemNaturally(LocationUtils.toBlockLocation(location), itemToDrop);
}
}
}
}, location);

View File

@@ -34,6 +34,7 @@ import net.momirealms.customcrops.api.misc.value.MathValue;
import net.momirealms.customcrops.api.util.EventUtils;
import net.momirealms.customcrops.api.util.LocationUtils;
import net.momirealms.customcrops.api.util.PlayerUtils;
import net.momirealms.customcrops.common.helper.VersionHelper;
import net.momirealms.customcrops.common.util.RandomUtils;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -95,7 +96,11 @@ public class ActionQualityCrops<T> extends AbstractBuiltInAction<T> {
if (toInv && player != null) {
PlayerUtils.giveItem(player, itemStack, itemStack.getAmount());
} else {
location.getWorld().dropItemNaturally(LocationUtils.toBlockCenterLocation(location), itemStack);
if (VersionHelper.isVersionNewerThan1_21_2()) {
location.getWorld().dropItemNaturally(LocationUtils.toBlockCenterLocation(location), itemStack);
} else {
location.getWorld().dropItemNaturally(LocationUtils.toBlockLocation(location), itemStack);
}
}
}
}, location);

View File

@@ -106,6 +106,10 @@ public class VersionHelper {
return version >= 21.39;
}
public static boolean isVersionNewerThan1_21_2() {
return version >= 19;
}
public static boolean isFolia() {
return folia;
}