Source Download Scaffold For Minecraft

CrazyTrap

Newbie
Newbie
Newbie
Newbie
Status
Offline
Joined
Jul 18, 2023
Messages
707
Reaction score
3
Step into a realm where dreams become tangible and imagination knows no limits! Introducing "Scaffold" - your gateway to boundless exploration and unrivaled innovation. Unlock the secrets of an extraordinary universe and immerse yourself in Minecraft like never before! With meticulously curated resources, we empower you to bring your wildest ideas and aspirations to life.

i

Scaffold:​

JavaScript:
 private BlockPos lastPos;
    private EnumFacing lastFacing;

    private final TimerHelper timer = new TimerHelper();

    private BlockData blockData;
    private IBlockState iBlockState;

    @SubscribeEvent
    public void onPlayerTick(TickEvent.PlayerTickEvent event) {
        if (event.phase != TickEvent.Phase.START) return;

        if (!event.player.isSneaking()) {
            BlockPos blockBelow1 = event.player.getPosition();
            IBlockState blockState = event.player.world.getBlockState(blockBelow1);
            if (blockState.getBlock() == Blocks.AIR) {
                this.blockData = getBlockData(blockBelow1, this.invalid);
                if (this.blockData != null) {
                    float yaw = aimAtLocation(this.blockData.position.getX(), this.blockData.position.getY(), this.blockData.position.getZ(), this.blockData.face)[0];
                    float pitch = aimAtLocation(this.blockData.position.getX(), this.blockData.position.getY(), this.blockData.position.getZ(), this.blockData.face)[1];
//                    event.player.rotationYaw = yaw;
//                    event.player.rotationPitch = pitch;
                    mc.player.connection.sendPacket((Packet) new CPacketPlayer.Rotation(yaw, pitch,mc.player.onGround));
                    mc.player.renderYawOffset = yaw;
                    mc.player.rotationYawHead = yaw;
                    mc.player.renderArmPitch = pitch;
                }
            }
        }

        if (this.blockData != null && this.timer.hasReached(75.0F)) {
            BlockPos blockBelow = event.player.getPosition().down();
            if (blockBelow.equals(this.blockData.position)) {
                mc.player.connection.sendPacket(new CPacketAnimation());
                int heldItem = event.player.inventory.currentItem;
                for (int i = 0; i < 9; i++) {
                    if (event.player.inventory.getStackInSlot(i) != null && event.player.inventory.getStackInSlot(i).getItem() instanceof net.minecraft.item.ItemBlock) {
                        event.player.inventory.currentItem = i;
                        break;
                    }
                }
                mc.playerController.processRightClickBlock(mc.player, mc.world, this.blockData.position, this.blockData.face, new Vec3d(this.blockData.position.getX() - 1, this.blockData.position.getY(), this.blockData.position.getZ()), net.minecraft.util.EnumHand.MAIN_HAND);
                event.player.inventory.currentItem = heldItem;
            }
        }
    }

    private float[] aimAtLocation(double x, double y, double z, EnumFacing facing) {
        double diffX = x - (Minecraft.getMinecraft().player.posX + Minecraft.getMinecraft().player.width / 2);
        double diffY = y - (Minecraft.getMinecraft().player.posY + Minecraft.getMinecraft().player.eyeHeight);
        double diffZ = z - (Minecraft.getMinecraft().player.posZ + Minecraft.getMinecraft().player.width / 2);

        double distance = MathHelper.sqrt(diffX * diffX + diffZ * diffZ);

        float yaw = (float) (Math.atan2(diffZ, diffX) * 180 / Math.PI) - 90;
        float pitch = (float) -(Math.atan2(diffY, distance) * 180 / Math.PI);

        return new float[]{yaw, pitch};
    }
    private BlockData getBlockData(BlockPos pos, List<Block> invalid) {
        BlockData blockData = null;

      
        for (EnumFacing facing : EnumFacing.HORIZONTALS) {
            BlockPos offsetPos = pos.offset(facing);
            Block block = mc.world.getBlockState(offsetPos).getBlock();

            if (!invalid.contains(block)) {
              
                BlockPos targetPos = offsetPos.offset(EnumFacing.UP);
                block = mc.world.getBlockState(targetPos).getBlock();

                if (block == Blocks.AIR && targetPos.equals(mc.player.getPosition())) {
                    blockData = new BlockData(targetPos, EnumFacing.UP);
                }
            }
        }

        if (blockData == null) {
          
            BlockPos targetPos = pos.offset(EnumFacing.DOWN);
            Block block = mc.world.getBlockState(targetPos).getBlock();

            if (block == Blocks.AIR) {
                blockData = new BlockData(targetPos, EnumFacing.UP);
            }
        }

        return blockData;
    }
    private class BlockData {
        public BlockPos position;

        public EnumFacing face;

        public BlockData(BlockPos position, EnumFacing face) {
            this.position = position;
            this.face = face;
        }
    }
 
Top