Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. @EventTarget
  2. public void onMotion(MotionUpdateEvent e) {
  3. if(!getState())
  4. return;
  5.  
  6. switch(e.getState()) {
  7. case UPDATE:
  8. for (Object entity : mc.theWorld.loadedEntityList)
  9. if (((Entity)entity).isInvisible() && entity != mc.thePlayer)
  10. {
  11. mc.theWorld.removeEntity((Entity)entity);
  12. }
  13. break;
  14. }
  15. }
  16.  
  17. @EventTarget
  18. public void onPacket(PacketEvent e) {
  19. if(!getState())
  20. return;
  21.  
  22. for (Object entity : this.mc.theWorld.loadedEntityList) {
  23. if (!(entity instanceof EntityPlayer)) {
  24. return;
  25. }
  26. if (mc.thePlayer.equals(entity)) {
  27. continue;
  28. }
  29. if (((Entity)entity).isInvisible()) {
  30. this.mc.theWorld.removeEntity((Entity)entity);
  31. }
  32. }
  33.  
  34. if ((e.getPacket() instanceof S0CPacketSpawnPlayer)) {
  35. S0CPacketSpawnPlayer packet = (S0CPacketSpawnPlayer) e.getPacket();
  36. final double posX = packet.func_148942_f() / 64.0;
  37. final double posY = packet.func_148949_g() / 64.0;
  38. final double posZ = packet.func_148946_h() / 64.0;
  39. final double difX = mc.thePlayer.posX - posX;
  40. final double difY = mc.thePlayer.posY - posY;
  41. final double difZ = mc.thePlayer.posZ - posZ;
  42. final double dist = Math.sqrt((difX * difX + difY * difY + difZ * difZ) * posX + posY + posZ);
  43. if (dist <=20.0) {
  44. final double n = posX;
  45. if (n != mc.thePlayer.posX) {
  46. final double n2 = posY;
  47. if (n2 != mc.thePlayer.posY) {
  48. final double n3 = posZ;
  49. if (n3 != mc.thePlayer.posZ) {
  50. e.setCancelled(true);
  51. }
  52. }
  53. }
  54. }
  55. }
  56.  
  57. if(e.getPacket() instanceof S0CPacketSpawnPlayer) {
  58. //Creates a new variable based on the packet
  59. S0CPacketSpawnPlayer spawnedEntity = (S0CPacketSpawnPlayer) e.getPacket();
  60. //Creates an object for all the entites in the ArrayList. Doesn't use a lambda due to NullPointers
  61. for (EntityPlayer entity : entities) {
  62. //Checks if the name of the entity spawned is the same as an entity that already exists.
  63. if (mc.theWorld.getPlayerEntityByUUID(spawnedEntity.func_179819_c()).getName().equals(entity.getName())) {
  64. //Cancels the event so the entity does not spawn on the user's side.
  65. e.setCancelled(true);
  66. return;
  67. }
  68. }
  69. }
  70. }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement