//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package alphadlc.client.utils.rotation.impl;
import alphadlc.client.AlphaDLC;
import alphadlc.client.modules.impl.combat.Aura;
import alphadlc.client.utils.math.StopWatch;
import alphadlc.client.utils.rotation.Rotation;
import alphadlc.client.utils.rotation.RotationHandler;
import alphadlc.client.utils.rotation.RotationMath;
import java.security.SecureRandom;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
public class FunTimeRotation extends RotationHandler {
private final StopWatch attackTimer = new StopWatch();
private final StopWatch headMovementTimer = new StopWatch();
private int attackCount = 0;
private final SecureRandom random = new SecureRandom();
private float randomYawOffset = 0.0F;
private float randomPitchOffset = 0.0F;
private boolean isPreparingAttack = false;
private long lastHeadMovement = 0L;
private long lastDirectionChange = 0L;
private float yawMultiplier = 1.0F;
private int movementSeries = 0;
private int seriesLength = 1;
private int attackCounter = 0;
private int nextMissAttack = 0;
private boolean shouldMiss = false;
private long lastCounterReset = System.currentTimeMillis();
private long nextResetTime = 0L;
public FunTimeRotation() {
super("FunTime");
this.nextMissAttack = 10 + this.random.nextInt(5);
this.nextResetTime = System.currentTimeMillis() + (long)('鱀' + this.random.nextInt(30001));
}
public Rotation limitAngleChange(Rotation currentRotation, Rotation targetRotation, Vector3d vec3d, Entity entity) {
Aura aura = AlphaDLC.getInstance().getFunctionRegistry().getAura();
if (entity != null) {
Vector3d targetPoint = this.getRandomAttackPoint(entity);
targetRotation = RotationMath.calculateAngle(targetPoint);
}
Rotation delta = Rotation.calculateDelta(currentRotation, targetRotation);
float yawDelta = delta.getYaw();
float pitchDelta = delta.getPitch();
float rotationDifference = (float)Math.hypot((double)Math.abs(yawDelta), (double)Math.abs(pitchDelta));
if (entity != null) {
boolean canAttack = this.canAttack();
long currentTime = System.currentTimeMillis();
if (currentTime >= this.nextResetTime) {
this.attackCounter = 0;
this.shouldMiss = false;
this.nextMissAttack = 10 + this.random.nextInt(5);
this.movementSeries = 0;
this.lastDirectionChange = currentTime;
this.nextResetTime = currentTime + (long)('鱀' + this.random.nextInt(30001));
this.lastCounterReset = currentTime;
}
if (canAttack) {
++this.attackCounter;
if (this.attackCounter >= this.nextMissAttack) {
this.shouldMiss = true;
this.attackCounter = 0;
this.nextMissAttack = 10 + this.random.nextInt(5);
}
}
float speed;
if (canAttack) {
speed = this.randomLerp(0.7F, 0.85F);
} else {
speed = this.randomLerp(0.35F, 0.5F);
}
float lineYaw = Math.abs(yawDelta / rotationDifference) * 180.0F;
float linePitch = Math.abs(pitchDelta / rotationDifference) * 180.0F;
float lookAwayYaw = 0.0F;
float lookAwayPitch = 0.0F;
float dynamicThreshold = 45.0F;
if (Math.abs(lookAwayYaw) > 20.0F) {
dynamicThreshold = 70.0F;
}
boolean isReadyToStrike = canAttack && rotationDifference < dynamicThreshold;
if (this.shouldMiss && isReadyToStrike) {
lookAwayYaw = this.randomLerp(40.0F, 80.0F) * (float)(this.random.nextBoolean() ? 1 : -1);
lookAwayPitch = this.randomLerp(20.0F, 40.0F) * (float)(this.random.nextBoolean() ? 1 : -1);
this.shouldMiss = false;
} else if (!isReadyToStrike && aura.isState()) {
long currentTimeMs = System.currentTimeMillis();
if (currentTimeMs - this.lastDirectionChange > 400L) {
++this.movementSeries;
if (this.movementSeries >= this.seriesLength) {
this.movementSeries = 0;
this.seriesLength = 1 + this.random.nextInt(3);
this.yawMultiplier = -this.yawMultiplier;
}
this.lastDirectionChange = currentTimeMs;
}
lookAwayYaw = (float)((double)(30.0F * this.yawMultiplier) * Math.cos((double)currentTimeMs / (double)400.0F));
float sinValue = (float)Math.sin((double)currentTimeMs / (double)5000.0F);
if (sinValue > 0.0F) {
lookAwayPitch = 1.0F + sinValue * 2.0F;
} else {
lookAwayPitch = -1.0F + sinValue * 1.0F;
}
}
float moveYaw = MathHelper.clamp(yawDelta, -lineYaw, lineYaw);
float movePitch = MathHelper.clamp(pitchDelta, -linePitch, linePitch);
Rotation moveRotation = new Rotation(currentRotation.getYaw(), currentRotation.getPitch());
float targetYawWithLookAway = currentRotation.getYaw() + moveYaw + lookAwayYaw;
float targetPitchWithLookAway = currentRotation.getPitch() + movePitch + lookAwayPitch;
float newYaw = MathHelper.lerp(this.randomLerp(speed, speed + 0.08F), currentRotation.getYaw(), targetYawWithLookAway);
float newPitch = MathHelper.lerp(this.randomLerp(speed, speed + 0.08F), currentRotation.getPitch(), targetPitchWithLookAway);
moveRotation.setYaw(newYaw);
moveRotation.setPitch(newPitch);
return moveRotation;
} else {
int suck = this.attackCount % 3;
float speed = this.attackTimer.isReached(430L) ? (this.random.nextBoolean() ? 0.4F : 0.2F) : -0.2F;
float randomValue = (float)this.attackTimer.getTime() / 40.0F + (float)(this.attackCount % 6);
Rotation randomRotation;
switch (suck) {
case 0 -> randomRotation = new Rotation((float)Math.cos((double)randomValue), (float)Math.sin((double)randomValue));
case 1 -> randomRotation = new Rotation((float)Math.sin((double)randomValue), (float)Math.cos((double)randomValue));
case 2 -> randomRotation = new Rotation((float)Math.sin((double)randomValue), (float)(-Math.cos((double)randomValue)));
default -> randomRotation = new Rotation((float)(-Math.cos((double)randomValue)), (float)Math.sin((double)randomValue));
}
float yaw = !this.attackTimer.isReached(2000L) ? this.randomLerp(12.0F, 24.0F) * randomRotation.getYaw() : 0.0F;
float pitch2 = this.randomLerp(0.0F, 2.0F) * (float)Math.cos((double)System.currentTimeMillis() / (double)5000.0F);
float pitch = !this.attackTimer.isReached(2000L) ? this.randomLerp(2.0F, 6.0F) * randomRotation.getPitch() + pitch2 : 0.0F;
float lineYaw = Math.abs(yawDelta / rotationDifference) * 180.0F;
float linePitch = Math.abs(pitchDelta / rotationDifference) * 180.0F;
float moveYaw = MathHelper.clamp(yawDelta, -lineYaw, lineYaw);
float movePitch = MathHelper.clamp(pitchDelta, -linePitch, linePitch);
Rotation moveRotation = new Rotation(currentRotation.getYaw(), currentRotation.getPitch());
moveRotation.setYaw(MathHelper.lerp(MathHelper.clamp(this.randomLerp(speed, speed + 0.2F), 0.0F, 1.0F), currentRotation.getYaw(), currentRotation.getYaw() + moveYaw) + yaw);
moveRotation.setPitch(MathHelper.lerp(MathHelper.clamp(this.randomLerp(speed, speed + 0.2F), 0.0F, 1.0F), currentRotation.getPitch(), currentRotation.getPitch() + movePitch) + pitch);
return moveRotation;
}
}
private void generateRandomHeadMovement() {
int direction = this.random.nextInt(4);
switch (direction) {
case 0:
this.randomYawOffset = -this.randomLerp(10.0F, 40.0F);
this.randomPitchOffset = this.randomLerp(-5.0F, 5.0F);
break;
case 1:
this.randomYawOffset = this.randomLerp(10.0F, 40.0F);
this.randomPitchOffset = this.randomLerp(-5.0F, 5.0F);
break;
case 2:
this.randomYawOffset = this.randomLerp(-5.0F, 5.0F);
this.randomPitchOffset = -this.randomLerp(10.0F, 40.0F);
break;
case 3:
this.randomYawOffset = this.randomLerp(-5.0F, 5.0F);
this.randomPitchOffset = this.randomLerp(10.0F, 40.0F);
}
}
private Vector3d getRandomAttackPoint(Entity entity) {
Vector3d entityPos = entity.getPositionVec();
double height = (double)entity.getHeight();
double width = (double)entity.getWidth();
int attackPoint = this.random.nextInt(9);
float xOffset = 0.0F;
float zOffset = 0.0F;
float yOffset;
switch (attackPoint) {
case 0:
yOffset = this.randomLerp(0.88F, 0.98F);
xOffset = this.randomLerp(-0.25F, 0.25F) * (float)width;
zOffset = this.randomLerp(-0.25F, 0.25F) * (float)width;
break;
case 1:
yOffset = this.randomLerp(0.75F, 0.88F);
xOffset = this.randomLerp(-0.35F, 0.35F) * (float)width;
zOffset = this.randomLerp(-0.35F, 0.35F) * (float)width;
break;
case 2:
yOffset = this.randomLerp(0.6F, 0.75F);
xOffset = this.randomLerp(-0.3F, 0.3F) * (float)width;
zOffset = this.randomLerp(-0.3F, 0.3F) * (float)width;
break;
case 3:
yOffset = this.randomLerp(0.45F, 0.6F);
xOffset = this.randomLerp(-0.3F, 0.3F) * (float)width;
zOffset = this.randomLerp(-0.3F, 0.3F) * (float)width;
break;
case 4:
yOffset = this.randomLerp(0.35F, 0.45F);
xOffset = this.randomLerp(-0.25F, 0.25F) * (float)width;
zOffset = this.randomLerp(-0.25F, 0.25F) * (float)width;
break;
case 5:
yOffset = this.randomLerp(0.2F, 0.35F);
xOffset = this.randomLerp(-0.2F, 0.2F) * (float)width;
zOffset = this.randomLerp(-0.2F, 0.2F) * (float)width;
break;
case 6:
yOffset = this.randomLerp(0.05F, 0.2F);
xOffset = this.randomLerp(-0.15F, 0.15F) * (float)width;
zOffset = this.randomLerp(-0.15F, 0.15F) * (float)width;
break;
case 7:
yOffset = this.randomLerp(0.4F, 0.8F);
xOffset = this.randomLerp(0.25F, 0.45F) * (float)width;
zOffset = this.randomLerp(-0.2F, 0.2F) * (float)width;
break;
default:
yOffset = this.randomLerp(0.4F, 0.8F);
xOffset = this.randomLerp(-0.45F, -0.25F) * (float)width;
zOffset = this.randomLerp(-0.2F, 0.2F) * (float)width;
}
double targetY = entityPos.y + height * (double)yOffset;
return new Vector3d(entityPos.x + (double)xOffset, targetY, entityPos.z + (double)zOffset);
}
private boolean canAttack() {
Minecraft var10000 = mc;
return Minecraft.player.getCooledAttackStrength(0.5F) >= 0.92F;
}
public Vector3d randomValue() {
return new Vector3d((double)0.0F, (double)0.0F, (double)0.0F);
}
}