package playasmob;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.Abilities;
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.EntityType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.core.BlockPos;
import net.minecraft.client.Options;
import java.util.List;
public abstract class FlyingMobInfo extends MobInfo {
public FlyingMobInfo(EntityType type, Class typeClass, Player player, CompoundTag compound) {
super(type, typeClass, player, compound);
}
// Custom Code
@Override
public boolean canFly() {
return true;
}
@Override
public boolean canWalk() {
return false;
}
@Override
public boolean canCrouch() {
return false;
}
@Override
public boolean canSwim() {
return false;
}
@Override
public boolean canGlide() {
return false;
}
@Override
public boolean canSprint(boolean original) {
return false;
}
@Override
public boolean isSteppingCarefully(boolean original) {
return false;
}
@Override
public Abilities getAbilities(Abilities original) {
original = super.getAbilities(original);
original.mayfly = false;
original.flying = false;
return original;
}
@Override
public List<HudIcon> getIcons(float partialTick) {
Options settings = Utils.clientSettings();
HudIcon flyUpwards = new HudIcon("textures/mob_effect/jump_boost.png").anchor(0, 1).key(settings.keyJump).using(settings.keyJump.isDown()).useable(this.isAlive() && !settings.keyShift.isDown());
HudIcon flyDownwards = new HudIcon("playasmob:textures/screens/down.png").anchor(0, 1).key(settings.keyShift).using(settings.keyShift.isDown()).useable(this.isAlive() && !settings.keyJump.isDown());
return Utils.merge(super.getIcons(partialTick), HudIcon.align(true, false, flyDownwards, flyUpwards.offsetY(flyDownwards, true)));
}
// FlyingMob.class Code
@Override
public boolean checkFallDamage(Object object, double p_20809_, boolean p_20810_, BlockState state, BlockPos pos) {
return false;
}
@Override
public boolean travel(Object object, Vec3 movement) {
if (!this.isBound())
return false;
if (this.isControlledByLocalInstance()) {
float speed = this.getSpeed();
Options settings = Utils.clientSettings();
this.player.yya = 0;
if (settings.keyShift.isDown())
this.player.yya = speed * -3f;
if (settings.keyJump.isDown())
this.player.yya = speed * 3f;
if (this.isInWater()) {
this.moveRelative(0.02F, movement);
this.move(MoverType.SELF, this.getDeltaMovement());
this.setDeltaMovement(this.getDeltaMovement().scale(0.8F));
} else if (this.isInLava()) {
this.moveRelative(0.02F, movement);
this.move(MoverType.SELF, this.getDeltaMovement());
this.setDeltaMovement(this.getDeltaMovement().scale(0.5));
} else {
BlockPos ground = getBlockPosBelowThatAffectsMyMovement();
float f = 0.91F;
if (this.onGround()) {
f = this.level().getBlockState(ground).getFriction(this.level(), ground, this.player) * 0.91F;
}
float f1 = 0.16277137F / (f * f * f);
f = 0.91F;
if (this.onGround()) {
f = this.level().getBlockState(ground).getFriction(this.level(), ground, this.player) * 0.91F;
}
this.moveRelative(this.onGround() ? 0.1F * f1 : 0.02F, movement);
this.move(MoverType.SELF, this.getDeltaMovement());
this.setDeltaMovement(this.getDeltaMovement().scale((double) f));
}
}
return false;
}
@Override
public boolean onClimbable(boolean original) {
return false;
}
}