mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 05:26:29 +01:00
Make piglins immune to zombification; resolves #905
This commit is contained in:
parent
a55f943d27
commit
c198c15362
@ -16,12 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
package de.erethon.dungeonsxl.mob;
|
package de.erethon.dungeonsxl.mob;
|
||||||
|
|
||||||
|
import de.erethon.caliburn.mob.VanillaMob;
|
||||||
import de.erethon.dungeonsxl.DungeonsXL;
|
import de.erethon.dungeonsxl.DungeonsXL;
|
||||||
import de.erethon.dungeonsxl.api.world.EditWorld;
|
|
||||||
import de.erethon.dungeonsxl.api.world.GameWorld;
|
import de.erethon.dungeonsxl.api.world.GameWorld;
|
||||||
|
import de.erethon.dungeonsxl.api.world.InstanceWorld;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.PiglinAbstract;
|
||||||
import org.bukkit.entity.Skeleton;
|
import org.bukkit.entity.Skeleton;
|
||||||
import org.bukkit.entity.Zombie;
|
import org.bukkit.entity.Zombie;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -46,17 +48,23 @@ public class DMobListener implements Listener {
|
|||||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
World world = event.getLocation().getWorld();
|
World world = event.getLocation().getWorld();
|
||||||
|
|
||||||
EditWorld editWorld = plugin.getEditWorld(world);
|
InstanceWorld instance = plugin.getInstanceWorld(world);
|
||||||
GameWorld gameWorld = plugin.getGameWorld(world);
|
if (instance == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (editWorld != null || gameWorld != null) {
|
|
||||||
switch (event.getSpawnReason()) {
|
switch (event.getSpawnReason()) {
|
||||||
case CHUNK_GEN:
|
case CHUNK_GEN:
|
||||||
case JOCKEY:
|
case JOCKEY:
|
||||||
case MOUNT:
|
case MOUNT:
|
||||||
case NATURAL:
|
case NATURAL:
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VanillaMob vm = VanillaMob.get(event.getEntityType());
|
||||||
|
if (vm == VanillaMob.PIGLIN || vm == VanillaMob.PIGLIN_BRUTE) {
|
||||||
|
((PiglinAbstract) event.getEntity()).setImmuneToZombification(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user