potion cleanup
This commit is contained in:
parent
460a58e062
commit
e108650cd4
30 changed files with 644 additions and 968 deletions
|
@ -2,8 +2,6 @@ package game.potion;
|
|||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import game.collect.Maps;
|
||||
|
||||
import game.entity.DamageSource;
|
||||
|
@ -16,398 +14,241 @@ 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 enum Potion {
|
||||
SPEED("speed", "Schnelligkeit", "Trank der Schnelligkeit", false, 8171462, new PotionModifier(Attributes.MOVEMENT_SPEED, "PotSpd", 0.2, true)),
|
||||
SLOWNESS("slowness", "Langsamkeit", "Trank der Langsamkeit", true, 5926017, new PotionModifier(Attributes.MOVEMENT_SPEED, "PotSlow", -0.15, true)),
|
||||
HASTE("haste", "Eile", "Trank der Eile", false, 14270531) {
|
||||
public double getEffectiveness() {
|
||||
return 1.5;
|
||||
}
|
||||
},
|
||||
FATIGUE("mining_fatigue", "Abbaulähmung", "Trank der Trägheit", true, 4866583),
|
||||
STRENGTH("strength", "Stärke", "Trank der Stärke", false, 9643043, new PotionModifier(Attributes.ATTACK_DAMAGE, "PotDmg", 2.5, true)) {
|
||||
public double getAmount(int amp, AttributeModifier modifier) {
|
||||
return 1.3D * (double)(amp + 1);
|
||||
}
|
||||
},
|
||||
HEAL("instant_health", "Direktheilung", "Trank der Heilung", false, 16262179) {
|
||||
public boolean isInstant() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onImpact(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect) {
|
||||
if(entity.arePotionsInverted()) {
|
||||
if(Config.damagePotion) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
},
|
||||
DAMAGE("instant_damage", "Direktschaden", "Trank des Schadens", true, 4393481) {
|
||||
public boolean isInstant() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onImpact(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect) {
|
||||
if(!entity.arePotionsInverted()) {
|
||||
if(Config.damagePotion) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
},
|
||||
JUMP("jump_boost", "Sprungkraft", "Trank der Sprungkraft", false, 2293580),
|
||||
NAUSEA("nausea", "Übelkeit", "Trank der Übelkeit", true, 5578058) {
|
||||
public double getEffectiveness() {
|
||||
return 0.25;
|
||||
}
|
||||
},
|
||||
REGENERATION("regeneration", "Regeneration", "Trank der Regeneration", false, 13458603) {
|
||||
public void onUpdate(EntityLiving entity, int duration, int amp) {
|
||||
int k = 50 >> amp;
|
||||
if((k <= 0 || duration % k == 0) && entity.getHealth() < entity.getMaxHealth())
|
||||
entity.heal(1);
|
||||
}
|
||||
|
||||
public final int id;
|
||||
public final String sid;
|
||||
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;
|
||||
public double getEffectiveness() {
|
||||
return 0.25;
|
||||
}
|
||||
},
|
||||
RESISTANCE("resistance", "Resistenz", "Trank des Widerstandes", false, 10044730),
|
||||
FIRE_RESISTANCE("fire_resistance", "Feuerschutz", "Trank der Feuerresistenz", false, 14981690),
|
||||
MANA("mana_boost", "Manaschub", "Trank des Manaschubes", false, 3035801) {
|
||||
public void onUpdate(EntityLiving entity, int duration, int amp) {
|
||||
int k = 40 >> amp;
|
||||
if((k <= 0 || duration % k == 0) && entity.getManaPoints() < entity.getMaxMana())
|
||||
entity.healMana(1);
|
||||
}
|
||||
},
|
||||
FLYING("flying", "Schweben", "Trank des Schwebens", false, 8356754),
|
||||
BLINDNESS("blindness", "Blindheit", "Trank der Blindheit", true, 2039587) {
|
||||
public double getEffectiveness() {
|
||||
return 0.25;
|
||||
}
|
||||
},
|
||||
NIGHT_VISION("night_vision", "Nachtsicht", "Trank der Nachtsicht", false, 2039713),
|
||||
STABILITY("stability", "Stabilität", "Trank der Standfestigkeit", false, 5797459, new PotionModifier(Attributes.KNOCKBACK_RESISTANCE, "PotStbl", 1.0, false)),
|
||||
WEAKNESS("weakness", "Schwäche", "Trank der Schwäche", true, 4738376, new PotionModifier(Attributes.ATTACK_DAMAGE, "PotWeak", 2.0, false)) {
|
||||
public double getAmount(int amp, AttributeModifier modifier) {
|
||||
return (double)(-0.5F * (float)(amp + 1));
|
||||
}
|
||||
},
|
||||
POISON("poison", "Vergiftung", "Trank der Vergiftung", true, 5149489) {
|
||||
public void onUpdate(EntityLiving entity, int duration, int amp) {
|
||||
int j = 25 >> amp;
|
||||
if((j <= 0 || duration % j == 0) && (entity.worldObj.client || Config.damagePoison) && entity.getHealth() > 1)
|
||||
entity.attackEntityFrom(DamageSource.magic, 1);
|
||||
}
|
||||
|
||||
protected Potion(int potionID, String location, boolean badEffect, int potionColor)
|
||||
{
|
||||
this.id = potionID;
|
||||
this.sid = location;
|
||||
POTION_TYPES[potionID] = this;
|
||||
POTION_MAP.put(location, this);
|
||||
this.bad = badEffect;
|
||||
public double getEffectiveness() {
|
||||
return 0.25;
|
||||
}
|
||||
},
|
||||
HEALTH("health_boost", "Extraenergie", "Trank der Extraenergie", false, 16284963, new PotionModifier(Attributes.MAX_HEALTH, "PotHp", 4.0, false)) {
|
||||
public void removeModifiers(EntityLiving entity, AttributeMap map, int amp) {
|
||||
super.removeModifiers(entity, map, amp);
|
||||
if(entity.getHealth() > entity.getMaxHealth())
|
||||
entity.setHealth(entity.getMaxHealth());
|
||||
}
|
||||
},
|
||||
ABSORPTION("absorption", "Absorption", "Trank der Absorption", false, 2445989) {
|
||||
public void removeModifiers(EntityLiving entity, AttributeMap map, int amp) {
|
||||
entity.setAbsorptionAmount(entity.getAbsorptionAmount() - (4 * (amp + 1)));
|
||||
super.removeModifiers(entity, map, amp);
|
||||
}
|
||||
|
||||
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;
|
||||
public void addModifiers(EntityLiving entity, AttributeMap map, int amp) {
|
||||
entity.setAbsorptionAmount(entity.getAbsorptionAmount() + (4 * (amp + 1)));
|
||||
super.addModifiers(entity, map, amp);
|
||||
}
|
||||
},
|
||||
RADIATION("radiation", "Strahlung", "Radioaktiver Trank", true, 0x00ff00) {
|
||||
public void onUpdate(EntityLiving entity, int duration, int amp) {
|
||||
if(entity.ticksExisted % 20 == 0 && (entity.worldObj.client || Config.damageRadiation)) // && entityLivingBaseIn.getHealth() > 1.0F)
|
||||
entity.attackEntityFrom(DamageSource.radiation, 1 + amp);
|
||||
}
|
||||
};
|
||||
|
||||
private static class PotionModifier {
|
||||
private final Attribute attribute;
|
||||
private final String id;
|
||||
private final double value;
|
||||
private final boolean multiply;
|
||||
|
||||
public PotionModifier(Attribute attr, String id, double value, boolean multiply) {
|
||||
this.attribute = attr;
|
||||
this.id = id;
|
||||
this.value = value;
|
||||
this.multiply = multiply;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
private static final Map<String, Potion> LOOKUP = Maps.newHashMap();
|
||||
|
||||
public String getDisplay()
|
||||
{
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public String getPotionDisplay()
|
||||
{
|
||||
return this.potionDisplay;
|
||||
}
|
||||
private final Map<Attribute, AttributeModifier> modifiers = Maps.<Attribute, AttributeModifier>newHashMap();
|
||||
private final String name;
|
||||
private final String effectDisplay;
|
||||
private final String potionDisplay;
|
||||
private final boolean bad;
|
||||
private final int color;
|
||||
|
||||
/**
|
||||
* Returns true if the potion has a associated status icon to display in then inventory when active.
|
||||
*/
|
||||
// public boolean hasStatusIcon()
|
||||
// {
|
||||
// return this.icon >= 0;
|
||||
// }
|
||||
static {
|
||||
for(Potion potion : values()) {
|
||||
LOOKUP.put(potion.name, potion);
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Returns the index for the icon to display when the potion is active.
|
||||
// */
|
||||
// public int getStatusIconIndex()
|
||||
// {
|
||||
// return this.icon;
|
||||
// }
|
||||
public static Potion getByName(String name) {
|
||||
return LOOKUP.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns true if the potion effect is bad - negative - for the entity.
|
||||
*/
|
||||
public boolean isBadEffect()
|
||||
{
|
||||
return this.bad;
|
||||
}
|
||||
private Potion(String name, String effectDisplay, String potionDisplay, boolean bad, int color, PotionModifier ... modifiers) {
|
||||
this.name = name;
|
||||
this.bad = bad;
|
||||
this.color = color;
|
||||
this.effectDisplay = effectDisplay;
|
||||
this.potionDisplay = potionDisplay;
|
||||
for(PotionModifier modifier : modifiers) {
|
||||
this.modifiers.put(modifier.attribute, new AttributeModifier(AttributeModifier.getModifierId(modifier.id), "potion." + name, modifier.value, modifier.multiply));
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDurationString(PotionEffect effect)
|
||||
{
|
||||
if (effect.getIsPotionDurationMax())
|
||||
{
|
||||
return "**:**";
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = effect.getDuration();
|
||||
return ticksToElapsedTime(i);
|
||||
}
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
protected Potion setEffectiveness(double effectivenessIn)
|
||||
{
|
||||
this.effectiveness = effectivenessIn;
|
||||
return this;
|
||||
}
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public double getEffectiveness()
|
||||
{
|
||||
return this.effectiveness;
|
||||
}
|
||||
public String getDisplay() {
|
||||
return this.effectDisplay;
|
||||
}
|
||||
|
||||
public boolean isUsable()
|
||||
{
|
||||
return this.usable;
|
||||
}
|
||||
public String getPotionDisplay() {
|
||||
return this.potionDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color of the potion liquid.
|
||||
*/
|
||||
public int getLiquidColor()
|
||||
{
|
||||
return this.color;
|
||||
}
|
||||
public boolean isBadEffect() {
|
||||
return this.bad;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 int getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public Map<Attribute, AttributeModifier> getAttributeModifierMap()
|
||||
{
|
||||
return this.modifiers;
|
||||
}
|
||||
public Map<Attribute, AttributeModifier> getModifiers() {
|
||||
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());
|
||||
public void onUpdate(EntityLiving entity, int duration, int amp) {
|
||||
}
|
||||
|
||||
if (iattributeinstance != null)
|
||||
{
|
||||
iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onImpact(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect) {
|
||||
}
|
||||
|
||||
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());
|
||||
public boolean isInstant() {
|
||||
return false;
|
||||
}
|
||||
|
||||
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 getAmount(int amp, AttributeModifier modifier) {
|
||||
return modifier.getAmount() * (double)(amp + 1);
|
||||
}
|
||||
|
||||
public double getAttributeModifierAmount(int p_111183_1_, AttributeModifier modifier)
|
||||
{
|
||||
return modifier.getAmount() * (double)(p_111183_1_ + 1);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.sid;
|
||||
}
|
||||
public double getEffectiveness() {
|
||||
return this.bad ? 0.5 : 1.0;
|
||||
}
|
||||
|
||||
public void removeModifiers(EntityLiving entity, AttributeMap map, int amp) {
|
||||
for(Entry<Attribute, AttributeModifier> entry : this.modifiers.entrySet()) {
|
||||
AttributeInstance attr = map.getAttributeInstance(entry.getKey());
|
||||
if(attr != null)
|
||||
attr.removeModifier(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void addModifiers(EntityLiving entity, AttributeMap map, int amp) {
|
||||
for(Entry<Attribute, AttributeModifier> entry : this.modifiers.entrySet()) {
|
||||
AttributeInstance attr = map.getAttributeInstance(entry.getKey());
|
||||
if(attr != null) {
|
||||
AttributeModifier mod = entry.getValue();
|
||||
attr.removeModifier(mod);
|
||||
attr.applyModifier(new AttributeModifier(mod.getID(), "potion." + this.name + " " + amp, this.getAmount(amp, mod), mod.isMultiplied()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -4,249 +4,151 @@ import game.entity.types.EntityLiving;
|
|||
import game.log.Log;
|
||||
import game.nbt.NBTTagCompound;
|
||||
|
||||
public class PotionEffect
|
||||
{
|
||||
/** ID value of the potion this effect matches. */
|
||||
private int potionID;
|
||||
public class PotionEffect {
|
||||
private final Potion potion;
|
||||
private final int duration;
|
||||
private final int amplifier;
|
||||
private final boolean ambient;
|
||||
private final boolean particles;
|
||||
|
||||
/** The duration of the potion effect */
|
||||
private int duration;
|
||||
private int remaining;
|
||||
private boolean thrown;
|
||||
|
||||
public PotionEffect(Potion id, int duration, int amplifier) {
|
||||
this(id, duration, amplifier, false, true);
|
||||
}
|
||||
|
||||
/** The amplifier of the potion effect */
|
||||
private int amplifier;
|
||||
public PotionEffect(Potion id, int duration, int amplifier, boolean ambient, boolean showParticles) {
|
||||
this.potion = id;
|
||||
this.duration = this.remaining = duration;
|
||||
this.amplifier = amplifier;
|
||||
this.ambient = ambient;
|
||||
this.particles = showParticles;
|
||||
}
|
||||
|
||||
/** Whether the potion is a splash potion */
|
||||
private boolean isSplashPotion;
|
||||
public PotionEffect(PotionEffect other) {
|
||||
this.potion = other.potion;
|
||||
this.duration = this.remaining = other.duration;
|
||||
this.amplifier = other.amplifier;
|
||||
this.ambient = other.ambient;
|
||||
this.particles = other.particles;
|
||||
}
|
||||
|
||||
/** Whether the potion effect came from a beacon */
|
||||
private boolean isAmbient;
|
||||
public PotionEffect combine(PotionEffect other) {
|
||||
if(this.potion != other.potion)
|
||||
Log.JNI.warn("PotionEffect.combine(): Diese Methode sollte nur für gleiche Effekte aufgerufen werden!");
|
||||
int duration = this.duration;
|
||||
int amplifier = this.amplifier;
|
||||
int remaining = this.remaining;
|
||||
boolean ambient = this.ambient;
|
||||
if(other.amplifier > this.amplifier) {
|
||||
amplifier = other.amplifier;
|
||||
duration = other.duration;
|
||||
remaining = other.remaining;
|
||||
}
|
||||
else if(other.amplifier == this.amplifier && this.remaining < other.remaining) {
|
||||
duration = other.duration;
|
||||
remaining = other.remaining;
|
||||
}
|
||||
else if(!other.ambient && this.ambient) {
|
||||
ambient = other.ambient;
|
||||
}
|
||||
return new PotionEffect(this.potion, duration, amplifier, ambient, other.particles).setRemaining(remaining);
|
||||
}
|
||||
|
||||
/** True if potion effect duration is at maximum, false otherwise. */
|
||||
private boolean isPotionDurationMax;
|
||||
private boolean showParticles;
|
||||
public Potion getPotion() {
|
||||
return this.potion;
|
||||
}
|
||||
|
||||
public PotionEffect(int id, int effectDuration)
|
||||
{
|
||||
this(id, effectDuration, 0);
|
||||
}
|
||||
public int getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public PotionEffect(int id, int effectDuration, int effectAmplifier)
|
||||
{
|
||||
this(id, effectDuration, effectAmplifier, false, true);
|
||||
}
|
||||
public boolean isInfinite() {
|
||||
return this.duration == Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
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 int getRemaining() {
|
||||
return this.remaining;
|
||||
}
|
||||
|
||||
public PotionEffect(PotionEffect other)
|
||||
{
|
||||
this.potionID = other.potionID;
|
||||
this.duration = other.duration;
|
||||
this.amplifier = other.amplifier;
|
||||
this.isAmbient = other.isAmbient;
|
||||
this.showParticles = other.showParticles;
|
||||
}
|
||||
public int getAmplifier() {
|
||||
return this.amplifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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!");
|
||||
}
|
||||
public PotionEffect setThrown(boolean thrown) {
|
||||
this.thrown = thrown;
|
||||
return this;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
public PotionEffect setRemaining(int remaining) {
|
||||
this.remaining = remaining;
|
||||
return this;
|
||||
}
|
||||
|
||||
this.showParticles = other.showParticles;
|
||||
}
|
||||
public boolean isAmbient() {
|
||||
return this.ambient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the ID of the potion this effect matches.
|
||||
*/
|
||||
public int getPotionID()
|
||||
{
|
||||
return this.potionID;
|
||||
}
|
||||
public boolean getIsShowParticles() {
|
||||
return this.particles;
|
||||
}
|
||||
|
||||
public int getDuration()
|
||||
{
|
||||
return this.duration;
|
||||
}
|
||||
public boolean onUpdate(EntityLiving entityIn) {
|
||||
if(this.isInfinite() && this.remaining < 20 * 60)
|
||||
this.remaining = Integer.MAX_VALUE;
|
||||
if(this.remaining > 0) {
|
||||
this.potion.onUpdate(entityIn, this.remaining, this.amplifier);
|
||||
--this.remaining;
|
||||
}
|
||||
return this.remaining > 0;
|
||||
}
|
||||
|
||||
public int getAmplifier()
|
||||
{
|
||||
return this.amplifier;
|
||||
}
|
||||
public String getEffectName() {
|
||||
return this.potion.getDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this potion is a splash potion.
|
||||
*/
|
||||
public void setSplashPotion(boolean splashPotion)
|
||||
{
|
||||
this.isSplashPotion = splashPotion;
|
||||
}
|
||||
public String getPotionName() {
|
||||
return this.potion.getPotionDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether this potion effect originated from a beacon
|
||||
*/
|
||||
public boolean getIsAmbient()
|
||||
{
|
||||
return this.isAmbient;
|
||||
}
|
||||
public String getDurationString() {
|
||||
if(this.isInfinite())
|
||||
return "**:**";
|
||||
int secs = this.remaining / 20;
|
||||
int hrs = secs / (60 * 60);
|
||||
secs = secs % (60 * 60);
|
||||
int mins = secs / 60;
|
||||
secs = secs % 60;
|
||||
return (hrs > 0 ? hrs + ":" + (mins < 10 ? "0" : "") : "") + mins + ":" + (secs < 10 ? "0" : "") + secs;
|
||||
}
|
||||
|
||||
public boolean getIsShowParticles()
|
||||
{
|
||||
return this.showParticles;
|
||||
}
|
||||
public int hashCode() {
|
||||
return this.potion.ordinal();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof PotionEffect))
|
||||
return false;
|
||||
PotionEffect other = (PotionEffect)obj;
|
||||
return this.potion == other.potion && this.amplifier == other.amplifier && this.duration == other.duration
|
||||
&& this.thrown == other.thrown && this.remaining == other.remaining && this.ambient == other.ambient;
|
||||
}
|
||||
|
||||
--this.duration;
|
||||
}
|
||||
public NBTTagCompound toNbt() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("Type", this.potion.getName());
|
||||
nbt.setByte("Amplifier", (byte)this.amplifier);
|
||||
nbt.setInteger("Duration", this.duration);
|
||||
nbt.setInteger("Remaining", this.remaining);
|
||||
nbt.setBoolean("Ambient", this.ambient);
|
||||
nbt.setBoolean("Particles", this.particles);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
public static PotionEffect fromNbt(NBTTagCompound nbt) {
|
||||
Potion potion = Potion.getByName(nbt.getString("Type"));
|
||||
return potion == null ? null : new PotionEffect(potion, nbt.getInteger("Duration"), (int)(nbt.getByte("Amplifier") & 255), nbt.getBoolean("Ambient"), nbt.getBoolean("Particles"))
|
||||
.setRemaining(nbt.getInteger("Remaining"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,8 +26,8 @@ public class PotionHelper
|
|||
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<Potion, String> potionRequirements = Maps.<Potion, String>newEnumMap(Potion.class);
|
||||
private static final Map<Potion, String> potionAmplifiers = Maps.<Potion, String>newEnumMap(Potion.class);
|
||||
private static final Map<Integer, Integer> DATAVALUE_COLORS = Maps.<Integer, Integer>newHashMap();
|
||||
|
||||
private static final String[] potionPrefixes = new String[] {
|
||||
|
@ -96,7 +96,7 @@ public class PotionHelper
|
|||
{
|
||||
if (potioneffect.getIsShowParticles())
|
||||
{
|
||||
int j = Potion.POTION_TYPES[potioneffect.getPotionID()].getLiquidColor();
|
||||
int j = potioneffect.getPotion().getColor();
|
||||
|
||||
for (int k = 0; k <= potioneffect.getAmplifier(); ++k)
|
||||
{
|
||||
|
@ -133,7 +133,7 @@ public class PotionHelper
|
|||
{
|
||||
for (PotionEffect potioneffect : potionEffects)
|
||||
{
|
||||
if (!potioneffect.getIsAmbient())
|
||||
if (!potioneffect.isAmbient())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public class PotionHelper
|
|||
}
|
||||
else
|
||||
{
|
||||
int i = calcPotionLiquidColor(getPotionEffects(key.intValue(), false));
|
||||
int i = calcPotionLiquidColor(getPotionEffects(key.intValue()));
|
||||
DATAVALUE_COLORS.put(key, Integer.valueOf(i));
|
||||
return i;
|
||||
}
|
||||
|
@ -168,32 +168,32 @@ public class PotionHelper
|
|||
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_)
|
||||
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 meta)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (p_77904_0_)
|
||||
{
|
||||
i = isFlagUnset(p_77904_6_, p_77904_4_);
|
||||
i = isFlagUnset(meta, p_77904_4_);
|
||||
}
|
||||
else if (p_77904_3_ != -1)
|
||||
{
|
||||
if (p_77904_3_ == 0 && countSetFlags(p_77904_6_) == p_77904_4_)
|
||||
if (p_77904_3_ == 0 && countSetFlags(meta) == p_77904_4_)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
else if (p_77904_3_ == 1 && countSetFlags(p_77904_6_) > p_77904_4_)
|
||||
else if (p_77904_3_ == 1 && countSetFlags(meta) > p_77904_4_)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
else if (p_77904_3_ == 2 && countSetFlags(p_77904_6_) < p_77904_4_)
|
||||
else if (p_77904_3_ == 2 && countSetFlags(meta) < p_77904_4_)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i = isFlagSet(p_77904_6_, p_77904_4_);
|
||||
i = isFlagSet(meta, p_77904_4_);
|
||||
}
|
||||
|
||||
if (p_77904_1_)
|
||||
|
@ -212,27 +212,27 @@ public class PotionHelper
|
|||
/**
|
||||
* Returns the number of 1 bits in the given integer.
|
||||
*/
|
||||
private static int countSetFlags(int p_77907_0_)
|
||||
private static int countSetFlags(int meta)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; p_77907_0_ > 0; ++i)
|
||||
for (i = 0; meta > 0; ++i)
|
||||
{
|
||||
p_77907_0_ &= p_77907_0_ - 1;
|
||||
meta &= meta - 1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private static int parsePotionEffects(String p_77912_0_, int p_77912_1_, int p_77912_2_, int p_77912_3_)
|
||||
private static int parsePotionEffects(String data, int start, int end, int meta)
|
||||
{
|
||||
if (p_77912_1_ < p_77912_0_.length() && p_77912_2_ >= 0 && p_77912_1_ < p_77912_2_)
|
||||
if (start < data.length() && end >= 0 && start < end)
|
||||
{
|
||||
int i = p_77912_0_.indexOf(124, p_77912_1_);
|
||||
int i = data.indexOf(124, start);
|
||||
|
||||
if (i >= 0 && i < p_77912_2_)
|
||||
if (i >= 0 && i < end)
|
||||
{
|
||||
int l1 = parsePotionEffects(p_77912_0_, p_77912_1_, i - 1, p_77912_3_);
|
||||
int l1 = parsePotionEffects(data, start, i - 1, meta);
|
||||
|
||||
if (l1 > 0)
|
||||
{
|
||||
|
@ -240,17 +240,17 @@ public class PotionHelper
|
|||
}
|
||||
else
|
||||
{
|
||||
int j2 = parsePotionEffects(p_77912_0_, i + 1, p_77912_2_, p_77912_3_);
|
||||
int j2 = parsePotionEffects(data, i + 1, end, meta);
|
||||
return j2 > 0 ? j2 : 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int j = p_77912_0_.indexOf(38, p_77912_1_);
|
||||
int j = data.indexOf(38, start);
|
||||
|
||||
if (j >= 0 && j < p_77912_2_)
|
||||
if (j >= 0 && j < end)
|
||||
{
|
||||
int i2 = parsePotionEffects(p_77912_0_, p_77912_1_, j - 1, p_77912_3_);
|
||||
int i2 = parsePotionEffects(data, start, j - 1, meta);
|
||||
|
||||
if (i2 <= 0)
|
||||
{
|
||||
|
@ -258,7 +258,7 @@ public class PotionHelper
|
|||
}
|
||||
else
|
||||
{
|
||||
int k2 = parsePotionEffects(p_77912_0_, j + 1, p_77912_2_, p_77912_3_);
|
||||
int k2 = parsePotionEffects(data, j + 1, end, meta);
|
||||
return k2 <= 0 ? 0 : (i2 > k2 ? i2 : k2);
|
||||
}
|
||||
}
|
||||
|
@ -274,9 +274,9 @@ public class PotionHelper
|
|||
int i1 = 0;
|
||||
int j1 = 0;
|
||||
|
||||
for (int k1 = p_77912_1_; k1 < p_77912_2_; ++k1)
|
||||
for (int k1 = start; k1 < end; ++k1)
|
||||
{
|
||||
char c0 = p_77912_0_.charAt(k1);
|
||||
char c0 = data.charAt(k1);
|
||||
|
||||
if (c0 >= 48 && c0 <= 57)
|
||||
{
|
||||
|
@ -300,7 +300,7 @@ public class PotionHelper
|
|||
{
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
|
@ -317,7 +317,7 @@ public class PotionHelper
|
|||
{
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
|
@ -334,7 +334,7 @@ public class PotionHelper
|
|||
{
|
||||
if (c0 == 43 && flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
|
@ -349,7 +349,7 @@ public class PotionHelper
|
|||
{
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
|
@ -377,7 +377,7 @@ public class PotionHelper
|
|||
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||
}
|
||||
|
||||
return j1;
|
||||
|
@ -390,67 +390,67 @@ public class PotionHelper
|
|||
}
|
||||
}
|
||||
|
||||
public static List<PotionEffect> getPotionEffects(int meta, boolean all)
|
||||
public static List<PotionEffect> getPotionEffects(int meta)
|
||||
{
|
||||
List<PotionEffect> list = null;
|
||||
|
||||
for (Potion potion : Potion.POTION_TYPES)
|
||||
for (Potion potion : Potion.values())
|
||||
{
|
||||
if (potion != null && (!potion.isUsable() || all))
|
||||
// if (potion != null) // && (!potion.isUsable() || all))
|
||||
// {
|
||||
String s = potionRequirements.get(potion);
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
String s = (String)potionRequirements.get(Integer.valueOf(potion.getId()));
|
||||
int i = parsePotionEffects(s, 0, s.length(), meta);
|
||||
|
||||
if (s != null)
|
||||
if (i > 0)
|
||||
{
|
||||
int i = parsePotionEffects(s, 0, s.length(), meta);
|
||||
int j = 0;
|
||||
String s1 = potionAmplifiers.get(potion);
|
||||
|
||||
if (i > 0)
|
||||
if (s1 != null)
|
||||
{
|
||||
int j = 0;
|
||||
String s1 = (String)potionAmplifiers.get(Integer.valueOf(potion.getId()));
|
||||
j = parsePotionEffects(s1, 0, s1.length(), meta);
|
||||
|
||||
if (s1 != null)
|
||||
if (j < 0)
|
||||
{
|
||||
j = parsePotionEffects(s1, 0, s1.length(), meta);
|
||||
|
||||
if (j < 0)
|
||||
{
|
||||
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 (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)
|
||||
{
|
||||
potioneffect.setSplashPotion(true);
|
||||
i = (int)Math.round((double)i * 0.75D + 0.5D);
|
||||
}
|
||||
|
||||
list.add(potioneffect);
|
||||
}
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
list = Lists.<PotionEffect>newArrayList();
|
||||
}
|
||||
|
||||
PotionEffect potioneffect = new PotionEffect(potion, i, j);
|
||||
|
||||
if ((meta & 16384) != 0)
|
||||
{
|
||||
potioneffect.setThrown(true);
|
||||
}
|
||||
|
||||
list.add(potioneffect);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -585,27 +585,27 @@ public class PotionHelper
|
|||
|
||||
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");
|
||||
potionRequirements.put(Potion.REGENERATION, "0 & !1 & !2 & !3 & 0+6");
|
||||
potionRequirements.put(Potion.SPEED, "!0 & 1 & !2 & !3 & 1+6");
|
||||
potionRequirements.put(Potion.FIRE_RESISTANCE, "0 & 1 & !2 & !3 & 0+6");
|
||||
potionRequirements.put(Potion.HEAL, "0 & !1 & 2 & !3");
|
||||
potionRequirements.put(Potion.POISON, "!0 & !1 & 2 & !3 & 2+6");
|
||||
potionRequirements.put(Potion.WEAKNESS, "!0 & !1 & !2 & 3 & 3+6");
|
||||
potionRequirements.put(Potion.DAMAGE, "!0 & !1 & 2 & 3");
|
||||
potionRequirements.put(Potion.SLOWNESS, "!0 & 1 & !2 & 3 & 3+6");
|
||||
potionRequirements.put(Potion.STRENGTH, "0 & !1 & !2 & 3 & 3+6");
|
||||
potionRequirements.put(Potion.NIGHT_VISION, "!0 & 1 & 2 & !3 & 2+6");
|
||||
potionRequirements.put(Potion.STABILITY, "!0 & 1 & 2 & 3 & 2+6");
|
||||
// potionRequirements.put(Potion.waterBreathing, "0 & !1 & 2 & 3 & 2+6");
|
||||
// potionRequirements.put(Potion.jump, "0 & 1 & !2 & 3 & 3+6");
|
||||
potionAmplifiers.put(Potion.SPEED, "5");
|
||||
potionAmplifiers.put(Potion.HASTE, "5");
|
||||
potionAmplifiers.put(Potion.STRENGTH, "5");
|
||||
potionAmplifiers.put(Potion.REGENERATION, "5");
|
||||
potionAmplifiers.put(Potion.DAMAGE, "5");
|
||||
potionAmplifiers.put(Potion.HEAL, "5");
|
||||
potionAmplifiers.put(Potion.RESISTANCE, "5");
|
||||
potionAmplifiers.put(Potion.POISON, "5");
|
||||
// potionAmplifiers.put(Potion.jump, "5");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue