From e118cb78a71b5463fd20ab1dacbcbfb894910b7f Mon Sep 17 00:00:00 2001 From: pahimar Date: Tue, 19 Mar 2013 12:15:09 -0400 Subject: [PATCH] Reverting back the version check mechanic I was trying out (different release streams), and some source code cleanup --- .../TileEntityAlchemicalChestRenderer.java | 3 +- .../configuration/ConfigurationSettings.java | 2 +- .../core/handlers/EntityLivingHandler.java | 10 ++-- .../ee3/core/helper/VersionHelper.java | 47 +++---------------- .../com/pahimar/ee3/item/ItemMiniumStone.java | 3 +- ee3_common/com/pahimar/ee3/lib/Reference.java | 1 - ee3_common/com/pahimar/ee3/lib/Strings.java | 2 - .../ee3/network/PacketTypeHandler.java | 9 ++-- .../minecraftforge/client/model/obj/Face.java | 31 ++++++------ .../client/model/obj/Group.java | 8 ++-- version.xml | 2 +- 11 files changed, 38 insertions(+), 80 deletions(-) diff --git a/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityAlchemicalChestRenderer.java b/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityAlchemicalChestRenderer.java index 790f3351..e16504cb 100644 --- a/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityAlchemicalChestRenderer.java +++ b/ee3_common/com/pahimar/ee3/client/renderer/tileentity/TileEntityAlchemicalChestRenderer.java @@ -25,8 +25,7 @@ import cpw.mods.fml.relauncher.SideOnly; * */ @SideOnly(Side.CLIENT) -public class TileEntityAlchemicalChestRenderer extends - TileEntitySpecialRenderer { +public class TileEntityAlchemicalChestRenderer extends TileEntitySpecialRenderer { private ModelChest modelChest = new ModelChest(); diff --git a/ee3_common/com/pahimar/ee3/configuration/ConfigurationSettings.java b/ee3_common/com/pahimar/ee3/configuration/ConfigurationSettings.java index 98a5bb66..e5f6bf28 100644 --- a/ee3_common/com/pahimar/ee3/configuration/ConfigurationSettings.java +++ b/ee3_common/com/pahimar/ee3/configuration/ConfigurationSettings.java @@ -23,7 +23,7 @@ public class ConfigurationSettings { public static String LAST_DISCOVERED_VERSION; public static final String LAST_DISCOVERED_VERSION_CONFIGNAME = "version_check.last_discovered_version"; public static final String LAST_DISCOVERED_VERSION_DEFAULT = ""; - + public static String LAST_DISCOVERED_VERSION_TYPE; public static final String LAST_DISCOVERED_VERSION_TYPE_CONFIGNAME = "version_check.last_discovered_version_type"; public static final String LAST_DISCOVERED_VERSION_TYPE_DEFAULT = ""; diff --git a/ee3_common/com/pahimar/ee3/core/handlers/EntityLivingHandler.java b/ee3_common/com/pahimar/ee3/core/handlers/EntityLivingHandler.java index 09a8fbf2..3c333750 100644 --- a/ee3_common/com/pahimar/ee3/core/handlers/EntityLivingHandler.java +++ b/ee3_common/com/pahimar/ee3/core/handlers/EntityLivingHandler.java @@ -29,11 +29,11 @@ public class EntityLivingHandler { if (event.source.getDamageType().equals("player")) { ItemDropHelper.dropMiniumShard((EntityPlayer) event.source.getSourceOfDamage(), event.entityLiving); - } - if (event.source.getSourceOfDamage() instanceof EntityArrow){ - if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity != null){ - if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity instanceof EntityPlayer){ - ItemDropHelper.dropMiniumShard((EntityPlayer) event.source.getSourceOfDamage(), event.entityLiving); + } + if (event.source.getSourceOfDamage() instanceof EntityArrow) { + if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity != null) { + if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity instanceof EntityPlayer) { + ItemDropHelper.dropMiniumShard((EntityPlayer) event.source.getSourceOfDamage(), event.entityLiving); } } } diff --git a/ee3_common/com/pahimar/ee3/core/helper/VersionHelper.java b/ee3_common/com/pahimar/ee3/core/helper/VersionHelper.java index aaae3e1e..7980f009 100644 --- a/ee3_common/com/pahimar/ee3/core/helper/VersionHelper.java +++ b/ee3_common/com/pahimar/ee3/core/helper/VersionHelper.java @@ -46,7 +46,6 @@ public class VersionHelper implements Runnable { private static byte result = UNINITIALIZED; public static String remoteVersion = null; public static String remoteUpdateLocation = null; - public static String remoteVersionType = null; /*** * Checks the version of the currently running instance of the mod against @@ -66,67 +65,33 @@ public class VersionHelper implements Runnable { String remoteVersionProperty = remoteVersionProperties.getProperty(Loader.instance().getMCVersionString()); if (remoteVersionProperty != null) { - String[] remoteVersionTokens = remoteVersionProperty.split("|"); + String[] remoteVersionTokens = remoteVersionProperty.split("\\|"); - if (remoteVersionTokens.length == 2) { + if (remoteVersionTokens.length >= 2) { remoteVersion = remoteVersionTokens[0]; remoteUpdateLocation = remoteVersionTokens[1]; } - else if (remoteVersionTokens.length == 3) { - remoteVersion = remoteVersionTokens[0]; - remoteUpdateLocation = remoteVersionTokens[1]; - remoteVersionType = remoteVersionTokens[2]; - } else { result = ERROR; - return; } if (remoteVersion != null) { if (!ConfigurationSettings.LAST_DISCOVERED_VERSION.equalsIgnoreCase(remoteVersion)) { ConfigurationHandler.set(Configuration.CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME, remoteVersion); - - if (remoteVersionType != null) { - ConfigurationHandler.set(Configuration.CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_CONFIGNAME, remoteVersionType); - } } - if (remoteVersion.equalsIgnoreCase(Reference.VERSION)) { - if (remoteVersionType != null) { - if (remoteVersionType.equalsIgnoreCase(Reference.VERSION_TYPE) && remoteVersionType.equalsIgnoreCase(Strings.RECOMMENDED_VERSION)) { - result = CURRENT; - return; - } - } - else { - result = CURRENT; - return; - } + if (remoteVersion.equals(Reference.VERSION)) { + result = CURRENT; } else { result = OUTDATED; - return; } } - else { - result = ERROR; - return; - } + } else { result = MC_VERSION_NOT_FOUND; } - - /* - * if (remoteVersion != null) { if - * (!ConfigurationSettings.LAST_DISCOVERED_VERSION - * .equalsIgnoreCase(remoteVersion)) { - * ConfigurationHandler.set(Configuration.CATEGORY_GENERAL, - * ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME, - * remoteVersion); } if (remoteVersion.equals(Reference.VERSION)) { - * result = CURRENT; return; } } if (remoteVersionProperty == null) - * { result = MC_VERSION_NOT_FOUND; } else { result = OUTDATED; } - */ } catch (Exception e) { } @@ -220,7 +185,7 @@ public class VersionHelper implements Runnable { LogHelper.log(Level.INFO, LanguageRegistry.instance().getStringLocalization(Strings.VERSION_CHECK_INIT_LOG_MESSAGE) + " " + REMOTE_VERSION_XML_FILE); try { - while (count < Reference.VERSION_CHECK_ATTEMPTS && (result == UNINITIALIZED || result == ERROR)) { + while (count < Reference.VERSION_CHECK_ATTEMPTS - 1 && (result == UNINITIALIZED || result == ERROR)) { checkVersion(); count++; diff --git a/ee3_common/com/pahimar/ee3/item/ItemMiniumStone.java b/ee3_common/com/pahimar/ee3/item/ItemMiniumStone.java index e3b73ed5..0d673733 100644 --- a/ee3_common/com/pahimar/ee3/item/ItemMiniumStone.java +++ b/ee3_common/com/pahimar/ee3/item/ItemMiniumStone.java @@ -25,8 +25,7 @@ import cpw.mods.fml.relauncher.SideOnly; * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) * */ -public class ItemMiniumStone extends ItemEE - implements ITransmutationStone, IKeyBound { +public class ItemMiniumStone extends ItemEE implements ITransmutationStone, IKeyBound { public ItemMiniumStone(int id) { diff --git a/ee3_common/com/pahimar/ee3/lib/Reference.java b/ee3_common/com/pahimar/ee3/lib/Reference.java index 581d4d09..2eab9bc3 100644 --- a/ee3_common/com/pahimar/ee3/lib/Reference.java +++ b/ee3_common/com/pahimar/ee3/lib/Reference.java @@ -18,7 +18,6 @@ public class Reference { public static final String MOD_ID = "EE3"; public static final String MOD_NAME = "Equivalent Exchange 3"; public static final String VERSION = "@VERSION@"; - public static final String VERSION_TYPE = "@VERSION_TYPE@"; public static final String CHANNEL_NAME = MOD_ID; public static final int SECOND_IN_TICKS = 20; public static final int SHIFTED_ID_RANGE_CORRECTION = 256; diff --git a/ee3_common/com/pahimar/ee3/lib/Strings.java b/ee3_common/com/pahimar/ee3/lib/Strings.java index 5624dd21..938e2350 100644 --- a/ee3_common/com/pahimar/ee3/lib/Strings.java +++ b/ee3_common/com/pahimar/ee3/lib/Strings.java @@ -23,8 +23,6 @@ public class Strings { public static final String GENERAL_ERROR_MESSAGE = "version.general_error"; public static final String FINAL_ERROR_MESSAGE = "version.final_error"; public static final String MC_VERSION_NOT_FOUND = "version.mc_version_not_found"; - public static final String DEVELOPMENT_VERSION = "Development"; - public static final String RECOMMENDED_VERSION = "Recommended"; /* NBT related constants */ public static final String NBT_ITEM_CHARGE_LEVEL_KEY = "itemChargeLevel"; diff --git a/ee3_common/com/pahimar/ee3/network/PacketTypeHandler.java b/ee3_common/com/pahimar/ee3/network/PacketTypeHandler.java index ada7d4a3..f4bc215a 100644 --- a/ee3_common/com/pahimar/ee3/network/PacketTypeHandler.java +++ b/ee3_common/com/pahimar/ee3/network/PacketTypeHandler.java @@ -25,12 +25,9 @@ import com.pahimar.ee3.network.packet.PacketTileUpdate; * */ public enum PacketTypeHandler { - KEY(PacketKeyPressed.class), - TILE(PacketTileUpdate.class), - REQUEST_EVENT(PacketRequestEvent.class), - SPAWN_PARTICLE(PacketSpawnParticle.class), - SOUND_EVENT(PacketSoundEvent.class), - ITEM_UPDATE(PacketItemUpdate.class); + KEY(PacketKeyPressed.class), TILE(PacketTileUpdate.class), REQUEST_EVENT( + PacketRequestEvent.class), SPAWN_PARTICLE(PacketSpawnParticle.class), SOUND_EVENT( + PacketSoundEvent.class), ITEM_UPDATE(PacketItemUpdate.class); private Class clazz; diff --git a/ee3_common/net/minecraftforge/client/model/obj/Face.java b/ee3_common/net/minecraftforge/client/model/obj/Face.java index 668ee5b6..6d9f7215 100644 --- a/ee3_common/net/minecraftforge/client/model/obj/Face.java +++ b/ee3_common/net/minecraftforge/client/model/obj/Face.java @@ -11,56 +11,57 @@ public class Face { public Vertex[] vertices; public Vertex[] vertexNormals; public TextureCoordinate[] textureCoordinates; - + public boolean invertNormal = false; public int glDrawingMode; - + public Vec3 getFaceNormal() { + Vec3 v1 = Vec3.createVectorHelper(vertices[1].x - vertices[0].x, vertices[1].y - vertices[0].y, vertices[1].z - vertices[0].z); Vec3 v2 = Vec3.createVectorHelper(vertices[2].x - vertices[0].x, vertices[2].y - vertices[0].y, vertices[2].z - vertices[0].z); - + return v1.crossProduct(v2).normalize(); } - + public void render(Tessellator tessellator, float scale) { this.render(tessellator, 0F, scale); } - + public void render(Tessellator tessellator, float textureOffset, float scale) { tessellator.startDrawing(glDrawingMode); - + tessellator.setNormal((float) getFaceNormal().xCoord, (float) getFaceNormal().yCoord, (float) getFaceNormal().zCoord); - + float averageU = 0F; float averageV = 0F; - + for (int i = 0; i < textureCoordinates.length; ++i) { averageU += textureCoordinates[i].u; averageV += textureCoordinates[i].v; } - + averageU = averageU / textureCoordinates.length; averageV = averageV / textureCoordinates.length; - + float offsetU, offsetV; - + for (int i = 0; i < vertices.length; ++i) { - + offsetU = textureOffset; offsetV = textureOffset; - + if (textureCoordinates[i].u > averageU) { offsetU = -offsetU; } if (textureCoordinates[i].v > averageV) { offsetV = -offsetV; } - + tessellator.addVertexWithUV(vertices[i].x * scale, vertices[i].y * scale, vertices[i].z * scale, textureCoordinates[i].u + offsetU, textureCoordinates[i].v + offsetV); } - + tessellator.draw(); } } diff --git a/ee3_common/net/minecraftforge/client/model/obj/Group.java b/ee3_common/net/minecraftforge/client/model/obj/Group.java index e49e8ba4..d77fa382 100644 --- a/ee3_common/net/minecraftforge/client/model/obj/Group.java +++ b/ee3_common/net/minecraftforge/client/model/obj/Group.java @@ -70,16 +70,16 @@ public class Group { return min; } - + public void render(Tessellator tessellator, float scale) { - + for (Face face : faces) { face.render(tessellator, 0F, scale); } } - + public void render(Tessellator tessellator, float textureOffset, float scale) { - + for (Face face : faces) { face.render(tessellator, textureOffset, scale); } diff --git a/version.xml b/version.xml index 99692e3a..754dd56a 100644 --- a/version.xml +++ b/version.xml @@ -7,5 +7,5 @@ pre1d|http://goo.gl/Ria2V pre1e|http://goo.gl/Ria2V pre1f|http://goo.gl/Ria2V - pre1g|http://goo.gl/Ria2V|Development + pre1g|http://goo.gl/Ria2V