本文整理匯總了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);
}
}
示例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))));
}
}
示例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);
}
}
}
示例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;
}
}
示例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);
}
示例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));
}
}
示例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");
}
示例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();
}
}
示例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));
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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());
}
示例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);
}
}
}
示例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;
}
}
示例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);
}
}