mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 02:57:37 +01:00
Rename the walkingSpeed ability to fieldViewModifier, the movement speed attribute should be used instead for speed
This commit is contained in:
parent
892c1d5806
commit
7bcca8ff9f
@ -515,10 +515,7 @@ public abstract class LivingEntity extends Entity implements EquipmentHandler {
|
||||
|
||||
property.instance = instances[i];
|
||||
property.attribute = instances[i].getAttribute();
|
||||
if (getEntityType() == EntityType.PLAYER && instances[i].getAttribute().equals(Attributes.MOVEMENT_SPEED))
|
||||
property.value = ((Player) this).getWalkingSpeed();
|
||||
else
|
||||
property.value = value;
|
||||
property.value = value;
|
||||
|
||||
properties[i] = property;
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package net.minestom.server.entity;
|
||||
import com.google.common.collect.Queues;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.advancements.AdvancementTab;
|
||||
import net.minestom.server.attribute.Attribute;
|
||||
import net.minestom.server.attribute.AttributeInstance;
|
||||
import net.minestom.server.attribute.Attributes;
|
||||
import net.minestom.server.bossbar.BossBar;
|
||||
@ -183,7 +182,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
private boolean allowFlying;
|
||||
private boolean instantBreak;
|
||||
private float flyingSpeed = 0.05f;
|
||||
private float walkingSpeed = 0.1f;
|
||||
private float fieldViewModifier = 0.1f;
|
||||
|
||||
// Statistics
|
||||
private final Map<PlayerStatistic, Integer> statisticValueMap = new Hashtable<>();
|
||||
@ -216,6 +215,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
this.dimensionType = DimensionType.OVERWORLD;
|
||||
this.levelFlat = true;
|
||||
refreshPosition(0, 0, 0);
|
||||
getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.1f);
|
||||
|
||||
// FakePlayer init its connection there
|
||||
playerConnectionInit();
|
||||
@ -323,14 +323,6 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
this.playerConnection.setPlayer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAttributeValue(@NotNull Attribute attribute) {
|
||||
if (attribute == Attributes.MOVEMENT_SPEED) {
|
||||
return walkingSpeed;
|
||||
}
|
||||
return super.getAttributeValue(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(long time) {
|
||||
// Network tick
|
||||
@ -2139,12 +2131,12 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
refreshAbilities();
|
||||
}
|
||||
|
||||
public float getWalkingSpeed() {
|
||||
return walkingSpeed;
|
||||
public float getFieldViewModifier() {
|
||||
return fieldViewModifier;
|
||||
}
|
||||
|
||||
public void setWalkingSpeed(float walkingSpeed) {
|
||||
this.walkingSpeed = walkingSpeed;
|
||||
public void setFieldViewModifier(float fieldViewModifier) {
|
||||
this.fieldViewModifier = fieldViewModifier;
|
||||
refreshAbilities();
|
||||
}
|
||||
|
||||
@ -2170,8 +2162,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends to the player a {@link PlayerAbilitiesPacket} with all the updated fields
|
||||
* (walkingSpeed set to 0.1).
|
||||
* Sends to the player a {@link PlayerAbilitiesPacket} with all the updated fields.
|
||||
*/
|
||||
protected void refreshAbilities() {
|
||||
PlayerAbilitiesPacket playerAbilitiesPacket = new PlayerAbilitiesPacket();
|
||||
@ -2180,7 +2171,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
playerAbilitiesPacket.allowFlying = allowFlying;
|
||||
playerAbilitiesPacket.instantBreak = instantBreak;
|
||||
playerAbilitiesPacket.flyingSpeed = flyingSpeed;
|
||||
playerAbilitiesPacket.walkingSpeed = 0.1f;
|
||||
playerAbilitiesPacket.fieldViewModifier = fieldViewModifier;
|
||||
|
||||
playerConnection.sendPacket(playerAbilitiesPacket);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class PlayerAbilitiesPacket implements ServerPacket {
|
||||
|
||||
// Options
|
||||
public float flyingSpeed;
|
||||
public float walkingSpeed;
|
||||
public float fieldViewModifier;
|
||||
|
||||
@Override
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
@ -31,7 +31,7 @@ public class PlayerAbilitiesPacket implements ServerPacket {
|
||||
|
||||
writer.writeByte(flags);
|
||||
writer.writeFloat(flyingSpeed);
|
||||
writer.writeFloat(walkingSpeed);
|
||||
writer.writeFloat(fieldViewModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user