aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0127-EntityTransformedEvent.patch
blob: c77c4a8ba626d02c9de07bef86fd9c0b8fdad15e (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
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..12194f1fc7f03ca6785904b6187b3dfd03b16461
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityTransformedEvent.java
@@ -0,0 +1,92 @@
+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.bukkit.event.entity.EntityTransformEvent;
+
+/**
+ * Fired when an entity transforms into another entity
+ * <p>
+ * If the event is cancelled, the entity will not transform
+ * @deprecated Bukkit has added {@link EntityTransformEvent}, you should start using that
+ */
+@Deprecated
+public class EntityTransformedEvent extends EntityEvent implements Cancellable {
+    private static final HandlerList handlers = new HandlerList();
+    private boolean cancelled;
+    private final Entity transformed;
+    private final TransformedReason reason;
+
+    public EntityTransformedEvent(Entity entity, Entity transformed, TransformedReason reason) {
+        super(entity);
+        this.transformed = transformed;
+        this.reason = reason;
+    }
+
+    /**
+     * The entity after it has transformed
+     *
+     * @return Transformed entity
+     * @deprecated see {@link EntityTransformEvent#getTransformedEntity()}
+     */
+    @Deprecated
+    public Entity getTransformed() {
+        return transformed;
+    }
+
+    /**
+     * @return The reason for the transformation
+     * @deprecated see {@link EntityTransformEvent#getTransformReason()}
+     */
+    @Deprecated
+    public TransformedReason getReason() {
+        return reason;
+    }
+
+
+    @Override
+    public HandlerList getHandlers(){
+        return handlers;
+    }
+
+    public static HandlerList getHandlerList(){
+        return handlers;
+    }
+
+    @Override
+    public boolean isCancelled(){
+        return cancelled;
+    }
+
+    @Override
+    public void setCancelled(boolean cancel){
+        cancelled = cancel;
+    }
+
+    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 zombiepigman
+         */
+        LIGHTNING
+
+    }
+}