Advertisement
Guest User

Untitled

a guest
Sep 12th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. package com.blueraven.magicmod.item;
  2.  
  3. import com.blueraven.magicmod.tileentity.TileEntityPylon;
  4. import cpw.mods.fml.relauncher.Side;
  5. import cpw.mods.fml.relauncher.SideOnly;
  6. import net.minecraft.entity.Entity;
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.nbt.NBTTagCompound;
  10. import net.minecraft.network.NetworkManager;
  11. import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
  12. import net.minecraft.util.EnumChatFormatting;
  13. import net.minecraft.world.World;
  14.  
  15. import java.awt.*;
  16. import java.util.List;
  17.  
  18. public class ItemColorCrystal extends ItemBase
  19. {
  20. public ItemColorCrystal()
  21. {
  22. super();
  23. this.setUnlocalizedName("colorCrystal");
  24. //this.setTextureName = "colorcrystal";
  25. }
  26.  
  27. @Override
  28. @SideOnly(Side.CLIENT)
  29. public int getColorFromItemStack(ItemStack stack, int renderPass)
  30. {
  31. //if (!(stack.stackTagCompound.getInteger("colorHEX") == 0))
  32. {
  33. int red = stack.stackTagCompound.getInteger("colorRed");
  34. int green = stack.stackTagCompound.getInteger("colorGreen");
  35. int blue = stack.stackTagCompound.getInteger("colorBlue");
  36. Color c = new Color(red, green, blue);
  37. return c.getRGB();
  38. }
  39. //else return Integer.parseInt("ffffff", 16);
  40. }
  41.  
  42. @Override
  43. public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
  44. {
  45. TileEntityPylon tePylon = (TileEntityPylon) world.getTileEntity(x, y, z);
  46.  
  47. if (world.getTileEntity(x, y, z) instanceof TileEntityPylon)
  48. {
  49. stack.stackTagCompound.setInteger("colorRed", tePylon.red);
  50. stack.stackTagCompound.setInteger("colorGreen", tePylon.green);
  51. stack.stackTagCompound.setInteger("colorBlue", tePylon.blue);
  52. return true;
  53. }
  54. return false;
  55. }
  56.  
  57. public void onUpdate(ItemStack stack, World world, Entity entity, int par1, boolean b)
  58. {
  59. /*if (stack.stackTagCompound == null)
  60. {
  61. stack.stackTagCompound = new NBTTagCompound();
  62. }
  63. if (world.isRemote)
  64. {
  65. stack.stackTagCompound.getInteger("colorRed");
  66. stack.stackTagCompound.getInteger("colorGreen");
  67. stack.stackTagCompound.getInteger("colorBlue");
  68. }*/
  69. }
  70.  
  71. @Override
  72. public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4)
  73. {
  74. if (stack.stackTagCompound != null)
  75. {
  76. int red = stack.stackTagCompound.getInteger("colorRed");
  77. int green = stack.stackTagCompound.getInteger("colorGreen");
  78. int blue = stack.stackTagCompound.getInteger("colorBlue");
  79.  
  80. // Color color = Color.decode(crystalColor);
  81. list.add("Current colors stored:");
  82. list.add(EnumChatFormatting.RED + "Red: "+ red);
  83. list.add(EnumChatFormatting.GREEN + "Green: "+ green);
  84. list.add(EnumChatFormatting.BLUE + "Blue: "+ blue);
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement