Skip to content

Commit

Permalink
Implement some more values
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Dec 12, 2024
1 parent 5fe91b5 commit 0d55473
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@

import com.soulfiremc.server.data.EntityType;
import com.soulfiremc.server.data.EquipmentSlot;
import com.soulfiremc.server.data.NamedEntityData;
import com.soulfiremc.server.protocol.bot.container.SFItemStack;
import com.soulfiremc.server.protocol.bot.state.Level;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataType;
import org.jetbrains.annotations.Nullable;

import java.util.EnumMap;
import java.util.Map;
import java.util.Optional;

public class Mob extends LivingEntity {
private static final int MOB_FLAG_NO_AI = 1;
private static final int MOB_FLAG_LEFTHANDED = 2;
private static final int MOB_FLAG_AGGRESSIVE = 4;
private final Map<EquipmentSlot, SFItemStack> slots = new EnumMap<>(EquipmentSlot.class);

public Mob(EntityType entityType, Level level) {
Expand All @@ -43,4 +48,21 @@ public Optional<SFItemStack> getItemBySlot(EquipmentSlot slot) {
public void setItemSlot(EquipmentSlot slot, @Nullable SFItemStack item) {
slots.put(slot, item);
}

@Override
public boolean isEffectiveAi() {
return super.isEffectiveAi() && !this.isNoAi();
}

public boolean isNoAi() {
return (this.metadataState.getMetadata(NamedEntityData.MOB__MOB_FLAGS, MetadataType.BYTE) & MOB_FLAG_NO_AI) != 0;
}

public boolean isLeftHanded() {
return (this.metadataState.getMetadata(NamedEntityData.MOB__MOB_FLAGS, MetadataType.BYTE) & MOB_FLAG_LEFTHANDED) != 0;
}

public boolean isAggressive() {
return (this.metadataState.getMetadata(NamedEntityData.MOB__MOB_FLAGS, MetadataType.BYTE) & MOB_FLAG_AGGRESSIVE) != 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,27 @@
public abstract class Player extends LivingEntity {
private final PlayerInventoryContainer inventory = new PlayerInventoryContainer();
private final AbilitiesData abilitiesData = new AbilitiesData();
public static final float CROUCH_BB_HEIGHT = 1.5F;
public static final float SWIMMING_BB_WIDTH = 0.6F;
public static final float SWIMMING_BB_HEIGHT = 0.6F;
public static final float DEFAULT_EYE_HEIGHT = 1.62F;
public static final EntityDimensions STANDING_DIMENSIONS = EntityDimensions.scalable(0.6F, 1.8F)
.withEyeHeight(1.62F);
.withEyeHeight(DEFAULT_EYE_HEIGHT);
private static final Map<Pose, EntityDimensions> POSES = ImmutableMap.<Pose, EntityDimensions>builder()
.put(Pose.STANDING, STANDING_DIMENSIONS)
.put(Pose.SLEEPING, SLEEPING_DIMENSIONS)
.put(Pose.FALL_FLYING, EntityDimensions.scalable(0.6F, 0.6F).withEyeHeight(0.4F))
.put(Pose.SWIMMING, EntityDimensions.scalable(0.6F, 0.6F).withEyeHeight(0.4F))
.put(Pose.SWIMMING, EntityDimensions.scalable(SWIMMING_BB_WIDTH, SWIMMING_BB_HEIGHT).withEyeHeight(0.4F))
.put(Pose.SPIN_ATTACK, EntityDimensions.scalable(0.6F, 0.6F).withEyeHeight(0.4F))
.put(Pose.SNEAKING, EntityDimensions.scalable(0.6F, 1.5F).withEyeHeight(1.27F))
.put(Pose.DYING, EntityDimensions.fixed(0.2F, 0.2F).withEyeHeight(1.62F))
.put(Pose.SNEAKING, EntityDimensions.scalable(0.6F, CROUCH_BB_HEIGHT).withEyeHeight(1.27F))
.put(Pose.DYING, EntityDimensions.fixed(0.2F, 0.2F).withEyeHeight(DEFAULT_EYE_HEIGHT))
.build();
public static final int CLIENT_LOADED_TIMEOUT_TIME = 60;
protected final GameProfile gameProfile;
protected boolean wasUnderwater = false;
private boolean reducedDebugInfo;
protected int clientLoadedTimeoutTimer = 60;
protected final float defaultFlySpeed = 0.02F;
protected int clientLoadedTimeoutTimer = CLIENT_LOADED_TIMEOUT_TIME;
private boolean clientLoaded = false;

public Player(Level level, GameProfile gameProfile) {
Expand Down Expand Up @@ -256,7 +262,7 @@ protected float getFlyingSpeed() {
if (this.abilitiesData.flying) {
return this.isSprinting() ? this.abilitiesData.flySpeed() * 2.0F : this.abilitiesData.flySpeed();
} else {
return this.isSprinting() ? 0.025999999F : 0.02F;
return this.isSprinting() ? 0.025999999F : defaultFlySpeed;
}
}

Expand Down

0 comments on commit 0d55473

Please sign in to comment.