From 67a231d8d9b0ba6cfe94405cadd693b143b0c8c0 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Thu, 21 Dec 2023 08:19:29 +1100 Subject: [PATCH] SPIGOT-7550: Fix creation of Arrow instances By: Doc --- .../main/java/org/bukkit/craftbukkit/entity/CraftEntity.java | 2 +- .../java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index dfe6110ef2..5ad14d4a39 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -93,7 +93,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { CraftEntityTypes.EntityTypeData 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())); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java index d1258cfd70..658734fd28 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntityTypes.java @@ -184,7 +184,7 @@ public final class CraftEntityTypes { public record EntityTypeData(EntityType entityType, Class entityClass, - BiFunction convertFunction, + BiFunction convertFunction, Function 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)));