mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-24 18:07:39 +01:00
58 lines
2.1 KiB
Diff
58 lines
2.1 KiB
Diff
--- a/net/minecraft/server/MobSpawnerAbstract.java
|
|
+++ b/net/minecraft/server/MobSpawnerAbstract.java
|
|
@@ -4,9 +4,11 @@
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent; // CraftBukkit
|
|
+
|
|
public abstract class MobSpawnerAbstract {
|
|
|
|
- private int spawnDelay = 20;
|
|
+ public int spawnDelay = 20; // CraftBukkit - public
|
|
private String mobName = "Pig";
|
|
private final List<MobSpawnerAbstract.a> mobs = Lists.newArrayList();
|
|
private MobSpawnerAbstract.a spawnData;
|
|
@@ -22,8 +24,13 @@
|
|
|
|
public MobSpawnerAbstract() {}
|
|
|
|
- private String getMobName() {
|
|
+ public String getMobName() { // CraftBukkit - public
|
|
if (this.i() == null) {
|
|
+ // CraftBukkit start - fix NPE
|
|
+ if (this.mobName == null) {
|
|
+ this.mobName = "Pig";
|
|
+ }
|
|
+ // CraftBukkit end
|
|
if (this.mobName != null && this.mobName.equals("Minecart")) {
|
|
this.mobName = "MinecartRideable";
|
|
}
|
|
@@ -129,7 +136,7 @@
|
|
|
|
entity.f(nbttagcompound);
|
|
if (entity.world != null && flag) {
|
|
- entity.world.addEntity(entity);
|
|
+ entity.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
|
|
}
|
|
|
|
NBTTagCompound nbttagcompound1;
|
|
@@ -154,7 +161,7 @@
|
|
entity2.f(nbttagcompound2);
|
|
entity2.setPositionRotation(entity1.locX, entity1.locY, entity1.locZ, entity1.yaw, entity1.pitch);
|
|
if (entity.world != null && flag) {
|
|
- entity.world.addEntity(entity2);
|
|
+ entity.world.addEntity(entity2, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
|
|
}
|
|
|
|
entity1.mount(entity2);
|
|
@@ -167,7 +174,7 @@
|
|
((EntityInsentient) entity).prepare(entity.world.E(new BlockPosition(entity)), (GroupDataEntity) null);
|
|
}
|
|
|
|
- entity.world.addEntity(entity);
|
|
+ entity.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
|
|
}
|
|
|
|
return entity;
|