-
Notifications
You must be signed in to change notification settings - Fork 58
Etherwarp Zoom #2248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mc-1.21.10
Are you sure you want to change the base?
Etherwarp Zoom #2248
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package moe.nea.firmament.mixins; | ||
|
|
||
| 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.CallbackInfoReturnable; | ||
| import net.minecraft.client.renderer.GameRenderer; | ||
| import net.minecraft.client.Camera; | ||
|
|
||
| @Mixin(GameRenderer.class) | ||
| public abstract class GameRendererFovPatch { | ||
| @Inject( | ||
| method = "getFov(Lnet/minecraft/client/Camera;FZ)F", | ||
| at = @At("RETURN"), | ||
| cancellable = true | ||
| ) | ||
| private void onGetFov(Camera camera, float tickDelta, boolean changingFov, CallbackInfoReturnable<Float> cir) { | ||
| try { | ||
| float base = cir.getReturnValueF(); | ||
| float mult = moe.nea.firmament.features.items.EtherwarpOverlay.getFovMultiplier(tickDelta); | ||
| cir.setReturnValue(base * mult); | ||
| } catch (Throwable t) { | ||
| } | ||
|
Comment on lines
+22
to
+23
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. while not crashing the client is good, |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,8 @@ object EtherwarpOverlay { | |
| val tooFarCubeColour by colour("cube-colour-toofar") { ChromaColour.fromStaticRGB(255, 255, 0, 60) } | ||
| var wireframe by toggle("wireframe") { false } | ||
| var failureText by toggle("failure-text") { false } | ||
| var smoothZoom by toggle("smooth-zoom") { false } | ||
| val zoomSmoothness by integer("zoom-smoothness", 1, 100) { 50 } | ||
| } | ||
|
|
||
| enum class EtherwarpResult(val label: Component?, val color: () -> ChromaColour) { | ||
|
|
@@ -152,15 +154,6 @@ object EtherwarpOverlay { | |
| if (isEtherwarpTransparent(world, blockPos)) { | ||
| return@traverseBlocks null | ||
| } | ||
| // val defaultedState = world.getBlockState(blockPos).block.defaultState | ||
| // val hitShape = defaultedState.getCollisionShape( | ||
| // world, | ||
| // blockPos, | ||
| // ShapeContext.absent() | ||
| // ) | ||
| // if (world.raycastBlock(start, end, blockPos, hitShape, defaultedState) == null) { | ||
| // return@raycast null | ||
| // } | ||
| val partialResult = world.clipWithInteractionOverride(start, end, blockPos, Shapes.block(), world.getBlockState(blockPos).block.defaultBlockState()) | ||
| return@traverseBlocks EtherwarpBlockHit.BlockHit(blockPos, partialResult?.location) | ||
| }, | ||
|
|
@@ -172,22 +165,54 @@ object EtherwarpOverlay { | |
| RAW | ||
| } | ||
|
|
||
| // Smooth FOV state | ||
| private var currentFovMult = 1.0f | ||
| private var targetFovMult: Float = 1.0f | ||
| private var lastPartialTicks = 0f | ||
|
|
||
| @JvmStatic | ||
| fun getFovMultiplier(partialTicks: Float): Float { | ||
| if (!TConfig.smoothZoom) { | ||
| currentFovMult = 1.0f | ||
| targetFovMult = 1.0f | ||
| lastPartialTicks = partialTicks + MC.currentTick | ||
| return 1.0f | ||
| } | ||
|
|
||
| val partialDelta = (partialTicks + MC.currentTick) - lastPartialTicks | ||
| val pd = if (partialDelta <= 0f) 0.0f else partialDelta | ||
| lastPartialTicks = partialTicks + MC.currentTick | ||
|
|
||
| val smooth = (TConfig.zoomSmoothness / 100f) | ||
|
|
||
| val delta = targetFovMult - currentFovMult | ||
| currentFovMult += delta * pd * smooth | ||
| if (currentFovMult < 0.15f) currentFovMult = 0.15f | ||
| if (currentFovMult > 1f) currentFovMult = 1f | ||
| return currentFovMult | ||
| } | ||
|
|
||
| @Subscribe | ||
| fun renderEtherwarpOverlay(event: WorldRenderLastEvent) { | ||
| if (!TConfig.etherwarpOverlay) return | ||
| val player = MC.player ?: return | ||
| if (TConfig.onlyShowWhileSneaking && !player.isShiftKeyDown) return | ||
| if (TConfig.onlyShowWhileSneaking && !player.isShiftKeyDown) { | ||
| targetFovMult = 1.0f | ||
| return | ||
| } | ||
| val world = player.level | ||
| val heldItem = MC.stackInHand | ||
| val etherwarpTyp = run { | ||
| if (heldItem.extraAttributes.contains("ethermerge")) | ||
| EtherwarpItemKind.MERGED | ||
| else if (heldItem.skyBlockId == SkyBlockItems.ETHERWARP_CONDUIT) | ||
| EtherwarpItemKind.RAW | ||
| else | ||
| else { | ||
| targetFovMult = 1.0f | ||
| return | ||
| } | ||
| } | ||
| val playerEyeHeight = // Sneaking: 1.27 (1.21) 1.54 (1.8.9) / Upright: 1.62 (1.8.9,1.21) | ||
| val playerEyeHeight = // Sneaking: 1.27 (1.21) 1.54 (1.8.9) / Upright: 1.62 | ||
| if (player.isShiftKeyDown || etherwarpTyp == EtherwarpItemKind.MERGED) | ||
| (if (SBData.skyblockLocation?.isModernServer ?: false) 1.27 else 1.54) | ||
| else 1.62 | ||
|
|
@@ -199,7 +224,10 @@ object EtherwarpOverlay { | |
| start, | ||
| end, | ||
| ) | ||
| if (hitResult !is EtherwarpBlockHit.BlockHit) return | ||
| if (hitResult !is EtherwarpBlockHit.BlockHit) { | ||
| targetFovMult = 1.0f | ||
| return | ||
| } | ||
| val blockPos = hitResult.blockPos | ||
| val success = run { | ||
| if (!isEtherwarpTransparent(world, blockPos.above())) | ||
|
|
@@ -217,6 +245,7 @@ object EtherwarpOverlay { | |
| else | ||
| EtherwarpResult.SUCCESS | ||
| } | ||
|
|
||
| RenderInWorldContext.renderInWorld(event) { | ||
| if (TConfig.cube) | ||
| block( | ||
|
|
@@ -230,5 +259,16 @@ object EtherwarpOverlay { | |
| } | ||
| } | ||
| } | ||
|
|
||
| if (success == EtherwarpResult.SUCCESS) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i feel like we should probably zoom in on occupied results as well? those might require fine tuning for which the smooth zoom might help |
||
| val hitCenter = hitResult.accuratePos ?: blockPos.center | ||
| val dist = playerEyePos.distanceTo(hitCenter) | ||
| val distFactor = 1 - (kotlin.math.sqrt(dist * dist) / 60.0) | ||
| var newTarget = (distFactor * distFactor * distFactor * 0.75).toFloat() + 0.25f | ||
| if (newTarget < 0.25f) newTarget = 0.25f | ||
| targetFovMult = newTarget | ||
| } else { | ||
| targetFovMult = 1.0f | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,6 +139,10 @@ | |
| "firmament.config.etherwarp-overlay.only-show-while-sneaking.description": "仅在潜行时显示Etherwarp覆盖层。", | ||
| "firmament.config.etherwarp-overlay.wireframe": "空心方框", | ||
| "firmament.config.etherwarp-overlay.wireframe.description": "在指向方块上显示的轮廓", | ||
| "firmament.config.etherwarp-overlay.smooth-zoom": "平滑缩放", | ||
| "firmament.config.etherwarp-overlay.smooth-zoom.description": "当 Etherwarp 指向一个方块时启用 FOV 的平滑插值", | ||
| "firmament.config.etherwarp-overlay.zoom-smoothness": "缩放平滑度", | ||
| "firmament.config.etherwarp-overlay.zoom-smoothness.description": "FOV 插值到目标的速度(更高 = 更迅速,更低 = 更缓慢)", | ||
|
Comment on lines
+142
to
+145
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for those translations. were those done by hand or machine assisted? generally adding other translations is not required, and i would prefer them to be done by someone with some amount of familiarity with chinese, and specifically gaming in chinese, since machine translations are always a bit weird when it comes to in-game languages. either way 谢谢。 |
||
| "firmament.config.fairy-souls": "仙女之魂", | ||
| "firmament.config.fairy-souls.reset": "重置已收集仙女之魂", | ||
| "firmament.config.fairy-souls.reset.description": "重置所有已收集的仙女之魂,允许你从头开始。", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, id prefer if we use
@ModifyReturnValueinstead of.setReturnValue, to allow better compatible with other modules also injecting in this method.