Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Metadata not able to go above 15


Recommended Posts

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.setBlockName("Experience Bank");

    public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) {
    	if(par1World.getBlockMetadata(par2, par3, par4)>=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){
        	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) {
    		if(metadata>=maxExpScaled*4) {
        		if(metadata>=maxExpScaled*3) {
            		if(metadata>=maxExpScaled*2) {
                		if(metadata>=maxExpScaled) {
    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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.