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

@ -157,7 +157,6 @@ import common.packet.HPacketHandshake;
import common.packet.CPacketAction.Action;
import common.potion.Potion;
import common.potion.PotionEffect;
import common.potion.PotionHelper;
import common.properties.IProperty;
import common.rng.Random;
import common.sound.EventType;
@ -937,7 +936,7 @@ public class Client implements IThreadListener {
for(PotionEffect effect : this.player.getEffects()) {
Potion potion = effect.getPotion();
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) + effect.getEffectName();
String desc = TextColor.NEON + effect.getDurationString();
// Drawing.drawRectColor(x, y, 250, Font.DEFAULT.yglyph + 2, color | 0xff000000);
Drawing.drawRectBorder(x, y, 250, Font.YGLYPH + 4, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff6f6f6f);

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() {

View file

@ -29,8 +29,9 @@ public class CommandMilk extends Command {
int done = 0;
for(EntityLiving entity : entities) {
if(type != null && entity.hasEffect(type)) {
int amplifier = entity.getEffect(type).getAmplifier();
entity.removeEffect(type);
exec.logConsole("%s von %s entfernt", type.getDisplay(), entity.getCommandName());
exec.logConsole("%s von %s entfernt", type.getDisplay(amplifier), entity.getCommandName());
done++;
}
else if(type == null && !entity.getEffects().isEmpty()) {

View file

@ -27,7 +27,7 @@ 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) {
int done = 0;
for(EntityLiving entity : entities) {
if(entity.isPotionApplicable(type)) {
if(entity.isPotionApplicable(type, strength - 1)) {
if(type.isInstant()) {
type.onImpact(null, null, entity, strength - 1, 1.0);
}
@ -38,9 +38,9 @@ public class CommandPotion extends Command {
entity.addEffect(effect);
}
if(type.isInstant() || duration == 0)
exec.logConsole("%d * %s an %s gegeben", strength, type.getDisplay(), entity.getCommandName());
exec.logConsole("%s an %s gegeben", type.getDisplay(strength - 1), entity.getCommandName());
else
exec.logConsole("%d * %s für %d Sekunden an %s gegeben", strength, type.getDisplay(), duration, entity.getCommandName());
exec.logConsole("%s für %d Sekunden an %s gegeben", type.getDisplay(strength - 1), duration, entity.getCommandName());
done++;
}
}

View file

@ -2763,7 +2763,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
this.entity.addEffect(new PotionEffect(Potion.HASTE, 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.FIRE_RESISTANCE, 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.FLYING, Integer.MAX_VALUE, 1, false, false));
this.entity.addEffect(new PotionEffect(Potion.MANA, Integer.MAX_VALUE, 255, false, false));
this.addFeed(TextColor.GREEN + "Statuseffekte wurden hinzugefügt");
}