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

hello

 

so im making something that requires that i need to detect if the block placed in the slot is the sand block(Block.sand)

 

so this is what i did for a item:

    //checking if the placed item is "Hydrocroconyzx ingot" only retuns false if there is no item in the slot since no othere item/block  is allowed in the slot
   public boolean CheckInventoryTrader1(ItemStack par1ItemStack) {
       
       Item item = par1ItemStack.getItem();
       
       if(par1ItemStack != null && item == EsteticsPLUS.HydrocroconyxIngot){
           return true;
       }
       
       else return false;
   }
    
    

 

and then i dont know how to do the same kind of thing, but with the Sand block or any kind of block for that matter

hello

 

so im making something that requires that i need to detect if the block placed in the slot is the sand block(Block.sand)

 

so this is what i did for a item:

    //checking if the placed item is "Hydrocroconyzx ingot" only retuns false if there is no item in the slot since no othere item/block  is allowed in the slot
   public boolean CheckInventoryTrader1(ItemStack par1ItemStack) {
       
       Item item = par1ItemStack.getItem();
       
       if(par1ItemStack != null && item == EsteticsPLUS.HydrocroconyxIngot){
           return true;
       }
       
       else return false;
   }
    
    

 

and then i dont know how to do the same kind of thing, but with the Sand block or any kind of block for that matter

 

first I would suggest a couple of changes to your code.

    //checking if the placed item is "Hydrocroconyzx ingot" only retuns false if there is no item in the slot since no othere item/block  is allowed in the slot
   public boolean CheckInventoryTrader1(ItemStack par1ItemStack) {
       
       if(par1ItemStack != null){
           Item item = par1ItemStack.getItem();
           
           if(item.equals(EsteticsPLUS.HydrocroconyxIngot))
               return true;
           else if(item.equals(Block.sand))
               return true;
           else if(item.equals(ITEM_OR_BLOCK_HERE))
               return true;
       }
       
       return false;
   }
    

when you compare things that have Object as a parent, you use .eqauls() to compare them. if they're primitives, then you can use ==. you should also check if the ItemStack is null before getting the item otherwise it can cause crashes. "else return false" is the same as "return false"

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.