Change packages and use enums

This commit is contained in:
Sollace 2018-06-22 00:42:13 +02:00
parent 658a48fe83
commit 8e173fc859
20 changed files with 160 additions and 164 deletions

View file

@ -13,7 +13,7 @@ import com.minelittlepony.pony.data.PonySize;
import com.minelittlepony.render.AbstractPonyRenderer;
import com.minelittlepony.render.PonyRenderer;
import com.minelittlepony.render.plane.PlaneRenderer;
import com.minelittlepony.transformation.PonyTransformation;
import com.minelittlepony.transform.PonyTransformation;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelPlayer;
@ -34,8 +34,7 @@ import static com.minelittlepony.model.PonyModelConstants.*;
*/
public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
public boolean isSleeping;
private boolean isSleeping;
private boolean isFlying;
private boolean isSwimming;
private boolean headGear;
@ -657,6 +656,16 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
return isFlying && canFly();
}
@Override
public boolean isSleeping() {
return isSleeping;
}
@Override
public boolean isRiding() {
return isRiding;
}
@Override
public boolean isSwimming() {
return isSwimming;

View file

@ -1,7 +1,5 @@
package com.minelittlepony.model.capabilities;
import javax.annotation.Nullable;
import net.minecraft.client.model.ModelRenderer;
public interface ICapitated {

View file

@ -4,7 +4,7 @@ import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.PonyArmor;
import com.minelittlepony.pony.data.IPonyData;
import com.minelittlepony.pony.data.PonyWearable;
import com.minelittlepony.transformation.PonyTransformation;
import com.minelittlepony.transform.PonyTransformation;
public interface IModel extends ICapitated {
@ -39,11 +39,21 @@ public interface IModel extends ICapitated {
*/
boolean isFlying();
/**
* Returns true if this model is lying on a bed or bed-like object.
*/
boolean isSleeping();
/**
* Returns true if this model is wimming underwater.
*/
boolean isSwimming();
/**
* Returns true if this model is riding a boat, horse, or other animals.
*/
boolean isRiding();
/**
* Returns true if we're flying really fast.
*/

View file

@ -46,7 +46,7 @@ public class ModelEarthPony extends AbstractPonyModel {
@Override
protected float getLegOutset() {
if (smallArms) {
if (isSleeping) return 2.6f;
if (isSleeping()) return 2.6f;
if (isCrouching()) return 1;
return 4;
}

View file

@ -77,7 +77,7 @@ public class ModelUnicorn extends ModelEarthPony implements IModelUnicorn {
EnumHandSide mainSide = getMainHand(entity);
if (canCast() && getArmPoseForSide(mainSide) != ArmPose.EMPTY) {
if (swingProgress > -9990.0F && !isSleeping) {
if (swingProgress > -9990.0F && !isSleeping()) {
swingArm(getUnicornArmForSide(mainSide));
}
} else {
@ -87,7 +87,7 @@ public class ModelUnicorn extends ModelEarthPony implements IModelUnicorn {
@Override
protected void swingArms(float ticks) {
if (isSleeping) return;
if (isSleeping()) return;
if (canCast()) {
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;

View file

@ -43,7 +43,7 @@ public class ModelSkeletonPony extends ModelMobPony {
}
protected float getLegOutset() {
if (isSleeping) return 2.6f;
if (isSleeping()) return 2.6f;
if (isCrouching()) return 0;
return 4;
}

View file

@ -1,13 +1,13 @@
package com.minelittlepony.pony.data;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.transformation.*;
import com.minelittlepony.transform.PonyTransformation;
public enum PonySize implements ITriggerPixelMapped<PonySize> {
NORMAL(0, 0.4f, 1f, new TransformNormal()),
LARGE(0xce3254, 0.5f, 0.8f, new TransformLarge()),
FOAL(0xffbe53, 0.25f, 0.8f, new TransformFoal()),
TALL(0x534b76, 0.45f, 1f, new TransformTall());
NORMAL(0, 0.4f, 1f, PonyTransformation.NORMAL),
LARGE(0xce3254, 0.5f, 0.8f, PonyTransformation.LARGE),
FOAL(0xffbe53, 0.25f, 0.8f, PonyTransformation.FOAL),
TALL(0x534b76, 0.45f, 1f, PonyTransformation.TALL);
private int triggerValue;

View file

@ -1,6 +1,6 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package com.minelittlepony.transformation;
package com.minelittlepony.posture;
import mcp.MethodsReturnNonnullByDefault;

View file

@ -19,7 +19,7 @@ import com.minelittlepony.render.layer.LayerPonyArmor;
import com.minelittlepony.render.layer.LayerPonyCape;
import com.minelittlepony.render.layer.LayerPonyCustomHead;
import com.minelittlepony.render.layer.LayerPonyElytra;
import com.minelittlepony.transformation.PonyPosture;
import com.minelittlepony.transform.PonyPosture;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.transformation;
package com.minelittlepony.transform;
import com.minelittlepony.model.AbstractPonyModel;

View file

@ -0,0 +1,114 @@
package com.minelittlepony.transform;
import static net.minecraft.client.renderer.GlStateManager.scale;
import static net.minecraft.client.renderer.GlStateManager.translate;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.capabilities.IModel;
public enum PonyTransformation {
NORMAL {
@Override
public void transform(IModel model, BodyPart part) {
if (model.isSleeping()) translate(0, -0.61F, 0.25F);
switch (part) {
case NECK:
if (model.isCrouching()) translate(-0.03F, 0.03F, 0.1F);
default:
}
}
},
LARGE {
@Override
public void transform(IModel model, BodyPart part) {
if (model.isSleeping()) translate(0, -0.98F, 0.2F);
switch (part) {
case NECK:
translate(0, -0.15F, -0.07F);
if (model.isCrouching()) translate(-0.03F, 0.16F, 0.07F);
break;
case HEAD:
translate(0, -0.17F, -0.04F);
if (model.isSleeping()) translate(0, 0, -0.1F);
if (model.isCrouching()) translate(0, 0.15F, 0);
break;
case BODY:
translate(0, -0.2F, -0.04F);
scale(1.15F, 1.2F, 1.2F);
break;
case TAIL:
translate(0, -0.2F, 0.08F);
break;
case LEGS:
translate(0, -0.14F, 0);
scale(1.15F, 1.12F, 1.15F);
break;
}
}
},
FOAL {
@Override
public void transform(IModel model, BodyPart part) {
if (model.isCrouching()) translate(0, -0.12F, 0);
if (model.isSleeping()) translate(0, -1.48F, 0.25F);
if (model.isRiding()) translate(0, -0.1F, 0);
switch (part) {
case NECK:
translate(0, 0.76F, 0);
scale(0.9F, 0.9F, 0.9F);
if (model.isCrouching()) translate(0, -0.01F, 0.15F);
break;
case HEAD:
translate(0, 0.76F, 0);
scale(0.9F, 0.9F, 0.9F);
break;
case BODY:
case TAIL:
translate(0, 0.76F, -0.04F);
scale(0.6F, 0.6F, 0.6F);
break;
case LEGS:
translate(0, 0.89F, 0);
scale(0.6F, 0.41F, 0.6F);
if (model.isCrouching()) translate(0, 0.12F, 0);
if (model.isGoingFast()) translate(0, -0.08F, 0);
break;
}
}
},
TALL {
@Override
public void transform(IModel model, BodyPart part) {
if (model.isSleeping()) translate(0, -0.5F, 0.25F);
switch (part) {
case NECK:
translate(0, -0.09F, -0.01F);
scale(1, 1.1F, 1);
if (model.isCrouching()) translate(-0.02F, -0.02F, 0.1F);
break;
case HEAD:
translate(0, -0.15F, 0.01F);
if (model.isCrouching()) translate(0, 0.05F, 0);
break;
case BODY:
translate(0, -0.1F, 0);
break;
case TAIL:
translate(0, -0.1F, 0);
break;
case LEGS:
translate(0, -0.25F, 0.03F);
scale(1, 1.18F, 1);
if (model.isGoingFast()) translate(0, 0.05F, 0);
break;
}
}
};
public abstract void transform(IModel model, BodyPart part);
}

View file

@ -1,4 +1,4 @@
package com.minelittlepony.transformation;
package com.minelittlepony.transform;
import com.minelittlepony.model.AbstractPonyModel;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.transformation;
package com.minelittlepony.transform;
import com.minelittlepony.model.AbstractPonyModel;

View file

@ -1,4 +1,4 @@
package com.minelittlepony.transformation;
package com.minelittlepony.transform;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.util.math.MathUtil;

View file

@ -0,0 +1,8 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package com.minelittlepony.transform;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -1,8 +0,0 @@
package com.minelittlepony.transformation;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart;
public interface PonyTransformation {
void transform(AbstractPonyModel model, BodyPart part);
}

View file

@ -1,40 +0,0 @@
package com.minelittlepony.transformation;
import static net.minecraft.client.renderer.GlStateManager.scale;
import static net.minecraft.client.renderer.GlStateManager.translate;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart;
public class TransformFoal implements PonyTransformation {
@Override
public void transform(AbstractPonyModel model, BodyPart part) {
if (model.isCrouching()) translate(0, -0.12F, 0);
if (model.isSleeping) translate(0, -1.48F, 0.25F);
if (model.isRiding) translate(0, -0.1F, 0);
switch (part) {
case NECK:
translate(0, 0.76F, 0);
scale(0.9F, 0.9F, 0.9F);
if (model.isCrouching()) translate(0, -0.01F, 0.15F);
break;
case HEAD:
translate(0, 0.76F, 0);
scale(0.9F, 0.9F, 0.9F);
break;
case BODY:
case TAIL:
translate(0, 0.76F, -0.04F);
scale(0.6F, 0.6F, 0.6F);
break;
case LEGS:
translate(0, 0.89F, 0);
scale(0.6F, 0.41F, 0.6F);
if (model.isCrouching()) translate(0, 0.12F, 0);
if (model.isGoingFast()) translate(0, -0.08F, 0);
break;
}
}
}

View file

@ -1,38 +0,0 @@
package com.minelittlepony.transformation;
import static net.minecraft.client.renderer.GlStateManager.scale;
import static net.minecraft.client.renderer.GlStateManager.translate;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart;
public class TransformLarge implements PonyTransformation {
@Override
public void transform(AbstractPonyModel model, BodyPart part) {
if (model.isSleeping) translate(0, -0.98F, 0.2F);
switch (part) {
case NECK:
translate(0, -0.15F, -0.07F);
if (model.isCrouching()) translate(-0.03F, 0.16F, 0.07F);
break;
case HEAD:
translate(0, -0.17F, -0.04F);
if (model.isSleeping) translate(0, 0, -0.1F);
if (model.isCrouching()) translate(0, 0.15F, 0);
break;
case BODY:
translate(0, -0.2F, -0.04F);
scale(1.15F, 1.2F, 1.2F);
break;
case TAIL:
translate(0, -0.2F, 0.08F);
break;
case LEGS:
translate(0, -0.14F, 0);
scale(1.15F, 1.12F, 1.15F);
break;
}
}
}

View file

@ -1,19 +0,0 @@
package com.minelittlepony.transformation;
import static net.minecraft.client.renderer.GlStateManager.translate;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart;
public class TransformNormal implements PonyTransformation {
@Override
public void transform(AbstractPonyModel model, BodyPart part) {
if (model.isSleeping) translate(0, -0.61F, 0.25F);
switch (part) {
case NECK:
if (model.isCrouching()) translate(-0.03F, 0.03F, 0.1F);
default:
}
}
}

View file

@ -1,38 +0,0 @@
package com.minelittlepony.transformation;
import static net.minecraft.client.renderer.GlStateManager.scale;
import static net.minecraft.client.renderer.GlStateManager.translate;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart;
public class TransformTall implements PonyTransformation {
@Override
public void transform(AbstractPonyModel model, BodyPart part) {
if (model.isSleeping) translate(0, -0.5F, 0.25F);
switch (part) {
case NECK:
translate(0, -0.09F, -0.01F);
scale(1, 1.1F, 1);
if (model.isCrouching()) translate(-0.02F, -0.02F, 0.1F);
break;
case HEAD:
translate(0, -0.15F, 0.01F);
if (model.isCrouching()) translate(0, 0.05F, 0);
break;
case BODY:
translate(0, -0.1F, 0);
break;
case TAIL:
translate(0, -0.1F, 0);
break;
case LEGS:
translate(0, -0.25F, 0.03F);
scale(1, 1.18F, 1);
if (model.isGoingFast()) translate(0, 0.05F, 0);
break;
}
}
}