Skip to content

Commit

Permalink
modifyblock air natural: drop xp
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Dec 28, 2021
1 parent 04195d5 commit 9f28047
Showing 1 changed file with 10 additions and 1 deletion.
@@ -1,6 +1,7 @@
package com.denizenscript.denizen.scripts.commands.world;

import com.denizenscript.denizen.Denizen;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.objects.*;
import com.denizenscript.denizen.utilities.Utilities;
import com.denizenscript.denizen.utilities.debugging.Debug;
Expand All @@ -23,6 +24,7 @@
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
Expand Down Expand Up @@ -478,10 +480,17 @@ public static void setBlock(Location location, MaterialTag material, boolean phy
physitick = tick;
}
if (!Utilities.isLocationYSafe(location)) {
Debug.echoError("Invalid modifyblock location: " + new LocationTag(location).toString());
Debug.echoError("Invalid modifyblock location: " + new LocationTag(location));
return;
}
if (natural != null && material.getMaterial() == Material.AIR) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
int xp = NMSHandler.getBlockHelper().getExpDrop(location.getBlock(), natural.getItemStack());
if (xp > 0) {
ExperienceOrb orb = (ExperienceOrb) location.getWorld().spawnEntity(location, EntityType.EXPERIENCE_ORB);
orb.setExperience(xp);
}
}
location.getBlock().breakNaturally(natural.getItemStack());
}
else {
Expand Down

0 comments on commit 9f28047

Please sign in to comment.