Adds 1.17.
Sorry for spoiling the fun of reverse engineering, but there are still old versions like beta 1.7.3 to create lists for.
Achieved using Spigot server, and this messy code:
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import net.minecraft.core.IRegistry;
import net.minecraft.data.Main;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.Item;
public class Collect {
public static void main(String[] args) throws Throwable {
PrintStream out = System.out; // Use original System.out.
Main.main(new String[] { "--validate" }); // Force bootstrap. Overwrites System.out to use logger.
// for(Field field : Blocks.class.getFields()) { // Iterate over block fields.
// if(field.getType() == Block.class) {
// out.println(IRegistry.W.getKey(((Block) field.get(null))).toString());
// }
// }
for(Field field : Items.class.getFields()) { // Iterate over item fields.
if(field.getType() == Item.class) {
out.println("minecraft:" + field.get(null).toString());
}
}
}
}
The Blocks class contains fields of Block. When converting them to strings, they produce something like Block{minecraft:waxed_oxidized_cut_copper_stairs}, so you need to convert it into a MinecraftKey (Spigot calls it this for some reason).
With the Item class, calling toString() produces something like waxed_oxidized_cut_copper_stairs, so you need to prepend minecraft:.
There is a better way to do this, but this was just the quickest and easy for server owners, as it doesn't require any decompilation (aside from running BuildTools, which many technical Minecraft players will have done at some point).
You may want to give this a quick review, as I can't trust myself to get things right (and I've had pull requests blindly accepted).
Adds 1.17. Sorry for spoiling the fun of reverse engineering, but there are still old versions like beta 1.7.3 to create lists for. Achieved using Spigot server, and this messy code:
The
Blocks
class contains fields ofBlock
. When converting them to strings, they produce something likeBlock{minecraft:waxed_oxidized_cut_copper_stairs}
, so you need to convert it into aMinecraftKey
(Spigot calls it this for some reason).With the
Item
class, callingtoString()
produces something likewaxed_oxidized_cut_copper_stairs
, so you need to prependminecraft:
.See my stackexchange answer: https://gaming.stackexchange.com/a/391998.
There is a better way to do this, but this was just the quickest and easy for server owners, as it doesn't require any decompilation (aside from running BuildTools, which many technical Minecraft players will have done at some point).
You may want to give this a quick review, as I can't trust myself to get things right (and I've had pull requests blindly accepted).