mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Now also handle entities spawning on a loading a world. (Redacted by Grum)
By: lem21h <lem21h@anon>
This commit is contained in:
parent
54d451934e
commit
bd7be2c7b6
1 changed files with 60 additions and 0 deletions
|
@ -1,12 +1,26 @@
|
||||||
package org.bukkit.craftbukkit.event;
|
package org.bukkit.craftbukkit.event;
|
||||||
|
|
||||||
import net.minecraft.server.ChunkCoordinates;
|
import net.minecraft.server.ChunkCoordinates;
|
||||||
|
import net.minecraft.server.EntityChicken;
|
||||||
|
import net.minecraft.server.EntityCow;
|
||||||
|
import net.minecraft.server.EntityCreeper;
|
||||||
|
import net.minecraft.server.EntityGhast;
|
||||||
import net.minecraft.server.EntityHuman;
|
import net.minecraft.server.EntityHuman;
|
||||||
|
import net.minecraft.server.EntityLiving;
|
||||||
|
import net.minecraft.server.EntityPig;
|
||||||
|
import net.minecraft.server.EntityPigZombie;
|
||||||
|
import net.minecraft.server.EntitySheep;
|
||||||
|
import net.minecraft.server.EntitySkeleton;
|
||||||
|
import net.minecraft.server.EntitySlime;
|
||||||
|
import net.minecraft.server.EntitySpider;
|
||||||
|
import net.minecraft.server.EntitySquid;
|
||||||
|
import net.minecraft.server.EntityZombie;
|
||||||
import net.minecraft.server.Item;
|
import net.minecraft.server.Item;
|
||||||
import net.minecraft.server.ItemStack;
|
import net.minecraft.server.ItemStack;
|
||||||
import net.minecraft.server.World;
|
import net.minecraft.server.World;
|
||||||
import net.minecraft.server.WorldServer;
|
import net.minecraft.server.WorldServer;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
@ -15,11 +29,14 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.CreatureType;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event.Type;
|
import org.bukkit.event.Event.Type;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
@ -146,6 +163,9 @@ public class CraftEventFactory {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BlockDamageEvent
|
||||||
|
*/
|
||||||
public static BlockDamageEvent callBlockDamageEvent(EntityHuman who, int x, int y, int z, ItemStack itemstack, boolean instaBreak) {
|
public static BlockDamageEvent callBlockDamageEvent(EntityHuman who, int x, int y, int z, ItemStack itemstack, boolean instaBreak) {
|
||||||
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
|
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
|
||||||
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
||||||
|
@ -160,4 +180,44 @@ public class CraftEventFactory {
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CreatureSpawnEvent
|
||||||
|
*/
|
||||||
|
public static CreatureSpawnEvent callCreatureSpawnEvent(EntityLiving entityliving) {
|
||||||
|
org.bukkit.entity.Entity entity = entityliving.getBukkitEntity();
|
||||||
|
CraftServer craftServer = (CraftServer) entity.getServer();
|
||||||
|
|
||||||
|
CreatureType type = null;
|
||||||
|
|
||||||
|
if (entity instanceof EntityChicken) {
|
||||||
|
type = CreatureType.CHICKEN;
|
||||||
|
} else if (entity instanceof EntityCow) {
|
||||||
|
type = CreatureType.COW;
|
||||||
|
} else if (entity instanceof EntityCreeper) {
|
||||||
|
type = CreatureType.CREEPER;
|
||||||
|
} else if (entity instanceof EntityGhast) {
|
||||||
|
type = CreatureType.GHAST;
|
||||||
|
} else if (entity instanceof EntityPig) {
|
||||||
|
type = CreatureType.PIG;
|
||||||
|
} else if (entity instanceof EntityPigZombie) {
|
||||||
|
type = CreatureType.PIG_ZOMBIE;
|
||||||
|
} else if (entity instanceof EntitySheep) {
|
||||||
|
type = CreatureType.SHEEP;
|
||||||
|
} else if (entity instanceof EntitySkeleton) {
|
||||||
|
type = CreatureType.SKELETON;
|
||||||
|
} else if (entity instanceof EntitySheep) {
|
||||||
|
type = CreatureType.SPIDER;
|
||||||
|
} else if (entity instanceof EntityZombie) {
|
||||||
|
type = CreatureType.ZOMBIE;
|
||||||
|
} else if (entity instanceof EntitySlime) {
|
||||||
|
type = CreatureType.SLIME;
|
||||||
|
} else if (entity instanceof EntitySquid) {
|
||||||
|
type = CreatureType.SQUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatureSpawnEvent event = new CreatureSpawnEvent(entity, type, entity.getLocation());
|
||||||
|
craftServer.getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue