Slightly improved where custom block drops spawn

This commit is contained in:
Indyuce 2020-03-19 13:29:36 +01:00
parent 17d99ace1b
commit df52b2c679
2 changed files with 38 additions and 29 deletions

View File

@ -89,15 +89,22 @@ public class BlockListener implements Listener {
if (info.hasTriggers() && !block.hasMetadata("player_placed")) {
PlayerData playerData = PlayerData.get(player);
info.getTriggers().forEach(trigger -> trigger.apply(playerData));
/**if (!block.hasMetadata("player_placed") && info.hasExperience() && MMOCore.plugin.hasHolograms())
MMOCore.plugin.hologramSupport.displayIndicator(block.getLocation().add(.5, 1.5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + called.getGainedExperience().getValue()).message(), player);*/
/**
* if (!block.hasMetadata("player_placed") &&
* info.hasExperience() && MMOCore.plugin.hasHolograms())
* MMOCore.plugin.hologramSupport.displayIndicator(block.getLocation().add(.5,
* 1.5, .5),
* MMOCore.plugin.configManager.getSimpleMessage("exp-hologram",
* "exp", "" +
* called.getGainedExperience().getValue()).message(), player);
*/
}
/*
* apply drop tables
*/
if (info.hasDropTable()) {
Location dropLocation = getSafeDropLocation(block, !info.hasDropTable());
Location dropLocation = getSafeDropLocation(block, true);
for (ItemStack drop : called.getDrops())
if (drop.getType() != Material.AIR && drop.getAmount() > 0)
block.getWorld().dropItemNaturally(dropLocation, drop);
@ -134,7 +141,8 @@ public class BlockListener implements Listener {
@EventHandler
public void c1(BlockPistonExtendEvent event) {
Block movedBlock = event.getBlock();
if(!movedBlock.hasMetadata("player_placed")) return;
if (!movedBlock.hasMetadata("player_placed"))
return;
BlockFace direction = event.getDirection();
movedBlock = movedBlock.getRelative(direction, 2);
@ -145,6 +153,7 @@ public class BlockListener implements Listener {
}
}
}
@EventHandler
public void c2(BlockPistonRetractEvent event) {
BlockFace direction = event.getDirection();

View File

@ -124,7 +124,7 @@ public class CustomBlockManager extends MMOManager {
}
public class BlockInfo {
private Material block;
private final Material block;
private final DropTable table;
private final boolean vanillaDrops;
private final String headValue;