当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.getActivePotionEffect方法代码示例

本文整理汇总了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);
			}
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:19,代码来源:ItemRemedyTalisman.java

示例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));
    }
}
 
开发者ID:cubex2,项目名称:chesttransporter,代码行数:9,代码来源:ItemChestTransporter.java

示例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;
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:11,代码来源:UCEventHandlerServer.java

示例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));
                }
            }
        }
    }
}
 
开发者ID:Ellpeck,项目名称:TrustCircle,代码行数:42,代码来源:Events.java


注:本文中的net.minecraft.entity.player.EntityPlayer.getActivePotionEffect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。