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 have this growth amulet it has an max damge but i want to use the meta data for an ative and an non aactive version. mayby nbt or something i have no clue

 

public class ItemAmuletGrowth extends ItemBaubles {

public ItemAmuletGrowth(){
	this.setUnlocalizedName("ItemAmuletGrowth");
    setMaxDamage(1001);
this.canRepair = true;

}

 private int tickDelay = 100;
@Override
public BaubleType getBaubleType(ItemStack arg0) {
	return BaubleType.AMULET;
}


@Override
public void onWornTick(ItemStack stack, EntityLivingBase entity) {
	  {

		  World par2World = entity.worldObj;
	        if (!(entity instanceof EntityPlayer))
	        {
	            return;
	        }

	        EntityPlayer par3EntityPlayer = (EntityPlayer) entity;
	      
	        if (stack.stackTagCompound == null)
	        {
	        	stack.setTagCompound(new NBTTagCompound());
	        }
	        {
	            if (par2World.getWorldTime() % tickDelay == stack.stackTagCompound.getInteger("worldTimeDelay") && entity instanceof EntityPlayer)
	            {
	            	
	            }

	            int range = 5;
	            int verticalRange = 2;
	            int posX = (int) Math.round(entity.posX - 0.5f);
	            int posY = (int) entity.posY;
	            int posZ = (int) Math.round(entity.posZ - 0.5f);

	            for (int ix = posX - range; ix <= posX + range; ix++)
	            {
	                for (int iz = posZ - range; iz <= posZ + range; iz++)
	                {
	                    for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++)
	                    {
	                        Block block = par2World.getBlock(ix, iy, iz);
	                        

	                        if (block instanceof IPlantable)
	                        {
	                        	
	                            if (par2World.rand.nextInt(20) == 0)
	                            {
	                            	
	                            	
	                            	
	                                block.updateTick(par2World, ix, iy, iz, par2World.rand);
	                                
	                                if (par2World.rand.nextInt(100) == 0){
	                                	stack.damageItem(1, par3EntityPlayer);
	                                }
	                               
	                            }
	                        }
	                    }
	                }
	            }
	        }

	        return;
	     
	    }
}
  
	   



}


[code/]

  • Author

I would use the normal item damage for the damage and the state of on and off with NBT

 

well i got it working with on item right click but i want to do it with an key bind but i cant figure it out it got this

 

 

@SubscribeEvent
    public void onKey(KeyInputEvent evt) {
    	
        boolean toggle = keyToggle.isPressed();
        ItemStack stack = new ItemStack (BaubleliciousItems.ItemAmuletGrowth);
  
      
        if (toggle) {
            if (mc.inGameHasFocus) {

        	        if (stack.stackTagCompound == null)
        	        {
        	        	stack.setTagCompound(new NBTTagCompound());
        	        }

        	        NBTTagCompound tag = stack.stackTagCompound;
        	        tag.setBoolean("isActive", (tag.getBoolean("isActive")));

        	        if (tag.getBoolean("isActive"))
        	        {
        	           System.out.print("yay");
        	         //  tag.setBoolean("isActive",true);
        	            
        	            
        	        } else
        	        {
        	        	System.out.print("nah");
        	        	// tag.setBoolean("isActive",false);
        	        }

        	    }
            return;
                    
                }
            }
        
    }
[code/]

  • Author

First of all: You're just creating a new ItemStack and then don't do anything with that. This will not do anything at all.

Then: KeyHandlers are client-only. For things like this you'll need to send a packet when the key is pressed and then do the actions on the server.

 

ok Thanks i will take a look at it

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.