ItemEnumGenerator converted to Javapoet and re-generation of everything

This commit is contained in:
jglrxavpok 2020-10-26 22:51:12 +01:00
parent 6577c6070c
commit 48670e8c37
12 changed files with 4975 additions and 2613 deletions

View File

@ -1,140 +1,250 @@
//==============================
// AUTOGENERATED BY EnumGenerator
//==============================
package net.minestom.server.entity;
import net.minestom.server.registry.Registries;
import net.minestom.server.utils.NamespaceID;
/**
* //==============================
* // AUTOGENERATED BY EnumGenerator
* //==============================
*/
@SuppressWarnings({"deprecation"})
public enum EntityType {
AREA_EFFECT_CLOUD("minecraft:area_effect_cloud"),
ARMOR_STAND("minecraft:armor_stand"),
ARROW("minecraft:arrow"),
BAT("minecraft:bat"),
BEE("minecraft:bee"),
BLAZE("minecraft:blaze"),
BOAT("minecraft:boat"),
CAT("minecraft:cat"),
CAVE_SPIDER("minecraft:cave_spider"),
CHICKEN("minecraft:chicken"),
COD("minecraft:cod"),
COW("minecraft:cow"),
CREEPER("minecraft:creeper"),
DOLPHIN("minecraft:dolphin"),
DONKEY("minecraft:donkey"),
DRAGON_FIREBALL("minecraft:dragon_fireball"),
DROWNED("minecraft:drowned"),
ELDER_GUARDIAN("minecraft:elder_guardian"),
END_CRYSTAL("minecraft:end_crystal"),
ENDER_DRAGON("minecraft:ender_dragon"),
ENDERMAN("minecraft:enderman"),
ENDERMITE("minecraft:endermite"),
EVOKER("minecraft:evoker"),
EVOKER_FANGS("minecraft:evoker_fangs"),
EXPERIENCE_ORB("minecraft:experience_orb"),
EYE_OF_ENDER("minecraft:eye_of_ender"),
FALLING_BLOCK("minecraft:falling_block"),
FIREWORK_ROCKET("minecraft:firework_rocket"),
FOX("minecraft:fox"),
GHAST("minecraft:ghast"),
GIANT("minecraft:giant"),
GUARDIAN("minecraft:guardian"),
HOGLIN("minecraft:hoglin"),
HORSE("minecraft:horse"),
HUSK("minecraft:husk"),
ILLUSIONER("minecraft:illusioner"),
IRON_GOLEM("minecraft:iron_golem"),
ITEM("minecraft:item"),
ITEM_FRAME("minecraft:item_frame"),
FIREBALL("minecraft:fireball"),
LEASH_KNOT("minecraft:leash_knot"),
LIGHTNING_BOLT("minecraft:lightning_bolt"),
LLAMA("minecraft:llama"),
LLAMA_SPIT("minecraft:llama_spit"),
MAGMA_CUBE("minecraft:magma_cube"),
MINECART("minecraft:minecart"),
CHEST_MINECART("minecraft:chest_minecart"),
COMMAND_BLOCK_MINECART("minecraft:command_block_minecart"),
FURNACE_MINECART("minecraft:furnace_minecart"),
HOPPER_MINECART("minecraft:hopper_minecart"),
SPAWNER_MINECART("minecraft:spawner_minecart"),
TNT_MINECART("minecraft:tnt_minecart"),
MULE("minecraft:mule"),
MOOSHROOM("minecraft:mooshroom"),
OCELOT("minecraft:ocelot"),
PAINTING("minecraft:painting"),
PANDA("minecraft:panda"),
PARROT("minecraft:parrot"),
PHANTOM("minecraft:phantom"),
PIG("minecraft:pig"),
PIGLIN("minecraft:piglin"),
PIGLIN_BRUTE("minecraft:piglin_brute"),
PILLAGER("minecraft:pillager"),
POLAR_BEAR("minecraft:polar_bear"),
TNT("minecraft:tnt"),
PUFFERFISH("minecraft:pufferfish"),
RABBIT("minecraft:rabbit"),
RAVAGER("minecraft:ravager"),
SALMON("minecraft:salmon"),
SHEEP("minecraft:sheep"),
SHULKER("minecraft:shulker"),
SHULKER_BULLET("minecraft:shulker_bullet"),
SILVERFISH("minecraft:silverfish"),
SKELETON("minecraft:skeleton"),
SKELETON_HORSE("minecraft:skeleton_horse"),
SLIME("minecraft:slime"),
SMALL_FIREBALL("minecraft:small_fireball"),
SNOW_GOLEM("minecraft:snow_golem"),
SNOWBALL("minecraft:snowball"),
SPECTRAL_ARROW("minecraft:spectral_arrow"),
SPIDER("minecraft:spider"),
SQUID("minecraft:squid"),
STRAY("minecraft:stray"),
STRIDER("minecraft:strider"),
EGG("minecraft:egg"),
ENDER_PEARL("minecraft:ender_pearl"),
EXPERIENCE_BOTTLE("minecraft:experience_bottle"),
POTION("minecraft:potion"),
TRIDENT("minecraft:trident"),
TRADER_LLAMA("minecraft:trader_llama"),
TROPICAL_FISH("minecraft:tropical_fish"),
TURTLE("minecraft:turtle"),
VEX("minecraft:vex"),
VILLAGER("minecraft:villager"),
VINDICATOR("minecraft:vindicator"),
WANDERING_TRADER("minecraft:wandering_trader"),
WITCH("minecraft:witch"),
WITHER("minecraft:wither"),
WITHER_SKELETON("minecraft:wither_skeleton"),
WITHER_SKULL("minecraft:wither_skull"),
WOLF("minecraft:wolf"),
ZOGLIN("minecraft:zoglin"),
ZOMBIE("minecraft:zombie"),
ZOMBIE_HORSE("minecraft:zombie_horse"),
ZOMBIE_VILLAGER("minecraft:zombie_villager"),
ZOMBIFIED_PIGLIN("minecraft:zombified_piglin"),
PLAYER("minecraft:player"),
FISHING_BOBBER("minecraft:fishing_bobber"),
;
private String namespaceID;
AREA_EFFECT_CLOUD("minecraft:area_effect_cloud"),
EntityType(String namespaceID) {
this.namespaceID = namespaceID;
Registries.entityTypes.put(NamespaceID.from(namespaceID), this);
}
ARMOR_STAND("minecraft:armor_stand"),
public int getId() {
return ordinal();
}
ARROW("minecraft:arrow"),
public String getNamespaceID() {
return namespaceID;
}
BAT("minecraft:bat"),
public static EntityType fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return PIG;
}
BEE("minecraft:bee"),
BLAZE("minecraft:blaze"),
BOAT("minecraft:boat"),
CAT("minecraft:cat"),
CAVE_SPIDER("minecraft:cave_spider"),
CHICKEN("minecraft:chicken"),
COD("minecraft:cod"),
COW("minecraft:cow"),
CREEPER("minecraft:creeper"),
DOLPHIN("minecraft:dolphin"),
DONKEY("minecraft:donkey"),
DRAGON_FIREBALL("minecraft:dragon_fireball"),
DROWNED("minecraft:drowned"),
ELDER_GUARDIAN("minecraft:elder_guardian"),
END_CRYSTAL("minecraft:end_crystal"),
ENDER_DRAGON("minecraft:ender_dragon"),
ENDERMAN("minecraft:enderman"),
ENDERMITE("minecraft:endermite"),
EVOKER("minecraft:evoker"),
EVOKER_FANGS("minecraft:evoker_fangs"),
EXPERIENCE_ORB("minecraft:experience_orb"),
EYE_OF_ENDER("minecraft:eye_of_ender"),
FALLING_BLOCK("minecraft:falling_block"),
FIREWORK_ROCKET("minecraft:firework_rocket"),
FOX("minecraft:fox"),
GHAST("minecraft:ghast"),
GIANT("minecraft:giant"),
GUARDIAN("minecraft:guardian"),
HOGLIN("minecraft:hoglin"),
HORSE("minecraft:horse"),
HUSK("minecraft:husk"),
ILLUSIONER("minecraft:illusioner"),
IRON_GOLEM("minecraft:iron_golem"),
ITEM("minecraft:item"),
ITEM_FRAME("minecraft:item_frame"),
FIREBALL("minecraft:fireball"),
LEASH_KNOT("minecraft:leash_knot"),
LIGHTNING_BOLT("minecraft:lightning_bolt"),
LLAMA("minecraft:llama"),
LLAMA_SPIT("minecraft:llama_spit"),
MAGMA_CUBE("minecraft:magma_cube"),
MINECART("minecraft:minecart"),
CHEST_MINECART("minecraft:chest_minecart"),
COMMAND_BLOCK_MINECART("minecraft:command_block_minecart"),
FURNACE_MINECART("minecraft:furnace_minecart"),
HOPPER_MINECART("minecraft:hopper_minecart"),
SPAWNER_MINECART("minecraft:spawner_minecart"),
TNT_MINECART("minecraft:tnt_minecart"),
MULE("minecraft:mule"),
MOOSHROOM("minecraft:mooshroom"),
OCELOT("minecraft:ocelot"),
PAINTING("minecraft:painting"),
PANDA("minecraft:panda"),
PARROT("minecraft:parrot"),
PHANTOM("minecraft:phantom"),
PIG("minecraft:pig"),
PIGLIN("minecraft:piglin"),
PIGLIN_BRUTE("minecraft:piglin_brute"),
PILLAGER("minecraft:pillager"),
POLAR_BEAR("minecraft:polar_bear"),
TNT("minecraft:tnt"),
PUFFERFISH("minecraft:pufferfish"),
RABBIT("minecraft:rabbit"),
RAVAGER("minecraft:ravager"),
SALMON("minecraft:salmon"),
SHEEP("minecraft:sheep"),
SHULKER("minecraft:shulker"),
SHULKER_BULLET("minecraft:shulker_bullet"),
SILVERFISH("minecraft:silverfish"),
SKELETON("minecraft:skeleton"),
SKELETON_HORSE("minecraft:skeleton_horse"),
SLIME("minecraft:slime"),
SMALL_FIREBALL("minecraft:small_fireball"),
SNOW_GOLEM("minecraft:snow_golem"),
SNOWBALL("minecraft:snowball"),
SPECTRAL_ARROW("minecraft:spectral_arrow"),
SPIDER("minecraft:spider"),
SQUID("minecraft:squid"),
STRAY("minecraft:stray"),
STRIDER("minecraft:strider"),
EGG("minecraft:egg"),
ENDER_PEARL("minecraft:ender_pearl"),
EXPERIENCE_BOTTLE("minecraft:experience_bottle"),
POTION("minecraft:potion"),
TRIDENT("minecraft:trident"),
TRADER_LLAMA("minecraft:trader_llama"),
TROPICAL_FISH("minecraft:tropical_fish"),
TURTLE("minecraft:turtle"),
VEX("minecraft:vex"),
VILLAGER("minecraft:villager"),
VINDICATOR("minecraft:vindicator"),
WANDERING_TRADER("minecraft:wandering_trader"),
WITCH("minecraft:witch"),
WITHER("minecraft:wither"),
WITHER_SKELETON("minecraft:wither_skeleton"),
WITHER_SKULL("minecraft:wither_skull"),
WOLF("minecraft:wolf"),
ZOGLIN("minecraft:zoglin"),
ZOMBIE("minecraft:zombie"),
ZOMBIE_HORSE("minecraft:zombie_horse"),
ZOMBIE_VILLAGER("minecraft:zombie_villager"),
ZOMBIFIED_PIGLIN("minecraft:zombified_piglin"),
PLAYER("minecraft:player"),
FISHING_BOBBER("minecraft:fishing_bobber");
private String namespaceID;
EntityType(String namespaceID) {
this.namespaceID = namespaceID;
Registries.entityTypes.put(NamespaceID.from(namespaceID), this);
}
public int getId() {
return ordinal();
}
public String getNamespaceID() {
return namespaceID;
}
public static EntityType fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return PIG;
}
}

View File

@ -1,37 +1,44 @@
//==============================
// AUTOGENERATED BY EnumGenerator
//==============================
package net.minestom.server.fluids;
import net.minestom.server.registry.Registries;
import net.minestom.server.utils.NamespaceID;
/**
* //==============================
* // AUTOGENERATED BY EnumGenerator
* //==============================
*/
@SuppressWarnings({"deprecation"})
public enum Fluid {
EMPTY("minecraft:empty"),
FLOWING_WATER("minecraft:flowing_water"),
WATER("minecraft:water"),
FLOWING_LAVA("minecraft:flowing_lava"),
LAVA("minecraft:lava"),
;
private String namespaceID;
EMPTY("minecraft:empty"),
Fluid(String namespaceID) {
this.namespaceID = namespaceID;
Registries.fluids.put(NamespaceID.from(namespaceID), this);
}
FLOWING_WATER("minecraft:flowing_water"),
public int getId() {
return ordinal();
}
WATER("minecraft:water"),
public String getNamespaceID() {
return namespaceID;
}
FLOWING_LAVA("minecraft:flowing_lava"),
public static Fluid fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return EMPTY;
}
LAVA("minecraft:lava");
private String namespaceID;
Fluid(String namespaceID) {
this.namespaceID = namespaceID;
Registries.fluids.put(NamespaceID.from(namespaceID), this);
}
public int getId() {
return ordinal();
}
public String getNamespaceID() {
return namespaceID;
}
public static Fluid fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return EMPTY;
}
}

View File

@ -1,70 +1,110 @@
//==============================
// AUTOGENERATED BY EnumGenerator
//==============================
package net.minestom.server.item;
import net.minestom.server.registry.Registries;
import net.minestom.server.utils.NamespaceID;
/**
* //==============================
* // AUTOGENERATED BY EnumGenerator
* //==============================
*/
@SuppressWarnings({"deprecation"})
public enum Enchantment {
PROTECTION("minecraft:protection"),
FIRE_PROTECTION("minecraft:fire_protection"),
FEATHER_FALLING("minecraft:feather_falling"),
BLAST_PROTECTION("minecraft:blast_protection"),
PROJECTILE_PROTECTION("minecraft:projectile_protection"),
RESPIRATION("minecraft:respiration"),
AQUA_AFFINITY("minecraft:aqua_affinity"),
THORNS("minecraft:thorns"),
DEPTH_STRIDER("minecraft:depth_strider"),
FROST_WALKER("minecraft:frost_walker"),
BINDING_CURSE("minecraft:binding_curse"),
SOUL_SPEED("minecraft:soul_speed"),
SHARPNESS("minecraft:sharpness"),
SMITE("minecraft:smite"),
BANE_OF_ARTHROPODS("minecraft:bane_of_arthropods"),
KNOCKBACK("minecraft:knockback"),
FIRE_ASPECT("minecraft:fire_aspect"),
LOOTING("minecraft:looting"),
SWEEPING("minecraft:sweeping"),
EFFICIENCY("minecraft:efficiency"),
SILK_TOUCH("minecraft:silk_touch"),
UNBREAKING("minecraft:unbreaking"),
FORTUNE("minecraft:fortune"),
POWER("minecraft:power"),
PUNCH("minecraft:punch"),
FLAME("minecraft:flame"),
INFINITY("minecraft:infinity"),
LUCK_OF_THE_SEA("minecraft:luck_of_the_sea"),
LURE("minecraft:lure"),
LOYALTY("minecraft:loyalty"),
IMPALING("minecraft:impaling"),
RIPTIDE("minecraft:riptide"),
CHANNELING("minecraft:channeling"),
MULTISHOT("minecraft:multishot"),
QUICK_CHARGE("minecraft:quick_charge"),
PIERCING("minecraft:piercing"),
MENDING("minecraft:mending"),
VANISHING_CURSE("minecraft:vanishing_curse"),
;
private String namespaceID;
PROTECTION("minecraft:protection"),
Enchantment(String namespaceID) {
this.namespaceID = namespaceID;
Registries.enchantments.put(NamespaceID.from(namespaceID), this);
}
FIRE_PROTECTION("minecraft:fire_protection"),
public int getId() {
return ordinal();
}
FEATHER_FALLING("minecraft:feather_falling"),
public String getNamespaceID() {
return namespaceID;
}
BLAST_PROTECTION("minecraft:blast_protection"),
public static Enchantment fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return null;
}
PROJECTILE_PROTECTION("minecraft:projectile_protection"),
RESPIRATION("minecraft:respiration"),
AQUA_AFFINITY("minecraft:aqua_affinity"),
THORNS("minecraft:thorns"),
DEPTH_STRIDER("minecraft:depth_strider"),
FROST_WALKER("minecraft:frost_walker"),
BINDING_CURSE("minecraft:binding_curse"),
SOUL_SPEED("minecraft:soul_speed"),
SHARPNESS("minecraft:sharpness"),
SMITE("minecraft:smite"),
BANE_OF_ARTHROPODS("minecraft:bane_of_arthropods"),
KNOCKBACK("minecraft:knockback"),
FIRE_ASPECT("minecraft:fire_aspect"),
LOOTING("minecraft:looting"),
SWEEPING("minecraft:sweeping"),
EFFICIENCY("minecraft:efficiency"),
SILK_TOUCH("minecraft:silk_touch"),
UNBREAKING("minecraft:unbreaking"),
FORTUNE("minecraft:fortune"),
POWER("minecraft:power"),
PUNCH("minecraft:punch"),
FLAME("minecraft:flame"),
INFINITY("minecraft:infinity"),
LUCK_OF_THE_SEA("minecraft:luck_of_the_sea"),
LURE("minecraft:lure"),
LOYALTY("minecraft:loyalty"),
IMPALING("minecraft:impaling"),
RIPTIDE("minecraft:riptide"),
CHANNELING("minecraft:channeling"),
MULTISHOT("minecraft:multishot"),
QUICK_CHARGE("minecraft:quick_charge"),
PIERCING("minecraft:piercing"),
MENDING("minecraft:mending"),
VANISHING_CURSE("minecraft:vanishing_curse");
private String namespaceID;
Enchantment(String namespaceID) {
this.namespaceID = namespaceID;
Registries.enchantments.put(NamespaceID.from(namespaceID), this);
}
public int getId() {
return ordinal();
}
public String getNamespaceID() {
return namespaceID;
}
public static Enchantment fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return null;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +0,0 @@
package net.minestom.server.item;
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
final class MaterialMap {
static final Short2ObjectOpenHashMap<Material> map = new Short2ObjectOpenHashMap<>();
}

View File

@ -1,104 +1,178 @@
//==============================
// AUTOGENERATED BY EnumGenerator
//==============================
package net.minestom.server.particle;
import net.minestom.server.registry.Registries;
import net.minestom.server.utils.NamespaceID;
/**
* //==============================
* // AUTOGENERATED BY EnumGenerator
* //==============================
*/
@SuppressWarnings({"deprecation"})
public enum Particle {
AMBIENT_ENTITY_EFFECT("minecraft:ambient_entity_effect"),
ANGRY_VILLAGER("minecraft:angry_villager"),
BARRIER("minecraft:barrier"),
BLOCK("minecraft:block"),
BUBBLE("minecraft:bubble"),
CLOUD("minecraft:cloud"),
CRIT("minecraft:crit"),
DAMAGE_INDICATOR("minecraft:damage_indicator"),
DRAGON_BREATH("minecraft:dragon_breath"),
DRIPPING_LAVA("minecraft:dripping_lava"),
FALLING_LAVA("minecraft:falling_lava"),
LANDING_LAVA("minecraft:landing_lava"),
DRIPPING_WATER("minecraft:dripping_water"),
FALLING_WATER("minecraft:falling_water"),
DUST("minecraft:dust"),
EFFECT("minecraft:effect"),
ELDER_GUARDIAN("minecraft:elder_guardian"),
ENCHANTED_HIT("minecraft:enchanted_hit"),
ENCHANT("minecraft:enchant"),
END_ROD("minecraft:end_rod"),
ENTITY_EFFECT("minecraft:entity_effect"),
EXPLOSION_EMITTER("minecraft:explosion_emitter"),
EXPLOSION("minecraft:explosion"),
FALLING_DUST("minecraft:falling_dust"),
FIREWORK("minecraft:firework"),
FISHING("minecraft:fishing"),
FLAME("minecraft:flame"),
SOUL_FIRE_FLAME("minecraft:soul_fire_flame"),
SOUL("minecraft:soul"),
FLASH("minecraft:flash"),
HAPPY_VILLAGER("minecraft:happy_villager"),
COMPOSTER("minecraft:composter"),
HEART("minecraft:heart"),
INSTANT_EFFECT("minecraft:instant_effect"),
ITEM("minecraft:item"),
ITEM_SLIME("minecraft:item_slime"),
ITEM_SNOWBALL("minecraft:item_snowball"),
LARGE_SMOKE("minecraft:large_smoke"),
LAVA("minecraft:lava"),
MYCELIUM("minecraft:mycelium"),
NOTE("minecraft:note"),
POOF("minecraft:poof"),
PORTAL("minecraft:portal"),
RAIN("minecraft:rain"),
SMOKE("minecraft:smoke"),
SNEEZE("minecraft:sneeze"),
SPIT("minecraft:spit"),
SQUID_INK("minecraft:squid_ink"),
SWEEP_ATTACK("minecraft:sweep_attack"),
TOTEM_OF_UNDYING("minecraft:totem_of_undying"),
UNDERWATER("minecraft:underwater"),
SPLASH("minecraft:splash"),
WITCH("minecraft:witch"),
BUBBLE_POP("minecraft:bubble_pop"),
CURRENT_DOWN("minecraft:current_down"),
BUBBLE_COLUMN_UP("minecraft:bubble_column_up"),
NAUTILUS("minecraft:nautilus"),
DOLPHIN("minecraft:dolphin"),
CAMPFIRE_COSY_SMOKE("minecraft:campfire_cosy_smoke"),
CAMPFIRE_SIGNAL_SMOKE("minecraft:campfire_signal_smoke"),
DRIPPING_HONEY("minecraft:dripping_honey"),
FALLING_HONEY("minecraft:falling_honey"),
LANDING_HONEY("minecraft:landing_honey"),
FALLING_NECTAR("minecraft:falling_nectar"),
ASH("minecraft:ash"),
CRIMSON_SPORE("minecraft:crimson_spore"),
WARPED_SPORE("minecraft:warped_spore"),
DRIPPING_OBSIDIAN_TEAR("minecraft:dripping_obsidian_tear"),
FALLING_OBSIDIAN_TEAR("minecraft:falling_obsidian_tear"),
LANDING_OBSIDIAN_TEAR("minecraft:landing_obsidian_tear"),
REVERSE_PORTAL("minecraft:reverse_portal"),
WHITE_ASH("minecraft:white_ash"),
;
private String namespaceID;
AMBIENT_ENTITY_EFFECT("minecraft:ambient_entity_effect"),
Particle(String namespaceID) {
this.namespaceID = namespaceID;
Registries.particles.put(NamespaceID.from(namespaceID), this);
}
ANGRY_VILLAGER("minecraft:angry_villager"),
public int getId() {
return ordinal();
}
BARRIER("minecraft:barrier"),
public String getNamespaceID() {
return namespaceID;
}
BLOCK("minecraft:block"),
public static Particle fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return null;
}
BUBBLE("minecraft:bubble"),
CLOUD("minecraft:cloud"),
CRIT("minecraft:crit"),
DAMAGE_INDICATOR("minecraft:damage_indicator"),
DRAGON_BREATH("minecraft:dragon_breath"),
DRIPPING_LAVA("minecraft:dripping_lava"),
FALLING_LAVA("minecraft:falling_lava"),
LANDING_LAVA("minecraft:landing_lava"),
DRIPPING_WATER("minecraft:dripping_water"),
FALLING_WATER("minecraft:falling_water"),
DUST("minecraft:dust"),
EFFECT("minecraft:effect"),
ELDER_GUARDIAN("minecraft:elder_guardian"),
ENCHANTED_HIT("minecraft:enchanted_hit"),
ENCHANT("minecraft:enchant"),
END_ROD("minecraft:end_rod"),
ENTITY_EFFECT("minecraft:entity_effect"),
EXPLOSION_EMITTER("minecraft:explosion_emitter"),
EXPLOSION("minecraft:explosion"),
FALLING_DUST("minecraft:falling_dust"),
FIREWORK("minecraft:firework"),
FISHING("minecraft:fishing"),
FLAME("minecraft:flame"),
SOUL_FIRE_FLAME("minecraft:soul_fire_flame"),
SOUL("minecraft:soul"),
FLASH("minecraft:flash"),
HAPPY_VILLAGER("minecraft:happy_villager"),
COMPOSTER("minecraft:composter"),
HEART("minecraft:heart"),
INSTANT_EFFECT("minecraft:instant_effect"),
ITEM("minecraft:item"),
ITEM_SLIME("minecraft:item_slime"),
ITEM_SNOWBALL("minecraft:item_snowball"),
LARGE_SMOKE("minecraft:large_smoke"),
LAVA("minecraft:lava"),
MYCELIUM("minecraft:mycelium"),
NOTE("minecraft:note"),
POOF("minecraft:poof"),
PORTAL("minecraft:portal"),
RAIN("minecraft:rain"),
SMOKE("minecraft:smoke"),
SNEEZE("minecraft:sneeze"),
SPIT("minecraft:spit"),
SQUID_INK("minecraft:squid_ink"),
SWEEP_ATTACK("minecraft:sweep_attack"),
TOTEM_OF_UNDYING("minecraft:totem_of_undying"),
UNDERWATER("minecraft:underwater"),
SPLASH("minecraft:splash"),
WITCH("minecraft:witch"),
BUBBLE_POP("minecraft:bubble_pop"),
CURRENT_DOWN("minecraft:current_down"),
BUBBLE_COLUMN_UP("minecraft:bubble_column_up"),
NAUTILUS("minecraft:nautilus"),
DOLPHIN("minecraft:dolphin"),
CAMPFIRE_COSY_SMOKE("minecraft:campfire_cosy_smoke"),
CAMPFIRE_SIGNAL_SMOKE("minecraft:campfire_signal_smoke"),
DRIPPING_HONEY("minecraft:dripping_honey"),
FALLING_HONEY("minecraft:falling_honey"),
LANDING_HONEY("minecraft:landing_honey"),
FALLING_NECTAR("minecraft:falling_nectar"),
ASH("minecraft:ash"),
CRIMSON_SPORE("minecraft:crimson_spore"),
WARPED_SPORE("minecraft:warped_spore"),
DRIPPING_OBSIDIAN_TEAR("minecraft:dripping_obsidian_tear"),
FALLING_OBSIDIAN_TEAR("minecraft:falling_obsidian_tear"),
LANDING_OBSIDIAN_TEAR("minecraft:landing_obsidian_tear"),
REVERSE_PORTAL("minecraft:reverse_portal"),
WHITE_ASH("minecraft:white_ash");
private String namespaceID;
Particle(String namespaceID) {
this.namespaceID = namespaceID;
Registries.particles.put(NamespaceID.from(namespaceID), this);
}
public int getId() {
return ordinal();
}
public String getNamespaceID() {
return namespaceID;
}
public static Particle fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return null;
}
}

View File

@ -1,47 +1,79 @@
//==============================
// AUTOGENERATED BY EnumGenerator
//==============================
package net.minestom.server.potion;
import net.minestom.server.registry.Registries;
import net.minestom.server.utils.NamespaceID;
/**
* //==============================
* // AUTOGENERATED BY EnumGenerator
* //==============================
*/
@SuppressWarnings({"deprecation"})
public enum PotionEffect {
SPEED("minecraft:speed"),
SLOWNESS("minecraft:slowness"),
HASTE("minecraft:haste"),
MINING_FATIGUE("minecraft:mining_fatigue"),
STRENGTH("minecraft:strength"),
INSTANT_HEALTH("minecraft:instant_health"),
INSTANT_DAMAGE("minecraft:instant_damage"),
JUMP_BOOST("minecraft:jump_boost"),
NAUSEA("minecraft:nausea"),
REGENERATION("minecraft:regeneration"),
RESISTANCE("minecraft:resistance"),
FIRE_RESISTANCE("minecraft:fire_resistance"),
WATER_BREATHING("minecraft:water_breathing"),
INVISIBILITY("minecraft:invisibility"),
BLINDNESS("minecraft:blindness"),
NIGHT_VISION("minecraft:night_vision"),
HUNGER("minecraft:hunger"),
WEAKNESS("minecraft:weakness"),
POISON("minecraft:poison"),
WITHER("minecraft:wither"),
HEALTH_BOOST("minecraft:health_boost"),
ABSORPTION("minecraft:absorption"),
SATURATION("minecraft:saturation"),
GLOWING("minecraft:glowing"),
LEVITATION("minecraft:levitation"),
LUCK("minecraft:luck"),
UNLUCK("minecraft:unluck"),
SLOW_FALLING("minecraft:slow_falling"),
CONDUIT_POWER("minecraft:conduit_power"),
DOLPHINS_GRACE("minecraft:dolphins_grace"),
BAD_OMEN("minecraft:bad_omen"),
HERO_OF_THE_VILLAGE("minecraft:hero_of_the_village"),
;
HERO_OF_THE_VILLAGE("minecraft:hero_of_the_village");
private String namespaceID;
PotionEffect(String namespaceID) {
@ -58,7 +90,7 @@ public enum PotionEffect {
}
public static PotionEffect fromId(int id) {
if (id >= 0 && id < values().length) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return null;

View File

@ -1,75 +1,120 @@
//==============================
// AUTOGENERATED BY EnumGenerator
//==============================
package net.minestom.server.potion;
import net.minestom.server.registry.Registries;
import net.minestom.server.utils.NamespaceID;
/**
* //==============================
* // AUTOGENERATED BY EnumGenerator
* //==============================
*/
@SuppressWarnings({"deprecation"})
public enum PotionType {
EMPTY("minecraft:empty"),
WATER("minecraft:water"),
MUNDANE("minecraft:mundane"),
THICK("minecraft:thick"),
AWKWARD("minecraft:awkward"),
NIGHT_VISION("minecraft:night_vision"),
LONG_NIGHT_VISION("minecraft:long_night_vision"),
INVISIBILITY("minecraft:invisibility"),
LONG_INVISIBILITY("minecraft:long_invisibility"),
LEAPING("minecraft:leaping"),
LONG_LEAPING("minecraft:long_leaping"),
STRONG_LEAPING("minecraft:strong_leaping"),
FIRE_RESISTANCE("minecraft:fire_resistance"),
LONG_FIRE_RESISTANCE("minecraft:long_fire_resistance"),
SWIFTNESS("minecraft:swiftness"),
LONG_SWIFTNESS("minecraft:long_swiftness"),
STRONG_SWIFTNESS("minecraft:strong_swiftness"),
SLOWNESS("minecraft:slowness"),
LONG_SLOWNESS("minecraft:long_slowness"),
STRONG_SLOWNESS("minecraft:strong_slowness"),
TURTLE_MASTER("minecraft:turtle_master"),
LONG_TURTLE_MASTER("minecraft:long_turtle_master"),
STRONG_TURTLE_MASTER("minecraft:strong_turtle_master"),
WATER_BREATHING("minecraft:water_breathing"),
LONG_WATER_BREATHING("minecraft:long_water_breathing"),
HEALING("minecraft:healing"),
STRONG_HEALING("minecraft:strong_healing"),
HARMING("minecraft:harming"),
STRONG_HARMING("minecraft:strong_harming"),
POISON("minecraft:poison"),
LONG_POISON("minecraft:long_poison"),
STRONG_POISON("minecraft:strong_poison"),
REGENERATION("minecraft:regeneration"),
LONG_REGENERATION("minecraft:long_regeneration"),
STRONG_REGENERATION("minecraft:strong_regeneration"),
STRENGTH("minecraft:strength"),
LONG_STRENGTH("minecraft:long_strength"),
STRONG_STRENGTH("minecraft:strong_strength"),
WEAKNESS("minecraft:weakness"),
LONG_WEAKNESS("minecraft:long_weakness"),
LUCK("minecraft:luck"),
SLOW_FALLING("minecraft:slow_falling"),
LONG_SLOW_FALLING("minecraft:long_slow_falling"),
;
private String namespaceID;
EMPTY("minecraft:empty"),
PotionType(String namespaceID) {
this.namespaceID = namespaceID;
Registries.potionTypes.put(NamespaceID.from(namespaceID), this);
}
WATER("minecraft:water"),
public int getId() {
return ordinal();
}
MUNDANE("minecraft:mundane"),
public String getNamespaceID() {
return namespaceID;
}
THICK("minecraft:thick"),
public static PotionType fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return EMPTY;
}
AWKWARD("minecraft:awkward"),
NIGHT_VISION("minecraft:night_vision"),
LONG_NIGHT_VISION("minecraft:long_night_vision"),
INVISIBILITY("minecraft:invisibility"),
LONG_INVISIBILITY("minecraft:long_invisibility"),
LEAPING("minecraft:leaping"),
LONG_LEAPING("minecraft:long_leaping"),
STRONG_LEAPING("minecraft:strong_leaping"),
FIRE_RESISTANCE("minecraft:fire_resistance"),
LONG_FIRE_RESISTANCE("minecraft:long_fire_resistance"),
SWIFTNESS("minecraft:swiftness"),
LONG_SWIFTNESS("minecraft:long_swiftness"),
STRONG_SWIFTNESS("minecraft:strong_swiftness"),
SLOWNESS("minecraft:slowness"),
LONG_SLOWNESS("minecraft:long_slowness"),
STRONG_SLOWNESS("minecraft:strong_slowness"),
TURTLE_MASTER("minecraft:turtle_master"),
LONG_TURTLE_MASTER("minecraft:long_turtle_master"),
STRONG_TURTLE_MASTER("minecraft:strong_turtle_master"),
WATER_BREATHING("minecraft:water_breathing"),
LONG_WATER_BREATHING("minecraft:long_water_breathing"),
HEALING("minecraft:healing"),
STRONG_HEALING("minecraft:strong_healing"),
HARMING("minecraft:harming"),
STRONG_HARMING("minecraft:strong_harming"),
POISON("minecraft:poison"),
LONG_POISON("minecraft:long_poison"),
STRONG_POISON("minecraft:strong_poison"),
REGENERATION("minecraft:regeneration"),
LONG_REGENERATION("minecraft:long_regeneration"),
STRONG_REGENERATION("minecraft:strong_regeneration"),
STRENGTH("minecraft:strength"),
LONG_STRENGTH("minecraft:long_strength"),
STRONG_STRENGTH("minecraft:strong_strength"),
WEAKNESS("minecraft:weakness"),
LONG_WEAKNESS("minecraft:long_weakness"),
LUCK("minecraft:luck"),
SLOW_FALLING("minecraft:slow_falling"),
LONG_SLOW_FALLING("minecraft:long_slow_falling");
private String namespaceID;
PotionType(String namespaceID) {
this.namespaceID = namespaceID;
Registries.potionTypes.put(NamespaceID.from(namespaceID), this);
}
public int getId() {
return ordinal();
}
public String getNamespaceID() {
return namespaceID;
}
public static PotionType fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return EMPTY;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,106 +1,182 @@
//==============================
// AUTOGENERATED BY EnumGenerator
//==============================
package net.minestom.server.stat;
import net.minestom.server.registry.Registries;
import net.minestom.server.utils.NamespaceID;
/**
* //==============================
* // AUTOGENERATED BY EnumGenerator
* //==============================
*/
@SuppressWarnings({"deprecation"})
public enum StatisticType {
LEAVE_GAME("minecraft:leave_game"),
PLAY_ONE_MINUTE("minecraft:play_one_minute"),
TIME_SINCE_DEATH("minecraft:time_since_death"),
TIME_SINCE_REST("minecraft:time_since_rest"),
SNEAK_TIME("minecraft:sneak_time"),
WALK_ONE_CM("minecraft:walk_one_cm"),
CROUCH_ONE_CM("minecraft:crouch_one_cm"),
SPRINT_ONE_CM("minecraft:sprint_one_cm"),
WALK_ON_WATER_ONE_CM("minecraft:walk_on_water_one_cm"),
FALL_ONE_CM("minecraft:fall_one_cm"),
CLIMB_ONE_CM("minecraft:climb_one_cm"),
FLY_ONE_CM("minecraft:fly_one_cm"),
WALK_UNDER_WATER_ONE_CM("minecraft:walk_under_water_one_cm"),
MINECART_ONE_CM("minecraft:minecart_one_cm"),
BOAT_ONE_CM("minecraft:boat_one_cm"),
PIG_ONE_CM("minecraft:pig_one_cm"),
HORSE_ONE_CM("minecraft:horse_one_cm"),
AVIATE_ONE_CM("minecraft:aviate_one_cm"),
SWIM_ONE_CM("minecraft:swim_one_cm"),
STRIDER_ONE_CM("minecraft:strider_one_cm"),
JUMP("minecraft:jump"),
DROP("minecraft:drop"),
DAMAGE_DEALT("minecraft:damage_dealt"),
DAMAGE_DEALT_ABSORBED("minecraft:damage_dealt_absorbed"),
DAMAGE_DEALT_RESISTED("minecraft:damage_dealt_resisted"),
DAMAGE_TAKEN("minecraft:damage_taken"),
DAMAGE_BLOCKED_BY_SHIELD("minecraft:damage_blocked_by_shield"),
DAMAGE_ABSORBED("minecraft:damage_absorbed"),
DAMAGE_RESISTED("minecraft:damage_resisted"),
DEATHS("minecraft:deaths"),
MOB_KILLS("minecraft:mob_kills"),
ANIMALS_BRED("minecraft:animals_bred"),
PLAYER_KILLS("minecraft:player_kills"),
FISH_CAUGHT("minecraft:fish_caught"),
TALKED_TO_VILLAGER("minecraft:talked_to_villager"),
TRADED_WITH_VILLAGER("minecraft:traded_with_villager"),
EAT_CAKE_SLICE("minecraft:eat_cake_slice"),
FILL_CAULDRON("minecraft:fill_cauldron"),
USE_CAULDRON("minecraft:use_cauldron"),
CLEAN_ARMOR("minecraft:clean_armor"),
CLEAN_BANNER("minecraft:clean_banner"),
CLEAN_SHULKER_BOX("minecraft:clean_shulker_box"),
INTERACT_WITH_BREWINGSTAND("minecraft:interact_with_brewingstand"),
INTERACT_WITH_BEACON("minecraft:interact_with_beacon"),
INSPECT_DROPPER("minecraft:inspect_dropper"),
INSPECT_HOPPER("minecraft:inspect_hopper"),
INSPECT_DISPENSER("minecraft:inspect_dispenser"),
PLAY_NOTEBLOCK("minecraft:play_noteblock"),
TUNE_NOTEBLOCK("minecraft:tune_noteblock"),
POT_FLOWER("minecraft:pot_flower"),
TRIGGER_TRAPPED_CHEST("minecraft:trigger_trapped_chest"),
OPEN_ENDERCHEST("minecraft:open_enderchest"),
ENCHANT_ITEM("minecraft:enchant_item"),
PLAY_RECORD("minecraft:play_record"),
INTERACT_WITH_FURNACE("minecraft:interact_with_furnace"),
INTERACT_WITH_CRAFTING_TABLE("minecraft:interact_with_crafting_table"),
OPEN_CHEST("minecraft:open_chest"),
SLEEP_IN_BED("minecraft:sleep_in_bed"),
OPEN_SHULKER_BOX("minecraft:open_shulker_box"),
OPEN_BARREL("minecraft:open_barrel"),
INTERACT_WITH_BLAST_FURNACE("minecraft:interact_with_blast_furnace"),
INTERACT_WITH_SMOKER("minecraft:interact_with_smoker"),
INTERACT_WITH_LECTERN("minecraft:interact_with_lectern"),
INTERACT_WITH_CAMPFIRE("minecraft:interact_with_campfire"),
INTERACT_WITH_CARTOGRAPHY_TABLE("minecraft:interact_with_cartography_table"),
INTERACT_WITH_LOOM("minecraft:interact_with_loom"),
INTERACT_WITH_STONECUTTER("minecraft:interact_with_stonecutter"),
BELL_RING("minecraft:bell_ring"),
RAID_TRIGGER("minecraft:raid_trigger"),
RAID_WIN("minecraft:raid_win"),
INTERACT_WITH_ANVIL("minecraft:interact_with_anvil"),
INTERACT_WITH_GRINDSTONE("minecraft:interact_with_grindstone"),
TARGET_HIT("minecraft:target_hit"),
INTERACT_WITH_SMITHING_TABLE("minecraft:interact_with_smithing_table"),
;
private String namespaceID;
LEAVE_GAME("minecraft:leave_game"),
StatisticType(String namespaceID) {
this.namespaceID = namespaceID;
Registries.statisticTypes.put(NamespaceID.from(namespaceID), this);
}
PLAY_ONE_MINUTE("minecraft:play_one_minute"),
public int getId() {
return ordinal();
}
TIME_SINCE_DEATH("minecraft:time_since_death"),
public String getNamespaceID() {
return namespaceID;
}
TIME_SINCE_REST("minecraft:time_since_rest"),
public static StatisticType fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return null;
}
SNEAK_TIME("minecraft:sneak_time"),
WALK_ONE_CM("minecraft:walk_one_cm"),
CROUCH_ONE_CM("minecraft:crouch_one_cm"),
SPRINT_ONE_CM("minecraft:sprint_one_cm"),
WALK_ON_WATER_ONE_CM("minecraft:walk_on_water_one_cm"),
FALL_ONE_CM("minecraft:fall_one_cm"),
CLIMB_ONE_CM("minecraft:climb_one_cm"),
FLY_ONE_CM("minecraft:fly_one_cm"),
WALK_UNDER_WATER_ONE_CM("minecraft:walk_under_water_one_cm"),
MINECART_ONE_CM("minecraft:minecart_one_cm"),
BOAT_ONE_CM("minecraft:boat_one_cm"),
PIG_ONE_CM("minecraft:pig_one_cm"),
HORSE_ONE_CM("minecraft:horse_one_cm"),
AVIATE_ONE_CM("minecraft:aviate_one_cm"),
SWIM_ONE_CM("minecraft:swim_one_cm"),
STRIDER_ONE_CM("minecraft:strider_one_cm"),
JUMP("minecraft:jump"),
DROP("minecraft:drop"),
DAMAGE_DEALT("minecraft:damage_dealt"),
DAMAGE_DEALT_ABSORBED("minecraft:damage_dealt_absorbed"),
DAMAGE_DEALT_RESISTED("minecraft:damage_dealt_resisted"),
DAMAGE_TAKEN("minecraft:damage_taken"),
DAMAGE_BLOCKED_BY_SHIELD("minecraft:damage_blocked_by_shield"),
DAMAGE_ABSORBED("minecraft:damage_absorbed"),
DAMAGE_RESISTED("minecraft:damage_resisted"),
DEATHS("minecraft:deaths"),
MOB_KILLS("minecraft:mob_kills"),
ANIMALS_BRED("minecraft:animals_bred"),
PLAYER_KILLS("minecraft:player_kills"),
FISH_CAUGHT("minecraft:fish_caught"),
TALKED_TO_VILLAGER("minecraft:talked_to_villager"),
TRADED_WITH_VILLAGER("minecraft:traded_with_villager"),
EAT_CAKE_SLICE("minecraft:eat_cake_slice"),
FILL_CAULDRON("minecraft:fill_cauldron"),
USE_CAULDRON("minecraft:use_cauldron"),
CLEAN_ARMOR("minecraft:clean_armor"),
CLEAN_BANNER("minecraft:clean_banner"),
CLEAN_SHULKER_BOX("minecraft:clean_shulker_box"),
INTERACT_WITH_BREWINGSTAND("minecraft:interact_with_brewingstand"),
INTERACT_WITH_BEACON("minecraft:interact_with_beacon"),
INSPECT_DROPPER("minecraft:inspect_dropper"),
INSPECT_HOPPER("minecraft:inspect_hopper"),
INSPECT_DISPENSER("minecraft:inspect_dispenser"),
PLAY_NOTEBLOCK("minecraft:play_noteblock"),
TUNE_NOTEBLOCK("minecraft:tune_noteblock"),
POT_FLOWER("minecraft:pot_flower"),
TRIGGER_TRAPPED_CHEST("minecraft:trigger_trapped_chest"),
OPEN_ENDERCHEST("minecraft:open_enderchest"),
ENCHANT_ITEM("minecraft:enchant_item"),
PLAY_RECORD("minecraft:play_record"),
INTERACT_WITH_FURNACE("minecraft:interact_with_furnace"),
INTERACT_WITH_CRAFTING_TABLE("minecraft:interact_with_crafting_table"),
OPEN_CHEST("minecraft:open_chest"),
SLEEP_IN_BED("minecraft:sleep_in_bed"),
OPEN_SHULKER_BOX("minecraft:open_shulker_box"),
OPEN_BARREL("minecraft:open_barrel"),
INTERACT_WITH_BLAST_FURNACE("minecraft:interact_with_blast_furnace"),
INTERACT_WITH_SMOKER("minecraft:interact_with_smoker"),
INTERACT_WITH_LECTERN("minecraft:interact_with_lectern"),
INTERACT_WITH_CAMPFIRE("minecraft:interact_with_campfire"),
INTERACT_WITH_CARTOGRAPHY_TABLE("minecraft:interact_with_cartography_table"),
INTERACT_WITH_LOOM("minecraft:interact_with_loom"),
INTERACT_WITH_STONECUTTER("minecraft:interact_with_stonecutter"),
BELL_RING("minecraft:bell_ring"),
RAID_TRIGGER("minecraft:raid_trigger"),
RAID_WIN("minecraft:raid_win"),
INTERACT_WITH_ANVIL("minecraft:interact_with_anvil"),
INTERACT_WITH_GRINDSTONE("minecraft:interact_with_grindstone"),
TARGET_HIT("minecraft:target_hit"),
INTERACT_WITH_SMITHING_TABLE("minecraft:interact_with_smithing_table");
private String namespaceID;
StatisticType(String namespaceID) {
this.namespaceID = namespaceID;
Registries.statisticTypes.put(NamespaceID.from(namespaceID), this);
}
public int getId() {
return ordinal();
}
public String getNamespaceID() {
return namespaceID;
}
public static StatisticType fromId(int id) {
if(id >= 0 && id < values().length) {
return values()[id];
}
return null;
}
}

View File

@ -60,7 +60,7 @@ public abstract class BasicEnumGenerator extends MinestomEnumGenerator<BasicEnum
ParameterSpec[] signature = new ParameterSpec[]{idParam};
if (linear) {
generator.addStaticMethod("fromId", signature, className, code -> {
code.beginControlFlow("if($N >= 0 && $N < values().length) {", idParam, idParam)
code.beginControlFlow("if($N >= 0 && $N < values().length)", idParam, idParam)
.addStatement("return values()[$N]", idParam)
.endControlFlow()
.addStatement("return " + (defaultEntry == null ? "null" : identifier(defaultEntry)));
@ -68,8 +68,8 @@ public abstract class BasicEnumGenerator extends MinestomEnumGenerator<BasicEnum
);
} else {
generator.addStaticMethod("fromId", signature, className, code -> {
code.beginControlFlow("for($T o : values()) {")
.beginControlFlow("if(o.getId() == id) {")
code.beginControlFlow("for($T o : values())")
.beginControlFlow("if(o.getId() == id)")
.addStatement("return o")
.endControlFlow()
.endControlFlow()
@ -102,7 +102,7 @@ public abstract class BasicEnumGenerator extends MinestomEnumGenerator<BasicEnum
generator.addMethod("getNamespaceID", new ParameterSpec[0], ClassName.get(String.class), code -> code.addStatement("return $N", "namespaceID"));
generator.appendToConstructor(code -> {
code.addStatement("$T." + CodeGenerator.decapitalize(getClassName()) + "s.put(NamespaceID.from($N), this)", registriesClass, "namespaceID");
code.addStatement("$T." + CodeGenerator.decapitalize(getClassName()) + "s.put($T.from($N), this)", registriesClass, NamespaceID.class, "namespaceID");
});
}

View File

@ -3,8 +3,7 @@ package net.minestom.codegen.items;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.squareup.javapoet.AnnotationSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.*;
import net.minestom.codegen.EnumGenerator;
import net.minestom.codegen.MinestomEnumGenerator;
import net.minestom.codegen.PrismarinePaths;
@ -12,6 +11,8 @@ import net.minestom.server.instance.block.Block;
import net.minestom.server.registry.Registries;
import net.minestom.server.registry.ResourceGatherer;
import net.minestom.server.utils.NamespaceID;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -138,82 +139,87 @@ public class ItemEnumGenerator extends MinestomEnumGenerator<ItemContainer> {
@Override
protected void prepare(EnumGenerator generator) {
String className = getClassName();
ClassName className = ClassName.get(getPackageName(), getClassName());
generator.addClassAnnotation(AnnotationSpec.builder(SuppressWarnings.class).addMember("value", "{$S}", "deprecation").build());
/*generator.setParams("String namespaceID", "int maxDefaultStackSize", "Block correspondingBlock");
generator.appendToConstructor("Registries.materials.put(NamespaceID.from(namespaceID), this);");
generator.setParams(ParameterSpec.builder(String.class, "namespaceID").addAnnotation(NotNull.class).build(), ParameterSpec.builder(TypeName.INT, "maxDefaultStackSize").build(),
ParameterSpec.builder(Block.class, "correspondingBlock").addAnnotation(Nullable.class).build());
generator.appendToConstructor(code -> {
code.addStatement("$T.$N.put($T.from(namespaceID), this)", Registries.class, "materials", NamespaceID.class);
});
generator.addMethod("getId", "()", "short", "return (short)ordinal();");
generator.addMethod("getName", "()", "String", "return namespaceID;");
generator.addMethod("getMaxDefaultStackSize", "()", "int", "return maxDefaultStackSize;");
generator.addMethod("isBlock", "()", "boolean", "return correspondingBlock != null && this != AIR;");
generator.addMethod("getBlock", "()", "Block", "return correspondingBlock;");
generator.addMethod("getId", new ParameterSpec[0], TypeName.SHORT, code -> { code.addStatement("return (short)ordinal()");});
generator.addMethod("getName", new ParameterSpec[0], ClassName.get(String.class), code -> { code.addStatement("return namespaceID");});
generator.addMethod("getMaxDefaultStackSize", new ParameterSpec[0], TypeName.INT, code -> { code.addStatement("return maxDefaultStackSize");});
generator.addMethod("isBlock", new ParameterSpec[0], TypeName.BOOLEAN, code -> { code.addStatement("return correspondingBlock != null && this != AIR");});
generator.addMethod("getBlock", new ParameterSpec[0], ClassName.get(Block.class), code -> { code.addStatement("return correspondingBlock");});
generator.addMethod("fromId", "(short id)", "static " + className,
"if(id >= 0 && id < values().length) {",
"\treturn values()[id];",
"}",
"return AIR;"
);
generator.addStaticMethod("fromId", new ParameterSpec[]{ParameterSpec.builder(TypeName.SHORT, "id").build()}, className, code -> {
code.beginControlFlow("if(id >= 0 && id < values().length)")
.addStatement("return values()[id]")
.endControlFlow()
.addStatement("return AIR");
});
// hard coded methods
generator.addMethod("isHelmet", "()", "boolean", "return toString().endsWith(\"HELMET\");");
generator.addMethod("isChestplate", "()", "boolean", "return toString().endsWith(\"CHESTPLATE\");");
generator.addMethod("isLeggings", "()", "boolean", "return toString().endsWith(\"LEGGINGS\");");
generator.addMethod("isBoots", "()", "boolean", "return toString().endsWith(\"BOOTS\");");
generator.addMethod("isArmor", "()", "boolean", "return isChestplate() || isHelmet() || isLeggings() || isBoots();");
generator.addMethod("isFood", "()", "boolean", "switch (this) {\n" +
" case APPLE:\n" +
" case MUSHROOM_STEW:\n" +
" case BREAD:\n" +
" case PORKCHOP:\n" +
" case COOKED_PORKCHOP:\n" +
" case GOLDEN_APPLE:\n" +
" case ENCHANTED_GOLDEN_APPLE:\n" +
" case COD:\n" +
" case SALMON:\n" +
" case TROPICAL_FISH:\n" +
" case PUFFERFISH:\n" +
" case COOKED_COD:\n" +
" case COOKED_SALMON:\n" +
" case CAKE:\n" +
" case COOKIE:\n" +
" case MELON_SLICE:\n" +
" case DRIED_KELP:\n" +
" case BEEF:\n" +
" case COOKED_BEEF:\n" +
" case CHICKEN:\n" +
" case COOKED_CHICKEN:\n" +
" case ROTTEN_FLESH:\n" +
" case SPIDER_EYE:\n" +
" case CARROT:\n" +
" case POTATO:\n" +
" case BAKED_POTATO:\n" +
" case POISONOUS_POTATO:\n" +
" case PUMPKIN_PIE:\n" +
" case RABBIT:\n" +
" case COOKED_RABBIT:\n" +
" case RABBIT_STEW:\n" +
" case MUTTON:\n" +
" case COOKED_MUTTON:\n" +
" case BEETROOT:\n" +
" case BEETROOT_SOUP:\n" +
" case SWEET_BERRIES:\n" +
" case HONEY_BOTTLE:\n" +
" case CHORUS_FRUIT:\n" +
" return true;\n" +
" default:\n" +
" return false;\n" +
" }");
generator.addMethod("hasState", "()", "boolean", "switch (this) {\n" +
" case BOW:\n" +
" case TRIDENT:\n" +
" case CROSSBOW:\n" +
" case SHIELD:\n" +
" return true;\n" +
" }\n" +
"\n" +
" return isFood();");*/
generator.addMethod("isHelmet", new ParameterSpec[0], TypeName.BOOLEAN, code -> { code.addStatement("return toString().endsWith(\"HELMET\")");});
generator.addMethod("isChestplate", new ParameterSpec[0], TypeName.BOOLEAN, code -> { code.addStatement("return toString().endsWith(\"CHESTPLATE\")");});
generator.addMethod("isLeggings", new ParameterSpec[0], TypeName.BOOLEAN, code -> { code.addStatement("return toString().endsWith(\"LEGGINGS\")");});
generator.addMethod("isBoots", new ParameterSpec[0], TypeName.BOOLEAN, code -> { code.addStatement("return toString().endsWith(\"BOOTS\")");});
generator.addMethod("isArmor", new ParameterSpec[0], TypeName.BOOLEAN, code -> { code.addStatement("return isChestplate() || isHelmet() || isLeggings() || isBoots()");});
generator.addMethod("isFood", new ParameterSpec[0], TypeName.BOOLEAN, code -> {
code.beginControlFlow("switch(this)")
.add("case APPLE:\n")
.add("case MUSHROOM_STEW:\n")
.add("case BREAD:\n")
.add("case PORKCHOP:\n")
.add("case COOKED_PORKCHOP:\n")
.add("case GOLDEN_APPLE:\n")
.add("case ENCHANTED_GOLDEN_APPLE:\n")
.add("case COD:\n")
.add("case SALMON:\n")
.add("case TROPICAL_FISH:\n")
.add("case PUFFERFISH:\n")
.add("case COOKED_COD:\n")
.add("case COOKED_SALMON:\n")
.add("case CAKE:\n")
.add("case COOKIE:\n")
.add("case MELON_SLICE:\n")
.add("case DRIED_KELP:\n")
.add("case BEEF:\n")
.add("case COOKED_BEEF:\n")
.add("case CHICKEN:\n")
.add("case COOKED_CHICKEN:\n")
.add("case ROTTEN_FLESH:\n")
.add("case SPIDER_EYE:\n")
.add("case CARROT:\n")
.add("case POTATO:\n")
.add("case BAKED_POTATO:\n")
.add("case POISONOUS_POTATO:\n")
.add("case PUMPKIN_PIE:\n")
.add("case RABBIT:\n")
.add("case COOKED_RABBIT:\n")
.add("case RABBIT_STEW:\n")
.add("case MUTTON:\n")
.add("case COOKED_MUTTON:\n")
.add("case BEETROOT:\n")
.add("case BEETROOT_SOUP:\n")
.add("case SWEET_BERRIES:\n")
.add("case HONEY_BOTTLE:\n")
.add("case CHORUS_FRUIT:\n")
.addStatement("return true")
.endControlFlow()
.addStatement("return false");
});
generator.addMethod("hasState", new ParameterSpec[0], TypeName.BOOLEAN, code -> {
code.beginControlFlow("switch(this)")
.add("case BOW:\n")
.add("case TRIDENT:\n")
.add("case CROSSBOW:\n")
.add("case SHIELD:\n")
.addStatement("return true")
.endControlFlow()
.addStatement("return isFood()");
});
}
@Override