AutoBuildDick - Автоматически строит член в 3 блока
package moscow.rockstar.systems.modules.modules.player;
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.SliderSetting;
import moscow.rockstar.utility.inventory.slots.HotbarSlot;
import moscow.rockstar.utility.time.Timer;
import net.minecraft.class_1268;
import net.minecraft.class_1799;
import net.minecraft.class_1802;
import net.minecraft.class_2338;
import net.minecraft.class_243;
import net.minecraft.class_2868;
import net.minecraft.class_3532;
@ModuleInfo(
name = "AutoBuilder",
category = ModuleCategory.PLAYER,
desc = "Строит хуй"
)
public class AutoBuilder extends BaseModule {
private final SliderSetting delay = new SliderSetting(this, "Задержка (мс)", 100, 50, 500);
private final int[][] blocks = {
{0, 1, 0},
{0, 2, 0},
{-1, 0, 0},
{0, 0, 0},
{1, 0, 0}
};
private int stage = 0;
private class_2338 startPos = null;
private final Timer timer = new Timer();
@override
public void onTick() {
if (mc.field_1724 == null) return;
if (mc.field_1761 == null) return;
if (startPos == null) {
startPos = getPlayerBlockPos();
stage = 0;
timer.reset();
return;
}
if (!timer.finished((long) delay.getValue())) return;
if (stage >= blocks.length) {
startPos = null;
stage = 0;
return;
}
int[] offset = blocks[stage];
class_2338 targetPos = new class_2338(
startPos.getX() + offset[0],
startPos.getY() + offset[1],
startPos.getZ() + offset[2]
);
if (isBlockOccupied(targetPos)) {
stage++;
return;
}
if (!isBlockReachable(targetPos)) {
startPos = null;
stage = 0;
return;
}
HotbarSlot slot = findBlockInHotbar();
if (slot == null) return;
placeBlock(targetPos, slot);
timer.reset();
stage++;
}
private boolean isBlockOccupied(class_2338 pos) {
if (mc.field_1687 == null) return true;
return !mc.field_1687.method_8323(pos).method_1584();
}
private boolean isBlockReachable(class_2338 pos) {
if (mc.field_1724 == null) return false;
double dx = pos.getX() + 0.5 - mc.field_1724.method_23317();
double dy = pos.getY() + 0.5 - (mc.field_1724.method_23318() + mc.field_1724.method_18376());
double dz = pos.getZ() + 0.5 - mc.field_1724.method_23321();
double distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
return distance <= 5.0;
}
private HotbarSlot findBlockInHotbar() {
if (mc.field_1724 == null) return null;
for (int i = 0; i < 9; i++) {
class_1799 stack = mc.field_1724.method_31548().field_7548.get(i);
if (stack != null && stack.method_7909() instanceof class_1802) {
class_1802 item = (class_1802) stack.method_7909();
if (item.method_7888()) {
return new HotbarSlot(i);
}
}
}
return null;
}
private void placeBlock(class_2338 pos, HotbarSlot slot) {
if (mc.field_1724 == null) return;
int oldSlot = mc.field_1724.method_31548().field_7545;
if (oldSlot != slot.getSlotId()) {
mc.field_1724.field_3944.method_52787(new class_2868(slot.getSlotId()));
}
facePosition(pos);
mc.field_1761.method_2919(mc.field_1724, class_1268.field_5808);
if (oldSlot != slot.getSlotId()) {
mc.field_1724.field_3944.method_52787(new class_2868(oldSlot));
}
}
private void facePosition(class_2338 pos) {
if (mc.field_1724 == null) return;
class_243 playerPos = mc.field_1724.method_19538();
double dx = pos.getX() + 0.5 - playerPos.field_1352;
double dy = pos.getY() + 0.5 - (playerPos.field_1351 + mc.field_1724.method_18376());
double dz = pos.getZ() + 0.5 - playerPos.field_1350;
float yaw = (float) Math.toDegrees(Math.atan2(dz, dx)) - 90.0F;
float pitch = (float) -Math.toDegrees(Math.atan2(dy, Math.sqrt(dx * dx + dz * dz)));
mc.field_1724.method_14697(yaw);
mc.field_1724.method_36457(class_3532.method_15363(pitch, -90.0F, 90.0F));
}
private class_2338 getPlayerBlockPos() {
if (mc.field_1724 == null) return null;
return new class_2338(
(int) Math.floor(mc.field_1724.method_23317()),
(int) Math.floor(mc.field_1724.method_23318()) - 1,
(int) Math.floor(mc.field_1724.method_23321())
);
}
@override
public void onEnable() {
super.onEnable();
this.startPos = null;
this.stage = 0;
this.timer.reset();
}
@override
public void onDisable() {
super.onDisable();
this.startPos = null;
this.stage = 0;
}
}