本文整理匯總了Java中net.minecraft.potion.PotionEffect.getDuration方法的典型用法代碼示例。如果您正苦於以下問題:Java PotionEffect.getDuration方法的具體用法?Java PotionEffect.getDuration怎麽用?Java PotionEffect.getDuration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.potion.PotionEffect
的用法示例。
在下文中一共展示了PotionEffect.getDuration方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applyPotionEffect
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
public static void applyPotionEffect(EntityLivingBase entitylivingbase, ShotPotion pot)
{
if (entitylivingbase == null) { return; } // Not a valid entity, for some reason
if (pot == null) { return; } // Nothing to apply
PotionEffect potion = entitylivingbase.getActivePotionEffect(pot.potion);
if (potion != null) // Already exists. Extending it
{
int dur = potion.getDuration();
entitylivingbase.addPotionEffect( new PotionEffect(pot.potion.id, pot.Duration + dur, pot.Strength - 1, false) );
}
else { entitylivingbase.addPotionEffect( new PotionEffect(pot.potion.id, pot.Duration, pot.Strength - 1, false) ); } // Fresh
}
示例2: 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);
}
}
}
示例3: onItemUse
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
@SubscribeEvent
public void onItemUse(LivingEntityUseItemEvent event)
{
EntityLivingBase living = event.getEntityLiving();
ItemStack stack = event.getItem();
PotionEffect effect = living.getActivePotionEffect(this);
if(ItemUtil.matchesOreDict(stack,"torch") && effect != null)
{
//TODO: Blow a cloud of fire out
if(effect.getDuration() > 10)
{
PotionEffect reducedEffect = new PotionEffect(this, effect.getDuration() - 5, effect.getAmplifier(), effect.getIsAmbient(), effect.doesShowParticles());
reducedEffect.setCurativeItems(effect.getCurativeItems());
living.addPotionEffect(reducedEffect);
}
else
{
living.removePotionEffect(this);
}
}
}
示例4: S1DPacketEntityEffect
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
public S1DPacketEntityEffect(int entityIdIn, PotionEffect effect)
{
this.entityId = entityIdIn;
this.effectId = (byte)(effect.getPotionID() & 255);
this.amplifier = (byte)(effect.getAmplifier() & 255);
if (effect.getDuration() > 32767)
{
this.duration = 32767;
}
else
{
this.duration = effect.getDuration();
}
this.hideParticles = (byte)(effect.getIsShowParticles() ? 1 : 0);
}
示例5: performEffect
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
@Override
public void performEffect(EntityLivingBase living, int amplifier) {
PotionEffect effect = living.getActivePotionEffect(this);
if(effect != null) //Why are you here?
{
if(effect.getDuration() == 1)
{
living.addPotionEffect(new PotionEffect(MobEffects.NAUSEA,1000));
}
}
super.performEffect(living, amplifier);
}
示例6: copyBrew
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
private Object copyBrew(Object brew) {
if (brew instanceof PotionEffect) {
PotionEffect potion = (PotionEffect) brew;
return new PotionEffect(potion.getPotion(), potion.getDuration(), potion.getAmplifier());
}
return ((BrewEffect) brew).copy();
}
示例7: SPacketEntityEffect
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
public SPacketEntityEffect(int entityIdIn, PotionEffect effect)
{
this.entityId = entityIdIn;
this.effectId = (byte)(Potion.getIdFromPotion(effect.getPotion()) & 255);
this.amplifier = (byte)(effect.getAmplifier() & 255);
if (effect.getDuration() > 32767)
{
this.duration = 32767;
}
else
{
this.duration = effect.getDuration();
}
this.flags = 0;
if (effect.getIsAmbient())
{
this.flags = (byte)(this.flags | 1);
}
if (effect.doesShowParticles())
{
this.flags = (byte)(this.flags | 2);
}
}
示例8: onPlayerUpdate
import net.minecraft.potion.PotionEffect; //導入方法依賴的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));
}
}
}
}
}
示例9: updatePotionEffects
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
protected void updatePotionEffects()
{
Iterator<Integer> iterator = this.activePotionsMap.keySet().iterator();
while (iterator.hasNext())
{
Integer integer = (Integer)iterator.next();
PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(integer);
if (!potioneffect.onUpdate(this))
{
if (!this.worldObj.isRemote)
{
iterator.remove();
this.onFinishedPotionEffect(potioneffect);
}
}
else if (potioneffect.getDuration() % 600 == 0)
{
this.onChangedPotionEffect(potioneffect, false);
}
}
if (this.potionsNeedUpdate)
{
if (!this.worldObj.isRemote)
{
this.updatePotionMetadata();
}
this.potionsNeedUpdate = false;
}
int i = this.dataWatcher.getWatchableObjectInt(7);
boolean flag1 = this.dataWatcher.getWatchableObjectByte(8) > 0;
if (i > 0)
{
boolean flag = false;
if (!this.isInvisible())
{
flag = this.rand.nextBoolean();
}
else
{
flag = this.rand.nextInt(15) == 0;
}
if (flag1)
{
flag &= this.rand.nextInt(5) == 0;
}
if (flag && i > 0)
{
double d0 = (double)(i >> 16 & 255) / 255.0D;
double d1 = (double)(i >> 8 & 255) / 255.0D;
double d2 = (double)(i >> 0 & 255) / 255.0D;
this.worldObj.spawnParticle(flag1 ? EnumParticleTypes.SPELL_MOB_AMBIENT : EnumParticleTypes.SPELL_MOB, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, d0, d1, d2, new int[0]);
}
}
}
示例10: updatePotionEffects
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
protected void updatePotionEffects()
{
Iterator<Potion> iterator = this.activePotionsMap.keySet().iterator();
try
{
while (iterator.hasNext())
{
Potion potion = (Potion)iterator.next();
PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(potion);
if (!potioneffect.onUpdate(this))
{
if (!this.world.isRemote)
{
iterator.remove();
this.onFinishedPotionEffect(potioneffect);
}
}
else if (potioneffect.getDuration() % 600 == 0)
{
this.onChangedPotionEffect(potioneffect, false);
}
}
}
catch (ConcurrentModificationException var11)
{
;
}
if (this.potionsNeedUpdate)
{
if (!this.world.isRemote)
{
this.updatePotionMetadata();
}
this.potionsNeedUpdate = false;
}
int i = ((Integer)this.dataManager.get(POTION_EFFECTS)).intValue();
boolean flag1 = ((Boolean)this.dataManager.get(HIDE_PARTICLES)).booleanValue();
if (i > 0)
{
boolean flag;
if (this.isInvisible())
{
flag = this.rand.nextInt(15) == 0;
}
else
{
flag = this.rand.nextBoolean();
}
if (flag1)
{
flag &= this.rand.nextInt(5) == 0;
}
if (flag && i > 0)
{
double d0 = (double)(i >> 16 & 255) / 255.0D;
double d1 = (double)(i >> 8 & 255) / 255.0D;
double d2 = (double)(i >> 0 & 255) / 255.0D;
this.world.spawnParticle(flag1 ? EnumParticleTypes.SPELL_MOB_AMBIENT : EnumParticleTypes.SPELL_MOB, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, d0, d1, d2, new int[0]);
}
}
}
示例11: onImpact
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected void onImpact(MovingObjectPosition p_70184_1_)
{
if (!this.worldObj.isRemote)
{
List<PotionEffect> list = Items.potionitem.getEffects(this.potionDamage);
if (list != null && !list.isEmpty())
{
AxisAlignedBB axisalignedbb = this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D);
List<EntityLivingBase> list1 = this.worldObj.<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
if (!list1.isEmpty())
{
for (EntityLivingBase entitylivingbase : list1)
{
double d0 = this.getDistanceSqToEntity(entitylivingbase);
if (d0 < 16.0D)
{
double d1 = 1.0D - Math.sqrt(d0) / 4.0D;
if (entitylivingbase == p_70184_1_.entityHit)
{
d1 = 1.0D;
}
for (PotionEffect potioneffect : list)
{
int i = potioneffect.getPotionID();
if (Potion.potionTypes[i].isInstant())
{
Potion.potionTypes[i].affectEntity(this, this.getThrower(), entitylivingbase, potioneffect.getAmplifier(), d1);
}
else
{
int j = (int)(d1 * (double)potioneffect.getDuration() + 0.5D);
if (j > 20)
{
entitylivingbase.addPotionEffect(new PotionEffect(i, j, potioneffect.getAmplifier()));
}
}
}
}
}
}
}
this.worldObj.playAuxSFX(2002, new BlockPos(this), this.getPotionDamage());
this.setDead();
}
}
示例12: renderPotionEffects
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
protected void renderPotionEffects(ScaledResolution resolution)
{
Collection<PotionEffect> collection = this.mc.thePlayer.getActivePotionEffects();
if (!collection.isEmpty())
{
this.mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
GlStateManager.enableBlend();
int i = 0;
int j = 0;
for (PotionEffect potioneffect : Ordering.natural().reverse().sortedCopy(collection))
{
Potion potion = potioneffect.getPotion();
if (!potion.shouldRenderHUD(potioneffect)) continue;
// Rebind in case previous renderHUDEffect changed texture
this.mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
if (potioneffect.doesShowParticles())
{
int k = resolution.getScaledWidth();
int l = 1;
int i1 = potion.getStatusIconIndex();
if (potion.isBeneficial())
{
++i;
k = k - 25 * i;
}
else
{
++j;
k = k - 25 * j;
l += 26;
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float f = 1.0F;
if (potioneffect.getIsAmbient())
{
this.drawTexturedModalRect(k, l, 165, 166, 24, 24);
}
else
{
this.drawTexturedModalRect(k, l, 141, 166, 24, 24);
if (potioneffect.getDuration() <= 200)
{
int j1 = 10 - potioneffect.getDuration() / 20;
f = MathHelper.clamp_float((float)potioneffect.getDuration() / 10.0F / 5.0F * 0.5F, 0.0F, 0.5F) + MathHelper.cos((float)potioneffect.getDuration() * (float)Math.PI / 5.0F) * MathHelper.clamp_float((float)j1 / 10.0F * 0.25F, 0.0F, 0.25F);
}
}
GlStateManager.color(1.0F, 1.0F, 1.0F, f);
// FORGE - Move status icon check down from above so renderHUDEffect will still be called without a status icon
if (potion.hasStatusIcon())
this.drawTexturedModalRect(k + 3, l + 3, i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
potion.renderHUDEffect(k, l, potioneffect, mc, f);
}
}
}
}
示例13: onRender
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
@EventTarget
public void onRender(EventRender2D e) {
if (!client.getManagers().getManager(SettingManager.class).getSetting(HUD.class, "PotionEffect").getBooleanValue()) {
int x = e.width - 20;
for (PotionEffect p : Minecraft.getMinecraft().thePlayer.getActivePotionEffects()) {
Potion potion = Potion.potionTypes[p.getPotionID()];
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (potion.hasStatusIcon()) {
RenderUtils.drawFullCircle(x + 5, e.height - 11, 10, ColorUtils.backColor);
RenderUtils.drawCircle(x + 5, e.height - 11, 10, ColorUtils.arrayColor);
GL11.glColor4f(1, 1, 1, 1);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableLighting();
int i1 = potion.getStatusIconIndex();
GL11.glScalef((float) 0.8f, (float) 0.8f, (float) 0.8f);
GlStateManager.enableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(inventoryBackground);
Gui.drawTexturedModalRect1((int) (x * 1.25f) - 2, (int) (e.height * 1.25f) - 23, 0 + i1 % 8 * 18,
198 + i1 / 8 * 18, 18, 18);
GL11.glScalef((float) 1.25f, (float) 1.25f, (float) 1.25f);
GlStateManager.disableBlend();
int i = p.getDuration() / 20;
int j = i / 60;
i = i % 60;
String time = (String) (i < 10 ? j + ":0" + i : j + ":" + i);
arraylist.drawStringWithShadow(time, x - arraylist.getStringWidth(time) + 12,
e.height - arraylist.getHeight() - 2, -1);
if (p.getAmplifier() != 0)
arraylist.drawStringWithShadow((p.getAmplifier() + 1) + "",
x - arraylist.getStringWidth((p.getAmplifier() + 1) + "") + 7,
e.height - arraylist.getHeight() - 13, -1);
}
if (Minecraft.getMinecraft().thePlayer.getActivePotionEffects().size() > 5)
x -= 90 / (Minecraft.getMinecraft().thePlayer.getActivePotionEffects().size() - 1);
else
x -= 24;
}
}
}
示例14: updatePotionEffects
import net.minecraft.potion.PotionEffect; //導入方法依賴的package包/類
protected void updatePotionEffects()
{
Iterator<Potion> iterator = this.activePotionsMap.keySet().iterator();
while (iterator.hasNext())
{
Potion potion = (Potion)iterator.next();
PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(potion);
if (!potioneffect.onUpdate(this))
{
if (!this.worldObj.isRemote)
{
iterator.remove();
this.onFinishedPotionEffect(potioneffect);
}
}
else if (potioneffect.getDuration() % 600 == 0)
{
this.onChangedPotionEffect(potioneffect, false);
}
}
if (this.potionsNeedUpdate)
{
if (!this.worldObj.isRemote)
{
this.updatePotionMetadata();
}
this.potionsNeedUpdate = false;
}
int i = ((Integer)this.dataManager.get(POTION_EFFECTS)).intValue();
boolean flag1 = ((Boolean)this.dataManager.get(HIDE_PARTICLES)).booleanValue();
if (i > 0)
{
boolean flag;
if (this.isInvisible())
{
flag = this.rand.nextInt(15) == 0;
}
else
{
flag = this.rand.nextBoolean();
}
if (flag1)
{
flag &= this.rand.nextInt(5) == 0;
}
if (flag && i > 0)
{
double d0 = (double)(i >> 16 & 255) / 255.0D;
double d1 = (double)(i >> 8 & 255) / 255.0D;
double d2 = (double)(i >> 0 & 255) / 255.0D;
this.worldObj.spawnParticle(flag1 ? EnumParticleTypes.SPELL_MOB_AMBIENT : EnumParticleTypes.SPELL_MOB, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, d0, d1, d2, new int[0]);
}
}
}