SPIGOT-7550: Fix creation of Arrow instances

This commit is contained in:
Doc 2023-12-21 08:19:29 +11:00 committed by md_5
parent f03fc3aa3c
commit 5876cca442
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 3 additions and 3 deletions

View File

@ -93,7 +93,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
CraftEntityTypes.EntityTypeData<?, T> entityTypeData = CraftEntityTypes.getEntityTypeData(CraftEntityType.minecraftToBukkit(entity.getType())); CraftEntityTypes.EntityTypeData<?, T> entityTypeData = CraftEntityTypes.getEntityTypeData(CraftEntityType.minecraftToBukkit(entity.getType()));
if (entityTypeData != null) { if (entityTypeData != null) {
return entityTypeData.convertFunction().apply(server, entity); return (CraftEntity) entityTypeData.convertFunction().apply(server, entity);
} }
throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass())); throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass()));

View File

@ -184,7 +184,7 @@ public final class CraftEntityTypes {
public record EntityTypeData<E extends Entity, M extends net.minecraft.world.entity.Entity>(EntityType entityType, public record EntityTypeData<E extends Entity, M extends net.minecraft.world.entity.Entity>(EntityType entityType,
Class<E> entityClass, Class<E> entityClass,
BiFunction<CraftServer, M, CraftEntity> convertFunction, BiFunction<CraftServer, M, E> convertFunction,
Function<SpawnData, M> spawnFunction) { Function<SpawnData, M> spawnFunction) {
} }
@ -340,7 +340,7 @@ public final class CraftEntityTypes {
register(new EntityTypeData<>(EntityType.GLOW_ITEM_FRAME, GlowItemFrame.class, CraftGlowItemFrame::new, createHanging(GlowItemFrame.class, (spawnData, hangingData) -> new net.minecraft.world.entity.decoration.GlowItemFrame(spawnData.minecraftWorld(), hangingData.position(), hangingData.direction())))); register(new EntityTypeData<>(EntityType.GLOW_ITEM_FRAME, GlowItemFrame.class, CraftGlowItemFrame::new, createHanging(GlowItemFrame.class, (spawnData, hangingData) -> new net.minecraft.world.entity.decoration.GlowItemFrame(spawnData.minecraftWorld(), hangingData.position(), hangingData.direction()))));
// Move no rotation // Move no rotation
register(new EntityTypeData<>(EntityType.ARROW, Arrow.class, CraftArrow::new, createAndMoveEmptyRot(EntityTypes.ARROW))); register(new EntityTypeData<>(EntityType.ARROW, Arrow.class, CraftTippedArrow::new, createAndMoveEmptyRot(EntityTypes.ARROW)));
register(new EntityTypeData<>(EntityType.ENDER_PEARL, EnderPearl.class, CraftEnderPearl::new, createAndMoveEmptyRot(EntityTypes.ENDER_PEARL))); register(new EntityTypeData<>(EntityType.ENDER_PEARL, EnderPearl.class, CraftEnderPearl::new, createAndMoveEmptyRot(EntityTypes.ENDER_PEARL)));
register(new EntityTypeData<>(EntityType.THROWN_EXP_BOTTLE, ThrownExpBottle.class, CraftThrownExpBottle::new, createAndMoveEmptyRot(EntityTypes.EXPERIENCE_BOTTLE))); register(new EntityTypeData<>(EntityType.THROWN_EXP_BOTTLE, ThrownExpBottle.class, CraftThrownExpBottle::new, createAndMoveEmptyRot(EntityTypes.EXPERIENCE_BOTTLE)));
register(new EntityTypeData<>(EntityType.SPECTRAL_ARROW, SpectralArrow.class, CraftSpectralArrow::new, createAndMoveEmptyRot(EntityTypes.SPECTRAL_ARROW))); register(new EntityTypeData<>(EntityType.SPECTRAL_ARROW, SpectralArrow.class, CraftSpectralArrow::new, createAndMoveEmptyRot(EntityTypes.SPECTRAL_ARROW)));