Advertisement
Guest User

Untitled

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