mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@29b17a8 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9088) PaperMC/Paper@b5ce6e3 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9104) PaperMC/Paper@9cda284 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@f8c0112 {ci skip} add missing labels to project status map (#9106) PaperMC/Paper@6a7fef0 Allow entity effect changes off the main thread for worldgen (#8942) PaperMC/Paper@f8d2f82 Resolve Plugin Dependency Issues, Improve PluginLoading Compat, Small Loading Issues (#9068) PaperMC/Paper@b626528 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@058d7c1 Updated Upstream (Bukkit/CraftBukkit/Spigot) PaperMC/Paper@ab72b12 Update Adventure to 4.13.1 (#9113) PaperMC/Paper@8be7a60 Fix getBrightness and getRawBrightness throwing exception in BlockStateListPopulator (#9111) PaperMC/Paper@e811927 Revert "Resolve Plugin Dependency Issues, Improve PluginLoading Compat, Small Loading Issues (#9068)" Pufferfish Changes: pufferfish-gg/Pufferfish@da9fd85 Updated Upstream (Paper) pufferfish-gg/Pufferfish@751dfb0 Updated Upstream (Paper) pufferfish-gg/Pufferfish@c09a154 Updated Upstream (Paper) pufferfish-gg/Pufferfish@b778163 Updated Upstream (Paper)
216 lines
6.5 KiB
Diff
216 lines
6.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Sat, 4 May 2019 00:57:16 -0500
|
|
Subject: [PATCH] Ridables
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
|
index 998f629852e1103767e005405d1f39c2251ecd28..49cba8a3226e4e2f2b11f3171c29e975bc6ec52b 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java
|
|
@@ -200,6 +200,12 @@ public interface VanillaGoal<T extends Mob> extends Goal<T> {
|
|
GoalKey<Mob> CLIMB_ON_TOP_OF_POWDER_SNOW = GoalKey.of(Mob.class, NamespacedKey.minecraft("climb_on_top_of_powder_snow"));
|
|
GoalKey<Wolf> WOLF_PANIC = GoalKey.of(Wolf.class, NamespacedKey.minecraft("wolf_panic"));
|
|
|
|
+ // Purpur start
|
|
+ GoalKey<Mob> MOB_HAS_RIDER = GoalKey.of(Mob.class, NamespacedKey.minecraft("has_rider"));
|
|
+ GoalKey<AbstractHorse> HORSE_HAS_RIDER = GoalKey.of(AbstractHorse.class, NamespacedKey.minecraft("horse_has_rider"));
|
|
+ GoalKey<Llama> LLAMA_HAS_RIDER = GoalKey.of(Llama.class, NamespacedKey.minecraft("llama_has_rider"));
|
|
+ // Purpur end
|
|
+
|
|
/**
|
|
* @deprecated removed in 1.16
|
|
*/
|
|
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
|
index a2a423d4e4c2702ba5967223cab0432dd7d04732..c6ece3f3a6a12998dab7f3c69a2af78bd22fdd48 100644
|
|
--- a/src/main/java/org/bukkit/entity/Entity.java
|
|
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
|
@@ -954,4 +954,35 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
|
*/
|
|
boolean wouldCollideUsing(@NotNull BoundingBox boundingBox);
|
|
// Paper End - Collision API
|
|
+
|
|
+ // Purpur start
|
|
+ /**
|
|
+ * Get the riding player
|
|
+ *
|
|
+ * @return Riding player
|
|
+ */
|
|
+ @Nullable
|
|
+ Player getRider();
|
|
+
|
|
+ /**
|
|
+ * Check if entity is being ridden
|
|
+ *
|
|
+ * @return True if being ridden
|
|
+ */
|
|
+ boolean hasRider();
|
|
+
|
|
+ /**
|
|
+ * Check if entity is ridable
|
|
+ *
|
|
+ * @return True if ridable
|
|
+ */
|
|
+ boolean isRidable();
|
|
+
|
|
+ /**
|
|
+ * Check if entity is ridable in water
|
|
+ *
|
|
+ * @return True if ridable in water
|
|
+ */
|
|
+ boolean isRidableInWater();
|
|
+ // Purpur end
|
|
}
|
|
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/RidableMoveEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/RidableMoveEvent.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..a037df01b07af9ffb98b67aca412c1d34fade03b
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/purpurmc/purpur/event/entity/RidableMoveEvent.java
|
|
@@ -0,0 +1,103 @@
|
|
+package org.purpurmc.purpur.event.entity;
|
|
+
|
|
+import com.google.common.base.Preconditions;
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.entity.Mob;
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.Cancellable;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.entity.EntityEvent;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+/**
|
|
+ * Triggered when a ridable mob moves with a rider
|
|
+ */
|
|
+public class RidableMoveEvent extends EntityEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private boolean canceled;
|
|
+ private final Player rider;
|
|
+ private Location from;
|
|
+ private Location to;
|
|
+
|
|
+ public RidableMoveEvent(@NotNull Mob entity, @NotNull Player rider, @NotNull Location from, @NotNull Location to) {
|
|
+ super(entity);
|
|
+ this.rider = rider;
|
|
+ this.from = from;
|
|
+ this.to = to;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public Mob getEntity() {
|
|
+ return (Mob) entity;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public Player getRider() {
|
|
+ return rider;
|
|
+ }
|
|
+
|
|
+ public boolean isCancelled() {
|
|
+ return canceled;
|
|
+ }
|
|
+
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ canceled = cancel;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the location this entity moved from
|
|
+ *
|
|
+ * @return Location the entity moved from
|
|
+ */
|
|
+ @NotNull
|
|
+ public Location getFrom() {
|
|
+ return from;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Sets the location to mark as where the entity moved from
|
|
+ *
|
|
+ * @param from New location to mark as the entity's previous location
|
|
+ */
|
|
+ public void setFrom(@NotNull Location from) {
|
|
+ validateLocation(from);
|
|
+ this.from = from;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Gets the location this entity moved to
|
|
+ *
|
|
+ * @return Location the entity moved to
|
|
+ */
|
|
+ @NotNull
|
|
+ public Location getTo() {
|
|
+ return to;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Sets the location that this entity will move to
|
|
+ *
|
|
+ * @param to New Location this entity will move to
|
|
+ */
|
|
+ public void setTo(@NotNull Location to) {
|
|
+ validateLocation(to);
|
|
+ this.to = to;
|
|
+ }
|
|
+
|
|
+ private void validateLocation(@NotNull Location loc) {
|
|
+ Preconditions.checkArgument(loc != null, "Cannot use null location!");
|
|
+ Preconditions.checkArgument(loc.getWorld() != null, "Cannot use null location with null world!");
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/RidableSpacebarEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/RidableSpacebarEvent.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..3d3a7d898e3278ce998d713dafbb4b354dad7fc7
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/purpurmc/purpur/event/entity/RidableSpacebarEvent.java
|
|
@@ -0,0 +1,37 @@
|
|
+package org.purpurmc.purpur.event.entity;
|
|
+
|
|
+import org.bukkit.entity.Entity;
|
|
+import org.bukkit.event.Cancellable;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.entity.EntityEvent;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+public class RidableSpacebarEvent extends EntityEvent implements Cancellable {
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+ private boolean cancelled;
|
|
+
|
|
+ public RidableSpacebarEvent(@NotNull Entity entity) {
|
|
+ super(entity);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCancelled() {
|
|
+ return cancelled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCancelled(boolean cancel) {
|
|
+ cancelled = cancel;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @NotNull
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+}
|