SPIGOT-7550: Fix creation of Arrow instances

By: Doc <nachito94@msn.com>
This commit is contained in:
CraftBukkit/Spigot 2023-12-21 08:19:29 +11:00
parent 1b81fe827e
commit 67a231d8d9
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()));
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()));

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,
Class<E> entityClass,
BiFunction<CraftServer, M, CraftEntity> convertFunction,
BiFunction<CraftServer, M, E> convertFunction,
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()))));
// 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.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)));