Posted December 20, 201212 yr I am using the metadata to store info about the block and so far I resets to 0 after i hit 15, heres my code package kore.korecraft.mod; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.asm.SideOnly; public class BlockExpBank extends Block { private int maxExpStorage = 24; protected BlockExpBank(int par1, Material par2Material) { super(par1, par2Material); this.blockIndexInTexture = 0; this.setCreativeTab(CreativeTabs.tabBlock); this.setHardness(6F); this.setBlockName("Experience Bank"); } public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) { if(par1World.getBlockMetadata(par2, par3, par4)>=1) { par5EntityPlayer.addExperienceLevel(1); par1World.setBlockMetadata(par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4)-1); tick(par1World.getBlockMetadata(par2, par3, par4)); } } public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if(par5EntityPlayer.experienceLevel>1&&par1World.getBlockMetadata(par2, par3, par4)<this.maxExpStorage){ par5EntityPlayer.addExperienceLevel(-1); par1World.setBlockMetadata(par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4)+1); tick(par1World.getBlockMetadata(par2, par3, par4)); return true; } return false; } public void tick(int metadata) { double maxExpScaled = maxExpStorage/6; if(metadata>=maxExpScaled*5) { this.blockIndexInTexture=5; }else if(metadata>=maxExpScaled*4) { this.blockIndexInTexture=4; }else if(metadata>=maxExpScaled*3) { this.blockIndexInTexture=3; }else if(metadata>=maxExpScaled*2) { this.blockIndexInTexture=2; }else if(metadata>=maxExpScaled) { this.blockIndexInTexture=1; }else{ this.blockIndexInTexture=0; } } public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) { if(par5>0) {} } public int idDropped() { return 1500; } public String getTextureFile() { return Korecraft.blockTexture; } } The Korecraft Mod
December 20, 201212 yr Make a Tile Entity of your block and store it in another tag. (Like a furnace does with burning time)
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.