Начинающий
-
Автор темы
- #1
Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:
- бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
- маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
- приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
- обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.
Спасибо!
AuraModule:
package Enight.function.impl.combat;
// all import
import Enight.enight;
import Enight.event.EventTarget;
import Enight.event.events.impl.player.EventPreMotion;
import Enight.friend.Friend;
import Enight.function.Function;
import Enight.function.impl.Category;
import Enight.function.impl.movement.Timer;
import Enight.ui.settings.impl.BooleanSetting;
import Enight.ui.settings.impl.ListSetting;
import Enight.ui.settings.impl.MultipleBoolSetting;
import Enight.ui.settings.impl.NumberSetting;
import Enight.utils.Combat.GCDFix;
import Enight.utils.inventory.InvenotryUtil;
import Enight.utils.math.MathematicHelper;
import baritone.events.events.player.EventUpdate;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemShield;
import net.minecraft.item.ItemSword;
import net.minecraft.network.play.client.CPacketEntityAction;
import net.minecraft.network.play.client.CPacketHeldItemChange;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.*;
import org.lwjgl.util.vector.Vector2f;
import java.util.ArrayList;
import java.util.List;
// initialization class
public class AuraModule extends Function {
public static EntityLivingBase targetEntity;
private final ListSetting rotationMode = new ListSetting("Rotation Mode", "Matrix", "Matrix", "Sunrise");
public static NumberSetting range = new NumberSetting("Range", 3.1f, 3, 6, 0.05f);
public static NumberSetting prerange = new NumberSetting("Rotation Range", 1.0f, 0, 2, 0.05f);
private final BooleanSetting onlyWeapon = new BooleanSetting("Only Weapon", false);
private final BooleanSetting clientRotation = new BooleanSetting("Client Look", false);
private final BooleanSetting critical = new BooleanSetting("Only Critical", true);
private final BooleanSetting waterCritical = new BooleanSetting("Water Critical", true);
private final BooleanSetting onlySpaceCritical = new BooleanSetting("Only Space Critical", false);
private final BooleanSetting breakShield = new BooleanSetting("Break Shield", true);
public static MultipleBoolSetting targets = new MultipleBoolSetting("Targets", new BooleanSetting("Players", true), new BooleanSetting("Animals", false), new BooleanSetting("Mobs", true), new BooleanSetting("Villagers", false));
public static Vector2f rotation = new Vector2f();
public Vector2f fake = new Vector2f();
private float counter = 0;
private boolean rotatedBefore;
public AuraModule() {
super("AttackAura", "", Category.Combat);
addSettings(rotationMode, targets, range, prerange, clientRotation, waterCritical, onlySpaceCritical, onlyWeapon, breakShield);
}
@EventTarget
public void onMotion(EventPreMotion e) {
if (targetEntity != null) {
if (!checkEntity(targetEntity, range.getNumberValue() + prerange.getNumberValue())) {
targetEntity = null;
}
}
if (targetEntity == null && mc.player.ticksExisted % 3 == 0) {
targetEntity = getTarget();
}
if (targetEntity != null) {
e.setYaw(rotation.x);
e.setPitch(rotation.y);
mc.player.rotationYawHead = rotation.x;
mc.player.renderYawOffset = rotation.x;
mc.player.rotationPitchHead = rotation.y;
if (clientRotation.getCurrentValue()) {
mc.player.rotationYaw = rotation.x;
mc.player.rotationPitch = rotation.y;
}
}
}
@EventTarget
public void onAttacking(EventUpdate e) {
if (targetEntity == null || !checkEntity(targetEntity, range.getNumberValue() + prerange.getNumberValue())) {
rotation = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
fake = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
return;
}
counter = MathematicHelper.clamp(counter, 0, 12 * (enight.instance.featureManager.getFeature(Timer.class).isEnabled() ? Timer.timerSpeed.getNumberValue() : 1));
if (counter > 0) {
counter--;
}
if (targetEntity != null) {
this.rotatedBefore = false;
if (checkCritical(critical.state, onlySpaceCritical.state, waterCritical.state)) {
if (onlyWeapon.getCurrentValue() && !(mc.player.getHeldItemMainhand().getItem() instanceof ItemSword
|| mc.player.getHeldItemMainhand().getItem() instanceof ItemAxe)) {
return;
}
mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SPRINTING));
rotation = rotation(true);
if (calculateDistance(targetEntity, rotation.x, rotation.y,
range.getNumberValue(), entityBehindWall()) == targetEntity) {
if (mc.player.isBlocking()) mc.playerController.onStoppedUsingItem(mc.player);
if (enight.instance.featureManager.getFeature(Timer.class).isEnabled()) {
counter = 30 * Timer.timerSpeed.getNumberValue();
} else {
counter = 10;
}
mc.playerController.attackEntity(mc.player, targetEntity);
mc.player.swingArm(EnumHand.MAIN_HAND);
breakShieldMethod(targetEntity, breakShield.getCurrentValue());
}
}
if (!rotatedBefore) {
rotation = rotation(false);
}
}
}
public static float getDistanceAura(Entity entityIn) {
float f = (float) (mc.player.posX - (entityIn.posX + mc.player.razXZ(entityIn)[0]));
float f1 = (float) (mc.player.posY - entityIn.posY);
float f2 = (float) (mc.player.posZ - entityIn.posZ + mc.player.razXZ(entityIn)[1]);
return MathHelper.sqrt(f * f + f1 * f1 + f2 * f2);
}
public static Entity calculateDistance(Entity target, float yaw, float pitch, double distance, boolean ignoreWalls) {
Minecraft mc = Minecraft.getMinecraft();
Entity pointedEntity;
RayTraceResult objectMouseOver;
Entity entity = mc.getRenderViewEntity();
if (entity != null && mc.world != null) {
objectMouseOver = ignoreWalls ? null : rayTrace(distance, yaw, pitch);
Vec3d vec3d = entity.getPositionEyes(1);
boolean flag = false;
double d1 = distance;
if (distance > 3) {
flag = true;
}
if (objectMouseOver != null) {
d1 = objectMouseOver.hitVec.distanceTo(vec3d);
}
Vec3d vec3d1 = getVectorForRotation(pitch, yaw);
Vec3d vec3d2 = vec3d.add(vec3d1.x * distance, vec3d1.y * distance, vec3d1.z * distance);
pointedEntity = null;
Vec3d vec3d3 = null;
double d2 = d1;
AxisAlignedBB axisalignedbb = target.getEntityBoundingBox()
.grow(target.getCollisionBorderSize());
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(vec3d, vec3d2);
if (axisalignedbb.contains(vec3d)) {
if (d2 >= 0.0D) {
pointedEntity = target;
vec3d3 = raytraceresult == null ? vec3d : raytraceresult.hitVec;
d2 = 0.0D;
}
} else if (raytraceresult != null) {
double d3 = vec3d.distanceTo(raytraceresult.hitVec);
if (d3 < d2 || d2 == 0.0D) {
boolean flag1 = false;
if (!flag1 && target.getLowestRidingEntity() == entity.getLowestRidingEntity()) {
if (d2 == 0.0D) {
pointedEntity = target;
vec3d3 = raytraceresult.hitVec;
}
} else {
pointedEntity = target;
vec3d3 = raytraceresult.hitVec;
d2 = d3;
}
}
}
if (pointedEntity != null && flag && vec3d.distanceTo(vec3d3) > distance) {
pointedEntity = null;
objectMouseOver = new RayTraceResult(RayTraceResult.Type.MISS, vec3d3, null,
new BlockPos(vec3d3));
}
if (pointedEntity != null && (d2 < d1 || objectMouseOver == null)) {
objectMouseOver = new RayTraceResult(pointedEntity, vec3d3);
}
if (objectMouseOver == null)
return null;
return objectMouseOver.entityHit;
}
return null;
}
public static RayTraceResult rayTrace(double blockReachDistance, float yaw, float pitch) {
Vec3d vec3d = Minecraft.getMinecraft().player.getPositionEyes(1);
Vec3d vec3d1 = getVectorForRotation(pitch, yaw);
Vec3d vec3d2 = vec3d.add(vec3d1.x * blockReachDistance, vec3d1.y * blockReachDistance,
vec3d1.z * blockReachDistance);
return Minecraft.getMinecraft().world.rayTraceBlocks(vec3d, vec3d2, true, true, true);
}
public static Vec3d getVectorForRotation(float pitch, float yaw) {
float f = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
float f1 = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
float f2 = -MathHelper.cos(-pitch * 0.017453292F);
float f3 = MathHelper.sin(-pitch * 0.017453292F);
return new Vec3d(f1 * f2, f3, f * f2);
}
public static Vec3d getVecTarget(EntityLivingBase targetEntity, double range) {
double[] rax = mc.player.razXZ(targetEntity);
Vec3d vec = targetEntity.getPositionVector().add(new Vec3d(rax[0], MathHelper.clamp(targetEntity.getEyeHeight() * (mc.player.getDistanceToEntity(targetEntity) / (range + targetEntity.width)), 0.2, mc.player.getEyeHeight()), rax[1]));
if (!isHitBoxVisible(vec)) {
for (double i = targetEntity.width * 0.05; i <= targetEntity.width * 0.95; i += targetEntity.width * 0.9 / 8f) {
for (double j = targetEntity.width * 0.05; j <= targetEntity.width * 0.95; j += targetEntity.width * 0.9 / 8f) {
for (double k = 0; k <= targetEntity.height; k += targetEntity.height / 8f) {
if (isHitBoxVisible(new Vec3d(i, k, j).add(targetEntity.getPositionVector().add(new Vec3d(-targetEntity.width / 2, 0, -targetEntity.width / 2))))) {
vec = new Vec3d(i, k, j).add(targetEntity.getPositionVector().add(new Vec3d(-targetEntity.width / 2, 0, -targetEntity.width / 2)));
break;
}
}
}
}
}
return vec;
}
public static boolean entityBehindWall() {
BlockPos pos = new BlockPos(mc.player.lastReportedPosX, mc.player.lastReportedPosY, mc.player.lastReportedPosZ);
return mc.world.getBlockState(pos).getMaterial() == Material.AIR;
}
public static boolean isHitBoxVisible(Vec3d vec3d) {
final Vec3d eyesPos = new Vec3d(mc.player.posX, mc.player.getEntityBoundingBox().minY + mc.player.getEyeHeight(), mc.player.posZ);
return mc.world.rayTraceBlocks(eyesPos, vec3d, false, true, false) == null;
}
public static void breakShieldMethod(EntityLivingBase base, boolean setting) {
if (InvenotryUtil.doesHotbarHaveAxe() && setting) {
int item = InvenotryUtil.getAxe();
if (base instanceof EntityPlayer && base.getActiveItemStack().getItem() instanceof ItemShield) {
mc.player.connection.sendPacket(new CPacketHeldItemChange(item));
mc.playerController.attackEntity(mc.player, base);
mc.player.swingArm(EnumHand.MAIN_HAND);
mc.player.resetCooldown();
mc.player.connection.sendPacket(new CPacketHeldItemChange(mc.player.inventory.currentItem));
}
}
}
public static boolean checkCritical(boolean criticalSet, boolean spaceCritSet, boolean waterCritSet) {
boolean onSpace = !spaceCritSet
|| (mc.gameSettings.keyBindJump.isKeyDown() || !mc.player.onGround);
if (mc.player.getCooledAttackStrength(1f) < 0.93f) {
return false;
}
if (criticalSet && !reason(waterCritSet)) {
if (isBlockAboveHead() && mc.player.onGround && mc.player.fallDistance > 0) {
return true;
}
return !onSpace || !mc.player.onGround && mc.player.fallDistance != Math.ceil(mc.player.fallDistance);
}
return true;
}
public static boolean reason(boolean water) {
boolean critWater = water && mc.world.getBlockState(new BlockPos(mc.player.posX, mc.player.posY, mc.player.posZ)).getBlock()
instanceof BlockLiquid && mc.world.getBlockState(new BlockPos(mc.player.posX, mc.player.posY + 1,
mc.player.posZ)).getBlock() instanceof BlockAir;
return mc.player.isPotionActive(MobEffects.BLINDNESS) || mc.player.isOnLadder()
|| mc.player.isInWater() && !critWater || mc.player.isInWeb || mc.player.capabilities.isFlying;
}
public static boolean isBlockAboveHead() {
AxisAlignedBB axisAlignedBB = new AxisAlignedBB(mc.player.posX - 0.3, mc.player.posY + mc.player.getEyeHeight(),
mc.player.posZ + 0.3, mc.player.posX + 0.3, mc.player.posY + (!mc.player.onGround ? 1.5 : 2.5),
mc.player.posZ - 0.3);
return !mc.world.getCollisionBoxes(mc.player, axisAlignedBB).isEmpty();
}
public static boolean checkEntity(EntityLivingBase e, double range) {
for (Friend friend : enight.instance.friendManager.getFriends()) {
if (!e.getName().equals(friend.getName())) {
continue;
}
return false;
}
if (e instanceof EntityPlayerSP) {
return false;
}
if (e.isDead) {
return false;
}
if (e.getHealth() <= 0) {
return false;
}
if (enight.instance.featureManager.getFeature(AntiBot.class).isEnabled() && AntiBot.isBotPlayer.contains(e)) {
return false;
}
if (getDistanceAura(e) > range) {
AuraModule.targetEntity = null;
return false;
}
if (e instanceof EntityPlayer && AuraModule.targets.getSetting("Players").getCurrentValue()) {
return true;
}
if (e instanceof EntityAnimal && AuraModule.targets.getSetting("Animals").getCurrentValue()) {
return true;
}
if (e instanceof EntityMob && AuraModule.targets.getSetting("Mobs").getCurrentValue()) {
return true;
}
if (e instanceof EntityVillager && AuraModule.targets.getSetting("Villagers").getCurrentValue()) {
return true;
}
return false;
}
public Vector2f rotation(boolean attack) {
this.rotatedBefore = true;
Vec3d vector = getVecTarget(targetEntity, range.getNumberValue() + prerange.getNumberValue());
float x = (float) (vector.x - mc.player.posX);
float y = (float) (vector.y - mc.player.getPositionEyes(1).y);
float z = (float) (vector.z - mc.player.posZ);
float distance = MathHelper.sqrt(x * x + z * z);
float yaw = (float) Math.toDegrees(Math.atan2(z, x)) - 90.0F;
float pitch = (float) -Math.toDegrees(Math.atan2(y, distance));
fake = new Vector2f(yaw, pitch);
yaw = MathHelper.wrapDegrees(yaw - rotation.x);
pitch = MathHelper.wrapDegrees(pitch - rotation.y);
float calculateYaw = Math.min(Math.max(Math.abs(yaw), 1), 80);
float calculatePitch = Math.max(attack ? Math.abs(pitch) : 1, rotationMode.is("Sunrise") ? 1 : 3);
yaw = GCDFix.getFixedRotation((float) ((rotation.x + (yaw > 0 ? calculateYaw : -calculateYaw)) + Math.sin(System.nanoTime() / 10000000f) * 4));
pitch = GCDFix.getFixedRotation((float) MathematicHelper.clamp(rotation.y + (pitch > 0 ? calculatePitch : -calculatePitch), -90, 90));
return new Vector2f(yaw, pitch);
}
public EntityLivingBase getTarget() {
List<EntityLivingBase> targets = entityParser();
targets.sort((o1, o2) -> {
if (o1.getHealth() > o2.getHealth()) {
return -1;
} else if (o1.getHealth() < o2.getHealth()) {
return 1;
} else {
int dst1 = (int) (getDistanceAura(o1) * 1000);
int dst2 = (int) (getDistanceAura(o2) * 1000);
return dst1 - dst2;
}
});
return targets.isEmpty() ? null : targets.get(0);
}
public List<EntityLivingBase> entityParser() {
List<EntityLivingBase> temp = new ArrayList<>();
for (EntityLivingBase entity : mc.world.playerEntities) {
if (checkEntity(entity, range.getNumberValue() + prerange.getNumberValue())) {
temp.add(entity);
}
}
return temp;
}
@Override
public void onDisable() {
super.onDisable();
targetEntity = null;
}
}
RayCastUtility:
package Enight.utils.Combat;
import Enight.utils.Helper;
import com.google.common.base.Predicates;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EntitySelectors;
import net.minecraft.util.math.*;
import optifine.Reflector;
import org.lwjgl.util.vector.Vector2f;
import java.util.List;
public class RayCastUtility implements Helper {
private static Minecraft mc = Minecraft.getMinecraft();
public static RayTraceResult getPointed(Vector2f rot, double dst, float scale, boolean walls) {
Entity entity = mc.player;
double d0 = dst;
RayTraceResult objectMouseOver = rayTrace(d0, rot.x, rot.y, walls);
Vec3d vec3d = entity.getPositionEyes(1);
boolean flag = false;
double d1 = d0;
if (objectMouseOver != null) {
d1 = objectMouseOver.hitVec.distanceTo(vec3d);
}
Vec3d vec3d1 = getLook(rot.x, rot.y);
Vec3d vec3d2 = vec3d.add(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0);
Entity pointedEntity = null;
Vec3d vec3d3 = null;
List<Entity> list = mc.world.getEntitiesInAABBexcluding(entity,
entity.getEntityBoundingBox().contract(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0)
.expand(1.0D, 1.0D, 1.0D),
Predicates.and(EntitySelectors.NOT_SPECTATING,
p_apply_1_ -> p_apply_1_ != null && p_apply_1_.canBeCollidedWith()));
double d2 = d1;
for (Entity entity1 : list) {
if (entity1 != mc.player) {
float widthPrev = entity1.width;
float heightPrev = entity1.height;
entity1.setSizeAdvanced(widthPrev / scale, heightPrev);
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox()
.grow(entity1.getCollisionBorderSize());
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(vec3d, vec3d2);
if (axisalignedbb.contains(vec3d)) {
if (d2 >= 0.0D) {
pointedEntity = entity1;
vec3d3 = raytraceresult == null ? vec3d : raytraceresult.hitVec;
d2 = 0.0D;
}
} else if (raytraceresult != null) {
double d3 = vec3d.distanceTo(raytraceresult.hitVec);
if (d3 < d2 || d2 == 0.0D) {
boolean flag1 = false;
if (Reflector.ForgeEntity_canRiderInteract.exists()) {
flag1 = Reflector.callBoolean(entity1, Reflector.ForgeEntity_canRiderInteract);
}
if (!flag1 && entity1.getLowestRidingEntity() == entity.getLowestRidingEntity()) {
if (d2 == 0.0D) {
pointedEntity = entity1;
vec3d3 = raytraceresult.hitVec;
}
} else {
pointedEntity = entity1;
vec3d3 = raytraceresult.hitVec;
d2 = d3;
}
}
}
entity1.setSizeAdvanced(widthPrev, heightPrev);
}
}
if (pointedEntity != null && flag && vec3d.distanceTo(vec3d3) > dst) {
pointedEntity = null;
objectMouseOver = new RayTraceResult(RayTraceResult.Type.MISS, vec3d3, null, new BlockPos(vec3d3));
}
if (pointedEntity != null && (d2 < d1 || objectMouseOver == null)) {
objectMouseOver = new RayTraceResult(pointedEntity, vec3d3);
}
return objectMouseOver;
}
public static Entity getPointedEntity(Vector2f rot, double dst, float scale, boolean walls, Entity target) {
Entity entity = mc.player;
double d0 = dst;
RayTraceResult objectMouseOver = rayTrace(d0, rot.x, rot.y, walls);
Vec3d vec3d = entity.getPositionEyes(1);
boolean flag = false;
double d1 = d0;
if (objectMouseOver != null) {
d1 = objectMouseOver.hitVec.distanceTo(vec3d);
}
Vec3d vec3d1 = getLook(rot.x, rot.y);
Vec3d vec3d2 = vec3d.add(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0);
Entity pointedEntity = null;
Vec3d vec3d3 = null;
double d2 = d1;
Entity entity1 = target;
float widthPrev = entity1.width;
float heightPrev = entity1.height;
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(entity1.getCollisionBorderSize());
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(vec3d, vec3d2);
if (axisalignedbb.contains(vec3d)) {
if (d2 >= 0.0D) {
pointedEntity = entity1;
vec3d3 = raytraceresult == null ? vec3d : raytraceresult.hitVec;
d2 = 0.0D;
}
} else if (raytraceresult != null) {
double d3 = vec3d.distanceTo(raytraceresult.hitVec);
if (d3 < d2 || d2 == 0.0D) {
boolean flag1 = false;
if (!flag1 && entity1.getLowestRidingEntity() == entity.getLowestRidingEntity()) {
if (d2 == 0.0D) {
pointedEntity = entity1;
vec3d3 = raytraceresult.hitVec;
}
} else {
pointedEntity = entity1;
vec3d3 = raytraceresult.hitVec;
d2 = d3;
}
}
}
if (pointedEntity != null && flag && vec3d.distanceTo(vec3d3) > dst) {
pointedEntity = null;
objectMouseOver = new RayTraceResult(RayTraceResult.Type.MISS, vec3d3, null, new BlockPos(vec3d3));
}
if (pointedEntity != null && (d2 < d1 || objectMouseOver == null)) {
objectMouseOver = new RayTraceResult(pointedEntity, vec3d3);
}
return objectMouseOver != null
? (objectMouseOver.entityHit instanceof Entity ? (Entity) objectMouseOver.entityHit : null)
: null;
}
public static EntityLivingBase getPointedEntity(Vector2f rot, double dst, float scale, boolean walls) {
Entity entity = mc.player;
double d0 = dst;
RayTraceResult objectMouseOver = rayTrace(d0, rot.x, rot.y, walls);
Vec3d vec3d = entity.getPositionEyes(1);
boolean flag = false;
double d1 = d0;
if (objectMouseOver != null) {
d1 = objectMouseOver.hitVec.distanceTo(vec3d);
}
Vec3d vec3d1 = getLook(rot.x, rot.y);
Vec3d vec3d2 = vec3d.add(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0);
Entity pointedEntity = null;
Vec3d vec3d3 = null;
List<Entity> list = mc.world.getEntitiesInAABBexcluding(entity,
entity.getEntityBoundingBox().contract(vec3d1.x * d0, vec3d1.y * d0, vec3d1.z * d0)
.expand(1.0D, 1.0D, 1.0D),
Predicates.and(EntitySelectors.NOT_SPECTATING,
p_apply_1_ -> p_apply_1_ != null && p_apply_1_.canBeCollidedWith()));
double d2 = d1;
for (Entity entity1 : list) {
if (entity1 != mc.player) {
float widthPrev = entity1.width;
float heightPrev = entity1.height;
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox()
.grow(entity1.getCollisionBorderSize());
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(vec3d, vec3d2);
if (axisalignedbb.contains(vec3d)) {
if (d2 >= 0.0D) {
pointedEntity = entity1;
vec3d3 = raytraceresult == null ? vec3d : raytraceresult.hitVec;
d2 = 0.0D;
}
} else if (raytraceresult != null) {
double d3 = vec3d.distanceTo(raytraceresult.hitVec);
if (d3 < d2 || d2 == 0.0D) {
boolean flag1 = false;
if (Reflector.ForgeEntity_canRiderInteract.exists()) {
flag1 = Reflector.callBoolean(entity1, Reflector.ForgeEntity_canRiderInteract);
}
if (!flag1 && entity1.getLowestRidingEntity() == entity.getLowestRidingEntity()) {
if (d2 == 0.0D) {
pointedEntity = entity1;
vec3d3 = raytraceresult.hitVec;
}
} else {
pointedEntity = entity1;
vec3d3 = raytraceresult.hitVec;
d2 = d3;
}
}
}
}
}
if (pointedEntity != null && flag && vec3d.distanceTo(vec3d3) > dst) {
pointedEntity = null;
objectMouseOver = new RayTraceResult(RayTraceResult.Type.MISS, vec3d3, null, new BlockPos(vec3d3));
}
if (pointedEntity != null && (d2 < d1 || objectMouseOver == null)) {
objectMouseOver = new RayTraceResult(pointedEntity, vec3d3);
}
return objectMouseOver != null
? (objectMouseOver.entityHit instanceof EntityLivingBase ? (EntityLivingBase) objectMouseOver.entityHit
: null)
: null;
}
public static RayTraceResult rayTrace(double blockReachDistance, float yaw, float pitch, boolean walls) {
if (!walls) {
return null;
}
Vec3d vec3d = mc.player.getPositionEyes(1);
Vec3d vec3d1 = getLook(yaw, pitch);
Vec3d vec3d2 = vec3d.add(vec3d1.x * blockReachDistance, vec3d1.y * blockReachDistance,
vec3d1.z * blockReachDistance);
return mc.world.rayTraceBlocks(vec3d, vec3d2, true, true, true);
}
static Vec3d getVectorForRotation(float pitch, float yaw) {
float f = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
float f1 = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
float f2 = -MathHelper.cos(-pitch * 0.017453292F);
float f3 = MathHelper.sin(-pitch * 0.017453292F);
return new Vec3d((double) (f1 * f2), (double) f3, (double) (f * f2));
}
static Vec3d getLook(float yaw, float pitch) {
return getVectorForRotation(pitch, yaw);
}
}
RotationUtility:
package Enight.utils.Combat;
import Enight.utils.Helper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.lwjgl.util.vector.Vector2f;
public class RotationUtility implements Helper {
public static Vector2f getDeltaForCoord(Vector2f rot, Vec3d point) {
EntityPlayerSP client = Minecraft.getMinecraft().player;
double x = point.x - client.posX;
double y = point.y - client.getPositionEyes(1).y;
double z = point.z - client.posZ;
double dst = Math.sqrt(Math.pow(x, 2) + Math.pow(z, 2));
float yawToTarget = (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(z, x)) - 90);
float pitchToTarget = (float) (-Math.toDegrees(Math.atan2(y, dst)));
float yawDelta = MathHelper.wrapDegrees(yawToTarget - rot.x);
float pitchDelta = (pitchToTarget - rot.y);
return new Vector2f(yawDelta, pitchDelta);
}
public static Vector2f getRotationForCoord(Vec3d point) {
EntityPlayerSP client = Minecraft.getMinecraft().player;
double x = point.x - client.posX;
double y = point.y - client.getPositionEyes(1).y;
double z = point.z - client.posZ;
double dst = Math.sqrt(Math.pow(x, 2) + Math.pow(z, 2));
float yawToTarget = (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(z, x)) - 90);
float pitchToTarget = (float) (-Math.toDegrees(Math.atan2(y, dst)));
return new Vector2f(yawToTarget, pitchToTarget);
}
}
AdvancedCast:
package Enight.utils.Combat;
import Enight.utils.Helper;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
public class AdvancedCast implements Helper {
public static AdvancedCast instance = new AdvancedCast();
public Entity getMouseOver(Entity target, float yaw, float pitch, double distance, boolean ignoreWalls) {
Minecraft mc = Minecraft.getMinecraft();
Entity pointedEntity;
RayTraceResult objectMouseOver;
Entity entity = mc.getRenderViewEntity();
if (entity != null && mc.world != null) {
objectMouseOver = ignoreWalls ? null : rayTrace(distance, yaw, pitch);
Vec3d vec3d = entity.getPositionEyes(1);
boolean flag = false;
double d1 = distance;
if (distance > 3) {
flag = true;
}
if (objectMouseOver != null) {
d1 = objectMouseOver.hitVec.distanceTo(vec3d);
}
Vec3d vec3d1 = getVectorForRotation(pitch, yaw);
Vec3d vec3d2 = vec3d.add(vec3d1.x * distance, vec3d1.y * distance, vec3d1.z * distance);
pointedEntity = null;
Vec3d vec3d3 = null;
double d2 = d1;
AxisAlignedBB axisalignedbb = target.getEntityBoundingBox()
.grow(target.getCollisionBorderSize());
RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(vec3d, vec3d2);
if (axisalignedbb.contains(vec3d)) {
if (d2 >= 0.0D) {
pointedEntity = target;
vec3d3 = raytraceresult == null ? vec3d : raytraceresult.hitVec;
d2 = 0.0D;
}
} else if (raytraceresult != null) {
double d3 = vec3d.distanceTo(raytraceresult.hitVec);
if (d3 < d2 || d2 == 0.0D) {
boolean flag1 = false;
if (!flag1 && target.getLowestRidingEntity() == entity.getLowestRidingEntity()) {
if (d2 == 0.0D) {
pointedEntity = target;
vec3d3 = raytraceresult.hitVec;
}
} else {
pointedEntity = target;
vec3d3 = raytraceresult.hitVec;
d2 = d3;
}
}
}
if (pointedEntity != null && flag && vec3d.distanceTo(vec3d3) > distance) {
pointedEntity = null;
objectMouseOver = new RayTraceResult(RayTraceResult.Type.MISS, vec3d3, null,
new BlockPos(vec3d3));
}
if (pointedEntity != null && (d2 < d1 || objectMouseOver == null)) {
objectMouseOver = new RayTraceResult(pointedEntity, vec3d3);
}
if (objectMouseOver == null)
return null;
return objectMouseOver.entityHit;
}
return null;
}
public RayTraceResult rayTrace(double blockReachDistance, float yaw, float pitch) {
Vec3d vec3d = Minecraft.getMinecraft().player.getPositionEyes(1);
Vec3d vec3d1 = getVectorForRotation(pitch, yaw);
Vec3d vec3d2 = vec3d.add(vec3d1.x * blockReachDistance, vec3d1.y * blockReachDistance,
vec3d1.z * blockReachDistance);
return Minecraft.getMinecraft().world.rayTraceBlocks(vec3d, vec3d2, true, true, true);
}
protected final Vec3d getVectorForRotation(float pitch, float yaw) {
float f = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
float f1 = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
float f2 = -MathHelper.cos(-pitch * 0.017453292F);
float f3 = MathHelper.sin(-pitch * 0.017453292F);
return new Vec3d(f1 * f2, f3, f * f2);
}
}
Пожалуйста, авторизуйтесь для просмотра ссылки.