Начинающий
- Статус
- Оффлайн
- Регистрация
- 21 Дек 2024
- Сообщения
- 31
- Реакции
- 0
- Выберите загрузчик игры
- Vanilla
- Forge
- Fabric
- NeoForge
- OptiFine
- ForgeOptiFine
- Прочие моды
функция ставит рельсу на нее вагонетку и взрывает луком для работы оно все должно находится в хот баре ss - не будет у мя 3 кадра в обс может какой-то хороший человек кинет так функция вроде работает хорошо ток не пиздите палками
}
JavaScript:
@ModuleRegister(name = "Автоматически взрывает вагонетку", category = Category.Combat, description = "Ставит рельсы с вагонеткой TNT и взрывает рядом с игроком")
public class TNTbabax extends Module {
private BlockPos railPos;
private Entity minecart;
private boolean hasPlaced = false;
private final SliderSetting range = new SliderSetting("Дистанция", 5.0f, 1.0f, 10.0f, 0.5f);
public TNTbabax() {
addSettings(range);
}
public void onEnabled() {
railPos = null;
minecart = null;
hasPlaced = false;
}
@Subscribe
private void onUpdate(EventUpdate event) {
if (!hasPlaced) {
placeRailsAndMinecart();
hasPlaced = true;
} else {
if (minecart != null && minecart.isAlive()) {
if (isPlayerNear(minecart.getPositionVec(), range.get().floatValue())) {
shootArrowAtMinecart();
}
} else {
this.toggle();
}
}
}
private void placeRailsAndMinecart() {
BlockRayTraceResult rayTrace = (BlockRayTraceResult) MouseUtil.rayTrace(5, mc.player.rotationYaw, mc.player.rotationPitch, mc.player);
if (rayTrace.getType() == BlockRayTraceResult.Type.BLOCK) {
BlockPos pos = rayTrace.getPos();
int railSlot = findItemInHotbar(Items.RAIL);
if (railSlot == -1) {
print("Рельсы не найдены в инвентаре!");
this.toggle();
return;
}
int previousSlot = mc.player.inventory.currentItem;
mc.player.inventory.currentItem = railSlot;
mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rayTrace);
mc.player.inventory.currentItem = previousSlot;
int tntMinecartSlot = findItemInHotbar(Items.TNT_MINECART);
if (tntMinecartSlot == -1) {
print("Вагонетка с TNT не найдена!");
this.toggle();
return;
}
mc.player.inventory.currentItem = tntMinecartSlot;
mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rayTrace);
mc.player.inventory.currentItem = previousSlot;
minecart = findMinecartAtPos(pos);
if (minecart == null) {
print("Не удалось найти вагонетку!");
this.toggle();
}
} else {
print("Не удалось найти блок для установки рельсов!");
this.toggle();
}
}
private Entity findMinecartAtPos(BlockPos pos) {
for (Entity entity : mc.world.getAllEntities()) {
if (entity.getType() == EntityType.TNT_MINECART && entity.getPosition().equals(pos)) {
return entity;
}
}
return null;
}
private boolean isPlayerNear(Vector3d pos, float range) {
for (Entity player : mc.world.getPlayers()) {
if (player != mc.player && player.getDistanceSq(pos.x, pos.y, pos.z) <= range * range) {
return true;
}
}
return false;
}
private void shootArrowAtMinecart() {
int bowSlot = findItemInHotbar(Items.BOW);
if (bowSlot == -1) {
print("Лук не найден!");
return;
}
int arrowSlot = findItemInHotbar(Items.ARROW);
if (arrowSlot == -1) {
print("Стрелы не найдены!");
return;
}
int previousSlot = mc.player.inventory.currentItem;
mc.player.inventory.currentItem = bowSlot;
Vector3d eyesPos = mc.player.getEyePosition(1.0f);
Vector3d targetPos = minecart.getBoundingBox().getCenter();
double diffX = targetPos.x - eyesPos.x;
double diffY = targetPos.y - eyesPos.y;
double diffZ = targetPos.z - eyesPos.z;
double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0f;
float pitch = (float) -Math.toDegrees(Math.atan2(diffY, diffXZ));
mc.player.rotationYaw = yaw;
mc.player.rotationPitch = pitch;
mc.gameSettings.keyBindUseItem.setPressed(true);
for (int i = 0; i < 3; i++) {
mc.playerController.processRightClick(mc.player, mc.world, Hand.MAIN_HAND);
}
mc.gameSettings.keyBindUseItem.setPressed(false);
mc.player.inventory.currentItem = previousSlot;
}
private int findItemInHotbar(net.minecraft.item.Item item) {
for (int i = 0; i < 9; i++) {
if (mc.player.inventory.getStackInSlot(i).getItem() == item) {
return i;
}
}
return -1;
}
}
}