Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Snapshots are [here](https://github.com/xTracr/RealCamera/actions/workflows/buil
#### Tips

* Configs can have their priority adjusted - higher priority configs appear higher in the right-side list
* In the mod settings, you can manually switch between available configurations by modifying the configuration index. You can also set it to a non-zero value to lock the active configuration
* In the mod settings, you can manually switch between available configurations by modifying the configuration selector
* When the main feature is enabled, hover over the configuration entries. The one annotated with `Current Config` is the configuration currently in use
* Disable depth in `Preview` section to hide models blocking the view
* About `Disable` section:
Expand Down Expand Up @@ -62,13 +62,13 @@ Snapshots are [here](https://github.com/xTracr/RealCamera/actions/workflows/buil
![disable_depth](https://github.com/xTracr/RealCamera/assets/57320980/78c246e8-34aa-4979-89de-780ee907870b)
* What key to press can open Model View Screen?
* Set the key binding by yourself
* Why can't i open the Config Screen?
* Please downlowd [Cloth Config API](https://modrinth.com/mod/cloth-config)
* Why can't I open the Config Screen?
* Please download [Cloth Config API](https://modrinth.com/mod/cloth-config)
* Why does it show binding failed when use YSM models?
* Snapshot 0.6.15 "try" to fix problems, but it didn't fully fix completely
* When your model rotates to a specific angle, the position you bound may disappear due to YSM's `face culling feature`, resulting in binding failure
* You can alleviate this problem by increasing the `Bind Result Retention Frames`
* Why does the disabled texture appear when i downloaded Better Combat and attack?
* Why does the disabled texture appear when I downloaded Better Combat and attack?
* Open settings of Better Combat and change Auto to False in First person player animation

### Compatibility
Expand Down
6 changes: 3 additions & 3 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
#### Tips

* 可以更改配置的优先级,优先级越高的配置,在右侧排序越靠上
* 在模组设置中,你可以通过修改配置索引来主动切换允许的配置,也可以调整到非0的数来锁定配置
* 在模组设置中,你可以通过修改配置选择器来主动切换允许的配置
* 当开启主功能时,将鼠标放到配置上方,其中有注释`当前配置`的即为此时使用的配置
* 在`预览`界面可以更改禁用深度来禁用眼前的模型的渲染
* 关于`禁用`界面:
* 在左侧材质id输入框为空时,使用「Alt+左键」选择材质
* 选择模式:
* 单选、多选:按下「Alt+左键」以选择需要禁用的面
* 范围:按下「Alt+左键」以确定被选择区域,使用「Alt+滚轮」以更改被选择区域的大小
* 单选、多选:按下「Alt+左键」以选择需要禁用的面
* 范围:按下「Alt+左键」以确定被选择区域,使用「Alt+滚轮」以更改被选择区域的大小
* 在玩家渲染左侧材质视图中:
* 按下「鼠标左键」开始/结束框选,其它键取消选择
* 被框选中的面效果与多选禁用的面效果相同
Expand Down
5 changes: 4 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ allprojects {
repositories {
mavenCentral()
maven("https://maven.shedaniel.me/")
maven("https://maven.terraformersmc.com/releases/")
maven("https://maven.terraformersmc.com")
maven("https://maven.fabricmc.net/")
maven("https://maven.neoforged.net/releases/")
//maven("https://api.modrinth.com/maven")
// maven("https://cursemaven.com")
// maven("https://www.jitpack.io"
}
}
7 changes: 4 additions & 3 deletions common/src/main/java/com/xtracr/realcamera/KeyMappings.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.blaze3d.platform.InputConstants;
import com.xtracr.realcamera.config.ConfigFile;
import com.xtracr.realcamera.config.ModConfig.SelectorAction;
import com.xtracr.realcamera.gui.ModelViewScreen;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -32,9 +33,9 @@ public final class KeyMappings {
createKeyMapping("adjustRIGHT", _ -> ConfigFile.config().adjustOffsetZ(-1));
createKeyMapping("adjustFRONT", _ -> ConfigFile.config().adjustOffsetX(1));
createKeyMapping("adjustBACK", _ -> ConfigFile.config().adjustOffsetX(-1));
createKeyMapping("activeConfigIndexNEXT", _ -> ConfigFile.config().binding.activeConfigIndex += 1);
createKeyMapping("activeConfigIndexPREV", _ -> ConfigFile.config().binding.activeConfigIndex -= 1);
createKeyMapping("activeConfigIndexRESET", _ -> ConfigFile.config().binding.activeConfigIndex = 0);
createKeyMapping("adjustActiveConfigNEXT", _ -> ConfigFile.config().adjustActiveConfig(SelectorAction.NEXT));
createKeyMapping("adjustActiveConfigPREV", _ -> ConfigFile.config().adjustActiveConfig(SelectorAction.PREV));
createKeyMapping("adjustActiveConfigRESET", _ -> ConfigFile.config().adjustActiveConfig(SelectorAction.RESET));
}

private static KeyMapping createKeyMapping(String id, Consumer<Minecraft> whenPressed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public static void computeCamera(Minecraft client, float partialTicks) {
dispatcher.submit(dispatcher.extractEntity(entity, partialTicks), new CameraRenderState(), 0, 0, 0, new PoseStack(), vertexCatcher.initCollector());
vertexCatcher.forEachBuffer(RealCameraCore::computeBindResult);
}
} catch (Exception e) {
failureFrames++;
if (failureFrames < 60) {
return;
}
throw e;
} finally {
entity.setInvisible(invisible);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void initialize(PlatformHelper platformHelper) {
Method EMF_registerPauseCondition = EMF_EMFAnimationApi.getMethod("registerPauseCondition", Function.class);
EMF_registerPauseCondition.invoke(null, function);
} else {
throw new IllegalStateException("EntityModelFeatures API is outdated, players‘s heads in the modelView may flicker");
throw new IllegalStateException("EntityModelFeatures API is outdated, players in the modelView may flicker");
}
} catch (Exception e) {
RealCamera.LOGGER.warn("Compatibility with EntityModelFeatures is outdated: [{}] {}", e.getClass().getName(), e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,23 +171,22 @@ public static Screen create(Screen parent) {
.setTooltip(LocUtil.CONFIG_TOOLTIP("bindResultRetentionFrames"))
.setSaveConsumer(i -> config.binding.bindResultRetentionFrames = i)
.build());
binding.addEntry(entryBuilder.startIntField(LocUtil.CONFIG_OPTION("activeConfigIndex"), config.binding.activeConfigIndex)
.setDefaultValue(0)
.setMin(0)
.setTooltip(LocUtil.CONFIG_TOOLTIP("activeConfigIndex"))
.setSaveConsumer(i -> config.binding.activeConfigIndex = i)
binding.addEntry(entryBuilder.startStrField(LocUtil.CONFIG_OPTION("activeConfigSelector"), config.binding.activeConfigSelector)
.setDefaultValue("0")
.setTooltip(LocUtil.CONFIG_TOOLTIP("activeConfigSelector"))
.setSaveConsumer(s -> config.binding.activeConfigSelector = s)
.build());
binding.addEntry(entryBuilder.startDoubleField(LocUtil.CONFIG_OPTION("displacementSmoothFactor"), config.binding.displacementSmoothFactor)
.setDefaultValue(0.4)
.setMin(0.0)
.setMax(1.0)
.setMax(0.9)
.setTooltip(LocUtil.CONFIG_TOOLTIP("displacementSmoothFactor"))
.setSaveConsumer(d -> config.binding.displacementSmoothFactor = d)
.build());
binding.addEntry(entryBuilder.startDoubleField(LocUtil.CONFIG_OPTION("rotationSmoothFactor"), config.binding.rotationSmoothFactor)
.setDefaultValue(0.4)
.setMin(0.0)
.setMax(1.0)
.setMax(0.9)
.setTooltip(LocUtil.CONFIG_TOOLTIP("rotationSmoothFactor"))
.setSaveConsumer(d -> config.binding.rotationSmoothFactor = d)
.build());
Expand Down
58 changes: 51 additions & 7 deletions common/src/main/java/com/xtracr/realcamera/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,52 @@ public float getClassicYaw() {
public float getClassicRoll() {
return classic.roll;
}

public void adjustActiveConfig(SelectorAction selector) {
if (selector == SelectorAction.RESET){
binding.activeConfigSelector = "0";
return;
}
if (isParsableInt(binding.activeConfigSelector)) {
int activeConfigIndex = Integer.parseInt(binding.activeConfigSelector);
switch (selector) {
case NEXT -> binding.activeConfigSelector = String.valueOf(activeConfigIndex + 1);
case PREV -> binding.activeConfigSelector = String.valueOf(activeConfigIndex - 1);
}
} else {
List<BindTarget> matchedTargets = binding.targetList;
String activeConfigName = binding.activeConfigSelector;
int foundIndex = IntStream.range(0, matchedTargets.size())
.filter(i -> matchedTargets.get(i).name().equalsIgnoreCase(activeConfigName)).findFirst()
.orElse(-1);
switch (selector){
case NEXT -> binding.activeConfigSelector = matchedTargets.get(Math.clamp(foundIndex + 1, 0, matchedTargets.size() - 1)).name();
case PREV -> binding.activeConfigSelector = matchedTargets.get(Math.clamp(foundIndex - 1, 0, matchedTargets.size() - 1)).name();
}
}
}

public List<BindTarget> getBindTargetList(String textureId) {
int activeConfigIndex = binding.activeConfigIndex;
List<BindTarget> matchedTargets = binding.targetList.stream().filter(target -> textureId.contains(target.textureId())).toList();
if (activeConfigIndex <= 0 || matchedTargets.isEmpty()) return matchedTargets;
return List.of(matchedTargets.get(Math.clamp(activeConfigIndex - 1, 0, matchedTargets.size() - 1)));
if ("0".equals(binding.activeConfigSelector)) return matchedTargets;
List<BindTarget> filteredTargets = matchedTargets.stream()
.filter(target -> target.name().equalsIgnoreCase(binding.activeConfigSelector))
.toList();
if (!filteredTargets.isEmpty())
return filteredTargets;
if (isParsableInt(binding.activeConfigSelector)) {
int activeConfigIndex = Integer.parseInt(binding.activeConfigSelector);
return List.of(matchedTargets.get(Math.clamp(activeConfigIndex - 1, 0, matchedTargets.size() - 1)));
} else return matchedTargets;
}

private boolean isParsableInt(String s){
try {
Integer.parseInt(s);
return true;
} catch (NumberFormatException e) {
return false;
}
}

public void putBindTarget(BindTarget target) {
Expand Down Expand Up @@ -193,7 +233,7 @@ public static class Binding {
public boolean disableWhenFlying = false;
public int exitTick = 13;
public int bindResultRetentionFrames = 2;
public int activeConfigIndex = 0;
public String activeConfigSelector = "0";
public double displacementSmoothFactor = 0.4;
public double rotationSmoothFactor = 0.4;
public List<String> disableMainFeatureItems = List.of();
Expand All @@ -209,9 +249,9 @@ private void clamp() {
}
exitTick = Mth.clamp(exitTick, 0, 40);
bindResultRetentionFrames = Math.max(bindResultRetentionFrames, 0);
activeConfigIndex = Math.max(activeConfigIndex, 0);
displacementSmoothFactor = Mth.clamp(displacementSmoothFactor, 0.0, 1.0);
rotationSmoothFactor = Mth.clamp(rotationSmoothFactor, 0.0, 1.0);
if (activeConfigSelector == null || activeConfigSelector.isBlank()) activeConfigSelector = "0";
displacementSmoothFactor = Mth.clamp(displacementSmoothFactor, 0.0, 0.9);
rotationSmoothFactor = Mth.clamp(rotationSmoothFactor, 0.0, 0.9);
if (disableMainFeatureItems == null) disableMainFeatureItems = List.of();
if (disableRenderItems == null) disableRenderItems = List.of();
if (fixedTargetList == null) fixedTargetList = new ArrayList<>();
Expand All @@ -223,4 +263,8 @@ private void clamp() {
}
}
}

public enum SelectorAction {
NEXT, PREV, RESET
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ private Vec2 translateXYToUV(float x, float y, ScreenRectangle screenArea) {
}

private void importBindTarget(Button button) {
String base64 = minecraft.keyboardHandler.getClipboard();
String base64 = minecraft.keyboardHandler.getClipboard().strip();
DataResult<BindTarget> result = ConfigCodec.fromCompressedBase64(base64);
switch (result) {
case DataResult.Success<BindTarget> success -> {
Expand Down
11 changes: 5 additions & 6 deletions common/src/main/resources/assets/realcamera/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"config.category.xtracr_realcamera.centerOffset": "Rotation Center Offset",
"config.category.xtracr_realcamera.classic": "Classic Mode",
"config.category.xtracr_realcamera.general": "General",
"config.option.xtracr_realcamera.activeConfigIndex": "Active Configuration Index",
"config.option.xtracr_realcamera.activeConfigSelector": "Active Configuration Selector",
"config.option.xtracr_realcamera.adjustOffset": "Adjust Camera Offset",
"config.option.xtracr_realcamera.adjustStep": "Adjust Step",
"config.option.xtracr_realcamera.bindResultRetentionFrames": "Bind Result Retention Frames",
Expand Down Expand Up @@ -34,8 +34,7 @@
"config.option.xtracr_realcamera.screenModifierKey": "%s Screen Modifier Key",
"config.option.xtracr_realcamera.toModelViewScreen": "For detailed settings, please go to the %s screen (key bind need to be set to open it)",
"config.option.xtracr_realcamera.yaw": "Yaw",
"config.tooltip.xtracr_realcamera.activeConfigIndex": "Currently bound configuration index, 0 means allowing binding to any valid configuration",
"config.tooltip.xtracr_realcamera.adjustOffset": "When pressing the adjustment key, adjust the offset or rotation of camera",
"config.tooltip.xtracr_realcamera.activeConfigSelector": "Current configuration selector. 0 allows binding to any valid configuration\nYou can use either configuration names or configuration indices\nWhen using indices, only valid configurations are included in the index list\nIf the specified configuration name is invalid, it behaves the same as allowing any valid configuration", "config.tooltip.xtracr_realcamera.adjustOffset": "When pressing the adjustment key, adjust the offset or rotation of camera",
"config.tooltip.xtracr_realcamera.adjustStep": "Length or 1/100 of the angle of the adjustment per step",
"config.tooltip.xtracr_realcamera.bindResultRetentionFrames": "For several frames after the binding failure, continue to use the previous successful binding result",
"config.tooltip.xtracr_realcamera.cameraRotation": "Additional camera rotation in degrees",
Expand All @@ -56,9 +55,9 @@
"config.tooltip.xtracr_realcamera.scale": "Control the size of the offsets",
"general.xtracr_realcamera.modName": "Real Camera",
"key.category.xtracr_realcamera.general": "Real Camera",
"key.xtracr_realcamera.activeConfigIndexNEXT": "Switch to next configuration",
"key.xtracr_realcamera.activeConfigIndexPREV": "Switch to previous configuration",
"key.xtracr_realcamera.activeConfigIndexRESET": "Reset configuration index",
"key.xtracr_realcamera.adjustActiveConfigNEXT": "Switch to next configuration",
"key.xtracr_realcamera.adjustActiveConfigPREV": "Switch to previous configuration",
"key.xtracr_realcamera.adjustActiveConfigRESET": "Reset configuration index",
"key.xtracr_realcamera.adjustUP": "Adjust UP (Rotate Up)",
"key.xtracr_realcamera.adjustDOWN": "Adjust DOWN (Rotate Down)",
"key.xtracr_realcamera.adjustLEFT": "Adjust LEFT (Rotate Left)",
Expand Down
10 changes: 5 additions & 5 deletions common/src/main/resources/assets/realcamera/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"config.category.xtracr_realcamera.centerOffset": "旋转中心偏移",
"config.category.xtracr_realcamera.classic": "经典模式",
"config.category.xtracr_realcamera.general": "通用",
"config.option.xtracr_realcamera.activeConfigIndex": "当前配置索引",
"config.option.xtracr_realcamera.activeConfigSelector": "配置选择器",
"config.option.xtracr_realcamera.adjustOffset": "调整摄像头偏移",
"config.option.xtracr_realcamera.adjustStep": "调整步长",
"config.option.xtracr_realcamera.bindResultRetentionFrames": "绑定结果保留帧数",
Expand Down Expand Up @@ -34,7 +34,7 @@
"config.option.xtracr_realcamera.screenModifierKey": "%s界面修饰键",
"config.option.xtracr_realcamera.toModelViewScreen": "详细设置请前往%s界面(需设置快捷键来打开它)",
"config.option.xtracr_realcamera.yaw": "偏航角",
"config.tooltip.xtracr_realcamera.activeConfigIndex": "当前绑定的配置索引,0表示允许绑定任何有效配置",
"config.tooltip.xtracr_realcamera.activeConfigSelector": "当前的配置选择器,0表示允许绑定任何有效配置\n可以使用配置名称或配置索引\n在使用索引时,仅有效的配置会被纳入索引列表\n当使用的配置名称无效时,等同于允许任何有效配置",
"config.tooltip.xtracr_realcamera.adjustOffset": "当前按下调整键时是调整摄像头的偏移还是旋转",
"config.tooltip.xtracr_realcamera.adjustStep": "每步调整的角度的1/100或长度",
"config.tooltip.xtracr_realcamera.bindResultRetentionFrames": "在绑定失败后的数帧内,沿用上个成功的绑定结果",
Expand All @@ -56,9 +56,9 @@
"config.tooltip.xtracr_realcamera.scale": "控制偏移量的大小",
"general.xtracr_realcamera.modName": "Real Camera",
"key.category.xtracr_realcamera.general": "Real Camera",
"key.xtracr_realcamera.activeConfigIndexNEXT": "切换到下一个配置",
"key.xtracr_realcamera.activeConfigIndexPREV": "切换到上一个配置",
"key.xtracr_realcamera.activeConfigIndexRESET": "重置配置索引",
"key.xtracr_realcamera.adjustActiveConfigNEXT": "切换到下一个配置",
"key.xtracr_realcamera.adjustActiveConfigPREV": "切换到上一个配置",
"key.xtracr_realcamera.adjustActiveConfigRESET": "重置配置索引",
"key.xtracr_realcamera.adjustUP": "向上调整(向上旋转)",
"key.xtracr_realcamera.adjustDOWN": "向下调整(向下旋转)",
"key.xtracr_realcamera.adjustLEFT": "向左调整(向左旋转)",
Expand Down