mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-19 11:39:50 +01:00
Use mapped names for sensor and behavior timings/config (#6228)
This commit is contained in:
parent
3051846c73
commit
e2ed8e9e86
2 changed files with 30 additions and 14 deletions
|
@ -372,19 +372,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ return rootClassName + ".java";
|
||||
+ }
|
||||
+
|
||||
+ private record ClassMapping(
|
||||
+ public record ClassMapping(
|
||||
+ String obfName,
|
||||
+ String mojangName,
|
||||
+ Map<Pair<String, String>, MethodMapping> methodMappings
|
||||
+ ) {
|
||||
+ }
|
||||
+
|
||||
+ private record MethodMapping(
|
||||
+ public record MethodMapping(
|
||||
+ String obfName,
|
||||
+ String mojangName,
|
||||
+ String descriptor
|
||||
+ ) {
|
||||
+ }
|
||||
+
|
||||
+ public @Nullable Map<String, ClassMapping> mappings() {
|
||||
+ return mappings;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/util/TraceUtil.java b/src/main/java/io/papermc/paper/util/TraceUtil.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
|
|
|
@ -59,8 +59,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ private Table<String, String, Integer> sensorTickRates;
|
||||
+ private Table<String, String, Integer> behaviorTickRates;
|
||||
+ private void tickRates() {
|
||||
+ config.addDefault("world-settings.default.tick-rates.sensor.villager.secondaryplaces", 40);
|
||||
+ config.addDefault("world-settings.default.tick-rates.behavior.villager.positionvalidate", 20);
|
||||
+ config.addDefault("world-settings.default.tick-rates.sensor.villager.secondarypoisensor", 40);
|
||||
+ config.addDefault("world-settings.default.tick-rates.behavior.villager.validatenearbypoi", -1); // Example
|
||||
+ log("Tick rates:");
|
||||
+ sensorTickRates = loadTickRates("sensor");
|
||||
+ behaviorTickRates = loadTickRates("behavior");
|
||||
|
@ -130,12 +130,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
this.maxDuration = maxRunTime;
|
||||
this.entryCondition = requiredMemoryState;
|
||||
+ // Paper start - configurable behavior tick rate and timings
|
||||
+ String key = getClass().getName().startsWith("net.minecraft.") ? getClass().getSimpleName() : getClass().getName();
|
||||
+ key = key.toLowerCase(java.util.Locale.ROOT);
|
||||
+ if (key.startsWith("behavior")) {
|
||||
+ key = key.substring("behavior".length());
|
||||
+ Map<String, io.papermc.paper.util.StacktraceDeobfuscator.ClassMapping> mappings = io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.mappings();
|
||||
+ String key;
|
||||
+ if (mappings != null) {
|
||||
+ key = mappings.get(getClass().getName()).mojangName();
|
||||
+ int lastSeparator = key.lastIndexOf('.');
|
||||
+ if (lastSeparator != -1) {
|
||||
+ key = key.substring(lastSeparator + 1);
|
||||
+ }
|
||||
+ } else {
|
||||
+ key = getClass().getSimpleName();
|
||||
+ }
|
||||
+ this.configKey = key;
|
||||
+ this.configKey = key.toLowerCase(java.util.Locale.ROOT);
|
||||
+ this.timing = co.aikar.timings.MinecraftTimings.getBehaviorTimings(configKey);
|
||||
+ // Paper end
|
||||
}
|
||||
|
@ -190,12 +196,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
public Sensor(int senseInterval) {
|
||||
+ // Paper start - configurable sensor tick rate and timings
|
||||
+ String key = getClass().getName().startsWith("net.minecraft.") ? getClass().getSimpleName() : getClass().getName();
|
||||
+ key = key.toLowerCase(java.util.Locale.ROOT);
|
||||
+ if (key.startsWith("sensor")) {
|
||||
+ key = key.substring("sensor".length());
|
||||
+ java.util.Map<String, io.papermc.paper.util.StacktraceDeobfuscator.ClassMapping> mappings = io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.mappings();
|
||||
+ String key;
|
||||
+ if (mappings != null) {
|
||||
+ key = mappings.get(getClass().getName()).mojangName();
|
||||
+ int lastSeparator = key.lastIndexOf('.');
|
||||
+ if (lastSeparator != -1) {
|
||||
+ key = key.substring(lastSeparator + 1);
|
||||
+ }
|
||||
+ } else {
|
||||
+ key = getClass().getSimpleName();
|
||||
+ }
|
||||
+ this.configKey = key;
|
||||
+ this.configKey = key.toLowerCase(java.util.Locale.ROOT);
|
||||
+ this.timing = co.aikar.timings.MinecraftTimings.getSensorTimings(configKey);
|
||||
+ // Paper end
|
||||
this.scanRate = senseInterval;
|
||||
|
|
Loading…
Add table
Reference in a new issue