Merge pull request #52 from mioclient/rotations
feat: rework rotations system
This commit is contained in:
@@ -3,4 +3,7 @@ package me.alpha432.oyvey.event.impl.entity.player;
|
|||||||
import me.alpha432.oyvey.event.Event;
|
import me.alpha432.oyvey.event.Event;
|
||||||
|
|
||||||
public class TickEvent extends Event {
|
public class TickEvent extends Event {
|
||||||
|
public static class Post extends TickEvent { }
|
||||||
|
|
||||||
|
public static class Pre extends TickEvent { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package me.alpha432.oyvey.event.impl.entity.player;
|
||||||
|
|
||||||
|
import me.alpha432.oyvey.event.Event;
|
||||||
|
|
||||||
|
public class TravelEvent extends Event {
|
||||||
|
public static class Post extends TravelEvent { }
|
||||||
|
|
||||||
|
public static class Pre extends TravelEvent { }
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package me.alpha432.oyvey.features.modules.combat;
|
||||||
|
|
||||||
|
import me.alpha432.oyvey.OyVey;
|
||||||
|
import me.alpha432.oyvey.event.impl.entity.player.TickEvent;
|
||||||
|
import me.alpha432.oyvey.event.system.Subscribe;
|
||||||
|
import me.alpha432.oyvey.features.modules.Module;
|
||||||
|
import me.alpha432.oyvey.features.settings.Setting;
|
||||||
|
import me.alpha432.oyvey.util.models.Angles;
|
||||||
|
import net.minecraft.tags.ItemTags;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
|
||||||
|
public class KillAuraModule extends Module {
|
||||||
|
private final Setting<Float> delay = num("Delay", 1f, 0f, 1f);
|
||||||
|
private final Setting<Float> range = num("Range", 3f, 1f, 6f);
|
||||||
|
private final Setting<Boolean> onlyWeapon = bool("OnlyWeapon", false);
|
||||||
|
private final Setting<Boolean> sync = bool("MovementSync", false);
|
||||||
|
|
||||||
|
public KillAuraModule() {
|
||||||
|
super("KillAura", "Attacks nearby players.", Category.COMBAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe public void onPreTick(TickEvent.Pre event) {
|
||||||
|
if (isOnCooldown())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (onlyWeapon.getValue() && !isHoldingWeapon())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player target = findPlayerTarget();
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Angles angles = Angles.entity(target);
|
||||||
|
int priority = 0;
|
||||||
|
|
||||||
|
if (sync.getValue()) {
|
||||||
|
OyVey.rotationManager.sync(angles, priority, () -> attack(target));
|
||||||
|
} else {
|
||||||
|
OyVey.rotationManager.motion(angles, priority, () -> attack(target));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void attack(Entity entity) {
|
||||||
|
mc.gameMode.attack(mc.player, entity);
|
||||||
|
mc.player.swing(InteractionHand.MAIN_HAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isOnCooldown() {
|
||||||
|
float attackDelay = sync.getValue() ? 1 : 0;
|
||||||
|
return mc.player.getAttackStrengthScale(attackDelay) < delay.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isHoldingWeapon() {
|
||||||
|
ItemStack stack = mc.player.getMainHandItem();
|
||||||
|
return stack.is(ItemTags.SWORDS) || stack.is(ItemTags.AXES) || stack.is(ItemTags.SPEARS)
|
||||||
|
|| stack.is(Items.MACE) || stack.is(Items.TRIDENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Player findPlayerTarget() {
|
||||||
|
Player target = null;
|
||||||
|
float min = range.getValue();
|
||||||
|
for (Player entity : mc.level.players()) {
|
||||||
|
float dist = entity.distanceTo(mc.player);
|
||||||
|
if (entity == mc.player || dist > min) continue;
|
||||||
|
if (OyVey.friendManager.isFriend(entity)) continue;
|
||||||
|
target = entity;
|
||||||
|
min = dist;
|
||||||
|
}
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,7 +29,7 @@ public class EventManager extends Feature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onTick(TickEvent event) {
|
public void onTick(TickEvent.Post event) {
|
||||||
if (nullCheck())
|
if (nullCheck())
|
||||||
return;
|
return;
|
||||||
OyVey.moduleManager.onTick();
|
OyVey.moduleManager.onTick();
|
||||||
@@ -40,21 +40,6 @@ public class EventManager extends Feature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onUpdateWalkingPlayer(UpdateWalkingPlayerEvent event) {
|
|
||||||
if (nullCheck())
|
|
||||||
return;
|
|
||||||
if (event.getStage() == Stage.PRE) {
|
|
||||||
OyVey.speedManager.update();
|
|
||||||
OyVey.rotationManager.updateRotations();
|
|
||||||
OyVey.positionManager.updatePosition();
|
|
||||||
}
|
|
||||||
if (event.getStage() == Stage.POST) {
|
|
||||||
OyVey.rotationManager.restoreRotations();
|
|
||||||
OyVey.positionManager.restorePosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPacketReceive(PacketEvent.Receive event) {
|
public void onPacketReceive(PacketEvent.Receive event) {
|
||||||
OyVey.serverManager.onPacketReceived();
|
OyVey.serverManager.onPacketReceived();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class HoleManager extends Feature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void onTick(TickEvent event) {
|
private void onTick(TickEvent.Pre event) {
|
||||||
holes.clear();
|
holes.clear();
|
||||||
for (int x = -RANGE; x < RANGE; x++) {
|
for (int x = -RANGE; x < RANGE; x++) {
|
||||||
for (int y = -RANGE; y < RANGE; y++) {
|
for (int y = -RANGE; y < RANGE; y++) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import me.alpha432.oyvey.features.modules.Module;
|
|||||||
import me.alpha432.oyvey.features.modules.client.ClickGuiModule;
|
import me.alpha432.oyvey.features.modules.client.ClickGuiModule;
|
||||||
import me.alpha432.oyvey.features.modules.client.HudEditorModule;
|
import me.alpha432.oyvey.features.modules.client.HudEditorModule;
|
||||||
import me.alpha432.oyvey.features.modules.client.NotificationsModule;
|
import me.alpha432.oyvey.features.modules.client.NotificationsModule;
|
||||||
|
import me.alpha432.oyvey.features.modules.combat.KillAuraModule;
|
||||||
import me.alpha432.oyvey.features.modules.combat.CriticalsModule;
|
import me.alpha432.oyvey.features.modules.combat.CriticalsModule;
|
||||||
import me.alpha432.oyvey.features.modules.combat.KeyPearlModule;
|
import me.alpha432.oyvey.features.modules.combat.KeyPearlModule;
|
||||||
import me.alpha432.oyvey.features.modules.hud.CoordinatesHudModule;
|
import me.alpha432.oyvey.features.modules.hud.CoordinatesHudModule;
|
||||||
@@ -51,6 +52,7 @@ public class ModuleManager implements Jsonable, Util {
|
|||||||
register(new BlockHighlightModule());
|
register(new BlockHighlightModule());
|
||||||
register(new NoFallModule());
|
register(new NoFallModule());
|
||||||
register(new KeyPearlModule());
|
register(new KeyPearlModule());
|
||||||
|
register(new KillAuraModule());
|
||||||
|
|
||||||
LOGGER.info("Registered {} modules", modules.size());
|
LOGGER.info("Registered {} modules", modules.size());
|
||||||
|
|
||||||
|
|||||||
@@ -1,75 +1,162 @@
|
|||||||
package me.alpha432.oyvey.manager;
|
package me.alpha432.oyvey.manager;
|
||||||
|
|
||||||
import me.alpha432.oyvey.util.MathUtil;
|
import me.alpha432.oyvey.event.Stage;
|
||||||
|
import me.alpha432.oyvey.event.impl.entity.player.TickEvent;
|
||||||
|
import me.alpha432.oyvey.event.impl.entity.player.TravelEvent;
|
||||||
|
import me.alpha432.oyvey.event.impl.entity.player.UpdateWalkingPlayerEvent;
|
||||||
|
import me.alpha432.oyvey.event.system.Subscribe;
|
||||||
|
import me.alpha432.oyvey.util.models.Angles;
|
||||||
import me.alpha432.oyvey.util.traits.Util;
|
import me.alpha432.oyvey.util.traits.Util;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class RotationManager implements Util {
|
public class RotationManager implements Util {
|
||||||
private float yaw;
|
private final List<Callback> callbacks = new ArrayList<>();
|
||||||
private float pitch;
|
|
||||||
|
|
||||||
public void updateRotations() {
|
private boolean updateRender;
|
||||||
this.yaw = mc.player.getYRot();
|
private Angles renderSnapshot, renderSnapshot0;
|
||||||
this.pitch = mc.player.getXRot();
|
|
||||||
|
private Angles snapshot;
|
||||||
|
private Angles travelSnapshot;
|
||||||
|
|
||||||
|
public RotationManager() {
|
||||||
|
EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreRotations() {
|
@Subscribe(priority = 1000)
|
||||||
mc.player.setYRot(yaw);
|
public void onTickPre(TickEvent.Pre event) {
|
||||||
mc.player.yHeadRot = yaw;
|
executeCallbacks(callback -> callback.type() == Type.SYNC);
|
||||||
mc.player.setXRot(pitch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerRotations(float yaw, float pitch) {
|
@Subscribe
|
||||||
mc.player.setYRot(yaw);
|
public void onTravelPre(TravelEvent.Pre event) {
|
||||||
mc.player.yHeadRot = yaw;
|
if (callbacks.isEmpty())
|
||||||
mc.player.setXRot(pitch);
|
return;
|
||||||
|
|
||||||
|
Callback highest = callbacks.stream().max(Comparator.comparing(Callback::priority)).orElseThrow();
|
||||||
|
if (highest.type() == Type.SYNC) {
|
||||||
|
travelSnapshot = new Angles(mc.player.getYRot(), mc.player.getXRot());
|
||||||
|
mc.player.setYRot(highest.angles().yRot());
|
||||||
|
mc.player.setXRot(highest.angles().xRot());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerYaw(float yaw) {
|
@Subscribe
|
||||||
mc.player.setYRot(yaw);
|
public void onTravelPost(TravelEvent.Post event) {
|
||||||
mc.player.yHeadRot = yaw;
|
if (travelSnapshot != null) {
|
||||||
|
mc.player.setYRot(travelSnapshot.yRot());
|
||||||
|
mc.player.setXRot(travelSnapshot.xRot());
|
||||||
|
travelSnapshot = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lookAtPos(BlockPos pos) {
|
@Subscribe
|
||||||
float[] angle = MathUtil.calcAngle(mc.player.getEyePosition(), new Vec3((float) pos.getX() + 0.5f, (float) pos.getY() + 0.5f, (float) pos.getZ() + 0.5f));
|
public void onUpdateWalking(UpdateWalkingPlayerEvent event) {
|
||||||
this.setPlayerRotations(angle[0], angle[1]);
|
if (event.getStage() == Stage.PRE) {
|
||||||
|
if (callbacks.isEmpty()) {
|
||||||
|
updateRenderSnapshot(new Angles(mc.player.getYRot(), mc.player.getXRot()), false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Callback highest = callbacks.stream().max(Comparator.comparing(Callback::priority)).orElseThrow();
|
||||||
|
|
||||||
|
updateRenderSnapshot(highest.angles(), true);
|
||||||
|
|
||||||
|
snapshot = new Angles(mc.player.getYRot(), mc.player.getXRot());
|
||||||
|
mc.player.setYRot(highest.angles().yRot());
|
||||||
|
mc.player.setXRot(highest.angles().xRot());
|
||||||
|
} else if (snapshot != null) {
|
||||||
|
executeCallbacks(callback -> callback.type() == Type.MOTION);
|
||||||
|
|
||||||
|
mc.player.setYRot(snapshot.yRot());
|
||||||
|
mc.player.setXRot(snapshot.xRot());
|
||||||
|
snapshot = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lookAtVec3d(Vec3 vec3d) {
|
public void sync(Angles angles, Runnable runnable) {
|
||||||
float[] angle = MathUtil.calcAngle(mc.player.getEyePosition(), new Vec3(vec3d.x, vec3d.y, vec3d.z));
|
sync(angles, 0, runnable);
|
||||||
this.setPlayerRotations(angle[0], angle[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lookAtVec3d(double x, double y, double z) {
|
public void sync(Angles angles, int priority, Runnable runnable) {
|
||||||
Vec3 vec3d = new Vec3(x, y, z);
|
request(Type.SYNC, angles, priority, runnable);
|
||||||
this.lookAtVec3d(vec3d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lookAtEntity(Entity entity) {
|
public void motion(Angles angles, Runnable runnable) {
|
||||||
float[] angle = MathUtil.calcAngle(mc.player.getEyePosition(), entity.getEyePosition());
|
motion(angles, 0, runnable);
|
||||||
this.setPlayerRotations(angle[0], angle[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerPitch(float pitch) {
|
public void motion(Angles angles, int priority, Runnable runnable) {
|
||||||
mc.player.setXRot(pitch);
|
request(Type.MOTION, angles, priority, runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getYaw() {
|
public void silent(Angles angles, Runnable runnable) {
|
||||||
return this.yaw;
|
request(Type.SILENT, angles, 0, runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setYaw(float yaw) {
|
public Angles getLerpRenderSnapshot(float lerp) {
|
||||||
this.yaw = yaw;
|
if (!updateRender) return null;
|
||||||
|
return new Angles(
|
||||||
|
Mth.lerp(lerp, renderSnapshot0.yRot(), renderSnapshot.yRot()),
|
||||||
|
Mth.lerp(lerp, renderSnapshot0.xRot(), renderSnapshot.xRot())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getPitch() {
|
public void sendDuplicate(float yaw, float pitch) {
|
||||||
return this.pitch;
|
mc.player.positionReminder = 20;
|
||||||
|
mc.player.yRotLast = yaw;
|
||||||
|
mc.player.xRotLast = pitch;
|
||||||
|
mc.player.connection.send(new ServerboundMovePlayerPacket.PosRot(
|
||||||
|
mc.player.getX(), mc.player.getY(), mc.player.getZ(),
|
||||||
|
yaw, pitch,
|
||||||
|
mc.player.onGround(), mc.player.horizontalCollision
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPitch(float pitch) {
|
private void request(Type type, Angles angles, int priority, Runnable runnable) {
|
||||||
this.pitch = pitch;
|
Callback callback = new Callback(type, angles, priority, runnable);
|
||||||
|
if (type == Type.SILENT) {
|
||||||
|
sendDuplicate(angles.yRot(), angles.xRot());
|
||||||
|
callback.execute();
|
||||||
|
} else {
|
||||||
|
callbacks.add(callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void executeCallbacks(Predicate<Callback> filter) {
|
||||||
|
callbacks.removeIf(callback -> {
|
||||||
|
if (filter.test(callback)) {
|
||||||
|
callback.execute();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateRenderSnapshot(Angles angles, boolean update) {
|
||||||
|
this.renderSnapshot0 = this.renderSnapshot;
|
||||||
|
this.renderSnapshot = angles;
|
||||||
|
this.updateRender = update;
|
||||||
|
|
||||||
|
if (renderSnapshot0 == null || renderSnapshot == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Mth.abs(renderSnapshot.yRot() - renderSnapshot0.yRot()) > 320) {
|
||||||
|
this.renderSnapshot0 = this.renderSnapshot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
record Callback(Type type, Angles angles, int priority, Runnable action) {
|
||||||
|
public void execute() {
|
||||||
|
if (action != null) action.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
MOTION,
|
||||||
|
SYNC,
|
||||||
|
SILENT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package me.alpha432.oyvey.mixin.entity;
|
||||||
|
|
||||||
|
import me.alpha432.oyvey.event.impl.entity.player.TravelEvent;
|
||||||
|
import net.minecraft.client.player.AbstractClientPlayer;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import static me.alpha432.oyvey.util.traits.Util.EVENT_BUS;
|
||||||
|
import static me.alpha432.oyvey.util.traits.Util.isLocalPlayer;
|
||||||
|
|
||||||
|
@Mixin(AbstractClientPlayer.class)
|
||||||
|
public class MixinAbstractClientPlayer {
|
||||||
|
@Inject(method = "tick", at = @At("HEAD"))
|
||||||
|
private void travelPreHook(CallbackInfo ci) {
|
||||||
|
if (isLocalPlayer(this)) {
|
||||||
|
EVENT_BUS.post(new TravelEvent.Pre());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "tick", at = @At("TAIL"))
|
||||||
|
private void travelPostHook(CallbackInfo ci) {
|
||||||
|
if (isLocalPlayer(this)) {
|
||||||
|
EVENT_BUS.post(new TravelEvent.Post());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,9 +13,14 @@ import static me.alpha432.oyvey.util.traits.Util.EVENT_BUS;
|
|||||||
|
|
||||||
@Mixin(LocalPlayer.class)
|
@Mixin(LocalPlayer.class)
|
||||||
public class MixinClientPlayerEntity {
|
public class MixinClientPlayerEntity {
|
||||||
|
@Inject(method = "tick", at = @At("HEAD"))
|
||||||
|
private void tickPreHook(CallbackInfo ci) {
|
||||||
|
EVENT_BUS.post(new TickEvent.Pre());
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "tick", at = @At("TAIL"))
|
@Inject(method = "tick", at = @At("TAIL"))
|
||||||
private void tickHook(CallbackInfo ci) {
|
private void tickHook(CallbackInfo ci) {
|
||||||
EVENT_BUS.post(new TickEvent());
|
EVENT_BUS.post(new TickEvent.Post());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/AbstractClientPlayer;tick()V", shift = At.Shift.AFTER))
|
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/AbstractClientPlayer;tick()V", shift = At.Shift.AFTER))
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package me.alpha432.oyvey.mixin.render;
|
||||||
|
|
||||||
|
import me.alpha432.oyvey.OyVey;
|
||||||
|
import me.alpha432.oyvey.util.models.Angles;
|
||||||
|
import net.minecraft.client.renderer.entity.player.AvatarRenderer;
|
||||||
|
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
|
||||||
|
import net.minecraft.world.entity.Avatar;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import static me.alpha432.oyvey.util.traits.Util.mc;
|
||||||
|
|
||||||
|
@Mixin(AvatarRenderer.class)
|
||||||
|
public class MixinAvatarRenderer {
|
||||||
|
@Inject(method = "extractRenderState(Lnet/minecraft/world/entity/Avatar;Lnet/minecraft/client/renderer/entity/state/AvatarRenderState;F)V", at = @At("TAIL"))
|
||||||
|
private <T extends Avatar> void extractRenderStateHook(T avatar, AvatarRenderState state, float f, CallbackInfo ci) {
|
||||||
|
if (mc.player != avatar) return;
|
||||||
|
Angles lerped = OyVey.rotationManager.getLerpRenderSnapshot(f);
|
||||||
|
if (lerped == null) return;
|
||||||
|
state.xRot = lerped.xRot();
|
||||||
|
state.yRot = 0;
|
||||||
|
state.bodyRot = lerped.yRot();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -204,4 +204,12 @@ public class MathUtil
|
|||||||
double dist = Math.sqrt(difX * difX + difZ * difZ);
|
double dist = Math.sqrt(difX * difX + difZ * difZ);
|
||||||
return new float[]{(float) Mth.wrapDegrees(Math.toDegrees(Math.atan2(difZ, difX)) - 90.0), (float) Mth.wrapDegrees(Math.toDegrees(Math.atan2(difY, dist)))};
|
return new float[]{(float) Mth.wrapDegrees(Math.toDegrees(Math.atan2(difZ, difX)) - 90.0), (float) Mth.wrapDegrees(Math.toDegrees(Math.atan2(difY, dist)))};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vec3 clamp(Vec3 vec3d, AABB aabb) {
|
||||||
|
return new Vec3(
|
||||||
|
clamp(vec3d.x, aabb.minX, aabb.maxX),
|
||||||
|
clamp(vec3d.y, aabb.minY, aabb.maxY),
|
||||||
|
clamp(vec3d.z, aabb.minZ, aabb.maxZ)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package me.alpha432.oyvey.util.models;
|
||||||
|
|
||||||
|
import me.alpha432.oyvey.util.MathUtil;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
import static me.alpha432.oyvey.util.traits.Util.mc;
|
||||||
|
|
||||||
|
public record Angles(float yRot, float xRot) {
|
||||||
|
public Angles(float[] rot) {
|
||||||
|
this(rot[0], rot[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Angles pos(Vec3 pos) {
|
||||||
|
return new Angles(MathUtil.calcAngle(mc.player.getEyePosition(), pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Angles entity(Entity entity) {
|
||||||
|
return pos(MathUtil.clamp(mc.player.getEyePosition(), entity.getBoundingBox()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,4 +6,8 @@ import net.minecraft.client.Minecraft;
|
|||||||
public interface Util {
|
public interface Util {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
EventBus EVENT_BUS = new EventBus();
|
EventBus EVENT_BUS = new EventBus();
|
||||||
|
|
||||||
|
static boolean isLocalPlayer(Object o) {
|
||||||
|
return o == mc.player;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,4 +6,8 @@ accessible method net/minecraft/network/protocol/game/ServerboundInteractPacket$
|
|||||||
accessible class net/minecraft/network/protocol/game/ServerboundInteractPacket$ActionType
|
accessible class net/minecraft/network/protocol/game/ServerboundInteractPacket$ActionType
|
||||||
accessible field net/minecraft/network/protocol/game/ServerboundInteractPacket action Lnet/minecraft/network/protocol/game/ServerboundInteractPacket$Action;
|
accessible field net/minecraft/network/protocol/game/ServerboundInteractPacket action Lnet/minecraft/network/protocol/game/ServerboundInteractPacket$Action;
|
||||||
accessible method net/minecraft/client/multiplayer/MultiPlayerGameMode ensureHasSentCarriedItem ()V
|
accessible method net/minecraft/client/multiplayer/MultiPlayerGameMode ensureHasSentCarriedItem ()V
|
||||||
accessible field com/mojang/blaze3d/platform/InputConstants$Type map Lit/unimi/dsi/fastutil/ints/Int2ObjectMap;
|
accessible field com/mojang/blaze3d/platform/InputConstants$Type map Lit/unimi/dsi/fastutil/ints/Int2ObjectMap;
|
||||||
|
|
||||||
|
accessible field net/minecraft/client/player/LocalPlayer positionReminder I
|
||||||
|
accessible field net/minecraft/client/player/LocalPlayer yRotLast F
|
||||||
|
accessible field net/minecraft/client/player/LocalPlayer xRotLast F
|
||||||
@@ -7,13 +7,15 @@
|
|||||||
"network.MixinConnection"
|
"network.MixinConnection"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
|
"entity.MixinAbstractClientPlayer",
|
||||||
"entity.MixinClientPlayerEntity",
|
"entity.MixinClientPlayerEntity",
|
||||||
"input.MixinKeyboardHandler",
|
"input.MixinKeyboardHandler",
|
||||||
"input.MixinMouseHandler",
|
"input.MixinMouseHandler",
|
||||||
"network.MixinClientPacketListener",
|
"network.MixinClientPacketListener",
|
||||||
|
"render.MixinAvatarRenderer",
|
||||||
"render.MixinChatComponent",
|
"render.MixinChatComponent",
|
||||||
"render.MixinLevelRenderer",
|
|
||||||
"render.MixinDeltaTrackerTimer",
|
"render.MixinDeltaTrackerTimer",
|
||||||
|
"render.MixinLevelRenderer",
|
||||||
"render.gui.MixinCommandSuggestions",
|
"render.gui.MixinCommandSuggestions",
|
||||||
"render.gui.MixinGui"
|
"render.gui.MixinGui"
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user