Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.dukeson.calum.mod.mods;
- import me.dukeson.calum.mod.Mod;
- import me.dukeson.calum.utils.helpers.DrawHelper;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.ItemCloth;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.util.math.MathHelper;
- import java.awt.*;
- import java.util.ArrayList;
- public class BlockPartsBot extends Mod {
- public BlockPartsBot() {
- super("BlockPartsBot", "B", 0xff00ff, Category.SCRIPT);
- }
- private final int minX = -32;
- private final int maxX = 16;
- private final double y = 0.5;
- private final int minZ = -16;
- private final int maxZ = 32;
- private ArrayList<Color> blockColor;
- {
- blockColor = new ArrayList() {{
- add(new Color(254, 254, 254));
- add(new Color(218, 120, 54));
- add(new Color(177, 68, 186));
- add(new Color(80, 117, 192));
- add(new Color(166, 156, 36));
- add(new Color(55, 150, 48));
- add(new Color(209, 135, 154));
- add(new Color(57, 57, 57));
- add(new Color(146, 154, 154));
- add(new Color(40, 96, 120));
- add(new Color(137, 70, 194));
- add(new Color(49, 61, 149));
- add(new Color(78, 49, 30));
- add(new Color(46, 62, 24));
- add(new Color(141, 47, 45));
- add(new Color(17, 13, 13));
- }};
- }
- private ArrayList<BlockPos> matchingBlocks = new ArrayList<>();
- private BlockPos closestMatchingBlock;
- private int colorindex = -1;
- public void update() {
- if (isActive()) {
- matchingBlocks.clear();
- colorindex = mc.player.inventory.getStackInSlot(4).getItem() instanceof ItemCloth ? mc.player.inventory.getStackInSlot(4).getMetadata() : -1;
- if (colorindex == -1) closestMatchingBlock = null;
- for (double x = minX + 0.5; x < maxX; x++) {
- for (double z = minZ + 0.5; z < maxZ; z++) {
- BlockPos bp = new BlockPos(x, y, z);
- IBlockState iBlockState = mc.world.getBlockState(bp);
- if (iBlockState.getBlock() == Blocks.CLAY || iBlockState.getBlock() == Blocks.HARDENED_CLAY || iBlockState.getBlock() == Blocks.STAINED_HARDENED_CLAY || iBlockState.getBlock() == Blocks.WOOL) {
- int index = iBlockState.getBlock().getMetaFromState(iBlockState);
- if (index == colorindex) {
- matchingBlocks.add(bp);
- }
- }
- }
- }
- double distance = Double.MAX_VALUE;
- for (BlockPos blockPos : matchingBlocks) {
- double x = blockPos.getX() - mc.player.posX;
- double z = blockPos.getZ() - mc.player.posZ;
- double d = Math.sqrt(x * x + z * z);
- if (d < distance) {
- distance = d;
- closestMatchingBlock = blockPos;
- }
- }
- if (closestMatchingBlock != null) {
- if (colorindex != mc.world.getBlockState(new BlockPos(mc.player.posX, mc.player.posY - 0.377d, mc.player.posZ)).getBlock().getMetaFromState(mc.world.getBlockState(new BlockPos(mc.player.posX, mc.player.posY - 0.377d, mc.player.posZ)))) {
- double x = closestMatchingBlock.getX() - mc.player.posX;
- double z = closestMatchingBlock.getZ() - mc.player.posZ;
- float yaw = (float) ((Math.atan2(z, x) * 180.0d / Math.PI) - 90.0f);
- mc.player.rotationYaw = mc.player.rotationYaw + MathHelper.wrapDegrees(yaw - mc.player.rotationYaw);
- mc.gameSettings.keyBindSprint.pressed = true;
- mc.gameSettings.keyBindForward.pressed = true;
- } else {
- mc.gameSettings.keyBindSprint.pressed = false;
- mc.gameSettings.keyBindForward.pressed = false;
- }
- } else {
- mc.gameSettings.keyBindSprint.pressed = false;
- mc.gameSettings.keyBindForward.pressed = false;
- }
- }
- }
- public void draw() {
- if (isActive()) {
- for (BlockPos bp : matchingBlocks) {
- if (bp == closestMatchingBlock) DrawHelper.tracerLineToPos2(bp, blockColor.get(colorindex));
- else DrawHelper.tracerLineToPos(bp, blockColor.get(colorindex));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement