Posted December 31, 201410 yr I have a block that changes colour depending on metadata but for whatever reason it resets the metadata every frame. heres the code: package com.example.gammacraft.PlasmaTech; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; public class LaserBeam extends Block { public LaserBeam() { super(Material.fire); this.setBlockName("LaserBeam"); this.setBlockUnbreakable(); } //colours are in "rainbow" configuration @SideOnly(Side.CLIENT) public static IIcon Red; @SideOnly(Side.CLIENT) public static IIcon Orange; @SideOnly(Side.CLIENT) public static IIcon Yellow; @SideOnly(Side.CLIENT) public static IIcon Green; @SideOnly(Side.CLIENT) public static IIcon Blue; @SideOnly(Side.CLIENT) public static IIcon Purple; @SideOnly(Side.CLIENT) public static IIcon White; @SideOnly(Side.CLIENT) public static IIcon Void; public void registerBlockIcons(IIconRegister i){ this.Red = i.registerIcon("gammacraft:RedConstructionBlock"); //red this.Orange = i.registerIcon("gammacraft:Orange"); //orange this.Yellow = i.registerIcon("gammacraft:Yellow"); //yellow this.Green = i.registerIcon("gammacraft:Green"); //green this.Blue = i.registerIcon("gammacraft:BlueConstructionBlock"); //blue this.Purple = i.registerIcon("gammacraft:Purple"); //purple this.White = i.registerIcon("gammacraft:White"); //white this.Void = i.registerIcon("gammacraft:Void"); //"void" } public IIcon getIcon(int side, int meta){ /*switch(meta){ case 0:return Red; case 1:return Orange; case 2:return Yellow; case 3:return Green; case 4:return Blue; case 5:return Purple; case 6:return White; case 7:return Void; default:return White; }*/ System.out.println(meta); if(meta==0)return Red; if(meta==1)return Orange; if(meta==2)return Yellow; if(meta==3)return Green; if(meta==4)return Blue; if(meta==5)return Purple; if(meta==6)return White; if(meta==7)return Void; return Void; } } I made an item that sets the metadata as a debug item, if you need the code here it is: package com.example.gammacraft.items; import com.example.gammacraft.RandomFunctions; import com.example.gammacraft.gammacraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class MetaDataSetter extends Item { public MetaDataSetter() { this.setCreativeTab(gammacraft.PlamsaTech); this.setUnlocalizedName("MetaDataSetter"); this.setMaxStackSize(1); } @Override public boolean onItemUse(ItemStack itemstack,EntityPlayer player,World world,int x,int y,int z,int side,float hx,float hy,float hz){ if(itemstack.stackTagCompound!=null){ System.out.println(itemstack.stackTagCompound.getInteger("Meta")); world.setBlockMetadataWithNotify(x, y, z, itemstack.stackTagCompound.getInteger("Meta"), 0); } return player.isSneaking(); } public ItemStack onItemRightClick(ItemStack itemstack,World world,EntityPlayer player){ if(itemstack.stackTagCompound==null){ itemstack.setTagCompound(new NBTTagCompound()); } if(player.isSneaking()){ NBTTagCompound nbt = itemstack.stackTagCompound; int Meta = nbt.getInteger("Meta"); if(Meta==15){ Meta = 0; }else{ Meta++; } if(!world.isRemote) RandomFunctions.tell(player, "Meta:"+Meta); nbt.setInteger("Meta", Meta); itemstack.setTagCompound(nbt); } return itemstack; } } EDIT: I figured it out, turns out it doesn't like having a material of fire. The proud(ish) developer of Ancients
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.