Yet more codestyle!

This commit is contained in:
Sollace 2018-04-26 23:53:03 +02:00
parent 785784b694
commit 2ad7119723
16 changed files with 71 additions and 65 deletions

View file

@ -32,10 +32,9 @@ import java.util.stream.Collectors;
*/ */
public class PonyManager implements IResourceManagerReloadListener { public class PonyManager implements IResourceManagerReloadListener {
public static final ResourceLocation public static final ResourceLocation STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png");
STEVE = new ResourceLocation("minelittlepony", "textures/entity/steve_pony.png"), public static final ResourceLocation ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png");
ALEX = new ResourceLocation("minelittlepony", "textures/entity/alex_pony.png"), public static final ResourceLocation BGPONIES_JSON = new ResourceLocation("minelittlepony", "textures/entity/pony/bgponies.json");
BGPONIES_JSON = new ResourceLocation("minelittlepony", "textures/entity/pony/bgponies.json");
private static final Gson GSON = new Gson(); private static final Gson GSON = new Gson();

View file

@ -56,12 +56,12 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> {
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack.getItem() == Items.ELYTRA) { if (itemstack.getItem() == Items.ELYTRA) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1, 1, 1, 1);
bindTexture(entity.getElytraTexture()); bindTexture(entity.getElytraTexture());
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.25F, 0.125F); GlStateManager.translate(0, 0.25F, 0.125F);
((AbstractPonyModel) mainModel).transform(BodyPart.BODY); ((AbstractPonyModel) mainModel).transform(BodyPart.BODY);
modelElytra.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); modelElytra.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity);

View file

@ -130,7 +130,7 @@ public abstract class AbstractPonyModel extends ModelPlayer {
float swing = MathHelper.sin(swingProgress * (float)Math.PI); float swing = MathHelper.sin(swingProgress * (float)Math.PI);
float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI); float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI);
arm.rotateAngleZ = 0.0F; arm.rotateAngleZ = 0;
arm.rotateAngleY = direction * (0.1F - swing * 0.6F); arm.rotateAngleY = direction * (0.1F - swing * 0.6F);
arm.rotateAngleX = -1.5707964F; arm.rotateAngleX = -1.5707964F;
arm.rotateAngleX -= swing * 1.2F - roll * 0.4F; arm.rotateAngleX -= swing * 1.2F - roll * 0.4F;
@ -224,9 +224,9 @@ public abstract class AbstractPonyModel extends ModelPlayer {
} }
private void transformFoal(BodyPart part) { private void transformFoal(BodyPart part) {
if (isCrouching()) translate(0, -0.12F, 0.0F); if (isCrouching()) translate(0, -0.12F, 0);
if (isSleeping) translate(0, -1.2F, 0.25F); if (isSleeping) translate(0, -1.2F, 0.25F);
if (isRiding) translate(0, -.1, 0); if (isRiding) translate(0, -0.1F, 0);
switch (part) { switch (part) {
case NECK: case NECK:
@ -247,7 +247,6 @@ public abstract class AbstractPonyModel extends ModelPlayer {
scale(0.6F, 0.41F, 0.6F); scale(0.6F, 0.41F, 0.6F);
if (isCrouching()) translate(0, 0.12F, 0); if (isCrouching()) translate(0, 0.12F, 0);
if (rainboom) translate(0, -0.08F, 0); if (rainboom) translate(0, -0.08F, 0);
break; break;
} }
} }
@ -272,17 +271,17 @@ public abstract class AbstractPonyModel extends ModelPlayer {
public ModelRenderer getRandomModelBox(Random rand) { public ModelRenderer getRandomModelBox(Random rand) {
// grab one at random, but cycle through the list until you find one that's filled. // grab one at random, but cycle through the list until you find one that's filled.
// Return if you find one, or if you get back to where you started in which case there isn't any. // Return if you find one, or if you get back to where you started in which case there isn't any.
int index = rand.nextInt(boxList.size()); int randomI = rand.nextInt(boxList.size());
int i = index; int index = randomI;
ModelRenderer mr; ModelRenderer result;
do { do {
mr = boxList.get(index); result = boxList.get(randomI);
if (!mr.cubeList.isEmpty()) return mr; if (!result.cubeList.isEmpty()) return result;
i = (i + 1) % boxList.size(); index = (index + 1) % boxList.size();
} while (i != index); } while (index != randomI);
return mr; return result;
} }
} }

View file

@ -10,12 +10,12 @@ public final class PonyModelConstants {
BODY_CENTRE_Z = 6, BODY_CENTRE_Z = 6,
NECK_CENTRE_X = BODY_CENTRE_X - 2, NECK_CENTRE_X = BODY_CENTRE_X - 2,
NECK_CENTRE_Y = BODY_CENTRE_Y - 6.8f, NECK_CENTRE_Y = BODY_CENTRE_Y - 6.8F,
NECK_CENTRE_Z = BODY_CENTRE_Z - 8.8f, NECK_CENTRE_Z = BODY_CENTRE_Z - 8.8F,
BODY_ROTATE_ANGLE_X_NOTSNEAK = 0, BODY_ROTATE_ANGLE_X_NOTSNEAK = 0,
BODY_ROTATE_ANGLE_X_SNEAK = 0.4F, BODY_ROTATE_ANGLE_X_SNEAK = 0.4F,
BODY_ROTATE_ANGLE_X_RIDING = (float) (Math.PI * 3.8), BODY_ROTATE_ANGLE_X_RIDING = PI * 3.8F,
BODY_RP_Y_NOTSNEAK = 0, BODY_RP_Y_NOTSNEAK = 0,
BODY_RP_Y_SNEAK = 7, BODY_RP_Y_SNEAK = 7,
@ -42,6 +42,10 @@ public final class PonyModelConstants {
HEAD_RP_Y = 0, HEAD_RP_Y = 0,
HEAD_RP_Z = 0, HEAD_RP_Z = 0,
HORN_X = HEAD_CENTRE_X - 0.5F,
HORN_Y = HEAD_CENTRE_Y - 10,
HORN_Z = HEAD_CENTRE_Z - 1.5F,
LEFT_WING_EXT_RP_X = 4.5F, LEFT_WING_EXT_RP_X = 4.5F,
LEFT_WING_EXT_RP_Y = 6, LEFT_WING_EXT_RP_Y = 6,
LEFT_WING_EXT_RP_Z = 6, LEFT_WING_EXT_RP_Z = 6,

View file

@ -12,7 +12,8 @@ public class PegasusWings extends ModelBase {
private final AbstractPonyModel pony; private final AbstractPonyModel pony;
public final ModelWing leftWing, rightWing; public final ModelWing leftWing;
public final ModelWing rightWing;
public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) { public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) {
this.pony = pony; this.pony = pony;
@ -32,7 +33,7 @@ public class PegasusWings extends ModelBase {
} else { } else {
float pi = PI * (float) Math.pow(limbSwingAmount, 16); float pi = PI * (float) Math.pow(limbSwingAmount, 16);
float mve = limbSwing * 0.6662F; // magic number ahoy float mve = limbSwing * 0.6662f; // magic number ahoy
float srt = limbSwingAmount / 4; float srt = limbSwingAmount / 4;
swing = MathHelper.cos(mve + pi) * srt; swing = MathHelper.cos(mve + pi) * srt;
@ -51,7 +52,7 @@ public class PegasusWings extends ModelBase {
public float getWingRotationFactor(float ticks) { public float getWingRotationFactor(float ticks) {
if (pony.isFlying) { if (pony.isFlying) {
return (MathHelper.sin(ticks * 0.536F) * 1.0F) + ROTATE_270 + 0.4F; return (MathHelper.sin(ticks * 0.536f) * 1) + ROTATE_270 + 0.4f;
} }
return LEFT_WING_ROTATE_ANGLE_Z_SNEAK; return LEFT_WING_ROTATE_ANGLE_Z_SNEAK;
} }

View file

@ -2,9 +2,9 @@ package com.minelittlepony.model.components;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.render.HornGlowRenderer; import com.minelittlepony.render.HornGlowRenderer;
import com.minelittlepony.render.PonyRenderer;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import static org.lwjgl.opengl.GL11.*; import static org.lwjgl.opengl.GL11.*;
@ -12,15 +12,10 @@ import static net.minecraft.client.renderer.GlStateManager.*;
import static com.minelittlepony.model.PonyModelConstants.*; import static com.minelittlepony.model.PonyModelConstants.*;
public class UnicornHorn extends ModelBase { public class UnicornHorn extends ModelBase {
static final float
hornX = HEAD_CENTRE_X - 0.5F,
hornY = HEAD_CENTRE_Y - 10,
hornZ = HEAD_CENTRE_Z - 1.5F;
protected final AbstractPonyModel pony; protected final AbstractPonyModel pony;
private ModelRenderer horn; private PonyRenderer horn;
private HornGlowRenderer glow; private HornGlowRenderer glow;
private boolean usingMagic; private boolean usingMagic;
@ -28,22 +23,25 @@ public class UnicornHorn extends ModelBase {
public UnicornHorn(AbstractPonyModel pony, float yOffset, float stretch) { public UnicornHorn(AbstractPonyModel pony, float yOffset, float stretch) {
this.pony = pony; this.pony = pony;
horn = new ModelRenderer(pony, 0, 3); horn = new PonyRenderer(pony, 0, 3);
glow = new HornGlowRenderer(pony, 0, 3); glow = new HornGlowRenderer(pony, 0, 3);
horn.addBox(hornX, hornY, hornZ, 1, 4, 1, stretch); horn.offset(HORN_X, HORN_Y, HORN_Z)
horn.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
horn.rotateAngleX = 0.5F; .box(0, 0, 0, 1, 4, 1, stretch)
.rotateAngleX = 0.5F;
glow.setAlpha(0.4f).addBox(hornX, hornY, hornZ, 1, 4, 1, stretch + 0.5F); glow.offset(HORN_X, HORN_Y, HORN_Z)
glow.setAlpha(0.2f).addBox(hornX, hornY, hornZ, 1, 3, 1, stretch + 0.8F); .around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.setAlpha(0.4f).box(0, 0, 0, 1, 4, 1, stretch + 0.5F)
.setAlpha(0.2f).box(0, 0, 0, 1, 3, 1, stretch + 0.8F);
} }
@Override @Override
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
if (!pony.metadata.getRace().hasHorn()) return; if (!pony.metadata.getRace().hasHorn()) return;
this.horn.render(scale); horn.render(scale);
if (usingMagic && pony.metadata.hasMagic()) { if (usingMagic && pony.metadata.hasMagic()) {
renderMagic(pony.metadata.getGlowColor(), scale); renderMagic(pony.metadata.getGlowColor(), scale);

View file

@ -21,7 +21,7 @@ public class ModelVillagerPony extends ModelPlayerPony {
float swing = 0; float swing = 0;
if (swingProgress > -9990.0F && !metadata.hasMagic()) { if (swingProgress > -9990.0F && !metadata.hasMagic()) {
swing = MathHelper.sin(MathHelper.sqrt(swingProgress) * (float)Math.PI * 2) * 0.04f; swing = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.04F;
} }
bag.rotateAngleY = swing; bag.rotateAngleY = swing;
apron.rotateAngleY = swing; apron.rotateAngleY = swing;

View file

@ -18,7 +18,7 @@ public class ModelZombiePony extends ModelMobPony {
} }
private boolean isRight(float move) { private boolean isRight(float move) {
return MathHelper.sin(move / 20f) < 0; return MathHelper.sin(move / 20) < 0;
} }
@Override @Override

View file

@ -4,7 +4,7 @@ public enum PonyGender implements ITriggerPixelMapped<PonyGender> {
MARE(0), MARE(0),
STALLION(0xffffff); STALLION(0xffffff);
int triggerValue; private int triggerValue;
PonyGender(int pixel) { PonyGender(int pixel) {
triggerValue = pixel; triggerValue = pixel;

View file

@ -1,7 +1,6 @@
package com.minelittlepony.pony.data; package com.minelittlepony.pony.data;
public enum PonyLevel { public enum PonyLevel {
PONIES, PONIES,
HUMANS, HUMANS,
BOTH BOTH

View file

@ -15,7 +15,8 @@ public enum PonyRace implements ITriggerPixelMapped<PonyRace> {
GRIFFIN(0xae9145, PlayerModels.PONY, true, false), GRIFFIN(0xae9145, PlayerModels.PONY, true, false),
HIPPOGRIFF(0xd6ddac, PlayerModels.PONY, true, false); HIPPOGRIFF(0xd6ddac, PlayerModels.PONY, true, false);
private boolean wings, horn; private boolean wings;
private boolean horn;
private int triggerPixel; private int triggerPixel;

View file

@ -8,7 +8,8 @@ public enum PonySize implements ITriggerPixelMapped<PonySize> {
private int triggerValue; private int triggerValue;
private float shadowSize, scale; private float shadowSize;
private float scale;
PonySize(int pixel, float shadowSz, float scaleF) { PonySize(int pixel, float shadowSz, float scaleF) {
triggerValue = pixel; triggerValue = pixel;

View file

@ -13,7 +13,8 @@ public enum TriggerPixels {
SIZE(PonySize.NORMAL, 3, 0), SIZE(PonySize.NORMAL, 3, 0),
GLOW(null, 0, 1); GLOW(null, 0, 1);
private int x, y; private int x;
private int y;
ITriggerPixelMapped<?> def; ITriggerPixelMapped<?> def;

View file

@ -10,9 +10,12 @@ public abstract class BasePonyRenderer<T extends BasePonyRenderer<T>> extends Mo
protected final ModelBase baseModel; protected final ModelBase baseModel;
protected int textureOffsetX, textureOffsetY; protected int textureOffsetX;
protected int textureOffsetY;
protected float modelOffsetX, modelOffsetY, modelOffsetZ; protected float modelOffsetX;
protected float modelOffsetY;
protected float modelOffsetZ;
public BasePonyRenderer(ModelBase model) { public BasePonyRenderer(ModelBase model) {
super(model); super(model);

View file

@ -37,8 +37,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
} }
@Override @Override
public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, float partialTicks) {
float partialTicks) {
double yOrigin = yPosition; double yOrigin = yPosition;
if (entity.isSneaking()) { if (entity.isSneaking()) {
yOrigin -= 0.125D; yOrigin -= 0.125D;

View file

@ -16,6 +16,7 @@ import net.minecraft.util.math.MathHelper;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import static net.minecraft.client.renderer.GlStateManager.*; import static net.minecraft.client.renderer.GlStateManager.*;
import static com.minelittlepony.model.PonyModelConstants.PI;
public class LayerPonyCape extends AbstractPonyLayer<AbstractClientPlayer> { public class LayerPonyCape extends AbstractPonyLayer<AbstractClientPlayer> {
@ -31,38 +32,38 @@ public class LayerPonyCape extends AbstractPonyLayer<AbstractClientPlayer> {
&& clientPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() != Items.ELYTRA) { && clientPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() != Items.ELYTRA) {
pushMatrix(); pushMatrix();
model.getModel().transform(BodyPart.BODY); model.getModel().transform(BodyPart.BODY);
translate(0.0F, 0.24F, 0.0F); translate(0, 0.24F, 0);
model.getModel().bipedBody.postRender(scale); model.getModel().bipedBody.postRender(scale);
double d = clientPlayer.prevChasingPosX + (clientPlayer.chasingPosX - clientPlayer.prevChasingPosX) * scale - (clientPlayer.prevPosX + (clientPlayer.posX - clientPlayer.prevPosX) * scale); double d = clientPlayer.prevChasingPosX + (clientPlayer.chasingPosX - clientPlayer.prevChasingPosX) * scale - (clientPlayer.prevPosX + (clientPlayer.posX - clientPlayer.prevPosX) * scale);
double d1 = clientPlayer.prevChasingPosY + (clientPlayer.chasingPosY - clientPlayer.prevChasingPosY) * scale - (clientPlayer.prevPosY + (clientPlayer.posY - clientPlayer.prevPosY) * scale); double d1 = clientPlayer.prevChasingPosY + (clientPlayer.chasingPosY - clientPlayer.prevChasingPosY) * scale - (clientPlayer.prevPosY + (clientPlayer.posY - clientPlayer.prevPosY) * scale);
double d2 = clientPlayer.prevChasingPosZ + (clientPlayer.chasingPosZ - clientPlayer.prevChasingPosZ) * scale - (clientPlayer.prevPosZ + (clientPlayer.posZ - clientPlayer.prevPosZ) * scale); double d2 = clientPlayer.prevChasingPosZ + (clientPlayer.chasingPosZ - clientPlayer.prevChasingPosZ) * scale - (clientPlayer.prevPosZ + (clientPlayer.posZ - clientPlayer.prevPosZ) * scale);
float f10 = clientPlayer.prevRenderYawOffset + (clientPlayer.renderYawOffset - clientPlayer.prevRenderYawOffset) * scale; float f10 = clientPlayer.prevRenderYawOffset + (clientPlayer.renderYawOffset - clientPlayer.prevRenderYawOffset) * scale;
double d3 = MathHelper.sin(f10 * 3.1415927F / 180.0F); double d3 = MathHelper.sin(f10 * PI / 180);
double d4 = (-MathHelper.cos(f10 * 3.1415927F / 180.0F)); double d4 = (-MathHelper.cos(f10 * PI / 180));
float f12 = (float) d1 * 10.0F; float f12 = (float) d1 * 10;
if (f12 < -6.0F) { if (f12 < -6.0F) {
f12 = -6.0F; f12 = -6.0F;
} }
if (f12 > 32.0F) { if (f12 > 32) {
f12 = 32.0F; f12 = 32;
} }
float f13 = (float) (d * d3 + d2 * d4) * 100.0F; float f13 = (float) (d * d3 + d2 * d4) * 100;
float f14 = (float) (d * d4 - d2 * d3) * 100.0F; float f14 = (float) (d * d4 - d2 * d3) * 100;
if (f13 < 0.0F) { if (f13 < 0) {
f13 = 0.0F; f13 = 0;
} }
float f15 = clientPlayer.prevCameraYaw + (clientPlayer.cameraYaw - clientPlayer.prevCameraYaw) * scale; float f15 = clientPlayer.prevCameraYaw + (clientPlayer.cameraYaw - clientPlayer.prevCameraYaw) * scale;
f12 += MathHelper.sin((clientPlayer.prevDistanceWalkedModified + (clientPlayer.distanceWalkedModified - clientPlayer.prevDistanceWalkedModified) * scale) * 6.0F) * 32.0F * f15; f12 += MathHelper.sin((clientPlayer.prevDistanceWalkedModified + (clientPlayer.distanceWalkedModified - clientPlayer.prevDistanceWalkedModified) * scale) * 6) * 32 * f15;
rotate(2.0F + f13 / 12.0F + f12, 1.0F, 0.0F, 0.0F); rotate(2 + f13 / 12 + f12, 1, 0, 0);
rotate(f14 / 2.0F, 0.0F, 0.0F, 1.0F); rotate(f14 / 2, 0, 0, 1);
rotate(-f14 / 2.0F, 0.0F, 1.0F, 0.0F); rotate(-f14 / 2, 0, 1, 0);
rotate(180.0F, 0.0F, 0.0F, 1.0F); rotate(180, 0, 0, 1);
rotate(90.0F, 1.0F, 0.0F, 0.0F); rotate(90, 1, 0, 0);
this.getRenderer().bindTexture(clientPlayer.getLocationCape()); this.getRenderer().bindTexture(clientPlayer.getLocationCape());
model.getModel().renderCape(0.0625F); model.getModel().renderCape(0.0625F);
popMatrix(); popMatrix();