-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Всем привет, видел то что сливают "NoPlayerTrace", но те функции как таковыми не являются, т.к они работают по разному, Hitbox - это объект который показывает область занимаемую Entity(в нашем случае игроком).
Trace - наш луч, показывает, пересекается ли он с хитбоксом(надеюсь я не ошибаюсь), как раз и хукнёмся к методу который возвращает результат в случае true.
У нас есть класс ProjectileHelper, по крайней мере на 1.16.5 так, на версиях выше будет ProjectileUtil или что то другое, находим метод
Теперь всё просто, мы можешь либо изменять axisalignedbb, либо же возвращать null если функция NoRayTrace включена, по итогу вот как будет выглядеть это у меня, я не пишу свой чит, поэтому покажу на миксинах, вот итог:
Так же вам надо зарегистрировать этот класс как Mixin.
Всё, это готовый вариант, так же обратите внимание, я переименовал некоторые объекты что бы вам было понятнее.
Всем удачи!
Trace - наш луч, показывает, пересекается ли он с хитбоксом(надеюсь я не ошибаюсь), как раз и хукнёмся к методу который возвращает результат в случае true.
У нас есть класс ProjectileHelper, по крайней мере на 1.16.5 так, на версиях выше будет ProjectileUtil или что то другое, находим метод
2:
@Nullable
@OnlyIn(Dist.CLIENT)
public static EntityRayTraceResult getEntityHitResult(Entity p_221273_0_, Vector3d p_221273_1_, Vector3d p_221273_2_, AxisAlignedBB p_221273_3_, Predicate<Entity> p_221273_4_, double p_221273_5_) {
World world = p_221273_0_.level;
double d0 = p_221273_5_;
Entity entity = null;
Vector3d vector3d = null;
for(Entity entity1 : world.getEntities(p_221273_0_, p_221273_3_, p_221273_4_)) {
AxisAlignedBB axisalignedbb = entity1.getBoundingBox().inflate((double)entity1.getPickRadius());
Optional<Vector3d> optional = axisalignedbb.clip(p_221273_1_, p_221273_2_);
if (axisalignedbb.contains(p_221273_1_)) {
if (d0 >= 0.0D) {
entity = entity1;
vector3d = optional.orElse(p_221273_1_);
d0 = 0.0D;
}
} else if (optional.isPresent()) {
Vector3d vector3d1 = optional.get();
double d1 = p_221273_1_.distanceToSqr(vector3d1);
if (d1 < d0 || d0 == 0.0D) {
if (entity1.getRootVehicle() == p_221273_0_.getRootVehicle() && !entity1.canRiderInteract()) {
if (d0 == 0.0D) {
entity = entity1;
vector3d = vector3d1;
}
} else {
entity = entity1;
vector3d = vector3d1;
d0 = d1;
}
}
}
}
return entity == null ? null : new EntityRayTraceResult(entity, vector3d);
}
newCode:
@Mixin(ProjectileHelper.class)
public class ProjectileHelperMixin {
@Inject(method = "getEntityHitResult(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/vector/Vector3d;Lnet/minecraft/util/math/vector/Vector3d;Lnet/minecraft/util/math/AxisAlignedBB;Ljava/util/function/Predicate;D)Lnet/minecraft/util/math/EntityRayTraceResult;", at = @At("RETURN"), cancellable = true)
private static void hitResultHook(Entity shooter, Vector3d start, Vector3d end, AxisAlignedBB axisAlignedBB, Predicate<Entity> entityPredicate, double maxRange, CallbackInfoReturnable<EntityRayTraceResult> cir)
{
World world = shooter.level;
double range = maxRange;
Entity entity = null;
Vector3d vector3d = null;
for(Entity entity1 : world.getEntities(shooter, axisAlignedBB, entityPredicate)) {
AxisAlignedBB axisalignedbb = entity1.getBoundingBox().inflate((double)entity1.getPickRadius());
Optional<Vector3d> optional = axisalignedbb.clip(start, end);
if (axisalignedbb.contains(start)) {
if (range >= .0D) {
entity = entity1;
vector3d = optional.orElse(start);
range = 0.0D;
}
} else if (optional.isPresent()) {
Vector3d vector3d1 = optional.get();
double distance = start.distanceToSqr(vector3d1);
if (distance < range || range == 0.0D) {
if (entity1.getRootVehicle() == shooter.getRootVehicle() && !entity1.canRiderInteract()) {
if (range == 0.0D) {
entity = entity1;
vector3d = vector3d1;
}
} else {
entity = entity1;
vector3d = vector3d1;
range = distance;
}
}
}
}
cir.setReturnValue(entity == null ? null : ((BoolValue && entity instanceof PlayerEntity) ? null : new EntityRayTraceResult(entity, vector3d)));
}
}
Всё, это готовый вариант, так же обратите внимание, я переименовал некоторые объекты что бы вам было понятнее.
Всем удачи!