Freecam, Xray tweaks

main
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.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/sodium-fabric-mc1.18.2-0.4.1+build.15.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 {
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) {
if (ignoreShouldDrawSide)
return;

View File

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

View File

@ -1,11 +1,27 @@
package codes.som.hibiscus.features.visual
import codes.som.hibiscus.HibiscusLog
import codes.som.hibiscus.api.feature.Feature
import codes.som.hibiscus.api.feature.FeatureCategory
import codes.som.hibiscus.events.WorldCullingEvent
import codes.som.hibiscus.mc
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 {
on { event: WorldCullingEvent -> event.cancel() }
}
@ -20,5 +36,25 @@ class Xray : Feature("X-ray", FeatureCategory.VISUAL) {
override fun createFeatureCommand() = super.createFeatureCommand().apply {
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) {
val currTime = System.currentTimeMillis()
if (lastSecond != -1L) {
tpsMultipliers.add((currTime - lastSecond) / 1000.0)
if (tpsMultipliers.size > 2)
val multiplier = (currTime - lastSecond) / 1000.0
tpsMultipliers.add(multiplier)
if (tpsMultipliers.size > 8)
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.features.visual.Xray
import net.minecraft.block.BlockState
import net.minecraft.block.FluidBlock
import net.minecraft.block.IceBlock
import net.minecraft.block.OreBlock
import net.minecraft.util.registry.Registry
import kotlin.streams.asSequence
object XraySystem {
@JvmStatic
@ -20,9 +19,19 @@ object XraySystem {
@JvmStatic
fun isXrayBlock(blockState: BlockState): Boolean {
return when (blockState.block) {
is OreBlock, is FluidBlock, is IceBlock -> true
else -> false
try {
val blockId = Registry.BLOCK.getId(blockState.block).toString()
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 isDrawingUI: Boolean = false
var isProcessingInput: Boolean = false
var isDrawingDebugHud: Boolean = false
}

View File

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