mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-22 08:19:31 +00:00
Include hardware specs in timings
This commit is contained in:
92
patches/server/0027-Use-array-for-gamerule-storage.patch
Normal file
92
patches/server/0027-Use-array-for-gamerule-storage.patch
Normal file
@@ -0,0 +1,92 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 21:52:25 +0100
|
||||
Subject: [PATCH] Use array for gamerule storage
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Use array for gamerule storage"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
index 663c1d8c1611af915a1bae733920dd75ad73feb1..19bdb2c717718f074ab2b4c5fb934ea29dd80c53 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
@@ -98,6 +98,7 @@ public class GameRules {
|
||||
public static final GameRules.Key<GameRules.BooleanValue> RULE_LAVA_SOURCE_CONVERSION = GameRules.register("lavaSourceConversion", GameRules.Category.UPDATES, GameRules.BooleanValue.create(false));
|
||||
public static final GameRules.Key<GameRules.BooleanValue> RULE_GLOBAL_SOUND_EVENTS = GameRules.register("globalSoundEvents", GameRules.Category.MISC, GameRules.BooleanValue.create(true));
|
||||
private final Map<GameRules.Key<?>, GameRules.Value<?>> rules;
|
||||
+ private final GameRules.Value<?>[] gameruleArray; // Gale - Airplane - use array for gamerule storage
|
||||
|
||||
private static <T extends GameRules.Value<T>> GameRules.Key<T> register(String name, GameRules.Category category, GameRules.Type<T> type) {
|
||||
GameRules.Key<T> gamerules_gamerulekey = new GameRules.Key<>(name, category);
|
||||
@@ -116,17 +117,33 @@ public class GameRules {
|
||||
}
|
||||
|
||||
public GameRules() {
|
||||
- this.rules = (Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> {
|
||||
+ // Gale start - Airplane - use array for gamerule storage - use this to ensure gameruleArray is initialized
|
||||
+ this((Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> {
|
||||
return ((GameRules.Type) entry.getValue()).createRule();
|
||||
- }));
|
||||
+ })));
|
||||
+ // Gale end - Airplane - use array for gamerule storage - use this to ensure gameruleArray is initialized
|
||||
}
|
||||
|
||||
private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules) {
|
||||
this.rules = rules;
|
||||
+
|
||||
+ // Gale start - Airplane - use array for gamerule storage
|
||||
+ int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1;
|
||||
+ GameRules.Value<?>[] values = new GameRules.Value[arraySize];
|
||||
+
|
||||
+ for (Entry<GameRules.Key<?>, GameRules.Value<?>> entry : rules.entrySet()) {
|
||||
+ values[entry.getKey().gameRuleIndex] = entry.getValue();
|
||||
+ }
|
||||
+
|
||||
+ this.gameruleArray = values;
|
||||
+ // Gale end - Airplane - use array for gamerule storage
|
||||
}
|
||||
|
||||
public <T extends GameRules.Value<T>> T getRule(GameRules.Key<T> key) {
|
||||
- return (T) this.rules.get(key); // CraftBukkit - decompile error
|
||||
+ // Gale start - Airplane - use array for gamerule storage
|
||||
+ return key == null ? null : (T) this.gameruleArray[key.gameRuleIndex];
|
||||
+ //return (T) this.rules.get(key); // CraftBukkit - decompile error
|
||||
+ // Gale end - Airplane - use array for gamerule storage
|
||||
}
|
||||
|
||||
public CompoundTag createTag() {
|
||||
@@ -185,6 +202,10 @@ public class GameRules {
|
||||
}
|
||||
|
||||
public static final class Key<T extends GameRules.Value<T>> {
|
||||
+ // Gale start - Airplane - use array for gamerule storage
|
||||
+ private static int lastGameRuleIndex = 0;
|
||||
+ public final int gameRuleIndex = lastGameRuleIndex++;
|
||||
+ // Gale end - Airplane - use array for gamerule storage
|
||||
|
||||
final String id;
|
||||
private final GameRules.Category category;
|
||||
Reference in New Issue
Block a user