mirror of https://github.com/PaperMC/Paper.git
switch to partial generation
This commit is contained in:
parent
06926486bf
commit
62f8b35767
|
@ -24,7 +24,8 @@ tasks.register<JavaExec>("generate") {
|
|||
dependsOn(tasks.check)
|
||||
mainClass.set("io.papermc.generator.Main")
|
||||
classpath(sourceSets.main.map { it.runtimeClasspath })
|
||||
args(projectDir.toPath().resolve("generated").toString())
|
||||
args(file("generated").toString(),
|
||||
project(":paper-api").sourceSets["main"].java.srcDirs.first().toString())
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package org.bukkit;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a fluid type.
|
||||
*/
|
||||
public enum Fluid implements Keyed {
|
||||
|
||||
// Paper start - Generated/Fluid
|
||||
// @GeneratedFrom 1.20.4
|
||||
EMPTY,
|
||||
FLOWING_LAVA,
|
||||
FLOWING_WATER,
|
||||
LAVA,
|
||||
WATER;
|
||||
// Paper end - Generated/Fluid
|
||||
|
||||
private final NamespacedKey key;
|
||||
|
||||
private Fluid() {
|
||||
this.key = NamespacedKey.minecraft(this.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,69 +1,47 @@
|
|||
package org.bukkit.attribute;
|
||||
|
||||
import io.papermc.paper.generated.GeneratedFrom;
|
||||
import net.kyori.adventure.translation.Translatable;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Vanilla keys for Attributes.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
* changed (including removals) on any Minecraft version
|
||||
* bump, so cross-version compatibility is not provided on the
|
||||
* same level as it is on most of the other API.
|
||||
* Types of attributes which may be present on an {@link Attributable}.
|
||||
*/
|
||||
@SuppressWarnings({
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@GeneratedFrom("1.20.4")
|
||||
public enum Attribute implements Keyed, Translatable {
|
||||
public enum Attribute implements Keyed, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
|
||||
|
||||
// Paper start - Generated/Attribute
|
||||
// @GeneratedFrom 1.20.4
|
||||
GENERIC_ARMOR("generic.armor"),
|
||||
|
||||
GENERIC_ARMOR_TOUGHNESS("generic.armor_toughness"),
|
||||
|
||||
GENERIC_ATTACK_DAMAGE("generic.attack_damage"),
|
||||
|
||||
GENERIC_ATTACK_KNOCKBACK("generic.attack_knockback"),
|
||||
|
||||
GENERIC_ATTACK_SPEED("generic.attack_speed"),
|
||||
|
||||
GENERIC_FLYING_SPEED("generic.flying_speed"),
|
||||
|
||||
GENERIC_FOLLOW_RANGE("generic.follow_range"),
|
||||
|
||||
GENERIC_KNOCKBACK_RESISTANCE("generic.knockback_resistance"),
|
||||
|
||||
GENERIC_LUCK("generic.luck"),
|
||||
|
||||
GENERIC_MAX_ABSORPTION("generic.max_absorption"),
|
||||
|
||||
GENERIC_MAX_HEALTH("generic.max_health"),
|
||||
|
||||
GENERIC_MOVEMENT_SPEED("generic.movement_speed"),
|
||||
|
||||
HORSE_JUMP_STRENGTH("horse.jump_strength"),
|
||||
|
||||
ZOMBIE_SPAWN_REINFORCEMENTS("zombie.spawn_reinforcements");
|
||||
// Paper end - Generated/Attribute
|
||||
|
||||
private final NamespacedKey key;
|
||||
|
||||
Attribute(String key) {
|
||||
private Attribute(String key) {
|
||||
this.key = NamespacedKey.minecraft(key);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return this.key;
|
||||
return key;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
// Paper start
|
||||
@Override
|
||||
public String translationKey() {
|
||||
public @NotNull String translationKey() {
|
||||
return "attribute.name." + this.key.getKey();
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
|
|
@ -1,171 +1,102 @@
|
|||
package org.bukkit.block;
|
||||
|
||||
import io.papermc.paper.generated.GeneratedFrom;
|
||||
import net.kyori.adventure.translation.Translatable;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Vanilla keys for Biomes.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
* changed (including removals) on any Minecraft version
|
||||
* bump, so cross-version compatibility is not provided on the
|
||||
* same level as it is on most of the other API.
|
||||
* Holds all accepted Biomes in the default server
|
||||
*/
|
||||
@SuppressWarnings({
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@GeneratedFrom("1.20.4")
|
||||
public enum Biome implements Keyed, Translatable {
|
||||
BADLANDS("badlands"),
|
||||
|
||||
BAMBOO_JUNGLE("bamboo_jungle"),
|
||||
|
||||
BASALT_DELTAS("basalt_deltas"),
|
||||
|
||||
BEACH("beach"),
|
||||
|
||||
BIRCH_FOREST("birch_forest"),
|
||||
|
||||
CHERRY_GROVE("cherry_grove"),
|
||||
|
||||
COLD_OCEAN("cold_ocean"),
|
||||
|
||||
CRIMSON_FOREST("crimson_forest"),
|
||||
|
||||
DARK_FOREST("dark_forest"),
|
||||
|
||||
DEEP_COLD_OCEAN("deep_cold_ocean"),
|
||||
|
||||
DEEP_DARK("deep_dark"),
|
||||
|
||||
DEEP_FROZEN_OCEAN("deep_frozen_ocean"),
|
||||
|
||||
DEEP_LUKEWARM_OCEAN("deep_lukewarm_ocean"),
|
||||
|
||||
DEEP_OCEAN("deep_ocean"),
|
||||
|
||||
DESERT("desert"),
|
||||
|
||||
DRIPSTONE_CAVES("dripstone_caves"),
|
||||
|
||||
END_BARRENS("end_barrens"),
|
||||
|
||||
END_HIGHLANDS("end_highlands"),
|
||||
|
||||
END_MIDLANDS("end_midlands"),
|
||||
|
||||
ERODED_BADLANDS("eroded_badlands"),
|
||||
|
||||
FLOWER_FOREST("flower_forest"),
|
||||
|
||||
FOREST("forest"),
|
||||
|
||||
FROZEN_OCEAN("frozen_ocean"),
|
||||
|
||||
FROZEN_PEAKS("frozen_peaks"),
|
||||
|
||||
FROZEN_RIVER("frozen_river"),
|
||||
|
||||
GROVE("grove"),
|
||||
|
||||
ICE_SPIKES("ice_spikes"),
|
||||
|
||||
JAGGED_PEAKS("jagged_peaks"),
|
||||
|
||||
JUNGLE("jungle"),
|
||||
|
||||
LUKEWARM_OCEAN("lukewarm_ocean"),
|
||||
|
||||
LUSH_CAVES("lush_caves"),
|
||||
|
||||
MANGROVE_SWAMP("mangrove_swamp"),
|
||||
|
||||
MEADOW("meadow"),
|
||||
|
||||
MUSHROOM_FIELDS("mushroom_fields"),
|
||||
|
||||
NETHER_WASTES("nether_wastes"),
|
||||
|
||||
OCEAN("ocean"),
|
||||
|
||||
OLD_GROWTH_BIRCH_FOREST("old_growth_birch_forest"),
|
||||
|
||||
OLD_GROWTH_PINE_TAIGA("old_growth_pine_taiga"),
|
||||
|
||||
OLD_GROWTH_SPRUCE_TAIGA("old_growth_spruce_taiga"),
|
||||
|
||||
PLAINS("plains"),
|
||||
|
||||
RIVER("river"),
|
||||
|
||||
SAVANNA("savanna"),
|
||||
|
||||
SAVANNA_PLATEAU("savanna_plateau"),
|
||||
|
||||
SMALL_END_ISLANDS("small_end_islands"),
|
||||
|
||||
SNOWY_BEACH("snowy_beach"),
|
||||
|
||||
SNOWY_PLAINS("snowy_plains"),
|
||||
|
||||
SNOWY_SLOPES("snowy_slopes"),
|
||||
|
||||
SNOWY_TAIGA("snowy_taiga"),
|
||||
|
||||
SOUL_SAND_VALLEY("soul_sand_valley"),
|
||||
|
||||
SPARSE_JUNGLE("sparse_jungle"),
|
||||
|
||||
STONY_PEAKS("stony_peaks"),
|
||||
|
||||
STONY_SHORE("stony_shore"),
|
||||
|
||||
SUNFLOWER_PLAINS("sunflower_plains"),
|
||||
|
||||
SWAMP("swamp"),
|
||||
|
||||
TAIGA("taiga"),
|
||||
|
||||
THE_END("the_end"),
|
||||
|
||||
THE_VOID("the_void"),
|
||||
|
||||
WARM_OCEAN("warm_ocean"),
|
||||
|
||||
WARPED_FOREST("warped_forest"),
|
||||
|
||||
WINDSWEPT_FOREST("windswept_forest"),
|
||||
|
||||
WINDSWEPT_GRAVELLY_HILLS("windswept_gravelly_hills"),
|
||||
|
||||
WINDSWEPT_HILLS("windswept_hills"),
|
||||
|
||||
WINDSWEPT_SAVANNA("windswept_savanna"),
|
||||
|
||||
WOODED_BADLANDS("wooded_badlands"),
|
||||
|
||||
CUSTOM("custom");
|
||||
public enum Biome implements Keyed, net.kyori.adventure.translation.Translatable { // Paper
|
||||
// Paper start - Generated/Biome
|
||||
// @GeneratedFrom 1.20.4
|
||||
BADLANDS,
|
||||
BAMBOO_JUNGLE,
|
||||
BASALT_DELTAS,
|
||||
BEACH,
|
||||
BIRCH_FOREST,
|
||||
CHERRY_GROVE,
|
||||
COLD_OCEAN,
|
||||
CRIMSON_FOREST,
|
||||
DARK_FOREST,
|
||||
DEEP_COLD_OCEAN,
|
||||
DEEP_DARK,
|
||||
DEEP_FROZEN_OCEAN,
|
||||
DEEP_LUKEWARM_OCEAN,
|
||||
DEEP_OCEAN,
|
||||
DESERT,
|
||||
DRIPSTONE_CAVES,
|
||||
END_BARRENS,
|
||||
END_HIGHLANDS,
|
||||
END_MIDLANDS,
|
||||
ERODED_BADLANDS,
|
||||
FLOWER_FOREST,
|
||||
FOREST,
|
||||
FROZEN_OCEAN,
|
||||
FROZEN_PEAKS,
|
||||
FROZEN_RIVER,
|
||||
GROVE,
|
||||
ICE_SPIKES,
|
||||
JAGGED_PEAKS,
|
||||
JUNGLE,
|
||||
LUKEWARM_OCEAN,
|
||||
LUSH_CAVES,
|
||||
MANGROVE_SWAMP,
|
||||
MEADOW,
|
||||
MUSHROOM_FIELDS,
|
||||
NETHER_WASTES,
|
||||
OCEAN,
|
||||
OLD_GROWTH_BIRCH_FOREST,
|
||||
OLD_GROWTH_PINE_TAIGA,
|
||||
OLD_GROWTH_SPRUCE_TAIGA,
|
||||
PLAINS,
|
||||
RIVER,
|
||||
SAVANNA,
|
||||
SAVANNA_PLATEAU,
|
||||
SMALL_END_ISLANDS,
|
||||
SNOWY_BEACH,
|
||||
SNOWY_PLAINS,
|
||||
SNOWY_SLOPES,
|
||||
SNOWY_TAIGA,
|
||||
SOUL_SAND_VALLEY,
|
||||
SPARSE_JUNGLE,
|
||||
STONY_PEAKS,
|
||||
STONY_SHORE,
|
||||
SUNFLOWER_PLAINS,
|
||||
SWAMP,
|
||||
TAIGA,
|
||||
THE_END,
|
||||
THE_VOID,
|
||||
WARM_OCEAN,
|
||||
WARPED_FOREST,
|
||||
WINDSWEPT_FOREST,
|
||||
WINDSWEPT_GRAVELLY_HILLS,
|
||||
WINDSWEPT_HILLS,
|
||||
WINDSWEPT_SAVANNA,
|
||||
WOODED_BADLANDS,
|
||||
// Paper end - Generated/Biome
|
||||
/**
|
||||
* Represents a custom Biome
|
||||
*/
|
||||
CUSTOM;
|
||||
|
||||
private final NamespacedKey key;
|
||||
|
||||
Biome(String key) {
|
||||
this.key = NamespacedKey.minecraft(key);
|
||||
private Biome() {
|
||||
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return this.key;
|
||||
return key;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
// Paper start
|
||||
@Override
|
||||
public String translationKey() {
|
||||
public @NotNull String translationKey() {
|
||||
return "biome.minecraft." + this.key.getKey();
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
|
|
@ -1,277 +0,0 @@
|
|||
package org.bukkit.generator.structure;
|
||||
|
||||
import io.papermc.paper.generated.GeneratedFrom;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.MinecraftExperimental;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Vanilla keys for Structures.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
* changed (including removals) on any Minecraft version
|
||||
* bump, so cross-version compatibility is not provided on the
|
||||
* same level as it is on most of the other API.
|
||||
*/
|
||||
@SuppressWarnings({
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@GeneratedFrom("1.20.4")
|
||||
public abstract class Structure implements Keyed {
|
||||
/**
|
||||
* {@code minecraft:ancient_city}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure ANCIENT_CITY = fetch("ancient_city");
|
||||
|
||||
/**
|
||||
* {@code minecraft:bastion_remnant}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure BASTION_REMNANT = fetch("bastion_remnant");
|
||||
|
||||
/**
|
||||
* {@code minecraft:buried_treasure}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure BURIED_TREASURE = fetch("buried_treasure");
|
||||
|
||||
/**
|
||||
* {@code minecraft:desert_pyramid}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure DESERT_PYRAMID = fetch("desert_pyramid");
|
||||
|
||||
/**
|
||||
* {@code minecraft:end_city}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure END_CITY = fetch("end_city");
|
||||
|
||||
/**
|
||||
* {@code minecraft:fortress}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure FORTRESS = fetch("fortress");
|
||||
|
||||
/**
|
||||
* {@code minecraft:igloo}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure IGLOO = fetch("igloo");
|
||||
|
||||
/**
|
||||
* {@code minecraft:jungle_pyramid}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure JUNGLE_PYRAMID = fetch("jungle_pyramid");
|
||||
|
||||
/**
|
||||
* {@code minecraft:mansion}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure MANSION = fetch("mansion");
|
||||
|
||||
/**
|
||||
* {@code minecraft:mineshaft}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure MINESHAFT = fetch("mineshaft");
|
||||
|
||||
/**
|
||||
* {@code minecraft:mineshaft_mesa}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure MINESHAFT_MESA = fetch("mineshaft_mesa");
|
||||
|
||||
/**
|
||||
* {@code minecraft:monument}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure MONUMENT = fetch("monument");
|
||||
|
||||
/**
|
||||
* {@code minecraft:nether_fossil}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure NETHER_FOSSIL = fetch("nether_fossil");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ocean_ruin_cold}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure OCEAN_RUIN_COLD = fetch("ocean_ruin_cold");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ocean_ruin_warm}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure OCEAN_RUIN_WARM = fetch("ocean_ruin_warm");
|
||||
|
||||
/**
|
||||
* {@code minecraft:pillager_outpost}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure PILLAGER_OUTPOST = fetch("pillager_outpost");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ruined_portal}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure RUINED_PORTAL = fetch("ruined_portal");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ruined_portal_desert}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure RUINED_PORTAL_DESERT = fetch("ruined_portal_desert");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ruined_portal_jungle}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure RUINED_PORTAL_JUNGLE = fetch("ruined_portal_jungle");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ruined_portal_mountain}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure RUINED_PORTAL_MOUNTAIN = fetch("ruined_portal_mountain");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ruined_portal_nether}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure RUINED_PORTAL_NETHER = fetch("ruined_portal_nether");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ruined_portal_ocean}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure RUINED_PORTAL_OCEAN = fetch("ruined_portal_ocean");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ruined_portal_swamp}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure RUINED_PORTAL_SWAMP = fetch("ruined_portal_swamp");
|
||||
|
||||
/**
|
||||
* {@code minecraft:shipwreck}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure SHIPWRECK = fetch("shipwreck");
|
||||
|
||||
/**
|
||||
* {@code minecraft:shipwreck_beached}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure SHIPWRECK_BEACHED = fetch("shipwreck_beached");
|
||||
|
||||
/**
|
||||
* {@code minecraft:stronghold}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure STRONGHOLD = fetch("stronghold");
|
||||
|
||||
/**
|
||||
* {@code minecraft:swamp_hut}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure SWAMP_HUT = fetch("swamp_hut");
|
||||
|
||||
/**
|
||||
* {@code minecraft:trail_ruins}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure TRAIL_RUINS = fetch("trail_ruins");
|
||||
|
||||
/**
|
||||
* {@code minecraft:trial_chambers}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@MinecraftExperimental("update 1.21")
|
||||
public static final Structure TRIAL_CHAMBERS = fetch("trial_chambers");
|
||||
|
||||
/**
|
||||
* {@code minecraft:village_desert}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure VILLAGE_DESERT = fetch("village_desert");
|
||||
|
||||
/**
|
||||
* {@code minecraft:village_plains}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure VILLAGE_PLAINS = fetch("village_plains");
|
||||
|
||||
/**
|
||||
* {@code minecraft:village_savanna}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure VILLAGE_SAVANNA = fetch("village_savanna");
|
||||
|
||||
/**
|
||||
* {@code minecraft:village_snowy}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure VILLAGE_SNOWY = fetch("village_snowy");
|
||||
|
||||
/**
|
||||
* {@code minecraft:village_taiga}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final Structure VILLAGE_TAIGA = fetch("village_taiga");
|
||||
|
||||
private static @NotNull Structure fetch(final @NotNull String key) {
|
||||
return Registry.STRUCTURE.get(NamespacedKey.minecraft(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the structure.
|
||||
*
|
||||
* @return the type of structure
|
||||
*/
|
||||
@NotNull
|
||||
public abstract StructureType getStructureType();
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
package org.bukkit.generator.structure;
|
||||
|
||||
import io.papermc.paper.generated.GeneratedFrom;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Vanilla keys for StructureTypes.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
* changed (including removals) on any Minecraft version
|
||||
* bump, so cross-version compatibility is not provided on the
|
||||
* same level as it is on most of the other API.
|
||||
*/
|
||||
@SuppressWarnings({
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@GeneratedFrom("1.20.4")
|
||||
public abstract class StructureType implements Keyed {
|
||||
/**
|
||||
* {@code minecraft:buried_treasure}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType BURIED_TREASURE = fetch("buried_treasure");
|
||||
|
||||
/**
|
||||
* {@code minecraft:desert_pyramid}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType DESERT_PYRAMID = fetch("desert_pyramid");
|
||||
|
||||
/**
|
||||
* {@code minecraft:end_city}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType END_CITY = fetch("end_city");
|
||||
|
||||
/**
|
||||
* {@code minecraft:fortress}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType FORTRESS = fetch("fortress");
|
||||
|
||||
/**
|
||||
* {@code minecraft:igloo}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType IGLOO = fetch("igloo");
|
||||
|
||||
/**
|
||||
* {@code minecraft:jigsaw}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType JIGSAW = fetch("jigsaw");
|
||||
|
||||
/**
|
||||
* {@code minecraft:jungle_temple}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType JUNGLE_TEMPLE = fetch("jungle_temple");
|
||||
|
||||
/**
|
||||
* {@code minecraft:mineshaft}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType MINESHAFT = fetch("mineshaft");
|
||||
|
||||
/**
|
||||
* {@code minecraft:nether_fossil}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType NETHER_FOSSIL = fetch("nether_fossil");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ocean_monument}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType OCEAN_MONUMENT = fetch("ocean_monument");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ocean_ruin}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType OCEAN_RUIN = fetch("ocean_ruin");
|
||||
|
||||
/**
|
||||
* {@code minecraft:ruined_portal}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType RUINED_PORTAL = fetch("ruined_portal");
|
||||
|
||||
/**
|
||||
* {@code minecraft:shipwreck}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType SHIPWRECK = fetch("shipwreck");
|
||||
|
||||
/**
|
||||
* {@code minecraft:stronghold}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType STRONGHOLD = fetch("stronghold");
|
||||
|
||||
/**
|
||||
* {@code minecraft:swamp_hut}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType SWAMP_HUT = fetch("swamp_hut");
|
||||
|
||||
/**
|
||||
* {@code minecraft:woodland_mansion}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
public static final StructureType WOODLAND_MANSION = fetch("woodland_mansion");
|
||||
|
||||
private static @NotNull StructureType fetch(final @NotNull String key) {
|
||||
return Registry.STRUCTURE_TYPE.get(NamespacedKey.minecraft(key));
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
package org.bukkit.inventory.meta.trim;
|
||||
|
||||
import io.papermc.paper.generated.GeneratedFrom;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Vanilla keys for TrimMaterial.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
* changed (including removals) on any Minecraft version
|
||||
* bump, so cross-version compatibility is not provided on the
|
||||
* same level as it is on most of the other API.
|
||||
*/
|
||||
@SuppressWarnings({
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@GeneratedFrom("1.20.4")
|
||||
public interface TrimMaterial extends Keyed {
|
||||
/**
|
||||
* {@code minecraft:amethyst}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimMaterial AMETHYST = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("amethyst"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:copper}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimMaterial COPPER = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("copper"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:diamond}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimMaterial DIAMOND = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("diamond"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:emerald}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimMaterial EMERALD = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("emerald"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:gold}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimMaterial GOLD = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("gold"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:iron}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimMaterial IRON = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("iron"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:lapis}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimMaterial LAPIS = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("lapis"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:netherite}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimMaterial NETHERITE = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("netherite"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:quartz}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimMaterial QUARTZ = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("quartz"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:redstone}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimMaterial REDSTONE = Registry.TRIM_MATERIAL.get(NamespacedKey.minecraft("redstone"));
|
||||
|
||||
/**
|
||||
* @deprecated use {@link Registry#getKey(Keyed)} and {@link Registry#TRIM_MATERIAL}. TrimMaterial
|
||||
* can exist without a key.
|
||||
*/
|
||||
@Deprecated(
|
||||
forRemoval = true,
|
||||
since = "1.20.4"
|
||||
)
|
||||
@Override
|
||||
@NotNull
|
||||
NamespacedKey getKey();
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
package org.bukkit.inventory.meta.trim;
|
||||
|
||||
import io.papermc.paper.generated.GeneratedFrom;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Vanilla keys for TrimPattern.
|
||||
*
|
||||
* @apiNote The fields provided here are a direct representation of
|
||||
* what is available from the vanilla game source. They may be
|
||||
* changed (including removals) on any Minecraft version
|
||||
* bump, so cross-version compatibility is not provided on the
|
||||
* same level as it is on most of the other API.
|
||||
*/
|
||||
@SuppressWarnings({
|
||||
"unused",
|
||||
"SpellCheckingInspection"
|
||||
})
|
||||
@GeneratedFrom("1.20.4")
|
||||
public interface TrimPattern extends Keyed {
|
||||
/**
|
||||
* {@code minecraft:coast}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern COAST = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("coast"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:dune}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern DUNE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("dune"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:eye}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern EYE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("eye"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:host}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern HOST = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("host"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:raiser}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern RAISER = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("raiser"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:rib}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern RIB = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("rib"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:sentry}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern SENTRY = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("sentry"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:shaper}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern SHAPER = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("shaper"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:silence}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern SILENCE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("silence"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:snout}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern SNOUT = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("snout"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:spire}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern SPIRE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("spire"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:tide}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern TIDE = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("tide"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:vex}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern VEX = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("vex"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:ward}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern WARD = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("ward"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:wayfinder}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern WAYFINDER = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("wayfinder"));
|
||||
|
||||
/**
|
||||
* {@code minecraft:wild}
|
||||
*
|
||||
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||
*/
|
||||
TrimPattern WILD = Registry.TRIM_PATTERN.get(NamespacedKey.minecraft("wild"));
|
||||
|
||||
/**
|
||||
* @deprecated use {@link Registry#getKey(Keyed)} and {@link Registry#TRIM_PATTERN}. TrimPattern
|
||||
* can exist without a key.
|
||||
*/
|
||||
@Deprecated(
|
||||
forRemoval = true,
|
||||
since = "1.20.4"
|
||||
)
|
||||
@Override
|
||||
@NotNull
|
||||
NamespacedKey getKey();
|
||||
}
|
|
@ -1,21 +1,19 @@
|
|||
package io.papermc.generator;
|
||||
|
||||
import io.papermc.generator.types.registry.AttributeGenerator;
|
||||
import io.papermc.generator.rewriter.SourceRewriter;
|
||||
import io.papermc.generator.rewriter.types.EnumRegistryRewriter;
|
||||
import io.papermc.generator.types.registry.GeneratedKeyType;
|
||||
import io.papermc.generator.types.SourceGenerator;
|
||||
import io.papermc.generator.types.registry.BiomeGenerator;
|
||||
import io.papermc.generator.types.registry.SoundGenerator;
|
||||
import io.papermc.generator.types.goal.MobGoalGenerator;
|
||||
import io.papermc.generator.types.registry.StructureGenerator;
|
||||
import io.papermc.generator.types.registry.StructureTypeGenerator;
|
||||
import io.papermc.generator.types.registry.TagGenerator;
|
||||
import io.papermc.generator.types.registry.LegacyKeyedRegistryGenerator;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import org.bukkit.Fluid;
|
||||
import org.bukkit.GameEvent;
|
||||
import org.bukkit.MusicInstrument;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.damage.DamageType;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
@ -41,14 +39,23 @@ public interface Generators {
|
|||
simpleKey("DamageTypeKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, true),
|
||||
simpleKey("WolfVariantKeys", Wolf.Variant.class, Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, true),
|
||||
new MobGoalGenerator("VanillaGoal", "com.destroystokyo.paper.entity.ai"),
|
||||
new SoundGenerator("Sound", "org.bukkit"),
|
||||
/*new SoundGenerator("Sound", "org.bukkit"), todo extract fields
|
||||
new BiomeGenerator("Biome", "org.bukkit.block"),
|
||||
new AttributeGenerator("Attribute", "org.bukkit.attribute"),
|
||||
new StructureTypeGenerator("StructureType", "org.bukkit.generator.structure"),
|
||||
new StructureGenerator("Structure", "org.bukkit.generator.structure"),
|
||||
new LegacyKeyedRegistryGenerator<>("TrimPattern", "org.bukkit.inventory.meta.trim", Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN),
|
||||
new LegacyKeyedRegistryGenerator<>("TrimMaterial", "org.bukkit.inventory.meta.trim", Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL),
|
||||
new TagGenerator("Tag", "org.bukkit")
|
||||
new TagGenerator("Tag", "org.bukkit")*/
|
||||
};
|
||||
|
||||
SourceRewriter[] API_REWRITE = {
|
||||
//new EnumCloneRewriter(Pose.class, net.minecraft.world.entity.Pose.class, "Pose", false)
|
||||
new EnumRegistryRewriter<>(Fluid.class, Registries.FLUID, "Fluid", false),
|
||||
new EnumRegistryRewriter<>(Sound.class, Registries.SOUND_EVENT, "Sound", true),
|
||||
new EnumRegistryRewriter<>(Attribute.class, Registries.ATTRIBUTE, "Attribute", true),
|
||||
new EnumRegistryRewriter<>(Biome.class, Registries.BIOME, "Biome", false),
|
||||
//new EnumRegistryRewriter<>(EntityType.class, Registries.ENTITY_TYPE, "EntityType", false) seems complex to get the typeId?
|
||||
};
|
||||
|
||||
private static <T, A> SourceGenerator simpleKey(final String className, final Class<A> apiType, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.papermc.generator;
|
|||
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.papermc.generator.rewriter.SourceRewriter;
|
||||
import io.papermc.generator.types.SourceGenerator;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -30,6 +31,7 @@ public final class Main {
|
|||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final RegistryAccess.Frozen REGISTRY_ACCESS;
|
||||
public static final TagResult EXPERIMENTAL_TAGS;
|
||||
public static Path generatedPath;
|
||||
|
||||
static {
|
||||
SharedConstants.tryDetectVersion();
|
||||
|
@ -52,9 +54,9 @@ public final class Main {
|
|||
|
||||
public static void main(final String[] args) {
|
||||
LOGGER.info("Running API generators...");
|
||||
generate(Path.of(args[0]), Generators.API);
|
||||
// LOGGER.info("Running Server generators...");
|
||||
// generate(Path.of(args[1]), Generators.SERVER);
|
||||
Main.generatedPath = Path.of(args[0]); // todo remove
|
||||
generate(Main.generatedPath, Generators.API);
|
||||
apply(Path.of(args[1]), Generators.API_REWRITE);
|
||||
}
|
||||
|
||||
private static void generate(Path output, SourceGenerator[] generators) {
|
||||
|
@ -73,4 +75,16 @@ public final class Main {
|
|||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void apply(Path output, SourceRewriter[] generators) {
|
||||
try {
|
||||
for (final SourceRewriter generator : generators) {
|
||||
generator.writeToFile(output);
|
||||
}
|
||||
|
||||
LOGGER.info("Files written to {}", output.toAbsolutePath());
|
||||
} catch (final Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
package io.papermc.generator.rewriter;
|
||||
|
||||
public record SearchMetadata(String indent, String replacedContent, int line) {
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
package io.papermc.generator.rewriter;
|
||||
|
||||
import io.papermc.generator.Main;
|
||||
import io.papermc.generator.rewriter.utils.Annotations;
|
||||
import io.papermc.paper.generated.GeneratedFrom;
|
||||
import net.minecraft.SharedConstants;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
public class SearchReplaceRewriter implements SourceRewriter {
|
||||
|
||||
private static final String INDENT = " ";
|
||||
private static final String PAPER_START_FORMAT = "Paper start";
|
||||
private static final String PAPER_END_FORMAT = "Paper end";
|
||||
|
||||
private final Class<?> rewriteClass;
|
||||
private final String pattern;
|
||||
private final boolean equalsSize;
|
||||
|
||||
public SearchReplaceRewriter(Class<?> rewriteClass, String pattern, boolean equalsSize) {
|
||||
this.rewriteClass = rewriteClass;
|
||||
this.pattern = pattern;
|
||||
this.equalsSize = equalsSize;
|
||||
}
|
||||
|
||||
// only when equalsSize = false
|
||||
public void insert(SearchMetadata metadata, StringBuilder builder) {}
|
||||
|
||||
// only when equalsSize = true
|
||||
public void replaceLine(SearchMetadata metadata, StringBuilder builder) {}
|
||||
|
||||
private String getIndent(String unit, Class<?> clazz) { // todo move in formatting
|
||||
Class<?> parent = clazz.getEnclosingClass();
|
||||
StringBuilder indentBuilder = new StringBuilder(unit);
|
||||
while (parent != null) {
|
||||
indentBuilder.append(unit);
|
||||
parent = parent.getEnclosingClass();
|
||||
}
|
||||
return indentBuilder.toString();
|
||||
}
|
||||
|
||||
private boolean framed;
|
||||
|
||||
@Override
|
||||
public void writeToFile(Path parent) throws IOException {
|
||||
String indent = getIndent(INDENT, this.rewriteClass);
|
||||
String startPattern = String.format("%s// %s - Generated/%s", indent, PAPER_START_FORMAT, this.pattern);
|
||||
String endPattern = String.format("%s// %s - Generated/%s", indent, PAPER_END_FORMAT, this.pattern);
|
||||
|
||||
Path path = parent.resolve(this.rewriteClass.getCanonicalName().replace('.', '/') + ".java");
|
||||
StringBuilder content = new StringBuilder();
|
||||
StringBuilder strippedContent = new StringBuilder();
|
||||
|
||||
// strip the replaced content first or apply directly the change when the replaced content size is equals to the new content size
|
||||
{
|
||||
List<String> lines = Files.readAllLines(path, StandardCharsets.UTF_8);
|
||||
boolean replace = false;
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = lines.get(i);
|
||||
|
||||
if (line.equals(endPattern)) {
|
||||
if (this.framed) {
|
||||
this.framed = false;
|
||||
if (this.equalsSize) {
|
||||
replace = false;
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Start generated comment missing for " + this.rewriteClass.getSimpleName() + " at line " + (i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.framed) {
|
||||
content.append(line);
|
||||
content.append('\n');
|
||||
} else {
|
||||
strippedContent.append(line);
|
||||
strippedContent.append('\n');
|
||||
if (replace) {
|
||||
// todo generated version comment
|
||||
this.replaceLine(new SearchMetadata(indent, line, i), content);
|
||||
}
|
||||
}
|
||||
|
||||
if (line.equals(startPattern)) {
|
||||
if (!this.framed) {
|
||||
this.framed = true;
|
||||
if (this.equalsSize) {
|
||||
replace = true;
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Nested generated comments are not allowed for " + this.rewriteClass.getSimpleName() + " at line " + (i + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.framed) {
|
||||
throw new IllegalStateException("End generated comment missing for " + this.rewriteClass.getSimpleName());
|
||||
}
|
||||
|
||||
// often content doesn't match because of javadoc or by design for some rewriter so insert manually later
|
||||
if (!this.equalsSize) {
|
||||
StringBuilder replacedContent = new StringBuilder();
|
||||
String[] stripLines = content.toString().split("\n");
|
||||
boolean replace = false;
|
||||
for (int i = 0; i < stripLines.length; i++) {
|
||||
String line = stripLines[i];
|
||||
if (replace) {
|
||||
replacedContent.append(indent).append("// %s %s".formatted(
|
||||
Annotations.annotation(GeneratedFrom.class, true),
|
||||
SharedConstants.getCurrentVersion().getName()
|
||||
));
|
||||
replacedContent.append('\n');
|
||||
|
||||
this.insert(new SearchMetadata(indent, strippedContent.toString(), i), replacedContent);
|
||||
replace = false;
|
||||
}
|
||||
replacedContent.append(line);
|
||||
replacedContent.append('\n');
|
||||
if (line.equals(startPattern)) {
|
||||
replace = true;
|
||||
}
|
||||
}
|
||||
content = replacedContent;
|
||||
}
|
||||
|
||||
// Files.writeString(path, content.toString(), StandardCharsets.UTF_8); // todo
|
||||
Path createdPath = Main.generatedPath.resolve(this.rewriteClass.getCanonicalName().replace('.', '/') + ".java");
|
||||
Files.createDirectories(createdPath.getParent());
|
||||
Files.writeString(createdPath, content.toString(), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package io.papermc.generator.rewriter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface SourceRewriter {
|
||||
|
||||
void writeToFile(Path parent) throws IOException;
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package io.papermc.generator.rewriter.types;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.papermc.generator.rewriter.SearchMetadata;
|
||||
import io.papermc.generator.rewriter.SearchReplaceRewriter;
|
||||
|
||||
public class EnumCloneRewriter extends SearchReplaceRewriter {
|
||||
|
||||
private final Enum<? extends Enum<?>>[] enums;
|
||||
|
||||
public EnumCloneRewriter(final Class<? extends Enum<?>> rewriteClass, final Class<? extends Enum<?>> basedOn, final String pattern, boolean equalsSize) {
|
||||
super(rewriteClass, pattern, equalsSize);
|
||||
this.enums = basedOn.getEnumConstants();
|
||||
}
|
||||
|
||||
private int index = 0;
|
||||
|
||||
private void appendEnumValue(StringBuilder builder, String indent, Enum<? extends Enum<?>>[] enums, int index) {
|
||||
builder.append(indent).append(enums[index].name());
|
||||
if (index != enums.length - 1) {
|
||||
builder.append(',');
|
||||
} else {
|
||||
builder.append(';');
|
||||
}
|
||||
builder.append('\n');
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceLine(final SearchMetadata metadata, final StringBuilder builder) {
|
||||
appendEnumValue(builder, metadata.indent(), this.enums, this.index++);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(final SearchMetadata metadata, final StringBuilder builder) {
|
||||
Preconditions.checkState(metadata.replacedContent().stripTrailing().endsWith(";"), "The generated comments must enclose the whole enum in the clone enum rewriter");
|
||||
|
||||
for (int i = 0, len = this.enums.length; i < len; i++) {
|
||||
appendEnumValue(builder, metadata.indent(), this.enums, i);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package io.papermc.generator.rewriter.types;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import io.papermc.generator.Main;
|
||||
import io.papermc.generator.rewriter.SearchMetadata;
|
||||
import io.papermc.generator.rewriter.SearchReplaceRewriter;
|
||||
import io.papermc.generator.rewriter.utils.Annotations;
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import io.papermc.generator.utils.RegistryUtils;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.flag.FeatureElement;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class EnumRegistryRewriter<T, A extends Enum<A>> extends SearchReplaceRewriter {
|
||||
|
||||
private final net.minecraft.core.Registry<T> registry;
|
||||
private final Supplier<Set<ResourceKey<T>>> experimentalKeys;
|
||||
private final boolean isFilteredRegistry;
|
||||
private final boolean keyedParam;
|
||||
|
||||
public EnumRegistryRewriter(final Class<A> rewriteClass, final ResourceKey<? extends Registry<T>> registryKey, final String pattern, final boolean keyedParam) {
|
||||
super(rewriteClass, pattern, false);
|
||||
this.registry = Main.REGISTRY_ACCESS.registryOrThrow(registryKey);
|
||||
this.experimentalKeys = Suppliers.memoize(() -> RegistryUtils.collectExperimentalDataDrivenKeys(this.registry));
|
||||
this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey);
|
||||
this.keyedParam = keyedParam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(final SearchMetadata metadata, final StringBuilder builder) {
|
||||
boolean reachEnd = metadata.replacedContent().stripTrailing().endsWith(";");
|
||||
|
||||
List<Holder.Reference<T>> references = this.registry.holders().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).toList();
|
||||
for (int i = 0, size = references.size(); i < size; i++) {
|
||||
Holder.Reference<T> reference = references.get(i);
|
||||
ResourceKey<T> resourceKey = reference.key();
|
||||
String pathKey = resourceKey.location().getPath();
|
||||
|
||||
String fieldName = Formatting.formatKeyAsField(pathKey);
|
||||
String experimentalValue = this.getExperimentalValue(reference);
|
||||
if (experimentalValue != null) {
|
||||
Annotations.experimentalAnnotations(builder, metadata::indent, experimentalValue);
|
||||
}
|
||||
|
||||
builder.append(metadata.indent()).append(fieldName);
|
||||
if (this.keyedParam) {
|
||||
builder.append("(\"%s\")".formatted(pathKey));
|
||||
}
|
||||
if (reachEnd && i == size - 1) {
|
||||
builder.append(';');
|
||||
} else {
|
||||
builder.append(',');
|
||||
}
|
||||
builder.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getExperimentalValue(Holder.Reference<T> reference) {
|
||||
if (this.isFilteredRegistry && reference.value() instanceof FeatureElement element && FeatureFlags.isExperimental(element.requiredFeatures())) {
|
||||
return Formatting.formatFeatureFlagSet(element.requiredFeatures());
|
||||
}
|
||||
if (this.experimentalKeys.get().contains(reference.key())) {
|
||||
return Formatting.formatFeatureFlag(FeatureFlags.UPDATE_1_21);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package io.papermc.generator.rewriter.utils;
|
||||
|
||||
import io.papermc.generator.utils.Formatting;
|
||||
import net.minecraft.world.flag.FeatureFlag;
|
||||
import org.bukkit.MinecraftExperimental;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Annotations {
|
||||
|
||||
private static String retrieveFullNestedName(Class<?> clazz) {
|
||||
List<Class<?>> nestedClasses = new ArrayList<>();
|
||||
nestedClasses.add(clazz);
|
||||
Class<?> parent = clazz.getEnclosingClass();
|
||||
while (parent != null) {
|
||||
nestedClasses.add(parent);
|
||||
parent = parent.getEnclosingClass();
|
||||
}
|
||||
Collections.reverse(nestedClasses);
|
||||
return nestedClasses.stream().map(Class::getSimpleName).collect(Collectors.joining("."));
|
||||
}
|
||||
|
||||
public static String annotation(Class<? extends Annotation> clazz, boolean imported) { // todo importCollector
|
||||
return "@%s".formatted(imported ? retrieveFullNestedName(clazz) : clazz.getCanonicalName());
|
||||
}
|
||||
|
||||
public static String annotation(Class<? extends Annotation> clazz, String param, String value) {
|
||||
if (value.isEmpty()) {
|
||||
return annotation(clazz, false);
|
||||
}
|
||||
return "@%s(%s = %s)".formatted(clazz.getCanonicalName(), param, value);
|
||||
}
|
||||
|
||||
public static void experimentalAnnotations(final StringBuilder builder, final Supplier<String> indent, final FeatureFlag featureFlag) {
|
||||
experimentalAnnotations(builder, indent, Formatting.formatFeatureFlag(featureFlag));
|
||||
}
|
||||
|
||||
public static void experimentalAnnotations(final StringBuilder builder, Supplier<String> indent, final String value) {
|
||||
builder.append(indent.get()).append(annotation(MinecraftExperimental.class, "value", '"' + value + '"')).append('\n');
|
||||
builder.append(indent.get()).append(annotation(ApiStatus.Experimental.class, false)).append('\n');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
||||
Date: Wed, 14 Feb 2024 19:33:27 +0100
|
||||
Subject: [PATCH] Code generation marker stub
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Fluid.java b/src/main/java/org/bukkit/Fluid.java
|
||||
index 7202b44a65e8699cf64329e441e83d4dd1779c19..ebcef7cdbcd402010af13d9fb055b3a3f6ce665e 100644
|
||||
--- a/src/main/java/org/bukkit/Fluid.java
|
||||
+++ b/src/main/java/org/bukkit/Fluid.java
|
||||
@@ -8,6 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public enum Fluid implements Keyed {
|
||||
|
||||
+ // Paper start - Generated/Fluid
|
||||
// Paper start
|
||||
/**
|
||||
* No fluid.
|
||||
@@ -30,6 +31,7 @@ public enum Fluid implements Keyed {
|
||||
* Flowing lava.
|
||||
*/
|
||||
FLOWING_LAVA;
|
||||
+ // Paper end - Generated/Fluid
|
||||
|
||||
private final NamespacedKey key;
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Sound.java b/src/main/java/org/bukkit/Sound.java
|
||||
index bb1b6bc9349af6dec369420035e860921da52589..98bdf175bea2f559655ccb96ceb900669752fbb5 100644
|
||||
--- a/src/main/java/org/bukkit/Sound.java
|
||||
+++ b/src/main/java/org/bukkit/Sound.java
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public enum Sound implements Keyed, net.kyori.adventure.sound.Sound.Type { // Paper - implement Sound.Type
|
||||
|
||||
+ // Paper start - Generated/Sound
|
||||
AMBIENT_BASALT_DELTAS_ADDITIONS("ambient.basalt_deltas.additions"),
|
||||
AMBIENT_BASALT_DELTAS_LOOP("ambient.basalt_deltas.loop"),
|
||||
AMBIENT_BASALT_DELTAS_MOOD("ambient.basalt_deltas.mood"),
|
||||
@@ -1653,6 +1654,7 @@ public enum Sound implements Keyed, net.kyori.adventure.sound.Sound.Type { // Pa
|
||||
UI_TOAST_OUT("ui.toast.out"),
|
||||
WEATHER_RAIN("weather.rain"),
|
||||
WEATHER_RAIN_ABOVE("weather.rain.above");
|
||||
+ // Paper end - Generated/Sound
|
||||
|
||||
private final NamespacedKey key;
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/attribute/Attribute.java b/src/main/java/org/bukkit/attribute/Attribute.java
|
||||
index 37f93b7e9f722e76631c3e7d3e770526ee0c3926..ee18e01cf5407ee1c6bd2626431bd283d0db56b2 100644
|
||||
--- a/src/main/java/org/bukkit/attribute/Attribute.java
|
||||
+++ b/src/main/java/org/bukkit/attribute/Attribute.java
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public enum Attribute implements Keyed, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
|
||||
|
||||
+ // Paper start - Generated/Attribute
|
||||
/**
|
||||
* Maximum health of an Entity.
|
||||
*/
|
||||
@@ -65,6 +66,7 @@ public enum Attribute implements Keyed, net.kyori.adventure.translation.Translat
|
||||
* Chance of a zombie to spawn reinforcements.
|
||||
*/
|
||||
ZOMBIE_SPAWN_REINFORCEMENTS("zombie.spawn_reinforcements");
|
||||
+ // Paper end - Generated/Attribute
|
||||
|
||||
private final NamespacedKey key;
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/block/Biome.java b/src/main/java/org/bukkit/block/Biome.java
|
||||
index 5d8fa5b39a5d50cca48ba63af3a84b80f279b649..c6ea69c0d05aef5a29b758dbd3ea4c84a7587f6b 100644
|
||||
--- a/src/main/java/org/bukkit/block/Biome.java
|
||||
+++ b/src/main/java/org/bukkit/block/Biome.java
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Holds all accepted Biomes in the default server
|
||||
*/
|
||||
public enum Biome implements Keyed, net.kyori.adventure.translation.Translatable { // Paper
|
||||
+ // Paper start - Generated/Biome
|
||||
OCEAN,
|
||||
PLAINS,
|
||||
DESERT,
|
||||
@@ -73,6 +74,7 @@ public enum Biome implements Keyed, net.kyori.adventure.translation.Translatable
|
||||
JAGGED_PEAKS,
|
||||
STONY_PEAKS,
|
||||
CHERRY_GROVE,
|
||||
+ // Paper end - Generated/Biome
|
||||
/**
|
||||
* Represents a custom Biome
|
||||
*/
|
Loading…
Reference in New Issue