Configurable goal selector update interval

Correspond to new vanilla optimization mechanic
This commit is contained in:
IzzelAliz 2021-12-03 17:10:46 +08:00
parent baf681d166
commit 93e54f8d26
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338
6 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,16 @@
package io.izzel.arclight.common.mixin.optimization.general;
import io.izzel.arclight.i18n.ArclightConfig;
import net.minecraft.world.entity.Mob;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(Mob.class)
public class MobMixin_Optimization {
@ModifyConstant(method = "serverAiStep", constant = @Constant(intValue = 2))
private int arclight$goalUpdateInterval(int orig) {
return ArclightConfig.spec().getOptimization().getGoalSelectorInterval();
}
}

View File

@ -7,6 +7,7 @@
"mixins": [
"ClassInheritanceMultiMapMixin",
"EntityDataManagerMixin_Optimize",
"MobMixin_Optimization",
"VoxelShapesMixin",
"activationrange.ActivationRangeMixin",
"activationrange.EntityMixin_ActivationRange",

View File

@ -12,6 +12,9 @@ public class OptimizationSpec {
@Setting("disable-data-fixer")
private boolean disableDFU;
@Setting("goal-selector-update-interval")
private int goalSelectorInterval;
public boolean isCachePluginClass() {
return cachePluginClass;
}
@ -19,4 +22,8 @@ public class OptimizationSpec {
public boolean isDisableDFU() {
return disableDFU;
}
public int getGoalSelectorInterval() {
return goalSelectorInterval;
}
}

View File

@ -4,9 +4,9 @@ locale {
fallback = "zh_cn"
}
optimization {
remove-stream = true
cache-plugin-class = true
disable-data-fixer = false
goal-selector-update-interval = 2
}
compatibility {
material-property-overrides {

View File

@ -88,6 +88,11 @@ comments {
"Arclight and its developers are not reponsible for any data loss or corruption"
"DO NOT USE IN PRODUCTION!"
]
goal-selector-update-interval.comment = [
"Interval in ticks to update the goal selector"
"Higher values costs less resources"
"Cause mobs changing their goals less often"
]
}
async-catcher.comment = [
"Async Catcher related settings"

View File

@ -89,6 +89,11 @@ comments {
"Arclight 及其开发者不对任何数据丢失或损害负责"
"请不要在生产环境中使用"
]
goal-selector-update-interval.comment = [
"实体目标选择器的更新间隔"
"数值越高消耗资源越少"
"导致实体更改目标速度变慢"
]
}
async-catcher.comment = [
"异步捕获相关设置"