Jump to content

write to NBT


nickfromgreek

Recommended Posts

I want to store a booolean variable(well 2) and i want to triger it on Item rick click: i want ot store these 2:

 

par3EntityPlayer.capabilities.isFlying = false;

  par3EntityPlayer.capabilities.allowFlying = true;

 

code:

 

package toolsPlus;

import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntityBeacon;
import net.minecraft.src.World;

public class Itemenderfcoremk2 extends Item {

protected Itemenderfcoremk2(int par1) {
	super(par1);
	this.setCreativeTab(CreativeTabs.tabMisc);
}

    public TileEntity createNewTileEntity(World par1World)
    {
        return new TileEntityBeacon();
    }

@Override
public String getTextureFile() {
return "/Sheet.png";
}

@SideOnly(Side.CLIENT)
    public boolean hasEffect(ItemStack stack) {
        return true;
    }
    
    @Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
    	
    		
       		if(par3EntityPlayer.experienceLevel < 40 || par3EntityPlayer.experienceLevel <= 0){
       			
       			par3EntityPlayer.capabilities.allowFlying = false;
        		par3EntityPlayer.capabilities.isFlying = false;
       			
       		}
       		else if(!par3EntityPlayer.capabilities.isFlying || !par3EntityPlayer.capabilities.allowFlying){
    		
       		par3EntityPlayer.capabilities.isFlying = false;
   			par3EntityPlayer.capabilities.allowFlying = true;

       		par3EntityPlayer.experienceLevel = par3EntityPlayer.experienceLevel - 40;
    	}
    	
    	else if(par3EntityPlayer.capabilities.isFlying || par3EntityPlayer.capabilities.allowFlying){
    		
    		par3EntityPlayer.capabilities.allowFlying = false;
    		par3EntityPlayer.capabilities.isFlying = false;
    		
    		par3EntityPlayer.experienceLevel = par3EntityPlayer.experienceLevel + 40;
    		
    		
    	}
    	
	return par1ItemStack;

    }

}

Link to comment
Share on other sites

((EntityPlayerMP) par3EntityPlayer).playerNetSeverHandler.handleAbilites(new Packet202PlayerAbilites(par3EntityPlayer.capabilities))

Protip: try and find answers yourself before asking on the forum.

It's pretty likely that there is an answer.

 

Was I helpful? Give me a thank you!

 

 

width=635 height=903http://bit.ly/HZ03zy[/img]

 

 

Tired of waiting for mods to port to bukkit?

use BukkitForge! (now with a working version of WorldEdit!)

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.
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...

×   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 Terms of Use.