diff --git a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java index 8d589ae2..56fbc60a 100644 --- a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java +++ b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java @@ -51,6 +51,7 @@ public class EquivalentExchange3 public static CreativeTabs tabsEE3 = new CreativeTabEE3(CreativeTabs.getNextID(), Reference.MOD_ID); @EventHandler + @SuppressWarnings("unused") public void invalidFingerprint(FMLFingerprintViolationEvent event) { // Report (log) to the user that the version of Equivalent Exchange 3 @@ -66,6 +67,7 @@ public class EquivalentExchange3 } @EventHandler + @SuppressWarnings("unused") public void serverStarting(FMLServerStartingEvent event) { // Initialize the custom commands @@ -73,6 +75,7 @@ public class EquivalentExchange3 } @EventHandler + @SuppressWarnings("unused") public void preInit(FMLPreInitializationEvent event) { // set version number @@ -110,7 +113,7 @@ public class EquivalentExchange3 } @EventHandler - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked, unused") public void init(FMLInitializationEvent event) { // Register the GUI Handler @@ -155,12 +158,14 @@ public class EquivalentExchange3 } @EventHandler + @SuppressWarnings("unused") public void postInit(FMLPostInitializationEvent event) { // NOOP } @EventHandler + @SuppressWarnings("unused") public void handleIMCMessages(IMCEvent event) { InterModCommsHandler.processIMCMessages(event); diff --git a/src/main/java/com/pahimar/ee3/addon/AddonEquivalentExchange3.java b/src/main/java/com/pahimar/ee3/addon/AddonEquivalentExchange3.java index d4d214c6..6df756aa 100644 --- a/src/main/java/com/pahimar/ee3/addon/AddonEquivalentExchange3.java +++ b/src/main/java/com/pahimar/ee3/addon/AddonEquivalentExchange3.java @@ -1,7 +1,6 @@ package com.pahimar.ee3.addon; import com.pahimar.ee3.block.ModBlocks; -import com.pahimar.ee3.item.ItemAlchemicalDust; import com.pahimar.ee3.item.ModItems; import net.minecraft.item.ItemStack; @@ -24,17 +23,11 @@ public class AddonEquivalentExchange3 private static void addPreAssignmentEmcValues() { - /** - * Alchemical Dust - */ - for (int meta = 0; meta < ItemAlchemicalDust.DEFAULT_EMC_VALUES.length; meta++) - { - AddonHandler.sendPreValueAssignment(new ItemStack(ModItems.alchemicalDust, 1, meta), ItemAlchemicalDust.DEFAULT_EMC_VALUES[meta]); - } + // NOOP } private static void addPostAssignmentEmcValues() { - + // NOOP } } diff --git a/src/main/java/com/pahimar/ee3/client/helper/ColourUtils.java b/src/main/java/com/pahimar/ee3/client/helper/ColourUtils.java new file mode 100644 index 00000000..f723d3dc --- /dev/null +++ b/src/main/java/com/pahimar/ee3/client/helper/ColourUtils.java @@ -0,0 +1,171 @@ +package com.pahimar.ee3.client.helper; + +import java.util.regex.Pattern; + +public class ColourUtils +{ + private static final Pattern HEX_COLOUR_PATTERN = Pattern.compile("[0-9a-fA-F]{6}"); + + @SuppressWarnings("unused") + public static byte[] convertHexColorToByteArray(String hexColor) + { + if (HEX_COLOUR_PATTERN.matcher(hexColor).matches()) + { + byte[] colourByteArray = new byte[3]; + + colourByteArray[0] = (byte) Integer.parseInt(hexColor.substring(0, 2), 16); + colourByteArray[1] = (byte) Integer.parseInt(hexColor.substring(2, 4), 16); + colourByteArray[2] = (byte) Integer.parseInt(hexColor.substring(4, 6), 16); + + return colourByteArray; + } + + return null; + } + + public static byte[] convertIntColourToByteArray(int intColour) + { + byte[] colourByteArray = new byte[3]; + + colourByteArray[0] = (byte) (intColour >> 16 & 255); + colourByteArray[1] = (byte) (intColour >> 8 & 255); + colourByteArray[2] = (byte) (intColour & 255); + + return colourByteArray; + } + + public static float[] convertIntColourToFloatArray(int intColour) + { + float[] colourFloatArray = new float[3]; + + colourFloatArray[0] = (float) (intColour >> 16 & 255) / 255F; + colourFloatArray[1] = (float) (intColour >> 8 & 255) / 255F; + colourFloatArray[2] = (float) (intColour & 255) / 255F; + + return colourFloatArray; + } + + @SuppressWarnings("unused") + public static byte[] getBlendedColours(String firstColour, String secondColour) + { + byte[] firstColourByteArray = convertHexColorToByteArray(firstColour); + byte[] secondColourByteArray = convertHexColorToByteArray(secondColour); + + if (firstColourByteArray != null && secondColourByteArray != null) + { + return getBlendedColours(firstColourByteArray, secondColourByteArray); + } + else + { + return null; + } + } + + @SuppressWarnings("unused") + public static byte[] getBlendedColours(byte[] firstColour, byte[] secondColour) + { + byte[][] blendedColours = getByteBlendedColours(firstColour, secondColour, 3); + + if (blendedColours.length == 3) + { + return blendedColours[1]; + } + else + { + return null; + } + } + + public static byte[][] getByteBlendedColours(String firstColour, String secondColour, int steps) + { + byte[] firstColourByteArray = convertHexColorToByteArray(firstColour); + byte[] secondColourByteArray = convertHexColorToByteArray(secondColour); + + if (firstColourByteArray != null && secondColourByteArray != null) + { + return getByteBlendedColours(firstColourByteArray, secondColourByteArray, steps); + } + else + { + return null; + } + } + + public static byte[][] getByteBlendedColours(byte[] firstColour, byte[] secondColour, int steps) + { + if (firstColour.length == 3 && secondColour.length == 3 && steps > 0) + { + byte[][] blendedColours = new byte[steps + 2][3]; + + byte redDifference = (byte) (((secondColour[0] & 0xFF) - (firstColour[0] & 0xFF)) / steps); + byte greenDifference = (byte) (((secondColour[1] & 0xFF) - (firstColour[1] & 0xFF)) / steps); + byte blueDifference = (byte) (((secondColour[2] & 0xFF) - (firstColour[2] & 0xFF)) / steps); + + blendedColours[0] = firstColour; + for (int i = 1; i < blendedColours.length - 1; i++) + { + blendedColours[i][0] = (byte) (firstColour[0] + i * redDifference); + blendedColours[i][1] = (byte) (firstColour[1] + i * greenDifference); + blendedColours[i][2] = (byte) (firstColour[2] + i * blueDifference); + } + blendedColours[blendedColours.length - 1] = secondColour; + + return blendedColours; + } + + return null; + } + + public static float[][] getFloatBlendedColours(byte[] firstColour, byte[] secondColour, int steps) + { + byte[][] byteBlendedColours = getByteBlendedColours(firstColour, secondColour, steps); + + if (byteBlendedColours != null) + { + float[][] floatBlendedColours = new float[byteBlendedColours.length][3]; + + for (int i = 0; i < byteBlendedColours.length; i++) + { + floatBlendedColours[i][0] = (byteBlendedColours[i][0] & 0xFF) / 255F; + floatBlendedColours[i][1] = (byteBlendedColours[i][1] & 0xFF) / 255F; + floatBlendedColours[i][2] = (byteBlendedColours[i][2] & 0xFF) / 255F; + } + + return floatBlendedColours; + } + else + { + return null; + } + } + + public static float[][] getFloatBlendedColours(String firstColour, String secondColour, int steps) + { + byte[] firstColourByteArray = convertHexColorToByteArray(firstColour); + byte[] secondColourByteArray = convertHexColorToByteArray(secondColour); + + if (firstColourByteArray != null && secondColourByteArray != null) + { + return getFloatBlendedColours(firstColourByteArray, secondColourByteArray, steps); + } + else + { + return null; + } + } + + public static float[][] getFloatBlendedColours(int firstColour, int secondColour, int steps) + { + byte[] firstColourByteArray = convertIntColourToByteArray(firstColour); + byte[] secondColourByteArray = convertIntColourToByteArray(secondColour); + + if (firstColourByteArray != null && secondColourByteArray != null) + { + return getFloatBlendedColours(firstColourByteArray, secondColourByteArray, steps); + } + else + { + return null; + } + } +} diff --git a/src/main/java/com/pahimar/ee3/client/renderer/RenderUtils.java b/src/main/java/com/pahimar/ee3/client/renderer/RenderUtils.java index 9719fab2..7094d041 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/RenderUtils.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/RenderUtils.java @@ -18,14 +18,13 @@ import org.lwjgl.opengl.GL11; * * @author pahimar */ +//@SideOnly(Side.CLIENT) public class RenderUtils { - private static int rotationAngle = 0; public static void renderRotatingBlockIntoGUI(FontRenderer fontRenderer, ItemStack stack, int x, int y, float zLevel, float scale) { - RenderBlocks renderBlocks = new RenderBlocks(); Block block = Block.blocksList[stack.itemID]; @@ -55,7 +54,6 @@ public class RenderUtils public static void renderItemIntoGUI(FontRenderer fontRenderer, ItemStack itemStack, int x, int y, float opacity, float scale) { - Icon icon = itemStack.getIconIndex(); GL11.glDisable(GL11.GL_LIGHTING); FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.VANILLA_ITEM_TEXTURE_SHEET); @@ -70,7 +68,6 @@ public class RenderUtils public static void drawTexturedQuad(int x, int y, Icon icon, float width, float height, double zLevel) { - Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(x, y + height, zLevel, icon.getMinU(), icon.getMaxV()); diff --git a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityCalcinatorRenderer.java b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityCalcinatorRenderer.java index 4232af92..77338b44 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityCalcinatorRenderer.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityCalcinatorRenderer.java @@ -20,6 +20,8 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer { + // TODO Show the firepot as being "lit" + // TODO Packet for display dust size/colour and calcinator state private ModelCalcinator modelCalcinator = new ModelCalcinator(); @@ -53,8 +55,8 @@ public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer GL11.glRotatef(90F, 1F, 0F, 0F); GL11.glRotatef(-45F, 0F, 1F, 0F); - // TODO Handle colouring the dusts as per their meta in the calcinator inventory - GL11.glColor3b((byte) 32, (byte) 128, (byte) 192); + float[] dustColour = tileCalcinator.getBlendedDustColour(); + GL11.glColor4f(dustColour[0], dustColour[1], dustColour[2], 1F); if (tileCalcinator.getCombinedOutputSize() <= 32) { diff --git a/src/main/java/com/pahimar/ee3/emc/EmcValuesDefault.java b/src/main/java/com/pahimar/ee3/emc/EmcValuesDefault.java index f637531f..8e7b049b 100644 --- a/src/main/java/com/pahimar/ee3/emc/EmcValuesDefault.java +++ b/src/main/java/com/pahimar/ee3/emc/EmcValuesDefault.java @@ -15,7 +15,6 @@ import java.util.Map; public class EmcValuesDefault { - private static EmcValuesDefault emcDefaultValues = null; private Map valueMap; @@ -64,9 +63,6 @@ public class EmcValuesDefault valueMap.put(new WrappedStack(FluidRegistry.LAVA), new EmcValue(64, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 4), new EmcComponent(EmcType.AMORPHOUS, 1)))); valueMap.put(new WrappedStack(FluidRegistry.getFluid("milk")), new EmcValue(64, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 3), new EmcComponent(EmcType.AMORPHOUS, 1)))); -// valueMap.put(new WrappedStack(Block.waterStill), new EmcValue(0.1f, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 1), new EmcComponent(EmcType.AMORPHOUS, 1)))); -// valueMap.put(new WrappedStack(Block.lavaStill), new EmcValue(64, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 4), new EmcComponent(EmcType.AMORPHOUS, 1)))); - /* Building Blocks */ valueMap.put(new WrappedStack(Block.stone), new EmcValue(1)); valueMap.put(new WrappedStack(Block.grass), new EmcValue(1, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 9), new EmcComponent(EmcType.ESSENTIA, 1)))); @@ -189,12 +185,10 @@ public class EmcValuesDefault valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 2)), new EmcValue(2048)); valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 3)), new EmcValue(8192)); valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 4)), new EmcValue(73728)); - valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 5)), new EmcValue(4718592)); } public static Map getDefaultValueMap() { - lazyInit(); return emcDefaultValues.valueMap; } diff --git a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalDust.java b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalDust.java index a22524a4..30f1f780 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalDust.java +++ b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalDust.java @@ -1,15 +1,13 @@ package com.pahimar.ee3.item; import com.pahimar.ee3.EquivalentExchange3; -import com.pahimar.ee3.emc.EmcValue; +import com.pahimar.ee3.lib.Colours; import com.pahimar.ee3.lib.Strings; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import java.util.ArrayList; @@ -24,53 +22,56 @@ import java.util.List; */ public class ItemAlchemicalDust extends ItemEE { - public static final EmcValue[] DEFAULT_EMC_VALUES = { - new EmcValue(1), - new EmcValue(64), - new EmcValue(2048), - new EmcValue(8192), - new EmcValue(4718592) - }; - - @SideOnly(Side.CLIENT) - private Icon[] icons; - public ItemAlchemicalDust(int id) { super(id); this.setHasSubtypes(true); + this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_DUST_NAME); this.setCreativeTab(EquivalentExchange3.tabsEE3); maxStackSize = 64; } + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack itemStack, int renderPass) + { + if (itemStack.getItemDamage() == 0) + { + return Integer.parseInt(Colours.DUST_ASH, 16); + } + else if (itemStack.getItemDamage() == 1) + { + return Integer.parseInt(Colours.DUST_VERDANT, 16); + } + else if (itemStack.getItemDamage() == 2) + { + return Integer.parseInt(Colours.DUST_AZURE, 16); + } + else if (itemStack.getItemDamage() == 3) + { + return Integer.parseInt(Colours.DUST_MINIUM, 16); + } + else if (itemStack.getItemDamage() == 4) + { + return Integer.parseInt(Colours.DUST_IRIDESCENT, 16); + } + + return Integer.parseInt(Colours.PURE_WHITE, 16); + } + @Override public String getUnlocalizedName(ItemStack itemStack) { return String.format("item.%s%s.%s", Strings.RESOURCE_PREFIX, Strings.ALCHEMICAL_DUST_NAME, Strings.ALCHEMICAL_DUST_SUBTYPE_NAMES[MathHelper.clamp_int(itemStack.getItemDamage(), 0, Strings.ALCHEMICAL_DUST_SUBTYPE_NAMES.length - 1)]); } - @Override - @SideOnly(Side.CLIENT) - /** - * Gets an icon index based on an item's damage value - */ - public Icon getIconFromDamage(int meta) - { - return icons[MathHelper.clamp_int(meta, 0, Strings.ALCHEMICAL_DUST_SUBTYPE_NAMES.length - 1)]; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) - { - icons = new Icon[Strings.ALCHEMICAL_DUST_SUBTYPE_NAMES.length]; - - for (int i = 0; i < Strings.ALCHEMICAL_DUST_SUBTYPE_NAMES.length; ++i) - { - icons[i] = iconRegister.registerIcon(String.format("%s%s.%s", Strings.RESOURCE_PREFIX, Strings.ALCHEMICAL_DUST_NAME, Strings.ALCHEMICAL_DUST_SUBTYPE_NAMES[i])); - } - } - @Override @SideOnly(Side.CLIENT) public boolean hasEffect(ItemStack stack, int renderPass) diff --git a/src/main/java/com/pahimar/ee3/lib/Colours.java b/src/main/java/com/pahimar/ee3/lib/Colours.java index 972b29f2..7bfd795f 100644 --- a/src/main/java/com/pahimar/ee3/lib/Colours.java +++ b/src/main/java/com/pahimar/ee3/lib/Colours.java @@ -12,6 +12,12 @@ public class Colours public static final String PURE_WHITE = "ffffff"; + public static final String DUST_ASH = "A0A0A0"; + public static final String DUST_VERDANT = "45CC39"; + public static final String DUST_AZURE = "35A6DE"; + public static final String DUST_MINIUM = "FF4545"; + public static final String DUST_IRIDESCENT = "FFF459"; + /* Text colour related constants */ public static final String TEXT_COLOUR_PREFIX_YELLOW = "\u00a7e"; public static final String TEXT_COLOUR_PREFIX_WHITE = "\u00a7f"; diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileCalcinator.java b/src/main/java/com/pahimar/ee3/tileentity/TileCalcinator.java index f132fe93..c0891162 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileCalcinator.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileCalcinator.java @@ -1,5 +1,6 @@ package com.pahimar.ee3.tileentity; +import com.pahimar.ee3.client.helper.ColourUtils; import com.pahimar.ee3.lib.Strings; import com.pahimar.ee3.recipe.CalcinationManager; import cpw.mods.fml.relauncher.Side; @@ -349,13 +350,6 @@ public class TileCalcinator extends TileEE implements IInventory } } - @Override - // TODO This is not an ideal toString - public String toString() - { - return super.toString(); - } - public int getCombinedOutputSize() { int result = 0; @@ -372,4 +366,33 @@ public class TileCalcinator extends TileEE implements IInventory return result; } + + @SideOnly(Side.CLIENT) + public float[] getBlendedDustColour() + { + if (inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null && inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null) + { + int leftStackColour = inventory[OUTPUT_LEFT_INVENTORY_INDEX].getItem().getColorFromItemStack(inventory[OUTPUT_LEFT_INVENTORY_INDEX], 1); + int rightStackColour = inventory[OUTPUT_RIGHT_INVENTORY_INDEX].getItem().getColorFromItemStack(inventory[OUTPUT_RIGHT_INVENTORY_INDEX], 1); + + int stackSizeStepRange = 8; + int leftStackSize = inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize / stackSizeStepRange; + int rightStackSize = inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize / stackSizeStepRange; + float[][] blendedColours = ColourUtils.getFloatBlendedColours(leftStackColour, rightStackColour, 2 * stackSizeStepRange - 1); + + return blendedColours[stackSizeStepRange + (leftStackSize - rightStackSize)]; + } + else if (inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null) + { + return ColourUtils.convertIntColourToFloatArray(inventory[OUTPUT_LEFT_INVENTORY_INDEX].getItem().getColorFromItemStack(inventory[OUTPUT_LEFT_INVENTORY_INDEX], 1)); + } + else if (inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null) + { + return ColourUtils.convertIntColourToFloatArray(inventory[OUTPUT_RIGHT_INVENTORY_INDEX].getItem().getColorFromItemStack(inventory[OUTPUT_RIGHT_INVENTORY_INDEX], 1)); + } + else + { + return new float[]{1F, 1F, 1F}; + } + } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEE.java b/src/main/java/com/pahimar/ee3/tileentity/TileEE.java index 9a28e29e..2bb7db6e 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEE.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEE.java @@ -124,6 +124,6 @@ public class TileEE extends TileEntity @Override public String toString() { - return String.format("TileEE Data - xCoord: %d, yCoord: %d, zCoord: %d, customName: '%s', orientation: %s, state: %d\n", xCoord, yCoord, zCoord, customName, orientation, state); + return String.format("TileEE Data - Class: %s, xCoord: %d, yCoord: %d, zCoord: %d, customName: '%s', orientation: %s, state: %d\n", this.getClass().getSimpleName(), xCoord, yCoord, zCoord, customName, orientation, state); } } diff --git a/src/main/resources/assets/ee3/textures/items/alchemicalDust.Ash.png b/src/main/resources/assets/ee3/textures/items/alchemicalDust.Ash.png deleted file mode 100644 index 2ef83eec..00000000 Binary files a/src/main/resources/assets/ee3/textures/items/alchemicalDust.Ash.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/items/alchemicalDust.Azure.png b/src/main/resources/assets/ee3/textures/items/alchemicalDust.Azure.png deleted file mode 100644 index de365c34..00000000 Binary files a/src/main/resources/assets/ee3/textures/items/alchemicalDust.Azure.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/items/alchemicalDust.Iridescent.png b/src/main/resources/assets/ee3/textures/items/alchemicalDust.Iridescent.png deleted file mode 100644 index f6c0252a..00000000 Binary files a/src/main/resources/assets/ee3/textures/items/alchemicalDust.Iridescent.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/items/alchemicalDust.Minium.png b/src/main/resources/assets/ee3/textures/items/alchemicalDust.Minium.png deleted file mode 100644 index fcdd69d5..00000000 Binary files a/src/main/resources/assets/ee3/textures/items/alchemicalDust.Minium.png and /dev/null differ diff --git a/src/main/resources/assets/ee3/textures/items/alchemicalDust.Verdant.png b/src/main/resources/assets/ee3/textures/items/alchemicalDust.Verdant.png deleted file mode 100644 index 6ed51837..00000000 Binary files a/src/main/resources/assets/ee3/textures/items/alchemicalDust.Verdant.png and /dev/null differ