本文整理汇总了Java中net.minecraft.init.MobEffects类的典型用法代码示例。如果您正苦于以下问题:Java MobEffects类的具体用法?Java MobEffects怎么用?Java MobEffects使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MobEffects类属于net.minecraft.init包,在下文中一共展示了MobEffects类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUpdate
import net.minecraft.init.MobEffects; //导入依赖的package包/类
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (entityIn instanceof EntityLivingBase) {
EntityLivingBase entity = (EntityLivingBase) entityIn;
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (entity.isInWater()) {
entity.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 20 , 5 , false, false));
entity.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 20 , 5 , false, false));
player.capabilities.disableDamage = true;
} else {
player.capabilities.disableDamage = false;
}
}
}
}
示例2: processInteract
import net.minecraft.init.MobEffects; //导入依赖的package包/类
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
ItemStack itemstack = player.getHeldItem(hand);
if (itemstack.getItem() == Items.GOLDEN_APPLE && itemstack.getMetadata() == 0 && this.isPotionActive(MobEffects.WEAKNESS))
{
if (!player.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
if (!this.world.isRemote)
{
this.func_190734_b(this.rand.nextInt(2401) + 3600);
}
return true;
}
else
{
return false;
}
}
示例3: onWornTick
import net.minecraft.init.MobEffects; //导入依赖的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);
}
}
}
}
示例4: processInteract
import net.minecraft.init.MobEffects; //导入依赖的package包/类
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
if (stack != null && stack.getItem() == Items.GOLDEN_APPLE && stack.getMetadata() == 0 && this.isVillager() && this.isPotionActive(MobEffects.WEAKNESS))
{
if (!player.capabilities.isCreativeMode)
{
--stack.stackSize;
}
if (!this.worldObj.isRemote)
{
this.startConversion(this.rand.nextInt(2401) + 3600);
}
return true;
}
else
{
return false;
}
}
示例5: onFoodEaten
import net.minecraft.init.MobEffects; //导入依赖的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));
}
}
}
示例6: apply
import net.minecraft.init.MobEffects; //导入依赖的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);
}
}
示例7: updatePotionMetadata
import net.minecraft.init.MobEffects; //导入依赖的package包/类
/**
* Clears potion metadata values if the entity has no potion effects. Otherwise, updates potion effect color,
* ambience, and invisibility metadata values
*/
protected void updatePotionMetadata()
{
if (this.activePotionsMap.isEmpty())
{
this.resetPotionEffectMetadata();
this.setInvisible(false);
}
else
{
Collection<PotionEffect> collection = this.activePotionsMap.values();
this.dataManager.set(HIDE_PARTICLES, Boolean.valueOf(areAllPotionsAmbient(collection)));
this.dataManager.set(POTION_EFFECTS, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(collection)));
this.setInvisible(this.isPotionActive(MobEffects.INVISIBILITY));
}
}
示例8: affectEntity
import net.minecraft.init.MobEffects; //导入依赖的package包/类
public void affectEntity(@Nullable Entity source, @Nullable Entity indirectSource, EntityLivingBase entityLivingBaseIn, int amplifier, double health)
{
if ((this != MobEffects.INSTANT_HEALTH || entityLivingBaseIn.isEntityUndead()) && (this != MobEffects.INSTANT_DAMAGE || !entityLivingBaseIn.isEntityUndead()))
{
if (this == MobEffects.INSTANT_DAMAGE && !entityLivingBaseIn.isEntityUndead() || this == MobEffects.INSTANT_HEALTH && entityLivingBaseIn.isEntityUndead())
{
int j = (int)(health * (double)(6 << amplifier) + 0.5D);
if (source == null)
{
entityLivingBaseIn.attackEntityFrom(DamageSource.magic, (float)j);
}
else
{
entityLivingBaseIn.attackEntityFrom(DamageSource.causeIndirectMagicDamage(source, indirectSource), (float)j);
}
}
}
else
{
int i = (int)(health * (double)(4 << amplifier) + 0.5D);
entityLivingBaseIn.heal((float)i);
}
}
示例9: attackEntity
import net.minecraft.init.MobEffects; //导入依赖的package包/类
@SubscribeEvent
public void attackEntity(LivingHurtEvent event)
{
try
{
if((event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityLivingBase
&& (((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof BaseHarshenSword ||
((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof HarshenProps)
&&!(Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet
&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate
&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings
&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots)))
event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1));
}
catch (ClassCastException clazz){}
}
示例10: attackEntityAsMob
import net.minecraft.init.MobEffects; //导入依赖的package包/类
public boolean attackEntityAsMob(Entity entityIn)
{
if (super.attackEntityAsMob(entityIn))
{
if (this.getSkeletonType() == SkeletonType.WITHER && entityIn instanceof EntityLivingBase)
{
((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(MobEffects.WITHER, 200));
}
return true;
}
else
{
return false;
}
}
示例11: PlayerDeath
import net.minecraft.init.MobEffects; //导入依赖的package包/类
@HarshenEvent
public void PlayerDeath(LivingDeathEvent event)
{
EntityPlayer player = (EntityPlayer) event.getEntity();
event.setCanceled(true);
if (player instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)player;
entityplayermp.addStat(StatList.getObjectUseStats(Items.TOTEM_OF_UNDYING));
CriteriaTriggers.USED_TOTEM.trigger(entityplayermp, HarshenUtils.getFirstOccuringItem(player, Items.TOTEM_OF_UNDYING));
}
HarshenUtils.setStackInSlot(player, Items.TOTEM_OF_UNDYING, ItemStack.EMPTY);
player.setHealth(1.0F);
player.clearActivePotions();
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 900, 1));
player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 100, 1));
player.world.setEntityState(player, (byte)35);
}
示例12: setRandomEffect
import net.minecraft.init.MobEffects; //导入依赖的package包/类
public void setRandomEffect(Random rand)
{
int i = rand.nextInt(5);
if (i <= 1)
{
this.effect = MobEffects.SPEED;
}
else if (i <= 2)
{
this.effect = MobEffects.STRENGTH;
}
else if (i <= 3)
{
this.effect = MobEffects.REGENERATION;
}
else if (i <= 4)
{
this.effect = MobEffects.INVISIBILITY;
}
}
示例13: onFoodEaten
import net.minecraft.init.MobEffects; //导入依赖的package包/类
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
if (!worldIn.isRemote && worldIn.rand.nextFloat() < 0.75F)
{
int foodAdditions = getFoodAdditions(stack);
int durationTicks = (10 + foodAdditions) * 20;
playerIn.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, durationTicks));
if (foodAdditions >= 2)
{
playerIn.addPotionEffect(new PotionEffect(MobEffects.POISON, durationTicks));
}
if (foodAdditions >= 4)
{
playerIn.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, durationTicks));
}
if (foodAdditions >= 6)
{
playerIn.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, durationTicks));
}
}
}
示例14: onUpdate
import net.minecraft.init.MobEffects; //导入依赖的package包/类
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean par5)
{
if (hasChest(stack) && entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entity;
if (player.capabilities.isCreativeMode)
return;
if (ChestTransporter.debuffSlowness)
addEffect(player, MobEffects.SLOWNESS, 2);
if (ChestTransporter.debuffMiningFatigue)
addEffect(player, MobEffects.MINING_FATIGUE, 3);
if (ChestTransporter.debuffJump)
addEffect(player, MobEffects.JUMP_BOOST, -2);
if (ChestTransporter.debuffHunger)
addEffect(player, MobEffects.HUNGER, 0);
}
}
示例15: tweakVanilla
import net.minecraft.init.MobEffects; //导入依赖的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");
}