mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 20:47:59 +01:00
Add a fix for floating pegasi.
This commit is contained in:
parent
4709e45d62
commit
73db95a777
1 changed files with 30 additions and 1 deletions
|
@ -8,7 +8,10 @@ import com.minelittlepony.pony.IPony;
|
||||||
import com.minelittlepony.pony.IPonyData;
|
import com.minelittlepony.pony.IPonyData;
|
||||||
import com.minelittlepony.pony.meta.Race;
|
import com.minelittlepony.pony.meta.Race;
|
||||||
import com.minelittlepony.pony.meta.Size;
|
import com.minelittlepony.pony.meta.Size;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
|
import net.minecraft.block.StairsBlock;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
|
@ -70,13 +73,39 @@ public class Pony implements IPony {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFlying(LivingEntity entity) {
|
public boolean isFlying(LivingEntity entity) {
|
||||||
return !(entity.onGround
|
return !(isOnGround(entity)
|
||||||
|| entity.hasVehicle()
|
|| entity.hasVehicle()
|
||||||
|| (entity.isClimbing() && !(entity instanceof PlayerEntity && ((PlayerEntity)entity).abilities.allowFlying))
|
|| (entity.isClimbing() && !(entity instanceof PlayerEntity && ((PlayerEntity)entity).abilities.allowFlying))
|
||||||
|| entity.isInWater()
|
|| entity.isInWater()
|
||||||
|| entity.isSleeping());
|
|| entity.isSleeping());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the entity is on the ground, or close enough to be "effectively" grounded.
|
||||||
|
* this is to keep Pegasus wings from flapping in odd situations (Hypixel).
|
||||||
|
*/
|
||||||
|
private boolean isOnGround(LivingEntity entity) {
|
||||||
|
if (entity.onGround) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockState below = entity.getEntityWorld()
|
||||||
|
.getBlockState(entity.getBlockPos().down());
|
||||||
|
|
||||||
|
// Check for stairs so we can keep Pegasi from flailing their wings as they descend
|
||||||
|
double offsetAmount = below.getBlock() instanceof StairsBlock ? 1 : 0.05;
|
||||||
|
|
||||||
|
Vec3d pos = entity.getPos();
|
||||||
|
BlockPos blockpos = new BlockPos(
|
||||||
|
Math.floor(pos.x),
|
||||||
|
Math.floor(pos.y - offsetAmount),
|
||||||
|
Math.floor(pos.z));
|
||||||
|
|
||||||
|
BlockState state = entity.getEntityWorld()
|
||||||
|
.getBlockState(blockpos);
|
||||||
|
return !state.isAir();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSwimming(LivingEntity entity) {
|
public boolean isSwimming(LivingEntity entity) {
|
||||||
return entity.isSwimming() || entity.isInSwimmingPose();
|
return entity.isSwimming() || entity.isInSwimmingPose();
|
||||||
|
|
Loading…
Reference in a new issue