149 lines
5.6 KiB
Java
149 lines
5.6 KiB
Java
package baritone.api.utils;
|
|
|
|
import baritone.api.utils.BetterBlockPos;
|
|
import baritone.pathing.BaritoneCore;
|
|
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.monster.EntityEnderman;
|
|
import net.minecraft.entity.monster.EntityMob;
|
|
import net.minecraft.entity.monster.EntityPigZombie;
|
|
import net.minecraft.entity.monster.EntitySpider;
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
public final class BaritoneHelperHandler {
|
|
|
|
private transient int count;
|
|
private transient int count2;
|
|
private transient int count3;
|
|
private transient int count4;
|
|
private transient double coordVal;
|
|
private transient int count5;
|
|
|
|
private static final boolean canAcceptEntity(Entity entity2) {
|
|
return !(entity2 instanceof EntityEnderman) || ((EntityEnderman)entity2).isScreaming();
|
|
}
|
|
|
|
|
|
|
|
public static final List resolveList(IPlayerContext playerContext) {
|
|
|
|
|
|
|
|
if (!BaritoneCore.getBaritoneSettings().avoidance.value) {
|
|
return Collections.emptyList();
|
|
}
|
|
|
|
ArrayList list = new ArrayList();
|
|
double value = BaritoneCore.getBaritoneSettings().mobSpawnerAvoidanceCoefficient.value;
|
|
double value2 = BaritoneCore.getBaritoneSettings().mobAvoidanceCoefficient.value;
|
|
double amountD;
|
|
int value3 = (amountD = value - (1.0)) == 0.0 ? 0 : (amountD < 0.0 ? -1 : 1);
|
|
if (((value3)) != 0) {
|
|
playerContext.getCachedWorldData()
|
|
.getCacheBaritoneComponent022()
|
|
.resolveArrayList("mob_spawner", 1, playerContext.playerFeet().blockX, playerContext.playerFeet().blockZ, 2)
|
|
.forEach((BlockPos pos3) -> BaritoneHelperHandler.handleList2(list, value, pos3));
|
|
}
|
|
|
|
double amountD2;
|
|
value3 = (amountD2 = value2 - (1.0)) == 0.0 ? 0 : (amountD2 < 0.0 ? -1 : 1);
|
|
|
|
if (((value3)) != 0) {
|
|
playerContext.world()
|
|
.loadedEntityList
|
|
.stream()
|
|
.filter(BaritoneHelperHandler::canAcceptEntity2)
|
|
.filter((Entity entity7) -> BaritoneHelperHandler.canAcceptPlayerContext(playerContext, entity7))
|
|
.filter((java.util.function.Predicate<net.minecraft.entity.Entity>) BaritoneHelperHandler::canAcceptEntity3)
|
|
.filter((java.util.function.Predicate<net.minecraft.entity.Entity>) BaritoneHelperHandler::canAcceptEntity)
|
|
.forEach((Entity entity8) -> BaritoneHelperHandler.handleList(list, value2, entity8));
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
private static final void handleList(List list, double amountD, Entity entity3) {
|
|
list.add(new BaritoneHelperHandler(new BlockPos(entity3), amountD, BaritoneCore.getBaritoneSettings().mobAvoidanceRadius.value));
|
|
}
|
|
|
|
// $VF: Irreducible bytecode was duplicated to produce valid code
|
|
public void updateLong2DoubleOpenHashMap(Long2DoubleOpenHashMap long2DoubleOpenHashMap) {
|
|
|
|
int value = -this.count3;
|
|
if ((value <= this.count3)) {
|
|
label68:
|
|
do {
|
|
int value2 = -this.count3;
|
|
if ((value2 <= this.count3)) {
|
|
while (true) {
|
|
int value3 = -this.count3;
|
|
|
|
|
|
while (true) {
|
|
while (value3 <= this.count3) {
|
|
int value4 = value * value + value2 * value2 + value3 * value3;
|
|
int value5 = this.count3 * this.count3;
|
|
if (value4 <= value5) {
|
|
long timestampMs = BetterBlockPos.longHash(this.count2 + value, this.count5 + value2, this.count + value3);
|
|
long2DoubleOpenHashMap.put(timestampMs, long2DoubleOpenHashMap.get(timestampMs) * this.coordVal);
|
|
value3++;
|
|
} else {
|
|
value3++;
|
|
}
|
|
}
|
|
|
|
if (++value2 > this.count3) {
|
|
continue label68;
|
|
}
|
|
break;
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
} while (++value <= this.count3);
|
|
}
|
|
}
|
|
|
|
private static final boolean canAcceptPlayerContext(IPlayerContext playerContext, Entity entity4) {
|
|
return !(entity4 instanceof EntitySpider) || playerContext.player().getBrightness(0.0F) < 0.5;
|
|
}
|
|
|
|
|
|
|
|
public BaritoneHelperHandler(int count2, int count5, int count, double coordVal, int count3) {
|
|
this.count2 = count2;
|
|
this.count5 = count5;
|
|
this.count = count;
|
|
this.coordVal = coordVal;
|
|
this.count3 = count3;
|
|
this.count4 = count3 * count3;
|
|
}
|
|
|
|
private static final boolean canAcceptEntity2(Entity entity5) {
|
|
return entity5 instanceof EntityMob;
|
|
}
|
|
|
|
public double resolveDistance(int posX, int posY, int posZ) {
|
|
int value = posX - this.count2;
|
|
int value2 = posY - this.count5;
|
|
int value3 = posZ - this.count;
|
|
return value * value + value2 * value2 + value3 * value3 <= this.count4 ? this.coordVal : 1.0;
|
|
}
|
|
|
|
private static final boolean canAcceptEntity3(Entity entity6) {
|
|
return !(entity6 instanceof EntityPigZombie) || ((EntityPigZombie)entity6).isAngry();
|
|
}
|
|
|
|
public BaritoneHelperHandler(BlockPos pos, double amountD, int value) {
|
|
this(pos.getX(), pos.getY(), pos.getZ(), amountD, value);
|
|
}
|
|
|
|
private static final void handleList2(List list2, double amountD, BlockPos pos2) {
|
|
list2.add(new BaritoneHelperHandler(pos2, amountD, BaritoneCore.getBaritoneSettings().mobSpawnerAvoidanceRadius.value));
|
|
}
|
|
}
|