Paper/CraftBukkit-Patches/0080-Add-Option-to-Nerf-Mobs-from-Spawner-s.patch

85 lines
3.7 KiB
Diff
Raw Normal View History

2014-02-02 17:03:20 +00:00
From 2af65921e4e70431afb681c5f12d33b771c31e5e Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
2014-02-02 17:03:20 +00:00
Date: Sun, 2 Feb 2014 16:55:46 +0000
Subject: [PATCH] Add Option to Nerf Mobs from Spawner's
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
2014-01-31 20:42:29 +00:00
index 5826b50..69331ff 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2014-01-31 20:42:29 +00:00
@@ -117,6 +117,7 @@ public abstract class Entity {
public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState;
public long activatedTick = 0;
+ public boolean fromMobSpawner;
public void inactiveTick() { }
// Spigot end
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 885a0ef..639354b 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -417,6 +417,12 @@ public abstract class EntityInsentient extends EntityLiving {
this.world.methodProfiler.a("checkDespawn");
this.w();
this.world.methodProfiler.b();
+ // Spigot Start
+ if ( this.fromMobSpawner )
+ {
+ return;
+ }
+ // Spigot End
this.world.methodProfiler.a("sensing");
this.bq.a();
this.world.methodProfiler.b();
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
2014-02-02 17:03:20 +00:00
index bb6b3d5..20d9094 100644
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
@@ -136,6 +136,12 @@ public abstract class MobSpawnerAbstract {
SpawnerSpawnEvent event = CraftEventFactory.callSpawnerSpawnEvent(entity, this.b(), this.c(), this.d());
if (!event.isCancelled()) {
entity.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
+ // Spigot Start
+ if ( entity.world.spigotConfig.nerfSpawnerMobs )
+ {
+ entity.fromMobSpawner = true;
+ }
+ // Spigot End
}
// CraftBukkit end
}
2014-02-02 17:03:20 +00:00
@@ -181,6 +187,12 @@ public abstract class MobSpawnerAbstract {
SpawnerSpawnEvent event = CraftEventFactory.callSpawnerSpawnEvent(entity, this.b(), this.c(), this.d());
if (!event.isCancelled()) {
this.a().addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
+ // Spigot Start
+ if ( entity.world.spigotConfig.nerfSpawnerMobs )
+ {
+ entity.fromMobSpawner = true;
+ }
+ // Spigot End
}
// CraftBukkit end
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
2014-01-21 21:34:03 +00:00
index e7cb99d..018ec18 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -250,4 +250,11 @@ public class SpigotWorldConfig
zombieAggressiveTowardsVillager = getBoolean( "zombie-aggressive-towards-villager", true );
log( "Zombie Aggressive Towards Villager: " + zombieAggressiveTowardsVillager );
}
+
+ public boolean nerfSpawnerMobs;
+ private void nerfSpawnerMobs()
+ {
+ nerfSpawnerMobs = getBoolean( "nerf-spawner-mobs", false );
2014-01-21 21:34:03 +00:00
+ log( "Nerfing mobs spawned from spawners: " + nerfSpawnerMobs );
+ }
}
--
2014-02-02 17:03:20 +00:00
1.8.3.2