Начинающий
- Статус
- Оффлайн
- Регистрация
- 6 Окт 2024
- Сообщения
- 360
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
Пишу свои визуалы, решил написать хряка который следует за тобой, да криво, да не много нейронка но как по мне нормик
А кстати у меня завтра др :)
( если тему кнш одобрят 3 марта )
( хз зачем вам эта информация )
А кстати у меня завтра др :)
( если тему кнш одобрят 3 марта )
( хз зачем вам эта информация )
Пожалуйста, авторизуйтесь для просмотра ссылки.
code:
package dev.simplevisuals.modules.impl.utility;
import dev.simplevisuals.client.events.impl.EventTick;
import dev.simplevisuals.modules.api.Category;
import dev.simplevisuals.modules.api.Module;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.entity.passive.PigEntity;
import net.minecraft.util.math.Vec3d;
public class Pig extends Module {
private PigEntity pigEntity;
private Vec3d targetPosition;
private boolean addedToWorld = false;
private int tickCounter = 0;
public Pig() {
super("Pig", Category.Utility, "Spawns your only friend");
}
@Override
public void onEnable() {
super.onEnable();
createPig();
}
@Override
public void onDisable() {
super.onDisable();
removePig();
}
private void createPig() {
if (mc.world != null && mc.player != null) {
pigEntity = new PigEntity(net.minecraft.entity.EntityType.PIG, mc.world);
Vec3d playerPos = mc.player.getPos();
Vec3d pigPosition = new Vec3d(playerPos.x, playerPos.y, playerPos.z - 3.0);
pigEntity.setPos(pigPosition.x, pigPosition.y, pigPosition.z);
pigEntity.setNoGravity(false);
pigEntity.setSilent(true);
pigEntity.setInvulnerable(true);
pigEntity.setAiDisabled(false);
pigEntity.setInvisible(false);
pigEntity.setGlowing(true);
try {
mc.world.addEntity(pigEntity);
addedToWorld = true;
} catch (Exception e) {
addedToWorld = false;
}
}
}
private void removePig() {
if (pigEntity != null && mc.world != null) {
try {
if (addedToWorld) {
pigEntity.remove(net.minecraft.entity.Entity.RemovalReason.DISCARDED);
mc.world.removeEntity(pigEntity.getId(), net.minecraft.entity.Entity.RemovalReason.DISCARDED);
}
} catch (Exception e) {
}
addedToWorld = false;
}
pigEntity = null;
targetPosition = null;
tickCounter = 0;
}
@EventHandler
public void onTick(EventTick event) {
if (mc.player == null || mc.world == null) return;
if (pigEntity == null || pigEntity.isRemoved()) {
createPig();
return;
}
tickCounter++;
updateTargetPosition();
updatePigPosition();
if (tickCounter % 10 == 0) {
pigEntity.setGlowing(true);
pigEntity.setInvisible(false);
}
}
private void updateTargetPosition() {
if (mc.player == null) return;
Vec3d playerPos = mc.player.getPos();
targetPosition = new Vec3d(playerPos.x + 2.0, playerPos.y, playerPos.z);
}
private void updatePigPosition() {
if (targetPosition == null || pigEntity == null) return;
Vec3d currentPos = pigEntity.getPos();
Vec3d direction = targetPosition.subtract(currentPos);
double distance = direction.length();
Vec3d lookDir = mc.player.getPos().subtract(pigEntity.getPos());
float headYaw = (float) Math.toDegrees(Math.atan2(-lookDir.x, lookDir.z));
pigEntity.setHeadYaw(headYaw);
if (distance > 1.0) {
Vec3d movement = direction.normalize().multiply(0.15);
Vec3d newPos = currentPos.add(movement);
double groundY = findGroundLevel(newPos.x, newPos.z);
pigEntity.setPos(newPos.x, groundY, newPos.z);
float bodyYaw = (float) Math.toDegrees(Math.atan2(-direction.x, direction.z));
pigEntity.setYaw(bodyYaw);
pigEntity.limbAnimator.setSpeed(2.0f);
} else {
pigEntity.limbAnimator.setSpeed(0.0f);
pigEntity.setYaw(headYaw);
}
pigEntity.updatePosition(pigEntity.getX(), pigEntity.getY(), pigEntity.getZ());
}
private double findGroundLevel(double x, double z) {
if (mc.world == null) return mc.player.getY();
double startY = mc.player.getY() + 5;
for (int y = (int) startY; y > mc.world.getBottomY(); y--) {
if (mc.world.getBlockState(new net.minecraft.util.math.BlockPos((int) x, y, (int) z)).isSolidBlock(mc.world, new net.minecraft.util.math.BlockPos((int) x, y, (int) z))) {
return y + 1.0;
}
}
return mc.player.getY();
}
}

