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'm trying to get my custom Item accept ONLY SPECIFIC vanilla enchantments (unbreaking) in the enchanting table. I know that you can allow the tool enchantments to be added by making the items class extend ItemTool, but that would allow all tool enchantments, like silk touch,... , to be added to the item. Is there a way of only accepting a few of these enchants without modifying base classes?

Hi

 

After a quick look through the vanilla code I don't think there is anything you could do directly, but you might be able to get to the same place indirectly.  If you hijack the vanilla enchanting table using the GuiOpenEvent to replace the enchanting table GUI with one of your own which derives from GuiEnchantment, you could override mouseClicked to call a customContainerEnchantment which restricts the enchantments that can be applied.

 

If Draco reads this he might have more specific help, he's done a stack of stuff with enchantment.

 

-TGG

The only enchantment stuff I did was using the inbuilt system.

 

Specifically I'd check what kind of item I had, or close approximation, modified a tiny bit randomly, then:

 

                ItemStack stack = new ItemStack(item); //the vanilla item that is similar to my item
                stack = EnchantmentHelper.addRandomEnchantment(rand, stack, level); //add enchantments per existing rules
                if(stack.stackTagCompound != null) {
                        artifact.stackTagCompound.setTag("ench", stack.stackTagCompound.getTag("ench").copy()); //copy enchantments to my item
                        //other stuff
                }

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

use the on update function to remove the enchantment what is not allowed. That is the only way when you still want to use the vanilla enchanting way.

For my enchanter i created a new enchanting system

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.