use of baritone.api.utils.IPlayerContext in project baritone by cabaletta.
the class Avoidance method create.
public static List<Avoidance> create(IPlayerContext ctx) {
if (!Baritone.settings().avoidance.value) {
return Collections.emptyList();
}
List<Avoidance> res = new ArrayList<>();
double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.value;
double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.value;
if (mobSpawnerCoeff != 1.0D) {
ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerFeet().x, ctx.playerFeet().z, 2).forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.value)));
}
if (mobCoeff != 1.0D) {
ctx.world().loadedEntityList.stream().filter(entity -> entity instanceof EntityMob).filter(entity -> (!(entity instanceof EntitySpider)) || ctx.player().getBrightness() < 0.5).filter(entity -> !(entity instanceof EntityPigZombie) || ((EntityPigZombie) entity).isAngry()).filter(entity -> !(entity instanceof EntityEnderman) || ((EntityEnderman) entity).isScreaming()).forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
}
return res;
}
use of baritone.api.utils.IPlayerContext in project baritone by cabaletta.
the class MixinRenderChunk method isEmpty.
@Redirect(method = "rebuildChunk", at = @At(value = "INVOKE", target = "net/minecraft/world/ChunkCache.isEmpty()Z"))
private boolean isEmpty(ChunkCache chunkCache) {
if (!chunkCache.isEmpty()) {
return false;
}
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
IPlayerContext ctx = baritone.getPlayerContext();
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
BlockPos position = ((RenderChunk) (Object) this).getPosition();
// so if ANY of the adjacent chunks are loaded, we are unempty
for (int dx = -1; dx <= 1; dx++) {
for (int dz = -1; dz <= 1; dz++) {
if (baritone.bsi.isLoaded(16 * dx + position.getX(), 16 * dz + position.getZ())) {
return false;
}
}
}
}
}
return true;
}
use of baritone.api.utils.IPlayerContext in project baritone by cabaletta.
the class MixinChunkRenderWorker method isChunkExisting.
@Redirect(method = "processTask", at = @At(value = "INVOKE", target = "net/minecraft/client/renderer/chunk/ChunkRenderWorker.isChunkExisting(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/World;)Z"))
private boolean isChunkExisting(ChunkRenderWorker worker, BlockPos pos, World world) {
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
IPlayerContext ctx = baritone.getPlayerContext();
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
return baritone.bsi.isLoaded(pos.getX(), pos.getZ()) || this.isChunkExisting(pos, world);
}
}
return this.isChunkExisting(pos, world);
}
use of baritone.api.utils.IPlayerContext in project Spark-Client by Spark-Client-Development.
the class MixinRenderChunk method getBlockState.
@Redirect(method = "rebuildChunk", at = @At(value = "INVOKE", target = "net/minecraft/world/ChunkCache.getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/IBlockState;"))
private IBlockState getBlockState(ChunkCache chunkCache, BlockPos pos) {
if (Baritone.settings().renderCachedChunks.getValue() && !Minecraft.getMinecraft().isSingleplayer()) {
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
IPlayerContext ctx = baritone.getPlayerContext();
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
return baritone.bsi.get0(pos);
}
}
return chunkCache.getBlockState(pos);
}
use of baritone.api.utils.IPlayerContext in project baritone by cabaletta.
the class MixinRenderChunk method getBlockState.
@Redirect(method = "rebuildChunk", at = @At(value = "INVOKE", target = "net/minecraft/world/ChunkCache.getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/IBlockState;"))
private IBlockState getBlockState(ChunkCache chunkCache, BlockPos pos) {
if (Baritone.settings().renderCachedChunks.value && !Minecraft.getMinecraft().isSingleplayer()) {
Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone();
IPlayerContext ctx = baritone.getPlayerContext();
if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) {
return baritone.bsi.get0(pos);
}
}
return chunkCache.getBlockState(pos);
}
Aggregations