blob: ee2983e6b3b5d99f04fcc3f957a704416a81f7a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
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
index 0000000000000000000000000000000000000000..9ce2638aeec5745f1a2b88e1cc125f57f8c8debe
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
@@ -0,0 +1,95 @@
+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;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Fired when an entity transforms into another entity
+ * <p>
+ * If the event is cancelled, the entity will not transform
+ *
+ * @deprecated Bukkit has added {@link org.bukkit.event.entity.EntityTransformEvent}, you should start using that
+ */
+@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
+public class EntityTransformedEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Entity transformed;
+ private final TransformedReason reason;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityTransformedEvent(@NotNull Entity entity, @NotNull Entity transformed, @NotNull TransformedReason reason) {
+ super(entity);
+ this.transformed = transformed;
+ this.reason = reason;
+ }
+
+ /**
+ * The entity after it has transformed
+ *
+ * @return Transformed entity
+ */
+ @NotNull
+ public Entity getTransformed() {
+ return this.transformed;
+ }
+
+ /**
+ * @return The reason for the transformation
+ */
+ @NotNull
+ public TransformedReason getReason() {
+ return this.reason;
+ }
+
+ @Override
+ public boolean isCancelled(){
+ return this.cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel){
+ this.cancelled = cancel;
+ }
+
+ @Override
+ @NotNull
+ public HandlerList getHandlers(){
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList(){
+ return HANDLER_LIST;
+ }
+
+ 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,
+ /**
+ * When a pig turns to a zombified piglin
+ */
+ LIGHTNING
+ }
+}
|