Advertisement
Guest User

Bot.java

a guest
Apr 15th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. package de.souperfish.bot.main;
  2.  
  3. import java.lang.reflect.Field;
  4.  
  5. import org.bukkit.Material;
  6. import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
  7. import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
  8. import org.bukkit.craftbukkit.v1_7_R3.util.UnsafeList;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.entity.Zombie;
  11. import org.bukkit.inventory.EntityEquipment;
  12. import org.bukkit.inventory.ItemStack;
  13. import org.bukkit.scheduler.BukkitRunnable;
  14.  
  15. import me.libraryaddict.disguise.DisguiseAPI;
  16. import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
  17. import net.minecraft.server.v1_7_R3.EntityHuman;
  18. import net.minecraft.server.v1_7_R3.EntityZombie;
  19. import net.minecraft.server.v1_7_R3.GenericAttributes;
  20. import net.minecraft.server.v1_7_R3.PacketPlayOutAnimation;
  21. import net.minecraft.server.v1_7_R3.PacketPlayOutSpawnEntityLiving;
  22. import net.minecraft.server.v1_7_R3.PathfinderGoalLookAtPlayer;
  23. import net.minecraft.server.v1_7_R3.PathfinderGoalMeleeAttack;
  24. import net.minecraft.server.v1_7_R3.PathfinderGoalNearestAttackableTarget;
  25. import net.minecraft.server.v1_7_R3.PathfinderGoalSelector;
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. public class Bot extends EntityZombie {
  33.  
  34.  
  35. Main plugin;
  36. EntityEquipment ee = ((Zombie)getBukkitEntity()).getEquipment();
  37.  
  38.  
  39. public Bot(net.minecraft.server.v1_7_R3. World world) {
  40. super(world);
  41.  
  42. try {
  43.  
  44. //Get the Fields from PathFinderGoal
  45. Field bField = PathfinderGoalSelector.class.getDeclaredField("b");
  46. bField.setAccessible(true);
  47. Field cField = PathfinderGoalSelector.class.getDeclaredField("c");
  48. cField.setAccessible(true);
  49. bField.set(goalSelector, new UnsafeList<PathfinderGoalSelector>());
  50. bField.set(targetSelector, new UnsafeList<PathfinderGoalSelector>());
  51. cField.set(goalSelector, new UnsafeList<PathfinderGoalSelector>());
  52. cField.set(targetSelector, new UnsafeList<PathfinderGoalSelector>());
  53.  
  54. } catch (Exception e) {
  55. e.printStackTrace();
  56.  
  57. }
  58.  
  59. // Set the Pathfindergoals
  60. this.goalSelector.a(1, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
  61. this.goalSelector.a(0, new PathfinderGoalMeleeAttack(this, EntityHuman.class, 1.4D, false));
  62. this.targetSelector.a(0, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 0, true));
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69. public void start( final Player p)
  70. {
  71. if(!p.isOnline())
  72. {
  73. this.getBukkitEntity().remove();
  74. return;
  75. }
  76.  
  77.  
  78. if(((CraftWorld)p.getWorld()).getHandle().addEntity(this))
  79. {
  80. p.sendMessage("§aBot gespawnt");
  81. }else{
  82. try{
  83. new BukkitRunnable() {
  84.  
  85. @Override
  86. public void run() {
  87. new Bot((net.minecraft.server.v1_7_R3.World) p.getWorld());
  88.  
  89.  
  90.  
  91. }
  92. }.runTaskLater(Main.inst(), 2 * 20);
  93.  
  94.  
  95.  
  96. }catch(Exception ex)
  97. {
  98.  
  99. }
  100. return;
  101. }
  102.  
  103.  
  104.  
  105.  
  106. PlayerDisguise dis = new PlayerDisguise(p.getName());
  107. DisguiseAPI.disguiseEntity(getBukkitEntity(), dis);
  108. EntityEquipment ee = ((Zombie)getBukkitEntity()).getEquipment();
  109. ee.setItemInHand(new ItemStack(Material.STONE_SWORD));
  110. setSprinting(true);
  111. this.getAttributeInstance(GenericAttributes.a).setValue(350D);
  112. this.getAttributeInstance(GenericAttributes.e).setValue(0);
  113. setHealth(350);
  114.  
  115. PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(Bot.this);
  116. ((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
  117.  
  118. }
  119.  
  120. public void fakeAttack(Player p)
  121. {
  122. for(org.bukkit.entity.Entity ent : getBukkitEntity().getNearbyEntities(3.0, 3.0, 3.0))
  123. {
  124. if(ent instanceof Player)
  125. {
  126. PacketPlayOutAnimation hitAnimation = new PacketPlayOutAnimation(Bot.this, 0);
  127. ((CraftPlayer)p).getHandle().playerConnection.sendPacket(hitAnimation);
  128.  
  129.  
  130. ((Player) ent).damage(2.0);
  131.  
  132. }
  133. }
  134. }
  135.  
  136.  
  137.  
  138.  
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement