mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 10:35:38 +01:00
d1a72eac31
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: 1fc1020a PR-1049: Add MenuType API 8ae2e3be PR-1055: Expand riptiding API cac68bfb SPIGOT-7890: AttributeModifier#getUniqueId() doesn't match the UUID passed to its constructor 7004fcf2 SPIGOT-7886: Fix mistake in AttributeModifier UUID shim 1ac7f950 PR-1054: Add FireworkMeta#hasPower 4cfb565f SPIGOT-7873: Add powered state for skulls CraftBukkit Changes: bbb30e7a8 SPIGOT-7894: NPE when sending tile entity update ba21e9472 SPIGOT-7895: PlayerItemBreakEvent not firing 0fb24bbe0 SPIGOT-7875: Fix PlayerItemConsumeEvent cancellation causing client-side desync 815066449 SPIGOT-7891: Can't remove second ingredient of MerchantRecipe 45c206f2c PR-1458: Add MenuType API 19c8ef9ae SPIGOT-7867: Merchant instanceof AbstractVillager always returns false 4e006d28f PR-1468: Expand riptiding API bd8aded7d Ignore checks in CraftPlayerProfile for ResolvableProfile used in profile components 8679620b5 SPIGOT-7889: Fix tool component deserialisation without speed and/or correct-for-drops 8d5222691 SPIGOT-7882, PR-1467: Fix conversion of name in Profile Component to empty if it is missing 63f91669a SPIGOT-7887: Remove duplicate ProjectileHitEvent for fireballs 7070de8c8 SPIGOT-7878: Server#getLootTable does not return null on invalid loot table 060ee6cae SPIGOT-7876: Can't kick player or disconnect player in PlayerLoginEvent when checking for cookies 7ccb86cc0 PR-1465: Add FireworkMeta#hasPower 804ad6491 SPIGOT-7873: Add powered state for skulls f9610cdcb Improve minecart movement Spigot Changes: a759b629 Rebuild patches Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
162 lines
6.2 KiB
Diff
162 lines
6.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
|
Date: Sat, 22 Jun 2024 21:17:54 +0200
|
|
Subject: [PATCH] Leashable API
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/entity/PaperLeashable.java b/src/main/java/io/papermc/paper/entity/PaperLeashable.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..a9ddf9a4a07cd29833f38d7e5f42b2b14ec98f78
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/entity/PaperLeashable.java
|
|
@@ -0,0 +1,50 @@
|
|
+package io.papermc.paper.entity;
|
|
+
|
|
+import com.google.common.base.Preconditions;
|
|
+import net.minecraft.world.entity.Leashable;
|
|
+import org.bukkit.craftbukkit.entity.CraftEntity;
|
|
+import org.bukkit.entity.Entity;
|
|
+
|
|
+public interface PaperLeashable extends io.papermc.paper.entity.Leashable {
|
|
+
|
|
+ Leashable getHandle();
|
|
+
|
|
+ @Override
|
|
+ default boolean isLeashed() {
|
|
+ return this.getHandle().getLeashHolder() != null;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ default Entity getLeashHolder() throws IllegalStateException {
|
|
+ Preconditions.checkState(this.isLeashed(), "Entity not leashed");
|
|
+ return this.getHandle().getLeashHolder().getBukkitEntity();
|
|
+ }
|
|
+
|
|
+ private boolean unleash() {
|
|
+ if (!this.isLeashed()) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ this.getHandle().dropLeash(true, false);
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ default boolean setLeashHolder(Entity holder) {
|
|
+ if (this.getHandle() instanceof net.minecraft.world.entity.Entity entity && entity.generation) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ if (holder == null) {
|
|
+ return this.unleash();
|
|
+ }
|
|
+
|
|
+ if (holder.isDead()) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ this.unleash();
|
|
+ this.getHandle().setLeashedTo(((CraftEntity) holder).getHandle(), true);
|
|
+ return true;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
|
|
index e33b1b6fd50a4eea57500cc00dba20d6edcab75d..01a9660de65688b7c1a4f9dafcb650774ce1853b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
|
|
@@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
|
import org.bukkit.entity.Boat;
|
|
import org.bukkit.entity.Entity;
|
|
|
|
-public class CraftBoat extends CraftVehicle implements Boat {
|
|
+public class CraftBoat extends CraftVehicle implements Boat, io.papermc.paper.entity.PaperLeashable { // Paper - Leashable API
|
|
|
|
public CraftBoat(CraftServer server, net.minecraft.world.entity.vehicle.Boat entity) {
|
|
super(server, entity);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
index a54cf98661cc678277855f21735e98fafd018ded..a46fbd2a5e31dd9aa7fcf0867c91ec8d28990861 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -753,43 +753,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|
|
|
@Override
|
|
public boolean isLeashed() {
|
|
- if (!(this.getHandle() instanceof Mob)) {
|
|
- return false;
|
|
- }
|
|
- return ((Mob) this.getHandle()).getLeashHolder() != null;
|
|
+ return false; // Paper - implement in CraftMob & PaperLeashable
|
|
}
|
|
|
|
@Override
|
|
public Entity getLeashHolder() throws IllegalStateException {
|
|
- Preconditions.checkState(this.isLeashed(), "Entity not leashed");
|
|
- return ((Mob) this.getHandle()).getLeashHolder().getBukkitEntity();
|
|
- }
|
|
-
|
|
- private boolean unleash() {
|
|
- if (!this.isLeashed()) {
|
|
- return false;
|
|
- }
|
|
- ((Mob) this.getHandle()).dropLeash(true, false);
|
|
- return true;
|
|
+ throw new IllegalStateException("Entity not leashed"); // Paper - implement in CraftMob & PaperLeashable
|
|
}
|
|
|
|
@Override
|
|
public boolean setLeashHolder(Entity holder) {
|
|
- if (this.getHandle().generation || (this.getHandle() instanceof WitherBoss) || !(this.getHandle() instanceof Mob)) {
|
|
- return false;
|
|
- }
|
|
-
|
|
- if (holder == null) {
|
|
- return this.unleash();
|
|
- }
|
|
-
|
|
- if (holder.isDead()) {
|
|
- return false;
|
|
- }
|
|
-
|
|
- this.unleash();
|
|
- ((Mob) this.getHandle()).setLeashedTo(((CraftEntity) holder).getHandle(), true);
|
|
- return true;
|
|
+ return false; // Paper - implement in CraftMob & PaperLeashable
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
|
index deb66c04abefb4a88521483db1612e494bd27164..5f9f7e325e3e0276f7a475c4a4725cc0e1b54afd 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
|
@@ -11,7 +11,7 @@ import org.bukkit.entity.LivingEntity;
|
|
import org.bukkit.entity.Mob;
|
|
import org.bukkit.loot.LootTable;
|
|
|
|
-public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
|
+public abstract class CraftMob extends CraftLivingEntity implements Mob, io.papermc.paper.entity.PaperLeashable { // Paper - Leashable API
|
|
public CraftMob(CraftServer server, net.minecraft.world.entity.Mob entity) {
|
|
super(server, entity);
|
|
paperPathfinder = new com.destroystokyo.paper.entity.PaperPathfinder(entity); // Paper - Mob Pathfinding API
|
|
@@ -175,4 +175,21 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
|
return getHandle().getExperienceReward((ServerLevel) this.getHandle().level(), null);
|
|
}
|
|
// Paper end
|
|
+
|
|
+ // Paper start - Leashable API
|
|
+ @Override
|
|
+ public boolean isLeashed() {
|
|
+ return io.papermc.paper.entity.PaperLeashable.super.isLeashed();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public org.bukkit.entity.Entity getLeashHolder() throws IllegalStateException {
|
|
+ return io.papermc.paper.entity.PaperLeashable.super.getLeashHolder();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean setLeashHolder(final org.bukkit.entity.Entity holder) {
|
|
+ return io.papermc.paper.entity.PaperLeashable.super.setLeashHolder(holder);
|
|
+ }
|
|
+ // Paper end - Leashable API
|
|
}
|