use of net.tslat.aoa3.item.tool.SpecialHarvestTool in project Advent-Of-Ascension by Tslat.
the class PlayerEvents method onBlockHarvest.
@SubscribeEvent
public void onBlockHarvest(final BlockEvent.HarvestDropsEvent ev) {
if (ev.getHarvester() == null || ev.getHarvester() instanceof FakePlayer)
return;
EntityPlayer pl = ev.getHarvester();
Item tool = pl.getHeldItem(EnumHand.MAIN_HAND).getItem();
if (tool instanceof SpecialHarvestTool)
((SpecialHarvestTool) tool).doHarvestEffect(ev);
if (ev.getWorld().isRemote)
return;
Block bl = ev.getState().getBlock();
if (bl instanceof BlockCrops || bl instanceof BlockFlower || bl instanceof BlockVine || bl instanceof BlockLeaves) {
if (!(bl instanceof BlockCrops) || ((BlockCrops) bl).isMaxAge(ev.getState())) {
if (bl instanceof BlockCrops && ev.getWorld().isDaytime()) {
PlayerUtil.getAdventPlayer(pl).stats().addTribute(Enums.Deities.SELYAN, 2);
if (AdventOfAscension.rand.nextInt(2000) == 0)
pl.entityDropItem(new ItemStack(WeaponRegister.GARDENER), 0);
}
if (bl instanceof BlockLeaves ? AdventOfAscension.rand.nextInt(35) == 0 : bl instanceof BlockCrops ? AdventOfAscension.rand.nextInt(6) == 0 : AdventOfAscension.rand.nextInt(8) == 0) {
EntityAnimaStone animaStone = new EntityAnimaStone(ev.getWorld(), ev.getPos());
ev.getWorld().playSound(null, ev.getPos(), SoundsRegister.HEART_STONE_SPAWN, SoundCategory.MASTER, 1.0f, 1.0f);
ev.getWorld().spawnEntity(animaStone);
}
}
} else if (bl == Blocks.STONE || bl == Blocks.NETHERRACK || bl instanceof StoneBlock || bl == Blocks.END_STONE) {
PlayerDataManager plData = PlayerUtil.getAdventPlayer(pl);
int lvl = plData.stats().getLevel(Enums.Skills.FORAGING);
if (bl != Blocks.NETHERRACK || AdventOfAscension.rand.nextBoolean()) {
if (ForagingUtil.shouldGetLoot(lvl)) {
ev.getDrops().addAll(ForagingUtil.getLoot(pl));
if (plData.equipment().getCurrentFullArmourSet() == Enums.ArmourSets.FORAGING)
ev.getDrops().addAll(ForagingUtil.getLoot(pl));
ev.getWorld().playSound(null, ev.getPos(), SoundsRegister.FORAGING_LOOT, SoundCategory.MASTER, 1.0f, 1.0f);
if (ev.getWorld().provider.getDimension() == 0 && ev.getWorld().isDaytime())
plData.stats().addTribute(Enums.Deities.PLUTON, 11 - lvl / 10);
}
}
} else if (bl instanceof BlockLog) {
PlayerDataManager plData = PlayerUtil.getAdventPlayer(pl);
int lvl = plData.stats().getLevel(Enums.Skills.LOGGING);
if (LoggingUtil.shouldGetLoot(lvl)) {
if (AdventOfAscension.rand.nextBoolean()) {
ev.getDrops().addAll(LoggingUtil.getLoot(pl));
if (plData.equipment().getCurrentFullArmourSet() == Enums.ArmourSets.LOGGING)
ev.getDrops().addAll(LoggingUtil.getLoot(pl));
} else {
ItemStack duplicateStack = ItemStack.EMPTY;
for (ItemStack stack : ev.getDrops()) {
if (stack.getItem() == Item.getItemFromBlock(bl)) {
duplicateStack = stack.copy();
duplicateStack.setCount(lvl > 50 ? 2 : 1);
plData.stats().addXp(Enums.Skills.LOGGING, (float) Math.pow(lvl, 1.65D) * 3, false, false);
break;
}
}
if (!duplicateStack.isEmpty())
ev.getDrops().add(duplicateStack);
}
if (ev.getWorld().provider.getDimension() == 0)
plData.stats().addTribute(Enums.Deities.PLUTON, 11 - lvl / 10);
ev.getWorld().playSound(null, ev.getPos(), SoundsRegister.FORAGING_LOOT, SoundCategory.MASTER, 1.0f, 1.0f);
}
} else if (WorldUtil.isOreBlock(bl) && ev.getPos().getY() <= 5 && ItemUtil.findInventoryItem(pl, new ItemStack(ItemRegister.BLANK_REALMSTONE), true, 1)) {
ItemUtil.givePlayerItemOrDrop(pl, new ItemStack(ItemRegister.DEEPLANDS_REALMSTONE));
}
}
Aggregations