Search in sources :

Example 1 with EntityAnimaStone

use of net.tslat.aoa3.entity.misc.EntityAnimaStone 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));
    }
}
Also used : FakePlayer(net.minecraftforge.common.util.FakePlayer) PlayerDataManager(net.tslat.aoa3.utils.player.PlayerDataManager) Item(net.minecraft.item.Item) BossSpawningItem(net.tslat.aoa3.item.misc.summon.BossSpawningItem) EntityItem(net.minecraft.entity.item.EntityItem) ReservedItem(net.tslat.aoa3.item.misc.ReservedItem) SpecialHarvestTool(net.tslat.aoa3.item.tool.SpecialHarvestTool) EntityAnimaStone(net.tslat.aoa3.entity.misc.EntityAnimaStone) StoneBlock(net.tslat.aoa3.block.generation.stone.StoneBlock) EntityPlayer(net.minecraft.entity.player.EntityPlayer) StoneBlock(net.tslat.aoa3.block.generation.stone.StoneBlock) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 FakePlayer (net.minecraftforge.common.util.FakePlayer)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 StoneBlock (net.tslat.aoa3.block.generation.stone.StoneBlock)1 EntityAnimaStone (net.tslat.aoa3.entity.misc.EntityAnimaStone)1 ReservedItem (net.tslat.aoa3.item.misc.ReservedItem)1 BossSpawningItem (net.tslat.aoa3.item.misc.summon.BossSpawningItem)1 SpecialHarvestTool (net.tslat.aoa3.item.tool.SpecialHarvestTool)1 PlayerDataManager (net.tslat.aoa3.utils.player.PlayerDataManager)1