2022-03-11 17:37:08 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Tue, 22 Jun 2021 23:41:11 -0400
Subject: [PATCH] More Projectile API
2022-11-20 00:53:20 +01:00
== AT ==
public net.minecraft.world.entity.projectile.FishingHook timeUntilLured
public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaX
public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaY
public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaZ
public net.minecraft.world.entity.projectile.ShulkerBullet currentMoveDirection
public net.minecraft.world.entity.projectile.ShulkerBullet flightSteps
public net.minecraft.world.entity.projectile.AbstractArrow soundEvent
public net.minecraft.world.entity.projectile.ThrownTrident dealtDamage
public net.minecraft.world.entity.projectile.Projectile hasBeenShot
public net.minecraft.world.entity.projectile.Projectile leftOwner
2023-02-11 16:41:06 +01:00
public net.minecraft.world.entity.projectile.Projectile preOnHit(Lnet/minecraft/world/phys/HitResult;)V
public net.minecraft.world.entity.projectile.Projectile canHitEntity(Lnet/minecraft/world/entity/Entity;)Z
2022-11-20 00:53:20 +01:00
2022-08-14 16:53:36 +02:00
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
2022-03-11 17:37:08 +01:00
2022-08-14 16:53:36 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
index 0204257ca0245830534592922e400a362c347715..252355d19e4f07406f78616e2366182758e0947b 100644
2022-08-14 16:53:36 +02:00
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -101,6 +101,11 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
2022-08-14 16:53:36 +02:00
@Override
protected void onHit(HitResult hitResult) {
super.onHit(hitResult);
+ // Paper start - More projectile API
+ this.splash(hitResult);
+ }
2024-02-10 20:27:29 +01:00
+ public void splash(@Nullable HitResult hitResult) {
2022-08-14 16:53:36 +02:00
+ // Paper end - More projectile API
2023-06-08 10:08:08 +02:00
if (!this.level().isClientSide) {
2022-08-14 16:53:36 +02:00
ItemStack itemstack = this.getItem();
Potion potionregistry = PotionUtils.getPotion(itemstack);
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -114,7 +119,7 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
2022-08-14 16:53:36 +02:00
if (this.isLingering()) {
2023-10-29 00:02:13 +02:00
showParticles = this.makeAreaOfEffectCloud(itemstack, potionregistry, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper
2022-08-14 16:53:36 +02:00
} else {
2023-10-29 00:02:13 +02:00
- showParticles = this.applySplash(list, hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper
2024-01-18 18:52:00 +01:00
+ showParticles = this.applySplash(list, hitResult != null && hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper - More projectile API
2022-08-14 16:53:36 +02:00
}
}
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -176,7 +181,7 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
2023-10-29 00:02:13 +02:00
}
2024-01-19 13:22:30 +01:00
- private boolean applySplash(List<MobEffectInstance> list, @Nullable Entity entity, HitResult position) { // CraftBukkit - Pass MovingObjectPosition // Paper - Fix potions splash events
+ private boolean applySplash(List<MobEffectInstance> list, @Nullable Entity entity, @Nullable HitResult position) { // CraftBukkit - Pass MovingObjectPosition // Paper - Fix potions splash events & More projectile API
2023-10-29 00:02:13 +02:00
AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
List<net.minecraft.world.entity.LivingEntity> list1 = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb);
Map<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>(); // CraftBukkit
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -253,7 +258,7 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
2023-10-29 00:02:13 +02:00
}
- private boolean makeAreaOfEffectCloud(ItemStack itemstack, Potion potionregistry, HitResult position) { // CraftBukkit - Pass MovingObjectPosition // Paper - return boolean
2024-01-18 18:52:00 +01:00
+ private boolean makeAreaOfEffectCloud(ItemStack itemstack, Potion potionregistry, @Nullable HitResult position) { // CraftBukkit - Pass MovingObjectPosition // Paper - return boolean & More projectile API
2023-10-29 00:02:13 +02:00
AreaEffectCloud entityareaeffectcloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
Entity entity = this.getOwner();
2022-10-11 23:04:26 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java
2024-01-18 18:52:00 +01:00
index 91c2d0b40d3fca86938cd454e1415a4eea3df7c7..c1c52f4fc5f900fac4098e5e37c52dfc4e82b8bb 100644
2022-10-11 23:04:26 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java
2023-09-29 02:28:26 +02:00
@@ -17,4 +17,65 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti
@Override
public void setBounce(boolean doesBounce) {}
2024-01-18 18:52:00 +01:00
+ // Paper start - More projectile API
2022-10-11 23:04:26 +02:00
+ @Override
+ public boolean hasLeftShooter() {
+ return this.getHandle().leftOwner;
+ }
+
+ @Override
+ public void setHasLeftShooter(boolean leftShooter) {
+ this.getHandle().leftOwner = leftShooter;
+ }
+
+ @Override
+ public boolean hasBeenShot() {
+ return this.getHandle().hasBeenShot;
+ }
+
+ @Override
+ public void setHasBeenShot(boolean beenShot) {
+ this.getHandle().hasBeenShot = beenShot;
+ }
+
+ @Override
2023-02-11 16:41:06 +01:00
+ public boolean canHitEntity(org.bukkit.entity.Entity entity) {
+ return this.getHandle().canHitEntity(((CraftEntity) entity).getHandle());
+ }
+
+ @Override
+ public void hitEntity(org.bukkit.entity.Entity entity) {
+ this.getHandle().preOnHit(new net.minecraft.world.phys.EntityHitResult(((CraftEntity) entity).getHandle()));
+ }
+
+ @Override
+ public void hitEntity(org.bukkit.entity.Entity entity, org.bukkit.util.Vector vector) {
+ this.getHandle().preOnHit(new net.minecraft.world.phys.EntityHitResult(((CraftEntity) entity).getHandle(), new net.minecraft.world.phys.Vec3(vector.getX(), vector.getY(), vector.getZ())));
+ }
+
+ @Override
2022-10-11 23:04:26 +02:00
+ public net.minecraft.world.entity.projectile.Projectile getHandle() {
+ return (net.minecraft.world.entity.projectile.Projectile) entity;
+ }
2023-06-01 04:43:51 +02:00
+
+ @Override
+ public final org.bukkit.projectiles.ProjectileSource getShooter() {
+ return this.getHandle().projectileSource;
+ }
+
+ @Override
+ public final void setShooter(org.bukkit.projectiles.ProjectileSource shooter) {
+ if (shooter instanceof CraftEntity craftEntity) {
+ this.getHandle().setOwner(craftEntity.getHandle());
+ } else {
+ this.getHandle().setOwner(null);
+ }
+ this.getHandle().projectileSource = shooter;
+ }
+
+ @Override
+ public java.util.UUID getOwnerUniqueId() {
+ return this.getHandle().ownerUUID;
+ }
2024-01-18 18:52:00 +01:00
+ // Paper end - More projectile API
2022-10-11 23:04:26 +02:00
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
2024-04-06 21:53:39 +02:00
index a24a6fe5bf634bb02654b0ec4f771aa07458ce84..0fd2677181d741e553b9825c8c319a209194ec46 100644
2022-10-11 23:04:26 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java
2024-04-06 21:53:39 +02:00
@@ -60,20 +60,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
2023-06-01 04:43:51 +02:00
this.getHandle().setCritArrow(critical);
}
- @Override
- public ProjectileSource getShooter() {
- return this.getHandle().projectileSource;
- }
-
- @Override
- public void setShooter(ProjectileSource shooter) {
- if (shooter instanceof Entity) {
- this.getHandle().setOwner(((CraftEntity) shooter).getHandle());
- } else {
- this.getHandle().setOwner(null);
- }
- this.getHandle().projectileSource = shooter;
- }
+ // Paper - moved to AbstractProjectile
@Override
public boolean isInBlock() {
2024-04-06 21:53:39 +02:00
@@ -101,6 +88,35 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
2024-03-23 22:26:17 +01:00
this.getHandle().pickup = net.minecraft.world.entity.projectile.AbstractArrow.Pickup.byOrdinal(status.ordinal());
2022-10-11 23:04:26 +02:00
}
2024-03-23 22:26:17 +01:00
+ // Paper start
+ @Override
+ @org.jetbrains.annotations.NotNull
+ public org.bukkit.craftbukkit.inventory.CraftItemStack getItemStack() {
+ return org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(getHandle().getPickupItem());
+ }
+
2022-10-11 23:04:26 +02:00
+ @Override
+ public void setLifetimeTicks(int ticks) {
+ this.getHandle().life = ticks;
+ }
+
+ @Override
+ public int getLifetimeTicks() {
+ return this.getHandle().life;
+ }
+
+ @org.jetbrains.annotations.NotNull
+ @Override
+ public org.bukkit.Sound getHitSound() {
2023-09-23 04:06:03 +02:00
+ return org.bukkit.craftbukkit.CraftSound.minecraftToBukkit(this.getHandle().soundEvent);
2022-10-11 23:04:26 +02:00
+ }
+
+ @Override
+ public void setHitSound(@org.jetbrains.annotations.NotNull org.bukkit.Sound sound) {
2023-09-23 04:06:03 +02:00
+ this.getHandle().setSoundEvent(org.bukkit.craftbukkit.CraftSound.bukkitToMinecraft(sound));
2022-10-11 23:04:26 +02:00
+ }
2024-03-23 22:26:17 +01:00
+ // Paper end
2022-10-11 23:04:26 +02:00
+
@Override
2024-03-23 22:26:17 +01:00
public void setTicksLived(int value) {
super.setTicksLived(value);
2023-06-01 04:43:51 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java
2024-03-23 22:26:17 +01:00
index e1a2f0924da6ebcdf332040f922226af5d8a2d45..a8699b274b51c5f6691557c3c3db88436f05e304 100644
2023-06-01 04:43:51 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java
2023-08-14 01:32:51 +02:00
@@ -32,20 +32,7 @@ public class CraftFireball extends AbstractProjectile implements Fireball {
2023-06-01 04:43:51 +02:00
this.getHandle().bukkitYield = yield;
}
- @Override
- public ProjectileSource getShooter() {
- return this.getHandle().projectileSource;
- }
-
- @Override
- public void setShooter(ProjectileSource shooter) {
- if (shooter instanceof CraftLivingEntity) {
- this.getHandle().setOwner(((CraftLivingEntity) shooter).getHandle());
- } else {
- this.getHandle().setOwner(null);
- }
- this.getHandle().projectileSource = shooter;
- }
+ // Paper - moved to AbstractProjectile
@Override
public Vector getDirection() {
2022-03-11 17:37:08 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
2024-01-19 22:13:42 +01:00
index c9e15a9d82dee935293b2e7e233f5b9b2d822448..fedbfbac02b73382aacc69f8a1e5a3e746c55ea2 100644
2022-03-11 17:37:08 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
2023-08-14 01:32:51 +02:00
@@ -15,24 +15,26 @@ import org.bukkit.inventory.meta.FireworkMeta;
2022-03-11 17:37:08 +01:00
public class CraftFirework extends CraftProjectile implements Firework {
private final Random random = new Random();
- private final CraftItemStack item;
+ //private CraftItemStack item; // Paper - Remove usage, not accurate representation of current item.
public CraftFirework(CraftServer server, FireworkRocketEntity entity) {
super(server, entity);
- ItemStack item = this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM);
-
- if (item.isEmpty()) {
- item = new ItemStack(Items.FIREWORK_ROCKET);
- this.getHandle().getEntityData().set(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM, item);
- }
-
- this.item = CraftItemStack.asCraftMirror(item);
-
- // Ensure the item is a firework...
- if (this.item.getType() != Material.FIREWORK_ROCKET) {
- this.item.setType(Material.FIREWORK_ROCKET);
- }
2024-01-19 22:13:42 +01:00
+// Paper start - Expose firework item directly
2022-03-11 17:37:08 +01:00
+// ItemStack item = this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM);
+//
+// if (item.isEmpty()) {
+// item = new ItemStack(Items.FIREWORK_ROCKET);
+// this.getHandle().getEntityData().set(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM, item);
+// }
+//
+// this.item = CraftItemStack.asCraftMirror(item);
+//
+// // Ensure the item is a firework...
+// if (this.item.getType() != Material.FIREWORK_ROCKET) {
+// this.item.setType(Material.FIREWORK_ROCKET);
+// }
2024-01-19 22:13:42 +01:00
+ // Paper end - Expose firework item directly
2022-03-11 17:37:08 +01:00
}
@Override
2023-08-14 01:32:51 +02:00
@@ -47,12 +49,12 @@ public class CraftFirework extends CraftProjectile implements Firework {
2022-03-11 17:37:08 +01:00
@Override
public FireworkMeta getFireworkMeta() {
- return (FireworkMeta) this.item.getItemMeta();
+ return (FireworkMeta) CraftItemStack.getItemMeta(this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM), Material.FIREWORK_ROCKET); // Paper - Expose firework item directly
}
@Override
public void setFireworkMeta(FireworkMeta meta) {
- this.item.setItemMeta(meta);
+ applyFireworkEffect(meta); // Paper - Expose firework item directly
2022-03-12 21:34:03 +01:00
2022-03-11 17:37:08 +01:00
// Copied from EntityFireworks constructor, update firework lifetime/power
this.getHandle().lifetime = 10 * (1 + meta.getPower()) + this.random.nextInt(6) + this.random.nextInt(7);
2023-08-14 01:32:51 +02:00
@@ -136,4 +138,46 @@ public class CraftFirework extends CraftProjectile implements Firework {
2022-09-12 13:31:45 +02:00
return getHandle().spawningEntity;
2022-03-11 17:37:08 +01:00
}
// Paper end
+ // Paper start - Expose firework item directly + manually setting flight
+ @Override
+ public org.bukkit.inventory.ItemStack getItem() {
+ return CraftItemStack.asBukkitCopy(this.getHandle().getItem());
+ }
+
+ @Override
+ public void setItem(org.bukkit.inventory.ItemStack itemStack) {
+ FireworkMeta meta = getFireworkMeta();
2022-03-12 21:34:03 +01:00
+ ItemStack nmsItem = itemStack == null ? ItemStack.EMPTY : CraftItemStack.asNMSCopy(itemStack);
2022-03-11 17:37:08 +01:00
+ this.getHandle().getEntityData().set(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM, nmsItem);
+
+ applyFireworkEffect(meta);
+ }
+
+ @Override
+ public int getTicksFlown() {
+ return this.getHandle().life;
+ }
+
+ @Override
+ public void setTicksFlown(int ticks) {
+ this.getHandle().life = ticks;
+ }
+
+ @Override
+ public int getTicksToDetonate() {
+ return this.getHandle().lifetime;
+ }
+
+ @Override
+ public void setTicksToDetonate(int ticks) {
+ this.getHandle().lifetime = ticks;
+ }
+
+ void applyFireworkEffect(FireworkMeta meta) {
2022-03-12 21:34:03 +01:00
+ ItemStack item = this.getHandle().getItem();
+ CraftItemStack.applyMetaToItem(item, meta);
+
+ this.getHandle().getEntityData().set(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM, item);
2022-03-11 17:37:08 +01:00
+ }
+ // Paper end - Expose firework item directly + manually setting flight
}
2022-03-13 23:33:01 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java
2023-10-27 01:34:58 +02:00
index 6e2f91423371ead9890095cf4b1e2299c4dcba28..ad1aeea80877f2cdb9e8ad9c5b46f95dd76b3335 100644
2022-03-13 23:33:01 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java
2023-08-14 01:32:51 +02:00
@@ -196,4 +196,15 @@ public class CraftFishHook extends CraftProjectile implements FishHook {
2022-03-13 23:33:01 +01:00
public HookState getState() {
return HookState.values()[this.getHandle().currentState.ordinal()];
}
+ // Paper start - More FishHook API
+ @Override
+ public int getWaitTime() {
+ return this.getHandle().timeUntilLured;
+ }
+
+ @Override
+ public void setWaitTime(int ticks) {
+ this.getHandle().timeUntilLured = ticks;
+ }
+ // Paper end
}
2023-06-01 04:43:51 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java
2023-08-14 01:32:51 +02:00
index 70cbc6c668c60e9d608ca7013b72f9b916c05c2d..47633f05b4fab1dcabc2117e7645fe6d6949622a 100644
2023-06-01 04:43:51 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java
2023-08-14 01:32:51 +02:00
@@ -20,13 +20,5 @@ public class CraftLlamaSpit extends AbstractProjectile implements LlamaSpit {
return "CraftLlamaSpit";
2023-06-01 04:43:51 +02:00
}
- @Override
- public ProjectileSource getShooter() {
- return (this.getHandle().getOwner() != null) ? (ProjectileSource) this.getHandle().getOwner().getBukkitEntity() : null;
- }
-
- @Override
- public void setShooter(ProjectileSource source) {
- this.getHandle().setOwner((source != null) ? ((CraftLivingEntity) source).getHandle() : null);
- }
+ // Paper - moved to AbstractProjectile
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java
2023-10-27 01:34:58 +02:00
index 696fdfa723aa896a67946f862d7c6890f7f7ab17..4f1fa7dec78970bdfc184d3c1f1632dc9d75a574 100644
2023-06-01 04:43:51 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java
@@ -10,20 +10,7 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj
super(server, entity);
}
- @Override
- public ProjectileSource getShooter() {
- return this.getHandle().projectileSource;
- }
-
- @Override
- public void setShooter(ProjectileSource shooter) {
- if (shooter instanceof CraftLivingEntity) {
- this.getHandle().setOwner((LivingEntity) ((CraftLivingEntity) shooter).entity);
- } else {
- this.getHandle().setOwner(null);
- }
- this.getHandle().projectileSource = shooter;
- }
+ // Paper - moved to AbstractProjectile
@Override
public net.minecraft.world.entity.projectile.Projectile getHandle() {
2022-10-11 23:04:26 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java
2023-10-27 01:34:58 +02:00
index d685d09cae5f862c0004f148298c800736d2139e..636c4481e3afdf20197e502cf221f5d34d18f101 100644
2022-10-11 23:04:26 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java
2023-08-14 01:32:51 +02:00
@@ -12,20 +12,7 @@ public class CraftShulkerBullet extends AbstractProjectile implements ShulkerBul
2023-06-01 04:43:51 +02:00
super(server, entity);
}
- @Override
- public ProjectileSource getShooter() {
- return this.getHandle().projectileSource;
- }
-
- @Override
- public void setShooter(ProjectileSource shooter) {
- if (shooter instanceof Entity) {
- this.getHandle().setOwner(((CraftEntity) shooter).getHandle());
- } else {
- this.getHandle().setOwner(null);
- }
- this.getHandle().projectileSource = shooter;
- }
+ // Paper - moved to AbstractProjectile
@Override
public org.bukkit.entity.Entity getTarget() {
2023-08-14 01:32:51 +02:00
@@ -39,6 +26,40 @@ public class CraftShulkerBullet extends AbstractProjectile implements ShulkerBul
2022-10-11 23:04:26 +02:00
this.getHandle().setTarget(target == null ? null : ((CraftEntity) target).getHandle());
}
+ @Override
+ public org.bukkit.util.Vector getTargetDelta() {
+ net.minecraft.world.entity.projectile.ShulkerBullet bullet = this.getHandle();
+ return new org.bukkit.util.Vector(bullet.targetDeltaX, bullet.targetDeltaY, bullet.targetDeltaZ);
+ }
+
+ @Override
+ public void setTargetDelta(org.bukkit.util.Vector vector) {
+ net.minecraft.world.entity.projectile.ShulkerBullet bullet = this.getHandle();
+ bullet.targetDeltaX = vector.getX();
+ bullet.targetDeltaY = vector.getY();
+ bullet.targetDeltaZ = vector.getZ();
+ }
+
+ @Override
+ public org.bukkit.block.BlockFace getCurrentMovementDirection() {
+ return org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(this.getHandle().currentMoveDirection);
+ }
+
+ @Override
+ public void setCurrentMovementDirection(org.bukkit.block.BlockFace movementDirection) {
+ this.getHandle().currentMoveDirection = org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(movementDirection);
+ }
+
+ @Override
+ public int getFlightSteps() {
+ return this.getHandle().flightSteps;
+ }
+
+ @Override
+ public void setFlightSteps(int steps) {
+ this.getHandle().flightSteps = steps;
+ }
+
@Override
public String toString() {
return "CraftShulkerBullet";
2022-03-11 17:37:08 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java
2023-10-27 01:34:58 +02:00
index 269af20a6d0d100909a0aea0bdba307ea0658f3e..d5f1681a476c8fe2ae128a84910f4bf04063b75a 100644
2022-03-11 17:37:08 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java
2023-08-14 01:32:51 +02:00
@@ -35,11 +35,31 @@ public class CraftThrownPotion extends CraftThrowableProjectile implements Throw
2023-06-13 01:51:45 +02:00
@Override
public void setItem(ItemStack item) {
Preconditions.checkArgument(item != null, "ItemStack cannot be null");
- Preconditions.checkArgument(item.getType() == Material.LINGERING_POTION || item.getType() == Material.SPLASH_POTION, "ItemStack material must be Material.LINGERING_POTION or Material.SPLASH_POTION but was Material.%s", item.getType());
+ // Preconditions.checkArgument(item.getType() == Material.LINGERING_POTION || item.getType() == Material.SPLASH_POTION, "ItemStack material must be Material.LINGERING_POTION or Material.SPLASH_POTION but was Material.%s", item.getType()); // Paper - Projectile API
2022-04-22 02:07:56 +02:00
+ org.bukkit.inventory.meta.PotionMeta meta = (item.getType() == Material.LINGERING_POTION || item.getType() == Material.SPLASH_POTION) ? null : this.getPotionMeta(); // Paper - Projectile API
2022-03-11 17:37:08 +01:00
this.getHandle().setItem(CraftItemStack.asNMSCopy(item));
2022-04-22 02:07:56 +02:00
+ if (meta != null) this.setPotionMeta(meta); // Paper - Projectile API
2022-03-11 17:37:08 +01:00
}
+ // Paper start - Projectile API
+ @Override
+ public org.bukkit.inventory.meta.PotionMeta getPotionMeta() {
+ return (org.bukkit.inventory.meta.PotionMeta) CraftItemStack.getItemMeta(this.getHandle().getItemRaw(), Material.SPLASH_POTION);
+ }
+
+ @Override
+ public void setPotionMeta(org.bukkit.inventory.meta.PotionMeta meta) {
2022-03-12 21:34:03 +01:00
+ net.minecraft.world.item.ItemStack item = this.getHandle().getItem();
+ CraftItemStack.applyMetaToItem(item, meta);
+ this.getHandle().setItem(item); // Reset item
2022-03-11 17:37:08 +01:00
+ }
2022-08-14 16:53:36 +02:00
+
+ @Override
+ public void splash() {
+ this.getHandle().splash(null);
+ }
2022-03-11 17:37:08 +01:00
+ // Paper end
@Override
public net.minecraft.world.entity.projectile.ThrownPotion getHandle() {
2023-10-27 01:34:58 +02:00
return (net.minecraft.world.entity.projectile.ThrownPotion) this.entity;
2022-10-11 23:04:26 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java
2023-12-06 17:00:26 +01:00
index 20f9735c7cb76024e15dbdca7684f5c560876175..8a6af0db8e0aa0cffbf19584be747076c2c8ee44 100644
2022-10-11 23:04:26 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java
2023-08-14 01:32:51 +02:00
@@ -53,5 +53,15 @@ public class CraftTrident extends CraftArrow implements Trident {
2022-10-11 23:04:26 +02:00
com.google.common.base.Preconditions.checkArgument(loyaltyLevel >= 0 && loyaltyLevel <= 127, "The loyalty level has to be between 0 and 127");
this.getHandle().setLoyalty((byte) loyaltyLevel);
}
+
+ @Override
+ public boolean hasDealtDamage() {
+ return this.getHandle().dealtDamage;
+ }
+
+ @Override
+ public void setHasDealtDamage(boolean hasDealtDamage) {
+ this.getHandle().dealtDamage = hasDealtDamage;
+ }
// Paper end
}
2023-10-29 00:02:13 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
2024-04-06 21:53:39 +02:00
index 7d72ccdd82daa6afe85859f5bc6ec7b187622384..fb0426a1d864f3c60637e394e5bedb3963677df1 100644
2023-10-29 00:02:13 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
2024-04-06 21:53:39 +02:00
@@ -833,19 +833,19 @@ public class CraftEventFactory {
2023-10-29 00:02:13 +02:00
/**
* PotionSplashEvent
*/
- public static PotionSplashEvent callPotionSplashEvent(net.minecraft.world.entity.projectile.ThrownPotion potion, HitResult position, Map<LivingEntity, Double> affectedEntities) {
+ public static PotionSplashEvent callPotionSplashEvent(net.minecraft.world.entity.projectile.ThrownPotion potion, @Nullable HitResult position, Map<LivingEntity, Double> affectedEntities) { // Paper - nullable hitResult
ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity();
Block hitBlock = null;
BlockFace hitFace = null;
- if (position.getType() == HitResult.Type.BLOCK) {
+ if (position != null && position.getType() == HitResult.Type.BLOCK) { // Paper - nullable hitResult
BlockHitResult positionBlock = (BlockHitResult) position;
hitBlock = CraftBlock.at(potion.level(), positionBlock.getBlockPos());
hitFace = CraftBlock.notchToBlockFace(positionBlock.getDirection());
}
org.bukkit.entity.Entity hitEntity = null;
- if (position.getType() == HitResult.Type.ENTITY) {
+ if (position != null && position.getType() == HitResult.Type.ENTITY) { // Paper - nullable hitResult
hitEntity = ((EntityHitResult) position).getEntity().getBukkitEntity();
}
2024-04-06 21:53:39 +02:00
@@ -854,20 +854,20 @@ public class CraftEventFactory {
2023-10-29 00:02:13 +02:00
return event;
}
- public static LingeringPotionSplashEvent callLingeringPotionSplashEvent(net.minecraft.world.entity.projectile.ThrownPotion potion, HitResult position, net.minecraft.world.entity.AreaEffectCloud cloud) {
+ public static LingeringPotionSplashEvent callLingeringPotionSplashEvent(net.minecraft.world.entity.projectile.ThrownPotion potion, @Nullable HitResult position, net.minecraft.world.entity.AreaEffectCloud cloud) { // Paper - nullable hitResult
ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity();
AreaEffectCloud effectCloud = (AreaEffectCloud) cloud.getBukkitEntity();
Block hitBlock = null;
BlockFace hitFace = null;
- if (position.getType() == HitResult.Type.BLOCK) {
+ if (position != null && position.getType() == HitResult.Type.BLOCK) { // Paper
BlockHitResult positionBlock = (BlockHitResult) position;
hitBlock = CraftBlock.at(potion.level(), positionBlock.getBlockPos());
hitFace = CraftBlock.notchToBlockFace(positionBlock.getDirection());
}
org.bukkit.entity.Entity hitEntity = null;
- if (position.getType() == HitResult.Type.ENTITY) {
+ if (position != null && position.getType() == HitResult.Type.ENTITY) { // Paper
hitEntity = ((EntityHitResult) position).getEntity().getBukkitEntity();
}
2022-03-11 17:37:08 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
2024-01-26 20:17:06 +01:00
index 7ce48473222516aefda3c5ad40e5e3fd23502e3d..6725c0824b986885c8aade846f6e159986ffbe59 100644
2022-03-11 17:37:08 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
2024-01-26 20:17:06 +01:00
@@ -294,12 +294,20 @@ public final class CraftItemStack extends ItemStack {
2022-03-11 17:37:08 +01:00
public ItemMeta getItemMeta() {
return CraftItemStack.getItemMeta(this.handle);
}
+ // Paper start
+ public static void applyMetaToItem(net.minecraft.world.item.ItemStack itemStack, ItemMeta meta) {
+ ((org.bukkit.craftbukkit.inventory.CraftMetaItem) meta).applyToItem(itemStack.getOrCreateTag());
+ }
public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item) {
+ return getItemMeta(item, CraftItemStack.getType(item));
+ }
+ public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item, Material material) {
+ // Paper end
if (!CraftItemStack.hasItemMeta(item)) {
- return CraftItemFactory.instance().getItemMeta(CraftItemStack.getType(item));
+ return CraftItemFactory.instance().getItemMeta(material); // Paper
}
- switch (CraftItemStack.getType(item)) {
+ switch (material) { // Paper
case WRITTEN_BOOK:
return new CraftMetaBookSigned(item.getTag());
case WRITABLE_BOOK: