mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 17:07:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 12dec20 Bump paerweight to 1.1.7 e33ed89 Get short commit ref using a more proper method 7d6147d Remove now unneeded patch due to paperweight 1.1.7 e72fa41 Update task dependency for includeMappings so the new task isn't skipped 0ad5526 Trim whitspace off of git hash (oops) Tuinity Changes: e878ba9 Update paper 2bd2849 Bring back fix codec spam patch
64 lines
4.2 KiB
Diff
64 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sat, 20 Jul 2013 22:40:56 -0400
|
|
Subject: [PATCH] EMC - MonsterEggSpawnEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
index 01f27e4aee9e257c632e9e163e495443cca4c822..500d4494db3c9663e02f6ce02c2104a9b08d6dc4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
@@ -331,13 +331,20 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
|
|
|
|
@Nullable
|
|
public Entity spawn(ServerLevel world, @Nullable ItemStack stack, @Nullable Player player, BlockPos pos, MobSpawnType spawnReason, boolean alignPosition, boolean invertY) {
|
|
- return this.spawn(world, stack == null ? null : stack.getTag(), stack != null && stack.hasCustomHoverName() ? stack.getHoverName() : null, player, pos, spawnReason, alignPosition, invertY);
|
|
+ return this.spawn(world, stack, stack == null ? null : stack.getTag(), stack != null && stack.hasCustomHoverName() ? stack.getHoverName() : null, player, pos, spawnReason, alignPosition, invertY); // Purpur
|
|
}
|
|
|
|
@Nullable
|
|
public T spawn(ServerLevel world, @Nullable CompoundTag itemNbt, @Nullable Component name, @Nullable Player player, BlockPos pos, MobSpawnType spawnReason, boolean alignPosition, boolean invertY) {
|
|
+ // Purpur start
|
|
+ return spawn(world, null, itemNbt, name, player, pos, spawnReason, alignPosition, invertY); // Purpur
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ public T spawn(ServerLevel world, @Nullable ItemStack stack, @Nullable CompoundTag itemNbt, @Nullable Component name, @Nullable Player player, BlockPos pos, MobSpawnType spawnReason, boolean alignPosition, boolean invertY) {
|
|
+ // Purpur end
|
|
// CraftBukkit start
|
|
- return this.spawnCreature(world, itemNbt, name, player, pos, spawnReason, alignPosition, invertY, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
|
|
+ return this.spawn(world, stack, itemNbt, name, player, pos, spawnReason, alignPosition, invertY, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG, null); // Purpur
|
|
}
|
|
|
|
@Nullable
|
|
@@ -362,9 +369,29 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
|
|
}
|
|
}
|
|
// Paper end
|
|
+ // Purpur start
|
|
+ return this.spawn(worldserver, null, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, spawnReason, op);
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ public T spawn(ServerLevel worldserver, @Nullable ItemStack stack, @Nullable CompoundTag nbttagcompound, @Nullable Component ichatbasecomponent, @Nullable Player entityhuman, BlockPos blockposition, MobSpawnType enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason, @Nullable java.util.function.Consumer<T> op) {
|
|
+ // Purpur end
|
|
T t0 = this.create(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1);
|
|
if (t0 != null && op != null) op.accept(t0); // Paper
|
|
|
|
+ // Purpur start
|
|
+ if (spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG && stack != null && t0 != null) {
|
|
+ final net.pl3x.purpur.event.entity.MonsterEggSpawnEvent event = new net.pl3x.purpur.event.entity.MonsterEggSpawnEvent(entityhuman != null ? entityhuman.getBukkitEntity() : null, t0.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack));
|
|
+ if (!event.callEvent()) {
|
|
+ t0.setRemoved(Entity.RemovalReason.DISCARDED);
|
|
+ return null;
|
|
+ }
|
|
+ if (event.getEntity().getEntityId() != t0.getId()) {
|
|
+ return (T) ((org.bukkit.craftbukkit.entity.CraftEntity) event.getEntity()).getHandle();
|
|
+ }
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
if (t0 != null) {
|
|
worldserver.addAllEntities(t0, spawnReason);
|
|
return !t0.isRemoved() ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled
|