add flying types

This commit is contained in:
Sen 2025-05-29 15:03:03 +02:00
parent b317139c97
commit 414dc668ff
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
11 changed files with 29 additions and 22 deletions

View file

@ -129,9 +129,9 @@ public abstract class EntityFlyingNPC extends EntityNPC
return false;
}
public boolean isPotionApplicable(Potion potion)
public boolean isPotionApplicable(Potion potion, int amplifier)
{
return potion != Potion.FLYING && super.isPotionApplicable(potion);
return (potion != Potion.FLYING || amplifier > 0) && super.isPotionApplicable(potion, amplifier);
}
static class AILookAround extends EntityAIBase

View file

@ -3960,7 +3960,7 @@ public abstract class EntityNPC extends EntityLiving
{
double d3 = this.motionY;
float f = this.jumpMovement;
this.jumpMovement = this.landMovement * (this.canFlyFullSpeed() ? 0.5f : 0.2f) * (float)(this.isSprinting() ? 2 : 1);
this.jumpMovement = this.landMovement * (this.canFlyFullSpeed() ? 0.5f : 0.2f) * (this.isSprinting() ? (this.canFlyFullSpeed() ? 2.0f : 1.3f) : 1.0f);
super.moveEntityWithHeading(strafe, forward);
this.motionY = d3 * 0.6D;
this.jumpMovement = f;
@ -4369,7 +4369,7 @@ public abstract class EntityNPC extends EntityLiving
}
public boolean canFlyFullSpeed() {
return this.flying;
return this.hasEffect(Potion.FLYING) && this.getEffect(Potion.FLYING).getAmplifier() > 0;
}
public int getEnergy(Energy type) { // TODO

View file

@ -125,7 +125,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
for (PotionEffect potioneffect : list)
{
Potion i = potioneffect.getPotion();
if(!entitylivingbase.isPotionApplicable(i))
if(!entitylivingbase.isPotionApplicable(i, potioneffect.getAmplifier()))
continue;
if (i.isInstant())

View file

@ -813,7 +813,7 @@ public abstract class EntityLiving extends Entity
*/
public void addEffect(PotionEffect potioneffectIn)
{
if (!potioneffectIn.getPotion().isInstant() && this.isPotionApplicable(potioneffectIn.getPotion()))
if (!potioneffectIn.getPotion().isInstant() && this.isPotionApplicable(potioneffectIn.getPotion(), potioneffectIn.getAmplifier()))
{
if (this.effects.containsKey(potioneffectIn.getPotion()))
{
@ -828,7 +828,7 @@ public abstract class EntityLiving extends Entity
}
}
public boolean isPotionApplicable(Potion potion)
public boolean isPotionApplicable(Potion potion, int amplifier)
{
// if (this.getCreatureType() == CreatureType.UNDEAD)
// {

View file

@ -228,7 +228,7 @@ public class ItemPotion extends Item
if (list != null && !list.isEmpty())
{
String s2 = ((PotionEffect)list.get(0)).getPotionName();
String s2 = list.get(0).getPotionName();
// s2 = s2 + ".postfix";
return s + s2.trim();
}
@ -272,7 +272,6 @@ public class ItemPotion extends Item
}
}
s1 = s1 + PotionHelper.getPotionPotency(potioneffect.getAmplifier());
// if (potioneffect.getAmplifier() >= 1 && potioneffect.getAmplifier() <= 9)
// {
// s1 = s1 + " " + Strs.get("potion.potency." + potioneffect.getAmplifier()).trim();

View file

@ -94,7 +94,15 @@ public enum Potion {
entity.healMana(1);
}
},
FLYING("flying", "Schweben", "Trank des Schwebens", false, 8356754),
FLYING("flying", null, null, false, 8356754) {
public String getDisplay(int amplifier) {
return amplifier <= 0 ? "Schweben" : "Flugkraft";
}
public String getPotionDisplay(int amplifier) {
return amplifier <= 0 ? "Trank des Schwebens" : "Trank der Flugkraft";
}
},
BLINDNESS("blindness", "Blindheit", "Trank der Blindheit", true, 2039587) {
public double getEffectiveness() {
return 0.25;
@ -195,11 +203,11 @@ public enum Potion {
return this.name;
}
public String getDisplay() {
return this.effectDisplay;
public String getDisplay(int amplifier) {
return this.effectDisplay + PotionHelper.getPotionPotency(amplifier);
}
public String getPotionDisplay() {
public String getPotionDisplay(int amplifier) {
return this.potionDisplay;
}

View file

@ -105,11 +105,11 @@ public class PotionEffect {
}
public String getEffectName() {
return this.potion.getDisplay();
return this.potion.getDisplay(this.amplifier);
}
public String getPotionName() {
return this.potion.getPotionDisplay();
return this.potion.getPotionDisplay(this.amplifier);
}
public String getDurationString() {