Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.blueraven.magicmod.item;
- import com.blueraven.magicmod.tileentity.TileEntityPylon;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.network.NetworkManager;
- import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
- import net.minecraft.util.EnumChatFormatting;
- import net.minecraft.world.World;
- import java.awt.*;
- import java.util.List;
- public class ItemColorCrystal extends ItemBase
- {
- public ItemColorCrystal()
- {
- super();
- this.setUnlocalizedName("colorCrystal");
- //this.setTextureName = "colorcrystal";
- }
- @Override
- @SideOnly(Side.CLIENT)
- public int getColorFromItemStack(ItemStack stack, int renderPass)
- {
- //if (!(stack.stackTagCompound.getInteger("colorHEX") == 0))
- {
- int red = stack.stackTagCompound.getInteger("colorRed");
- int green = stack.stackTagCompound.getInteger("colorGreen");
- int blue = stack.stackTagCompound.getInteger("colorBlue");
- Color c = new Color(red, green, blue);
- return c.getRGB();
- }
- //else return Integer.parseInt("ffffff", 16);
- }
- @Override
- public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
- {
- TileEntityPylon tePylon = (TileEntityPylon) world.getTileEntity(x, y, z);
- if (world.getTileEntity(x, y, z) instanceof TileEntityPylon)
- {
- stack.stackTagCompound.setInteger("colorRed", tePylon.red);
- stack.stackTagCompound.setInteger("colorGreen", tePylon.green);
- stack.stackTagCompound.setInteger("colorBlue", tePylon.blue);
- return true;
- }
- return false;
- }
- public void onUpdate(ItemStack stack, World world, Entity entity, int par1, boolean b)
- {
- /*if (stack.stackTagCompound == null)
- {
- stack.stackTagCompound = new NBTTagCompound();
- }
- if (world.isRemote)
- {
- stack.stackTagCompound.getInteger("colorRed");
- stack.stackTagCompound.getInteger("colorGreen");
- stack.stackTagCompound.getInteger("colorBlue");
- }*/
- }
- @Override
- public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4)
- {
- if (stack.stackTagCompound != null)
- {
- int red = stack.stackTagCompound.getInteger("colorRed");
- int green = stack.stackTagCompound.getInteger("colorGreen");
- int blue = stack.stackTagCompound.getInteger("colorBlue");
- // Color color = Color.decode(crystalColor);
- list.add("Current colors stored:");
- list.add(EnumChatFormatting.RED + "Red: "+ red);
- list.add(EnumChatFormatting.GREEN + "Green: "+ green);
- list.add(EnumChatFormatting.BLUE + "Blue: "+ blue);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement