本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.getActivePotionEffect方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.getActivePotionEffect方法的具体用法?Java EntityLivingBase.getActivePotionEffect怎么用?Java EntityLivingBase.getActivePotionEffect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getActivePotionEffect方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyEffects
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void applyEffects(EntityLivingBase target, EntityLivingBase source, EntityLivingBase indirectsource) {
for (CaskPotionEffect effect : effects)
{
PotionEffect potioneffect = effect.potionEffect;
PotionEffect currentStack = target.getActivePotionEffect(potioneffect.getPotion());
if (potioneffect.getPotion().isInstant())
{
potioneffect.getPotion().affectEntity(source, indirectsource, target, potioneffect.getAmplifier(), 1.0D);
}
else
{
int amplifier = currentStack.getAmplifier();
int duration = currentStack.getDuration();
if(currentStack != null)
{
amplifier = Math.min(amplifier + currentStack.getAmplifier() + 1,effect.maxStack);
if(amplifier != currentStack.getAmplifier())
duration += currentStack.getDuration();
}
PotionEffect newStack = new PotionEffect(potioneffect.getPotion(),duration,amplifier,false,false); //TODO: curative item?? alchemical hangover cure???
target.addPotionEffect(newStack);
}
}
}
示例2: onItemUse
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemUse(LivingEntityUseItemEvent event)
{
EntityLivingBase living = event.getEntityLiving();
ItemStack stack = event.getItem();
PotionEffect effect = living.getActivePotionEffect(this);
if(ItemUtil.matchesOreDict(stack,"torch") && effect != null)
{
//TODO: Blow a cloud of fire out
if(effect.getDuration() > 10)
{
PotionEffect reducedEffect = new PotionEffect(this, effect.getDuration() - 5, effect.getAmplifier(), effect.getIsAmbient(), effect.doesShowParticles());
reducedEffect.setCurativeItems(effect.getCurativeItems());
living.addPotionEffect(reducedEffect);
}
else
{
living.removePotionEffect(this);
}
}
}
示例3: apply
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Applies all effects in the bottle to the entity; if the bottle has both a potion and a spirit, both are applied.
*/
public void apply(ItemStack bottle, EntityLivingBase entity) {
if (entity.world.isRemote) return;
Spirit spirit = getSpirit(bottle);
if (spirit!=null) {
if (spirit.isAlcoholic()) {
PotionEffect effect = entity.getActivePotionEffect(Thermionics.POTION_TIPSY);
int curStrength = 0;
if (effect!=null) {
curStrength = effect.getAmplifier();
}
entity.removeActivePotionEffect(Thermionics.POTION_TIPSY);
entity.addPotionEffect( new PotionEffect(Thermionics.POTION_TIPSY, 20*30, curStrength+1));
}
}
for (PotionEffect potion : PotionUtils.getEffectsFromStack(bottle)) {
if (potion.getPotion().isInstant()) {
potion.getPotion().affectEntity(entity, entity, entity, potion.getAmplifier(), 1.0D);
} else {
entity.addPotionEffect(new PotionEffect(potion));
}
}
}
示例4: applyPotionEffect
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void applyPotionEffect(EntityLivingBase entitylivingbase, ShotPotion pot)
{
if (entitylivingbase == null) { return; } // Not a valid entity, for some reason
if (pot == null) { return; } // Nothing to apply
PotionEffect potion = entitylivingbase.getActivePotionEffect(pot.potion);
if (potion != null) // Already exists. Extending it
{
int dur = potion.getDuration();
entitylivingbase.addPotionEffect( new PotionEffect(pot.potion.id, pot.Duration + dur, pot.Strength - 1, false) );
}
else { entitylivingbase.addPotionEffect( new PotionEffect(pot.potion.id, pot.Duration, pot.Strength - 1, false) ); } // Fresh
}
示例5: calculateCritPre
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static int calculateCritPre(ItemStack stack, EntityLivingBase living) {
int thisCritical = 0;
if (living.getActivePotionEffect(TF2weapons.crit) != null || living.getActivePotionEffect(TF2weapons.buffbanner) != null)
thisCritical = 1;
if ( thisCritical == 0 && (living.getCapability(TF2weapons.WEAPONS_CAP, null).focusedShot(stack) || living.getCapability(TF2weapons.WEAPONS_CAP, null).focusShotRemaining>0))
thisCritical = 1;
if (TF2ConfigVars.randomCrits && !stack.isEmpty() && stack.getItem() instanceof ItemWeapon) {
ItemWeapon item = (ItemWeapon) stack.getItem();
if ((!item.rapidFireCrits(stack) && item.hasRandomCrits(stack, living) && living.getRNG().nextFloat() <= item.critChance(stack, living))
|| living.getCapability(TF2weapons.WEAPONS_CAP, null).getCritTime() > 0)
thisCritical = 2;
}
if (living.getActivePotionEffect(TF2weapons.critBoost) != null)
thisCritical = 2;
if (!stack.isEmpty() && (!(stack.getItem() instanceof ItemWeapon) || stack.getItem() instanceof ItemMeleeWeapon)
&& (living.getActivePotionEffect(TF2weapons.charging) != null || living.getCapability(TF2weapons.WEAPONS_CAP, null).ticksBash > 0))
if (thisCritical < 2 && (living.getCapability(TF2weapons.WEAPONS_CAP, null).ticksBash > 0 && living.getCapability(TF2weapons.WEAPONS_CAP, null).bashCritical)
|| (living.getActivePotionEffect(TF2weapons.charging) != null && living.getActivePotionEffect(TF2weapons.charging).getDuration() < 14))
thisCritical = 2;
else if (thisCritical == 0 && (living.getCapability(TF2weapons.WEAPONS_CAP, null).ticksBash > 0 || living.getActivePotionEffect(TF2weapons.charging).getDuration() < 35))
thisCritical = 1;
return thisCritical;
}
示例6: doChargeTick
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void doChargeTick(EntityLivingBase player) {
if (player == Minecraft.getMinecraft().player) {
if (player.getActivePotionEffect(TF2weapons.charging) != null
&& !(Minecraft.getMinecraft().player.movementInput instanceof MovementInputCharging)) {
player.getCapability(TF2weapons.PLAYER_CAP,
null).lastMovementInput = Minecraft.getMinecraft().player.movementInput;
Minecraft.getMinecraft().player.movementInput = new MovementInputCharging();
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSprint.getKeyCode(), true);
Minecraft.getMinecraft().gameSettings.mouseSensitivity *= 0.1f;
} else if (player.getActivePotionEffect(TF2weapons.charging) == null
&& player.getCapability(TF2weapons.PLAYER_CAP, null).lastMovementInput != null) {
Minecraft.getMinecraft().player.movementInput = player.getCapability(TF2weapons.PLAYER_CAP,
null).lastMovementInput;
player.getCapability(TF2weapons.PLAYER_CAP, null).lastMovementInput = null;
Minecraft.getMinecraft().gameSettings.mouseSensitivity *= 10f;
}
//Minecraft.getMinecraft().player.movementInput.moveForward = 1f;
}
}
示例7: stopJump
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void stopJump(LivingEvent.LivingJumpEvent event) {
EntityLivingBase living=event.getEntityLiving();
if ((living.getActivePotionEffect(TF2weapons.stun) != null && living.getActivePotionEffect(TF2weapons.bombmrs) == null)
|| living.getActivePotionEffect(TF2weapons.charging) != null
|| (living.getHeldItemMainhand() != null && living.getHeldItemMainhand().getItem() instanceof ItemMinigun
&& living.hasCapability(TF2weapons.WEAPONS_CAP, null) && living.getCapability(TF2weapons.WEAPONS_CAP, null).chargeTicks > 0)) {
living.isAirBorne = false;
living.motionY -= 0.5f;
if (living.isSprinting()) {
float f = living.rotationYaw * 0.017453292F;
living.motionX += MathHelper.sin(f) * 0.2F;
living.motionZ -= MathHelper.cos(f) * 0.2F;
}
}
}
示例8: performEffect
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void performEffect(EntityLivingBase living, int amplifier) {
PotionEffect effect = living.getActivePotionEffect(this);
if(effect != null) //Why are you here?
{
if(effect.getDuration() == 1)
{
living.addPotionEffect(new PotionEffect(MobEffects.NAUSEA,1000));
}
}
super.performEffect(living, amplifier);
}
示例9: onWornTick
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
if (itemstack.getItemDamage() == 0 && player.ticksExisted % 40 == 0) {
if (player.getActivePotionEffect(MobEffects.UNLUCK) != null) {
player.removePotionEffect(MobEffects.UNLUCK);
}
}
}
示例10: onFovModifier
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onFovModifier(EntityViewRenderEvent.FOVModifier event) {
if (event.getEntity() instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase)event.getEntity();
if (living.getActivePotionEffect(Thermionics.POTION_EFFORTLESS_SPEED)!=null) {
event.setFOV( Minecraft.getMinecraft().gameSettings.fovSetting );
}
}
}
示例11: canInteract
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static boolean canInteract(EntityLivingBase entity) {
return !(entity instanceof EntityPlayer && ((EntityPlayer)entity).isSpectator())
&& entity.getActivePotionEffect(TF2weapons.stun) == null && (!entity.hasCapability(TF2weapons.WEAPONS_CAP, null)
|| (WeaponsCapability.get(entity).invisTicks == 0 && !WeaponsCapability.get(entity).isFeign())) && entity.getActivePotionEffect(TF2weapons.bonk) == null;
}
示例12: onUpdate
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
if (par1ItemStack.isEmpty())
return;
if (par5 && !this.canFire(par2World, (EntityLivingBase) par3Entity, par1ItemStack)) {
par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null).setHealTarget(-1);
}
Potion effect=Potion.getPotionFromResourceLocation(ItemFromData.getData(par1ItemStack).getString(PropertyType.EFFECT_TYPE));
if (!par2World.isRemote&&par1ItemStack.getTagCompound().getBoolean("Activated")) {
par1ItemStack.getTagCompound().setFloat("ubercharge",
Math.max(0, par1ItemStack.getTagCompound().getFloat("ubercharge") - 0.00625f));
if(par5 && effect != null && par3Entity.ticksExisted%4==0)
((EntityLivingBase)par3Entity).addPotionEffect(new PotionEffect(effect,15));
if (par1ItemStack.getTagCompound().getFloat("ubercharge") == 0) {
par1ItemStack.getTagCompound().setBoolean("Activated", false);
TF2Util.playSound(par3Entity,ItemFromData.getSound(par1ItemStack, PropertyType.UBER_STOP_SOUND), 1.5f, 1);
((EntityLivingBase)par3Entity).removePotionEffect(effect);
// TF2weapons.sendTracking(new
// TF2Message.PropertyMessage("UberCharged",
// (byte)0,par3Entity),par3Entity);
}
}
if(par5){
Entity healTargetEnt = par2World.getEntityByID(par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null).getHealTarget());
if(healTargetEnt != null && healTargetEnt instanceof EntityLivingBase){
EntityLivingBase healTarget=(EntityLivingBase) healTargetEnt;
// System.out.println("healing:
// "+ItemUsable.itemProperties.server.get(par3Entity).getInteger("HealTarget"));
if (!par2World.isRemote && healTarget != null && par3Entity.getDistanceSqToEntity(healTarget) > 72) {
par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null).setHealTarget(-1);
// TF2weapons.sendTracking(new
// TF2Message.PropertyMessage("HealTarget",
// -1,par3Entity),par3Entity);
} else if (healTarget != null && healTarget instanceof EntityLivingBase) {
if(!par2World.isRemote)
this.heal(par1ItemStack, (EntityLivingBase) par3Entity, par2World, (EntityLivingBase) healTarget);
if (effect != null && par1ItemStack.getTagCompound().getBoolean("Activated") && (healTarget.getActivePotionEffect(effect)==null||healTarget.ticksExisted%4==0))
healTarget.addPotionEffect(new PotionEffect(effect,15));
// TF2weapons.sendTracking(new
// TF2Message.PropertyMessage("UberCharged",
// (byte)1,healTarget),healTarget);
}
}
}
}