diff --git a/patches/api/0050-Add-Bee-API.patch b/patches/api/0050-Add-Bee-API.patch new file mode 100644 index 000000000..6efae8520 --- /dev/null +++ b/patches/api/0050-Add-Bee-API.patch @@ -0,0 +1,179 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: SageSphinx63920 +Date: Mon, 25 Jul 2022 19:33:49 +0200 +Subject: [PATCH] Add Bee API + + +diff --git a/src/main/java/org/purpurmc/purpur/event/entity/BeeFoundFlowerEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/BeeFoundFlowerEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..833f46d1941f377765132fc528c45567ee0290d2 +--- /dev/null ++++ b/src/main/java/org/purpurmc/purpur/event/entity/BeeFoundFlowerEvent.java +@@ -0,0 +1,48 @@ ++package org.purpurmc.purpur.event.entity; ++ ++import org.bukkit.Location; ++import org.bukkit.entity.Bee; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; ++ ++/** ++ * Called when a bee targets a flower ++ */ ++public class BeeFoundFlowerEvent extends EntityEvent { ++ private static final HandlerList handlers = new HandlerList(); ++ private final Location location; ++ ++ public BeeFoundFlowerEvent(@NotNull Bee bee, @Nullable Location location) { ++ super(bee); ++ this.location = location; ++ } ++ ++ @Override ++ @NotNull ++ public Bee getEntity() { ++ return (Bee) super.getEntity(); ++ } ++ ++ /** ++ * Returns the location of the flower that the bee targets ++ * ++ * @return The location of the flower ++ */ ++ @Nullable ++ public Location getLocation() { ++ return location; ++ } ++ ++ @Override ++ @NotNull ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +diff --git a/src/main/java/org/purpurmc/purpur/event/entity/BeeStartedPollinatingEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/BeeStartedPollinatingEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..ae0bb654745724889c67fae9072ae90ea3778ba4 +--- /dev/null ++++ b/src/main/java/org/purpurmc/purpur/event/entity/BeeStartedPollinatingEvent.java +@@ -0,0 +1,47 @@ ++package org.purpurmc.purpur.event.entity; ++ ++import org.bukkit.Location; ++import org.bukkit.entity.Bee; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.NotNull; ++ ++/** ++ * Called when a bee starts pollinating ++ */ ++public class BeeStartedPollinatingEvent extends EntityEvent { ++ private static final HandlerList handlers = new HandlerList(); ++ private final Location location; ++ ++ public BeeStartedPollinatingEvent(@NotNull Bee bee, @NotNull Location location) { ++ super(bee); ++ this.location = location; ++ } ++ ++ @Override ++ @NotNull ++ public Bee getEntity() { ++ return (Bee) super.getEntity(); ++ } ++ ++ /** ++ * Returns the location of the flower that the bee pollinates ++ * ++ * @return The location of the flower ++ */ ++ @NotNull ++ public Location getLocation() { ++ return this.location; ++ } ++ ++ @Override ++ @NotNull ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +diff --git a/src/main/java/org/purpurmc/purpur/event/entity/BeeStopPollinatingEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/BeeStopPollinatingEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..ff3c9f075be2f624af8b0ce5fffc5ea69a41f32e +--- /dev/null ++++ b/src/main/java/org/purpurmc/purpur/event/entity/BeeStopPollinatingEvent.java +@@ -0,0 +1,60 @@ ++package org.purpurmc.purpur.event.entity; ++ ++import org.bukkit.Location; ++import org.bukkit.entity.Bee; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.entity.EntityEvent; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; ++ ++/** ++ * Called when a bee stops pollinating ++ */ ++public class BeeStopPollinatingEvent extends EntityEvent { ++ private static final HandlerList handlers = new HandlerList(); ++ private final Location location; ++ private final boolean success; ++ ++ public BeeStopPollinatingEvent(@NotNull Bee bee, @Nullable Location location, boolean success) { ++ super(bee); ++ this.location = location; ++ this.success = success; ++ } ++ ++ @Override ++ @NotNull ++ public Bee getEntity() { ++ return (Bee) super.getEntity(); ++ } ++ ++ /** ++ * Returns the location of the flower that the bee stopped pollinating ++ * ++ * @return The location of the flower ++ */ ++ @Nullable ++ public Location getLocation() { ++ return location; ++ } ++ ++ /** ++ * Returns whether the bee successfully pollinated the flower ++ * ++ * @return True if the pollination was successful ++ */ ++ public boolean wasSuccessful() { ++ return success; ++ } ++ ++ ++ @Override ++ @NotNull ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} diff --git a/patches/server/0292-Add-Bee-API.patch b/patches/server/0292-Add-Bee-API.patch new file mode 100644 index 000000000..2b34f3b26 --- /dev/null +++ b/patches/server/0292-Add-Bee-API.patch @@ -0,0 +1,34 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: SageSphinx63920 +Date: Mon, 25 Jul 2022 19:33:49 +0200 +Subject: [PATCH] Add Bee API + + +diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java +index fb14d13e2812c5a2841b43dadea782536bd3c94f..b934d7d0317e6a94171ea484c72c8b15708842a3 100644 +--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java ++++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java +@@ -806,6 +806,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { + if (optional.isPresent()) { + Bee.this.savedFlowerPos = (BlockPos) optional.get(); + Bee.this.navigation.moveTo((double) Bee.this.savedFlowerPos.getX() + 0.5D, (double) Bee.this.savedFlowerPos.getY() + 0.5D, (double) Bee.this.savedFlowerPos.getZ() + 0.5D, 1.2000000476837158D); ++ new org.purpurmc.purpur.event.entity.BeeFoundFlowerEvent((org.bukkit.entity.Bee) Bee.this.getBukkitEntity(), net.minecraft.server.MCUtil.toLocation(Bee.this.level, Bee.this.savedFlowerPos)).callEvent(); // Purpur + return true; + } else { + Bee.this.remainingCooldownBeforeLocatingNewFlower = Mth.nextInt(Bee.this.random, 20, 60); +@@ -862,6 +863,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { + this.pollinating = false; + Bee.this.navigation.stop(); + Bee.this.remainingCooldownBeforeLocatingNewFlower = 200; ++ new org.purpurmc.purpur.event.entity.BeeStopPollinatingEvent((org.bukkit.entity.Bee) Bee.this.getBukkitEntity(), Bee.this.savedFlowerPos == null ? null : net.minecraft.server.MCUtil.toLocation(Bee.this.level, Bee.this.savedFlowerPos), Bee.this.hasNectar()).callEvent(); // Purpur + } + + @Override +@@ -908,6 +910,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { + this.setWantedPos(); + } + ++ if (this.successfulPollinatingTicks == 0) new org.purpurmc.purpur.event.entity.BeeStartedPollinatingEvent((org.bukkit.entity.Bee) Bee.this.getBukkitEntity(), net.minecraft.server.MCUtil.toLocation(Bee.this.level, Bee.this.savedFlowerPos)).callEvent(); // Purpur + ++this.successfulPollinatingTicks; + if (Bee.this.random.nextFloat() < 0.05F && this.successfulPollinatingTicks > this.lastSoundPlayedTick + 60) { + this.lastSoundPlayedTick = this.successfulPollinatingTicks;