potion cleanup
This commit is contained in:
parent
460a58e062
commit
e108650cd4
30 changed files with 644 additions and 968 deletions
|
@ -851,12 +851,13 @@ public class Game implements IThreadListener {
|
||||||
x = 40;
|
x = 40;
|
||||||
y = 40;
|
y = 40;
|
||||||
for(PotionEffect effect : this.thePlayer.getEffects()) {
|
for(PotionEffect effect : this.thePlayer.getEffects()) {
|
||||||
Potion potion = Potion.POTION_TYPES[effect.getPotionID()];
|
Potion potion = effect.getPotion();
|
||||||
int color = potion.getLiquidColor();
|
int color = potion.getColor();
|
||||||
String name = (potion.isBadEffect() ? TextColor.ORANGE : TextColor.ACID) + potion.getDisplay() + PotionHelper.getPotionPotency(effect.getAmplifier());
|
String name = (potion.isBadEffect() ? TextColor.ORANGE : TextColor.ACID) + potion.getDisplay() + PotionHelper.getPotionPotency(effect.getAmplifier());
|
||||||
String desc = TextColor.NEON + Potion.getDurationString(effect);
|
String desc = TextColor.NEON + effect.getDurationString();
|
||||||
// Drawing.drawRectColor(x, y, 250, Font.DEFAULT.yglyph + 2, color | 0xff000000);
|
// Drawing.drawRectColor(x, y, 250, Font.DEFAULT.yglyph + 2, color | 0xff000000);
|
||||||
Drawing.drawGradientBorder(x, y, 250, Font.YGLYPH + 4, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000), 0xff202020, 0xffcfcfcf, 0xff6f6f6f);
|
Drawing.drawRectBorder(x, y, 250, Font.YGLYPH + 4, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff6f6f6f);
|
||||||
|
Drawing.drawGradient(x + 2, y + 2, effect.isInfinite() ? 246 : ((int)(246.0f * ((float)effect.getRemaining() / (float)effect.getDuration()))), Font.YGLYPH, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000));
|
||||||
Drawing.drawText(name, x + 4, y + 2, 0xffffffff);
|
Drawing.drawText(name, x + 4, y + 2, 0xffffffff);
|
||||||
Drawing.drawTextRight(desc, x + 250 - 4, y + 2, 0xffffffff);
|
Drawing.drawTextRight(desc, x + 250 - 4, y + 2, 0xffffffff);
|
||||||
y += 24;
|
y += 24;
|
||||||
|
|
|
@ -15,8 +15,8 @@ public class CommandMilk extends Command {
|
||||||
this.addLivingEntityList("entities", true);
|
this.addLivingEntityList("entities", true);
|
||||||
this.setParamsOptional();
|
this.setParamsOptional();
|
||||||
List<Potion> potions = Lists.newArrayList();
|
List<Potion> potions = Lists.newArrayList();
|
||||||
for(Potion potion : Potion.POTION_TYPES) {
|
for(Potion potion : Potion.values()) {
|
||||||
if(potion != null)
|
if(!potion.isInstant())
|
||||||
potions.add(potion);
|
potions.add(potion);
|
||||||
}
|
}
|
||||||
this.addEnum("type", Potion.class, potions);
|
this.addEnum("type", Potion.class, potions);
|
||||||
|
@ -28,7 +28,7 @@ public class CommandMilk extends Command {
|
||||||
int done = 0;
|
int done = 0;
|
||||||
for(EntityLiving entity : entities) {
|
for(EntityLiving entity : entities) {
|
||||||
if(type != null && entity.hasEffect(type)) {
|
if(type != null && entity.hasEffect(type)) {
|
||||||
entity.removeEffect(type.id);
|
entity.removeEffect(type);
|
||||||
exec.logConsole("%s von %s entfernt", type.getDisplay(), entity.getCommandName());
|
exec.logConsole("%s von %s entfernt", type.getDisplay(), entity.getCommandName());
|
||||||
done++;
|
done++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,13 @@ public class CommandPotion extends Command {
|
||||||
super("potion");
|
super("potion");
|
||||||
|
|
||||||
List<Potion> potions = Lists.newArrayList();
|
List<Potion> potions = Lists.newArrayList();
|
||||||
for(Potion potion : Potion.POTION_TYPES) {
|
for(Potion potion : Potion.values()) {
|
||||||
if(potion != null)
|
|
||||||
potions.add(potion);
|
potions.add(potion);
|
||||||
}
|
}
|
||||||
this.addLivingEntityList("entities", true);
|
this.addLivingEntityList("entities", true);
|
||||||
this.addEnum("type", Potion.class, potions);
|
this.addEnum("type", Potion.class, potions);
|
||||||
this.setParamsOptional();
|
this.setParamsOptional();
|
||||||
this.addInt("duration", 1, 1000000, 1000000);
|
this.addInt("duration", 0, 1000000, 1000000);
|
||||||
this.addInt("strength", 1, 256, 1);
|
this.addInt("strength", 1, 256, 1);
|
||||||
|
|
||||||
this.addFlag("particles", 'p');
|
this.addFlag("particles", 'p');
|
||||||
|
@ -32,11 +31,19 @@ public class CommandPotion extends Command {
|
||||||
public Object exec(CommandEnvironment env, Executor exec, List<EntityLiving> entities, Potion type, int duration, int strength, boolean particles, boolean ambient, boolean keep) {
|
public Object exec(CommandEnvironment env, Executor exec, List<EntityLiving> entities, Potion type, int duration, int strength, boolean particles, boolean ambient, boolean keep) {
|
||||||
int done = 0;
|
int done = 0;
|
||||||
for(EntityLiving entity : entities) {
|
for(EntityLiving entity : entities) {
|
||||||
PotionEffect effect = new PotionEffect(type.id, duration * 20, strength - 1, ambient, particles);
|
if(entity.isPotionApplicable(type)) {
|
||||||
if(entity.isPotionApplicable(effect)) {
|
if(type.isInstant()) {
|
||||||
|
type.onImpact(null, null, entity, strength - 1, 1.0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PotionEffect effect = new PotionEffect(type, duration == 0 ? Integer.MAX_VALUE : (duration * 20), strength - 1, ambient, particles);
|
||||||
if(!keep && entity.hasEffect(type))
|
if(!keep && entity.hasEffect(type))
|
||||||
entity.removeEffect(type.id);
|
entity.removeEffect(type);
|
||||||
entity.addEffect(effect);
|
entity.addEffect(effect);
|
||||||
|
}
|
||||||
|
if(type.isInstant() || duration == 0)
|
||||||
|
exec.logConsole("%d * %s an %s gegeben", strength, type.getDisplay(), entity.getCommandName());
|
||||||
|
else
|
||||||
exec.logConsole("%d * %s für %d Sekunden an %s gegeben", strength, type.getDisplay(), duration, entity.getCommandName());
|
exec.logConsole("%d * %s für %d Sekunden an %s gegeben", strength, type.getDisplay(), duration, entity.getCommandName());
|
||||||
done++;
|
done++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1329,9 +1329,9 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
|
||||||
{
|
{
|
||||||
this.motionY = this.getHorseJumpStrength() * (double)this.jumpPower;
|
this.motionY = this.getHorseJumpStrength() * (double)this.jumpPower;
|
||||||
|
|
||||||
if (this.hasEffect(Potion.jump))
|
if (this.hasEffect(Potion.JUMP))
|
||||||
{
|
{
|
||||||
this.motionY += (double)((float)(this.getEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
|
this.motionY += (double)((float)(this.getEffect(Potion.JUMP).getAmplifier() + 1) * 0.1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setHorseJumping(true);
|
this.setHorseJumping(true);
|
||||||
|
|
|
@ -342,7 +342,7 @@ public class EntityRabbit extends EntityAnimal {
|
||||||
}).isEmpty())
|
}).isEmpty())
|
||||||
this.setInLove(null);
|
this.setInLove(null);
|
||||||
if(state.getBlock() == Blocks.blue_mushroom)
|
if(state.getBlock() == Blocks.blue_mushroom)
|
||||||
this.addEffect(new PotionEffect(Potion.moveSpeed.id, this.rand.range(400, 2600), this.rand.chance(0, 1, 5)));
|
this.addEffect(new PotionEffect(Potion.SPEED, this.rand.range(400, 2600), this.rand.chance(0, 1, 5)));
|
||||||
this.worldObj.destroyBlock(pos, false);
|
this.worldObj.destroyBlock(pos, false);
|
||||||
this.worldObj.setState(pos, Blocks.air.getState(), 2);
|
this.worldObj.setState(pos, Blocks.air.getState(), 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,11 +111,11 @@ public class EntityArachnoid extends EntityNPC
|
||||||
|
|
||||||
if (livingdata instanceof EntityArachnoid.GroupData)
|
if (livingdata instanceof EntityArachnoid.GroupData)
|
||||||
{
|
{
|
||||||
int i = ((EntityArachnoid.GroupData)livingdata).potionEffectId;
|
Potion i = ((EntityArachnoid.GroupData)livingdata).potionEffectId;
|
||||||
|
|
||||||
if (i > 0 && Potion.POTION_TYPES[i] != null)
|
if (i != null)
|
||||||
{
|
{
|
||||||
this.addEffect(new PotionEffect(i, Integer.MAX_VALUE));
|
this.addEffect(new PotionEffect(i, Integer.MAX_VALUE, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((EntityArachnoid.GroupData)livingdata).isChild)
|
if(((EntityArachnoid.GroupData)livingdata).isChild)
|
||||||
|
@ -228,7 +228,7 @@ public class EntityArachnoid extends EntityNPC
|
||||||
{
|
{
|
||||||
if(super.attackEntityAsMob(entityIn)) {
|
if(super.attackEntityAsMob(entityIn)) {
|
||||||
if(entityIn instanceof EntityLiving && this.rand.chance(50))
|
if(entityIn instanceof EntityLiving && this.rand.chance(50))
|
||||||
((EntityLiving)entityIn).addEffect(new PotionEffect(Potion.poison.id, this.rand.range(14, 35) * 20, 0));
|
((EntityLiving)entityIn).addEffect(new PotionEffect(Potion.POISON, this.rand.range(14, 35) * 20, 0));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -248,7 +248,7 @@ public class EntityArachnoid extends EntityNPC
|
||||||
|
|
||||||
public static class GroupData
|
public static class GroupData
|
||||||
{
|
{
|
||||||
public int potionEffectId;
|
public Potion potionEffectId;
|
||||||
public boolean isChild;
|
public boolean isChild;
|
||||||
|
|
||||||
public GroupData(boolean isChild) {
|
public GroupData(boolean isChild) {
|
||||||
|
@ -257,7 +257,7 @@ public class EntityArachnoid extends EntityNPC
|
||||||
|
|
||||||
public void pickEffect(Random rand)
|
public void pickEffect(Random rand)
|
||||||
{
|
{
|
||||||
this.potionEffectId = rand.pick(Potion.moveSpeed.id, Potion.moveSpeed.id, Potion.damageBoost.id, Potion.regeneration.id);
|
this.potionEffectId = rand.pick(Potion.SPEED, Potion.SPEED, Potion.STRENGTH, Potion.REGENERATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import game.ai.EntityMoveHelper;
|
||||||
import game.block.Block;
|
import game.block.Block;
|
||||||
import game.entity.attributes.Attributes;
|
import game.entity.attributes.Attributes;
|
||||||
import game.entity.types.EntityLiving;
|
import game.entity.types.EntityLiving;
|
||||||
|
import game.potion.Potion;
|
||||||
import game.rng.Random;
|
import game.rng.Random;
|
||||||
import game.util.ExtMath;
|
import game.util.ExtMath;
|
||||||
import game.world.BlockPos;
|
import game.world.BlockPos;
|
||||||
|
@ -112,6 +113,11 @@ public abstract class EntityFlyingNPC extends EntityNPC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPotionApplicable(Potion potion)
|
||||||
|
{
|
||||||
|
return potion != Potion.FLYING && super.isPotionApplicable(potion);
|
||||||
|
}
|
||||||
|
|
||||||
static class AILookAround extends EntityAIBase
|
static class AILookAround extends EntityAIBase
|
||||||
{
|
{
|
||||||
private EntityFlyingNPC parentEntity;
|
private EntityFlyingNPC parentEntity;
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class EntityMage extends EntityNPC
|
||||||
// i = 8237;
|
// i = 8237;
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
if (this.rand.floatv() < 0.15F && this.isBurning() && !this.hasEffect(Potion.fireResistance))
|
if (this.rand.floatv() < 0.15F && this.isBurning() && !this.hasEffect(Potion.FIRE_RESISTANCE))
|
||||||
{
|
{
|
||||||
i = 16307;
|
i = 16307;
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,11 @@ public class EntityMage extends EntityNPC
|
||||||
{
|
{
|
||||||
i = 16341;
|
i = 16341;
|
||||||
}
|
}
|
||||||
else if (this.rand.floatv() < 0.25F && this.getAttackTarget() != null && !this.hasEffect(Potion.moveSpeed) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
|
else if (this.rand.floatv() < 0.25F && this.getAttackTarget() != null && !this.hasEffect(Potion.SPEED) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
|
||||||
{
|
{
|
||||||
i = 16274;
|
i = 16274;
|
||||||
}
|
}
|
||||||
else if (this.rand.floatv() < 0.25F && this.getAttackTarget() != null && !this.hasEffect(Potion.moveSpeed) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
|
else if (this.rand.floatv() < 0.25F && this.getAttackTarget() != null && !this.hasEffect(Potion.SPEED) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
|
||||||
{
|
{
|
||||||
i = 16274;
|
i = 16274;
|
||||||
}
|
}
|
||||||
|
|
|
@ -798,15 +798,15 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
double d3 = target.posZ + target.motionZ - this.posZ;
|
double d3 = target.posZ + target.motionZ - this.posZ;
|
||||||
float f = ExtMath.sqrtd(d1 * d1 + d3 * d3);
|
float f = ExtMath.sqrtd(d1 * d1 + d3 * d3);
|
||||||
|
|
||||||
if (f >= 8.0F && !target.hasEffect(Potion.moveSlowdown))
|
if (f >= 8.0F && !target.hasEffect(Potion.SLOWNESS))
|
||||||
{
|
{
|
||||||
entitypotion.setPotionDamage(32698);
|
entitypotion.setPotionDamage(32698);
|
||||||
}
|
}
|
||||||
else if (target.getHealth() >= 8 && !target.hasEffect(Potion.poison))
|
else if (target.getHealth() >= 8 && !target.hasEffect(Potion.POISON))
|
||||||
{
|
{
|
||||||
entitypotion.setPotionDamage(32660);
|
entitypotion.setPotionDamage(32660);
|
||||||
}
|
}
|
||||||
else if (f <= 3.0F && !target.hasEffect(Potion.weakness) && this.rand.floatv() < 0.25F)
|
else if (f <= 3.0F && !target.hasEffect(Potion.WEAKNESS) && this.rand.floatv() < 0.25F)
|
||||||
{
|
{
|
||||||
entitypotion.setPotionDamage(32696);
|
entitypotion.setPotionDamage(32696);
|
||||||
}
|
}
|
||||||
|
@ -2404,7 +2404,7 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
this.pushOutOfBlocks(this.posX + (double)this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ + (double)this.width * 0.35D);
|
this.pushOutOfBlocks(this.posX + (double)this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ + (double)this.width * 0.35D);
|
||||||
boolean canSprint = true; // (float)this.getFoodStats().getFoodLevel() > 6.0F || this.allowFlying;
|
boolean canSprint = true; // (float)this.getFoodStats().getFoodLevel() > 6.0F || this.allowFlying;
|
||||||
|
|
||||||
if (this.onGround && !flag1 && !flag2 && this.gm.moveForward >= f && !this.isSprinting() && canSprint && !this.isUsingItem() && !this.hasEffect(Potion.blindness))
|
if (this.onGround && !flag1 && !flag2 && this.gm.moveForward >= f && !this.isSprinting() && canSprint && !this.isUsingItem() && !this.hasEffect(Potion.BLINDNESS))
|
||||||
{
|
{
|
||||||
if (this.sprintToggleTimer <= 0 && !this.gm.sprint)
|
if (this.sprintToggleTimer <= 0 && !this.gm.sprint)
|
||||||
{
|
{
|
||||||
|
@ -2416,7 +2416,7 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isSprinting() && this.gm.moveForward >= f && canSprint && !this.isUsingItem() && !this.hasEffect(Potion.blindness) && this.gm.sprint)
|
if (!this.isSprinting() && this.gm.moveForward >= f && canSprint && !this.isUsingItem() && !this.hasEffect(Potion.BLINDNESS) && this.gm.sprint)
|
||||||
{
|
{
|
||||||
this.setSprinting(true);
|
this.setSprinting(true);
|
||||||
}
|
}
|
||||||
|
@ -2426,7 +2426,7 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
this.setSprinting(false);
|
this.setSprinting(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasEffect(Potion.flying) || this.noclip)
|
if (this.hasEffect(Potion.FLYING) || this.noclip)
|
||||||
{
|
{
|
||||||
if (this.noclip)
|
if (this.noclip)
|
||||||
{
|
{
|
||||||
|
@ -3037,7 +3037,7 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
|
|
||||||
protected void onFinishedEffect(PotionEffect effect) {
|
protected void onFinishedEffect(PotionEffect effect) {
|
||||||
super.onFinishedEffect(effect);
|
super.onFinishedEffect(effect);
|
||||||
if(this.isPlayer() && effect.getPotionID() == Potion.flying.id)
|
if(this.isPlayer() && effect.getPotion() == Potion.FLYING)
|
||||||
this.flying = false;
|
this.flying = false;
|
||||||
// super.onFinishedEffect(effect);
|
// super.onFinishedEffect(effect);
|
||||||
if(this.connection != null)
|
if(this.connection != null)
|
||||||
|
@ -3380,19 +3380,19 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasEffect(Potion.digSpeed))
|
if (this.hasEffect(Potion.HASTE))
|
||||||
{
|
{
|
||||||
int speed = this.getEffect(Potion.digSpeed).getAmplifier();
|
int speed = this.getEffect(Potion.HASTE).getAmplifier();
|
||||||
if(speed >= 255)
|
if(speed >= 255)
|
||||||
return 1000000.0f;
|
return 1000000.0f;
|
||||||
f *= 1.0F + (float)(speed + 1) * 0.2F;
|
f *= 1.0F + (float)(speed + 1) * 0.2F;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasEffect(Potion.digSlowdown))
|
if (this.hasEffect(Potion.FATIGUE))
|
||||||
{
|
{
|
||||||
float f1 = 1.0F;
|
float f1 = 1.0F;
|
||||||
|
|
||||||
switch (this.getEffect(Potion.digSlowdown).getAmplifier())
|
switch (this.getEffect(Potion.FATIGUE).getAmplifier())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
f1 = 0.3F;
|
f1 = 0.3F;
|
||||||
|
@ -3527,7 +3527,7 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
|
|
||||||
// this.foodStats.readNBT(tagCompund);
|
// this.foodStats.readNBT(tagCompund);
|
||||||
// this.readCapabilitiesFromNBT(tagCompund);
|
// this.readCapabilitiesFromNBT(tagCompund);
|
||||||
this.flying = tagCompund.getBoolean("flying") && this.hasEffect(Potion.flying);
|
this.flying = tagCompund.getBoolean("flying") && this.hasEffect(Potion.FLYING);
|
||||||
// if(tagCompund.hasKey("speed", 99))
|
// if(tagCompund.hasKey("speed", 99))
|
||||||
// this.speed = tagCompund.getFloat("speed");
|
// this.speed = tagCompund.getFloat("speed");
|
||||||
// this.disableDamagePersist = tagCompund.getBoolean("alwaysInvulnerable");
|
// this.disableDamagePersist = tagCompund.getBoolean("alwaysInvulnerable");
|
||||||
|
@ -3803,7 +3803,7 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
|
|
||||||
if (f > 0 || f1 > 0)
|
if (f > 0 || f1 > 0)
|
||||||
{
|
{
|
||||||
boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInLiquid() && !this.hasEffect(Potion.blindness) && this.vehicle == null && targetEntity instanceof EntityLiving;
|
boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInLiquid() && !this.hasEffect(Potion.BLINDNESS) && this.vehicle == null && targetEntity instanceof EntityLiving;
|
||||||
|
|
||||||
if (flag && f > 0)
|
if (flag && f > 0)
|
||||||
{
|
{
|
||||||
|
@ -4118,7 +4118,7 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
this.addStat((int)Math.round((double)distance * 100.0D));
|
this.addStat((int)Math.round((double)distance * 100.0D));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.hasEffect(Potion.flying))
|
if(!this.hasEffect(Potion.FLYING))
|
||||||
super.fall(distance, damageMultiplier);
|
super.fall(distance, damageMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class EntityBox extends EntityProjectile
|
||||||
//
|
//
|
||||||
// if (i > 0)
|
// if (i > 0)
|
||||||
// {
|
// {
|
||||||
((EntityLiving)movingObject.entity).addEffect(new PotionEffect(Potion.moveSlowdown.id, 20 * this.rand.range(35, 55), this.rand.chance(1, 2, 5)));
|
((EntityLiving)movingObject.entity).addEffect(new PotionEffect(Potion.SLOWNESS, 20 * this.rand.range(35, 55), this.rand.chance(1, 2, 5)));
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,11 +124,13 @@ public class EntityPotion extends EntityThrowable implements IObjectData
|
||||||
|
|
||||||
for (PotionEffect potioneffect : list)
|
for (PotionEffect potioneffect : list)
|
||||||
{
|
{
|
||||||
int i = potioneffect.getPotionID();
|
Potion i = potioneffect.getPotion();
|
||||||
|
if(!entitylivingbase.isPotionApplicable(i))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (Potion.POTION_TYPES[i].isInstant())
|
if (i.isInstant())
|
||||||
{
|
{
|
||||||
Potion.POTION_TYPES[i].affectEntity(this, this.getThrower(), entitylivingbase, potioneffect.getAmplifier(), d1);
|
i.onImpact(this, this.getThrower(), entitylivingbase, potioneffect.getAmplifier(), d1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,7 +75,7 @@ public abstract class EntityLiving extends Entity
|
||||||
|
|
||||||
private AttributeMap attributes;
|
private AttributeMap attributes;
|
||||||
private final List<CombatEntry> combat = Lists.<CombatEntry>newArrayList();
|
private final List<CombatEntry> combat = Lists.<CombatEntry>newArrayList();
|
||||||
private final Map<Integer, PotionEffect> effects = Maps.<Integer, PotionEffect>newHashMap();
|
private final Map<Potion, PotionEffect> effects = Maps.<Potion, PotionEffect>newEnumMap(Potion.class);
|
||||||
public int soundTimer;
|
public int soundTimer;
|
||||||
protected int xpValue;
|
protected int xpValue;
|
||||||
private EntityLookHelper lookHelper;
|
private EntityLookHelper lookHelper;
|
||||||
|
@ -373,7 +373,7 @@ public abstract class EntityLiving extends Entity
|
||||||
// if(this.isPlayer())
|
// if(this.isPlayer())
|
||||||
// Log.SERVER.info("rad:" + radiation);
|
// Log.SERVER.info("rad:" + radiation);
|
||||||
if(radiation >= 0.0f) {
|
if(radiation >= 0.0f) {
|
||||||
this.addEffect(new PotionEffect(Potion.radiation.id, ExtMath.clampi((int)(radiation * 5.0f), 10, 32766),
|
this.addEffect(new PotionEffect(Potion.RADIATION, ExtMath.clampi((int)(radiation * 5.0f), 10, 32766),
|
||||||
ExtMath.clampi((int)(radiation / 20.0f), 0, 255)));
|
ExtMath.clampi((int)(radiation / 20.0f), 0, 255)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -565,7 +565,7 @@ public abstract class EntityLiving extends Entity
|
||||||
|
|
||||||
for (PotionEffect potioneffect : this.effects.values())
|
for (PotionEffect potioneffect : this.effects.values())
|
||||||
{
|
{
|
||||||
nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
|
nbttaglist.appendTag(potioneffect.toNbt());
|
||||||
}
|
}
|
||||||
|
|
||||||
tagCompound.setTag("ActiveEffects", nbttaglist);
|
tagCompound.setTag("ActiveEffects", nbttaglist);
|
||||||
|
@ -615,11 +615,11 @@ public abstract class EntityLiving extends Entity
|
||||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||||
{
|
{
|
||||||
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
|
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
|
||||||
PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbttagcompound);
|
PotionEffect potioneffect = PotionEffect.fromNbt(nbttagcompound);
|
||||||
|
|
||||||
if (potioneffect != null)
|
if (potioneffect != null && !potioneffect.getPotion().isInstant())
|
||||||
{
|
{
|
||||||
this.effects.put(Integer.valueOf(potioneffect.getPotionID()), potioneffect);
|
this.effects.put(potioneffect.getPotion(), potioneffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,12 +665,12 @@ public abstract class EntityLiving extends Entity
|
||||||
|
|
||||||
protected void updateEffects()
|
protected void updateEffects()
|
||||||
{
|
{
|
||||||
Iterator<Integer> iterator = this.effects.keySet().iterator();
|
Iterator<Potion> iterator = this.effects.keySet().iterator();
|
||||||
|
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext())
|
||||||
{
|
{
|
||||||
Integer integer = (Integer)iterator.next();
|
Potion potion = iterator.next();
|
||||||
PotionEffect potioneffect = (PotionEffect)this.effects.get(integer);
|
PotionEffect potioneffect = this.effects.get(potion);
|
||||||
|
|
||||||
if (!potioneffect.onUpdate(this))
|
if (!potioneffect.onUpdate(this))
|
||||||
{
|
{
|
||||||
|
@ -680,7 +680,7 @@ public abstract class EntityLiving extends Entity
|
||||||
this.onFinishedEffect(potioneffect);
|
this.onFinishedEffect(potioneffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (potioneffect.getDuration() % 600 == 0)
|
else if (potioneffect.getRemaining() % 600 == 0)
|
||||||
{
|
{
|
||||||
this.onChangedEffect(potioneffect, false);
|
this.onChangedEffect(potioneffect, false);
|
||||||
}
|
}
|
||||||
|
@ -758,14 +758,14 @@ public abstract class EntityLiving extends Entity
|
||||||
|
|
||||||
public void clearEffects(boolean negative)
|
public void clearEffects(boolean negative)
|
||||||
{
|
{
|
||||||
Iterator<Integer> iterator = this.effects.keySet().iterator();
|
Iterator<Potion> iterator = this.effects.keySet().iterator();
|
||||||
|
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext())
|
||||||
{
|
{
|
||||||
Integer integer = (Integer)iterator.next();
|
Potion potion = iterator.next();
|
||||||
PotionEffect potioneffect = (PotionEffect)this.effects.get(integer);
|
PotionEffect potioneffect = this.effects.get(potion);
|
||||||
|
|
||||||
if (!this.worldObj.client && (!negative || Potion.POTION_TYPES[potioneffect.getPotionID()].isBadEffect()))
|
if (!this.worldObj.client && (!negative || potioneffect.getPotion().isBadEffect()))
|
||||||
{
|
{
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
this.onFinishedEffect(potioneffect);
|
this.onFinishedEffect(potioneffect);
|
||||||
|
@ -778,14 +778,14 @@ public abstract class EntityLiving extends Entity
|
||||||
return this.effects.values();
|
return this.effects.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasEffect(int potionId)
|
// public boolean hasEffect(int potionId)
|
||||||
{
|
// {
|
||||||
return this.effects.containsKey(Integer.valueOf(potionId));
|
// return this.effects.containsKey(Integer.valueOf(potionId));
|
||||||
}
|
// }
|
||||||
|
|
||||||
public boolean hasEffect(Potion potionIn)
|
public boolean hasEffect(Potion potionIn)
|
||||||
{
|
{
|
||||||
return this.effects.containsKey(Integer.valueOf(potionIn.id));
|
return this.effects.containsKey(potionIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -793,7 +793,7 @@ public abstract class EntityLiving extends Entity
|
||||||
*/
|
*/
|
||||||
public PotionEffect getEffect(Potion potionIn)
|
public PotionEffect getEffect(Potion potionIn)
|
||||||
{
|
{
|
||||||
return (PotionEffect)this.effects.get(Integer.valueOf(potionIn.id));
|
return this.effects.get(potionIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -801,22 +801,22 @@ public abstract class EntityLiving extends Entity
|
||||||
*/
|
*/
|
||||||
public void addEffect(PotionEffect potioneffectIn)
|
public void addEffect(PotionEffect potioneffectIn)
|
||||||
{
|
{
|
||||||
if (this.isPotionApplicable(potioneffectIn))
|
if (!potioneffectIn.getPotion().isInstant() && this.isPotionApplicable(potioneffectIn.getPotion()))
|
||||||
{
|
{
|
||||||
if (this.effects.containsKey(Integer.valueOf(potioneffectIn.getPotionID())))
|
if (this.effects.containsKey(potioneffectIn.getPotion()))
|
||||||
{
|
{
|
||||||
((PotionEffect)this.effects.get(Integer.valueOf(potioneffectIn.getPotionID()))).combine(potioneffectIn);
|
this.effects.put(potioneffectIn.getPotion(), this.effects.get(potioneffectIn.getPotion()).combine(potioneffectIn));
|
||||||
this.onChangedEffect((PotionEffect)this.effects.get(Integer.valueOf(potioneffectIn.getPotionID())), true);
|
this.onChangedEffect(this.effects.get(potioneffectIn.getPotion()), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.effects.put(Integer.valueOf(potioneffectIn.getPotionID()), potioneffectIn);
|
this.effects.put(potioneffectIn.getPotion(), potioneffectIn);
|
||||||
this.onNewEffect(potioneffectIn);
|
this.onNewEffect(potioneffectIn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPotionApplicable(PotionEffect potioneffectIn)
|
public boolean isPotionApplicable(Potion potion)
|
||||||
{
|
{
|
||||||
// if (this.getCreatureType() == CreatureType.UNDEAD)
|
// if (this.getCreatureType() == CreatureType.UNDEAD)
|
||||||
// {
|
// {
|
||||||
|
@ -839,17 +839,17 @@ public abstract class EntityLiving extends Entity
|
||||||
/**
|
/**
|
||||||
* Remove the speified potion effect from this entity.
|
* Remove the speified potion effect from this entity.
|
||||||
*/
|
*/
|
||||||
public void removeEffectClient(int potionId)
|
public void removeEffectClient(Potion potionId)
|
||||||
{
|
{
|
||||||
this.effects.remove(Integer.valueOf(potionId));
|
this.effects.remove(potionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the specified potion effect from this entity.
|
* Remove the specified potion effect from this entity.
|
||||||
*/
|
*/
|
||||||
public void removeEffect(int potionId)
|
public void removeEffect(Potion potion)
|
||||||
{
|
{
|
||||||
PotionEffect potioneffect = (PotionEffect)this.effects.remove(Integer.valueOf(potionId));
|
PotionEffect potioneffect = this.effects.remove(potion);
|
||||||
|
|
||||||
if (potioneffect != null)
|
if (potioneffect != null)
|
||||||
{
|
{
|
||||||
|
@ -863,7 +863,7 @@ public abstract class EntityLiving extends Entity
|
||||||
|
|
||||||
if (!this.worldObj.client)
|
if (!this.worldObj.client)
|
||||||
{
|
{
|
||||||
Potion.POTION_TYPES[id.getPotionID()].applyAttributesModifiersToEntity(this, this.getAttributeMap(), id.getAmplifier());
|
id.getPotion().addModifiers(this, this.getAttributeMap(), id.getAmplifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,8 +873,8 @@ public abstract class EntityLiving extends Entity
|
||||||
|
|
||||||
if (added && !this.worldObj.client)
|
if (added && !this.worldObj.client)
|
||||||
{
|
{
|
||||||
Potion.POTION_TYPES[id.getPotionID()].removeAttributesModifiersFromEntity(this, this.getAttributeMap(), id.getAmplifier());
|
id.getPotion().removeModifiers(this, this.getAttributeMap(), id.getAmplifier());
|
||||||
Potion.POTION_TYPES[id.getPotionID()].applyAttributesModifiersToEntity(this, this.getAttributeMap(), id.getAmplifier());
|
id.getPotion().addModifiers(this, this.getAttributeMap(), id.getAmplifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -884,7 +884,7 @@ public abstract class EntityLiving extends Entity
|
||||||
|
|
||||||
if (!this.worldObj.client)
|
if (!this.worldObj.client)
|
||||||
{
|
{
|
||||||
Potion.POTION_TYPES[effect.getPotionID()].removeAttributesModifiersFromEntity(this, this.getAttributeMap(), effect.getAmplifier());
|
effect.getPotion().removeModifiers(this, this.getAttributeMap(), effect.getAmplifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -917,7 +917,7 @@ public abstract class EntityLiving extends Entity
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isImmuneToFire() {
|
public boolean isImmuneToFire() {
|
||||||
return this.hasEffect(Potion.fireResistance);
|
return this.hasEffect(Potion.FIRE_RESISTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1217,7 +1217,7 @@ public abstract class EntityLiving extends Entity
|
||||||
{
|
{
|
||||||
damageMultiplier = Math.max(0.0f, damageMultiplier - (1.65f - (float)this.worldObj.gravity * 1.65f));
|
damageMultiplier = Math.max(0.0f, damageMultiplier - (1.65f - (float)this.worldObj.gravity * 1.65f));
|
||||||
super.fall(distance, damageMultiplier);
|
super.fall(distance, damageMultiplier);
|
||||||
PotionEffect potioneffect = this.getEffect(Potion.jump);
|
PotionEffect potioneffect = this.getEffect(Potion.JUMP);
|
||||||
float f = potioneffect != null ? (float)(potioneffect.getAmplifier() + 1) : 0.0F;
|
float f = potioneffect != null ? (float)(potioneffect.getAmplifier() + 1) : 0.0F;
|
||||||
int i = ExtMath.ceilf((distance - 3.0F - f) * damageMultiplier);
|
int i = ExtMath.ceilf((distance - 3.0F - f) * damageMultiplier);
|
||||||
|
|
||||||
|
@ -1303,9 +1303,9 @@ public abstract class EntityLiving extends Entity
|
||||||
*/
|
*/
|
||||||
protected int applyPotionDamageCalculations(DamageSource source, int damage)
|
protected int applyPotionDamageCalculations(DamageSource source, int damage)
|
||||||
{
|
{
|
||||||
if (this.hasEffect(Potion.resistance) && source != DamageSource.outOfWorld)
|
if (this.hasEffect(Potion.RESISTANCE) && source != DamageSource.outOfWorld)
|
||||||
{
|
{
|
||||||
int i = (this.getEffect(Potion.resistance).getAmplifier() + 1) * 5;
|
int i = (this.getEffect(Potion.RESISTANCE).getAmplifier() + 1) * 5;
|
||||||
int j = 25 - i;
|
int j = 25 - i;
|
||||||
float f = (float)damage * (float)j;
|
float f = (float)damage * (float)j;
|
||||||
damage = (int)(f / 25.0F);
|
damage = (int)(f / 25.0F);
|
||||||
|
@ -1638,9 +1638,9 @@ public abstract class EntityLiving extends Entity
|
||||||
{
|
{
|
||||||
this.motionY = (double)this.getJumpUpwardsMotion();
|
this.motionY = (double)this.getJumpUpwardsMotion();
|
||||||
|
|
||||||
if (this.hasEffect(Potion.jump))
|
if (this.hasEffect(Potion.JUMP))
|
||||||
{
|
{
|
||||||
this.motionY += (double)((float)(this.getEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
|
this.motionY += (double)((float)(this.getEffect(Potion.JUMP).getAmplifier() + 1) * 0.1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isSprinting())
|
if (this.isSprinting())
|
||||||
|
|
|
@ -417,7 +417,7 @@ public abstract class ItemRegistry {
|
||||||
registerItem("flint", (new Item()).setDisplay("Feuerstein").setTab(CheatTab.tabMaterials).setMaxStackSize(128));
|
registerItem("flint", (new Item()).setDisplay("Feuerstein").setTab(CheatTab.tabMaterials).setMaxStackSize(128));
|
||||||
registerItem("porkchop", (new ItemFood(3, true)).setDisplay("Rohes Schweinefleisch"));
|
registerItem("porkchop", (new ItemFood(3, true)).setDisplay("Rohes Schweinefleisch"));
|
||||||
registerItem("cooked_porkchop", (new ItemFood(8, true)).setDisplay("Gebratenes Schweinefleisch"));
|
registerItem("cooked_porkchop", (new ItemFood(8, true)).setDisplay("Gebratenes Schweinefleisch"));
|
||||||
registerItem("golden_apple", (new ItemAppleGold(4, false)).setPotionEffect(Potion.regeneration.id, 5, 1, 1.0F)
|
registerItem("golden_apple", (new ItemAppleGold(4, false)).setPotionEffect(Potion.REGENERATION, 5, 1, 1.0F)
|
||||||
.setDisplay("Goldener Apfel"));
|
.setDisplay("Goldener Apfel"));
|
||||||
registerItem((new ItemSign()).setDisplay("Schild"));
|
registerItem((new ItemSign()).setDisplay("Schild"));
|
||||||
// registerItem("oak_door", (new ItemDoor(Blocks.oak_door)).setUnlocalizedName("doorOak"));
|
// registerItem("oak_door", (new ItemDoor(Blocks.oak_door)).setUnlocalizedName("doorOak"));
|
||||||
|
@ -464,7 +464,7 @@ public abstract class ItemRegistry {
|
||||||
registerItem((new ItemSeeds(Blocks.soul_wart, Blocks.soul_sand)).setDisplay("Seelenwarze").setPotionEffect("+4").setMaxStackSize(128));
|
registerItem((new ItemSeeds(Blocks.soul_wart, Blocks.soul_sand)).setDisplay("Seelenwarze").setPotionEffect("+4").setMaxStackSize(128));
|
||||||
registerItem("potion", (new ItemPotion()).setDisplay("Trank"));
|
registerItem("potion", (new ItemPotion()).setDisplay("Trank"));
|
||||||
registerItem("glass_bottle", (new ItemGlassBottle()).setDisplay("Glasflasche"));
|
registerItem("glass_bottle", (new ItemGlassBottle()).setDisplay("Glasflasche"));
|
||||||
registerItem("spider_eye", (new ItemFood(2, false)).setPotionEffect(Potion.poison.id, 5, 0, 1.0F).setDisplay("Spinnenauge")
|
registerItem("spider_eye", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 1.0F).setDisplay("Spinnenauge")
|
||||||
.setPotionEffect(PotionHelper.spiderEyeEffect).setMaxStackSize(128));
|
.setPotionEffect(PotionHelper.spiderEyeEffect).setMaxStackSize(128));
|
||||||
registerItem("fermented_spider_eye", (new Item()).setDisplay("Fermentiertes Spinnenauge")
|
registerItem("fermented_spider_eye", (new Item()).setDisplay("Fermentiertes Spinnenauge")
|
||||||
.setPotionEffect(PotionHelper.fermentedSpiderEyeEffect).setTab(CheatTab.tabMisc).setMaxStackSize(128));
|
.setPotionEffect(PotionHelper.fermentedSpiderEyeEffect).setTab(CheatTab.tabMisc).setMaxStackSize(128));
|
||||||
|
@ -486,7 +486,7 @@ public abstract class ItemRegistry {
|
||||||
registerItem((new ItemSeedFood(3, Blocks.carrot, Blocks.farmland)).setDisplay("Karotte").setMaxStackSize(128));
|
registerItem((new ItemSeedFood(3, Blocks.carrot, Blocks.farmland)).setDisplay("Karotte").setMaxStackSize(128));
|
||||||
registerItem((new ItemSeedFood(1, Blocks.potato, Blocks.farmland)).setDisplay("Kartoffel").setMaxStackSize(128));
|
registerItem((new ItemSeedFood(1, Blocks.potato, Blocks.farmland)).setDisplay("Kartoffel").setMaxStackSize(128));
|
||||||
registerItem("baked_potato", (new ItemFood(5, false)).setDisplay("Ofenkartoffel").setMaxStackSize(128));
|
registerItem("baked_potato", (new ItemFood(5, false)).setDisplay("Ofenkartoffel").setMaxStackSize(128));
|
||||||
registerItem("poisonous_potato", (new ItemFood(2, false)).setPotionEffect(Potion.poison.id, 5, 0, 0.6F).setDisplay("Giftige Kartoffel").setMaxStackSize(128));
|
registerItem("poisonous_potato", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 0.6F).setDisplay("Giftige Kartoffel").setMaxStackSize(128));
|
||||||
registerItem("golden_carrot", (new ItemFood(6, false)).setDisplay("Goldene Karotte")
|
registerItem("golden_carrot", (new ItemFood(6, false)).setDisplay("Goldene Karotte")
|
||||||
.setPotionEffect(PotionHelper.goldenCarrotEffect).setTab(CheatTab.tabMisc));
|
.setPotionEffect(PotionHelper.goldenCarrotEffect).setTab(CheatTab.tabMisc));
|
||||||
registerItem((new ItemSkull()).setDisplay("Kopf"));
|
registerItem((new ItemSkull()).setDisplay("Kopf"));
|
||||||
|
|
|
@ -34,16 +34,16 @@ public class ItemAppleGold extends ItemFood
|
||||||
{
|
{
|
||||||
if (!worldIn.client)
|
if (!worldIn.client)
|
||||||
{
|
{
|
||||||
player.addEffect(new PotionEffect(Potion.absorption.id, 2400, 0));
|
player.addEffect(new PotionEffect(Potion.ABSORPTION, 2400, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getMetadata() > 0)
|
if (stack.getMetadata() > 0)
|
||||||
{
|
{
|
||||||
if (!worldIn.client)
|
if (!worldIn.client)
|
||||||
{
|
{
|
||||||
player.addEffect(new PotionEffect(Potion.regeneration.id, 600, 4));
|
player.addEffect(new PotionEffect(Potion.REGENERATION, 600, 4));
|
||||||
player.addEffect(new PotionEffect(Potion.resistance.id, 6000, 0));
|
player.addEffect(new PotionEffect(Potion.RESISTANCE, 6000, 0));
|
||||||
player.addEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0));
|
player.addEffect(new PotionEffect(Potion.FIRE_RESISTANCE, 6000, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class ItemFishFood extends ItemFood
|
||||||
|
|
||||||
if (itemfishfood$fishtype == ItemFishFood.FishType.PUFFERFISH)
|
if (itemfishfood$fishtype == ItemFishFood.FishType.PUFFERFISH)
|
||||||
{
|
{
|
||||||
player.addEffect(new PotionEffect(Potion.poison.id, 1200, 3));
|
player.addEffect(new PotionEffect(Potion.POISON, 1200, 3));
|
||||||
player.addEffect(new PotionEffect(Potion.confusion.id, 300, 1));
|
player.addEffect(new PotionEffect(Potion.NAUSEA, 300, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onFoodEaten(stack, worldIn, player);
|
super.onFoodEaten(stack, worldIn, player);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package game.item;
|
||||||
|
|
||||||
import game.entity.npc.EntityNPC;
|
import game.entity.npc.EntityNPC;
|
||||||
import game.init.SoundEvent;
|
import game.init.SoundEvent;
|
||||||
|
import game.potion.Potion;
|
||||||
import game.potion.PotionEffect;
|
import game.potion.PotionEffect;
|
||||||
import game.world.World;
|
import game.world.World;
|
||||||
|
|
||||||
|
@ -10,7 +11,7 @@ public class ItemFood extends Item
|
||||||
public final int itemUseDuration;
|
public final int itemUseDuration;
|
||||||
private final int healAmount;
|
private final int healAmount;
|
||||||
private final boolean isWolfsFavoriteMeat;
|
private final boolean isWolfsFavoriteMeat;
|
||||||
private int potionId;
|
private Potion potionId;
|
||||||
private int potionDuration;
|
private int potionDuration;
|
||||||
private int potionAmplifier;
|
private int potionAmplifier;
|
||||||
private float potionEffectProbability;
|
private float potionEffectProbability;
|
||||||
|
@ -40,7 +41,7 @@ public class ItemFood extends Item
|
||||||
|
|
||||||
protected void onFoodEaten(ItemStack stack, World worldIn, EntityNPC player)
|
protected void onFoodEaten(ItemStack stack, World worldIn, EntityNPC player)
|
||||||
{
|
{
|
||||||
if (!worldIn.client && this.potionId > 0 && worldIn.rand.floatv() < this.potionEffectProbability)
|
if (!worldIn.client && this.potionId != null && worldIn.rand.floatv() < this.potionEffectProbability)
|
||||||
{
|
{
|
||||||
player.addEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier));
|
player.addEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier));
|
||||||
}
|
}
|
||||||
|
@ -88,7 +89,7 @@ public class ItemFood extends Item
|
||||||
* sets a potion effect on the item. Args: int potionId, int duration (will be multiplied by 20), int amplifier,
|
* sets a potion effect on the item. Args: int potionId, int duration (will be multiplied by 20), int amplifier,
|
||||||
* float probability of effect happening
|
* float probability of effect happening
|
||||||
*/
|
*/
|
||||||
public ItemFood setPotionEffect(int id, int duration, int amplifier, float probability)
|
public ItemFood setPotionEffect(Potion id, int duration, int amplifier, float probability)
|
||||||
{
|
{
|
||||||
this.potionId = id;
|
this.potionId = id;
|
||||||
this.potionDuration = duration;
|
this.potionDuration = duration;
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ItemPotion extends Item
|
||||||
|
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
list = PotionHelper.getPotionEffects(stack.getMetadata(), false);
|
list = PotionHelper.getPotionEffects(stack.getMetadata());
|
||||||
this.effectCache.put(Integer.valueOf(stack.getMetadata()), list);
|
this.effectCache.put(Integer.valueOf(stack.getMetadata()), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class ItemPotion extends Item
|
||||||
|
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
list = PotionHelper.getPotionEffects(meta, false);
|
list = PotionHelper.getPotionEffects(meta);
|
||||||
this.effectCache.put(Integer.valueOf(meta), list);
|
this.effectCache.put(Integer.valueOf(meta), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ public class ItemPotion extends Item
|
||||||
{
|
{
|
||||||
for (PotionEffect potioneffect : list)
|
for (PotionEffect potioneffect : list)
|
||||||
{
|
{
|
||||||
if (Potion.POTION_TYPES[potioneffect.getPotionID()].isInstant())
|
if (potioneffect.getPotion().isInstant())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -254,15 +254,15 @@ public class ItemPotion extends Item
|
||||||
for (PotionEffect potioneffect : list)
|
for (PotionEffect potioneffect : list)
|
||||||
{
|
{
|
||||||
String s1 = potioneffect.getEffectName().trim();
|
String s1 = potioneffect.getEffectName().trim();
|
||||||
Potion potion = Potion.POTION_TYPES[potioneffect.getPotionID()];
|
Potion potion = potioneffect.getPotion();
|
||||||
Map<Attribute, AttributeModifier> map = potion.getAttributeModifierMap();
|
Map<Attribute, AttributeModifier> map = potion.getModifiers();
|
||||||
|
|
||||||
if (map != null && map.size() > 0)
|
if (map != null && map.size() > 0)
|
||||||
{
|
{
|
||||||
for (Entry<Attribute, AttributeModifier> entry : map.entrySet())
|
for (Entry<Attribute, AttributeModifier> entry : map.entrySet())
|
||||||
{
|
{
|
||||||
AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
|
AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
|
||||||
AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.getAttributeModifierAmount(potioneffect.getAmplifier(), attributemodifier), attributemodifier.isMultiplied());
|
AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.getAmount(potioneffect.getAmplifier(), attributemodifier), attributemodifier.isMultiplied());
|
||||||
Set<AttributeModifier> set = multimap.get(entry.getKey());
|
Set<AttributeModifier> set = multimap.get(entry.getKey());
|
||||||
if(set == null)
|
if(set == null)
|
||||||
multimap.put(entry.getKey(), set = Sets.newHashSet());
|
multimap.put(entry.getKey(), set = Sets.newHashSet());
|
||||||
|
@ -283,7 +283,7 @@ public class ItemPotion extends Item
|
||||||
|
|
||||||
if (potioneffect.getDuration() > 20)
|
if (potioneffect.getDuration() > 20)
|
||||||
{
|
{
|
||||||
s1 = s1 + " (" + Potion.getDurationString(potioneffect) + ")";
|
s1 = s1 + " (" + potioneffect.getDurationString() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (potion.isBadEffect())
|
if (potion.isBadEffect())
|
||||||
|
@ -384,7 +384,7 @@ public class ItemPotion extends Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PotionEffect> list = PotionHelper.getPotionEffects(i1, false);
|
List<PotionEffect> list = PotionHelper.getPotionEffects(i1);
|
||||||
|
|
||||||
if (list != null && !list.isEmpty())
|
if (list != null && !list.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1404,8 +1404,8 @@ public class ClientPlayer extends NetHandler
|
||||||
|
|
||||||
if (entity instanceof EntityLiving)
|
if (entity instanceof EntityLiving)
|
||||||
{
|
{
|
||||||
PotionEffect potioneffect = new PotionEffect(packetIn.getEffectId(), packetIn.getDuration(), packetIn.getAmplifier(), false, packetIn.func_179707_f());
|
PotionEffect potioneffect = new PotionEffect(packetIn.getEffectId(), packetIn.getDuration(), packetIn.getAmplifier(), false, packetIn.hasParticles())
|
||||||
potioneffect.setPotionDurationMax(packetIn.func_149429_c());
|
.setRemaining(packetIn.getRemaining());
|
||||||
((EntityLiving)entity).addEffect(potioneffect);
|
((EntityLiving)entity).addEffect(potioneffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1751,7 +1751,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
||||||
this.admin = admin;
|
this.admin = admin;
|
||||||
if(!this.isAdmin() && this.entity != null && this.entity.noclip) {
|
if(!this.isAdmin() && this.entity != null && this.entity.noclip) {
|
||||||
this.entity.noclip = false;
|
this.entity.noclip = false;
|
||||||
this.entity.flying &= this.entity.hasEffect(Potion.flying);
|
this.entity.flying &= this.entity.hasEffect(Potion.FLYING);
|
||||||
this.entity.fallDistance = 0.0F;
|
this.entity.fallDistance = 0.0F;
|
||||||
this.sendPlayerAbilities();
|
this.sendPlayerAbilities();
|
||||||
this.addFeed(TextColor.RED + "NoClip wurde deaktiviert");
|
this.addFeed(TextColor.RED + "NoClip wurde deaktiviert");
|
||||||
|
@ -2520,7 +2520,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case START_FLYING:
|
case START_FLYING:
|
||||||
this.entity.flying = this.entity.hasEffect(Potion.flying) || this.entity.noclip;
|
this.entity.flying = this.entity.hasEffect(Potion.FLYING) || this.entity.noclip;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STOP_FLYING:
|
case STOP_FLYING:
|
||||||
|
@ -2640,12 +2640,12 @@ public class Player extends NetHandler implements ICrafting, Executor
|
||||||
if(this.isAdmin()) {
|
if(this.isAdmin()) {
|
||||||
// this.playerEntity.setCheat(!this.playerEntity.godmode);
|
// this.playerEntity.setCheat(!this.playerEntity.godmode);
|
||||||
this.entity.fallDistance = 0.0F;
|
this.entity.fallDistance = 0.0F;
|
||||||
if(this.entity.hasEffect(Potion.digSpeed) && this.entity.getEffect(Potion.digSpeed).getAmplifier() == 255) {
|
if(this.entity.hasEffect(Potion.HASTE) && this.entity.getEffect(Potion.HASTE).getAmplifier() == 255) {
|
||||||
this.entity.removeEffect(Potion.digSpeed.id);
|
this.entity.removeEffect(Potion.HASTE);
|
||||||
this.entity.removeEffect(Potion.resistance.id);
|
this.entity.removeEffect(Potion.RESISTANCE);
|
||||||
this.entity.removeEffect(Potion.fireResistance.id);
|
this.entity.removeEffect(Potion.FIRE_RESISTANCE);
|
||||||
this.entity.removeEffect(Potion.flying.id);
|
this.entity.removeEffect(Potion.FLYING);
|
||||||
this.entity.removeEffect(Potion.manaBoost.id);
|
this.entity.removeEffect(Potion.MANA);
|
||||||
this.addFeed(TextColor.RED + "Statuseffekte wurden entfernt");
|
this.addFeed(TextColor.RED + "Statuseffekte wurden entfernt");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2653,11 +2653,11 @@ public class Player extends NetHandler implements ICrafting, Executor
|
||||||
this.entity.setHealth(this.entity.getMaxHealth());
|
this.entity.setHealth(this.entity.getMaxHealth());
|
||||||
this.entity.setManaPoints(this.entity.getMaxMana());
|
this.entity.setManaPoints(this.entity.getMaxMana());
|
||||||
this.entity.clearEffects(false);
|
this.entity.clearEffects(false);
|
||||||
this.entity.addEffect(new PotionEffect(Potion.digSpeed.id, Integer.MAX_VALUE, 255, false, false));
|
this.entity.addEffect(new PotionEffect(Potion.HASTE, Integer.MAX_VALUE, 255, false, false));
|
||||||
this.entity.addEffect(new PotionEffect(Potion.resistance.id, Integer.MAX_VALUE, 255, false, false));
|
this.entity.addEffect(new PotionEffect(Potion.RESISTANCE, Integer.MAX_VALUE, 255, false, false));
|
||||||
this.entity.addEffect(new PotionEffect(Potion.fireResistance.id, Integer.MAX_VALUE, 0, false, false));
|
this.entity.addEffect(new PotionEffect(Potion.FIRE_RESISTANCE, Integer.MAX_VALUE, 0, false, false));
|
||||||
this.entity.addEffect(new PotionEffect(Potion.flying.id, Integer.MAX_VALUE, 0, false, false));
|
this.entity.addEffect(new PotionEffect(Potion.FLYING, Integer.MAX_VALUE, 0, false, false));
|
||||||
this.entity.addEffect(new PotionEffect(Potion.manaBoost.id, Integer.MAX_VALUE, 255, false, false));
|
this.entity.addEffect(new PotionEffect(Potion.MANA, Integer.MAX_VALUE, 255, false, false));
|
||||||
this.addFeed(TextColor.GREEN + "Statuseffekte wurden hinzugefügt");
|
this.addFeed(TextColor.GREEN + "Statuseffekte wurden hinzugefügt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2668,7 +2668,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
||||||
if(!this.entity.noclip)
|
if(!this.entity.noclip)
|
||||||
this.entity.mountEntity(null);
|
this.entity.mountEntity(null);
|
||||||
this.entity.noclip ^= true;
|
this.entity.noclip ^= true;
|
||||||
this.entity.flying &= this.entity.hasEffect(Potion.flying) || this.entity.noclip;
|
this.entity.flying &= this.entity.hasEffect(Potion.FLYING) || this.entity.noclip;
|
||||||
this.entity.fallDistance = 0.0F;
|
this.entity.fallDistance = 0.0F;
|
||||||
this.sendPlayerAbilities();
|
this.sendPlayerAbilities();
|
||||||
this.addFeed((this.entity.noclip ? TextColor.GREEN : TextColor.RED) + "NoClip ist jetzt " + (this.entity.noclip ? "eingeschaltet" : "ausgeschaltet"));
|
this.addFeed((this.entity.noclip ? TextColor.GREEN : TextColor.RED) + "NoClip ist jetzt " + (this.entity.noclip ? "eingeschaltet" : "ausgeschaltet"));
|
||||||
|
@ -2677,10 +2677,10 @@ public class Player extends NetHandler implements ICrafting, Executor
|
||||||
|
|
||||||
case SPEED:
|
case SPEED:
|
||||||
if(this.isAdmin()) {
|
if(this.isAdmin()) {
|
||||||
if(this.entity.hasEffect(Potion.moveSpeed))
|
if(this.entity.hasEffect(Potion.SPEED))
|
||||||
this.entity.removeEffect(Potion.moveSpeed.id);
|
this.entity.removeEffect(Potion.SPEED);
|
||||||
else
|
else
|
||||||
this.entity.addEffect(new PotionEffect(Potion.moveSpeed.id, Integer.MAX_VALUE, 19, false, false));
|
this.entity.addEffect(new PotionEffect(Potion.SPEED, Integer.MAX_VALUE, 19, false, false));
|
||||||
this.addFeed(TextColor.GREEN + "Deine Geschwindigkeit wurde auf %dx geändert", (int)(this.entity.getAIMoveSpeed() * 10.0f));
|
this.addFeed(TextColor.GREEN + "Deine Geschwindigkeit wurde auf %dx geändert", (int)(this.entity.getAIMoveSpeed() * 10.0f));
|
||||||
// int speed = this.playerEntity.speed != 1.0f ? 1 : 5;
|
// int speed = this.playerEntity.speed != 1.0f ? 1 : 5;
|
||||||
// this.playerEntity.speed = (float)speed;
|
// this.playerEntity.speed = (float)speed;
|
||||||
|
|
|
@ -5,15 +5,17 @@ import java.io.IOException;
|
||||||
import game.network.ClientPlayer;
|
import game.network.ClientPlayer;
|
||||||
import game.network.Packet;
|
import game.network.Packet;
|
||||||
import game.network.PacketBuffer;
|
import game.network.PacketBuffer;
|
||||||
|
import game.potion.Potion;
|
||||||
import game.potion.PotionEffect;
|
import game.potion.PotionEffect;
|
||||||
|
|
||||||
public class S1DPacketEntityEffect implements Packet<ClientPlayer>
|
public class S1DPacketEntityEffect implements Packet<ClientPlayer>
|
||||||
{
|
{
|
||||||
private int entityId;
|
private int entityId;
|
||||||
private byte effectId;
|
private Potion effectId;
|
||||||
private int amplifier;
|
private int amplifier;
|
||||||
private int duration;
|
private int duration;
|
||||||
private byte hideParticles;
|
private int remaining;
|
||||||
|
private boolean particles;
|
||||||
|
|
||||||
public S1DPacketEntityEffect()
|
public S1DPacketEntityEffect()
|
||||||
{
|
{
|
||||||
|
@ -22,19 +24,20 @@ public class S1DPacketEntityEffect implements Packet<ClientPlayer>
|
||||||
public S1DPacketEntityEffect(int entityIdIn, PotionEffect effect)
|
public S1DPacketEntityEffect(int entityIdIn, PotionEffect effect)
|
||||||
{
|
{
|
||||||
this.entityId = entityIdIn;
|
this.entityId = entityIdIn;
|
||||||
this.effectId = (byte)(effect.getPotionID() & 255);
|
this.effectId = effect.getPotion();
|
||||||
this.amplifier = /* (byte)(*/ effect.getAmplifier(); // & 255);
|
this.amplifier = /* (byte)(*/ effect.getAmplifier(); // & 255);
|
||||||
|
|
||||||
if (effect.getDuration() > 32767)
|
// if (effect.getDuration() > 32767)
|
||||||
{
|
// {
|
||||||
this.duration = 32767;
|
// this.duration = 32767;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
this.duration = effect.getDuration();
|
this.duration = effect.getDuration();
|
||||||
}
|
this.remaining = effect.getRemaining();
|
||||||
|
// }
|
||||||
|
|
||||||
this.hideParticles = (byte)(effect.getIsShowParticles() ? 1 : 0);
|
this.particles = effect.getIsShowParticles();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,10 +46,11 @@ public class S1DPacketEntityEffect implements Packet<ClientPlayer>
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.entityId = buf.readVarIntFromBuffer();
|
this.entityId = buf.readVarIntFromBuffer();
|
||||||
this.effectId = buf.readByte();
|
this.effectId = buf.readEnumValue(Potion.class);
|
||||||
this.amplifier = buf.readVarIntFromBuffer();
|
this.amplifier = buf.readVarIntFromBuffer();
|
||||||
this.duration = buf.readVarIntFromBuffer();
|
this.duration = buf.readVarIntFromBuffer();
|
||||||
this.hideParticles = buf.readByte();
|
this.remaining = buf.readVarIntFromBuffer();
|
||||||
|
this.particles = buf.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,15 +59,11 @@ public class S1DPacketEntityEffect implements Packet<ClientPlayer>
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeVarIntToBuffer(this.entityId);
|
buf.writeVarIntToBuffer(this.entityId);
|
||||||
buf.writeByte(this.effectId);
|
buf.writeEnumValue(this.effectId);
|
||||||
buf.writeVarIntToBuffer(this.amplifier);
|
buf.writeVarIntToBuffer(this.amplifier);
|
||||||
buf.writeVarIntToBuffer(this.duration);
|
buf.writeVarIntToBuffer(this.duration);
|
||||||
buf.writeByte(this.hideParticles);
|
buf.writeVarIntToBuffer(this.remaining);
|
||||||
}
|
buf.writeBoolean(this.particles);
|
||||||
|
|
||||||
public boolean func_149429_c()
|
|
||||||
{
|
|
||||||
return this.duration == 32767;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +79,7 @@ public class S1DPacketEntityEffect implements Packet<ClientPlayer>
|
||||||
return this.entityId;
|
return this.entityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getEffectId()
|
public Potion getEffectId()
|
||||||
{
|
{
|
||||||
return this.effectId;
|
return this.effectId;
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,13 @@ public class S1DPacketEntityEffect implements Packet<ClientPlayer>
|
||||||
return this.duration;
|
return this.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean func_179707_f()
|
public int getRemaining()
|
||||||
{
|
{
|
||||||
return this.hideParticles != 0;
|
return this.remaining;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasParticles()
|
||||||
|
{
|
||||||
|
return this.particles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,13 @@ import java.io.IOException;
|
||||||
import game.network.ClientPlayer;
|
import game.network.ClientPlayer;
|
||||||
import game.network.Packet;
|
import game.network.Packet;
|
||||||
import game.network.PacketBuffer;
|
import game.network.PacketBuffer;
|
||||||
|
import game.potion.Potion;
|
||||||
import game.potion.PotionEffect;
|
import game.potion.PotionEffect;
|
||||||
|
|
||||||
public class S1EPacketRemoveEntityEffect implements Packet<ClientPlayer>
|
public class S1EPacketRemoveEntityEffect implements Packet<ClientPlayer>
|
||||||
{
|
{
|
||||||
private int entityId;
|
private int entityId;
|
||||||
private int effectId;
|
private Potion effectId;
|
||||||
|
|
||||||
public S1EPacketRemoveEntityEffect()
|
public S1EPacketRemoveEntityEffect()
|
||||||
{
|
{
|
||||||
|
@ -19,7 +20,7 @@ public class S1EPacketRemoveEntityEffect implements Packet<ClientPlayer>
|
||||||
public S1EPacketRemoveEntityEffect(int entityIdIn, PotionEffect effect)
|
public S1EPacketRemoveEntityEffect(int entityIdIn, PotionEffect effect)
|
||||||
{
|
{
|
||||||
this.entityId = entityIdIn;
|
this.entityId = entityIdIn;
|
||||||
this.effectId = effect.getPotionID();
|
this.effectId = effect.getPotion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +29,7 @@ public class S1EPacketRemoveEntityEffect implements Packet<ClientPlayer>
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.entityId = buf.readVarIntFromBuffer();
|
this.entityId = buf.readVarIntFromBuffer();
|
||||||
this.effectId = buf.readUnsignedByte();
|
this.effectId = buf.readEnumValue(Potion.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +38,7 @@ public class S1EPacketRemoveEntityEffect implements Packet<ClientPlayer>
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeVarIntToBuffer(this.entityId);
|
buf.writeVarIntToBuffer(this.entityId);
|
||||||
buf.writeByte(this.effectId);
|
buf.writeEnumValue(this.effectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +54,7 @@ public class S1EPacketRemoveEntityEffect implements Packet<ClientPlayer>
|
||||||
return this.entityId;
|
return this.entityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEffectId()
|
public Potion getEffectId()
|
||||||
{
|
{
|
||||||
return this.effectId;
|
return this.effectId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package game.potion;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import game.collect.Maps;
|
import game.collect.Maps;
|
||||||
|
|
||||||
import game.entity.DamageSource;
|
import game.entity.DamageSource;
|
||||||
|
@ -16,398 +14,241 @@ import game.entity.projectile.EntityPotion;
|
||||||
import game.entity.types.EntityLiving;
|
import game.entity.types.EntityLiving;
|
||||||
import game.init.Config;
|
import game.init.Config;
|
||||||
|
|
||||||
public class Potion
|
public enum Potion {
|
||||||
{
|
SPEED("speed", "Schnelligkeit", "Trank der Schnelligkeit", false, 8171462, new PotionModifier(Attributes.MOVEMENT_SPEED, "PotSpd", 0.2, true)),
|
||||||
public static final Potion[] POTION_TYPES = new Potion[32];
|
SLOWNESS("slowness", "Langsamkeit", "Trank der Langsamkeit", true, 5926017, new PotionModifier(Attributes.MOVEMENT_SPEED, "PotSlow", -0.15, true)),
|
||||||
private static final Map<String, Potion> POTION_MAP = Maps.<String, Potion>newHashMap();
|
HASTE("haste", "Eile", "Trank der Eile", false, 14270531) {
|
||||||
|
public double getEffectiveness() {
|
||||||
// public static final Potion field_180151_b = null;
|
return 1.5;
|
||||||
|
|
||||||
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;
|
|
||||||
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;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
if (badEffect)
|
|
||||||
{
|
|
||||||
this.effectiveness = 0.5D;
|
|
||||||
}
|
}
|
||||||
else
|
},
|
||||||
{
|
FATIGUE("mining_fatigue", "Abbaulähmung", "Trank der Trägheit", true, 4866583),
|
||||||
this.effectiveness = 1.0D;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.color = potionColor;
|
public void onImpact(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect) {
|
||||||
}
|
if(entity.arePotionsInverted()) {
|
||||||
|
if(Config.damagePotion) {
|
||||||
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);
|
int dmg = (int)(effect * (double)(6 << amp) + 0.5D);
|
||||||
|
if(potion == null)
|
||||||
if (potion == null)
|
|
||||||
{
|
|
||||||
entity.attackEntityFrom(DamageSource.magic, dmg);
|
entity.attackEntityFrom(DamageSource.magic, dmg);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
entity.attackEntityFrom(DamageSource.causeIndirectMagicDamage(potion, thrower), dmg);
|
entity.attackEntityFrom(DamageSource.causeIndirectMagicDamage(potion, thrower), dmg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
else
|
|
||||||
{
|
|
||||||
entity.heal(Math.max((int)(effect * (double)(4 << amp) + 0.5D), 0));
|
entity.heal(Math.max((int)(effect * (double)(4 << amp) + 0.5D), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
/**
|
DAMAGE("instant_damage", "Direktschaden", "Trank des Schadens", true, 4393481) {
|
||||||
* Returns true if the potion has an instant effect instead of a continuous one (eg Harming)
|
public boolean isInstant() {
|
||||||
*/
|
return true;
|
||||||
public boolean isInstant()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void onImpact(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect) {
|
||||||
* checks if Potion effect is ready to be applied this tick.
|
if(!entity.arePotionsInverted()) {
|
||||||
*/
|
if(Config.damagePotion) {
|
||||||
public boolean isReady(int duration, int amp, int ticks)
|
int dmg = (int)(effect * (double)(6 << amp) + 0.5D);
|
||||||
{
|
if(potion == null)
|
||||||
if (this.id == regeneration.id)
|
entity.attackEntityFrom(DamageSource.magic, dmg);
|
||||||
{
|
|
||||||
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
|
else
|
||||||
{
|
entity.attackEntityFrom(DamageSource.causeIndirectMagicDamage(potion, thrower), dmg);
|
||||||
return false; // this.id == hunger.id;
|
}
|
||||||
|
}
|
||||||
|
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 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static final Map<String, Potion> LOOKUP = Maps.newHashMap();
|
||||||
* Set the potion name.
|
|
||||||
*/
|
private final Map<Attribute, AttributeModifier> modifiers = Maps.<Attribute, AttributeModifier>newHashMap();
|
||||||
public Potion setPotionName(String name, String display, String potion)
|
private final String name;
|
||||||
{
|
private final String effectDisplay;
|
||||||
|
private final String potionDisplay;
|
||||||
|
private final boolean bad;
|
||||||
|
private final int color;
|
||||||
|
|
||||||
|
static {
|
||||||
|
for(Potion potion : values()) {
|
||||||
|
LOOKUP.put(potion.name, potion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Potion getByName(String name) {
|
||||||
|
return LOOKUP.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Potion(String name, String effectDisplay, String potionDisplay, boolean bad, int color, PotionModifier ... modifiers) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.display = display;
|
this.bad = bad;
|
||||||
this.potionDisplay = potion;
|
this.color = color;
|
||||||
return this;
|
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 String getName() {
|
||||||
* returns the name of the potion
|
|
||||||
*/
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplay()
|
public String toString() {
|
||||||
{
|
return this.name;
|
||||||
return this.display;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPotionDisplay()
|
public String getDisplay() {
|
||||||
{
|
return this.effectDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPotionDisplay() {
|
||||||
return this.potionDisplay;
|
return this.potionDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean isBadEffect() {
|
||||||
* 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;
|
return this.bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDurationString(PotionEffect effect)
|
public int getColor() {
|
||||||
{
|
|
||||||
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;
|
return this.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Map<Attribute, AttributeModifier> getModifiers() {
|
||||||
* 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;
|
return this.modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAttributesModifiersFromEntity(EntityLiving entityLivingBaseIn, AttributeMap p_111187_2_, int amplifier)
|
public void onUpdate(EntityLiving entity, int duration, int amp) {
|
||||||
{
|
|
||||||
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 onImpact(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInstant() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getAmount(int amp, AttributeModifier modifier) {
|
||||||
|
return modifier.getAmount() * (double)(amp + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 applyAttributesModifiersToEntity(EntityLiving entityLivingBaseIn, AttributeMap p_111185_2_, int amplifier)
|
public void addModifiers(EntityLiving entity, AttributeMap map, int amp) {
|
||||||
{
|
for(Entry<Attribute, AttributeModifier> entry : this.modifiers.entrySet()) {
|
||||||
for (Entry<Attribute, AttributeModifier> entry : this.modifiers.entrySet())
|
AttributeInstance attr = map.getAttributeInstance(entry.getKey());
|
||||||
{
|
if(attr != null) {
|
||||||
AttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((Attribute)entry.getKey());
|
AttributeModifier mod = entry.getValue();
|
||||||
|
attr.removeModifier(mod);
|
||||||
if (iattributeinstance != null)
|
attr.applyModifier(new AttributeModifier(mod.getID(), "potion." + this.name + " " + amp, this.getAmount(amp, mod), mod.isMultiplied()));
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return this.sid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.log.Log;
|
||||||
import game.nbt.NBTTagCompound;
|
import game.nbt.NBTTagCompound;
|
||||||
|
|
||||||
public class PotionEffect
|
public class PotionEffect {
|
||||||
{
|
private final Potion potion;
|
||||||
/** ID value of the potion this effect matches. */
|
private final int duration;
|
||||||
private int potionID;
|
private final int amplifier;
|
||||||
|
private final boolean ambient;
|
||||||
|
private final boolean particles;
|
||||||
|
|
||||||
/** The duration of the potion effect */
|
private int remaining;
|
||||||
private int duration;
|
private boolean thrown;
|
||||||
|
|
||||||
/** The amplifier of the potion effect */
|
public PotionEffect(Potion id, int duration, int amplifier) {
|
||||||
private int amplifier;
|
this(id, duration, amplifier, false, true);
|
||||||
|
|
||||||
/** 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)
|
public PotionEffect(Potion id, int duration, int amplifier, boolean ambient, boolean showParticles) {
|
||||||
{
|
this.potion = id;
|
||||||
this(id, effectDuration, effectAmplifier, false, true);
|
this.duration = this.remaining = duration;
|
||||||
|
this.amplifier = amplifier;
|
||||||
|
this.ambient = ambient;
|
||||||
|
this.particles = showParticles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PotionEffect(int id, int effectDuration, int effectAmplifier, boolean ambient, boolean showParticles)
|
public PotionEffect(PotionEffect other) {
|
||||||
{
|
this.potion = other.potion;
|
||||||
this.potionID = id;
|
this.duration = this.remaining = other.duration;
|
||||||
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.amplifier = other.amplifier;
|
||||||
this.isAmbient = other.isAmbient;
|
this.ambient = other.ambient;
|
||||||
this.showParticles = other.showParticles;
|
this.particles = other.particles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public PotionEffect combine(PotionEffect other) {
|
||||||
* merges the input PotionEffect into this one if this.amplifier <= tomerge.amplifier. The duration in the supplied
|
if(this.potion != other.potion)
|
||||||
* 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!");
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (other.amplifier > this.amplifier)
|
public Potion getPotion() {
|
||||||
{
|
return this.potion;
|
||||||
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;
|
public int getDuration() {
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the ID of the potion this effect matches.
|
|
||||||
*/
|
|
||||||
public int getPotionID()
|
|
||||||
{
|
|
||||||
return this.potionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDuration()
|
|
||||||
{
|
|
||||||
return this.duration;
|
return this.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAmplifier()
|
public boolean isInfinite() {
|
||||||
{
|
return this.duration == Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRemaining() {
|
||||||
|
return this.remaining;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmplifier() {
|
||||||
return this.amplifier;
|
return this.amplifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public PotionEffect setThrown(boolean thrown) {
|
||||||
* Set whether this potion is a splash potion.
|
this.thrown = thrown;
|
||||||
*/
|
return this;
|
||||||
public void setSplashPotion(boolean splashPotion)
|
|
||||||
{
|
|
||||||
this.isSplashPotion = splashPotion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public PotionEffect setRemaining(int remaining) {
|
||||||
* Gets whether this potion effect originated from a beacon
|
this.remaining = remaining;
|
||||||
*/
|
return this;
|
||||||
public boolean getIsAmbient()
|
|
||||||
{
|
|
||||||
return this.isAmbient;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIsShowParticles()
|
public boolean isAmbient() {
|
||||||
{
|
return this.ambient;
|
||||||
return this.showParticles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onUpdate(EntityLiving entityIn)
|
public boolean getIsShowParticles() {
|
||||||
{
|
return this.particles;
|
||||||
if (this.duration > 0)
|
|
||||||
{
|
|
||||||
if (Potion.POTION_TYPES[this.potionID].isReady(this.duration, this.amplifier, entityIn.ticksExisted))
|
|
||||||
{
|
|
||||||
this.performEffect(entityIn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.duration > 0;
|
public String getEffectName() {
|
||||||
|
return this.potion.getDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performEffect(EntityLiving entityIn)
|
public String getPotionName() {
|
||||||
{
|
return this.potion.getPotionDisplay();
|
||||||
if (this.duration > 0)
|
|
||||||
{
|
|
||||||
Potion.POTION_TYPES[this.potionID].performEffect(entityIn, this.amplifier);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEffectName()
|
public String getDurationString() {
|
||||||
{
|
if(this.isInfinite())
|
||||||
return Potion.POTION_TYPES[this.potionID].getDisplay();
|
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 String getPotionName()
|
public int hashCode() {
|
||||||
{
|
return this.potion.ordinal();
|
||||||
return Potion.POTION_TYPES[this.potionID].getPotionDisplay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode()
|
public boolean equals(Object obj) {
|
||||||
{
|
if(!(obj instanceof PotionEffect))
|
||||||
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;
|
return false;
|
||||||
}
|
PotionEffect other = (PotionEffect)obj;
|
||||||
else
|
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;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public NBTTagCompound toNbt() {
|
||||||
* Write a custom potion effect to a potion item's NBT data.
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
*/
|
nbt.setString("Type", this.potion.getName());
|
||||||
public NBTTagCompound writeCustomPotionEffectToNBT(NBTTagCompound nbt)
|
nbt.setByte("Amplifier", (byte)this.amplifier);
|
||||||
{
|
nbt.setInteger("Duration", this.duration);
|
||||||
nbt.setByte("Id", (byte)this.getPotionID());
|
nbt.setInteger("Remaining", this.remaining);
|
||||||
nbt.setByte("Amplifier", (byte)this.getAmplifier());
|
nbt.setBoolean("Ambient", this.ambient);
|
||||||
nbt.setInteger("Duration", this.getDuration());
|
nbt.setBoolean("Particles", this.particles);
|
||||||
nbt.setBoolean("Ambient", this.getIsAmbient());
|
|
||||||
nbt.setBoolean("ShowParticles", this.getIsShowParticles());
|
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static PotionEffect fromNbt(NBTTagCompound nbt) {
|
||||||
* Read a custom potion effect from a potion item's NBT data.
|
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"))
|
||||||
public static PotionEffect readCustomPotionEffectFromNBT(NBTTagCompound nbt)
|
.setRemaining(nbt.getInteger("Remaining"));
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 pufferfishEffect = "+0-1+2+3+13&4-4";
|
||||||
// public static final String rabbitFootEffect = "+0+1-2+3&4-4+13";
|
// 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<Potion, String> potionRequirements = Maps.<Potion, String>newEnumMap(Potion.class);
|
||||||
private static final Map<Integer, String> potionAmplifiers = Maps.<Integer, String>newHashMap();
|
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 Map<Integer, Integer> DATAVALUE_COLORS = Maps.<Integer, Integer>newHashMap();
|
||||||
|
|
||||||
private static final String[] potionPrefixes = new String[] {
|
private static final String[] potionPrefixes = new String[] {
|
||||||
|
@ -96,7 +96,7 @@ public class PotionHelper
|
||||||
{
|
{
|
||||||
if (potioneffect.getIsShowParticles())
|
if (potioneffect.getIsShowParticles())
|
||||||
{
|
{
|
||||||
int j = Potion.POTION_TYPES[potioneffect.getPotionID()].getLiquidColor();
|
int j = potioneffect.getPotion().getColor();
|
||||||
|
|
||||||
for (int k = 0; k <= potioneffect.getAmplifier(); ++k)
|
for (int k = 0; k <= potioneffect.getAmplifier(); ++k)
|
||||||
{
|
{
|
||||||
|
@ -133,7 +133,7 @@ public class PotionHelper
|
||||||
{
|
{
|
||||||
for (PotionEffect potioneffect : potionEffects)
|
for (PotionEffect potioneffect : potionEffects)
|
||||||
{
|
{
|
||||||
if (!potioneffect.getIsAmbient())
|
if (!potioneffect.isAmbient())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ public class PotionHelper
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i = calcPotionLiquidColor(getPotionEffects(key.intValue(), false));
|
int i = calcPotionLiquidColor(getPotionEffects(key.intValue()));
|
||||||
DATAVALUE_COLORS.put(key, Integer.valueOf(i));
|
DATAVALUE_COLORS.put(key, Integer.valueOf(i));
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -168,32 +168,32 @@ public class PotionHelper
|
||||||
return value >= 1 && value <= 9 ? " " + POTENCIES[value - 1] : (value == 0 ? "" : (" " + (value + 1)));
|
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;
|
int i = 0;
|
||||||
|
|
||||||
if (p_77904_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)
|
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;
|
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;
|
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;
|
i = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
i = isFlagSet(p_77904_6_, p_77904_4_);
|
i = isFlagSet(meta, p_77904_4_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_77904_1_)
|
if (p_77904_1_)
|
||||||
|
@ -212,27 +212,27 @@ public class PotionHelper
|
||||||
/**
|
/**
|
||||||
* Returns the number of 1 bits in the given integer.
|
* 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;
|
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;
|
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)
|
if (l1 > 0)
|
||||||
{
|
{
|
||||||
|
@ -240,17 +240,17 @@ public class PotionHelper
|
||||||
}
|
}
|
||||||
else
|
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;
|
return j2 > 0 ? j2 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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)
|
if (i2 <= 0)
|
||||||
{
|
{
|
||||||
|
@ -258,7 +258,7 @@ public class PotionHelper
|
||||||
}
|
}
|
||||||
else
|
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);
|
return k2 <= 0 ? 0 : (i2 > k2 ? i2 : k2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,9 +274,9 @@ public class PotionHelper
|
||||||
int i1 = 0;
|
int i1 = 0;
|
||||||
int j1 = 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)
|
if (c0 >= 48 && c0 <= 57)
|
||||||
{
|
{
|
||||||
|
@ -300,7 +300,7 @@ public class PotionHelper
|
||||||
{
|
{
|
||||||
if (flag2)
|
if (flag2)
|
||||||
{
|
{
|
||||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||||
flag3 = false;
|
flag3 = false;
|
||||||
flag4 = false;
|
flag4 = false;
|
||||||
flag = false;
|
flag = false;
|
||||||
|
@ -317,7 +317,7 @@ public class PotionHelper
|
||||||
{
|
{
|
||||||
if (flag2)
|
if (flag2)
|
||||||
{
|
{
|
||||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||||
flag3 = false;
|
flag3 = false;
|
||||||
flag4 = false;
|
flag4 = false;
|
||||||
flag = false;
|
flag = false;
|
||||||
|
@ -334,7 +334,7 @@ public class PotionHelper
|
||||||
{
|
{
|
||||||
if (c0 == 43 && flag2)
|
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;
|
flag3 = false;
|
||||||
flag4 = false;
|
flag4 = false;
|
||||||
flag = false;
|
flag = false;
|
||||||
|
@ -349,7 +349,7 @@ public class PotionHelper
|
||||||
{
|
{
|
||||||
if (flag2)
|
if (flag2)
|
||||||
{
|
{
|
||||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||||
flag3 = false;
|
flag3 = false;
|
||||||
flag4 = false;
|
flag4 = false;
|
||||||
flag = false;
|
flag = false;
|
||||||
|
@ -377,7 +377,7 @@ public class PotionHelper
|
||||||
|
|
||||||
if (flag2)
|
if (flag2)
|
||||||
{
|
{
|
||||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, p_77912_3_);
|
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
return j1;
|
return j1;
|
||||||
|
@ -390,15 +390,15 @@ public class PotionHelper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<PotionEffect> getPotionEffects(int meta, boolean all)
|
public static List<PotionEffect> getPotionEffects(int meta)
|
||||||
{
|
{
|
||||||
List<PotionEffect> list = null;
|
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 = (String)potionRequirements.get(Integer.valueOf(potion.getId()));
|
String s = potionRequirements.get(potion);
|
||||||
|
|
||||||
if (s != null)
|
if (s != null)
|
||||||
{
|
{
|
||||||
|
@ -407,7 +407,7 @@ public class PotionHelper
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
String s1 = (String)potionAmplifiers.get(Integer.valueOf(potion.getId()));
|
String s1 = potionAmplifiers.get(potion);
|
||||||
|
|
||||||
if (s1 != null)
|
if (s1 != null)
|
||||||
{
|
{
|
||||||
|
@ -440,17 +440,17 @@ public class PotionHelper
|
||||||
list = Lists.<PotionEffect>newArrayList();
|
list = Lists.<PotionEffect>newArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
PotionEffect potioneffect = new PotionEffect(potion.getId(), i, j);
|
PotionEffect potioneffect = new PotionEffect(potion, i, j);
|
||||||
|
|
||||||
if ((meta & 16384) != 0)
|
if ((meta & 16384) != 0)
|
||||||
{
|
{
|
||||||
potioneffect.setSplashPotion(true);
|
potioneffect.setThrown(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
list.add(potioneffect);
|
list.add(potioneffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -585,27 +585,27 @@ public class PotionHelper
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
potionRequirements.put(Integer.valueOf(Potion.regeneration.getId()), "0 & !1 & !2 & !3 & 0+6");
|
potionRequirements.put(Potion.REGENERATION, "0 & !1 & !2 & !3 & 0+6");
|
||||||
potionRequirements.put(Integer.valueOf(Potion.moveSpeed.getId()), "!0 & 1 & !2 & !3 & 1+6");
|
potionRequirements.put(Potion.SPEED, "!0 & 1 & !2 & !3 & 1+6");
|
||||||
potionRequirements.put(Integer.valueOf(Potion.fireResistance.getId()), "0 & 1 & !2 & !3 & 0+6");
|
potionRequirements.put(Potion.FIRE_RESISTANCE, "0 & 1 & !2 & !3 & 0+6");
|
||||||
potionRequirements.put(Integer.valueOf(Potion.heal.getId()), "0 & !1 & 2 & !3");
|
potionRequirements.put(Potion.HEAL, "0 & !1 & 2 & !3");
|
||||||
potionRequirements.put(Integer.valueOf(Potion.poison.getId()), "!0 & !1 & 2 & !3 & 2+6");
|
potionRequirements.put(Potion.POISON, "!0 & !1 & 2 & !3 & 2+6");
|
||||||
potionRequirements.put(Integer.valueOf(Potion.weakness.getId()), "!0 & !1 & !2 & 3 & 3+6");
|
potionRequirements.put(Potion.WEAKNESS, "!0 & !1 & !2 & 3 & 3+6");
|
||||||
potionRequirements.put(Integer.valueOf(Potion.harm.getId()), "!0 & !1 & 2 & 3");
|
potionRequirements.put(Potion.DAMAGE, "!0 & !1 & 2 & 3");
|
||||||
potionRequirements.put(Integer.valueOf(Potion.moveSlowdown.getId()), "!0 & 1 & !2 & 3 & 3+6");
|
potionRequirements.put(Potion.SLOWNESS, "!0 & 1 & !2 & 3 & 3+6");
|
||||||
potionRequirements.put(Integer.valueOf(Potion.damageBoost.getId()), "0 & !1 & !2 & 3 & 3+6");
|
potionRequirements.put(Potion.STRENGTH, "0 & !1 & !2 & 3 & 3+6");
|
||||||
potionRequirements.put(Integer.valueOf(Potion.nightVision.getId()), "!0 & 1 & 2 & !3 & 2+6");
|
potionRequirements.put(Potion.NIGHT_VISION, "!0 & 1 & 2 & !3 & 2+6");
|
||||||
potionRequirements.put(Integer.valueOf(Potion.stability.getId()), "!0 & 1 & 2 & 3 & 2+6");
|
potionRequirements.put(Potion.STABILITY, "!0 & 1 & 2 & 3 & 2+6");
|
||||||
// potionRequirements.put(Integer.valueOf(Potion.waterBreathing.getId()), "0 & !1 & 2 & 3 & 2+6");
|
// potionRequirements.put(Potion.waterBreathing, "0 & !1 & 2 & 3 & 2+6");
|
||||||
// potionRequirements.put(Integer.valueOf(Potion.jump.getId()), "0 & 1 & !2 & 3 & 3+6");
|
// potionRequirements.put(Potion.jump, "0 & 1 & !2 & 3 & 3+6");
|
||||||
potionAmplifiers.put(Integer.valueOf(Potion.moveSpeed.getId()), "5");
|
potionAmplifiers.put(Potion.SPEED, "5");
|
||||||
potionAmplifiers.put(Integer.valueOf(Potion.digSpeed.getId()), "5");
|
potionAmplifiers.put(Potion.HASTE, "5");
|
||||||
potionAmplifiers.put(Integer.valueOf(Potion.damageBoost.getId()), "5");
|
potionAmplifiers.put(Potion.STRENGTH, "5");
|
||||||
potionAmplifiers.put(Integer.valueOf(Potion.regeneration.getId()), "5");
|
potionAmplifiers.put(Potion.REGENERATION, "5");
|
||||||
potionAmplifiers.put(Integer.valueOf(Potion.harm.getId()), "5");
|
potionAmplifiers.put(Potion.DAMAGE, "5");
|
||||||
potionAmplifiers.put(Integer.valueOf(Potion.heal.getId()), "5");
|
potionAmplifiers.put(Potion.HEAL, "5");
|
||||||
potionAmplifiers.put(Integer.valueOf(Potion.resistance.getId()), "5");
|
potionAmplifiers.put(Potion.RESISTANCE, "5");
|
||||||
potionAmplifiers.put(Integer.valueOf(Potion.poison.getId()), "5");
|
potionAmplifiers.put(Potion.POISON, "5");
|
||||||
// potionAmplifiers.put(Integer.valueOf(Potion.jump.getId()), "5");
|
// potionAmplifiers.put(Potion.jump, "5");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,7 +406,7 @@ public class EntityRenderer {
|
||||||
GL11.glRotatef(40.0F - 8000.0F / (f1 + 200.0F), 0.0F, 0.0F, 1.0F);
|
GL11.glRotatef(40.0F - 8000.0F / (f1 + 200.0F), 0.0F, 0.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f < 0.0F || entitylivingbase.hasEffect(Potion.stability))
|
if (f < 0.0F || entitylivingbase.hasEffect(Potion.STABILITY))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -792,7 +792,7 @@ public class EntityRenderer {
|
||||||
// f10 = 0.25F + f7 * 0.75F;
|
// f10 = 0.25F + f7 * 0.75F;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (this.gm.thePlayer.hasEffect(Potion.nightVision))
|
if (this.gm.thePlayer.hasEffect(Potion.NIGHT_VISION))
|
||||||
{
|
{
|
||||||
float vis = this.getNightVisionBrightness(this.gm.thePlayer, partialTicks);
|
float vis = this.getNightVisionBrightness(this.gm.thePlayer, partialTicks);
|
||||||
float mult = 1.0F / red;
|
float mult = 1.0F / red;
|
||||||
|
@ -886,7 +886,7 @@ public class EntityRenderer {
|
||||||
|
|
||||||
private float getNightVisionBrightness(EntityLiving entitylivingbaseIn, float partialTicks)
|
private float getNightVisionBrightness(EntityLiving entitylivingbaseIn, float partialTicks)
|
||||||
{
|
{
|
||||||
int i = entitylivingbaseIn.getEffect(Potion.nightVision).getDuration();
|
int i = entitylivingbaseIn.getEffect(Potion.NIGHT_VISION).getRemaining();
|
||||||
return i > 200 ? 1.0F : 0.7F + ExtMath.sin(((float)i - partialTicks) * (float)Math.PI * 0.2F) * 0.3F;
|
return i > 200 ? 1.0F : 0.7F + ExtMath.sin(((float)i - partialTicks) * (float)Math.PI * 0.2F) * 0.3F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1509,9 +1509,9 @@ public class EntityRenderer {
|
||||||
this.fogColorBlue *= mult;
|
this.fogColorBlue *= mult;
|
||||||
double vfog = (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partial); // * world.dimension.getVoidFogYFactor();
|
double vfog = (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partial); // * world.dimension.getVoidFogYFactor();
|
||||||
|
|
||||||
if (entity instanceof EntityLiving && ((EntityLiving)entity).hasEffect(Potion.blindness))
|
if (entity instanceof EntityLiving && ((EntityLiving)entity).hasEffect(Potion.BLINDNESS))
|
||||||
{
|
{
|
||||||
int blind = ((EntityLiving)entity).getEffect(Potion.blindness).getDuration();
|
int blind = ((EntityLiving)entity).getEffect(Potion.BLINDNESS).getRemaining();
|
||||||
|
|
||||||
if (blind < 20)
|
if (blind < 20)
|
||||||
{
|
{
|
||||||
|
@ -1544,7 +1544,7 @@ public class EntityRenderer {
|
||||||
// this.fogColorBlue = this.fogColorBlue * (1.0F - shift) + this.fogColorBlue * 0.6F * shift;
|
// this.fogColorBlue = this.fogColorBlue * (1.0F - shift) + this.fogColorBlue * 0.6F * shift;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (entity instanceof EntityLiving && ((EntityLiving)entity).hasEffect(Potion.nightVision))
|
if (entity instanceof EntityLiving && ((EntityLiving)entity).hasEffect(Potion.NIGHT_VISION))
|
||||||
{
|
{
|
||||||
float vis = this.getNightVisionBrightness((EntityLiving)entity, partial);
|
float vis = this.getNightVisionBrightness((EntityLiving)entity, partial);
|
||||||
float mul = 1.0F / this.fogColorRed;
|
float mul = 1.0F / this.fogColorRed;
|
||||||
|
@ -1604,10 +1604,10 @@ public class EntityRenderer {
|
||||||
if(distance >= 1.0f) {
|
if(distance >= 1.0f) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
else if (entity instanceof EntityLiving && ((EntityLiving)entity).hasEffect(Potion.blindness))
|
else if (entity instanceof EntityLiving && ((EntityLiving)entity).hasEffect(Potion.BLINDNESS))
|
||||||
{
|
{
|
||||||
float far = 5.0F;
|
float far = 5.0F;
|
||||||
int effect = ((EntityLiving)entity).getEffect(Potion.blindness).getDuration();
|
int effect = ((EntityLiving)entity).getEffect(Potion.BLINDNESS).getRemaining();
|
||||||
|
|
||||||
if (effect < 20)
|
if (effect < 20)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ import game.world.WorldServer;
|
||||||
public class TileEntityBeacon extends TileEntity implements ITickable
|
public class TileEntityBeacon extends TileEntity implements ITickable
|
||||||
{
|
{
|
||||||
/** List of effects that Beacon can apply */
|
/** List of effects that Beacon can apply */
|
||||||
public static final Potion[][] effectsList = new Potion[][] {{Potion.moveSpeed, Potion.digSpeed}, {Potion.resistance, Potion.jump}, {Potion.damageBoost}, {Potion.regeneration}};
|
public static final Potion[][] effectsList = new Potion[][] {{Potion.SPEED, Potion.HASTE}, {Potion.RESISTANCE, Potion.JUMP}, {Potion.STRENGTH}, {Potion.REGENERATION}};
|
||||||
// private final List<TileEntityBeacon.BeamSegment> beamSegments = Lists.<TileEntityBeacon.BeamSegment>newArrayList();
|
// private final List<TileEntityBeacon.BeamSegment> beamSegments = Lists.<TileEntityBeacon.BeamSegment>newArrayList();
|
||||||
// private long lastRenderUpdate;
|
// private long lastRenderUpdate;
|
||||||
// private float charge;
|
// private float charge;
|
||||||
|
@ -30,10 +30,10 @@ public class TileEntityBeacon extends TileEntity implements ITickable
|
||||||
private int levels = -1;
|
private int levels = -1;
|
||||||
|
|
||||||
/** Primary potion effect given by this beacon. */
|
/** Primary potion effect given by this beacon. */
|
||||||
private int primaryEffect;
|
private Potion primaryEffect;
|
||||||
|
|
||||||
/** Secondary potion effect given by this beacon. */
|
/** Secondary potion effect given by this beacon. */
|
||||||
private int secondaryEffect;
|
private Potion secondaryEffect;
|
||||||
|
|
||||||
/** Item given to this beacon as payment. */
|
/** Item given to this beacon as payment. */
|
||||||
// private ItemStack payment;
|
// private ItemStack payment;
|
||||||
|
@ -65,7 +65,7 @@ public class TileEntityBeacon extends TileEntity implements ITickable
|
||||||
|
|
||||||
private void addEffectsToPlayers()
|
private void addEffectsToPlayers()
|
||||||
{
|
{
|
||||||
if (this.isComplete && this.levels > 0 && this.primaryEffect > 0)
|
if (this.isComplete && this.levels > 0 && this.primaryEffect != null)
|
||||||
{
|
{
|
||||||
double d0 = (double)(this.levels * 10 + 10);
|
double d0 = (double)(this.levels * 10 + 10);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -86,7 +86,7 @@ public class TileEntityBeacon extends TileEntity implements ITickable
|
||||||
entityplayer.addEffect(new PotionEffect(this.primaryEffect, 180, i, true, true));
|
entityplayer.addEffect(new PotionEffect(this.primaryEffect, 180, i, true, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect > 0)
|
if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null)
|
||||||
{
|
{
|
||||||
for (EntityLiving entityplayer1 : list)
|
for (EntityLiving entityplayer1 : list)
|
||||||
{
|
{
|
||||||
|
@ -288,24 +288,24 @@ public class TileEntityBeacon extends TileEntity implements ITickable
|
||||||
return 65536.0D;
|
return 65536.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getEffect(int id)
|
private Potion getEffect(String id)
|
||||||
{
|
{
|
||||||
if (id >= 0 && id < Potion.POTION_TYPES.length && Potion.POTION_TYPES[id] != null)
|
Potion potion = Potion.getByName(id);
|
||||||
{
|
// if (potion != null)
|
||||||
Potion potion = Potion.POTION_TYPES[id];
|
// {
|
||||||
return potion != Potion.moveSpeed && potion != Potion.digSpeed && potion != Potion.resistance && potion != Potion.jump && potion != Potion.damageBoost && potion != Potion.regeneration ? 0 : id;
|
return potion != Potion.SPEED && potion != Potion.HASTE && potion != Potion.RESISTANCE && potion != Potion.JUMP && potion != Potion.STRENGTH && potion != Potion.REGENERATION ? null : potion;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
return 0;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound compound)
|
public void readFromNBT(NBTTagCompound compound)
|
||||||
{
|
{
|
||||||
super.readFromNBT(compound);
|
super.readFromNBT(compound);
|
||||||
this.primaryEffect = this.getEffect(compound.getInteger("Primary"));
|
this.primaryEffect = compound.hasKey("Primary", 8) ? this.getEffect(compound.getString("Primary")) : null;
|
||||||
this.secondaryEffect = this.getEffect(compound.getInteger("Secondary"));
|
this.secondaryEffect = compound.hasKey("Secondary", 8) ? this.getEffect(compound.getString("Secondary")) : null;
|
||||||
this.levels = compound.getInteger("Levels");
|
this.levels = compound.getInteger("Levels");
|
||||||
// try {
|
// try {
|
||||||
this.beamColor = DyeColor.getByName(compound.getString("Color"));
|
this.beamColor = DyeColor.getByName(compound.getString("Color"));
|
||||||
|
@ -318,8 +318,10 @@ public class TileEntityBeacon extends TileEntity implements ITickable
|
||||||
public void writeToNBT(NBTTagCompound compound)
|
public void writeToNBT(NBTTagCompound compound)
|
||||||
{
|
{
|
||||||
super.writeToNBT(compound);
|
super.writeToNBT(compound);
|
||||||
compound.setInteger("Primary", this.primaryEffect);
|
if(this.primaryEffect != null)
|
||||||
compound.setInteger("Secondary", this.secondaryEffect);
|
compound.setString("Primary", this.primaryEffect.getName());
|
||||||
|
if(this.secondaryEffect != null)
|
||||||
|
compound.setString("Secondary", this.secondaryEffect.getName());
|
||||||
compound.setInteger("Levels", this.levels);
|
compound.setInteger("Levels", this.levels);
|
||||||
compound.setString("Color", this.beamColor.getName());
|
compound.setString("Color", this.beamColor.getName());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue