Add ShulkerDuplicateEvent

This commit is contained in:
Chase Henderson 2024-01-05 03:50:10 -05:00
parent 597ce940a4
commit 0b0012faf2

View File

@ -1,18 +1,18 @@
--- a/net/minecraft/world/entity/monster/Shulker.java
+++ b/net/minecraft/world/entity/monster/Shulker.java
@@ -58,6 +58,12 @@
import net.minecraft.world.phys.AABB;
@@ -59,6 +59,12 @@
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
+
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.event.entity.EntityTeleportEvent;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class Shulker extends AbstractGolem implements VariantHolder<Optional<DyeColor>>, Enemy {
private static final ResourceLocation COVERED_ARMOR_MODIFIER_ID = ResourceLocation.withDefaultNamespace("covered");
@@ -283,7 +289,13 @@
@Override
@ -43,11 +43,16 @@
this.unRide();
this.setAttachFace(enumdirection);
this.playSound(SoundEvents.SHULKER_TELEPORT, 1.0F, 1.0F);
@@ -472,7 +492,7 @@
@@ -472,7 +492,12 @@
if (entityshulker != null) {
entityshulker.setVariant(this.getVariant());
entityshulker.moveTo(vec3d);
- this.level().addFreshEntity(entityshulker);
+ // Paper start - Shulker duplicate event
+ if (!new io.papermc.paper.event.entity.ShulkerDuplicateEvent((org.bukkit.entity.Shulker) entityshulker.getBukkitEntity(), (org.bukkit.entity.Shulker) this.getBukkitEntity()).callEvent()) {
+ return;
+ }
+ // Paper end - Shulker duplicate event
+ this.level().addFreshEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life
}