use of com.skelril.skree.content.zone.global.cursedmine.restoration.BlockRecord in project Skree by Skelril.
the class CursedMineListener method onBlockBreak.
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Named(NamedCause.SOURCE) Player player) {
Optional<CursedMineInstance> optInst = manager.getApplicableZone(player);
if (!optInst.isPresent()) {
return;
}
CursedMineInstance inst = optInst.get();
Optional<ItemStack> optHeldItem = player.getItemInHand(HandTypes.MAIN_HAND);
if (!optHeldItem.isPresent()) {
event.setCancelled(true);
return;
}
for (Transaction<BlockSnapshot> block : event.getTransactions()) {
BlockType originalType = block.getOriginal().getState().getType();
if (cursedOres.contains(originalType)) {
// we were having some multi-firing problems
if (inst.recordBlockBreak(player, new BlockRecord(block.getOriginal()))) {
/*if (Probability.getChance(3000)) {
ChatUtil.send(player, "You feel as though a spirit is trying to tell you something...");
player.getInventory().addItem(BookUtil.Lore.Areas.theGreatMine());
}*/
ExperienceOrb xpOrb = (ExperienceOrb) player.getWorld().createEntity(EntityTypes.EXPERIENCE_ORB, block.getOriginal().getLocation().get().getPosition());
xpOrb.offer(Keys.CONTAINED_EXPERIENCE, (70 - player.getLocation().getBlockY()) / 2);
inst.eatFood(player);
inst.poison(player, 6);
inst.ghost(player, originalType);
}
} else if (stealableFluids.contains(originalType)) {
inst.recordBlockBreak(player, new BlockRecord(block.getOriginal()));
} else {
block.setCustom(block.getOriginal());
}
}
}
Aggregations