本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.getActivePotionEffect方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.getActivePotionEffect方法的具体用法?Java EntityPlayer.getActivePotionEffect怎么用?Java EntityPlayer.getActivePotionEffect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.getActivePotionEffect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onWornTick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
if (player.ticksExisted % 40 == 0 && player instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) player;
boolean flag = p.getActivePotionEffect(MobEffects.POISON) != null || p.getActivePotionEffect(MobEffects.NAUSEA) != null || p.getActivePotionEffect(MobEffects.WITHER) != null || p.getActivePotionEffect(MobEffects.BLINDNESS) != null || p.getActivePotionEffect(MobEffects.WEAKNESS) != null;
p.removePotionEffect(MobEffects.NAUSEA);
p.removePotionEffect(MobEffects.WITHER);
p.removePotionEffect(MobEffects.BLINDNESS);
p.removePotionEffect(MobEffects.POISON);
p.removePotionEffect(MobEffects.WEAKNESS);
if (flag) {
itemstack.setItemDamage(itemstack.getItemDamage() + 1);
if (itemstack.getItemDamage() >= itemstack.getMaxDamage()) {
itemstack.setCount(0);
}
}
}
}
示例2: addEffect
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private void addEffect(EntityPlayer player, Potion potion, int amplifier)
{
PotionEffect effect = player.getActivePotionEffect(potion);
if (effect == null || effect.getDuration() < 20)
{
player.addPotionEffect(new PotionEffect(potion, 20 * 3, amplifier));
}
}
示例3: onPlayerJump
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerJump(LivingJumpEvent event) {
if (!(event.getEntityLiving() instanceof EntityPlayer))
return;
EntityPlayer player = (EntityPlayer)event.getEntityLiving();
if (player.getActivePotionEffect(MobEffects.SLOWNESS) != null && player.getActivePotionEffect(MobEffects.SLOWNESS).getAmplifier() >= 4)
player.motionY = 0;
}
示例4: onPlayerUpdate
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerUpdate(LivingUpdateEvent event){
EntityLivingBase entity = event.getEntityLiving();
if(entity != null && !entity.worldObj.isRemote && entity instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)entity;
if(player.worldObj.getTotalWorldTime()%TrustCircle.updateInterval == 0){
double modifier = 0;
for(EntityPlayer other : player.worldObj.playerEntities){
if(other != player && !other.isSpectator()){
if(doesTeamWork(player.getTeam(), other.getTeam())){
double dist = other.getDistanceSq(player.posX, player.posY, player.posZ);
if(dist <= TrustCircle.maxRange*TrustCircle.maxRange){
double mod = dist <= 0 ? 1 : (1/Math.sqrt(dist));
modifier += mod*TrustCircle.baseCalcModifier;
if(!TrustCircle.allowMultiplePlayers){
break;
}
}
}
}
}
if(modifier > 0){
int amplifier = Math.min(3, MathHelper.ceiling_double_int(modifier*TrustCircle.amplifierModifier)-1);
int duration = Math.max(TrustCircle.updateInterval+1, MathHelper.ceiling_double_int(modifier*TrustCircle.durationModifier));
PotionEffect active = player.getActivePotionEffect(TrustCircle.potionTrust);
boolean ampChange = active != null && active.getAmplifier() != amplifier;
if(active == null || ampChange || active.getDuration() <= TrustCircle.updateInterval){
if(ampChange){
player.removePotionEffect(TrustCircle.potionTrust);
}
player.addPotionEffect(new PotionEffect(TrustCircle.potionTrust, duration, amplifier, true, true));
}
}
}
}
}