diff options
Diffstat (limited to 'java/darkknight/jewelrycraft/block/BlockMoltenMetal.java')
| -rw-r--r-- | java/darkknight/jewelrycraft/block/BlockMoltenMetal.java | 63 |
1 files changed, 11 insertions, 52 deletions
diff --git a/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java b/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java index f005e04..da3c5c1 100644 --- a/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java +++ b/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java @@ -2,6 +2,12 @@ package darkknight.jewelrycraft.block; import java.awt.image.BufferedImage; import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.Random; import javax.imageio.ImageIO; @@ -221,17 +227,13 @@ public class BlockMoltenMetal extends BlockFluidClassic world.setBlock(x, y, z, this, meta, 3); JewelrycraftMod.saveData.setString(stringFromLocation(x, y, z, world.provider.dimensionId), originData); String[] data = originData.split(":"); - JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Integer.parseInt(data[0]), Integer.parseInt(data[1]))); + JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Integer.parseInt(data[0]), Integer.parseInt(data[1]), Integer.parseInt(data[2]))); } } @SideOnly(Side.CLIENT) public static int color(IBlockAccess world, int i, int j, int k, boolean forcecolor, Item itemC) throws IOException { - String domain = "", texture; - IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - BufferedImage icon; - ItemStack item = new ItemStack(BlockList.moltenMetal); String ingotData = JewelrycraftMod.clientData.getString(String.valueOf(i) + " " + String.valueOf(j) + " " + String.valueOf(k) + " " + Minecraft.getMinecraft().theWorld.provider.dimensionId); if (ingotData == "") { @@ -241,14 +243,15 @@ public class BlockMoltenMetal extends BlockFluidClassic else { String[] splitData = ingotData.split(":"); - if (splitData.length == 2) + if (splitData.length == 3) { - int itemID, itemDamage; + int itemID, itemDamage, color; try { itemID = Integer.parseInt(splitData[0]); itemDamage = Integer.parseInt(splitData[1]); - JewelryNBT.addMetal(item, new ItemStack(Item.getItemById(itemID), 1, itemDamage)); + color = Integer.parseInt(splitData[2]); + return color; } catch (Exception e) { @@ -256,53 +259,9 @@ public class BlockMoltenMetal extends BlockFluidClassic } } } - if (forcecolor) JewelryNBT.addMetal(item, new ItemStack(itemC)); - int x = 0, y = 0, ok = 0, red, green, blue; - if (item != null && JewelryNBT.ingot(item) != null && JewelryNBT.ingot(item).getIconIndex() != null && JewelryNBT.ingotColor(item) == 16777215) - { - IIcon itemIcon = JewelryNBT.ingot(item).getItem().getIcon(JewelryNBT.ingot(item), 0); - String ingotIconName = itemIcon.getIconName(); - - if (ingotIconName.substring(0, ingotIconName.indexOf(":") + 1) != "") domain = ingotIconName.substring(0, ingotIconName.indexOf(":") + 1).replace(":", " ").trim(); - else domain = "minecraft"; - - texture = ingotIconName.substring(ingotIconName.lastIndexOf(":") + 1) + ".png"; - ResourceLocation ingot = null; - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - - if (texturemanager.getResourceLocation(JewelryNBT.ingot(item).getItemSpriteNumber()).toString().contains("items")) ingot = new ResourceLocation(domain.toLowerCase(), "textures/items/" + texture); - else ingot = new ResourceLocation(domain.toLowerCase(), "textures/blocks/" + texture); - - icon = ImageIO.read(rm.getResource(ingot).getInputStream()); - while (ok == 0) - { - red = (icon.getRGB(x, y) >> 16) & 0xFF; - green = (icon.getRGB(x, y) >> 8) & 0xFF; - blue = icon.getRGB(x, y) & 0xFF; - if (!isColorPretty(red, green, blue)) - { - if (x < icon.getTileWidth() - 1) x++; - if (x >= icon.getTileWidth() - 1 && y < icon.getTileWidth() - 1) - { - x = 0; - y++; - } - if (x == icon.getTileWidth() - 1 && y == icon.getTileWidth() - 1) ok = 1; - } - else ok = 1; - } - JewelryNBT.addIngotColor(item, icon.getRGB(x, y)); - } - if (JewelryNBT.ingot(item) != null) return JewelryNBT.ingotColor(item); return 16777215; } - public static boolean isColorPretty(int r, int g, int b) - { - if ((r >= 100 && g >= 100 && b >= 100 && r < 200 && b < 200 && g < 200) || ((r >= 100 && (g < 100 || b < 100)) || (g >= 100 && (r < 100 || b < 100)) || (b >= 100 && (g < 100 || r < 100)))) return true; - else return false; - } - public static String stringFromLocation(int x, int y, int z, int dimID) { return x + " " + y + " " + z + " " + dimID; |
