Начинающий
- Статус
- Оффлайн
- Регистрация
- 4 Дек 2025
- Сообщения
- 14
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
короче жеско на селф кодил Хз кому надо ниже сс
предлогайте че еще сделать
ss:
предлогайте че еще сделать
ss:
не ну пiпiськi какието:
package moscow.rockstar.systems.modules.modules.player;
import moscow.rockstar.Rockstar;
import moscow.rockstar.systems.event.EventListener;
import moscow.rockstar.systems.event.impl.player.ClientPlayerTickEvent;
import moscow.rockstar.systems.modules.api.ModuleCategory;
import moscow.rockstar.systems.modules.api.ModuleInfo;
import moscow.rockstar.systems.modules.impl.BaseModule;
import moscow.rockstar.systems.setting.settings.BooleanSetting;
import moscow.rockstar.systems.setting.settings.SelectSetting;
import moscow.rockstar.systems.setting.settings.SliderSetting;
import moscow.rockstar.systems.setting.settings.ButtonSetting;
import moscow.rockstar.utility.inventory.group.impl.HotbarSlotsGroup;
import moscow.rockstar.utility.inventory.slots.HotbarSlot;
import moscow.rockstar.utility.time.Timer;
import net.minecraft.block.*;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
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;
@ModuleInfo(name = "AutoFarm", category = ModuleCategory.PLAYER, desc = "Автоматически фармит еду в радиусе: вскапывает, сажает, удобряет и собирает")
public class AutoFarm extends BaseModule {
public final BooleanSetting autoTill = new BooleanSetting(this, "Автовскапывание").enabled(true);
public final BooleanSetting autoReplant = new BooleanSetting(this, "Автопосадка").enabled(true);
public final SliderSetting boneMealSpeed = new SliderSetting(this, "Скорость костной муки").min(1.0f).max(100.0f).step(1.0f).currentValue(10.0f);
public final BooleanSetting onlyWithHoe = new BooleanSetting(this, "Ломать только мотыгой").enabled(false);
public final SelectSetting foodTypes = new SelectSetting(this, "Типы еды");
public final ButtonSetting testButton = new ButtonSetting(this, "Тест", () -> {
testAutoFarmFunction();
return true;
});
public final ButtonSetting demoButton = new ButtonSetting(this, "Демо", () -> {
startDemo();
return true;
});
private final HotbarSlotsGroup hotbarGroup = new HotbarSlotsGroup();
private final Timer boneMealTimer = new Timer();
private final Timer actionTimer = new Timer();
private final Timer plantedTimer = new Timer();
private final Timer demoTimer = new Timer();
private int boneMealCount = 0;
private BlockPos lastBoneMealPos = null;
private BlockPos lastPlantedPos = null;
private boolean demoMode = false;
private int demoStep = 0;
public AutoFarm() {
new SelectSetting.Value(foodTypes, "Морковь").select();
new SelectSetting.Value(foodTypes, "Картофель").select();
new SelectSetting.Value(foodTypes, "Пшеница").select();
new SelectSetting.Value(foodTypes, "Свекла").select();
}
private final EventListener<ClientPlayerTickEvent> onTick = event -> {
if (!isEnabled()) return;
if (demoMode) {
processDemoMode();
return;
}
int hoeSlot = getHoeSlot();
if (hoeSlot == -1) return;
if (!actionTimer.finished(250)) return;
if (mc.crosshairTarget instanceof BlockHitResult hitResult) {
BlockPos pos = hitResult.getBlockPos();
processFarmBlock(pos);
}
};
private void testAutoFarmFunction() {
if (mc.player == null || mc.world == null) return;
addNotification("AutoFarm Test", "Тестирую функции AutoFarm...", true);
int hoeSlot = getHoeSlot();
int boneMealSlot = getItemSlot(Items.BONE_MEAL);
int seedSlot = findSelectedSeeds();
if (hoeSlot == -1) {
addNotification("AutoFarm Test", "Мотыга не найдена в хотбаре!", false);
} else {
addNotification("AutoFarm Test", "Мотыга найдена в слоте " + hoeSlot, true);
}
if (boneMealSlot == -1) {
addNotification("AutoFarm Test", "Костная мука не найдена в хотбаре!", false);
} else {
addNotification("AutoFarm Test", "Костная мука найдена в слоте " + boneMealSlot, true);
}
if (seedSlot == -1) {
addNotification("AutoFarm Test", "Семена выбранных типов еды не найдены!", false);
} else {
addNotification("AutoFarm Test", "Семена найдены в слоте " + seedSlot, true);
}
addNotification("AutoFarm Test", "Тест завершен!", true);
}
private void addNotification(String title, String message, boolean success) {
if (success) {
Rockstar.getInstance().getNotificationManager().addNotification(moscow.rockstar.systems.notifications.NotificationType.SUCCESS, title + ": " + message);
} else {
Rockstar.getInstance().getNotificationManager().addNotification(moscow.rockstar.systems.notifications.NotificationType.ERROR, title + ": " + message);
}
}
private int getBlockPriority(Block block, BlockState state) {
if (canTillBlock(block) && autoTill.isEnabled()) {
return 5;
}
if (block == Blocks.FARMLAND && autoReplant.isEnabled()) {
return 4;
}
if (isFarmableCrop(block) && !isCropFullyGrown(state)) {
return 3;
}
if (isFarmableCrop(block) && isCropFullyGrown(state)) {
return 2;
}
return -1;
}
private void processFarmBlock(BlockPos pos) {
BlockState state = mc.world.getBlockState(pos);
Block block = state.getBlock();
int boneMealSlot = getItemSlot(Items.BONE_MEAL);
int hoeSlot = getHoeSlot();
if (autoTill.isEnabled() && canTillBlock(block) && hoeSlot != -1) {
mc.player.getInventory().selectedSlot = hoeSlot;
interactWithBlock(pos, Direction.UP);
actionTimer.reset();
return;
}
if (block == Blocks.FARMLAND && autoReplant.isEnabled()) {
int seedSlot = findSelectedSeeds();
if (seedSlot != -1) {
ItemStack currentItem = mc.player.getMainHandStack();
if (!isSelectedFood(currentItem.getItem())) {
mc.player.getInventory().selectedSlot = seedSlot;
interactWithBlock(pos, Direction.UP);
lastPlantedPos = pos;
plantedTimer.reset();
boneMealCount = 0;
lastBoneMealPos = pos;
boneMealTimer.reset();
actionTimer.reset();
}
}
return;
}
if (isFarmableCrop(block)) {
boolean isFullyGrown = isCropFullyGrown(state);
if (isFullyGrown) {
if (onlyWithHoe.isEnabled()) {
if (hoeSlot != -1) {
mc.player.getInventory().selectedSlot = hoeSlot;
breakBlock(pos);
actionTimer.reset();
}
} else {
breakBlock(pos);
actionTimer.reset();
}
if (pos.equals(lastPlantedPos)) {
lastPlantedPos = null;
}
} else if (boneMealSlot != -1) {
if (!pos.equals(lastBoneMealPos)) {
boneMealCount = 0;
lastBoneMealPos = pos;
}
boolean isRecentlyPlanted = pos.equals(lastPlantedPos) && !plantedTimer.finished(3000);
long baseBoneMealInterval = (long)(2000.0f / boneMealSpeed.getCurrentValue());
long boneMealInterval = isRecentlyPlanted ?
Math.max(10, baseBoneMealInterval / 2) :
Math.max(20, baseBoneMealInterval);
if (boneMealCount < 5 && boneMealTimer.finished(boneMealInterval)) {
mc.player.getInventory().selectedSlot = boneMealSlot;
interactWithBlock(pos, Direction.UP);
boneMealCount++;
boneMealTimer.reset();
actionTimer.reset();
}
}
}
}
private void interactWithBlock(BlockPos pos, Direction side) {
mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND,
new BlockHitResult(Vec3d.ofCenter(pos), side, pos, false));
mc.player.swingHand(Hand.MAIN_HAND);
}
private void breakBlock(BlockPos pos) {
mc.interactionManager.attackBlock(pos, Direction.UP);
mc.player.swingHand(Hand.MAIN_HAND);
}
private boolean isSelectedFood(Item item) {
for (SelectSetting.Value value : foodTypes.getSelectedValues()) {
String name = value.getName();
if ((name.equals("Морковь") && item == Items.CARROT) ||
(name.equals("Картофель") && item == Items.POTATO) ||
(name.equals("Пшеница") && item == Items.WHEAT) ||
(name.equals("Свекла") && item == Items.BEETROOT)) {
return true;
}
}
return false;
}
private int findSelectedSeeds() {
for (SelectSetting.Value value : foodTypes.getSelectedValues()) {
String name = value.getName();
int slot = -1;
if (name.equals("Морковь")) {
slot = getItemSlot(Items.CARROT);
} else if (name.equals("Картофель")) {
slot = getItemSlot(Items.POTATO);
} else if (name.equals("Пшеница")) {
slot = getItemSlot(Items.WHEAT_SEEDS);
} else if (name.equals("Свекла")) {
slot = getItemSlot(Items.BEETROOT_SEEDS);
}
if (slot != -1) return slot;
}
return -1;
}
private int getHoeSlot() {
HotbarSlot slot;
if ((slot = hotbarGroup.findItem(Items.NETHERITE_HOE)) != null) return slot.getSlotId();
if ((slot = hotbarGroup.findItem(Items.DIAMOND_HOE)) != null) return slot.getSlotId();
if ((slot = hotbarGroup.findItem(Items.GOLDEN_HOE)) != null) return slot.getSlotId();
if ((slot = hotbarGroup.findItem(Items.IRON_HOE)) != null) return slot.getSlotId();
if ((slot = hotbarGroup.findItem(Items.STONE_HOE)) != null) return slot.getSlotId();
if ((slot = hotbarGroup.findItem(Items.WOODEN_HOE)) != null) return slot.getSlotId();
return -1;
}
private int getItemSlot(Item item) {
HotbarSlot slot = hotbarGroup.findItem(item);
return slot != null ? slot.getSlotId() : -1;
}
private boolean canTillBlock(Block block) {
return block == Blocks.DIRT ||
block == Blocks.GRASS_BLOCK ||
block == Blocks.DIRT_PATH ||
block == Blocks.ROOTED_DIRT ||
block == Blocks.COARSE_DIRT;
}
private boolean isCropFullyGrown(BlockState state) {
Block block = state.getBlock();
if (block instanceof CropBlock cropBlock) {
return cropBlock.getAge(state) == cropBlock.getMaxAge();
}
return false;
}
private boolean isFarmableCrop(Block block) {
return block == Blocks.WHEAT ||
block == Blocks.CARROTS ||
block == Blocks.POTATOES ||
block == Blocks.BEETROOTS;
}
private void startDemo() {
if (mc.player == null || mc.world == null) return;
demoMode = true;
demoStep = 0;
demoTimer.reset();
}
private void processDemoMode() {
if (!demoTimer.finished(2000)) return;
switch (demoStep) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
demoMode = false;
return;
}
demoStep++;
demoTimer.reset();
}
@Override
public void onDisable() {
super.onDisable();
if (demoMode) {
demoMode = false;
}
}
}