-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
171 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: AlphaKR93 <[email protected]> | ||
Date: Sat, 30 Sep 2023 21:56:32 +0900 | ||
Subject: [PATCH] Variable entity wakeup duration | ||
|
||
|
||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java | ||
index 82975c1c92c84294740a411b4a351efb8a2e6769..cb21da3cff4dbb08c7786c09b39e381abdf45c33 100644 | ||
--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java | ||
+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java | ||
@@ -51,6 +51,20 @@ public class LevelConfigurations extends ConfigurationPart { | ||
|
||
} | ||
|
||
+ public WakeUpDurationVariance wakeUpDurationVariance; | ||
+ public class WakeUpDurationVariance extends ConfigurationPart { | ||
+ | ||
+ double defaultValue() { | ||
+ return DO_OPTIMIZE ? 0.2 : 0.0; | ||
+ } | ||
+ | ||
+ double animal = defaultValue(); public double animal() { return Math.max(0, this.animal); } | ||
+ double monster = defaultValue(); public double monster() { return Math.max(0, this.monster); } | ||
+ double flyingMonster = defaultValue(); public double flyingMonster() { return Math.max(0, this.flyingMonster); } | ||
+ double villager = defaultValue(); public double villager() { return Math.max(0, this.villager); } | ||
+ | ||
+ } | ||
+ | ||
} | ||
|
||
public Structure structure; | ||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java | ||
index 062a793a134f774ebf918aab10443527c06c4fd1..3a362fef29c6fa29c37eff539e343eb3a56bf122 100644 | ||
--- a/src/main/java/org/spigotmc/ActivationRange.java | ||
+++ b/src/main/java/org/spigotmc/ActivationRange.java | ||
@@ -68,6 +68,13 @@ public class ActivationRange | ||
Activity.PANIC | ||
}; | ||
|
||
+ // Plazma start - Variable entity wakeup duration | ||
+ private static final java.util.Random WAKEUP_DURATION_RANDOM = org.plazmamc.plazma.PlazmaOptions.useJavaRandom() ? new java.util.Random() : new org.plazmamc.plazma.Random(); | ||
+ private static int getWakeupDurationWithVariance(int duration, double deviation) { | ||
+ if (deviation == 0) return duration; | ||
+ return (int) Math.min(Integer.MAX_VALUE, Math.max(1, Math.round(duration * WAKEUP_DURATION_RANDOM.nextGaussian(1, deviation)))); | ||
+ } | ||
+ // Plazma end | ||
private static int checkInactiveWakeup(Entity entity) { | ||
Level world = entity.level(); | ||
SpigotWorldConfig config = world.spigotConfig; | ||
@@ -75,22 +82,22 @@ public class ActivationRange | ||
if (entity.activationType == ActivationType.VILLAGER) { | ||
if (inactiveFor > config.wakeUpInactiveVillagersEvery && world.wakeupInactiveRemainingVillagers > 0) { | ||
world.wakeupInactiveRemainingVillagers--; | ||
- return config.wakeUpInactiveVillagersFor; | ||
+ return getWakeupDurationWithVariance(config.wakeUpInactiveVillagersFor, world.plazmaLevelConfiguration().entity.wakeUpDurationVariance.villager()); // Plazma - Variable entity wakeup duration | ||
} | ||
} else if (entity.activationType == ActivationType.ANIMAL) { | ||
if (inactiveFor > config.wakeUpInactiveAnimalsEvery && world.wakeupInactiveRemainingAnimals > 0) { | ||
world.wakeupInactiveRemainingAnimals--; | ||
- return config.wakeUpInactiveAnimalsFor; | ||
+ return getWakeupDurationWithVariance(config.wakeUpInactiveAnimalsFor, world.plazmaLevelConfiguration().entity.wakeUpDurationVariance.animal()); // Plazma - Variable entity wakeup duration | ||
} | ||
} else if (entity.activationType == ActivationType.FLYING_MONSTER) { | ||
if (inactiveFor > config.wakeUpInactiveFlyingEvery && world.wakeupInactiveRemainingFlying > 0) { | ||
world.wakeupInactiveRemainingFlying--; | ||
- return config.wakeUpInactiveFlyingFor; | ||
+ return getWakeupDurationWithVariance(config.wakeUpInactiveFlyingFor, world.plazmaLevelConfiguration().entity.wakeUpDurationVariance.flyingMonster()); // Plazma - Variable entity wakeup duration | ||
} | ||
} else if (entity.activationType == ActivationType.MONSTER || entity.activationType == ActivationType.RAIDER) { | ||
if (inactiveFor > config.wakeUpInactiveMonstersEvery && world.wakeupInactiveRemainingMonsters > 0) { | ||
world.wakeupInactiveRemainingMonsters--; | ||
- return config.wakeUpInactiveMonstersFor; | ||
+ return getWakeupDurationWithVariance(config.wakeUpInactiveMonstersFor, world.plazmaLevelConfiguration().entity.wakeUpDurationVariance.monster()); // Plazma - Variable entity wakeup duration | ||
} | ||
} | ||
return -1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: IPECTER <[email protected]> | ||
Date: Wed, 10 May 2023 15:30:03 +0900 | ||
Subject: [PATCH] More optimise state lookup | ||
From: AlphaKR93 <[email protected]> | ||
Date: Sat, 30 Sep 2023 22:02:58 +0900 | ||
Subject: [PATCH] Optimise state lookup more | ||
|
||
|
||
diff --git a/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java b/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java | ||
index 57d0cd3ad6f972e986c72a57f1a6e36003f190c2..5c03e26db0f9da992e9b0487a872e0ec8786650a 100644 | ||
index 57d0cd3ad6f972e986c72a57f1a6e36003f190c2..0832e4fa92b6464a6206475fbceb3b36462757b3 100644 | ||
--- a/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java | ||
+++ b/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java | ||
@@ -16,7 +16,7 @@ public final class ZeroCollidingReferenceStateTable { | ||
protected final Comparable<?>[] this_table; | ||
@@ -17,6 +17,7 @@ public final class ZeroCollidingReferenceStateTable { | ||
protected final StateHolder<?, ?> this_state; | ||
|
||
- protected long[] index_table; | ||
+ protected long[] index_table; public long[] index_table() { return index_table; } // Plazma - Paper - optimise state lookup | ||
protected long[] index_table; | ||
+ public long[] index_table() { return this.index_table; } // Plazma - getter | ||
protected StateHolder<?, ?>[][] value_table; | ||
|
||
public ZeroCollidingReferenceStateTable(final StateHolder<?, ?> state, final Map<Property<?>, Comparable<?>> this_map) { | ||
diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java | ||
index 5f285d190186a2ff5a61d05070593e1d633dd79a..62934ef07ef856b917862c6f58ad391984da6327 100644 | ||
index 5f285d190186a2ff5a61d05070593e1d633dd79a..7b61a956892e90c7556db46d9277da8d252547cd 100644 | ||
--- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java | ||
+++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java | ||
@@ -114,21 +114,17 @@ public abstract class StateHolder<O, S> { | ||
@@ -114,21 +114,15 @@ public abstract class StateHolder<O, S> { | ||
} | ||
|
||
public <T extends Comparable<T>, V extends T> S trySetValue(Property<T> property, V value) { | ||
|
@@ -35,27 +34,26 @@ index 5f285d190186a2ff5a61d05070593e1d633dd79a..62934ef07ef856b917862c6f58ad3919 | |
- } | ||
- } else { | ||
- return (S)this; | ||
+ // Plazma start - Paper - optimise state lookup | ||
+ final S ret = (S)this.optimisedTable.get(property, value); | ||
+ if (ret == null) { | ||
+ throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value"); | ||
} | ||
- } | ||
+ // Plazma start - optimise state lookup more | ||
+ final S ret = (S) this.optimisedTable.get(property, value); | ||
+ if (ret == null) throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value"); | ||
+ return ret; | ||
+ // Plazma end - Paper - optimise state lookup | ||
+ // Plazma end | ||
} | ||
|
||
public void populateNeighbours(Map<Map<Property<?>, Comparable<?>>, S> states) { | ||
- if (this.neighbours != null) { | ||
+ if (this.optimisedTable.index_table() != null) { | ||
+ if (this.optimisedTable.index_table() != null) { // Plazma - optimise state lookup more | ||
throw new IllegalStateException(); | ||
} else { | ||
Table<Property<?>, Comparable<?>, S> table = HashBasedTable.create(); | ||
@@ -143,7 +139,7 @@ public abstract class StateHolder<O, S> { | ||
@@ -143,7 +137,7 @@ public abstract class StateHolder<O, S> { | ||
} | ||
} | ||
|
||
- this.neighbours = (Table<Property<?>, Comparable<?>, S>)(table.isEmpty() ? table : ArrayTable.create(table)); this.optimisedTable.loadInTable((Table)this.neighbours, this.values); // Paper - optimise state lookup | ||
+ this.optimisedTable.loadInTable((Table)(table.isEmpty() ? table : ArrayTable.create(table)), this.values); // Paper - optimise state lookup // Plazma | ||
+ this.optimisedTable.loadInTable((Table) (table.isEmpty() ? table : ArrayTable.create(table)), this.values); // Paper - optimise state lookup // Plazma - more | ||
} | ||
} | ||
|
Oops, something went wrong.