3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/api/0126-EntityTransformedEvent.patch

108 Zeilen
3.0 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Anthony MacAllister <anthonymmacallister@gmail.com>
Date: Thu, 26 Jul 2018 15:28:53 -0400
Subject: [PATCH] EntityTransformedEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
new file mode 100644
2024-02-01 10:15:57 +01:00
index 0000000000000000000000000000000000000000..9ce2638aeec5745f1a2b88e1cc125f57f8c8debe
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,95 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.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.ApiStatus;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.NotNull;
2021-06-11 14:02:28 +02:00
+
+/**
+ * Fired when an entity transforms into another entity
+ * <p>
+ * If the event is cancelled, the entity will not transform
2024-02-01 10:15:57 +01:00
+ *
+ * @deprecated Bukkit has added {@link org.bukkit.event.entity.EntityTransformEvent}, you should start using that
2021-06-11 14:02:28 +02:00
+ */
+@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
2021-06-11 14:02:28 +02:00
+public class EntityTransformedEvent extends EntityEvent implements Cancellable {
2024-02-01 10:15:57 +01:00
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
2021-06-11 14:02:28 +02:00
+ private final Entity transformed;
+ private final TransformedReason reason;
+
2024-02-01 10:15:57 +01:00
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityTransformedEvent(@NotNull Entity entity, @NotNull Entity transformed, @NotNull TransformedReason reason) {
2021-06-11 14:02:28 +02:00
+ super(entity);
+ this.transformed = transformed;
+ this.reason = reason;
+ }
+
+ /**
+ * The entity after it has transformed
+ *
+ * @return Transformed entity
+ */
2024-02-01 10:15:57 +01:00
+ @NotNull
2021-06-11 14:02:28 +02:00
+ public Entity getTransformed() {
2024-02-01 10:15:57 +01:00
+ return this.transformed;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * @return The reason for the transformation
+ */
2024-02-01 10:15:57 +01:00
+ @NotNull
2021-06-11 14:02:28 +02:00
+ public TransformedReason getReason() {
2024-02-01 10:15:57 +01:00
+ return this.reason;
2021-06-11 14:02:28 +02:00
+ }
+
+ @Override
2024-02-01 10:15:57 +01:00
+ public boolean isCancelled(){
+ return this.cancelled;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01:00
+ @Override
+ public void setCancelled(boolean cancel){
+ this.cancelled = cancel;
2021-06-11 14:02:28 +02:00
+ }
+
+ @Override
2024-02-01 10:15:57 +01:00
+ @NotNull
+ public HandlerList getHandlers(){
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+
2024-02-01 10:15:57 +01:00
+ @NotNull
+ public static HandlerList getHandlerList(){
+ return HANDLER_LIST;
2021-06-11 14:02:28 +02:00
+ }
+
+ public enum TransformedReason {
+ /**
+ * When a zombie drowns
+ */
+ DROWNED,
+ /**
+ * When a zombie villager is cured
+ */
+ CURED,
+ /**
+ * When a villager turns to a zombie villager
+ */
+ INFECTED,
+ /**
+ * When a mooshroom turns to a cow
+ */
+ SHEARED,
+ /**
2024-02-01 10:15:57 +01:00
+ * When a pig turns to a zombified piglin
2021-06-11 14:02:28 +02:00
+ */
+ LIGHTNING
+ }
+}