Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. package fr.dinnerwolph.test.customentities;
  2.  
  3. import net.minecraft.server.v1_8_R3.EntityLiving;
  4. import net.minecraft.server.v1_8_R3.NBTTagCompound;
  5. import net.minecraft.server.v1_8_R3.NBTTagList;
  6. import net.minecraft.server.v1_8_R3.World;
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.Location;
  9. import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
  10. import org.bukkit.entity.Entity;
  11. import org.bukkit.entity.LivingEntity;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.event.entity.CreatureSpawnEvent;
  14.  
  15. /**
  16. * @author Dinnerwolph
  17. */
  18.  
  19. public class CustomEntityManager {
  20.  
  21. public static void make(EntityLiving nmsEntity, Player player) {
  22. Location location = player.getLocation();
  23. World nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
  24. nmsEntity.setPosition(location.getX(), location.getY() + 0.3, location.getZ());
  25. System.out.println(nmsEntity);
  26. nmsWorld.addEntity(nmsEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
  27. }
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. package fr.dinnerwolph.test.commands;
  37.  
  38. import fr.dinnerwolph.test.customentities.CustomEntityManager;
  39. import fr.dinnerwolph.test.customentities.CustomIronGolem;
  40. import fr.dinnerwolph.test.customentities.CustomVillager;
  41. import org.bukkit.command.Command;
  42. import org.bukkit.command.CommandExecutor;
  43. import org.bukkit.command.CommandSender;
  44. import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
  45. import org.bukkit.entity.Player;
  46.  
  47. /**
  48. * @author Dinnerwolph
  49. */
  50.  
  51. public class Make implements CommandExecutor {
  52.  
  53. @Override
  54. public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
  55. Player player = (Player) commandSender;
  56. CustomEntityManager.make(new CustomVillager(((CraftWorld) player.getWorld()).getHandle(), "bob is fdp"), player);
  57. return true;
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement