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;
}
}
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;
}
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;
}
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);
}
}
}
}
Aggregations