Jump to content

Recommended Posts

Posted (edited)

I want to make an item could be a curios item if Curios is present but is worn in an armor slot if not. Is there a way to add optional Curios functionality to a custom item without requiring Curios? For example, the item would allow the wearer to breathe underwater if worn in chest Curios slot, or as a chestplate if curios is not present.

Edited by SilverfishStone
grammer
Posted

	use inventorytick()
	whit the slot number you can know if its into an armour slot  
	 
	    //########## ########## ##########
    public void inventoryTick(ItemStack helditem, Level warudo, Entity en, int slot, boolean value) {
        Long wtick = 0L;
        int tick = 0;
	        // System.out.println("\n#inventoryTick#\n");
        if( !warudo.isClientSide ){
            wtick = warudo.dayTime();
	            if( wtick % 20 == 0 && en instanceof Player ) {
	                item_handler ih = get_itemhandler(helditem);
	                //inicializar tiempo
                if (ih.start_time < 1L) {
                    ih.start_time = wtick;
                }
	                ih.time = (int) ( wtick - ih.start_time );
                tick = ih.time;
	                //cada 5 seg causar daño por fuego al player
                if (tick > 0 && tick % 100 == 0) {
                    en.setSecondsOnFire(1);
                }
	                //despues de un minuto el lingote se enfria y vielve a ser hierro
                if ( tick > 1200 ) { //
                    helditem = new ItemStack( Items.IRON_INGOT, helditem.getCount() );
                    ((Player) en).getInventory().setItem(slot, helditem );
                }
	            }
        }
    }
	

Posted
2 hours ago, perromercenary00 said:

 

	use inventorytick()
	whit the slot number you can know if its into an armour slot  
	 
	    //########## ########## ##########
    public void inventoryTick(ItemStack helditem, Level warudo, Entity en, int slot, boolean value) {
        Long wtick = 0L;
        int tick = 0;
	        // System.out.println("\n#inventoryTick#\n");
        if( !warudo.isClientSide ){
            wtick = warudo.dayTime();
	            if( wtick % 20 == 0 && en instanceof Player ) {
	                item_handler ih = get_itemhandler(helditem);
	                //inicializar tiempo
                if (ih.start_time < 1L) {
                    ih.start_time = wtick;
                }
	                ih.time = (int) ( wtick - ih.start_time );
                tick = ih.time;
	                //cada 5 seg causar daño por fuego al player
                if (tick > 0 && tick % 100 == 0) {
                    en.setSecondsOnFire(1);
                }
	                //despues de un minuto el lingote se enfria y vielve a ser hierro
                if ( tick > 1200 ) { //
                    helditem = new ItemStack( Items.IRON_INGOT, helditem.getCount() );
                    ((Player) en).getInventory().setItem(slot, helditem );
                }
	            }
        }
    }
	

 

I understand how to make the item function in the inventory, but I want to add an optional Curios functionality. Is there a way to add functionality without requiring Curios as a dependency?

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.

Announcements



×
×
  • Create New...

Important Information

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