Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
1,773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.96 KB | None | 0 0
  1. package me.zeroeightsix.kami.module.modules.combat;
  2.  
  3. import java.util.Collections;
  4. import java.util.List;
  5. import net.minecraft.client.Minecraft;
  6. import me.zeroeightsix.kami.command.Command;
  7. import me.zeroeightsix.kami.module.Module;
  8. import me.zeroeightsix.kami.module.ModuleManager;
  9. import me.zeroeightsix.kami.setting.Setting;
  10. import me.zeroeightsix.kami.setting.Settings;
  11. import me.zeroeightsix.kami.util.BlockInteractionHelper;
  12. import me.zeroeightsix.kami.util.Wrapper;
  13. import net.minecraft.block.Block;
  14. import net.minecraft.block.BlockContainer;
  15. import net.minecraft.block.BlockFalling;
  16. import me.zeroeightsix.kami.util.EntityUtil;
  17. import net.minecraft.entity.player.EntityPlayer;
  18. import net.minecraft.init.Blocks;
  19. import net.minecraft.item.ItemBlock;
  20. import net.minecraft.item.ItemStack;
  21. import net.minecraft.network.play.client.CPacketEntityAction;
  22. import net.minecraft.network.play.client.CPacketEntityAction.Action;
  23. import net.minecraft.util.math.BlockPos;
  24. import net.minecraft.util.math.Vec3d;
  25. import me.zeroeightsix.kami.util.Friends;
  26. import java.util.Collection;
  27. import java.util.Collections;
  28. import java.util.Comparator;
  29. import java.util.stream.Collectors;
  30.  
  31. @Module.Info(name = "TrapTest", category = Module.Category.COMBAT)
  32. public class TrapTest extends Module {
  33. private final Vec3d[] surroundList = new Vec3d[]{ new Vec3d(1.0D, 0.0D, 0.0D), new Vec3d(0.0D, 0.0D, 1.0D), new Vec3d(-1.0D, 0.0D, 0.0D), new Vec3d(0.0D, 0.0D, -1.0D), new Vec3d(1.0D, 1.0D, 0.0D), new Vec3d(0.0D, 1.0D, 1.0D), new Vec3d(-1.0D, 1.0D, 0.0D), new Vec3d(0.0D, 1.0D, -1.0D), new Vec3d(0.0D, 1.0D, -1.0D), new Vec3d(1.0D, 2.0D, 0.0D), new Vec3d(0.0D, 2.0D, 1.0D), new Vec3d(-1.0D, 2.0D, 0.0D), new Vec3d(0.0D, 2.0D, -1.0D), new Vec3d(0.0D, 3.0D, -1.0D), new Vec3d(0.0D, 3.0D, 1.0D), new Vec3d(0.0D, 3.0D, 0.0D)};
  34. private final Vec3d[] surroundListFeet = new Vec3d[]{ new Vec3d(1.0D, 1.0D, 1.0D), new Vec3d(-1.0D, 1.0D, 1.0D), new Vec3d(1.0D, 1.0D, -1.0D), new Vec3d(-1.0D, 1.0D, -1.0D), new Vec3d(1.0D, 0.0D, 1.0D), new Vec3d(-1.0D, 0.0D, 1.0D), new Vec3d(1.0D, 0.0D, -1.0D), new Vec3d(-1.0D, 0.0D, -1.0D),new Vec3d(-1.0D, 2.0D, 1.0D), new Vec3d(1.0D, 2.0D, 1.0D), new Vec3d(-1.0D, 2.0D, -1.0D), new Vec3d(1.0D, 2.0D, 0.0D), new Vec3d(0.0D, 2.0D, 1.0D), new Vec3d(-1.0D, 2.0D, 0.0D), new Vec3d(0.0D, 2.0D, -1.0D), new Vec3d(-1.0D, 3.0D, 0.0D), new Vec3d(0.0D, 3.0D, 0.0D),new Vec3d(1.0D, 3.0D, 0.0D),};//gay
  35. private final Vec3d[] surroundListFull = new Vec3d[]{new Vec3d(0.0D, 0.0D, 0.0D), new Vec3d(1.0D, 0.0D, 0.0D), new Vec3d(1.0D, 1.0D, 0.0D), new Vec3d(1.0D, 0.0D, 1.0D), new Vec3d(1.0D, 1.0D, 1.0D), new Vec3d(0.0D, 0.0D, 1.0D), new Vec3d(0.0D, 1.0D, 1.0D), new Vec3d(-1.0D, 0.0D, 1.0D), new Vec3d(-1.0D, 1.0D, 1.0D), new Vec3d(-1.0D, 0.0D, 0.0D), new Vec3d(-1.0D, 1.0D, 0.0D), new Vec3d(-1.0D, 0.0D, -1.0D), new Vec3d(-1.0D, 1.0D, -1.0D), new Vec3d(0.0D, 0.0D, -1.0D), new Vec3d(0.0D, 1.0D, -1.0D), new Vec3d(1.0D, 0.0D, -1.0D), new Vec3d(1.0D, 1.0D, -1.0D)};
  36. private final List obsidian;
  37. private Setting toggleable;
  38. private Setting slowmode;
  39. private Setting full;
  40. private Setting feet;
  41. private Vec3d[] surroundTargets;
  42. private BlockPos basePos;
  43. private boolean slowModeSwitch;
  44. private int blocksPerTick;
  45. private int offsetStep;
  46. private int oldSlot;
  47. boolean BaseBuilt = false;
  48.  
  49. public TrapTest() {
  50. this.obsidian = Collections.singletonList(Blocks.OBSIDIAN);
  51. this.toggleable = this.register(Settings.b("Toggleable", true));
  52. this.slowmode = this.register(Settings.b("Slow", false));
  53. this.full = this.register(Settings.b("Full", false));
  54. this.feet = this.register(Settings.b("Feet", false));
  55. this.slowModeSwitch = false;
  56. this.blocksPerTick = 12;
  57. this.offsetStep = 0;//ghjkl
  58. this.oldSlot = 0;
  59. }
  60.  
  61. public void onUpdate() {
  62. EntityPlayer TrapPlayer = Minecraft.getMinecraft().world.loadedEntityList.stream()
  63. .filter(EntityUtil::isLiving)
  64. .filter(entityPlayer -> !Friends.isFriend(entityPlayer.getName()))//dont crash
  65. .filter(entity -> entity instanceof EntityPlayer)
  66. .map(entity -> (EntityPlayer) entity)
  67. .min(Comparator.comparing(c -> mc.player.getDistance(c)))
  68. .orElse(null);
  69. // set slot
  70. if(TrapPlayer == null){
  71. this.end();
  72. }
  73. if (mc.player.isDead) {
  74. this.end();
  75. }
  76. if (!this.isDisabled() && mc.player != null && !ModuleManager.isModuleEnabled("Freecam")) {
  77. if (this.slowModeSwitch) {
  78. this.slowModeSwitch = false;
  79. } else {
  80. if (this.offsetStep == 0) {
  81. this.init();
  82. }
  83.  
  84. for(int i = 0; i < this.blocksPerTick; ++i) {
  85. if (this.offsetStep >= this.surroundTargets.length) {
  86. this.end();
  87. return;
  88. }
  89.  
  90. Vec3d offset = this.surroundTargets[this.offsetStep];
  91. this.placeBlock(new BlockPos(this.basePos.add(offset.x, offset.y, offset.z)));
  92. ++this.offsetStep;
  93. }
  94.  
  95. this.slowModeSwitch = true;
  96. }
  97. }
  98. }
  99.  
  100. private void placeBlock(BlockPos blockPos) {
  101. if (Wrapper.getWorld().getBlockState(blockPos).getMaterial().isReplaceable()) {
  102. int newSlot = -1;
  103.  
  104. for(int i = 0; i < 9; ++i) {
  105. ItemStack stack = Wrapper.getPlayer().inventory.getStackInSlot(i);
  106. if (stack != ItemStack.EMPTY && stack.getItem() instanceof ItemBlock) {
  107. Block block = ((ItemBlock)stack.getItem()).getBlock();
  108. if (!BlockInteractionHelper.blackList.contains(block) && !(block instanceof BlockContainer) && Block.getBlockFromItem(stack.getItem()).getDefaultState().isFullBlock() && (!(((ItemBlock)stack.getItem()).getBlock() instanceof BlockFalling) || !Wrapper.getWorld().getBlockState(blockPos.down()).getMaterial().isReplaceable()) && this.obsidian.contains(block)) {
  109. newSlot = i;
  110. break;
  111. }
  112. }
  113. }
  114.  
  115. if (newSlot == -1) {
  116. if (!(Boolean)this.toggleable.getValue()) {
  117. Command.sendChatMessage("No Obsidian in Hotbar!");
  118. }
  119.  
  120. this.end();
  121. } else {
  122. int oldSlot = Wrapper.getPlayer().inventory.currentItem;
  123. BaseBuilt = true;
  124. Wrapper.getPlayer().inventory.currentItem = newSlot;
  125. if (BlockInteractionHelper.checkForNeighbours(blockPos)) {
  126. if((Boolean)this.feet.getValue()) {
  127. this.surroundTargets = this.surroundListFeet;
  128. } else {
  129. this.surroundTargets = this.surroundList;
  130. }
  131. BlockInteractionHelper.placeBlockScaffoldEntity(blockPos);
  132. Wrapper.getPlayer().inventory.currentItem = oldSlot;
  133. }
  134. }
  135. }
  136. }
  137.  
  138. private void init() {
  139. EntityPlayer TrapPlayer = Minecraft.getMinecraft().world.loadedEntityList.stream()
  140. .filter(EntityUtil::isLiving)
  141. .filter(entityPlayer -> !Friends.isFriend(entityPlayer.getName()))//dont crash
  142. .filter(entity -> entity instanceof EntityPlayer)
  143. .map(entity -> (EntityPlayer) entity)
  144. .min(Comparator.comparing(c -> mc.player.getDistance(c)))
  145. .orElse(null);
  146. this.basePos = (new BlockPos(TrapPlayer.getPositionVector())).down();
  147. if ((Boolean)this.slowmode.getValue()) {
  148. this.blocksPerTick = 1;
  149. }
  150.  
  151. if ((Boolean)this.full.getValue()) {
  152. this.surroundTargets = this.surroundListFull;
  153. } else {
  154. this.surroundTargets = this.surroundList;
  155. }
  156.  
  157. }
  158.  
  159. private void end() {
  160. this.offsetStep = 0;
  161. if (!(Boolean)this.toggleable.getValue()) {
  162. this.disable();
  163. }
  164.  
  165. }
  166. @Override
  167. protected void onEnable() {
  168. BaseBuilt = false;
  169. mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, Action.START_SNEAKING));
  170. this.oldSlot = Wrapper.getPlayer().inventory.currentItem;
  171. }
  172.  
  173. protected void onDisable() {
  174. BaseBuilt = false;
  175. mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, Action.STOP_SNEAKING));
  176. Wrapper.getPlayer().inventory.currentItem = this.oldSlot;
  177. }
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement