Search in sources :

Example 1 with EntityFairy

use of com.teamwizardry.wizardry.common.entity.EntityFairy in project Wizardry by TeamWizardry.

the class EventHandler method fairyAmbush.

@SubscribeEvent
public void fairyAmbush(SpellCastEvent event) {
    Entity caster = event.getSpellData().getData(SpellData.DefaultKeys.CASTER);
    int chance = 5;
    for (SpellRing spellRing : SpellUtils.getAllSpellRings(event.getSpellRing())) if (spellRing instanceof IContinuousModule) {
        chance = 1000;
        break;
    }
    if (RandUtil.nextInt(chance) == 0 && caster != null) {
        List<EntityFairy> fairyList = event.getSpellData().world.getEntitiesWithinAABB(EntityFairy.class, new AxisAlignedBB(caster.getPosition()).grow(64, 64, 64));
        if (fairyList.isEmpty())
            return;
        EntityFairy fairy = fairyList.get(RandUtil.nextInt(fairyList.size() - 1));
        if (fairy == null)
            return;
        fairy.ambush = true;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) IContinuousModule(com.teamwizardry.wizardry.api.spell.IContinuousModule) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with EntityFairy

use of com.teamwizardry.wizardry.common.entity.EntityFairy in project Wizardry by TeamWizardry.

the class ItemJar method onLeftClickEntity.

@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
    if (entity instanceof EntityFairy) {
        EntityFairy fairy = (EntityFairy) entity;
        ItemNBTHelper.setBoolean(stack, Constants.NBT.FAIRY_INSIDE, true);
        ItemNBTHelper.setInt(stack, Constants.NBT.FAIRY_COLOR, fairy.getColor().getRGB());
        ItemNBTHelper.setInt(stack, Constants.NBT.FAIRY_AGE, fairy.getAge());
        entity.world.removeEntity(entity);
        return true;
    }
    return false;
}
Also used : EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy)

Example 3 with EntityFairy

use of com.teamwizardry.wizardry.common.entity.EntityFairy in project Wizardry by TeamWizardry.

the class BlockJar method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        TileEntity tile = worldIn.getTileEntity(pos);
        if (tile != null && tile instanceof TileJar) {
            TileJar jar = (TileJar) tile;
            if (playerIn.isSneaking() && jar.hasFairy) {
                EntityFairy entity = new EntityFairy(worldIn, jar.color, jar.age);
                entity.setPosition(playerIn.posX, playerIn.posY, playerIn.posZ);
                worldIn.spawnEntity(entity);
                jar.hasFairy = false;
                jar.markDirty();
                return true;
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileJar(com.teamwizardry.wizardry.common.tile.TileJar) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy)

Example 4 with EntityFairy

use of com.teamwizardry.wizardry.common.entity.EntityFairy in project Wizardry by TeamWizardry.

the class BiomeUnderWorld method onTickPlayerTick.

@SubscribeEvent
public void onTickPlayerTick(TickEvent.PlayerTickEvent event) {
    if (event.player.world.isRemote)
        return;
    if (!event.player.world.getGameRules().getBoolean("doMobSpawning"))
        return;
    if (RandUtil.nextInt(300) == 0 && getEntityCount(EntityFairy.class, event.player.getPosition(), event.player.world, 64) < 15) {
        BlockPos pos = new BlockPos(event.player.posX + RandUtil.nextInt(-64, 64), RandUtil.nextInt(110, 150), event.player.posZ + RandUtil.nextInt(-64, 64));
        if (event.player.world.getBiome(pos) == this && event.player.world.isAirBlock(pos)) {
            EntityFairy entity = new EntityFairy(event.player.world);
            entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
            event.player.world.spawnEntity(entity);
        }
    }
    if (RandUtil.nextInt(500) == 0 && getEntityCount(EntitySpiritWight.class, event.player.getPosition(), event.player.world, 128) < 1) {
        BlockPos pos = new BlockPos(event.player.posX + RandUtil.nextInt(-128, 128), event.player.posY + RandUtil.nextInt(-10, 10), event.player.posZ + RandUtil.nextInt(-128, 128));
        if (event.player.world.getBiome(pos) == this && pos.getDistance((int) event.player.posX, (int) event.player.posY, (int) event.player.posZ) > 64) {
            EntitySpiritWight entity = new EntitySpiritWight(event.player.world);
            entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
            entity.enablePersistence();
            event.player.world.spawnEntity(entity);
        }
    }
    if (RandUtil.nextInt(500) == 0 && getEntityCount(EntityUnicorn.class, event.player.getPosition(), event.player.world, 64) < 3) {
        BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos((int) event.player.posX + RandUtil.nextInt(-64, 64), 100, (int) event.player.posZ + RandUtil.nextInt(-64, 64));
        if (event.player.world.getBiome(pos) == this && pos.getDistance((int) event.player.posX, (int) event.player.posY, (int) event.player.posZ) > 30) {
            boolean success = false;
            for (int i = 150; i > 50; i--) {
                if (!event.player.world.isAirBlock(pos.move(EnumFacing.DOWN, -1))) {
                    success = true;
                    break;
                }
            }
            if (!success) {
                BlockPos fixed = new BlockPos(pos.getX(), 100, pos.getZ());
                for (int k = 100; k > 30; k--) {
                    for (int i = -20; i < 20; i++) {
                        for (int j = -20; j < 20; j++) {
                            if (!event.player.world.isAirBlock(pos.setPos(fixed).add(i, k, j))) {
                                success = true;
                                break;
                            }
                        }
                    }
                }
            }
            if (success) {
                pos.move(EnumFacing.UP, 2);
                EntityUnicorn entity = new EntityUnicorn(event.player.world);
                entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
                event.player.world.spawnEntity(entity);
            }
        }
    }
}
Also used : EntityUnicorn(com.teamwizardry.wizardry.common.entity.EntityUnicorn) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) EntitySpiritWight(com.teamwizardry.wizardry.common.entity.EntitySpiritWight) BlockPos(net.minecraft.util.math.BlockPos) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityFairy (com.teamwizardry.wizardry.common.entity.EntityFairy)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 IContinuousModule (com.teamwizardry.wizardry.api.spell.IContinuousModule)1 SpellRing (com.teamwizardry.wizardry.api.spell.SpellRing)1 EntitySpiritWight (com.teamwizardry.wizardry.common.entity.EntitySpiritWight)1 EntityUnicorn (com.teamwizardry.wizardry.common.entity.EntityUnicorn)1 TileJar (com.teamwizardry.wizardry.common.tile.TileJar)1 Entity (net.minecraft.entity.Entity)1 TileEntity (net.minecraft.tileentity.TileEntity)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1