mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-03-28 06:17:44 +01:00
Backport: Fixed floating pegasi
This commit is contained in:
parent
46bc422d45
commit
c7444ccca3
1 changed files with 30 additions and 1 deletions
|
@ -8,13 +8,18 @@ import com.voxelmodpack.hdskins.resources.texture.DynamicTextureImage;
|
||||||
import com.voxelmodpack.hdskins.resources.texture.IBufferedTexture;
|
import com.voxelmodpack.hdskins.resources.texture.IBufferedTexture;
|
||||||
import com.voxelmodpack.hdskins.util.ProfileTextureUtil;
|
import com.voxelmodpack.hdskins.util.ProfileTextureUtil;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockStairs;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.StairsBlock;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||||
import net.minecraft.client.resources.IResource;
|
import net.minecraft.client.resources.IResource;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -130,13 +135,37 @@ public class Pony extends Touchable<Pony> implements IPony {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFlying(EntityLivingBase entity) {
|
public boolean isFlying(EntityLivingBase entity) {
|
||||||
return !(entity.onGround
|
return !(isOnGround(entity)
|
||||||
|| entity.isRiding()
|
|| entity.isRiding()
|
||||||
|| (entity.isOnLadder() && !(entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.isFlying))
|
|| (entity.isOnLadder() && !(entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.isFlying))
|
||||||
|| entity.isInWater()
|
|| entity.isInWater()
|
||||||
|| entity.isPlayerSleeping());
|
|| entity.isPlayerSleeping());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(EntityLivingBase entity) {
|
||||||
|
if (entity.onGround) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IBlockState below = entity.getEntityWorld()
|
||||||
|
.getBlockState(entity.getPosition().down());
|
||||||
|
|
||||||
|
// Check for stairs so we can keep Pegasi from flailing their wings as they descend
|
||||||
|
double offsetAmount = below.getBlock() instanceof BlockStairs ? 1 : 0.05;
|
||||||
|
|
||||||
|
Vec3d pos = entity.getPositionVector();
|
||||||
|
BlockPos blockpos = new BlockPos(
|
||||||
|
Math.floor(pos.x),
|
||||||
|
Math.floor(pos.y - offsetAmount),
|
||||||
|
Math.floor(pos.z));
|
||||||
|
|
||||||
|
return !entity.getEntityWorld().isAirBlock(blockpos);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSwimming(EntityLivingBase entity) {
|
public boolean isSwimming(EntityLivingBase entity) {
|
||||||
return isFullySubmerged(entity) && !(entity.onGround || entity.isOnLadder());
|
return isFullySubmerged(entity) && !(entity.onGround || entity.isOnLadder());
|
||||||
|
|
Loading…
Add table
Reference in a new issue