13
0
geforkt von Mirrors/Paper

#1429: Implement TrialSpawnerSpawnEvent

By: Doc <nachito94@msn.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2024-06-28 07:06:36 +10:00
Ursprung 820bc6423d
Commit 5f8cff3bb5
2 geänderte Dateien mit 23 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -22,7 +22,7 @@
public Codec<TrialSpawner> codec() {
return RecordCodecBuilder.create((instance) -> {
@@ -219,13 +219,13 @@
@@ -219,13 +219,18 @@
}
entityinsentient.setPersistenceRequired();
@ -34,7 +34,12 @@
}
- if (!worldserver.tryAddFreshEntityWithPassengers(entity)) {
+ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRIAL_SPAWNER)) { // CraftBukkit
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callTrialSpawnerSpawnEvent(entity, blockposition).isCancelled()) {
+ return Optional.empty();
+ }
+ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRIAL_SPAWNER)) {
+ // CraftBukkit end
return Optional.empty();
} else {
TrialSpawner.a trialspawner_a = this.isOminous ? TrialSpawner.a.OMINOUS : TrialSpawner.a.NORMAL;

Datei anzeigen

@ -211,6 +211,7 @@ import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.entity.SpawnerSpawnEvent;
import org.bukkit.event.entity.StriderTemperatureChangeEvent;
import org.bukkit.event.entity.TrialSpawnerSpawnEvent;
import org.bukkit.event.entity.VillagerCareerChangeEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
@ -1568,6 +1569,21 @@ public class CraftEventFactory {
return event;
}
/**
* Trial Mob spawner event.
*/
public static TrialSpawnerSpawnEvent callTrialSpawnerSpawnEvent(Entity spawnee, BlockPosition pos) {
org.bukkit.craftbukkit.entity.CraftEntity entity = spawnee.getBukkitEntity();
BlockState state = CraftBlock.at(spawnee.level(), pos).getState();
if (!(state instanceof org.bukkit.block.TrialSpawner)) {
state = null;
}
TrialSpawnerSpawnEvent event = new TrialSpawnerSpawnEvent(entity, (org.bukkit.block.TrialSpawner) state);
entity.getServer().getPluginManager().callEvent(event);
return event;
}
public static EntityToggleGlideEvent callToggleGlideEvent(EntityLiving entity, boolean gliding) {
EntityToggleGlideEvent event = new EntityToggleGlideEvent((LivingEntity) entity.getBukkitEntity(), gliding);
entity.level().getCraftServer().getPluginManager().callEvent(event);