Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.