Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 03:20:07 +01:00
108 Zeilen
3.0 KiB
Diff
108 Zeilen
3.0 KiB
Diff
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
|
|
+ }
|
|
+}
|