Freecam, Xray tweaks

This commit is contained in:
Charlotte Som 2022-03-09 00:16:10 +00:00
parent 4d5a7c8b80
commit 7de33468b2
9 changed files with 86 additions and 12 deletions

View file

@ -62,7 +62,7 @@ dependencies {
runtimeOnly("org.joml:joml:1.10.4") runtimeOnly("org.joml:joml:1.10.4")
runtimeOnly("org.anarres:jcpp:1.4.14") runtimeOnly("org.anarres:jcpp:1.4.14")
modImplementation(files("vendor/mods/baritone-unoptimized-fabric-1.8.2.jar")) // modRuntimeOnly(files("vendor/mods/baritone-unoptimized-fabric-1.8.2.jar"))
modImplementation(files("vendor/mods/iris-mc1.18.2-1.2.1-rc2-0cc372f0.jar")) modImplementation(files("vendor/mods/iris-mc1.18.2-1.2.1-rc2-0cc372f0.jar"))
modImplementation(files("vendor/mods/sodium-fabric-mc1.18.2-0.4.1+build.15.jar")) modImplementation(files("vendor/mods/sodium-fabric-mc1.18.2-0.4.1+build.15.jar"))
modRuntimeOnly(files("vendor/mods/lazydfu-0.1.2.jar")) modRuntimeOnly(files("vendor/mods/lazydfu-0.1.2.jar"))

View file

@ -0,0 +1,22 @@
package codes.som.hibiscus.mixins;
import codes.som.hibiscus.util.graphics.MinecraftRenderPipelineProgress;
import net.minecraft.client.gui.hud.DebugHud;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(DebugHud.class)
public abstract class MixinDebugHud {
@Inject(method = "render", at = @At("HEAD"))
private void onStartRender(MatrixStack matrices, CallbackInfo ci) {
MinecraftRenderPipelineProgress.INSTANCE.setDrawingDebugHud(true);
}
@Inject(method = "render", at = @At("RETURN"))
private void onFinishRender(MatrixStack matrices, CallbackInfo ci) {
MinecraftRenderPipelineProgress.INSTANCE.setDrawingDebugHud(false);
}
}

View file

@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
public abstract class MixinBlock { public abstract class MixinBlock {
private static boolean ignoreShouldDrawSide = false; private static boolean ignoreShouldDrawSide = false;
@Inject(method = "shouldDrawSide", at = @At("RETURN"), cancellable = true) @Inject(method = "shouldDrawSide", at = @At("HEAD"), cancellable = true)
private static void onShouldRenderFace(BlockState state, BlockView world, BlockPos pos, Direction side, BlockPos blockPos, CallbackInfoReturnable<Boolean> cir) { private static void onShouldRenderFace(BlockState state, BlockView world, BlockPos pos, Direction side, BlockPos blockPos, CallbackInfoReturnable<Boolean> cir) {
if (ignoreShouldDrawSide) if (ignoreShouldDrawSide)
return; return;

View file

@ -47,9 +47,13 @@ class Freecam : Feature("Freecam", FeatureCategory.VISUAL) {
if (isPlayerTicking) if (isPlayerTicking)
return@on return@on
if (MinecraftRenderPipelineProgress.isRenderingEntities || MinecraftRenderPipelineProgress.isDrawingUI) if (MinecraftRenderPipelineProgress.isRenderingEntities)
return@on return@on
if (MinecraftRenderPipelineProgress.isDrawingUI)
if (!MinecraftRenderPipelineProgress.isDrawingDebugHud || isControllingPlayer)
return@on
if (isControllingPlayer && MinecraftRenderPipelineProgress.isProcessingInput) if (isControllingPlayer && MinecraftRenderPipelineProgress.isProcessingInput)
return@on return@on

View file

@ -1,11 +1,27 @@
package codes.som.hibiscus.features.visual package codes.som.hibiscus.features.visual
import codes.som.hibiscus.HibiscusLog
import codes.som.hibiscus.api.feature.Feature import codes.som.hibiscus.api.feature.Feature
import codes.som.hibiscus.api.feature.FeatureCategory import codes.som.hibiscus.api.feature.FeatureCategory
import codes.som.hibiscus.events.WorldCullingEvent import codes.som.hibiscus.events.WorldCullingEvent
import codes.som.hibiscus.mc import codes.som.hibiscus.mc
class Xray : Feature("X-ray", FeatureCategory.VISUAL) { class Xray : Feature("X-ray", FeatureCategory.VISUAL) {
val xrayBlocks = mutableSetOf(
"#minecraft:diamond_ores",
"#minecraft:iron_ores",
"#minecraft:portals",
"minecraft:obsidian",
"minecraft:furnace",
"minecraft:blast_furnace",
"minecraft:smoker",
"minecraft:dropper",
"minecraft:hopper",
"minecraft:barrel",
"minecraft:dispenser",
"minecraft:brewing_stand",
)
init { init {
on { event: WorldCullingEvent -> event.cancel() } on { event: WorldCullingEvent -> event.cancel() }
} }
@ -20,5 +36,25 @@ class Xray : Feature("X-ray", FeatureCategory.VISUAL) {
override fun createFeatureCommand() = super.createFeatureCommand().apply { override fun createFeatureCommand() = super.createFeatureCommand().apply {
alias("xray") alias("xray")
// TODO: Database stuff
branch("add") { blockOrTag: String ->
xrayBlocks.add(blockOrTag)
}
branch("del") { blockOrTag: String ->
xrayBlocks.remove(blockOrTag)
}
branch("list") {
HibiscusLog.info(buildString {
append("X-Ray Blocks: ${xrayBlocks.size}")
for (block in xrayBlocks) {
append("\n - ")
append(block)
}
})
}
} }
} }

View file

@ -26,11 +26,12 @@ object TPSDetectionSubsystem {
if (event.packet is WorldTimeUpdateS2CPacket) { if (event.packet is WorldTimeUpdateS2CPacket) {
val currTime = System.currentTimeMillis() val currTime = System.currentTimeMillis()
if (lastSecond != -1L) { if (lastSecond != -1L) {
tpsMultipliers.add((currTime - lastSecond) / 1000.0) val multiplier = (currTime - lastSecond) / 1000.0
if (tpsMultipliers.size > 2) tpsMultipliers.add(multiplier)
if (tpsMultipliers.size > 8)
tpsMultipliers.removeAt(0) tpsMultipliers.removeAt(0)
lastSecond = currTime
} }
lastSecond = currTime
} }
} }
} }

View file

@ -3,9 +3,8 @@ package codes.som.hibiscus.subsystems.xray
import codes.som.hibiscus.Hibiscus import codes.som.hibiscus.Hibiscus
import codes.som.hibiscus.features.visual.Xray import codes.som.hibiscus.features.visual.Xray
import net.minecraft.block.BlockState import net.minecraft.block.BlockState
import net.minecraft.block.FluidBlock import net.minecraft.util.registry.Registry
import net.minecraft.block.IceBlock import kotlin.streams.asSequence
import net.minecraft.block.OreBlock
object XraySystem { object XraySystem {
@JvmStatic @JvmStatic
@ -20,9 +19,19 @@ object XraySystem {
@JvmStatic @JvmStatic
fun isXrayBlock(blockState: BlockState): Boolean { fun isXrayBlock(blockState: BlockState): Boolean {
return when (blockState.block) { try {
is OreBlock, is FluidBlock, is IceBlock -> true val blockId = Registry.BLOCK.getId(blockState.block).toString()
else -> false val tags = blockState.streamTags().asSequence().map { "#" + it.id.toString() }
val checkedStrings = (sequenceOf(blockId) + tags).toSet()
return Hibiscus.features
.getFeature<Xray>()
.xrayBlocks
.any(checkedStrings::contains)
} catch (_: Exception) {
} }
return false
} }
} }

View file

@ -4,4 +4,5 @@ object MinecraftRenderPipelineProgress {
var isRenderingEntities: Boolean = false var isRenderingEntities: Boolean = false
var isDrawingUI: Boolean = false var isDrawingUI: Boolean = false
var isProcessingInput: Boolean = false var isProcessingInput: Boolean = false
var isDrawingDebugHud: Boolean = false
} }

View file

@ -10,6 +10,7 @@
"MixinClientConnection", "MixinClientConnection",
"MixinClientPlayerEntity", "MixinClientPlayerEntity",
"MixinClientPlayNetworkHandler", "MixinClientPlayNetworkHandler",
"MixinDebugHud",
"MixinExtClientPlayerEntity", "MixinExtClientPlayerEntity",
"MixinExtEntity", "MixinExtEntity",
"MixinExtMinecraftClient", "MixinExtMinecraftClient",