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


Java PotionEffect类代码示例

本文整理汇总了Java中net.minecraft.potion.PotionEffect的典型用法代码示例。如果您正苦于以下问题:Java PotionEffect类的具体用法?Java PotionEffect怎么用?Java PotionEffect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PotionEffect类属于net.minecraft.potion包,在下文中一共展示了PotionEffect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onFoodEaten

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
    if (!worldIn.isRemote)
    {
        player.addPotionEffect(new PotionEffect(Potion.absorption.id, 2400, 0));
    }

    if (stack.getMetadata() > 0)
    {
        if (!worldIn.isRemote)
        {
            player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 4));
            player.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0));
            player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0));
        }
    }
    else
    {
        super.onFoodEaten(stack, worldIn, player);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:22,代码来源:ItemAppleGold.java

示例2: readEntityFromNBT

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);

    if (compound.hasKey("Potion", 8))
    {
        this.potion = PotionUtils.getPotionTypeFromNBT(compound);
    }

    for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromTag(compound))
    {
        this.addEffect(potioneffect);
    }

    if (this.potion != PotionTypes.EMPTY || !this.customPotionEffects.isEmpty())
    {
        this.dataManager.set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(this.potion, this.customPotionEffects))));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:EntityTippedArrow.java

示例3: applyEffects

import net.minecraft.potion.PotionEffect; //导入依赖的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);
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:25,代码来源:CaskManager.java

示例4: applyEntityCollision

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
@Override
public void applyEntityCollision(Entity e) {
	if (!(e instanceof EntityLivingBase))
		return;
	EntityLivingBase entity = (EntityLivingBase) e;
	List<PotionEffect> effects = ((LingeringPotion) ModItems.lingering_potion).getEffects(stack);
	boolean addedEffect = false;

	for (PotionEffect effect : effects) {
		int effectID = effect.getPotionID();
		if (Potion.potionTypes[effectID].isInstant()) {
			Potion.potionTypes[effectID].affectEntity(thrower, entity, effect.getAmplifier(), 0.25);
			addedEffect = true;
		} else if (!entity.isPotionActive(effectID)) {
			entity.addPotionEffect(effect);
			addedEffect = true;
		}
	}

	if (addedEffect) {
		int ticks = dataWatcher.getWatchableObjectInt(TICKS_DATA_WATCHER);
		if (setTickCount(ticks + 5 * 20)) // Add 5 seconds to the expiration time (decreasing radius by 0.5 blocks)
			return;
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:26,代码来源:EntityLingeringEffect.java

示例5: convertToVillager

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
/**
 * Convert this zombie into a villager.
 */
protected void convertToVillager()
{
    EntityVillager entityvillager = new EntityVillager(this.worldObj);
    entityvillager.copyLocationAndAnglesFrom(this);
    entityvillager.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null);
    entityvillager.setLookingForHome();

    if (this.isChild())
    {
        entityvillager.setGrowingAge(-24000);
    }

    this.worldObj.removeEntity(this);
    entityvillager.setNoAI(this.isAIDisabled());

    if (this.hasCustomName())
    {
        entityvillager.setCustomNameTag(this.getCustomNameTag());
        entityvillager.setAlwaysRenderNameTag(this.getAlwaysRenderNameTag());
    }

    this.worldObj.spawnEntityInWorld(entityvillager);
    entityvillager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
    this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1017, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:EntityZombie.java

示例6: transferPlayerToDimension

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
/**
 * moves provided player from overworld to nether or vice versa
 */
public void transferPlayerToDimension(EntityPlayerMP playerIn, int dimension)
{
    int i = playerIn.dimension;
    WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension);
    playerIn.dimension = dimension;
    WorldServer worldserver1 = this.mcServer.worldServerForDimension(playerIn.dimension);
    playerIn.playerNetServerHandler.sendPacket(new S07PacketRespawn(playerIn.dimension, playerIn.worldObj.getDifficulty(), playerIn.worldObj.getWorldInfo().getTerrainType(), playerIn.theItemInWorldManager.getGameType()));
    worldserver.removePlayerEntityDangerously(playerIn);
    playerIn.isDead = false;
    this.transferEntityToWorld(playerIn, i, worldserver, worldserver1);
    this.preparePlayer(playerIn, worldserver);
    playerIn.playerNetServerHandler.setPlayerLocation(playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
    playerIn.theItemInWorldManager.setWorld(worldserver1);
    this.updateTimeAndWeatherForPlayer(playerIn, worldserver1);
    this.syncPlayerInventory(playerIn);

    for (PotionEffect potioneffect : playerIn.getActivePotionEffects())
    {
        playerIn.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(playerIn.getEntityId(), potioneffect));
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:ServerConfigurationManager.java

示例7: tweakVanilla

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
public static void tweakVanilla()
{
	((ItemFood) Items.BEEF).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 20);
	((ItemFood) Items.PORKCHOP).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 25);
	((ItemFood) Items.FISH).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 30, 1), 60); // Both fish types here
	((ItemFood) Items.MUTTON).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 25);
	((ItemFood) Items.RABBIT).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 30);

	if(BBConfig.makeStuffStackable)
	{
		// Let's face it, the vanilla stack sizes for these suck.
		Items.MINECART.setMaxStackSize(16);
		// Strangely enough the oak one doesn't change name.
		Items.OAK_DOOR.setMaxStackSize(16);
		Items.SPRUCE_DOOR.setMaxStackSize(16);
		Items.BIRCH_DOOR.setMaxStackSize(16);
		Items.ACACIA_DOOR.setMaxStackSize(16);
		Items.DARK_OAK_DOOR.setMaxStackSize(16);
		Items.IRON_DOOR.setMaxStackSize(16);
	}

	if(BBConfig.moduleFurnaces) Items.FURNACE_MINECART.setUnlocalizedName(ModMain.MODID + ".kilnCart");
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:24,代码来源:RegisterItems.java

示例8: readEntityFromNBT

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);

    if (compound.hasKey("Potion", 8))
    {
        this.potion = PotionUtils.getPotionTypeFromNBT(compound);
    }

    for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromTag(compound))
    {
        this.addEffect(potioneffect);
    }

    if (compound.hasKey("Color", 99))
    {
        this.func_191507_d(compound.getInteger("Color"));
    }
    else
    {
        this.func_190548_o();
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:EntityTippedArrow.java

示例9: onFoodEaten

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
    if (!worldIn.isRemote)
    {
        if (stack.getMetadata() > 0)
        {
            player.addStat(AchievementList.OVERPOWERED);
            player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1));
            player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 6000, 0));
            player.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 6000, 0));
            player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 2400, 3));
        }
        else
        {
            player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 100, 1));
            player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 2400, 0));
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:20,代码来源:ItemAppleGold.java

示例10: fall

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
public void fall(float distance, float damageMultiplier)
{
    super.fall(distance, damageMultiplier);
    PotionEffect potioneffect = this.getActivePotionEffect(Potion.jump);
    float f = potioneffect != null ? (float)(potioneffect.getAmplifier() + 1) : 0.0F;
    int i = MathHelper.ceiling_float_int((distance - 3.0F - f) * damageMultiplier);

    if (i > 0)
    {
        this.playSound(this.getFallSoundString(i), 1.0F, 1.0F);
        this.attackEntityFrom(DamageSource.fall, (float)i);
        int j = MathHelper.floor_double(this.posX);
        int k = MathHelper.floor_double(this.posY - 0.20000000298023224D);
        int l = MathHelper.floor_double(this.posZ);
        Block block = this.worldObj.getBlockState(new BlockPos(j, k, l)).getBlock();

        if (block.getMaterial() != Material.air)
        {
            Block.SoundType block$soundtype = block.stepSound;
            this.playSound(block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F);
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:24,代码来源:EntityLivingBase.java

示例11: onExecutionStart

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
	ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
	EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
	player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 1F);
	Vec3d look = player.getLookVec().scale(5);
	Vec3d pos = player.getPositionVector();
	List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
	EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
	if (assumedToBeLookedAt != null)
	{
		if (!player.world.isRemote)
		{
			assumedToBeLookedAt.addPotionEffect(new PotionEffect(ExPPotions.stunned, weight == EnumWeaponWeight.NORMAL ? 20 : 30, 0, false, false));
		}
		
		player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, SoundCategory.PLAYERS, 1, 1F);
		Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
		assumedToBeLookedAt.knockBack(player, 1, pos.x - targetPos.x, pos.z - targetPos.z);
		for (int i = 0; i < 50; ++i)
		{
			player.world.spawnParticle(EnumParticleTypes.CRIT_MAGIC, targetPos.x + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + assumedToBeLookedAt.getEyeHeight() + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + player.world.rand.nextDouble() - player.world.rand.nextDouble(), 0, -0.1, 0);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:27,代码来源:DownStrike.java

示例12: getEffects

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
@Override
public List<PotionEffect> getEffects(ItemStack stack) {
	if (stack.hasTagCompound() && stack.getTagCompound().hasKey("CustomPotionEffects", 9)) {
		List<PotionEffect> list = new ArrayList<PotionEffect>();
		NBTTagList nbttaglist = stack.getTagCompound().getTagList("CustomPotionEffects", 10);

		for (int i = 0; i < nbttaglist.tagCount(); i++) {
			NBTTagCompound nbt = nbttaglist.getCompoundTagAt(i);
			PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbt);
			if (potioneffect != null)
				list.add(potioneffect);
		}

		return list;
	} else
		return getEffects(stack.getItemDamage());
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:18,代码来源:LingeringPotion.java

示例13: getItemStackDisplayName

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
@Override
public String getItemStackDisplayName(ItemStack stack) {
	if (stack.getItemDamage() == 0)
		return StatCollector.translateToLocal("item.emptyPotion.name").trim();
	else {
		String s = StatCollector.translateToLocal("potion.prefix.lingering").trim() + " ";

		List<PotionEffect> list = getEffects(stack);
		String s1;

		if (list != null && !list.isEmpty()) {
			s1 = list.get(0).getEffectName();
			s1 = s1 + ".postfix";
			return s + StatCollector.translateToLocal(s1).trim();
		} else {
			s1 = PotionHelper.func_77905_c(stack.getItemDamage());
			return StatCollector.translateToLocal(s1).trim() + " " + super.getItemStackDisplayName(stack);
		}
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:21,代码来源:LingeringPotion.java

示例14: isEffectInstant

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
public boolean isEffectInstant(int meta)
{
    List<PotionEffect> list = this.getEffects(meta);

    if (list != null && !list.isEmpty())
    {
        for (PotionEffect potioneffect : list)
        {
            if (Potion.potionTypes[potioneffect.getPotionID()].isInstant())
            {
                return true;
            }
        }

        return false;
    }
    else
    {
        return false;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:ItemPotion.java

示例15: apply

import net.minecraft.potion.PotionEffect; //导入依赖的package包/类
@Override
public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) {
	if (amplifier >= 3) {
		if (entity instanceof EntityWitch) {
			entity.setFire(500);
			entity.attackEntityFrom(DamageSource.MAGIC, 20);
		} else if (entity.getCreatureAttribute() == EnumCreatureAttribute.ILLAGER) {
			entity.addPotionEffect(new PotionEffect(MobEffects.WITHER, 1500, 0));
			entity.attackEntityFrom(DamageSource.MAGIC, 20);
		}
	} else if (amplifier == 2 && entity.getCreatureAttribute() == EnumCreatureAttribute.ILLAGER || entity instanceof EntityWitch) {
		entity.attackEntityFrom(DamageSource.MAGIC, 16);
	} else if (entity.getCreatureAttribute() == EnumCreatureAttribute.ILLAGER) {
		entity.attackEntityFrom(DamageSource.MAGIC, 10);
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:17,代码来源:OutcastsShameBrew.java


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