Advertisement
Guest User

surrround

a guest
Nov 18th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.56 KB | None | 0 0
  1. import java.util.Collections;
  2. import java.util.List;
  3. import me.zeroeightsix.kami.command.Command;
  4. import me.zeroeightsix.kami.module.Module;
  5. import me.zeroeightsix.kami.module.Module.Info;
  6. import me.zeroeightsix.kami.module.ModuleManager;
  7. import me.zeroeightsix.kami.setting.Setting;
  8. import me.zeroeightsix.kami.setting.Settings;
  9. import me.zeroeightsix.kami.util.BlockInteractionHelper;
  10. import me.zeroeightsix.kami.util.Wrapper;
  11. import net.minecraft.block.Block;
  12. import net.minecraft.entity.Entity;
  13. import net.minecraft.init.Blocks;
  14. import net.minecraft.item.ItemBlock;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.network.Packet;
  17. import net.minecraft.network.play.client.CPacketEntityAction;
  18. import net.minecraft.util.math.BlockPos;
  19. import net.minecraft.util.math.Vec3d;
  20. import net.minecraft.util.math.Vec3i;
  21.  
  22. @Info(name = "Surround", category = Module.Category.COMBAT)
  23. public class Surround
  24. extends Module {
  25. private final Vec3d[] surroundList = 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(0.0D, 0.0D, 1.0D), new Vec3d(0.0D, 1.0D, 1.0D), new Vec3d(-1.0D, 0.0D, 0.0D), new Vec3d(-1.0D, 1.0D, 0.0D), new Vec3d(0.0D, 0.0D, -1.0D), new Vec3d(0.0D, 1.0D, -1.0D) };
  26. 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) };
  27. private final List obsidian;
  28. private Setting toggleable;
  29. private Setting slowmode;
  30. private Setting full;
  31. private Vec3d[] surroundTargets;
  32. private BlockPos basePos;
  33. private boolean slowModeSwitch;
  34. private int blocksPerTick;
  35. private int offsetStep;
  36. private int oldSlot;
  37.  
  38. public Surround() {
  39. this.obsidian = Collections.singletonList(Blocks.OBSIDIAN);
  40. this.toggleable = register(Settings.b("Toggleable", true));
  41. this.slowmode = register(Settings.b("Slow", false));
  42. this.full = register(Settings.b("Full", false));
  43. this.slowModeSwitch = false;
  44. this.blocksPerTick = 3;
  45. this.offsetStep = 0;
  46. this.oldSlot = 0;
  47. }
  48.  
  49. public void onUpdate() {
  50. if (!isDisabled() && mc.player != null && !ModuleManager.isModuleEnabled("Freecam")) {
  51. if (this.slowModeSwitch) {
  52. this.slowModeSwitch = false;
  53. } else {
  54. if (this.offsetStep == 0) {
  55. init();
  56. }
  57.  
  58. for (int i = 0; i < this.blocksPerTick; i++) {
  59. if (this.offsetStep >= this.surroundTargets.length) {
  60. end();
  61.  
  62. return;
  63. }
  64. Vec3d offset = this.surroundTargets[this.offsetStep];
  65. placeBlock(new BlockPos((Vec3i)this.basePos.add(offset.x, offset.y, offset.z)));
  66. this.offsetStep++;
  67. }
  68.  
  69. this.slowModeSwitch = true;
  70. }
  71. }
  72. }
  73.  
  74. private void placeBlock(BlockPos blockPos) {
  75. if (Wrapper.getWorld().getBlockState(blockPos).getMaterial().isReplaceable()) {
  76. int newSlot = -1;
  77.  
  78. for (int i = 0; i < 9; i++) {
  79. ItemStack stack = (Wrapper.getPlayer()).inventory.getStackInSlot(i);
  80. if (stack != ItemStack.EMPTY && stack.getItem() instanceof ItemBlock) {
  81. Block block = ((ItemBlock)stack.getItem()).getBlock();
  82. if (!BlockInteractionHelper.blackList.contains(block) && !(block instanceof net.minecraft.block.BlockContainer) && Block.getBlockFromItem(stack.getItem()).getDefaultState().isFullBlock() && (!(((ItemBlock)stack.getItem()).getBlock() instanceof net.minecraft.block.BlockFalling) || !Wrapper.getWorld().getBlockState(blockPos.down()).getMaterial().isReplaceable()) && this.obsidian.contains(block)) {
  83. newSlot = i;
  84.  
  85. break;
  86. }
  87. }
  88. }
  89. if (newSlot == -1) {
  90. if (!((Boolean)this.toggleable.getValue()).booleanValue()) {
  91. Command.sendChatMessage("Surround: Please Put Obsidian in Hotbar");
  92. }
  93.  
  94. end();
  95. } else {
  96. (Wrapper.getPlayer()).inventory.currentItem = newSlot;
  97. if (BlockInteractionHelper.checkForNeighbours(blockPos)) {
  98. BlockInteractionHelper.placeBlockScaffold(blockPos);
  99. }
  100. }
  101. }
  102. }
  103.  
  104. private void init() {
  105. this.basePos = (new BlockPos(mc.player.getPositionVector())).down();
  106. if (((Boolean)this.slowmode.getValue()).booleanValue()) {
  107. this.blocksPerTick = 1;
  108. }
  109.  
  110. if (((Boolean)this.full.getValue()).booleanValue()) {
  111. this.surroundTargets = this.surroundListFull;
  112. } else {
  113. this.surroundTargets = this.surroundList;
  114. }
  115. }
  116.  
  117.  
  118. private void end() {
  119. this.offsetStep = 0;
  120. if (!((Boolean)this.toggleable.getValue()).booleanValue()) {
  121. disable();
  122. }
  123. }
  124.  
  125.  
  126. protected void onEnable() {
  127. mc.player.connection.sendPacket((Packet)new CPacketEntityAction((Entity)mc.player, CPacketEntityAction.Action.START_SNEAKING));
  128. this.oldSlot = (Wrapper.getPlayer()).inventory.currentItem;
  129. }
  130.  
  131. protected void onDisable() {
  132. mc.player.connection.sendPacket((Packet)new CPacketEntityAction((Entity)mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
  133. (Wrapper.getPlayer()).inventory.currentItem = this.oldSlot;
  134. }
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement