mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Pegasus wings flap slower when underwater
This commit is contained in:
parent
b879c979ce
commit
d3efbc5c05
9 changed files with 44 additions and 22 deletions
|
@ -31,13 +31,9 @@ import static com.minelittlepony.model.PonyModelConstants.*;
|
|||
*/
|
||||
public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
||||
|
||||
/**
|
||||
* The model's current scale.
|
||||
*/
|
||||
protected float scale = 0.0625F;
|
||||
|
||||
public boolean isFlying;
|
||||
public boolean isSleeping;
|
||||
public boolean isSwimming;
|
||||
|
||||
/**
|
||||
* Associcated pony data.
|
||||
|
@ -660,6 +656,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
|||
return isFlying && canFly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSwimming() {
|
||||
return isSwimming;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChild() {
|
||||
return metadata.getSize() == PonySize.FOAL || isChild;
|
||||
|
@ -691,7 +692,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
|||
|
||||
pushMatrix();
|
||||
transform(BodyPart.NECK);
|
||||
renderNeck();
|
||||
renderNeck(scale);
|
||||
popMatrix();
|
||||
|
||||
pushMatrix();
|
||||
|
@ -701,7 +702,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
|||
|
||||
pushMatrix();
|
||||
transform(BodyPart.LEGS);
|
||||
renderLegs();
|
||||
renderLegs(scale);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
|
@ -718,7 +719,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
|||
bipedHead.postRender(scale);
|
||||
}
|
||||
|
||||
protected void renderNeck() {
|
||||
protected void renderNeck(float scale) {
|
||||
GlStateManager.scale(0.9, 0.9, 0.9);
|
||||
neck.render(scale);
|
||||
}
|
||||
|
@ -740,7 +741,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
|||
tail.render(scale);
|
||||
}
|
||||
|
||||
protected void renderLegs() {
|
||||
protected void renderLegs(float scale) {
|
||||
if (!isSneak) bipedBody.postRender(scale);
|
||||
|
||||
bipedLeftArm.render(scale);
|
||||
|
|
|
@ -33,12 +33,12 @@ public class ModelPonyArmor extends AbstractPonyModel {
|
|||
|
||||
@Override
|
||||
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
|
||||
flankGuard.render(this.scale);
|
||||
saddle.render(this.scale);
|
||||
flankGuard.render(scale);
|
||||
saddle.render(scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLegs() {
|
||||
protected void renderLegs(float scale) {
|
||||
if (!isSneak) {
|
||||
boolean isLegs = saddle.showModel;
|
||||
saddle.showModel = true;
|
||||
|
@ -46,7 +46,7 @@ public class ModelPonyArmor extends AbstractPonyModel {
|
|||
saddle.showModel = isLegs;
|
||||
}
|
||||
|
||||
super.renderLegs();
|
||||
super.renderLegs(scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,6 +36,11 @@ public interface IModel {
|
|||
*/
|
||||
boolean isFlying();
|
||||
|
||||
/**
|
||||
* Returns true if this model is wimming underwater.
|
||||
*/
|
||||
boolean isSwimming();
|
||||
|
||||
/**
|
||||
* Returns true if we're flying really fast.
|
||||
*/
|
||||
|
|
|
@ -5,6 +5,6 @@ public interface IModelPegasus extends IModel {
|
|||
* Returns true if the wings are spread.
|
||||
*/
|
||||
default boolean wingsAreOpen() {
|
||||
return isFlying() || isCrouching();
|
||||
return isSwimming() || isFlying() || isCrouching();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,11 @@ public class PegasusWings implements IModelPart {
|
|||
}
|
||||
|
||||
public float getWingRotationFactor(float ticks) {
|
||||
if (pegasus.isSwimming()) {
|
||||
return (MathHelper.sin(ticks * 0.136f) / 2) + ROTATE_270;
|
||||
}
|
||||
if (pegasus.isFlying()) {
|
||||
return (MathHelper.sin(ticks * 0.536f) * 1) + ROTATE_270 + 0.4f;
|
||||
return MathHelper.sin(ticks * 0.536f) + ROTATE_270 + 0.4f;
|
||||
}
|
||||
return LEFT_WING_ROTATE_ANGLE_Z_SNEAK;
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ public class ModelZebra extends ModelEarthPony {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderNeck() {
|
||||
protected void renderNeck(float scale) {
|
||||
GlStateManager.scale(1, 1.1F, 1);
|
||||
super.renderNeck();
|
||||
super.renderNeck(scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,13 +38,13 @@ public class ModelZebra extends ModelEarthPony {
|
|||
super.initHeadPositions(yOffset, stretch);
|
||||
|
||||
bristles.offset(-1, -1, -3)
|
||||
.box(0, -10, 2, 2, 6, 2, scale)
|
||||
.box(0, -10, 4, 2, 8, 2, scale)
|
||||
.box(0, -8, 6, 2, 6, 2, scale)
|
||||
.box(0, -10, 2, 2, 6, 2, stretch)
|
||||
.box(0, -10, 4, 2, 8, 2, stretch)
|
||||
.box(0, -8, 6, 2, 6, 2, stretch)
|
||||
.rotateAngleX = 0.3F;
|
||||
bristles.child(0).offset(-1.01F, 2, -7) //0.01 to prevent z-fighting
|
||||
.box(0, -10, 4, 2, 8, 2, scale)
|
||||
.box(0, -8, 6, 2, 6, 2, scale)
|
||||
.box(0, -10, 4, 2, 8, 2, stretch)
|
||||
.box(0, -8, 6, 2, 6, 2, stretch)
|
||||
.rotateAngleX = -1F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,15 @@ import com.minelittlepony.mixin.MixinThreadDownloadImageData;
|
|||
import com.minelittlepony.model.ModelWrapper;
|
||||
import com.voxelmodpack.hdskins.DynamicTextureImage;
|
||||
import com.voxelmodpack.hdskins.ThreadDownloadImageETag;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -101,6 +104,14 @@ public class Pony {
|
|||
!(entity.onGround || entity.isRiding() || entity.isOnLadder() || entity.isInWater());
|
||||
}
|
||||
|
||||
public boolean isSwimming(EntityLivingBase entity) {
|
||||
return isFullySubmerged(entity) && !(entity.onGround || entity.isOnLadder());
|
||||
}
|
||||
|
||||
public boolean isFullySubmerged(EntityLivingBase entity) {
|
||||
return entity.isInWater() && entity.getEntityWorld().getBlockState(new BlockPos(entity.getPositionEyes(1))).getMaterial() == Material.WATER;
|
||||
}
|
||||
|
||||
public ModelWrapper getModel(boolean ignorePony) {
|
||||
return getRace(ignorePony).getModel().getModel(smallArms);
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
|
|||
ponyModel.isSneak = entity.isSneaking();
|
||||
ponyModel.isSleeping = entity.isPlayerSleeping();
|
||||
ponyModel.isFlying = pony.isPegasusFlying(entity);
|
||||
ponyModel.isSwimming = pony.isSwimming(entity);
|
||||
|
||||
super.preRenderCallback(entity, ticks);
|
||||
shadowSize = getShadowScale();
|
||||
|
|
|
@ -53,6 +53,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
|
|||
ponyModel.isSneak = player.isSneaking();
|
||||
ponyModel.isSleeping = player.isPlayerSleeping();
|
||||
ponyModel.isFlying = pony.isPegasusFlying(player);
|
||||
ponyModel.isSwimming = pony.isSwimming(player);
|
||||
|
||||
super.preRenderCallback(player, ticks);
|
||||
shadowSize = getShadowScale();
|
||||
|
|
Loading…
Reference in a new issue