From c8bdab408cd5eda356f682adee98f4c11d44499b Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Fri, 11 Dec 2015 23:17:04 -0500 Subject: [PATCH] Fix meta detection --- .../java/com/brohoof/minelittlepony/Pony.java | 50 +------------------ .../com/brohoof/minelittlepony/PonyData.java | 36 ++++++------- .../brohoof/minelittlepony/PonyManager.java | 2 +- .../renderer/layer/LayerPonyArmor.java | 31 +++++------- 4 files changed, 32 insertions(+), 87 deletions(-) diff --git a/src/main/java/com/brohoof/minelittlepony/Pony.java b/src/main/java/com/brohoof/minelittlepony/Pony.java index 9b8b73f3..04a4e02e 100644 --- a/src/main/java/com/brohoof/minelittlepony/Pony.java +++ b/src/main/java/com/brohoof/minelittlepony/Pony.java @@ -101,55 +101,7 @@ public class Pony { return false; } return player.capabilities.isFlying || !(player.onGround || player.isOnLadder() || player.isInWater()); - - //@formatter:off -// boolean falling = player.fallDistance > 0; -// boolean levitating = player.fallDistance == this.previousFallDistance; -// boolean standingOnAir; -// if (falling && !levitating) { -// standingOnAir = this.standingOnAir(posX, posY, posZ, 1.5F, equestria); -// } else { -// standingOnAir = this.standingOnAir(posX, posY, posZ, 1.0F, equestria); -// } -// -// if (!standingOnAir) { -// return pegasusFlying = false; -// } else if (this.pegasusFlying) { -// return true; -// } else if (levitating) { -// return pegasusFlying = true; -// } else { -// this.previousFallDistance = fallDistance; -// if (fallDistance < 2.0F) { -// return false; -// } -// return pegasusFlying = true; -// } - } - - -// public boolean standingOnAir(BlockPos pos, float range, World equestria) { -// boolean foundSolidBlock = false; -// int y; -// if (this.isSpPlayer) { -// y = MathHelper.floor_double(posY - this.defaultYOffset - 0.009999999776482582D); -// } else { -// y = MathHelper.floor_double(posY - 0.009999999776482582D); -// } -// -// for (float shiftX = 0.0F - range; shiftX < range * 2.0F; shiftX += range) { -// for (float shiftZ = 0.0F - range; shiftZ < range * 2.0F; shiftZ += range) { -// int x = MathHelper.floor_double(posX + shiftX); -// int z = MathHelper.floor_double(posZ + shiftZ); -// if (!equestria.isAirBlock(new BlockPos(x, y, z))) { -// foundSolidBlock = true; -// } -// } -// } -// -// return !foundSolidBlock; -// } - // @formatter:on + } public PlayerModel getModel() { return getModel(false); diff --git a/src/main/java/com/brohoof/minelittlepony/PonyData.java b/src/main/java/com/brohoof/minelittlepony/PonyData.java index f5919947..db77aecc 100644 --- a/src/main/java/com/brohoof/minelittlepony/PonyData.java +++ b/src/main/java/com/brohoof/minelittlepony/PonyData.java @@ -8,22 +8,22 @@ import com.google.common.collect.ImmutableBiMap; public class PonyData { private static final Map RACE_COLORS = ImmutableBiMap. builder() - .put(0xfff9b131, PonyRace.EARTH) - .put(0xffd19fe4, PonyRace.UNICORN) - .put(0xff88caf0, PonyRace.PEGASUS) - .put(0xfffef9fc, PonyRace.ALICORN) - .put(0xffd0cccf, PonyRace.ZEBRA) - .put(0xff282b29, PonyRace.CHANGELING) + .put(0xf9b131, PonyRace.EARTH) + .put(0xd19fe4, PonyRace.UNICORN) + .put(0x88caf0, PonyRace.PEGASUS) + .put(0xfef9fc, PonyRace.ALICORN) + .put(0xd0cccf, PonyRace.ZEBRA) + .put(0x282b29, PonyRace.CHANGELING) .build(); private static final Map TAIL_COLORS = ImmutableBiMap. builder() - .put(0xff425844, TailLengths.STUB) - .put(0xffd19fe4, TailLengths.QUARTER) - .put(0xff534b76, TailLengths.HALF) - .put(0xff8a6b7f, TailLengths.THREE_QUARTERS).build(); + .put(0x425844, TailLengths.STUB) + .put(0xd19fe4, TailLengths.QUARTER) + .put(0x534b76, TailLengths.HALF) + .put(0x8a6b7f, TailLengths.THREE_QUARTERS).build(); private static final Map SIZE_COLORS = ImmutableBiMap. builder() - .put(0xffffbe53, PonySize.FOAL) - .put(0xffce3254, PonySize.LARGE) - .put(0xff534b76, PonySize.PRINCESS) + .put(0xffbe53, PonySize.FOAL) + .put(0xce3254, PonySize.LARGE) + .put(0x534b76, PonySize.PRINCESS) .build(); private PonyRace race = PonyRace.EARTH; @@ -114,10 +114,10 @@ public class PonyData { private enum TriggerPixels { RACE(0, 0), - TAIL(0, 1), - GENDER(0, 2), - SIZE(0, 3), - GLOW(1, 0); + TAIL(1, 0), + GENDER(2, 0), + SIZE(3, 0), + GLOW(0, 1); private int x, y; @@ -127,7 +127,7 @@ public class PonyData { } private int readColor(BufferedImage image) { - return image.getRGB(x, y); + return image.getRGB(x, y) & 0xffffff; } } } diff --git a/src/main/java/com/brohoof/minelittlepony/PonyManager.java b/src/main/java/com/brohoof/minelittlepony/PonyManager.java index 104cd49d..227765ec 100644 --- a/src/main/java/com/brohoof/minelittlepony/PonyManager.java +++ b/src/main/java/com/brohoof/minelittlepony/PonyManager.java @@ -107,7 +107,7 @@ public class PonyManager { private ResourceLocation getBackgroundPonyResource(AbstractClientPlayer player) { if (getNumberOfPonies() > 0) { - int backgroundIndex = player.getEntityId() % this.getNumberOfPonies(); + int backgroundIndex = player.getUniqueID().hashCode() % this.getNumberOfPonies(); if (backgroundIndex < 0) { backgroundIndex += this.getNumberOfPonies(); } diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyArmor.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyArmor.java index 12a7d976..3f4ca4da 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyArmor.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyArmor.java @@ -27,8 +27,7 @@ import net.minecraft.util.ResourceLocation; public class LayerPonyArmor implements LayerRenderer { - private static final ResourceLocation ENCHANTED_ITEM_GLINT_RES = new ResourceLocation( - "textures/misc/enchanted_item_glint.png"); + private static final ResourceLocation ENCHANTED_ITEM_GLINT_RES = new ResourceLocation("textures/misc/enchanted_item_glint.png"); private static final Map HUMAN_ARMORS = Maps.newHashMap(); private static final Map PONY_ARMORS = Maps.newHashMap(); @@ -43,12 +42,11 @@ public class LayerPonyArmor implements LayerRenderer { } @Override - public void doRenderLayer(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, float ticks, - float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { + public void doRenderLayer(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, float ticks, float p_177141_5_, float p_177141_6_, + float p_177141_7_, float scale) { pony = ((IRenderPony) renderer).getPony(); if (pony.getModel() instanceof pm_Human) { - humanArmor.doRenderLayer(entity, p_177141_2_, p_177141_3_, ticks, p_177141_5_, p_177141_6_, p_177141_7_, - scale); + humanArmor.doRenderLayer(entity, p_177141_2_, p_177141_3_, ticks, p_177141_5_, p_177141_6_, p_177141_7_, scale); } else { for (int i = 4; i > 0; i--) { renderArmor(entity, p_177141_2_, p_177141_3_, ticks, p_177141_5_, p_177141_6_, p_177141_7_, scale, i); @@ -56,8 +54,8 @@ public class LayerPonyArmor implements LayerRenderer { } } - private void renderArmor(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, - float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, int armorSlot) { + private void renderArmor(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, + float p_177141_6_, float p_177141_7_, float scale, int armorSlot) { ItemStack itemstack = entitylivingbaseIn.getCurrentArmor(armorSlot - 1); if (itemstack != null && itemstack.getItem() instanceof ItemArmor) { @@ -77,17 +75,14 @@ public class LayerPonyArmor implements LayerRenderer { float f8 = (j >> 8 & 255) / 255.0F; float f9 = (j & 255) / 255.0F; GlStateManager.color(f7, f8, f9, 1); - modelbase.render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_, - scale); + modelbase.render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_, scale); this.renderer.bindTexture(getArmorTexture(entitylivingbaseIn, itemstack, isLegs ? 2 : 1, "overlay")); } GlStateManager.color(1, 1, 1, 1); - modelbase.render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_, - scale); + modelbase.render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_, scale); if (itemstack.isItemEnchanted()) { - this.renderEnchantment(entitylivingbaseIn, modelbase, p_177141_2_, p_177141_3_, partialTicks, - p_177141_5_, p_177141_6_, p_177141_7_, scale); + this.renderEnchantment(entitylivingbaseIn, modelbase, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_, p_177141_7_, scale); } } } @@ -156,9 +151,8 @@ public class LayerPonyArmor implements LayerRenderer { } } - private void renderEnchantment(EntityLivingBase entitylivingbaseIn, ModelBase modelbaseIn, float p_177183_3_, - float p_177183_4_, float p_177183_5_, float p_177183_6_, float p_177183_7_, float p_177183_8_, - float p_177183_9_) { + private void renderEnchantment(EntityLivingBase entitylivingbaseIn, ModelBase modelbaseIn, float p_177183_3_, float p_177183_4_, float p_177183_5_, + float p_177183_6_, float p_177183_7_, float p_177183_8_, float p_177183_9_) { float f7 = entitylivingbaseIn.ticksExisted + p_177183_5_; this.renderer.bindTexture(ENCHANTED_ITEM_GLINT_RES); GlStateManager.enableBlend(); @@ -179,8 +173,7 @@ public class LayerPonyArmor implements LayerRenderer { GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(0.0F, f7 * (0.001F + i * 0.003F) * 20.0F, 0.0F); GlStateManager.matrixMode(5888); - modelbaseIn.render(entitylivingbaseIn, p_177183_3_, p_177183_4_, p_177183_6_, p_177183_7_, p_177183_8_, - p_177183_9_); + modelbaseIn.render(entitylivingbaseIn, p_177183_3_, p_177183_4_, p_177183_6_, p_177183_7_, p_177183_8_, p_177183_9_); } GlStateManager.matrixMode(5890);