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

hi am am trying to make a new furnace style thingy 

 

but i only want certain item into certain slots  i hav being trying this

 

@Override

public boolean isItemValid(ItemStack par1ItemStack, int Slot)

{

switch(Slot)

{

case 0: if(par1ItemStack.getItem() instanceof Item)

return true;

}

return false;

}

 

But the problem is one it doesnt work and 2 that will let any item in

 

i want it to only let blazerod in to the slot but if i do this

 

case 0: if(par1ItemStack.getItem() instanceof Item.blazeRod)

 

it errors out and says that it cant be done

 

plz help

 

 

Override slotClicked and return null(maybe just return? can't remember) if that item shouldn't be placed in the slot number passed in, otherwise, call the super.

 

You can get the itemstack that is currently stuck to the players mouse by doing a player.inventory.getItemStack()

 

Edit: Return the ItemStack, not null. Returning Null will delete the item in their hand.

  • Author

k thanks  i understand what you are saying i just dont now how to right that in code

 

even  u just give a basic layout would be good

 

thanks

 

Not be rude, by I really think that If you don't have at least a decent understanding in java you shouldn't be doing forge modding.

 

The reason:

 

case 0: if(par1ItemStack.getItem() instanceof Item.blazeRod)

 

does not work is because instanceof is used to check if an Item is of the class type. Item.blazeRod isn't a class type but rather an instance of a class. To get it to work I would do

 

case 0: if(par1ItemStack.getItem().shiftedIndex == Item.blazeRod.shiftedIndex){

//code in here

}

 

 

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.