Merge branch 'refs/heads/main' into jess-refactor
This commit is contained in:
commit
81f747ce40
1 changed files with 30 additions and 1 deletions
|
@ -10,6 +10,8 @@ import de.tudbut.parsing.TCN;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -74,7 +76,20 @@ public class AutoKill extends Feature {
|
|||
|
||||
@Override
|
||||
public void onTick() {
|
||||
ArrayList<?> attackable = getAttackable();
|
||||
Vec3d eyePos = mc.player.getPositionEyes(1f);
|
||||
ArrayList<EntityLivingBase> attackable = getAttackable();
|
||||
for (int i = 0; i < attackable.size(); i++) {
|
||||
EntityLivingBase elb = attackable.get(i);
|
||||
AxisAlignedBB boundingBox = elb.getEntityBoundingBox();
|
||||
double dminsq = getDminsq(boundingBox, eyePos);
|
||||
if (dminsq > 3 * 3) {
|
||||
attackable.remove(i--);
|
||||
}
|
||||
}
|
||||
if(attackable.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,6 +102,20 @@ public class AutoKill extends Feature {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static double getDminsq(AxisAlignedBB boundingBox, Vec3d eyePos) {
|
||||
double dmx = Double.MAX_VALUE;
|
||||
dmx = Math.min(Math.abs(boundingBox.maxX - eyePos.x), dmx);
|
||||
dmx = Math.min(Math.abs(boundingBox.minX - eyePos.x), dmx);
|
||||
double dmy = Double.MAX_VALUE;
|
||||
dmy = Math.min(Math.abs(boundingBox.maxY - eyePos.y), dmy);
|
||||
dmy = Math.min(Math.abs(boundingBox.minY - eyePos.y), dmy);
|
||||
double dmz = Double.MAX_VALUE;
|
||||
dmz = Math.min(Math.abs(boundingBox.maxZ - eyePos.z), dmz);
|
||||
dmz = Math.min(Math.abs(boundingBox.minZ - eyePos.z), dmz);
|
||||
return dmx * dmx + dmy * dmy + dmz * dmz;
|
||||
}
|
||||
|
||||
@Combat
|
||||
public class AutoCrystal extends Feature {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue