Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 11 Фев 2025
- Сообщения
- 5
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
наклипал flight на стеклянных панелях, по багам - флагает при установке блоков, ну я думаю вы сможете сами зафиксить.
Пожалуйста, авторизуйтесь для просмотра ссылки.
Java:
package sweetie.evaware.client.features.modules.movement.fly.modes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.PaneBlock;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import sweetie.evaware.api.event.events.player.move.MotionEvent;
import sweetie.evaware.api.utils.math.MathUtil;
import sweetie.evaware.api.utils.math.TimerUtil;
import sweetie.evaware.api.utils.rotation.RotationUtil;
import sweetie.evaware.api.utils.rotation.manager.Rotation;
import sweetie.evaware.api.utils.rotation.manager.RotationManager;
import sweetie.evaware.api.utils.rotation.manager.RotationStrategy;
import sweetie.evaware.api.utils.rotation.rotations.InstantRotation;
import sweetie.evaware.api.utils.task.TaskPriority;
import sweetie.evaware.api.utils.player.InventoryUtil;
import sweetie.evaware.api.utils.player.MoveUtil;
import sweetie.evaware.client.features.modules.movement.MoveFixModule;
import sweetie.evaware.client.features.modules.movement.fly.FlightMode;
import sweetie.evaware.client.features.modules.movement.fly.FlightModule;
import java.util.function.Supplier;
public class FlightFunTime extends FlightMode {
@Override
public String getName() {
return "FunTime";
}
private final TimerUtil timerUtil = new TimerUtil();
private final TimerUtil placeTimer = new TimerUtil();
private static final float SPEED = 0.1f;
private static final float JUMP_DELAY = 80f;
private static final float PLACE_DELAY = 40f;
public FlightFunTime(Supplier<Boolean> condition) {
}
@Override
public void onMotion(MotionEvent.MotionEventData event) {
Direction facing = mc.player.getHorizontalFacing();
BlockPos posInFront = BlockPos.ofFloored(mc.player.getPos()).offset(facing);
BlockPos posBelow = BlockPos.ofFloored(mc.player.getPos());
if (!isGlassPane(posInFront) && !isGlassPane(posBelow)) {
return;
}
float delay = JUMP_DELAY + MathUtil.randomInRange(0f, 25f);
if (timerUtil.finished(delay) && mc.player.horizontalCollision) {
event.ground(true);
mc.player.setOnGround(true);
mc.player.jump();
mc.player.fallDistance = 0;
timerUtil.reset();
}
}
@Override
public void onUpdate() {
if (MoveUtil.isMoving()) {
MoveUtil.setSpeed(SPEED);
}
tryPlacePane();
}
private boolean isGlassPane(BlockPos pos) {
BlockState state = mc.world.getBlockState(pos);
Block block = state.getBlock();
return block instanceof PaneBlock && block != net.minecraft.block.Blocks.IRON_BARS;
}
private void tryPlacePane() {
float delay = PLACE_DELAY + MathUtil.randomInRange(0f, 20f);
if (!placeTimer.finished(delay)) return;
BlockPos base = BlockPos.ofFloored(mc.player.getPos());
BlockPos target = base;
BlockPos support = target.down();
if (!mc.world.getBlockState(target).isAir()) {
target = base.up();
support = target.down();
}
if (!mc.world.getBlockState(target).isAir()) return;
BlockState supportState = mc.world.getBlockState(support);
if (!supportState.isSolidBlock(mc.world, support) && !isGlassPane(support)) return;
if (placePaneAt(support, Direction.UP)) {
placeTimer.reset();
}
}
private boolean placePaneAt(BlockPos support, Direction face) {
int hotbarSlot = findPaneSlot(true);
int invSlot = hotbarSlot == -1 ? findPaneSlot(false) : -1;
if (hotbarSlot == -1 && invSlot == -1) return false;
int oldSlot = mc.player.getInventory().selectedSlot;
if (hotbarSlot == -1) {
int bestSlot = InventoryUtil.findBestSlotInHotBar();
if (bestSlot == -1) return false;
InventoryUtil.swapSlots(invSlot, bestSlot);
InventoryUtil.swapToSlot(bestSlot);
boolean placed = placeWithHand(support, face);
InventoryUtil.swapToSlot(oldSlot);
InventoryUtil.swapSlots(invSlot, bestSlot);
return placed;
}
InventoryUtil.swapToSlot(hotbarSlot);
boolean placed = placeWithHand(support, face);
InventoryUtil.swapToSlot(oldSlot);
return placed;
}
private boolean placeWithHand(BlockPos support, Direction face) {
if (mc.interactionManager == null) return false;
applyPlaceRotation(support, face);
BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(support), face, support, false);
return mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, hitResult).isAccepted();
}
private void applyPlaceRotation(BlockPos support, Direction face) {
Vec3d targetVec = Vec3d.ofCenter(support).add(new Vec3d(face.getVector()).multiply(0.5));
Rotation rotation = RotationUtil.rotationAt(targetVec);
RotationStrategy strategy = new RotationStrategy(new InstantRotation(), MoveFixModule.enabled(), MoveFixModule.isFree())
.clientLook(false)
.ticksUntilReset(3);
RotationManager.getInstance().addRotation(new Rotation.VecRotation(rotation, targetVec), mc.player, strategy, TaskPriority.REQUIRED, FlightModule.getInstance());
}
private int findPaneSlot(boolean hotbarOnly) {
if (mc.player == null) return -1;
int start = hotbarOnly ? 0 : 9;
int end = hotbarOnly ? 9 : 36;
for (int i = start; i < end; i++) {
ItemStack stack = mc.player.getInventory().main.get(i);
Item item = stack.getItem();
if (isGlassPaneItem(item)) {
return i;
}
}
return -1;
}
private boolean isGlassPaneItem(Item item) {
if (!(item instanceof BlockItem blockItem)) return false;
Block block = blockItem.getBlock();
return block instanceof PaneBlock && block != net.minecraft.block.Blocks.IRON_BARS;
}
}