From 87e677ce49bb27be69206d54566bf7d621108925 Mon Sep 17 00:00:00 2001 From: BlackHole Date: Sun, 13 Mar 2016 16:38:07 +0100 Subject: [PATCH] Add spawn reasons for entities involved in a skeleton trap --- nms-patches/PathfinderGoalHorseTrap.patch | 37 +++++++++++++++++++++++ nms-patches/WorldServer.patch | 9 ++++++ 2 files changed, 46 insertions(+) create mode 100644 nms-patches/PathfinderGoalHorseTrap.patch diff --git a/nms-patches/PathfinderGoalHorseTrap.patch b/nms-patches/PathfinderGoalHorseTrap.patch new file mode 100644 index 0000000000..773ca83d4c --- /dev/null +++ b/nms-patches/PathfinderGoalHorseTrap.patch @@ -0,0 +1,37 @@ +--- a/net/minecraft/server/PathfinderGoalHorseTrap.java ++++ b/net/minecraft/server/PathfinderGoalHorseTrap.java +@@ -22,13 +22,14 @@ + this.a.world.strikeLightning(new EntityLightning(this.a.world, this.a.locX, this.a.locY, this.a.locZ, true)); + EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.a); + +- entityskeleton.startRiding(this.a); ++ if (entityskeleton != null) entityskeleton.startRiding(this.a); // CraftBukkit + + for (int i = 0; i < 3; ++i) { + EntityHorse entityhorse = this.a(difficultydamagescaler); ++ if (entityhorse == null) continue; // CraftBukkit + EntitySkeleton entityskeleton1 = this.a(difficultydamagescaler, entityhorse); + +- entityskeleton1.startRiding(entityhorse); ++ if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorse); // CraftBukkit + entityhorse.g(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D); + } + +@@ -44,7 +45,7 @@ + entityhorse.setType(EnumHorseType.SKELETON); + entityhorse.setTame(true); + entityhorse.setAgeRaw(0); +- entityhorse.world.addEntity(entityhorse); ++ if (!entityhorse.world.addEntity(entityhorse, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP)) return null; // CraftBukkit + return entityhorse; + } + +@@ -61,7 +62,7 @@ + + EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getItemInMainHand(), (int) (5.0F + difficultydamagescaler.c() * (float) entityskeleton.getRandom().nextInt(18)), false); + EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getEquipment(EnumItemSlot.HEAD), (int) (5.0F + difficultydamagescaler.c() * (float) entityskeleton.getRandom().nextInt(18)), false); +- entityskeleton.world.addEntity(entityskeleton); ++ if (!entityskeleton.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY)) return null; // CraftBukkit + return entityskeleton; + } + } diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch index 00f61664d2..c16bedce94 100644 --- a/nms-patches/WorldServer.patch +++ b/nms-patches/WorldServer.patch @@ -271,6 +271,15 @@ return false; } else { +@@ -277,7 +413,7 @@ + entityhorse.x(true); + entityhorse.setAgeRaw(0); + entityhorse.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); +- this.addEntity(entityhorse); ++ this.addEntity(entityhorse, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit + this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), true)); + } else { + this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), false)); @@ -293,11 +429,29 @@ BlockPosition blockposition1 = blockposition.down();