use of net.minecraft.potion.PotionEffect in project minecolonies by Minecolonies.
the class EntityCitizen method onLivingUpdate.
/**
* Called frequently so the entity can update its state every tick as
* required. For example, zombies and skeletons. use this to react to
* sunlight and start to burn.
*/
@Override
public void onLivingUpdate() {
if (recentlyHit > 0) {
citizenData.markDirty();
}
if (world.isRemote) {
updateColonyClient();
} else {
pickupItems();
cleanupChatMessages();
updateColonyServer();
if (getColonyJob() != null) {
checkIfStuck();
}
if (world.isDaytime() && !world.isRaining() && citizenData != null) {
SoundUtils.playRandomSound(world, this, citizenData.getSaturation());
} else if (world.isRaining() && 1 >= rand.nextInt(RANT_ABOUT_WEATHER_CHANCE) && this.getColonyJob() != null) {
SoundUtils.playSoundAtCitizenWithChance(world, this.getPosition(), this.getColonyJob().getBadWeatherSound(), 1);
}
}
if (isEntityInsideOpaqueBlock() || isInsideOfMaterial(Material.LEAVES)) {
getNavigator().moveAwayFromXYZ(this.getPosition(), MOVE_AWAY_RANGE, MOVE_AWAY_SPEED);
}
gatherXp();
if (citizenData != null) {
if (citizenData.getSaturation() <= 0) {
this.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("slowness")));
} else {
this.removeActivePotionEffect(Potion.getPotionFromResourceLocation("slowness"));
}
if (citizenData.getSaturation() < HIGH_SATURATION) {
tryToEat();
}
}
checkHeal();
super.onLivingUpdate();
}
use of net.minecraft.potion.PotionEffect in project Pearcel-Mod by MiningMark48.
the class ItemCharmedPearcel method doEffects.
public static void doEffects(EntityPlayer player, ItemStack stack) {
if (stack.getTagCompound().getString("type").equalsIgnoreCase("fire") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fire, player) || player.isCreative())) {
player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 25, 0, true, false));
player.extinguish();
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fire, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("water") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_water, player) || player.isCreative())) {
player.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 25, 5, true, false));
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_water, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("saturation") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_saturation, player) || player.isCreative())) {
player.addPotionEffect(new PotionEffect(MobEffects.SATURATION, 25, 5, true, false));
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_saturation, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("step_assist") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_stepAssist, player) || player.isCreative())) {
ItemStack s = new ItemStack(ModItems.charmed_pearcel);
if (!s.hasTagCompound()) {
s.setTagCompound(new NBTTagCompound());
}
s.getTagCompound().setString("type", "step_assist");
if (player.inventory.hasItemStack(s)) {
player.stepHeight = 1.25F;
}
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_stepAssist, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("gravity") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_gravity, player) || player.isCreative())) {
if (player.isSneaking()) {
player.addVelocity(0D, -0.125D, 0D);
}
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_gravity, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("adrenaline") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_adrenaline, player) || player.isCreative())) {
player.addPotionEffect(new PotionEffect(MobEffects.SPEED, 25, 1, true, false));
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, 25, 0, true, false));
player.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 25, 1, true, false));
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_adrenaline, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("cloaking") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_cloaking, player) || player.isCreative())) {
player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 25, 0, true, false));
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_cloaking, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("hearty") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_hearty, player) || player.isCreative())) {
player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 25, 0, true, false));
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 25, 0, true, false));
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_hearty, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("repair") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_repair, player) || player.isCreative())) {
if (player.getHeldItemMainhand() != null) {
if (player.getHeldItemMainhand().getItem().isDamageable() && player.getHeldItemMainhand().getItem().isDamaged(player.getHeldItemMainhand())) {
Random rand = new Random();
int num = rand.nextInt(100);
if (num == 0) {
player.getHeldItemMainhand().getItem().setDamage(player.getHeldItemMainhand(), player.getHeldItemMainhand().getItemDamage() - 1);
}
}
}
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_repair, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("physco") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_physco, player) || player.isCreative())) {
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;
int range = 15;
List<EntityCreature> creatureList = player.world.getEntitiesWithinAABB(EntityCreature.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
for (EntityCreature creature : creatureList) {
if (creature.isCreatureType(EnumCreatureType.MONSTER, false)) {
List<EntityCreature> creatureList2 = creature.world.getEntitiesWithinAABB(EntityCreature.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
for (EntityCreature creature2 : creatureList2) {
creature.setAttackTarget(creature2);
}
}
}
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_physco, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("third_eye") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_thirdEye, player) || player.isCreative())) {
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;
int range = 15;
List<EntityLiving> entities = player.world.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
for (EntityLiving e : entities) {
e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 25, 0, true, false));
}
player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 25, 0, true, false));
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_thirdEye, false, player);
}
if (stack.getTagCompound().getString("type").equalsIgnoreCase("fall") && (hasEnoughEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fall, player) || player.isCreative())) {
useEnergy(stack, ConfigurationHandler.rfPerTick_charmedPearcel_fall, false, player);
}
}
use of net.minecraft.potion.PotionEffect in project Pearcel-Mod by MiningMark48.
the class ItemJeweledPearcel method onItemUseFinish.
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
if (entityLiving instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) entityLiving;
if (!entityplayer.isCreative()) {
--stack.stackSize;
}
entityplayer.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 1500, 1));
entityplayer.addPotionEffect(new PotionEffect(MobEffects.HASTE, 2000, 3));
entityplayer.addPotionEffect(new PotionEffect(MobEffects.SATURATION, 3500, 0));
entityplayer.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 5000, 3));
entityplayer.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 5000, 2));
entityplayer.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 7000, 0));
entityplayer.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 7000, 5));
}
return stack;
}
use of net.minecraft.potion.PotionEffect in project ArsMagica2 by Mithion.
the class EntityAISummonAllies method updateTask.
@Override
public void updateTask() {
if (((IArsMagicaBoss) host).getCurrentAction() != BossActions.CASTING)
((IArsMagicaBoss) host).setCurrentAction(BossActions.CASTING);
actionTicks++;
if (actionTicks == 16) {
if (!host.worldObj.isRemote)
host.worldObj.playSoundAtEntity(host, "arsmagica2:mob.lifeguardian.summon", 1.0f, host.getRNG().nextFloat() * 0.5f + 0.5f);
int numAllies = 3;
for (int i = 0; i < numAllies; ++i) {
Class summon = mobs[host.worldObj.rand.nextInt(mobs.length)];
try {
Constructor ctor = summon.getConstructor(World.class);
EntityCreature mob = (EntityCreature) ctor.newInstance(host.worldObj);
mob.setPosition(host.posX + host.worldObj.rand.nextDouble() * 2 - 1, host.posY, host.posZ + host.worldObj.rand.nextDouble() * 2 - 1);
mob.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 99999, 1));
mob.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 99999, 1));
mob.addPotionEffect(new PotionEffect(Potion.regeneration.id, 99999, 1));
mob.addPotionEffect(new BuffEffectMagicShield(99999, 1));
if (host.getHealth() < host.getMaxHealth() / 2) {
mob.addPotionEffect(new BuffEffectShrink(99999, 1));
}
EntityUtilities.makeSummon_MonsterFaction(mob, false);
EntityUtilities.setOwner(mob, host);
EntityUtilities.setSummonDuration(mob, 1800);
host.worldObj.spawnEntityInWorld(mob);
host.queued_minions.add(mob);
} catch (Throwable e) {
e.printStackTrace();
return;
}
}
}
if (actionTicks >= 23) {
resetTask();
}
}
use of net.minecraft.potion.PotionEffect in project ArsMagica2 by Mithion.
the class BuffEffectFury method stopEffect.
@Override
public void stopEffect(EntityLivingBase entityliving) {
if (!entityliving.worldObj.isRemote) {
AMCore.proxy.addDeferredPotionEffect(entityliving, new PotionEffect(Potion.hunger.id, 200, 1));
AMCore.proxy.addDeferredPotionEffect(entityliving, new PotionEffect(Potion.confusion.id, 200, 1));
}
}
Aggregations