mirror of https://github.com/PaperMC/Paper.git
fix and generate entity type
This commit is contained in:
parent
737ac573bd
commit
4147603a67
|
@ -0,0 +1,347 @@
|
|||
package org.bukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.MinecraftExperimental;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Translatable;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
import org.bukkit.entity.minecart.HopperMinecart;
|
||||
import org.bukkit.entity.minecart.PoweredMinecart;
|
||||
import org.bukkit.entity.minecart.RideableMinecart;
|
||||
import org.bukkit.entity.minecart.SpawnerMinecart;
|
||||
import org.bukkit.entity.minecart.StorageMinecart;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public enum EntityType implements Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - translatable
|
||||
|
||||
// These strings MUST match the strings in nms.EntityTypes and are case sensitive.
|
||||
// Paper start - Generated/EntityType
|
||||
// @GeneratedFrom 1.20.4
|
||||
ALLAY("allay", Allay.class, -1),
|
||||
AREA_EFFECT_CLOUD("area_effect_cloud", AreaEffectCloud.class, 3),
|
||||
ARMOR_STAND("armor_stand", ArmorStand.class, 30),
|
||||
ARROW("arrow", Arrow.class, 10),
|
||||
AXOLOTL("axolotl", Axolotl.class, -1),
|
||||
BAT("bat", Bat.class, 65),
|
||||
BEE("bee", Bee.class, -1),
|
||||
BLAZE("blaze", Blaze.class, 61),
|
||||
BLOCK_DISPLAY("block_display", BlockDisplay.class, -1),
|
||||
BOAT("boat", Boat.class, 41),
|
||||
@MinecraftExperimental("update 1.21")
|
||||
@ApiStatus.Experimental
|
||||
BREEZE("breeze", Breeze.class, -1),
|
||||
CAMEL("camel", Camel.class, -1),
|
||||
CAT("cat", Cat.class, -1),
|
||||
CAVE_SPIDER("cave_spider", CaveSpider.class, 59),
|
||||
CHEST_BOAT("chest_boat", ChestBoat.class, -1),
|
||||
MINECART_CHEST("chest_minecart", StorageMinecart.class, 43),
|
||||
CHICKEN("chicken", Chicken.class, 93),
|
||||
COD("cod", Cod.class, -1),
|
||||
MINECART_COMMAND("command_block_minecart", CommandMinecart.class, 40),
|
||||
COW("cow", Cow.class, 92),
|
||||
CREEPER("creeper", Creeper.class, 50),
|
||||
DOLPHIN("dolphin", Dolphin.class, -1),
|
||||
DONKEY("donkey", Donkey.class, 31),
|
||||
DRAGON_FIREBALL("dragon_fireball", DragonFireball.class, 26),
|
||||
DROWNED("drowned", Drowned.class, -1),
|
||||
EGG("egg", Egg.class, 7),
|
||||
ELDER_GUARDIAN("elder_guardian", ElderGuardian.class, 4),
|
||||
ENDER_CRYSTAL("end_crystal", EnderCrystal.class, 200),
|
||||
ENDER_DRAGON("ender_dragon", EnderDragon.class, 63),
|
||||
ENDER_PEARL("ender_pearl", EnderPearl.class, 14),
|
||||
ENDERMAN("enderman", Enderman.class, 58),
|
||||
ENDERMITE("endermite", Endermite.class, 67),
|
||||
EVOKER("evoker", Evoker.class, 34),
|
||||
EVOKER_FANGS("evoker_fangs", EvokerFangs.class, 33),
|
||||
THROWN_EXP_BOTTLE("experience_bottle", ThrownExpBottle.class, 17),
|
||||
EXPERIENCE_ORB("experience_orb", ExperienceOrb.class, 2),
|
||||
ENDER_SIGNAL("eye_of_ender", EnderSignal.class, 15),
|
||||
FALLING_BLOCK("falling_block", FallingBlock.class, 21),
|
||||
FIREBALL("fireball", Fireball.class, 12),
|
||||
FIREWORK("firework_rocket", Firework.class, 22),
|
||||
FISHING_HOOK("fishing_bobber", FishHook.class, -1, false),
|
||||
FOX("fox", Fox.class, -1),
|
||||
FROG("frog", Frog.class, -1),
|
||||
MINECART_FURNACE("furnace_minecart", PoweredMinecart.class, 44),
|
||||
GHAST("ghast", Ghast.class, 56),
|
||||
GIANT("giant", Giant.class, 53),
|
||||
GLOW_ITEM_FRAME("glow_item_frame", GlowItemFrame.class, -1),
|
||||
GLOW_SQUID("glow_squid", GlowSquid.class, -1),
|
||||
GOAT("goat", Goat.class, -1),
|
||||
GUARDIAN("guardian", Guardian.class, 68),
|
||||
HOGLIN("hoglin", Hoglin.class, -1),
|
||||
MINECART_HOPPER("hopper_minecart", HopperMinecart.class, 46),
|
||||
HORSE("horse", Horse.class, 100),
|
||||
HUSK("husk", Husk.class, 23),
|
||||
ILLUSIONER("illusioner", Illusioner.class, 37),
|
||||
INTERACTION("interaction", Interaction.class, -1),
|
||||
IRON_GOLEM("iron_golem", IronGolem.class, 99),
|
||||
DROPPED_ITEM("item", Item.class, 1),
|
||||
ITEM_DISPLAY("item_display", ItemDisplay.class, -1),
|
||||
ITEM_FRAME("item_frame", ItemFrame.class, 18),
|
||||
LEASH_HITCH("leash_knot", LeashHitch.class, 8),
|
||||
LIGHTNING("lightning_bolt", LightningStrike.class, -1),
|
||||
LLAMA("llama", Llama.class, 103),
|
||||
LLAMA_SPIT("llama_spit", LlamaSpit.class, 104),
|
||||
MAGMA_CUBE("magma_cube", MagmaCube.class, 62),
|
||||
MARKER("marker", Marker.class, -1),
|
||||
MINECART("minecart", Minecart.class, 42),
|
||||
MUSHROOM_COW("mooshroom", MushroomCow.class, 96),
|
||||
MULE("mule", Mule.class, 32),
|
||||
OCELOT("ocelot", Ocelot.class, 98),
|
||||
PAINTING("painting", Painting.class, 9),
|
||||
PANDA("panda", Panda.class, -1),
|
||||
PARROT("parrot", Parrot.class, 105),
|
||||
PHANTOM("phantom", Phantom.class, -1),
|
||||
PIG("pig", Pig.class, 90),
|
||||
PIGLIN("piglin", Piglin.class, -1),
|
||||
PIGLIN_BRUTE("piglin_brute", PiglinBrute.class, -1),
|
||||
PILLAGER("pillager", Pillager.class, -1),
|
||||
PLAYER("player", Player.class, -1, false),
|
||||
POLAR_BEAR("polar_bear", PolarBear.class, 102),
|
||||
SPLASH_POTION("potion", ThrownPotion.class, 16),
|
||||
PUFFERFISH("pufferfish", PufferFish.class, -1),
|
||||
RABBIT("rabbit", Rabbit.class, 101),
|
||||
RAVAGER("ravager", Ravager.class, -1),
|
||||
SALMON("salmon", Salmon.class, -1),
|
||||
SHEEP("sheep", Sheep.class, 91),
|
||||
SHULKER("shulker", Shulker.class, 69),
|
||||
SHULKER_BULLET("shulker_bullet", ShulkerBullet.class, 25),
|
||||
SILVERFISH("silverfish", Silverfish.class, 60),
|
||||
SKELETON("skeleton", Skeleton.class, 51),
|
||||
SKELETON_HORSE("skeleton_horse", SkeletonHorse.class, 28),
|
||||
SLIME("slime", Slime.class, 55),
|
||||
SMALL_FIREBALL("small_fireball", SmallFireball.class, 13),
|
||||
SNIFFER("sniffer", Sniffer.class, -1),
|
||||
SNOWMAN("snow_golem", Snowman.class, 97),
|
||||
SNOWBALL("snowball", Snowball.class, 11),
|
||||
MINECART_MOB_SPAWNER("spawner_minecart", SpawnerMinecart.class, 47),
|
||||
SPECTRAL_ARROW("spectral_arrow", SpectralArrow.class, 24),
|
||||
SPIDER("spider", Spider.class, 52),
|
||||
SQUID("squid", Squid.class, 94),
|
||||
STRAY("stray", Stray.class, 6),
|
||||
STRIDER("strider", Strider.class, -1),
|
||||
TADPOLE("tadpole", Tadpole.class, -1),
|
||||
TEXT_DISPLAY("text_display", TextDisplay.class, -1),
|
||||
PRIMED_TNT("tnt", TNTPrimed.class, 20),
|
||||
MINECART_TNT("tnt_minecart", ExplosiveMinecart.class, 45),
|
||||
TRADER_LLAMA("trader_llama", TraderLlama.class, -1),
|
||||
TRIDENT("trident", Trident.class, -1),
|
||||
TROPICAL_FISH("tropical_fish", TropicalFish.class, -1),
|
||||
TURTLE("turtle", Turtle.class, -1),
|
||||
VEX("vex", Vex.class, 35),
|
||||
VILLAGER("villager", Villager.class, 120),
|
||||
VINDICATOR("vindicator", Vindicator.class, 36),
|
||||
WANDERING_TRADER("wandering_trader", WanderingTrader.class, -1),
|
||||
WARDEN("warden", Warden.class, -1),
|
||||
@MinecraftExperimental("update 1.21")
|
||||
@ApiStatus.Experimental
|
||||
WIND_CHARGE("wind_charge", WindCharge.class, -1),
|
||||
WITCH("witch", Witch.class, 66),
|
||||
WITHER("wither", Wither.class, 64),
|
||||
WITHER_SKELETON("wither_skeleton", WitherSkeleton.class, 5),
|
||||
WITHER_SKULL("wither_skull", WitherSkull.class, 19),
|
||||
WOLF("wolf", Wolf.class, 95),
|
||||
ZOGLIN("zoglin", Zoglin.class, -1),
|
||||
ZOMBIE("zombie", Zombie.class, 54),
|
||||
ZOMBIE_HORSE("zombie_horse", ZombieHorse.class, 29),
|
||||
ZOMBIE_VILLAGER("zombie_villager", ZombieVillager.class, 27),
|
||||
ZOMBIFIED_PIGLIN("zombified_piglin", PigZombie.class, 57),
|
||||
// Paper end - Generated/EntityType
|
||||
/**
|
||||
* An unknown entity without an Entity Class
|
||||
*/
|
||||
UNKNOWN(null, null, -1, false);
|
||||
|
||||
private final String name;
|
||||
private final Class<? extends Entity> clazz;
|
||||
private final short typeId;
|
||||
private final boolean independent, living;
|
||||
private final NamespacedKey key;
|
||||
|
||||
private static final Map<String, EntityType> NAME_MAP = new HashMap<String, EntityType>();
|
||||
private static final Map<Short, EntityType> ID_MAP = new HashMap<Short, EntityType>();
|
||||
|
||||
static {
|
||||
for (EntityType type : values()) {
|
||||
if (type.name != null) {
|
||||
NAME_MAP.put(type.name.toLowerCase(java.util.Locale.ENGLISH), type);
|
||||
}
|
||||
if (type.typeId > 0) {
|
||||
ID_MAP.put(type.typeId, type);
|
||||
}
|
||||
}
|
||||
|
||||
// Add legacy names
|
||||
NAME_MAP.put("xp_orb", EXPERIENCE_ORB);
|
||||
NAME_MAP.put("eye_of_ender_signal", ENDER_SIGNAL);
|
||||
NAME_MAP.put("xp_bottle", THROWN_EXP_BOTTLE);
|
||||
NAME_MAP.put("fireworks_rocket", FIREWORK);
|
||||
NAME_MAP.put("evocation_fangs", EVOKER_FANGS);
|
||||
NAME_MAP.put("evocation_illager", EVOKER);
|
||||
NAME_MAP.put("vindication_illager", VINDICATOR);
|
||||
NAME_MAP.put("illusion_illager", ILLUSIONER);
|
||||
NAME_MAP.put("commandblock_minecart", MINECART_COMMAND);
|
||||
NAME_MAP.put("snowman", SNOWMAN);
|
||||
NAME_MAP.put("villager_golem", IRON_GOLEM);
|
||||
NAME_MAP.put("ender_crystal", ENDER_CRYSTAL);
|
||||
NAME_MAP.put("zombie_pigman", ZOMBIFIED_PIGLIN);
|
||||
}
|
||||
|
||||
private EntityType(/*@Nullable*/ String name, /*@Nullable*/ Class<? extends Entity> clazz, int typeId) {
|
||||
this(name, clazz, typeId, true);
|
||||
}
|
||||
|
||||
private EntityType(/*@Nullable*/ String name, /*@Nullable*/ Class<? extends Entity> clazz, int typeId, boolean independent) {
|
||||
this.name = name;
|
||||
this.clazz = clazz;
|
||||
this.typeId = (short) typeId;
|
||||
this.independent = independent;
|
||||
this.living = clazz != null && LivingEntity.class.isAssignableFrom(clazz);
|
||||
this.key = (name == null) ? null : NamespacedKey.minecraft(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entity type name.
|
||||
*
|
||||
* @return the entity type's name
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
Preconditions.checkArgument(key != null, "EntityType doesn't have key! Is it UNKNOWN?");
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Class<? extends Entity> getEntityClass() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entity type id.
|
||||
*
|
||||
* @return the raw type id
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
public short getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an entity type from its name.
|
||||
*
|
||||
* @param name the entity type's name
|
||||
* @return the matching entity type or null
|
||||
* @apiNote Internal Use Only
|
||||
*/
|
||||
@org.jetbrains.annotations.ApiStatus.Internal // Paper
|
||||
@Contract("null -> null")
|
||||
@Nullable
|
||||
public static EntityType fromName(@Nullable String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
return NAME_MAP.get(name.toLowerCase(java.util.Locale.ENGLISH));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an entity from its id.
|
||||
*
|
||||
* @param id the raw type id
|
||||
* @return the matching entity type or null
|
||||
* @deprecated Magic value
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public static EntityType fromId(int id) {
|
||||
if (id > Short.MAX_VALUE) {
|
||||
return null;
|
||||
}
|
||||
return ID_MAP.get((short) id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some entities cannot be spawned using {@link
|
||||
* World#spawnEntity(Location, EntityType)} or {@link
|
||||
* World#spawn(Location, Class)}, usually because they require additional
|
||||
* information in order to spawn.
|
||||
*
|
||||
* @return False if the entity type cannot be spawned
|
||||
*/
|
||||
public boolean isSpawnable() {
|
||||
return independent;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return living;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@Deprecated(forRemoval = true) // Paper
|
||||
public String getTranslationKey() {
|
||||
return Bukkit.getUnsafe().getTranslationKey(this);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
/**
|
||||
* @throws IllegalArgumentException if the entity does not have a translation key (is probably a custom entity)
|
||||
*/
|
||||
@Override
|
||||
public @NotNull String translationKey() {
|
||||
Preconditions.checkArgument(this != UNKNOWN, "UNKNOWN entities do not have translation keys");
|
||||
return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entity has default attributes.
|
||||
*
|
||||
* @return true if it has default attributes
|
||||
*/
|
||||
public boolean hasDefaultAttributes() {
|
||||
return org.bukkit.Bukkit.getUnsafe().hasDefaultEntityAttributes(this.key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default attributes for the entity.
|
||||
*
|
||||
* @return an unmodifiable instance of Attributable for reading default attributes.
|
||||
* @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultAttributes()} first)
|
||||
*/
|
||||
public @NotNull org.bukkit.attribute.Attributable getDefaultAttributes() {
|
||||
return org.bukkit.Bukkit.getUnsafe().getDefaultEntityAttributes(this.key);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
* Gets if this EntityType is enabled by feature in a world.
|
||||
*
|
||||
* @param world the world to check
|
||||
* @return true if this EntityType can be used to spawn an Entity for this World.
|
||||
*/
|
||||
public boolean isEnabledByFeature(@NotNull World world) {
|
||||
return Bukkit.getDataPackManager().isEnabledByFeature(this, world);
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import io.papermc.generator.rewriter.types.EnumRegistryRewriter;
|
|||
import io.papermc.generator.rewriter.types.simple.CraftBlockDataMapping;
|
||||
import io.papermc.generator.rewriter.types.simple.CraftBlockEntityStateMapping;
|
||||
import io.papermc.generator.rewriter.types.simple.CraftPotionUtilRewriter;
|
||||
import io.papermc.generator.rewriter.types.simple.EntityTypeRewriter;
|
||||
import io.papermc.generator.rewriter.types.simple.MapPaletteRewriter;
|
||||
import io.papermc.generator.rewriter.types.RegistryFieldRewriter;
|
||||
import io.papermc.generator.rewriter.types.TagRewriter;
|
||||
|
@ -107,7 +108,6 @@ public interface Generators {
|
|||
new EnumRegistryRewriter<>(Attribute.class, Registries.ATTRIBUTE, "Attribute", true),
|
||||
new EnumRegistryRewriter<>(Cat.Type.class, Registries.CAT_VARIANT, "CatType", true),
|
||||
new EnumRegistryRewriter<>(PotionType.class, Registries.POTION, "PotionType", true),
|
||||
//new EnumRegistryRewriter<>(EntityType.class, Registries.ENTITY_TYPE, "EntityType", true), seems complex to get the typeId?
|
||||
new EnumRegistryRewriter<>(Art.class, Registries.PAINTING_VARIANT, "Art", true) {
|
||||
|
||||
private static final int PIXELS_PER_BLOCK = 16;
|
||||
|
@ -121,6 +121,7 @@ public interface Generators {
|
|||
);
|
||||
}
|
||||
},
|
||||
new EntityTypeRewriter("EntityType"),
|
||||
new PatternTypeRewriter("PatternType"),
|
||||
new EnumRegistryRewriter<>(MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, "MapCursorType", true) {
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
package io.papermc.generator.rewriter.types.simple;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.papermc.generator.rewriter.types.EnumRegistryRewriter;
|
||||
import io.papermc.generator.types.goal.MobGoalNames;
|
||||
import io.papermc.generator.utils.ClassHelper;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.papermc.generator.utils.Formatting.quoted;
|
||||
|
||||
public class EntityTypeRewriter extends EnumRegistryRewriter<EntityType<?>, org.bukkit.entity.EntityType> {
|
||||
|
||||
private static final Map<EntityType<?>, Class<? extends Entity>> ENTITY_GENERIC_TYPES;
|
||||
static {
|
||||
final Map<EntityType<?>, Class<? extends Entity>> map = new IdentityHashMap<>();
|
||||
try {
|
||||
for (final Field field : EntityType.class.getDeclaredFields()) {
|
||||
if (!EntityType.class.isAssignableFrom(field.getType())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int mod = field.getModifiers();
|
||||
if (Modifier.isPublic(mod) & Modifier.isStatic(mod) & Modifier.isFinal(mod)) {
|
||||
if (field.getGenericType() instanceof ParameterizedType complexType && complexType.getActualTypeArguments().length == 1) {
|
||||
map.put((EntityType<?>) field.get(null), (Class<? extends Entity>) ClassHelper.eraseType(complexType.getActualTypeArguments()[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
ENTITY_GENERIC_TYPES = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
private static final Map<String, String> CLASS_RENAMES = ImmutableMap.<String, String>builder()
|
||||
.put("ExperienceBottle", "ThrownExpBottle")
|
||||
.put("EyeOfEnder", "EnderSignal")
|
||||
.put("EndCrystal", "EnderCrystal")
|
||||
.put("FireworkRocket", "Firework")
|
||||
.put("FishingBobber", "FishHook")
|
||||
.put("LeashKnot", "LeashHitch")
|
||||
.put("LightningBolt", "LightningStrike")
|
||||
.put("Potion", "ThrownPotion")
|
||||
.put("Tnt", "TNTPrimed")
|
||||
.put("ChestMinecart", "StorageMinecart")
|
||||
.put("CommandBlockMinecart", "CommandMinecart")
|
||||
.put("TntMinecart", "ExplosiveMinecart")
|
||||
.put("FurnaceMinecart", "PoweredMinecart")
|
||||
.build();
|
||||
|
||||
@Deprecated
|
||||
private static final Object2IntMap<EntityType<?>> LEGACY_ID = Util.make(new Object2IntOpenHashMap<>(), map -> {
|
||||
map.put(EntityType.ITEM, 1);
|
||||
map.put(EntityType.EXPERIENCE_ORB, 2);
|
||||
map.put(EntityType.AREA_EFFECT_CLOUD, 3);
|
||||
map.put(EntityType.ELDER_GUARDIAN, 4);
|
||||
map.put(EntityType.WITHER_SKELETON, 5);
|
||||
map.put(EntityType.STRAY, 6);
|
||||
map.put(EntityType.EGG, 7);
|
||||
map.put(EntityType.LEASH_KNOT, 8);
|
||||
map.put(EntityType.PAINTING, 9);
|
||||
map.put(EntityType.ARROW, 10);
|
||||
map.put(EntityType.SNOWBALL, 11);
|
||||
map.put(EntityType.FIREBALL, 12);
|
||||
map.put(EntityType.SMALL_FIREBALL, 13);
|
||||
map.put(EntityType.ENDER_PEARL, 14);
|
||||
map.put(EntityType.EYE_OF_ENDER, 15);
|
||||
map.put(EntityType.POTION, 16);
|
||||
map.put(EntityType.EXPERIENCE_BOTTLE, 17);
|
||||
map.put(EntityType.ITEM_FRAME, 18);
|
||||
map.put(EntityType.WITHER_SKULL, 19);
|
||||
map.put(EntityType.TNT, 20);
|
||||
map.put(EntityType.FALLING_BLOCK, 21);
|
||||
map.put(EntityType.FIREWORK_ROCKET, 22);
|
||||
map.put(EntityType.HUSK, 23);
|
||||
map.put(EntityType.SPECTRAL_ARROW, 24);
|
||||
map.put(EntityType.SHULKER_BULLET, 25);
|
||||
map.put(EntityType.DRAGON_FIREBALL, 26);
|
||||
map.put(EntityType.ZOMBIE_VILLAGER, 27);
|
||||
map.put(EntityType.SKELETON_HORSE, 28);
|
||||
map.put(EntityType.ZOMBIE_HORSE, 29);
|
||||
map.put(EntityType.ARMOR_STAND, 30);
|
||||
map.put(EntityType.DONKEY, 31);
|
||||
map.put(EntityType.MULE, 32);
|
||||
map.put(EntityType.EVOKER_FANGS, 33);
|
||||
map.put(EntityType.EVOKER, 34);
|
||||
map.put(EntityType.VEX, 35);
|
||||
map.put(EntityType.VINDICATOR, 36);
|
||||
map.put(EntityType.ILLUSIONER, 37);
|
||||
|
||||
map.put(EntityType.COMMAND_BLOCK_MINECART, 40);
|
||||
map.put(EntityType.BOAT, 41);
|
||||
map.put(EntityType.MINECART, 42);
|
||||
map.put(EntityType.CHEST_MINECART, 43);
|
||||
map.put(EntityType.FURNACE_MINECART, 44);
|
||||
map.put(EntityType.TNT_MINECART, 45);
|
||||
map.put(EntityType.HOPPER_MINECART, 46);
|
||||
map.put(EntityType.SPAWNER_MINECART, 47);
|
||||
|
||||
map.put(EntityType.CREEPER, 50);
|
||||
map.put(EntityType.SKELETON, 51);
|
||||
map.put(EntityType.SPIDER, 52);
|
||||
map.put(EntityType.GIANT, 53);
|
||||
map.put(EntityType.ZOMBIE, 54);
|
||||
map.put(EntityType.SLIME, 55);
|
||||
map.put(EntityType.GHAST, 56);
|
||||
map.put(EntityType.ZOMBIFIED_PIGLIN, 57);
|
||||
map.put(EntityType.ENDERMAN, 58);
|
||||
map.put(EntityType.CAVE_SPIDER, 59);
|
||||
map.put(EntityType.SILVERFISH, 60);
|
||||
map.put(EntityType.BLAZE, 61);
|
||||
map.put(EntityType.MAGMA_CUBE, 62);
|
||||
map.put(EntityType.ENDER_DRAGON, 63);
|
||||
map.put(EntityType.WITHER, 64);
|
||||
map.put(EntityType.BAT, 65);
|
||||
map.put(EntityType.WITCH, 66);
|
||||
map.put(EntityType.ENDERMITE, 67);
|
||||
map.put(EntityType.GUARDIAN, 68);
|
||||
map.put(EntityType.SHULKER, 69);
|
||||
|
||||
map.put(EntityType.PIG, 90);
|
||||
map.put(EntityType.SHEEP, 91);
|
||||
map.put(EntityType.COW, 92);
|
||||
map.put(EntityType.CHICKEN, 93);
|
||||
map.put(EntityType.SQUID, 94);
|
||||
map.put(EntityType.WOLF, 95);
|
||||
map.put(EntityType.MOOSHROOM, 96);
|
||||
map.put(EntityType.SNOW_GOLEM, 97);
|
||||
map.put(EntityType.OCELOT, 98);
|
||||
map.put(EntityType.IRON_GOLEM, 99);
|
||||
map.put(EntityType.HORSE, 100);
|
||||
map.put(EntityType.RABBIT, 101);
|
||||
map.put(EntityType.POLAR_BEAR, 102);
|
||||
map.put(EntityType.LLAMA, 103);
|
||||
map.put(EntityType.LLAMA_SPIT, 104);
|
||||
map.put(EntityType.PARROT, 105);
|
||||
|
||||
map.put(EntityType.VILLAGER, 120);
|
||||
|
||||
map.put(EntityType.END_CRYSTAL, 200);
|
||||
});
|
||||
|
||||
public EntityTypeRewriter(final String pattern) {
|
||||
super(org.bukkit.entity.EntityType.class, Registries.ENTITY_TYPE, pattern, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String rewriteEnumValue(Holder.Reference<EntityType<?>> reference) {
|
||||
String path = reference.key().location().getPath();
|
||||
final String value;
|
||||
if (!reference.value().canSummon()) {
|
||||
value = "%s, %s.class, %d, false";
|
||||
} else {
|
||||
value = "%s, %s.class, %d";
|
||||
}
|
||||
|
||||
return value.formatted(quoted(path), toBukkitClass(reference), LEGACY_ID.getOrDefault(reference.value(), -1));
|
||||
}
|
||||
|
||||
private String toBukkitClass(Holder.Reference<EntityType<?>> reference) {
|
||||
Class<? extends Entity> internalClass = ENTITY_GENERIC_TYPES.get(reference.value());
|
||||
if (Mob.class.isAssignableFrom(internalClass)) {
|
||||
return MobGoalNames.bukkitMap.get((Class<? extends Mob>) internalClass).getSimpleName();
|
||||
}
|
||||
|
||||
String className = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, reference.key().location().getPath()); // use the key instead of the internal class name since name match a bit more
|
||||
return CLASS_RENAMES.getOrDefault(className, className);
|
||||
}
|
||||
}
|
|
@ -756,6 +756,26 @@ index d03adfaa4176617ef2ace2754fe02b63860e3aee..fceb2f0a452a1ce72988bbd1ecca599c
|
|||
|
||||
private final NamespacedKey key;
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/EntityType.java b/src/main/java/org/bukkit/entity/EntityType.java
|
||||
index 4aaf268f58038cd5d4101ec3fbfdc20b544d6678..48843885feebcf26a48a23f8085fcb246b6bbe18 100644
|
||||
--- a/src/main/java/org/bukkit/entity/EntityType.java
|
||||
+++ b/src/main/java/org/bukkit/entity/EntityType.java
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public enum EntityType implements Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - translatable
|
||||
|
||||
// These strings MUST match the strings in nms.EntityTypes and are case sensitive.
|
||||
+ // Paper start - Generated/EntityType
|
||||
/**
|
||||
* An item resting on the ground.
|
||||
* <p>
|
||||
@@ -303,6 +304,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans
|
||||
*/
|
||||
LIGHTNING("lightning_bolt", LightningStrike.class, -1, false),
|
||||
PLAYER("player", Player.class, -1, false),
|
||||
+ // Paper end - Generated/EntityType
|
||||
/**
|
||||
* An unknown entity without an Entity Class
|
||||
*/
|
||||
diff --git a/src/main/java/org/bukkit/entity/Fox.java b/src/main/java/org/bukkit/entity/Fox.java
|
||||
index 473a7e36ad64f866d1d2e09e2ecb2e9881668faf..1fb12e0bc77247e9f6562bb7a8d0ff35eecb54a9 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Fox.java
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
||||
Date: Thu, 11 Apr 2024 21:31:18 +0200
|
||||
Subject: [PATCH] fix EntityType#isSpawnable
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/EntityType.java b/src/main/java/org/bukkit/entity/EntityType.java
|
||||
index 48843885feebcf26a48a23f8085fcb246b6bbe18..e32b001ea23d1bf71a5774cfd99279ef08486dd7 100644
|
||||
--- a/src/main/java/org/bukkit/entity/EntityType.java
|
||||
+++ b/src/main/java/org/bukkit/entity/EntityType.java
|
||||
@@ -34,7 +34,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans
|
||||
* Spawn with {@link World#dropItem(Location, ItemStack)} or {@link
|
||||
* World#dropItemNaturally(Location, ItemStack)}
|
||||
*/
|
||||
- DROPPED_ITEM("item", Item.class, 1, false),
|
||||
+ DROPPED_ITEM("item", Item.class, 1),
|
||||
/**
|
||||
* An experience orb.
|
||||
*/
|
||||
@@ -94,7 +94,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans
|
||||
/**
|
||||
* A flying splash potion.
|
||||
*/
|
||||
- SPLASH_POTION("potion", ThrownPotion.class, 16, false),
|
||||
+ SPLASH_POTION("potion", ThrownPotion.class, 16),
|
||||
/**
|
||||
* A flying experience bottle.
|
||||
*/
|
||||
@@ -114,11 +114,11 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans
|
||||
/**
|
||||
* A block that is going to or is about to fall.
|
||||
*/
|
||||
- FALLING_BLOCK("falling_block", FallingBlock.class, 21, false),
|
||||
+ FALLING_BLOCK("falling_block", FallingBlock.class, 21),
|
||||
/**
|
||||
* Internal representation of a Firework once it has been launched.
|
||||
*/
|
||||
- FIREWORK("firework_rocket", Firework.class, 22, false),
|
||||
+ FIREWORK("firework_rocket", Firework.class, 22),
|
||||
/**
|
||||
* @see Husk
|
||||
*/
|
||||
@@ -302,7 +302,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans
|
||||
* <p>
|
||||
* Spawn with {@link World#strikeLightning(Location)}.
|
||||
*/
|
||||
- LIGHTNING("lightning_bolt", LightningStrike.class, -1, false),
|
||||
+ LIGHTNING("lightning_bolt", LightningStrike.class, -1),
|
||||
PLAYER("player", Player.class, -1, false),
|
||||
// Paper end - Generated/EntityType
|
||||
/**
|
Loading…
Reference in New Issue