Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.zeroeightsix.kami.module.modules.combat;
- import java.util.Collections;
- import java.util.List;
- import net.minecraft.client.Minecraft;
- import me.zeroeightsix.kami.command.Command;
- import me.zeroeightsix.kami.module.Module;
- import me.zeroeightsix.kami.module.ModuleManager;
- import me.zeroeightsix.kami.setting.Setting;
- import me.zeroeightsix.kami.setting.Settings;
- import me.zeroeightsix.kami.util.BlockInteractionHelper;
- import me.zeroeightsix.kami.util.Wrapper;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockContainer;
- import net.minecraft.block.BlockFalling;
- import me.zeroeightsix.kami.util.EntityUtil;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.ItemBlock;
- import net.minecraft.item.ItemStack;
- import net.minecraft.network.play.client.CPacketEntityAction;
- import net.minecraft.network.play.client.CPacketEntityAction.Action;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.util.math.Vec3d;
- import me.zeroeightsix.kami.util.Friends;
- import java.util.Collection;
- import java.util.Collections;
- import java.util.Comparator;
- import java.util.stream.Collectors;
- @Module.Info(name = "TrapTest", category = Module.Category.COMBAT)
- public class TrapTest extends Module {
- 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)};
- 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
- 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)};
- private final List obsidian;
- private Setting toggleable;
- private Setting slowmode;
- private Setting full;
- private Setting feet;
- private Vec3d[] surroundTargets;
- private BlockPos basePos;
- private boolean slowModeSwitch;
- private int blocksPerTick;
- private int offsetStep;
- private int oldSlot;
- boolean BaseBuilt = false;
- public TrapTest() {
- this.obsidian = Collections.singletonList(Blocks.OBSIDIAN);
- this.toggleable = this.register(Settings.b("Toggleable", true));
- this.slowmode = this.register(Settings.b("Slow", false));
- this.full = this.register(Settings.b("Full", false));
- this.feet = this.register(Settings.b("Feet", false));
- this.slowModeSwitch = false;
- this.blocksPerTick = 12;
- this.offsetStep = 0;//ghjkl
- this.oldSlot = 0;
- }
- public void onUpdate() {
- EntityPlayer TrapPlayer = Minecraft.getMinecraft().world.loadedEntityList.stream()
- .filter(EntityUtil::isLiving)
- .filter(entityPlayer -> !Friends.isFriend(entityPlayer.getName()))//dont crash
- .filter(entity -> entity instanceof EntityPlayer)
- .map(entity -> (EntityPlayer) entity)
- .min(Comparator.comparing(c -> mc.player.getDistance(c)))
- .orElse(null);
- // set slot
- if(TrapPlayer == null){
- this.end();
- }
- if (mc.player.isDead) {
- this.end();
- }
- if (!this.isDisabled() && mc.player != null && !ModuleManager.isModuleEnabled("Freecam")) {
- if (this.slowModeSwitch) {
- this.slowModeSwitch = false;
- } else {
- if (this.offsetStep == 0) {
- this.init();
- }
- for(int i = 0; i < this.blocksPerTick; ++i) {
- if (this.offsetStep >= this.surroundTargets.length) {
- this.end();
- return;
- }
- Vec3d offset = this.surroundTargets[this.offsetStep];
- this.placeBlock(new BlockPos(this.basePos.add(offset.x, offset.y, offset.z)));
- ++this.offsetStep;
- }
- this.slowModeSwitch = true;
- }
- }
- }
- private void placeBlock(BlockPos blockPos) {
- if (Wrapper.getWorld().getBlockState(blockPos).getMaterial().isReplaceable()) {
- int newSlot = -1;
- for(int i = 0; i < 9; ++i) {
- ItemStack stack = Wrapper.getPlayer().inventory.getStackInSlot(i);
- if (stack != ItemStack.EMPTY && stack.getItem() instanceof ItemBlock) {
- Block block = ((ItemBlock)stack.getItem()).getBlock();
- 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)) {
- newSlot = i;
- break;
- }
- }
- }
- if (newSlot == -1) {
- if (!(Boolean)this.toggleable.getValue()) {
- Command.sendChatMessage("No Obsidian in Hotbar!");
- }
- this.end();
- } else {
- int oldSlot = Wrapper.getPlayer().inventory.currentItem;
- BaseBuilt = true;
- Wrapper.getPlayer().inventory.currentItem = newSlot;
- if (BlockInteractionHelper.checkForNeighbours(blockPos)) {
- if((Boolean)this.feet.getValue()) {
- this.surroundTargets = this.surroundListFeet;
- } else {
- this.surroundTargets = this.surroundList;
- }
- BlockInteractionHelper.placeBlockScaffoldEntity(blockPos);
- Wrapper.getPlayer().inventory.currentItem = oldSlot;
- }
- }
- }
- }
- private void init() {
- EntityPlayer TrapPlayer = Minecraft.getMinecraft().world.loadedEntityList.stream()
- .filter(EntityUtil::isLiving)
- .filter(entityPlayer -> !Friends.isFriend(entityPlayer.getName()))//dont crash
- .filter(entity -> entity instanceof EntityPlayer)
- .map(entity -> (EntityPlayer) entity)
- .min(Comparator.comparing(c -> mc.player.getDistance(c)))
- .orElse(null);
- this.basePos = (new BlockPos(TrapPlayer.getPositionVector())).down();
- if ((Boolean)this.slowmode.getValue()) {
- this.blocksPerTick = 1;
- }
- if ((Boolean)this.full.getValue()) {
- this.surroundTargets = this.surroundListFull;
- } else {
- this.surroundTargets = this.surroundList;
- }
- }
- private void end() {
- this.offsetStep = 0;
- if (!(Boolean)this.toggleable.getValue()) {
- this.disable();
- }
- }
- @Override
- protected void onEnable() {
- BaseBuilt = false;
- mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, Action.START_SNEAKING));
- this.oldSlot = Wrapper.getPlayer().inventory.currentItem;
- }
- protected void onDisable() {
- BaseBuilt = false;
- mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, Action.STOP_SNEAKING));
- Wrapper.getPlayer().inventory.currentItem = this.oldSlot;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement