QingyangYu16 Posted April 27, 2019 Posted April 27, 2019 Maybe the problem is not explained clearly in the topic. For short, I am going to create a number of chips to act as keys for some machine, but those chips are different instances of one class with different nbt data to make some differences. Thus, using this approach, there need huge codes to realize registry events and I think that is kind of unpractical. Therefore, I want to know whether there is an efficient way to realize this thing because, for blocks, I only need to create a PropertyEnum variable and an Enum class to write down different block states. I really appreciate any help or hints 1 Quote
QingyangYu16 Posted April 27, 2019 Author Posted April 27, 2019 for code example, right now, what i have done is like this: public static final ItemChip ID_CHIP_1 = null; public static final ItemChip ID_CHIP_2 = null; but what i want to realize is like this public static final ItemChip ID_CHIP = null; and this line of code will give me enough items in my tab Quote
DavidM Posted April 27, 2019 Posted April 27, 2019 If I understood correctly, you can try looking up and overriding Block#getSubBlocks and Item#getSubItem. Make sure you set Item#setHasSubtypes and Block#setHasSubtypes to true though. Quote Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
QingyangYu16 Posted April 27, 2019 Author Posted April 27, 2019 4 minutes ago, DavidM said: If I understood correctly, you can try looking up and overriding Block#getSubBlocks and Item#getSubItem. Make sure you set Item#setHasSubtypes and Block#setHasSubtypes to true though. so can I use enum class to set different meta number to define different items? For blocks, it provides the function to get data from meta. For items, I do not know whether it is enough to just override gueSubItems() function. Maybe I can write down my individual class to realize? Quote
QingyangYu16 Posted April 28, 2019 Author Posted April 28, 2019 16 minutes ago, DavidM said: If I understood correctly, you can try looking up and overriding Block#getSubBlocks and Item#getSubItem. Make sure you set Item#setHasSubtypes and Block#setHasSubtypes to true though. For now, there is no time for me to code, I will try it tomorrow. Anyway, thx for the hint Quote
DavidM Posted April 28, 2019 Posted April 28, 2019 4 minutes ago, QingyangYu16 said: so can I use enum class to set different meta number to define different items? If I understood correctly, yes. In one of my mods I used subitems for items with different metadata. If needed, you can take a look here. The enum (which turned out to be quite useless in my case) can be viewed here. Quote Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
Cadiboo Posted May 1, 2019 Posted May 1, 2019 With metadata being pretty much removed in 1.13, you should be using separate items. Just make an item that takes in a Tier enum in the constructor and instantiate and register the items in a for loop Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
Recommended Posts
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.