initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
406
java/src/game/potion/Potion.java
Executable file
406
java/src/game/potion/Potion.java
Executable file
|
@ -0,0 +1,406 @@
|
|||
package game.potion;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import game.collect.Maps;
|
||||
import game.entity.DamageSource;
|
||||
import game.entity.attributes.Attribute;
|
||||
import game.entity.attributes.AttributeInstance;
|
||||
import game.entity.attributes.AttributeMap;
|
||||
import game.entity.attributes.AttributeModifier;
|
||||
import game.entity.attributes.Attributes;
|
||||
import game.entity.projectile.EntityPotion;
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.init.Config;
|
||||
|
||||
public class Potion
|
||||
{
|
||||
public static final Potion[] POTION_TYPES = new Potion[32];
|
||||
private static final Map<String, Potion> POTION_MAP = Maps.<String, Potion>newHashMap();
|
||||
|
||||
// public static final Potion field_180151_b = null;
|
||||
|
||||
public static final Potion moveSpeed = (new Potion(1, "speed", false, 8171462))
|
||||
.setPotionName("potion.moveSpeed", "Schnelligkeit", "Trank der Schnelligkeit").setIconIndex(0, 0).registerPotionAttributeModifier(Attributes.MOVEMENT_SPEED, "PotSpd", 0.20000000298023224D, true);
|
||||
public static final Potion moveSlowdown = (new Potion(2, "slowness", true, 5926017))
|
||||
.setPotionName("potion.moveSlowdown", "Langsamkeit", "Trank der Langsamkeit").setIconIndex(1, 0).registerPotionAttributeModifier(Attributes.MOVEMENT_SPEED, "PotSlow", -0.15000000596046448D, true);
|
||||
public static final Potion digSpeed = (new Potion(3, "haste", false, 14270531))
|
||||
.setPotionName("potion.digSpeed", "Eile", "Trank der Eile").setIconIndex(2, 0).setEffectiveness(1.5D);
|
||||
public static final Potion digSlowdown = (new Potion(4, "mining_fatigue", true, 4866583))
|
||||
.setPotionName("potion.digSlowDown", "Abbaulähmung", "Trank der Trägheit").setIconIndex(3, 0);
|
||||
public static final Potion damageBoost = (new PotionAttackDamage(5, "strength", false, 9643043))
|
||||
.setPotionName("potion.damageBoost", "Stärke", "Trank der Stärke").setIconIndex(4, 0).registerPotionAttributeModifier(Attributes.ATTACK_DAMAGE, "PotDmg", 2.5D, true);
|
||||
public static final Potion heal = (new PotionHealth(6, "instant_health", false, 16262179))
|
||||
.setPotionName("potion.heal", "Direktheilung", "Trank der Heilung");
|
||||
public static final Potion harm = (new PotionHealth(7, "instant_damage", true, 4393481))
|
||||
.setPotionName("potion.harm", "Direktschaden", "Trank des Schadens");
|
||||
public static final Potion jump = (new Potion(8, "jump_boost", false, 2293580))
|
||||
.setPotionName("potion.jump", "Sprungkraft", "Trank der Sprungkraft").setIconIndex(2, 1);
|
||||
public static final Potion confusion = (new Potion(9, "nausea", true, 5578058))
|
||||
.setPotionName("potion.confusion", "Übelkeit", "Trank der Übelkeit").setIconIndex(3, 1).setEffectiveness(0.25D);
|
||||
public static final Potion regeneration = (new Potion(10, "regeneration", false, 13458603))
|
||||
.setPotionName("potion.regeneration", "Regeneration", "Trank der Regeneration").setIconIndex(7, 0).setEffectiveness(0.25D);
|
||||
public static final Potion resistance = (new Potion(11, "resistance", false, 10044730))
|
||||
.setPotionName("potion.resistance", "Resistenz", "Trank des Widerstandes").setIconIndex(6, 1);
|
||||
public static final Potion fireResistance = (new Potion(12, "fire_resistance", false, 14981690))
|
||||
.setPotionName("potion.fireResistance", "Feuerschutz", "Trank der Feuerresistenz").setIconIndex(7, 1);
|
||||
public static final Potion manaBoost = (new Potion(13, "mana_boost", false, 3035801)).setPotionName("potion.manaBoost", "Manaschub", "Trank des Manaschubes").setIconIndex(0, 2);
|
||||
public static final Potion flying = (new Potion(14, "flying", false, 8356754))
|
||||
.setPotionName("potion.flying", "Schweben", "Trank des Schwebens").setIconIndex(0, 1);
|
||||
public static final Potion blindness = (new Potion(15, "blindness", true, 2039587))
|
||||
.setPotionName("potion.blindness", "Blindheit", "Trank der Blindheit").setIconIndex(5, 1).setEffectiveness(0.25D);
|
||||
public static final Potion nightVision = (new Potion(16, "night_vision", false, 2039713))
|
||||
.setPotionName("potion.nightVision", "Nachtsicht", "Trank der Nachtsicht").setIconIndex(4, 1);
|
||||
public static final Potion stability = (new Potion(17, "stability", false, 5797459)).setPotionName("potion.stability", "Stabilität", "Trank der Standfestigkeit").setIconIndex(1, 1).registerPotionAttributeModifier(Attributes.KNOCKBACK_RESISTANCE, "PotStbl", 1.0D, false);
|
||||
public static final Potion weakness = (new PotionAttackDamage(18, "weakness", true, 4738376))
|
||||
.setPotionName("potion.weakness", "Schwäche", "Trank der Schwäche").setIconIndex(5, 0).registerPotionAttributeModifier(Attributes.ATTACK_DAMAGE, "PotWeak", 2.0D, false);
|
||||
public static final Potion poison = (new Potion(19, "poison", true, 5149489))
|
||||
.setPotionName("potion.poison", "Vergiftung", "Trank der Vergiftung").setIconIndex(6, 0).setEffectiveness(0.25D);
|
||||
// public static final Potion wither = (new Potion(20, "wither", true, 3484199)).setPotionName("potion.wither").setIconIndex(1, 2).setEffectiveness(0.25D);
|
||||
public static final Potion healthBoost = (new PotionHealthBoost(21, "health_boost", false, 16284963))
|
||||
.setPotionName("potion.healthBoost", "Extraenergie", "Trank der Extraenergie").setIconIndex(2, 2).registerPotionAttributeModifier(Attributes.MAX_HEALTH, "PotHp", 4, false);
|
||||
public static final Potion absorption = (new PotionAbsorption(22, "absorption", false, 2445989))
|
||||
.setPotionName("potion.absorption", "Absorption", "Trank der Absorption").setIconIndex(2, 2);
|
||||
// public static final Potion saturation = (new PotionHealth(23, "saturation", false, 16262179)).setPotionName("potion.saturation");
|
||||
public static final Potion radiation = (new Potion(24, "radiation", true, 0x00ff00))
|
||||
.setPotionName("potion.radiation", "Strahlung", "Radioaktiver Trank").setIconIndex(3, 2);
|
||||
|
||||
// public static final Potion field_180153_z = null;
|
||||
// public static final Potion field_180147_A = null;
|
||||
// public static final Potion field_180148_B = null;
|
||||
// public static final Potion field_180149_C = null;
|
||||
// public static final Potion field_180143_D = null;
|
||||
// public static final Potion field_180144_E = null;
|
||||
// public static final Potion field_180145_F = null;
|
||||
// public static final Potion field_180146_G = null;
|
||||
|
||||
public final int id;
|
||||
private final Map<Attribute, AttributeModifier> modifiers = Maps.<Attribute, AttributeModifier>newHashMap();
|
||||
private final boolean bad;
|
||||
private final int color;
|
||||
private String name = "";
|
||||
private String display = "";
|
||||
private String potionDisplay = "";
|
||||
// private int icon = 0;
|
||||
private double effectiveness;
|
||||
private boolean usable;
|
||||
|
||||
protected Potion(int potionID, String location, boolean badEffect, int potionColor)
|
||||
{
|
||||
this.id = potionID;
|
||||
POTION_TYPES[potionID] = this;
|
||||
POTION_MAP.put(location, this);
|
||||
this.bad = badEffect;
|
||||
|
||||
if (badEffect)
|
||||
{
|
||||
this.effectiveness = 0.5D;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.effectiveness = 1.0D;
|
||||
}
|
||||
|
||||
this.color = potionColor;
|
||||
}
|
||||
|
||||
public static Potion getPotionFromResourceLocation(String location)
|
||||
{
|
||||
return POTION_MAP.get(location);
|
||||
}
|
||||
|
||||
public static Set<String> getPotionLocations()
|
||||
{
|
||||
return POTION_MAP.keySet();
|
||||
}
|
||||
|
||||
private static String ticksToElapsedTime(int ticks) {
|
||||
int i = ticks / 20;
|
||||
int j = i / 60;
|
||||
i = i % 60;
|
||||
return i < 10 ? j + ":0" + i : j + ":" + i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the index for the icon displayed in the player's inventory when the status is active.
|
||||
*/
|
||||
protected Potion setIconIndex(int color, int p_76399_2_)
|
||||
{
|
||||
// this.icon = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the ID of the potion
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void performEffect(EntityLiving entityLivingBaseIn, int amp)
|
||||
{
|
||||
if (this.id == regeneration.id)
|
||||
{
|
||||
if (entityLivingBaseIn.getHealth() < entityLivingBaseIn.getMaxHealth())
|
||||
{
|
||||
entityLivingBaseIn.heal(1);
|
||||
}
|
||||
}
|
||||
else if (this.id == manaBoost.id)
|
||||
{
|
||||
if (entityLivingBaseIn.getManaPoints() < entityLivingBaseIn.getMaxMana())
|
||||
{
|
||||
entityLivingBaseIn.healMana(1);
|
||||
}
|
||||
}
|
||||
else if (this.id == poison.id)
|
||||
{
|
||||
if ((entityLivingBaseIn.worldObj.client || Config.damagePoison) && entityLivingBaseIn.getHealth() > 1)
|
||||
{
|
||||
entityLivingBaseIn.attackEntityFrom(DamageSource.magic, 1);
|
||||
}
|
||||
}
|
||||
else if (this.id == radiation.id)
|
||||
{
|
||||
if (entityLivingBaseIn.worldObj.client || Config.damageRadiation) // && entityLivingBaseIn.getHealth() > 1.0F)
|
||||
{
|
||||
entityLivingBaseIn.attackEntityFrom(DamageSource.radiation, 1 + amp);
|
||||
}
|
||||
}
|
||||
// else if (this.id == wither.id)
|
||||
// {
|
||||
// if(entityLivingBaseIn.worldObj.client || Config.withering)
|
||||
// entityLivingBaseIn.attackEntityFrom(DamageSource.wither, 1);
|
||||
// }
|
||||
// else if (this.id == hunger.id && entityLivingBaseIn.isPlayer())
|
||||
// {
|
||||
// ((EntityNPC)entityLivingBaseIn).addExhaustion(ExhaustionType.POTION, (float)(amp + 1));
|
||||
// }
|
||||
// else if (this.id == saturation.id && entityLivingBaseIn.isPlayer())
|
||||
// {
|
||||
// if (!entityLivingBaseIn.worldObj.client)
|
||||
// {
|
||||
// ((EntityNPC)entityLivingBaseIn).getFoodStats().addStats(amp + 1, 1.0F);
|
||||
// }
|
||||
// }
|
||||
else if ((this.id != heal.id || entityLivingBaseIn.arePotionsInverted()) && (this.id != harm.id || !entityLivingBaseIn.arePotionsInverted()))
|
||||
{
|
||||
if (this.id == harm.id && !entityLivingBaseIn.arePotionsInverted() || this.id == heal.id && entityLivingBaseIn.arePotionsInverted())
|
||||
{
|
||||
entityLivingBaseIn.attackEntityFrom(DamageSource.magic, 6 << amp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entityLivingBaseIn.heal(Math.max(4 << amp, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public void affectEntity(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect)
|
||||
{
|
||||
if ((this.id != heal.id || entity.arePotionsInverted()) && (this.id != harm.id || !entity.arePotionsInverted()))
|
||||
{
|
||||
if (Config.damagePotion && (this.id == harm.id && !entity.arePotionsInverted() || this.id == heal.id && entity.arePotionsInverted()))
|
||||
{
|
||||
int dmg = (int)(effect * (double)(6 << amp) + 0.5D);
|
||||
|
||||
if (potion == null)
|
||||
{
|
||||
entity.attackEntityFrom(DamageSource.magic, dmg);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.attackEntityFrom(DamageSource.causeIndirectMagicDamage(potion, thrower), dmg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.heal(Math.max((int)(effect * (double)(4 << amp) + 0.5D), 0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the potion has an instant effect instead of a continuous one (eg Harming)
|
||||
*/
|
||||
public boolean isInstant()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if Potion effect is ready to be applied this tick.
|
||||
*/
|
||||
public boolean isReady(int duration, int amp, int ticks)
|
||||
{
|
||||
if (this.id == regeneration.id)
|
||||
{
|
||||
int k = 50 >> amp;
|
||||
return k > 0 ? duration % k == 0 : true;
|
||||
}
|
||||
else if (this.id == manaBoost.id)
|
||||
{
|
||||
int k = 40 >> amp;
|
||||
return k > 0 ? duration % k == 0 : true;
|
||||
}
|
||||
else if (this.id == poison.id)
|
||||
{
|
||||
int j = 25 >> amp;
|
||||
return j > 0 ? duration % j == 0 : true;
|
||||
}
|
||||
else if (this.id == radiation.id)
|
||||
{
|
||||
return ticks % 20 == 0;
|
||||
}
|
||||
// else if (this.id == wither.id)
|
||||
// {
|
||||
// int i = 40 >> amp;
|
||||
// return i > 0 ? duration % i == 0 : true;
|
||||
// }
|
||||
else
|
||||
{
|
||||
return false; // this.id == hunger.id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the potion name.
|
||||
*/
|
||||
public Potion setPotionName(String name, String display, String potion)
|
||||
{
|
||||
this.name = name;
|
||||
this.display = display;
|
||||
this.potionDisplay = potion;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the name of the potion
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDisplay()
|
||||
{
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public String getPotionDisplay()
|
||||
{
|
||||
return this.potionDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the potion has a associated status icon to display in then inventory when active.
|
||||
*/
|
||||
// public boolean hasStatusIcon()
|
||||
// {
|
||||
// return this.icon >= 0;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Returns the index for the icon to display when the potion is active.
|
||||
// */
|
||||
// public int getStatusIconIndex()
|
||||
// {
|
||||
// return this.icon;
|
||||
// }
|
||||
|
||||
/**
|
||||
* This method returns true if the potion effect is bad - negative - for the entity.
|
||||
*/
|
||||
public boolean isBadEffect()
|
||||
{
|
||||
return this.bad;
|
||||
}
|
||||
|
||||
public static String getDurationString(PotionEffect effect)
|
||||
{
|
||||
if (effect.getIsPotionDurationMax())
|
||||
{
|
||||
return "**:**";
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = effect.getDuration();
|
||||
return ticksToElapsedTime(i);
|
||||
}
|
||||
}
|
||||
|
||||
protected Potion setEffectiveness(double effectivenessIn)
|
||||
{
|
||||
this.effectiveness = effectivenessIn;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getEffectiveness()
|
||||
{
|
||||
return this.effectiveness;
|
||||
}
|
||||
|
||||
public boolean isUsable()
|
||||
{
|
||||
return this.usable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color of the potion liquid.
|
||||
*/
|
||||
public int getLiquidColor()
|
||||
{
|
||||
return this.color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by potions to register the attribute they modify.
|
||||
*/
|
||||
public Potion registerPotionAttributeModifier(Attribute attr, String name, double value, boolean multiply)
|
||||
{
|
||||
AttributeModifier mod = new AttributeModifier(AttributeModifier.getModifierId(name), this.getName(), value, multiply);
|
||||
this.modifiers.put(attr, mod);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Map<Attribute, AttributeModifier> getAttributeModifierMap()
|
||||
{
|
||||
return this.modifiers;
|
||||
}
|
||||
|
||||
public void removeAttributesModifiersFromEntity(EntityLiving entityLivingBaseIn, AttributeMap p_111187_2_, int amplifier)
|
||||
{
|
||||
for (Entry<Attribute, AttributeModifier> entry : this.modifiers.entrySet())
|
||||
{
|
||||
AttributeInstance iattributeinstance = p_111187_2_.getAttributeInstance((Attribute)entry.getKey());
|
||||
|
||||
if (iattributeinstance != null)
|
||||
{
|
||||
iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void applyAttributesModifiersToEntity(EntityLiving entityLivingBaseIn, AttributeMap p_111185_2_, int amplifier)
|
||||
{
|
||||
for (Entry<Attribute, AttributeModifier> entry : this.modifiers.entrySet())
|
||||
{
|
||||
AttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((Attribute)entry.getKey());
|
||||
|
||||
if (iattributeinstance != null)
|
||||
{
|
||||
AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
|
||||
iattributeinstance.removeModifier(attributemodifier);
|
||||
iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + amplifier, this.getAttributeModifierAmount(amplifier, attributemodifier), attributemodifier.isMultiplied()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getAttributeModifierAmount(int p_111183_1_, AttributeModifier modifier)
|
||||
{
|
||||
return modifier.getAmount() * (double)(p_111183_1_ + 1);
|
||||
}
|
||||
}
|
25
java/src/game/potion/PotionAbsorption.java
Executable file
25
java/src/game/potion/PotionAbsorption.java
Executable file
|
@ -0,0 +1,25 @@
|
|||
package game.potion;
|
||||
|
||||
import game.entity.attributes.AttributeMap;
|
||||
import game.entity.types.EntityLiving;
|
||||
|
||||
|
||||
public class PotionAbsorption extends Potion
|
||||
{
|
||||
protected PotionAbsorption(int potionID, String location, boolean badEffect, int potionColor)
|
||||
{
|
||||
super(potionID, location, badEffect, potionColor);
|
||||
}
|
||||
|
||||
public void removeAttributesModifiersFromEntity(EntityLiving entityLivingBaseIn, AttributeMap p_111187_2_, int amplifier)
|
||||
{
|
||||
entityLivingBaseIn.setAbsorptionAmount(entityLivingBaseIn.getAbsorptionAmount() - (4 * (amplifier + 1)));
|
||||
super.removeAttributesModifiersFromEntity(entityLivingBaseIn, p_111187_2_, amplifier);
|
||||
}
|
||||
|
||||
public void applyAttributesModifiersToEntity(EntityLiving entityLivingBaseIn, AttributeMap p_111185_2_, int amplifier)
|
||||
{
|
||||
entityLivingBaseIn.setAbsorptionAmount(entityLivingBaseIn.getAbsorptionAmount() + (4 * (amplifier + 1)));
|
||||
super.applyAttributesModifiersToEntity(entityLivingBaseIn, p_111185_2_, amplifier);
|
||||
}
|
||||
}
|
17
java/src/game/potion/PotionAttackDamage.java
Executable file
17
java/src/game/potion/PotionAttackDamage.java
Executable file
|
@ -0,0 +1,17 @@
|
|||
package game.potion;
|
||||
|
||||
import game.entity.attributes.AttributeModifier;
|
||||
|
||||
|
||||
public class PotionAttackDamage extends Potion
|
||||
{
|
||||
protected PotionAttackDamage(int potionID, String location, boolean badEffect, int potionColor)
|
||||
{
|
||||
super(potionID, location, badEffect, potionColor);
|
||||
}
|
||||
|
||||
public double getAttributeModifierAmount(int p_111183_1_, AttributeModifier modifier)
|
||||
{
|
||||
return this.id == Potion.weakness.id ? (double)(-0.5F * (float)(p_111183_1_ + 1)) : 1.3D * (double)(p_111183_1_ + 1);
|
||||
}
|
||||
}
|
252
java/src/game/potion/PotionEffect.java
Executable file
252
java/src/game/potion/PotionEffect.java
Executable file
|
@ -0,0 +1,252 @@
|
|||
package game.potion;
|
||||
|
||||
import game.Log;
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.nbt.NBTTagCompound;
|
||||
|
||||
public class PotionEffect
|
||||
{
|
||||
/** ID value of the potion this effect matches. */
|
||||
private int potionID;
|
||||
|
||||
/** The duration of the potion effect */
|
||||
private int duration;
|
||||
|
||||
/** The amplifier of the potion effect */
|
||||
private int amplifier;
|
||||
|
||||
/** Whether the potion is a splash potion */
|
||||
private boolean isSplashPotion;
|
||||
|
||||
/** Whether the potion effect came from a beacon */
|
||||
private boolean isAmbient;
|
||||
|
||||
/** True if potion effect duration is at maximum, false otherwise. */
|
||||
private boolean isPotionDurationMax;
|
||||
private boolean showParticles;
|
||||
|
||||
public PotionEffect(int id, int effectDuration)
|
||||
{
|
||||
this(id, effectDuration, 0);
|
||||
}
|
||||
|
||||
public PotionEffect(int id, int effectDuration, int effectAmplifier)
|
||||
{
|
||||
this(id, effectDuration, effectAmplifier, false, true);
|
||||
}
|
||||
|
||||
public PotionEffect(int id, int effectDuration, int effectAmplifier, boolean ambient, boolean showParticles)
|
||||
{
|
||||
this.potionID = id;
|
||||
this.duration = effectDuration;
|
||||
this.amplifier = effectAmplifier;
|
||||
this.isAmbient = ambient;
|
||||
this.showParticles = showParticles;
|
||||
}
|
||||
|
||||
public PotionEffect(PotionEffect other)
|
||||
{
|
||||
this.potionID = other.potionID;
|
||||
this.duration = other.duration;
|
||||
this.amplifier = other.amplifier;
|
||||
this.isAmbient = other.isAmbient;
|
||||
this.showParticles = other.showParticles;
|
||||
}
|
||||
|
||||
/**
|
||||
* merges the input PotionEffect into this one if this.amplifier <= tomerge.amplifier. The duration in the supplied
|
||||
* potion effect is assumed to be greater.
|
||||
*/
|
||||
public void combine(PotionEffect other)
|
||||
{
|
||||
if (this.potionID != other.potionID)
|
||||
{
|
||||
Log.JNI.warn("PotionEffect.combine(): Diese Methode sollte nur für gleiche Effekte aufgerufen werden!");
|
||||
}
|
||||
|
||||
if (other.amplifier > this.amplifier)
|
||||
{
|
||||
this.amplifier = other.amplifier;
|
||||
this.duration = other.duration;
|
||||
}
|
||||
else if (other.amplifier == this.amplifier && this.duration < other.duration)
|
||||
{
|
||||
this.duration = other.duration;
|
||||
}
|
||||
else if (!other.isAmbient && this.isAmbient)
|
||||
{
|
||||
this.isAmbient = other.isAmbient;
|
||||
}
|
||||
|
||||
this.showParticles = other.showParticles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the ID of the potion this effect matches.
|
||||
*/
|
||||
public int getPotionID()
|
||||
{
|
||||
return this.potionID;
|
||||
}
|
||||
|
||||
public int getDuration()
|
||||
{
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public int getAmplifier()
|
||||
{
|
||||
return this.amplifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this potion is a splash potion.
|
||||
*/
|
||||
public void setSplashPotion(boolean splashPotion)
|
||||
{
|
||||
this.isSplashPotion = splashPotion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether this potion effect originated from a beacon
|
||||
*/
|
||||
public boolean getIsAmbient()
|
||||
{
|
||||
return this.isAmbient;
|
||||
}
|
||||
|
||||
public boolean getIsShowParticles()
|
||||
{
|
||||
return this.showParticles;
|
||||
}
|
||||
|
||||
public boolean onUpdate(EntityLiving entityIn)
|
||||
{
|
||||
if (this.duration > 0)
|
||||
{
|
||||
if (Potion.POTION_TYPES[this.potionID].isReady(this.duration, this.amplifier, entityIn.ticksExisted))
|
||||
{
|
||||
this.performEffect(entityIn);
|
||||
}
|
||||
|
||||
--this.duration;
|
||||
}
|
||||
|
||||
return this.duration > 0;
|
||||
}
|
||||
|
||||
public void performEffect(EntityLiving entityIn)
|
||||
{
|
||||
if (this.duration > 0)
|
||||
{
|
||||
Potion.POTION_TYPES[this.potionID].performEffect(entityIn, this.amplifier);
|
||||
}
|
||||
}
|
||||
|
||||
public String getEffectName()
|
||||
{
|
||||
return Potion.POTION_TYPES[this.potionID].getDisplay();
|
||||
}
|
||||
|
||||
public String getPotionName()
|
||||
{
|
||||
return Potion.POTION_TYPES[this.potionID].getPotionDisplay();
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return this.potionID;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String s = "";
|
||||
|
||||
if (this.getAmplifier() > 0)
|
||||
{
|
||||
s = this.getEffectName() + " x " + (this.getAmplifier() + 1) + ", Duration: " + this.getDuration();
|
||||
}
|
||||
else
|
||||
{
|
||||
s = this.getEffectName() + ", Duration: " + this.getDuration();
|
||||
}
|
||||
|
||||
if (this.isSplashPotion)
|
||||
{
|
||||
s = s + ", Splash: true";
|
||||
}
|
||||
|
||||
if (!this.showParticles)
|
||||
{
|
||||
s = s + ", Particles: false";
|
||||
}
|
||||
|
||||
return Potion.POTION_TYPES[this.potionID].isUsable() ? "(" + s + ")" : s;
|
||||
}
|
||||
|
||||
public boolean equals(Object p_equals_1_)
|
||||
{
|
||||
if (!(p_equals_1_ instanceof PotionEffect))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
PotionEffect potioneffect = (PotionEffect)p_equals_1_;
|
||||
return this.potionID == potioneffect.potionID && this.amplifier == potioneffect.amplifier && this.duration == potioneffect.duration && this.isSplashPotion == potioneffect.isSplashPotion && this.isAmbient == potioneffect.isAmbient;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a custom potion effect to a potion item's NBT data.
|
||||
*/
|
||||
public NBTTagCompound writeCustomPotionEffectToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
nbt.setByte("Id", (byte)this.getPotionID());
|
||||
nbt.setByte("Amplifier", (byte)this.getAmplifier());
|
||||
nbt.setInteger("Duration", this.getDuration());
|
||||
nbt.setBoolean("Ambient", this.getIsAmbient());
|
||||
nbt.setBoolean("ShowParticles", this.getIsShowParticles());
|
||||
return nbt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a custom potion effect from a potion item's NBT data.
|
||||
*/
|
||||
public static PotionEffect readCustomPotionEffectFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
int i = nbt.getByte("Id");
|
||||
|
||||
if (i >= 0 && i < Potion.POTION_TYPES.length && Potion.POTION_TYPES[i] != null)
|
||||
{
|
||||
int j = (int)(nbt.getByte("Amplifier") & 255);
|
||||
int k = nbt.getInteger("Duration");
|
||||
boolean flag = nbt.getBoolean("Ambient");
|
||||
boolean flag1 = true;
|
||||
|
||||
if (nbt.hasKey("ShowParticles", 1))
|
||||
{
|
||||
flag1 = nbt.getBoolean("ShowParticles");
|
||||
}
|
||||
|
||||
return new PotionEffect(i, k, j, flag, flag1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the isPotionDurationMax field.
|
||||
*/
|
||||
public void setPotionDurationMax(boolean maxDuration)
|
||||
{
|
||||
this.isPotionDurationMax = maxDuration;
|
||||
}
|
||||
|
||||
public boolean getIsPotionDurationMax()
|
||||
{
|
||||
return this.isPotionDurationMax;
|
||||
}
|
||||
}
|
27
java/src/game/potion/PotionHealth.java
Executable file
27
java/src/game/potion/PotionHealth.java
Executable file
|
@ -0,0 +1,27 @@
|
|||
package game.potion;
|
||||
|
||||
|
||||
|
||||
public class PotionHealth extends Potion
|
||||
{
|
||||
public PotionHealth(int potionID, String location, boolean badEffect, int potionColor)
|
||||
{
|
||||
super(potionID, location, badEffect, potionColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the potion has an instant effect instead of a continuous one (eg Harming)
|
||||
*/
|
||||
public boolean isInstant()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if Potion effect is ready to be applied this tick.
|
||||
*/
|
||||
public boolean isReady(int duration, int amp, int ticks)
|
||||
{
|
||||
return duration >= 1;
|
||||
}
|
||||
}
|
23
java/src/game/potion/PotionHealthBoost.java
Executable file
23
java/src/game/potion/PotionHealthBoost.java
Executable file
|
@ -0,0 +1,23 @@
|
|||
package game.potion;
|
||||
|
||||
import game.entity.attributes.AttributeMap;
|
||||
import game.entity.types.EntityLiving;
|
||||
|
||||
|
||||
public class PotionHealthBoost extends Potion
|
||||
{
|
||||
public PotionHealthBoost(int potionID, String location, boolean badEffect, int potionColor)
|
||||
{
|
||||
super(potionID, location, badEffect, potionColor);
|
||||
}
|
||||
|
||||
public void removeAttributesModifiersFromEntity(EntityLiving entityLivingBaseIn, AttributeMap p_111187_2_, int amplifier)
|
||||
{
|
||||
super.removeAttributesModifiersFromEntity(entityLivingBaseIn, p_111187_2_, amplifier);
|
||||
|
||||
if (entityLivingBaseIn.getHealth() > entityLivingBaseIn.getMaxHealth())
|
||||
{
|
||||
entityLivingBaseIn.setHealth(entityLivingBaseIn.getMaxHealth());
|
||||
}
|
||||
}
|
||||
}
|
611
java/src/game/potion/PotionHelper.java
Executable file
611
java/src/game/potion/PotionHelper.java
Executable file
|
@ -0,0 +1,611 @@
|
|||
package game.potion;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import game.collect.Lists;
|
||||
import game.collect.Maps;
|
||||
|
||||
public class PotionHelper
|
||||
{
|
||||
private static final String[] POTENCIES = new String[] {"II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"};
|
||||
private static final Integer[] INTEGERS = new Integer[65535];
|
||||
|
||||
public static final String sugarEffect = "-0+1-2-3&4-4+13";
|
||||
public static final String ghastTearEffect = "+0-1-2-3&4-4+13";
|
||||
public static final String spiderEyeEffect = "-0-1+2-3&4-4+13";
|
||||
public static final String fermentedSpiderEyeEffect = "-0+3-4+13";
|
||||
public static final String speckledMelonEffect = "+0-1+2-3&4-4+13";
|
||||
public static final String blazePowderEffect = "+0-1-2+3&4-4+13";
|
||||
public static final String magmaCreamEffect = "+0+1-2-3&4-4+13";
|
||||
public static final String redstoneEffect = "-5+6-7";
|
||||
public static final String glowstoneEffect = "+5-6-7";
|
||||
public static final String gunpowderEffect = "+14&13-13";
|
||||
public static final String goldenCarrotEffect = "-0+1+2-3+13&4-4";
|
||||
public static final String pufferfishEffect = "+0-1+2+3+13&4-4";
|
||||
// public static final String rabbitFootEffect = "+0+1-2+3&4-4+13";
|
||||
|
||||
private static final Map<Integer, String> potionRequirements = Maps.<Integer, String>newHashMap();
|
||||
private static final Map<Integer, String> potionAmplifiers = Maps.<Integer, String>newHashMap();
|
||||
private static final Map<Integer, Integer> DATAVALUE_COLORS = Maps.<Integer, Integer>newHashMap();
|
||||
|
||||
private static final String[] potionPrefixes = new String[] {
|
||||
"Gewöhnlicher", "Langweiliger", "Fader", "Klarer", "Milchiger",
|
||||
"Trüber", "Schlichter", "Dünnflüssiger", "Seltsamer", "Flauer",
|
||||
"Wuchtiger", "Verpfuschter", "Cremiger", "Milder", "Sanfter",
|
||||
"Gefälliger", "Dickflüssiger", "Vornehmer", "Raffinierter", "Lieblicher",
|
||||
"Flinker", "Verfeinerter", "Belebender", "Prickelnder", "Starker",
|
||||
"Fauler", "Geruchloser", "Ranziger", "Rauer", "Beißender",
|
||||
"Widerlicher", "Stinkender"
|
||||
};
|
||||
|
||||
static {
|
||||
for(int z = 0; z < INTEGERS.length; z++) {
|
||||
INTEGERS[z] = z;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the bit at 1 << j is on in i.
|
||||
*/
|
||||
public static boolean checkFlag(int p_77914_0_, int p_77914_1_)
|
||||
{
|
||||
return (p_77914_0_ & 1 << p_77914_1_) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if the flag is set, 0 if it is not set.
|
||||
*/
|
||||
private static int isFlagSet(int p_77910_0_, int p_77910_1_)
|
||||
{
|
||||
return checkFlag(p_77910_0_, p_77910_1_) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0 if the flag is set, 1 if it is not set.
|
||||
*/
|
||||
private static int isFlagUnset(int p_77916_0_, int p_77916_1_)
|
||||
{
|
||||
return checkFlag(p_77916_0_, p_77916_1_) ? 0 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a potion data value, get its prefix index number.
|
||||
*/
|
||||
public static int getPotionPrefixIndex(int dataValue)
|
||||
{
|
||||
return getPotionPrefixIndexFlags(dataValue, 5, 4, 3, 2, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a {@link Collection}<{@link PotionEffect}> will return an Integer color.
|
||||
*/
|
||||
public static int calcPotionLiquidColor(Collection<PotionEffect> p_77911_0_)
|
||||
{
|
||||
int i = 3694022;
|
||||
|
||||
if (p_77911_0_ != null && !p_77911_0_.isEmpty())
|
||||
{
|
||||
float f = 0.0F;
|
||||
float f1 = 0.0F;
|
||||
float f2 = 0.0F;
|
||||
float f3 = 0.0F;
|
||||
|
||||
for (PotionEffect potioneffect : p_77911_0_)
|
||||
{
|
||||
if (potioneffect.getIsShowParticles())
|
||||
{
|
||||
int j = Potion.POTION_TYPES[potioneffect.getPotionID()].getLiquidColor();
|
||||
|
||||
for (int k = 0; k <= potioneffect.getAmplifier(); ++k)
|
||||
{
|
||||
f += (float)(j >> 16 & 255) / 255.0F;
|
||||
f1 += (float)(j >> 8 & 255) / 255.0F;
|
||||
f2 += (float)(j >> 0 & 255) / 255.0F;
|
||||
++f3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (f3 == 0.0F)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
f = f / f3 * 255.0F;
|
||||
f1 = f1 / f3 * 255.0F;
|
||||
f2 = f2 / f3 * 255.0F;
|
||||
return (int)f << 16 | (int)f1 << 8 | (int)f2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a {@link Collection}<{@link PotionEffect}> are all ambient.
|
||||
*/
|
||||
public static boolean getAreAmbient(Collection<PotionEffect> potionEffects)
|
||||
{
|
||||
for (PotionEffect potioneffect : potionEffects)
|
||||
{
|
||||
if (!potioneffect.getIsAmbient())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getLiquidColor(int meta)
|
||||
{
|
||||
Integer key = meta > 0 && meta < INTEGERS.length ? INTEGERS[meta] : meta;
|
||||
if (DATAVALUE_COLORS.containsKey(key))
|
||||
{
|
||||
return ((Integer)DATAVALUE_COLORS.get(key)).intValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = calcPotionLiquidColor(getPotionEffects(key.intValue(), false));
|
||||
DATAVALUE_COLORS.put(key, Integer.valueOf(i));
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPotionPrefix(int dataValue)
|
||||
{
|
||||
int i = getPotionPrefixIndex(dataValue);
|
||||
return potionPrefixes[i];
|
||||
}
|
||||
|
||||
public static String getPotionPotency(int value)
|
||||
{
|
||||
return value >= 1 && value <= 9 ? " " + POTENCIES[value - 1] : (value == 0 ? "" : (" " + (value + 1)));
|
||||
}
|
||||
|
||||
private static int getPotionEffect(boolean p_77904_0_, boolean p_77904_1_, boolean p_77904_2_, int p_77904_3_, int p_77904_4_, int p_77904_5_, int p_77904_6_)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (p_77904_0_)
|
||||
{
|
||||
i = isFlagUnset(p_77904_6_, p_77904_4_);
|
||||
}
|
||||
else if (p_77904_3_ != -1)
|
||||
{
|
||||
if (p_77904_3_ == 0 && countSetFlags(p_77904_6_) == p_77904_4_)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
else if (p_77904_3_ == 1 && countSetFlags(p_77904_6_) > p_77904_4_)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
else if (p_77904_3_ == 2 && countSetFlags(p_77904_6_) < p_77904_4_)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i = isFlagSet(p_77904_6_, p_77904_4_);
|
||||
}
|
||||
|
||||
if (p_77904_1_)
|
||||
{
|
||||
i *= p_77904_5_;
|
||||
}
|
||||
|
||||
if (p_77904_2_)
|
||||
{
|
||||
i *= -1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of 1 bits in the given integer.
|
||||
*/
|
||||
private static int countSetFlags(int p_77907_0_)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; p_77907_0_ > 0; ++i)
|
||||
{
|
||||
p_77907_0_ &= p_77907_0_ - 1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private static int parsePotionEffects(String p_77912_0_, int p_77912_1_, int p_77912_2_, int p_77912_3_)
|
||||
{
|
||||
if (p_77912_1_ < p_77912_0_.length() && p_77912_2_ >= 0 && p_77912_1_ < p_77912_2_)
|
||||
{
|
||||
int i = p_77912_0_.indexOf(124, p_77912_1_);
|
||||
|
||||
if (i >= 0 && i < p_77912_2_)
|
||||
{
|
||||
int l1 = parsePotionEffects(p_77912_0_, p_77912_1_, i - 1, p_77912_3_);
|
||||
|
||||
if (l1 > 0)
|
||||
{
|
||||
return l1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int j2 = parsePotionEffects(p_77912_0_, i + 1, p_77912_2_, p_77912_3_);
|
||||
return j2 > 0 ? j2 : 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int j = p_77912_0_.indexOf(38, p_77912_1_);
|
||||
|
||||
if (j >= 0 && j < p_77912_2_)
|
||||
{
|
||||
int i2 = parsePotionEffects(p_77912_0_, p_77912_1_, j - 1, p_77912_3_);
|
||||
|
||||
if (i2 <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int k2 = parsePotionEffects(p_77912_0_, j + 1, p_77912_2_, p_77912_3_);
|
||||
return k2 <= 0 ? 0 : (i2 > k2 ? i2 : k2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean flag = false;
|
||||
boolean flag1 = false;
|
||||
boolean flag2 = false;
|
||||
boolean flag3 = false;
|
||||
boolean flag4 = false;
|
||||
int k = -1;
|
||||
int l = 0;
|
||||
int i1 = 0;
|
||||
int j1 = 0;
|
||||
|
||||
for (int k1 = p_77912_1_; k1 < p_77912_2_; ++k1)
|
||||
{
|
||||
char c0 = p_77912_0_.charAt(k1);
|
||||
|
||||
if (c0 >= 48 && c0 <= 57)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
i1 = c0 - 48;
|
||||
flag1 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = l * 10;
|
||||
l = l + (c0 - 48);
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
else if (c0 == 42)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
else if (c0 == 33)
|
||||
{
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
i1 = 0;
|
||||
l = 0;
|
||||
k = -1;
|
||||
}
|
||||
|
||||
flag3 = true;
|
||||
}
|
||||
else if (c0 == 45)
|
||||
{
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
i1 = 0;
|
||||
l = 0;
|
||||
k = -1;
|
||||
}
|
||||
|
||||
flag4 = true;
|
||||
}
|
||||
else if (c0 != 61 && c0 != 60 && c0 != 62)
|
||||
{
|
||||
if (c0 == 43 && flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
i1 = 0;
|
||||
l = 0;
|
||||
k = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
i1 = 0;
|
||||
l = 0;
|
||||
k = -1;
|
||||
}
|
||||
|
||||
if (c0 == 61)
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
else if (c0 == 60)
|
||||
{
|
||||
k = 2;
|
||||
}
|
||||
else if (c0 == 62)
|
||||
{
|
||||
k = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
||||
}
|
||||
|
||||
return j1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<PotionEffect> getPotionEffects(int meta, boolean all)
|
||||
{
|
||||
List<PotionEffect> list = null;
|
||||
|
||||
for (Potion potion : Potion.POTION_TYPES)
|
||||
{
|
||||
if (potion != null && (!potion.isUsable() || all))
|
||||
{
|
||||
String s = (String)potionRequirements.get(Integer.valueOf(potion.getId()));
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
int i = parsePotionEffects(s, 0, s.length(), meta);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
int j = 0;
|
||||
String s1 = (String)potionAmplifiers.get(Integer.valueOf(potion.getId()));
|
||||
|
||||
if (s1 != null)
|
||||
{
|
||||
j = parsePotionEffects(s1, 0, s1.length(), meta);
|
||||
|
||||
if (j < 0)
|
||||
{
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (potion.isInstant())
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = 1200 * (i * 3 + (i - 1) * 2);
|
||||
i = i >> j;
|
||||
i = (int)Math.round((double)i * potion.getEffectiveness());
|
||||
|
||||
if ((meta & 16384) != 0)
|
||||
{
|
||||
i = (int)Math.round((double)i * 0.75D + 0.5D);
|
||||
}
|
||||
}
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
list = Lists.<PotionEffect>newArrayList();
|
||||
}
|
||||
|
||||
PotionEffect potioneffect = new PotionEffect(potion.getId(), i, j);
|
||||
|
||||
if ((meta & 16384) != 0)
|
||||
{
|
||||
potioneffect.setSplashPotion(true);
|
||||
}
|
||||
|
||||
list.add(potioneffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manipulates the specified bit of the potion damage value according to the rules passed from applyIngredient.
|
||||
*/
|
||||
private static int brewBitOperations(int p_77906_0_, int p_77906_1_, boolean p_77906_2_, boolean p_77906_3_, boolean p_77906_4_)
|
||||
{
|
||||
if (p_77906_4_)
|
||||
{
|
||||
if (!checkFlag(p_77906_0_, p_77906_1_))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (p_77906_2_)
|
||||
{
|
||||
p_77906_0_ &= ~(1 << p_77906_1_);
|
||||
}
|
||||
else if (p_77906_3_)
|
||||
{
|
||||
if ((p_77906_0_ & 1 << p_77906_1_) == 0)
|
||||
{
|
||||
p_77906_0_ |= 1 << p_77906_1_;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_77906_0_ &= ~(1 << p_77906_1_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p_77906_0_ |= 1 << p_77906_1_;
|
||||
}
|
||||
|
||||
return p_77906_0_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new potion damage value after the specified ingredient info is applied to the specified potion.
|
||||
*/
|
||||
public static int applyIngredient(int p_77913_0_, String p_77913_1_)
|
||||
{
|
||||
int i = 0;
|
||||
int j = p_77913_1_.length();
|
||||
boolean flag = false;
|
||||
boolean flag1 = false;
|
||||
boolean flag2 = false;
|
||||
boolean flag3 = false;
|
||||
int k = 0;
|
||||
|
||||
for (int l = i; l < j; ++l)
|
||||
{
|
||||
char c0 = p_77913_1_.charAt(l);
|
||||
|
||||
if (c0 >= 48 && c0 <= 57)
|
||||
{
|
||||
k = k * 10;
|
||||
k = k + (c0 - 48);
|
||||
flag = true;
|
||||
}
|
||||
else if (c0 == 33)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
p_77913_0_ = brewBitOperations(p_77913_0_, k, flag2, flag1, flag3);
|
||||
flag3 = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
flag = false;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
flag1 = true;
|
||||
}
|
||||
else if (c0 == 45)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
p_77913_0_ = brewBitOperations(p_77913_0_, k, flag2, flag1, flag3);
|
||||
flag3 = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
flag = false;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
flag2 = true;
|
||||
}
|
||||
else if (c0 == 43)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
p_77913_0_ = brewBitOperations(p_77913_0_, k, flag2, flag1, flag3);
|
||||
flag3 = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
flag = false;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
else if (c0 == 38)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
p_77913_0_ = brewBitOperations(p_77913_0_, k, flag2, flag1, flag3);
|
||||
flag3 = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
flag = false;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
flag3 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
p_77913_0_ = brewBitOperations(p_77913_0_, k, flag2, flag1, flag3);
|
||||
}
|
||||
|
||||
return p_77913_0_ & 32767;
|
||||
}
|
||||
|
||||
public static int getPotionPrefixIndexFlags(int p_77908_0_, int p_77908_1_, int p_77908_2_, int p_77908_3_, int p_77908_4_, int p_77908_5_)
|
||||
{
|
||||
return (checkFlag(p_77908_0_, p_77908_1_) ? 16 : 0) | (checkFlag(p_77908_0_, p_77908_2_) ? 8 : 0) | (checkFlag(p_77908_0_, p_77908_3_) ? 4 : 0) | (checkFlag(p_77908_0_, p_77908_4_) ? 2 : 0) | (checkFlag(p_77908_0_, p_77908_5_) ? 1 : 0);
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
potionRequirements.put(Integer.valueOf(Potion.regeneration.getId()), "0 & !1 & !2 & !3 & 0+6");
|
||||
potionRequirements.put(Integer.valueOf(Potion.moveSpeed.getId()), "!0 & 1 & !2 & !3 & 1+6");
|
||||
potionRequirements.put(Integer.valueOf(Potion.fireResistance.getId()), "0 & 1 & !2 & !3 & 0+6");
|
||||
potionRequirements.put(Integer.valueOf(Potion.heal.getId()), "0 & !1 & 2 & !3");
|
||||
potionRequirements.put(Integer.valueOf(Potion.poison.getId()), "!0 & !1 & 2 & !3 & 2+6");
|
||||
potionRequirements.put(Integer.valueOf(Potion.weakness.getId()), "!0 & !1 & !2 & 3 & 3+6");
|
||||
potionRequirements.put(Integer.valueOf(Potion.harm.getId()), "!0 & !1 & 2 & 3");
|
||||
potionRequirements.put(Integer.valueOf(Potion.moveSlowdown.getId()), "!0 & 1 & !2 & 3 & 3+6");
|
||||
potionRequirements.put(Integer.valueOf(Potion.damageBoost.getId()), "0 & !1 & !2 & 3 & 3+6");
|
||||
potionRequirements.put(Integer.valueOf(Potion.nightVision.getId()), "!0 & 1 & 2 & !3 & 2+6");
|
||||
potionRequirements.put(Integer.valueOf(Potion.stability.getId()), "!0 & 1 & 2 & 3 & 2+6");
|
||||
// potionRequirements.put(Integer.valueOf(Potion.waterBreathing.getId()), "0 & !1 & 2 & 3 & 2+6");
|
||||
// potionRequirements.put(Integer.valueOf(Potion.jump.getId()), "0 & 1 & !2 & 3 & 3+6");
|
||||
potionAmplifiers.put(Integer.valueOf(Potion.moveSpeed.getId()), "5");
|
||||
potionAmplifiers.put(Integer.valueOf(Potion.digSpeed.getId()), "5");
|
||||
potionAmplifiers.put(Integer.valueOf(Potion.damageBoost.getId()), "5");
|
||||
potionAmplifiers.put(Integer.valueOf(Potion.regeneration.getId()), "5");
|
||||
potionAmplifiers.put(Integer.valueOf(Potion.harm.getId()), "5");
|
||||
potionAmplifiers.put(Integer.valueOf(Potion.heal.getId()), "5");
|
||||
potionAmplifiers.put(Integer.valueOf(Potion.resistance.getId()), "5");
|
||||
potionAmplifiers.put(Integer.valueOf(Potion.poison.getId()), "5");
|
||||
// potionAmplifiers.put(Integer.valueOf(Potion.jump.getId()), "5");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue