1110 lines
74 KiB
Diff
1110 lines
74 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: AlphaKR93 <dev@alpha93.kr>
|
|
Date: Wed, 10 Jan 2024 12:43:26 +0900
|
|
Subject: [PATCH] Reduce allocations
|
|
|
|
|
|
diff --git a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java
|
|
index ad1eeebe6de219143492b94da309cb54ae9e0a5b..f83bdcf5d2d6f676b2dc83bc1fc0a7453fc2b36a 100644
|
|
--- a/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java
|
|
+++ b/src/main/java/ca/spottedleaf/starlight/common/light/StarLightEngine.java
|
|
@@ -38,6 +38,7 @@ public abstract class StarLightEngine {
|
|
AxisDirection.POSITIVE_X, AxisDirection.NEGATIVE_X,
|
|
AxisDirection.POSITIVE_Z, AxisDirection.NEGATIVE_Z
|
|
};
|
|
+ private static final AxisDirection[] EMPTY_DIRECTIONS = new AxisDirection[0]; // Plazma - Reduce allocations
|
|
|
|
protected static enum AxisDirection {
|
|
|
|
@@ -1094,7 +1095,7 @@ public abstract class StarLightEngine {
|
|
for (int bitset = i, len = Integer.bitCount(i), index = 0; index < len; ++index, bitset ^= IntegerUtil.getTrailingBit(bitset)) {
|
|
directions.add(AXIS_DIRECTIONS[IntegerUtil.trailingZeros(bitset)]);
|
|
}
|
|
- OLD_CHECK_DIRECTIONS[i] = directions.toArray(new AxisDirection[0]);
|
|
+ OLD_CHECK_DIRECTIONS[i] = directions.toArray(EMPTY_DIRECTIONS); // Plazma - Reduce allocations
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
|
|
index e7fe98ea30ae6d0baea3ec1f9f98a89502a49a12..7663ccd247b9942ccfb7a320b047ee621fc1bebe 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
|
|
@@ -97,8 +97,8 @@ public final class ChunkPacketBlockControllerAntiXray extends ChunkPacketBlockCo
|
|
Set<BlockState> presetBlockStateSet = new LinkedHashSet<>();
|
|
// Therefore addAll(Collection<? extends E>) is used, which guarantees this order in the doc
|
|
presetBlockStateSet.addAll(presetBlockStateList);
|
|
- presetBlockStates = presetBlockStateSet.isEmpty() ? new BlockState[]{Blocks.DIAMOND_ORE.defaultBlockState()} : presetBlockStateSet.toArray(new BlockState[0]);
|
|
- presetBlockStatesFull = presetBlockStateSet.isEmpty() ? new BlockState[]{Blocks.DIAMOND_ORE.defaultBlockState()} : presetBlockStateList.toArray(new BlockState[0]);
|
|
+ presetBlockStates = presetBlockStateSet.isEmpty() ? new BlockState[]{Blocks.DIAMOND_ORE.defaultBlockState()} : presetBlockStateSet.toArray(org.plazmamc.plazma.constants.Empty.BLOCK_STATE); // Plazma - Reduce allocations
|
|
+ presetBlockStatesFull = presetBlockStateSet.isEmpty() ? new BlockState[]{Blocks.DIAMOND_ORE.defaultBlockState()} : presetBlockStateList.toArray(org.plazmamc.plazma.constants.Empty.BLOCK_STATE); // Plazma - Reduce allocations
|
|
presetBlockStatesStone = null;
|
|
presetBlockStatesDeepslate = null;
|
|
presetBlockStatesNetherrack = null;
|
|
diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java
|
|
index 0133ea6feb1ab88f021f66855669f58367e7420b..a04049bc7738225633ac0b01c470cfbfde86c032 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java
|
|
@@ -17,9 +17,9 @@ public final class EntityList implements Iterable<Entity> {
|
|
this.entityToIndex.defaultReturnValue(Integer.MIN_VALUE);
|
|
}
|
|
|
|
- protected static final Entity[] EMPTY_LIST = new Entity[0];
|
|
+ //protected static final Entity[] EMPTY_LIST = new Entity[0]; // Plazma - Reduce allocations
|
|
|
|
- protected Entity[] entities = EMPTY_LIST;
|
|
+ protected Entity[] entities = org.plazmamc.plazma.constants.Empty.ENTITY; // Plazma - Reduce allocations
|
|
protected int count;
|
|
|
|
public int size() {
|
|
diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java
|
|
index 277cfd9d1e8fff5d9b5e534b75c3c5162d58b0b7..30d8d9c2dce5e4eb26cc52a03bc395c16c04c256 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java
|
|
@@ -20,9 +20,9 @@ public final class IBlockDataList {
|
|
this.map.defaultReturnValue(Long.MAX_VALUE);
|
|
}
|
|
|
|
- private static final long[] EMPTY_LIST = new long[0];
|
|
+ //private static final long[] EMPTY_LIST = new long[0]; // Plazma - Reduce allocations
|
|
|
|
- private long[] byIndex = EMPTY_LIST;
|
|
+ private long[] byIndex = org.plazmamc.plazma.constants.Empty.LONG; // Plazma - Reduce allocations
|
|
private int size;
|
|
|
|
public static int getLocationKey(final int x, final int y, final int z) {
|
|
diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/ReferenceList.java b/src/main/java/com/destroystokyo/paper/util/maplist/ReferenceList.java
|
|
index 190c5f0b02a3d99054704ae1afbffb3498ddffe1..042ea49ec61ee327c0f67ddcf080774042e44c02 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/util/maplist/ReferenceList.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/util/maplist/ReferenceList.java
|
|
@@ -15,9 +15,9 @@ public final class ReferenceList<E> implements Iterable<E> {
|
|
this.referenceToIndex.defaultReturnValue(Integer.MIN_VALUE);
|
|
}
|
|
|
|
- protected static final Object[] EMPTY_LIST = new Object[0];
|
|
+ //protected static final Object[] EMPTY_LIST = new Object[0]; // Plazma - Reduce allocations
|
|
|
|
- protected Object[] references = EMPTY_LIST;
|
|
+ protected Object[] references = org.plazmamc.plazma.constants.Empty.OBJECT; // Plazma - Reduce allocations
|
|
protected int count;
|
|
|
|
public int size() {
|
|
diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkTaskScheduler.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkTaskScheduler.java
|
|
index 17ce14f2dcbf900890efbc2351782bc6f8867068..a8d4acc1dbb3e8e5cd8d181fbd8335f84e252d0c 100644
|
|
--- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkTaskScheduler.java
|
|
+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkTaskScheduler.java
|
|
@@ -42,6 +42,7 @@ import java.util.function.Consumer;
|
|
public final class ChunkTaskScheduler {
|
|
|
|
private static final Logger LOGGER = LogUtils.getClassLogger();
|
|
+ private static final ChunkInfo[] EMPTY_INFO = new ChunkInfo[0]; // Plazma - Reduce allocations
|
|
|
|
static int newChunkSystemIOThreads;
|
|
static int newChunkSystemWorkerThreads;
|
|
@@ -854,7 +855,7 @@ public final class ChunkTaskScheduler {
|
|
|
|
public static ChunkInfo[] getChunkInfos() {
|
|
synchronized (WAITING_CHUNKS) {
|
|
- return WAITING_CHUNKS.toArray(new ChunkInfo[0]);
|
|
+ return WAITING_CHUNKS.toArray(EMPTY_INFO); // Plazma - Reduce allocations
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java
|
|
index ae60bd96b5284d54676d8e7e4dd5d170b526ec1e..359c4b080bd47234e569dce7055da03ddb7b1e90 100644
|
|
--- a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java
|
|
+++ b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java
|
|
@@ -14,7 +14,7 @@ public final class VersionCommand implements PaperSubcommand {
|
|
public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
|
final @Nullable Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
|
if (ver != null) {
|
|
- ver.execute(sender, "paper", new String[0]);
|
|
+ ver.execute(sender, "paper", org.plazmamc.plazma.constants.Empty.STRING); // Plazma - Reduce allocations
|
|
}
|
|
return true;
|
|
}
|
|
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
|
|
index eedbf46e04b5ae420f9bedcbc2bbb10643ba7e22..1ac70b965f5dd9441658156e19a38419cbcc47d6 100644
|
|
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
|
|
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperPluginInstanceManager.java
|
|
@@ -47,6 +47,8 @@ import java.util.logging.Level;
|
|
class PaperPluginInstanceManager {
|
|
|
|
private static final FileProviderSource FILE_PROVIDER_SOURCE = new FileProviderSource("File '%s'"::formatted);
|
|
+ private static final JavaPlugin[] EMPTY_JPLUGIN = new JavaPlugin[0]; // Plazma - Reduce allocations
|
|
+ private static final Plugin[] EMPTY_PLUGIN = new Plugin[0]; // Plazma - Reduce allocations
|
|
|
|
private final List<Plugin> plugins = new ArrayList<>();
|
|
private final Map<String, Plugin> lookupNames = new HashMap<>();
|
|
@@ -68,7 +70,7 @@ class PaperPluginInstanceManager {
|
|
}
|
|
|
|
public @NotNull Plugin[] getPlugins() {
|
|
- return this.plugins.toArray(new Plugin[0]);
|
|
+ return this.plugins.toArray(EMPTY_PLUGIN); // Plazma - Reduce allocations
|
|
}
|
|
|
|
public boolean isPluginEnabled(@NotNull String name) {
|
|
@@ -136,7 +138,7 @@ class PaperPluginInstanceManager {
|
|
this.server.getLogger().log(Level.SEVERE, "Unknown error occurred while loading plugins through PluginManager.", e);
|
|
}
|
|
|
|
- return runtimePluginEntrypointHandler.getPluginProviderStorage().getLoaded().toArray(new JavaPlugin[0]);
|
|
+ return runtimePluginEntrypointHandler.getPluginProviderStorage().getLoaded().toArray(EMPTY_JPLUGIN); // Plazma - Reduce allocations
|
|
}
|
|
|
|
// Plugins are disabled in order like this inorder to "rougly" prevent
|
|
diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java
|
|
index ee0331a6bc40cdde08d926fd8eb1dc642630c2e5..bafa781ea77afa159576afca3449bacb01ab387d 100644
|
|
--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java
|
|
+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java
|
|
@@ -1149,7 +1149,7 @@ public final class CollisionUtil {
|
|
}
|
|
|
|
private static final MergedVoxelCoordinateList EMPTY = new MergedVoxelCoordinateList(
|
|
- new double[] { 0.0 }, 0.0, new int[0], new int[0], 0
|
|
+ new double[] { 0.0 }, 0.0, org.plazmamc.plazma.constants.Empty.INT, org.plazmamc.plazma.constants.Empty.INT, 0 // Plazma - Reduce allocations
|
|
);
|
|
|
|
private static int[] getIndices(final int length) {
|
|
diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
|
|
index c78cbec447032de9fe69748591bef6be300160ed..8ca248e844e73685a8d44a966144657315a799aa 100644
|
|
--- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
|
|
+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
|
|
@@ -304,7 +304,7 @@ public final class ChunkEntitySlices {
|
|
|
|
protected static final class BasicEntityList<E extends Entity> {
|
|
|
|
- protected static final Entity[] EMPTY = new Entity[0];
|
|
+ //protected static final Entity[] EMPTY = new Entity[0]; // Plazma - Reduce allocations
|
|
protected static final int DEFAULT_CAPACITY = 4;
|
|
|
|
protected E[] storage;
|
|
@@ -315,7 +315,7 @@ public final class ChunkEntitySlices {
|
|
}
|
|
|
|
public BasicEntityList(final int cap) {
|
|
- this.storage = (E[])(cap <= 0 ? EMPTY : new Entity[cap]);
|
|
+ this.storage = (E[])(cap <= 0 ? org.plazmamc.plazma.constants.Empty.ENTITY : new Entity[cap]);
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
@@ -327,7 +327,7 @@ public final class ChunkEntitySlices {
|
|
}
|
|
|
|
private void resize() {
|
|
- if (this.storage == EMPTY) {
|
|
+ if (this.storage == org.plazmamc.plazma.constants.Empty.ENTITY) {
|
|
this.storage = (E[])new Entity[DEFAULT_CAPACITY];
|
|
} else {
|
|
this.storage = Arrays.copyOf(this.storage, this.storage.length * 2);
|
|
diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java
|
|
index c5a3f9c2daf3da135cccecb757353534e1688821..e5585c6befeef62ecf130e8dabbe6b78f9e90a65 100644
|
|
--- a/src/main/java/net/minecraft/CrashReport.java
|
|
+++ b/src/main/java/net/minecraft/CrashReport.java
|
|
@@ -30,7 +30,7 @@ public class CrashReport {
|
|
@Nullable
|
|
private File saveFile;
|
|
private boolean trackingStackTrace = true;
|
|
- private StackTraceElement[] uncategorizedStackTrace = new StackTraceElement[0];
|
|
+ private StackTraceElement[] uncategorizedStackTrace = org.plazmamc.plazma.constants.Empty.TRACE; // Plazma - Reduce allocations
|
|
private final SystemReport systemReport = new SystemReport();
|
|
|
|
public CrashReport(String message, Throwable cause) {
|
|
diff --git a/src/main/java/net/minecraft/CrashReportCategory.java b/src/main/java/net/minecraft/CrashReportCategory.java
|
|
index 2176171954609fd88f97f93408e14e018c1d6eaa..2a5576dc66a9b1f56e06ba47bef4fe882935c382 100644
|
|
--- a/src/main/java/net/minecraft/CrashReportCategory.java
|
|
+++ b/src/main/java/net/minecraft/CrashReportCategory.java
|
|
@@ -12,7 +12,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|
public class CrashReportCategory {
|
|
private final String title;
|
|
private final List<CrashReportCategory.Entry> entries = Lists.newArrayList();
|
|
- private StackTraceElement[] stackTrace = new StackTraceElement[0];
|
|
+ private StackTraceElement[] stackTrace = org.plazmamc.plazma.constants.Empty.TRACE; // Plazma - Reduce allocations
|
|
|
|
public CrashReportCategory(String title) {
|
|
this.title = title;
|
|
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
|
index 01a12f4d6f3c2f09bffc78692443b9fd391db45a..9a6e4538dd09263544f39c93f5f1480dc589fb4d 100644
|
|
--- a/src/main/java/net/minecraft/Util.java
|
|
+++ b/src/main/java/net/minecraft/Util.java
|
|
@@ -409,7 +409,7 @@ public class Util {
|
|
} else if (futures.size() == 1) {
|
|
return futures.get(0).thenApply(List::of);
|
|
} else {
|
|
- CompletableFuture<Void> completableFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
|
+ CompletableFuture<Void> completableFuture = CompletableFuture.allOf(futures.toArray(org.plazmamc.plazma.constants.Empty.FUTURE)); // Plazma - Reduce allocations
|
|
return completableFuture.thenApply(void_ -> futures.stream().map(CompletableFuture::join).toList());
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/nbt/ByteArrayTag.java b/src/main/java/net/minecraft/nbt/ByteArrayTag.java
|
|
index 06648f9751fd8a322d0809ffebf6a544596ee1a4..b0ea87e2ed8f9bf04b33c2ff8a827d4f6f57a435 100644
|
|
--- a/src/main/java/net/minecraft/nbt/ByteArrayTag.java
|
|
+++ b/src/main/java/net/minecraft/nbt/ByteArrayTag.java
|
|
@@ -175,7 +175,7 @@ public class ByteArrayTag extends CollectionTag<ByteTag> {
|
|
}
|
|
|
|
public void clear() {
|
|
- this.data = new byte[0];
|
|
+ this.data = org.plazmamc.plazma.constants.Empty.BYTE; // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
|
index 23916b011ed0645ab284fb080c9555921290d875..2abe6c8dcbf20bf550bb790fd4e18ccc848d1065 100644
|
|
--- a/src/main/java/net/minecraft/nbt/CompoundTag.java
|
|
+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
|
@@ -409,7 +409,7 @@ public class CompoundTag implements Tag {
|
|
throw new ReportedException(this.createReport(key, ByteArrayTag.TYPE, var3));
|
|
}
|
|
|
|
- return new byte[0];
|
|
+ return org.plazmamc.plazma.constants.Empty.BYTE; // Plazma - Reduce allocations
|
|
}
|
|
|
|
public int[] getIntArray(String key) {
|
|
@@ -421,7 +421,7 @@ public class CompoundTag implements Tag {
|
|
throw new ReportedException(this.createReport(key, IntArrayTag.TYPE, var3));
|
|
}
|
|
|
|
- return new int[0];
|
|
+ return org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations
|
|
}
|
|
|
|
public long[] getLongArray(String key) {
|
|
@@ -433,7 +433,7 @@ public class CompoundTag implements Tag {
|
|
throw new ReportedException(this.createReport(key, LongArrayTag.TYPE, var3));
|
|
}
|
|
|
|
- return new long[0];
|
|
+ return org.plazmamc.plazma.constants.Empty.LONG; // Plazma - Reduce allocations
|
|
}
|
|
|
|
public CompoundTag getCompound(String key) {
|
|
diff --git a/src/main/java/net/minecraft/nbt/IntArrayTag.java b/src/main/java/net/minecraft/nbt/IntArrayTag.java
|
|
index ff13d67151c50ea11a45117e524c7524e2b1a202..5048ec707c147b9a5b2dd8736d518d938ba95df0 100644
|
|
--- a/src/main/java/net/minecraft/nbt/IntArrayTag.java
|
|
+++ b/src/main/java/net/minecraft/nbt/IntArrayTag.java
|
|
@@ -186,7 +186,7 @@ public class IntArrayTag extends CollectionTag<IntTag> {
|
|
}
|
|
|
|
public void clear() {
|
|
- this.data = new int[0];
|
|
+ this.data = org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java
|
|
index 24ad8d22b5180cd7d7f793e3074e438f9192448f..c902b478d331a1cad9ac66a6eeb66c19fbcd8789 100644
|
|
--- a/src/main/java/net/minecraft/nbt/ListTag.java
|
|
+++ b/src/main/java/net/minecraft/nbt/ListTag.java
|
|
@@ -279,7 +279,7 @@ public class ListTag extends CollectionTag<Tag> {
|
|
}
|
|
}
|
|
|
|
- return new int[0];
|
|
+ return org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations
|
|
}
|
|
|
|
public long[] getLongArray(int index) {
|
|
@@ -291,7 +291,7 @@ public class ListTag extends CollectionTag<Tag> {
|
|
}
|
|
}
|
|
|
|
- return new long[0];
|
|
+ return org.plazmamc.plazma.constants.Empty.LONG; // Plazma - Reduce allocations
|
|
}
|
|
|
|
public double getDouble(int index) {
|
|
diff --git a/src/main/java/net/minecraft/nbt/LongArrayTag.java b/src/main/java/net/minecraft/nbt/LongArrayTag.java
|
|
index 2e5c34ebb94a1536cf09d71bdf052a49ecb9159d..144d3bbe80fc0f459a06017a19929e3e849aabd0 100644
|
|
--- a/src/main/java/net/minecraft/nbt/LongArrayTag.java
|
|
+++ b/src/main/java/net/minecraft/nbt/LongArrayTag.java
|
|
@@ -185,7 +185,7 @@ public class LongArrayTag extends CollectionTag<LongTag> {
|
|
|
|
@Override
|
|
public void clear() {
|
|
- this.data = new long[0];
|
|
+ this.data = org.plazmamc.plazma.constants.Empty.LONG; // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/nbt/NbtIo.java b/src/main/java/net/minecraft/nbt/NbtIo.java
|
|
index c2044d2e8ce2d4747aa73ba90e5b975b1b7d2c19..b4e043379ece86ce39eacd4c1eb9114a2b6727ca 100644
|
|
--- a/src/main/java/net/minecraft/nbt/NbtIo.java
|
|
+++ b/src/main/java/net/minecraft/nbt/NbtIo.java
|
|
@@ -249,7 +249,7 @@ public class NbtIo {
|
|
|
|
@Nullable
|
|
public static CompoundTag read(Path path) throws IOException {
|
|
- if (!Files.exists(path, new LinkOption[0])) {
|
|
+ if (!Files.exists(path/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations
|
|
return null;
|
|
} else {
|
|
InputStream inputstream = Files.newInputStream(path);
|
|
diff --git a/src/main/java/net/minecraft/network/CipherBase.java b/src/main/java/net/minecraft/network/CipherBase.java
|
|
index a2920b8a9eff77d9c5d1d7f70ad3abdacba8f0fa..70d776d5cfdb0612f65d92333d6f872afedc2207 100644
|
|
--- a/src/main/java/net/minecraft/network/CipherBase.java
|
|
+++ b/src/main/java/net/minecraft/network/CipherBase.java
|
|
@@ -7,8 +7,8 @@ import javax.crypto.ShortBufferException;
|
|
|
|
public class CipherBase {
|
|
private final Cipher cipher;
|
|
- private byte[] heapIn = new byte[0];
|
|
- private byte[] heapOut = new byte[0];
|
|
+ private byte[] heapIn = org.plazmamc.plazma.constants.Empty.BYTE; // Plazma - Reduce allocations
|
|
+ private byte[] heapOut = org.plazmamc.plazma.constants.Empty.BYTE; // Plazma - Reduce allocations
|
|
|
|
protected CipherBase(Cipher cipher) {
|
|
this.cipher = cipher;
|
|
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
|
index 9e31954212b1d6162dca2fbc91d373e908560335..5e7b4363e6f83d4145954a96d6b6b610d392c7d1 100644
|
|
--- a/src/main/java/net/minecraft/network/Connection.java
|
|
+++ b/src/main/java/net/minecraft/network/Connection.java
|
|
@@ -322,7 +322,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
|
}
|
|
|
|
public void setListener(PacketListener packetListener) {
|
|
- Validate.notNull(packetListener, "packetListener", new Object[0]);
|
|
+ Validate.notNull(packetListener, "packetListener"/*, new Object[0]*/); // Plazma - Reduce allocations
|
|
PacketFlow enumprotocoldirection = packetListener.flow();
|
|
|
|
if (enumprotocoldirection != this.receiving) {
|
|
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
|
index d3a80d0a23be762c05931ae8001d98e43cab2b4a..a94feef330b1836a2fc009405c52945551b7590a 100644
|
|
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
|
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
|
@@ -191,7 +191,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
}
|
|
|
|
static MutableComponent translatable(String key) {
|
|
- return MutableComponent.create(new TranslatableContents(key, (String) null, TranslatableContents.NO_ARGS));
|
|
+ return MutableComponent.create(new TranslatableContents(key, (String) null, org.plazmamc.plazma.constants.Empty.OBJECT)); // Plazma - Reduce allocations
|
|
}
|
|
|
|
static MutableComponent translatable(String key, Object... args) {
|
|
@@ -211,7 +211,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
}
|
|
|
|
static MutableComponent translatableWithFallback(String key, @Nullable String fallback) {
|
|
- return MutableComponent.create(new TranslatableContents(key, fallback, TranslatableContents.NO_ARGS));
|
|
+ return MutableComponent.create(new TranslatableContents(key, fallback, org.plazmamc.plazma.constants.Empty.OBJECT)); // Plazma - Reduce allocations
|
|
}
|
|
|
|
static MutableComponent translatableWithFallback(String key, @Nullable String fallback, Object... args) {
|
|
diff --git a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
|
index 18e53db59082bae94922edc4baa812aa6f089576..c922919e15a4157b7a46728caa4a7df0b5fcce1f 100644
|
|
--- a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
|
+++ b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
|
@@ -29,7 +29,7 @@ import net.minecraft.util.ExtraCodecs;
|
|
import net.minecraft.world.entity.Entity;
|
|
|
|
public class TranslatableContents implements ComponentContents {
|
|
- public static final Object[] NO_ARGS = new Object[0];
|
|
+ // public static final Object[] NO_ARGS = new Object[0]; // Plazma - Reduce allocations
|
|
private static final Codec<Object> PRIMITIVE_ARG_CODEC = ExtraCodecs.validate(ExtraCodecs.JAVA, TranslatableContents::filterAllowedArguments);
|
|
private static final Codec<Object> ARG_CODEC = Codec.either(PRIMITIVE_ARG_CODEC, ComponentSerialization.CODEC)
|
|
.xmap(
|
|
@@ -69,7 +69,7 @@ public class TranslatableContents implements ComponentContents {
|
|
}
|
|
|
|
private static Object[] adjustArgs(Optional<List<Object>> args) {
|
|
- return args.<Object[]>map(list -> list.isEmpty() ? NO_ARGS : list.toArray()).orElse(NO_ARGS);
|
|
+ return args.<Object[]>map(list -> list.isEmpty() ? org.plazmamc.plazma.constants.Empty.OBJECT : list.toArray()).orElse(org.plazmamc.plazma.constants.Empty.OBJECT);
|
|
}
|
|
|
|
private static TranslatableContents create(String key, Optional<String> fallback, Optional<List<Object>> args) {
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
|
|
index ccdc2345465313991f065e1176b58fb7d5e8722f..bb50e69a4d84e4753db77be071cc6fc73b08a981 100644
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
|
|
@@ -63,7 +63,7 @@ public class ClientboundSectionBlocksUpdatePacket implements Packet<ClientGamePa
|
|
public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, it.unimi.dsi.fastutil.shorts.Short2ObjectMap<BlockState> blockChanges) {
|
|
this.sectionPos = sectionPos;
|
|
this.positions = blockChanges.keySet().toShortArray();
|
|
- this.states = blockChanges.values().toArray(new BlockState[0]);
|
|
+ this.states = blockChanges.values().toArray(org.plazmamc.plazma.constants.Empty.BLOCK_STATE); // Plazma - Reduce allocations
|
|
}
|
|
// Paper end - Multi Block Change API
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index ac12ccf60b45b150982e79f32d3cdd21c4017cc8..1032916def98f0607fabb1bbb550ba2ff70b3019 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1499,13 +1499,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
}
|
|
|
|
private Optional<ServerStatus.Favicon> loadStatusIcon() {
|
|
- Optional<Path> optional = Optional.of(this.getFile("server-icon.png").toPath()).filter((path) -> {
|
|
- return Files.isRegularFile(path, new LinkOption[0]);
|
|
- }).or(() -> {
|
|
- return this.storageSource.getIconFile().filter((path) -> {
|
|
- return Files.isRegularFile(path, new LinkOption[0]);
|
|
- });
|
|
- });
|
|
+ // Plazma start - Reduce allocations
|
|
+ Optional<Path> optional = Optional.of(this.getFile("server-icon.png").toPath()).filter(Files::isRegularFile)
|
|
+ .or(() -> this.storageSource.getIconFile().filter(Files::isRegularFile));
|
|
+ // Plazma end
|
|
|
|
return optional.flatMap((path) -> {
|
|
try {
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
|
index ba8a8575af92541cef2e116743d51cd68d1e794a..140079be22acbb898720c538c4ffb06194da0860 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
|
@@ -130,7 +130,7 @@ public class PlayerAdvancements {
|
|
}
|
|
|
|
private void load(ServerAdvancementManager advancementLoader) {
|
|
- if (Files.isRegularFile(this.playerSavePath, new LinkOption[0])) {
|
|
+ if (Files.isRegularFile(this.playerSavePath/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations
|
|
try {
|
|
JsonReader jsonreader = new JsonReader(Files.newBufferedReader(this.playerSavePath, StandardCharsets.UTF_8));
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/RunningOnDifferentThreadException.java b/src/main/java/net/minecraft/server/RunningOnDifferentThreadException.java
|
|
index 0f52e8a61ca7e57e9f52473dceb9cc3464c0c86d..f54bde32760541a653460682e5a3ddd0b2ceec51 100644
|
|
--- a/src/main/java/net/minecraft/server/RunningOnDifferentThreadException.java
|
|
+++ b/src/main/java/net/minecraft/server/RunningOnDifferentThreadException.java
|
|
@@ -4,12 +4,12 @@ public final class RunningOnDifferentThreadException extends RuntimeException {
|
|
public static final RunningOnDifferentThreadException RUNNING_ON_DIFFERENT_THREAD = new RunningOnDifferentThreadException();
|
|
|
|
private RunningOnDifferentThreadException() {
|
|
- this.setStackTrace(new StackTraceElement[0]);
|
|
+ this.setStackTrace(org.plazmamc.plazma.constants.Empty.TRACE); // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Override
|
|
public synchronized Throwable fillInStackTrace() {
|
|
- this.setStackTrace(new StackTraceElement[0]);
|
|
+ this.setStackTrace(org.plazmamc.plazma.constants.Empty.TRACE); // Plazma - Reduce allocations
|
|
return this;
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/ServerFunctionLibrary.java b/src/main/java/net/minecraft/server/ServerFunctionLibrary.java
|
|
index bae0d208b31aa0a6977c30f2f8484ab3c316bc71..981c3023044f3cc6dc22ada20cd4bedcf7a28db3 100644
|
|
--- a/src/main/java/net/minecraft/server/ServerFunctionLibrary.java
|
|
+++ b/src/main/java/net/minecraft/server/ServerFunctionLibrary.java
|
|
@@ -92,7 +92,7 @@ public class ServerFunctionLibrary implements PreparableReloadListener {
|
|
}, prepareExecutor));
|
|
}
|
|
|
|
- CompletableFuture<?>[] completableFutures = map.values().toArray(new CompletableFuture[0]);
|
|
+ CompletableFuture<?>[] completableFutures = map.values().toArray(org.plazmamc.plazma.constants.Empty.FUTURE); // Plazma - Reduce allocations
|
|
return CompletableFuture.allOf(completableFutures).handle((unused, ex) -> map);
|
|
}
|
|
);
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
index bb412ca874b85d777c0e3565fcefcee15b23182b..9116b3d298a9bb6e550d299f76ff1243da824cbe 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
@@ -109,6 +109,7 @@ import org.bukkit.craftbukkit.generator.CustomChunkGenerator;
|
|
|
|
public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider {
|
|
|
|
+ private static final ServerPlayerConnection[] EMPTY_CONNECTION = new ServerPlayerConnection[0]; // Plazma - Reduce allocations
|
|
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
|
|
private static final byte CHUNK_TYPE_UNKNOWN = 0;
|
|
private static final byte CHUNK_TYPE_FULL = 1;
|
|
@@ -1347,7 +1348,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
// stuff could have been removed, so we need to check the trackedPlayers set
|
|
// for players that were removed
|
|
|
|
- for (ServerPlayerConnection conn : this.seenBy.toArray(new ServerPlayerConnection[0])) { // avoid CME
|
|
+ for (ServerPlayerConnection conn : this.seenBy.toArray(EMPTY_CONNECTION)) { // avoid CME // Plazma - Reduce allocations
|
|
if (newTrackerCandidates == null || !newTrackerCandidates.contains(conn.getPlayer())) {
|
|
this.updatePlayer(conn.getPlayer());
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 00ac2902be93327c7dd1bf78ee5922d7954f1b26..2ac8c77684c2e4cfc30bc0d39bcaf853dcd3bfb9 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1449,7 +1449,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
|
|
public static List<Entity> getCurrentlyTickingEntities() {
|
|
Entity ticking = currentlyTickingEntity.get();
|
|
- List<Entity> ret = java.util.Arrays.asList(ticking == null ? new Entity[0] : new Entity[] { ticking });
|
|
+ List<Entity> ret = java.util.Arrays.asList(ticking == null ? org.plazmamc.plazma.constants.Empty.ENTITY : new Entity[] { ticking }); // Plazma - Reduce allocations
|
|
|
|
return ret;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
index 8b62f992ec61d0a66a3856b4928ee2d705548291..c0729d3a38e0b9924711c0ca96afd138fa69fa3b 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
@@ -138,8 +138,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
|
|
|
@Override
|
|
public void handleHello(ServerboundHelloPacket packet) {
|
|
- Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]);
|
|
- if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation) Validate.validState(Player.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); // Paper - config username validation
|
|
+ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet"/*, new Object[0]*/); // Plazma - Reduce allocations
|
|
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation) Validate.validState(Player.isValidUsername(packet.name()), "Invalid characters in username"/*, new Object[0]*/); // Paper - config username validation // Plazma - Reduce allocations
|
|
this.requestedUsername = packet.name();
|
|
GameProfile gameprofile = this.server.getSingleplayerProfile();
|
|
|
|
@@ -223,7 +223,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
|
|
|
@Override
|
|
public void handleKey(ServerboundKeyPacket packet) {
|
|
- Validate.validState(this.state == ServerLoginPacketListenerImpl.State.KEY, "Unexpected key packet", new Object[0]);
|
|
+ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.KEY, "Unexpected key packet"/*, new Object[0]*/); // Plazma - Reduce allocations
|
|
|
|
final String s;
|
|
|
|
@@ -403,7 +403,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
|
|
|
@Override
|
|
public void handleLoginAcknowledgement(ServerboundLoginAcknowledgedPacket packet) {
|
|
- Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet", new Object[0]);
|
|
+ Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet"/*, new Object[0]*/); // Plazma - Reduce allocations
|
|
CommonListenerCookie commonlistenercookie = CommonListenerCookie.createInitial((GameProfile) Objects.requireNonNull(this.authenticatedProfile));
|
|
ServerConfigurationPacketListenerImpl serverconfigurationpacketlistenerimpl = new ServerConfigurationPacketListenerImpl(this.server, this.connection, commonlistenercookie, this.player); // CraftBukkit
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index ac1e0c66f167218306504db6037cc1d6509072a0..60aa2984e490374ab2659f9d0a4821f1ea17c700 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -133,6 +133,7 @@ public abstract class PlayerList {
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
private static final int SEND_PLAYER_INFO_INTERVAL = 600;
|
|
private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
|
|
+ private static final org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag[] EMPTY_FLAG = new org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag[0]; // Plazma - Reduce allocations
|
|
private final MinecraftServer server;
|
|
public final List<ServerPlayer> players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety
|
|
private final Map<UUID, ServerPlayer> playersByUUID = Maps.newHashMap();
|
|
@@ -816,7 +817,7 @@ public abstract class PlayerList {
|
|
|
|
public ServerPlayer respawn(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation, RespawnReason reason) {
|
|
// Paper start - Expand PlayerRespawnEvent
|
|
- return respawn(entityplayer, worldserver, flag, location, avoidSuffocation, reason, new org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag[0]);
|
|
+ return respawn(entityplayer, worldserver, flag, location, avoidSuffocation, reason, EMPTY_FLAG); // Plazma - Reduce allocations
|
|
}
|
|
|
|
public ServerPlayer respawn(ServerPlayer entityplayer, ServerLevel worldserver, boolean flag, Location location, boolean avoidSuffocation, RespawnReason reason, org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag...respawnFlags) {
|
|
diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java
|
|
index 7e133752ccb1ea7c0b4fa781feb1a88e2cfdcf6d..1289e8e9c54a584f5037ea8e852df37376af093d 100644
|
|
--- a/src/main/java/net/minecraft/server/players/StoredUserList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/StoredUserList.java
|
|
@@ -76,7 +76,7 @@ public abstract class StoredUserList<K, V extends StoredUserEntry<K>> {
|
|
}
|
|
|
|
public String[] getUserList() {
|
|
- return (String[]) this.map.keySet().toArray(new String[0]);
|
|
+ return this.map.keySet().toArray(org.plazmamc.plazma.constants.Empty.STRING); // Plazma - Reduce allocations
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
diff --git a/src/main/java/net/minecraft/util/MemoryReserve.java b/src/main/java/net/minecraft/util/MemoryReserve.java
|
|
index 0ee04fe6ff6a4d09754f326526ae04fe7226bab2..5663ce568a1daa638b7387bee8b9917ce1f64d14 100644
|
|
--- a/src/main/java/net/minecraft/util/MemoryReserve.java
|
|
+++ b/src/main/java/net/minecraft/util/MemoryReserve.java
|
|
@@ -11,6 +11,6 @@ public class MemoryReserve {
|
|
}
|
|
|
|
public static void release() {
|
|
- reserve = new byte[0];
|
|
+ reserve = org.plazmamc.plazma.constants.Empty.BYTE; // Plazma - Reduce allocations
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
|
index 01f5b946fabbe34f31110e75973dab9f39897346..2564c21900df7ca3c58872741ec8f68bce80a903 100644
|
|
--- a/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
|
+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
|
@@ -5,7 +5,7 @@ import java.util.function.IntConsumer;
|
|
import org.apache.commons.lang3.Validate;
|
|
|
|
public class ZeroBitStorage implements BitStorage {
|
|
- public static final long[] RAW = new long[0];
|
|
+ // public static final long[] RAW = new long[0]; // Plazma - Reduce allocations
|
|
private final int size;
|
|
|
|
public ZeroBitStorage(int size) {
|
|
@@ -33,7 +33,7 @@ public class ZeroBitStorage implements BitStorage {
|
|
|
|
@Override
|
|
public long[] getRaw() {
|
|
- return RAW;
|
|
+ return org.plazmamc.plazma.constants.Empty.LONG; // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
index 997ab942be9f742804041b07d607e7dd6473ba96..14a61e58987464d7865caf98e6232fb1334c6d88 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
|
@@ -251,7 +251,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
|
this.goalSelector.addGoal(8, new Bee.BeeWanderGoal());
|
|
this.goalSelector.addGoal(9, new FloatGoal(this));
|
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
|
- this.targetSelector.addGoal(1, (new Bee.BeeHurtByOtherGoal(this)).setAlertOthers(new Class[0]));
|
|
+ this.targetSelector.addGoal(1, (new Bee.BeeHurtByOtherGoal(this)).setAlertOthers(/*new Class[0]*/)); // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(2, new Bee.BeeBecomeAngryTargetGoal(this));
|
|
this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
|
|
index 442eb602f5c82550a87e218e2013171b718abd62..b68f7d1fba18cf08a1844a179f07cb6d873c236b 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
|
|
@@ -122,7 +122,7 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
|
|
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
|
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
|
this.targetSelector.addGoal(1, new DefendVillageTargetGoal(this));
|
|
- this.targetSelector.addGoal(2, new HurtByTargetGoal(this, new Class[0]));
|
|
+ this.targetSelector.addGoal(2, new HurtByTargetGoal(this/*, new Class[0]*/)); // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt));
|
|
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Mob.class, 5, false, false, (entityliving) -> {
|
|
return entityliving instanceof Enemy && !(entityliving instanceof Creeper);
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Panda.java b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
|
index adfa18c941b5070692ed855d1d609993ca49a01d..b44e752b4fa18d25ca7ac989b1eaacc138512848 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
|
@@ -340,7 +340,7 @@ public class Panda extends Animal {
|
|
this.goalSelector.addGoal(13, new FollowParentGoal(this, 1.25D));
|
|
this.goalSelector.addGoal(14, new WaterAvoidingRandomStrollGoal(this, 1.0D));
|
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
|
- this.targetSelector.addGoal(1, (new Panda.PandaHurtByTargetGoal(this, new Class[0])).setAlertOthers(new Class[0]));
|
|
+ this.targetSelector.addGoal(1, (new Panda.PandaHurtByTargetGoal(this/*, new Class[0]*/)).setAlertOthers(/*new Class[0]*/)); // Plazma - Reduce allocations
|
|
}
|
|
|
|
public static AttributeSupplier.Builder createAttributes() {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Rabbit.java b/src/main/java/net/minecraft/world/entity/animal/Rabbit.java
|
|
index eae2488f2a46e543b496b7a2919aabbb55dcb825..3383d61551f28b44943c0e935aedfa3cc9ac7e93 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Rabbit.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Rabbit.java
|
|
@@ -461,7 +461,7 @@ public class Rabbit extends Animal implements VariantHolder<Rabbit.Variant> {
|
|
if (variant == Rabbit.Variant.EVIL) {
|
|
this.getAttribute(Attributes.ARMOR).setBaseValue(8.0D);
|
|
this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.4D, true));
|
|
- this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers());
|
|
+ this.targetSelector.addGoal(1, (new HurtByTargetGoal(this/*,new Class[0]*/)).setAlertOthers()); // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
|
|
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Wolf.class, true));
|
|
if (!this.hasCustomName()) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
|
|
index a90055fe8819a32180754b6060a0f88e81d1a3b6..68825a2ad5a6ea1b0784a935206bd150d29e25f9 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
|
|
@@ -241,7 +241,7 @@ public class Wolf extends TamableAnimal implements NeutralMob {
|
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
|
this.targetSelector.addGoal(1, new OwnerHurtByTargetGoal(this));
|
|
this.targetSelector.addGoal(2, new OwnerHurtTargetGoal(this));
|
|
- this.targetSelector.addGoal(3, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers());
|
|
+ this.targetSelector.addGoal(3, (new HurtByTargetGoal(this/*, new Class[0]*/)).setAlertOthers()); // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt));
|
|
// this.targetSelector.addGoal(5, new NonTameRandomTargetGoal<>(this, Animal.class, false, Wolf.PREY_SELECTOR)); // Purpur - moved to updatePathfinders()
|
|
this.targetSelector.addGoal(6, new NonTameRandomTargetGoal<>(this, Turtle.class, false, Turtle.BABY_ON_LAND_SELECTOR));
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
|
index c783ce59ea766e6c46a3313628b961f27e01ee8b..518660609566ffe943103b305472590ee9f0a257 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
|
@@ -84,7 +84,7 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
|
private static final EntityDataAccessor<Boolean> DATA_DANCING = SynchedEntityData.defineId(Allay.class, EntityDataSerializers.BOOLEAN);
|
|
private static final EntityDataAccessor<Boolean> DATA_CAN_DUPLICATE = SynchedEntityData.defineId(Allay.class, EntityDataSerializers.BOOLEAN);
|
|
protected static final ImmutableList<SensorType<? extends Sensor<? super Allay>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.HURT_BY, SensorType.NEAREST_ITEMS);
|
|
- protected static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.PATH, MemoryModuleType.LOOK_TARGET, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.HURT_BY, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.LIKED_PLAYER, MemoryModuleType.LIKED_NOTEBLOCK_POSITION, MemoryModuleType.LIKED_NOTEBLOCK_COOLDOWN_TICKS, MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS, MemoryModuleType.IS_PANICKING, new MemoryModuleType[0]);
|
|
+ protected static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.PATH, MemoryModuleType.LOOK_TARGET, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.HURT_BY, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.LIKED_PLAYER, MemoryModuleType.LIKED_NOTEBLOCK_POSITION, MemoryModuleType.LIKED_NOTEBLOCK_COOLDOWN_TICKS, MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS, MemoryModuleType.IS_PANICKING/*, new MemoryModuleType[0]*/); // Plazma - Reduce allocations
|
|
public static final ImmutableList<Float> THROW_SOUND_PITCHES = ImmutableList.of(0.5625F, 0.625F, 0.75F, 0.9375F, 1.0F, 1.0F, 1.125F, 1.25F, 1.5F, 1.875F, 2.0F, 2.25F, new Float[]{2.5F, 3.0F, 3.75F, 4.0F});
|
|
private final DynamicGameEventListener<VibrationSystem.Listener> dynamicVibrationListener;
|
|
private VibrationSystem.Data vibrationData;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
|
index 1d896c6c49705acd87416dc11a1d8ce205f7844e..6d5c60cf9851fc358f29d25bf5d0de98ff7aeb40 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
|
@@ -255,7 +255,7 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
|
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 8.0F));
|
|
this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
|
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
|
- this.targetSelector.addGoal(1, new HurtByTargetGoal(this, new Class[0]));
|
|
+ this.targetSelector.addGoal(1, new HurtByTargetGoal(this/*, new Class[0]*/)); // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, LivingEntity.class, 0, false, false, WitherBoss.LIVING_ENTITY_SELECTOR));
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
|
|
index a00646bc8a9caefe56e48b7682e8fb0c464b81fa..a2b5d2f1be493148a0ed102f10fd8b762b8d3981 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
|
|
@@ -79,7 +79,7 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
|
|
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 8.0F));
|
|
this.goalSelector.addGoal(6, new RandomLookAroundGoal(this));
|
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
|
- this.targetSelector.addGoal(1, new HurtByTargetGoal(this, new Class[0]));
|
|
+ this.targetSelector.addGoal(1, new HurtByTargetGoal(this/*, new Class[0]*/)); // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
|
|
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true));
|
|
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR));
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
|
|
index 54315fb84e3289f0ad8305c2c2cec980a5b2c627..5adcb3cb643025de833935ad0b962cf557d354aa 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
|
|
@@ -154,7 +154,7 @@ public class Creeper extends Monster implements PowerableMob {
|
|
this.goalSelector.addGoal(6, new RandomLookAroundGoal(this));
|
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
|
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Player.class, true));
|
|
- this.targetSelector.addGoal(2, new HurtByTargetGoal(this, new Class[0]));
|
|
+ this.targetSelector.addGoal(2, new HurtByTargetGoal(this/*, new Class[0]*/)); // Plazma - Reduce allocations
|
|
}
|
|
|
|
public static AttributeSupplier.Builder createAttributes() {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
|
index 13bc6389652f8868d7539676ee6d85f37ba78f67..6e4dca9074132fc0fb8c90878bf5028729b72367 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
|
@@ -138,7 +138,7 @@ public class EnderMan extends Monster implements NeutralMob {
|
|
this.goalSelector.addGoal(11, new EnderMan.EndermanTakeBlockGoal(this));
|
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
|
this.targetSelector.addGoal(1, new EnderMan.EndermanLookForPlayerGoal(this, this::isAngryAt));
|
|
- this.targetSelector.addGoal(2, new HurtByTargetGoal(this, new Class[0]));
|
|
+ this.targetSelector.addGoal(2, new HurtByTargetGoal(this/*, new Class[0]*/)); // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Endermite.class, 10, true, false, (entityliving) -> entityliving.level().purpurConfig.endermanAggroEndermites && entityliving instanceof Endermite endermite && (!entityliving.level().purpurConfig.endermanAggroEndermitesOnlyIfPlayerSpawned || endermite.isPlayerSpawned()))); // Purpur
|
|
this.targetSelector.addGoal(4, new ResetUniversalAngerTargetGoal<>(this, false));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Silverfish.java b/src/main/java/net/minecraft/world/entity/monster/Silverfish.java
|
|
index 931412a5ab315d4080a9f5209d3e85d78642f4c2..0678c916eb6c7fe4a96d6716980892f80e77b3d8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/Silverfish.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Silverfish.java
|
|
@@ -90,7 +90,7 @@ public class Silverfish extends Monster {
|
|
this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.0D, false));
|
|
this.goalSelector.addGoal(5, new Silverfish.SilverfishMergeWithStoneGoal(this));
|
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
|
- this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers());
|
|
+ this.targetSelector.addGoal(1, (new HurtByTargetGoal(this/*,new Class[0]*/)).setAlertOthers()); // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
|
index b44ffeb4cc0ef63fdd25683f60c5a20fcdeb9135..284aa2340079a4bdf9f1916b28596ea4a06a53ba 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
|
@@ -95,7 +95,7 @@ public class Spider extends Monster {
|
|
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 8.0F));
|
|
this.goalSelector.addGoal(6, new RandomLookAroundGoal(this));
|
|
this.targetSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this)); // Purpur
|
|
- this.targetSelector.addGoal(1, new HurtByTargetGoal(this, new Class[0]));
|
|
+ this.targetSelector.addGoal(1, new HurtByTargetGoal(this/*, new Class[0]*/)); // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(2, new Spider.SpiderTargetGoal<>(this, Player.class));
|
|
this.targetSelector.addGoal(3, new Spider.SpiderTargetGoal<>(this, IronGolem.class));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
|
index c531d830f4d6b2d2213e160d7e1a5b50b80dbea5..18f33b417573417d5e3eb06768d9b59362c2dcf1 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
|
@@ -166,7 +166,7 @@ public class Zombie extends Monster {
|
|
this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0D, false));
|
|
this.goalSelector.addGoal(6, new MoveThroughVillageGoal(this, 1.0D, true, 4, this::canBreakDoors));
|
|
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D));
|
|
- this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers(ZombifiedPiglin.class));
|
|
+ this.targetSelector.addGoal(1, (new HurtByTargetGoal(this/*, new Class[0]*/)).setAlertOthers(ZombifiedPiglin.class)); // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
|
|
// Purpur start
|
|
if ( this.level().spigotConfig.zombieAggressiveTowardsVillager ) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false) { // Spigot
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java b/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java
|
|
index feba8a264bae656244f60296d0511a8046297f73..37dbf8ab18710fdd889073468c52cc0c6fc3ced2 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/ZombifiedPiglin.java
|
|
@@ -120,7 +120,7 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob {
|
|
protected void addBehaviourGoals() {
|
|
this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0D, false));
|
|
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D));
|
|
- this.targetSelector.addGoal(1, pathfinderGoalHurtByTarget = (new HurtByTargetGoal(this, new Class[0])).setAlertOthers()); // Paper - fix PigZombieAngerEvent cancellation
|
|
+ this.targetSelector.addGoal(1, pathfinderGoalHurtByTarget = (new HurtByTargetGoal(this/*, new Class[0]*/)).setAlertOthers()); // Paper - fix PigZombieAngerEvent cancellation // Plazma - Reduce allocations
|
|
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt));
|
|
this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
|
index a097cfc528f709c80575f35483b6878314ea2717..61840d78c4e99e706de56613d13d5741576ad660 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
|
@@ -27,6 +27,7 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo
|
|
final ItemStack result;
|
|
final NonNullList<Ingredient> ingredients;
|
|
private final boolean isBukkit; // Pufferfish
|
|
+ private static final Ingredient[] EMPTY_INGREDIENT = new Ingredient[0]; // Plazma - Reduce allocations
|
|
|
|
// Pufferfish start
|
|
public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, NonNullList<Ingredient> ingredients) {
|
|
@@ -84,7 +85,7 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo
|
|
public boolean matches(CraftingContainer inventory, Level world) {
|
|
// Pufferfish start
|
|
if (!this.isBukkit) {
|
|
- java.util.List<Ingredient> ingredients = com.google.common.collect.Lists.newArrayList(this.ingredients.toArray(new Ingredient[0]));
|
|
+ java.util.List<Ingredient> ingredients = com.google.common.collect.Lists.newArrayList(this.ingredients.toArray(EMPTY_INGREDIENT)); // Plazma - Reduce allocations
|
|
|
|
inventory: for (int index = 0; index < inventory.getContainerSize(); index++) {
|
|
ItemStack itemStack = inventory.getItem(index);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
|
index 47b7baa41f341087bcd5dfec1d2a13b96f8357ca..72e410ad6bed528b7a1febd30079ab39e10fd5ed 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
|
@@ -62,6 +62,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
|
|
|
avoxelshape[8] = avoxelshape[7];
|
|
});
|
|
+ private static final int[] ZERO_INT = new int[]{0}; // Plazma - Reduce allocations // Plazma - Reduce allocations
|
|
|
|
@Override
|
|
public MapCodec<ComposterBlock> codec() {
|
|
@@ -450,7 +451,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
|
|
|
@Override
|
|
public int[] getSlotsForFace(Direction side) {
|
|
- return side == Direction.DOWN ? new int[]{0} : new int[0];
|
|
+ return side == Direction.DOWN ? ZERO_INT : org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Override
|
|
@@ -499,7 +500,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
|
|
|
@Override
|
|
public int[] getSlotsForFace(Direction side) {
|
|
- return side == Direction.UP ? new int[]{0} : new int[0];
|
|
+ return side == Direction.UP ? ZERO_INT : org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Override
|
|
@@ -541,7 +542,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
|
|
|
@Override
|
|
public int[] getSlotsForFace(Direction side) {
|
|
- return new int[0];
|
|
+ return org.plazmamc.plazma.constants.Empty.INT; // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java b/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java
|
|
index a907b79fd8291a0e92db138f37239d17424188a1..a402db6baa4b24b4c6750b01b8b2f56e213ecf78 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkStatus.java
|
|
@@ -148,7 +148,7 @@ public class ChunkStatus {
|
|
}, (chunkstatus, worldserver, structuretemplatemanager, lightenginethreaded, function, ichunkaccess) -> {
|
|
return (CompletableFuture) function.apply(ichunkaccess);
|
|
});
|
|
- private static final List<ChunkStatus> STATUS_BY_RANGE = ImmutableList.of(ChunkStatus.FULL, ChunkStatus.INITIALIZE_LIGHT, ChunkStatus.CARVERS, ChunkStatus.BIOMES, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, new ChunkStatus[0]);
|
|
+ private static final List<ChunkStatus> STATUS_BY_RANGE = ImmutableList.of(ChunkStatus.FULL, ChunkStatus.INITIALIZE_LIGHT, ChunkStatus.CARVERS, ChunkStatus.BIOMES, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS, ChunkStatus.STRUCTURE_STARTS/*, new ChunkStatus[0]*/); // Plazma - Reduce allocations
|
|
private static final IntList RANGE_BY_STATUS = (IntList) Util.make(new IntArrayList(ChunkStatus.getStatusList().size()), (intarraylist) -> {
|
|
int i = 0;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
|
index 6cf83502a954cce9c562ec036bfeddb477d38b73..d28bffce82d0b40c31f240c016621ac06bbad178 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
|
@@ -444,7 +444,7 @@ public class RegionFile implements AutoCloseable {
|
|
initOversizedState(); // Paper
|
|
this.usedSectors = new RegionBitmap();
|
|
this.version = outputChunkStreamVersion;
|
|
- if (!Files.isDirectory(directory, new LinkOption[0])) {
|
|
+ if (!Files.isDirectory(directory/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations
|
|
throw new IllegalArgumentException("Expected directory, got " + directory.toAbsolutePath());
|
|
} else {
|
|
this.externalFileDir = directory;
|
|
@@ -700,7 +700,7 @@ public class RegionFile implements AutoCloseable {
|
|
private DataInputStream createExternalChunkInputStream(ChunkPos pos, byte flags) throws IOException {
|
|
Path path = this.getExternalChunkPath(pos);
|
|
|
|
- if (!Files.isRegularFile(path, new LinkOption[0])) {
|
|
+ if (!Files.isRegularFile(path/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations
|
|
RegionFile.LOGGER.error("External chunk path {} is not file", path);
|
|
return null;
|
|
} else {
|
|
@@ -752,7 +752,7 @@ public class RegionFile implements AutoCloseable {
|
|
return false;
|
|
}
|
|
|
|
- if (!Files.isRegularFile(this.getExternalChunkPath(pos), new LinkOption[0])) {
|
|
+ if (!Files.isRegularFile(this.getExternalChunkPath(pos)/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations
|
|
return false;
|
|
}
|
|
} else {
|
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/DebugLevelSource.java b/src/main/java/net/minecraft/world/level/levelgen/DebugLevelSource.java
|
|
index bf74c054e800104cd47208a29594d3c1340fd668..0320662df9bb039094ecd2bccc94dd59bcdd9d1d 100644
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/DebugLevelSource.java
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/DebugLevelSource.java
|
|
@@ -89,7 +89,7 @@ public class DebugLevelSource extends ChunkGenerator {
|
|
|
|
@Override
|
|
public NoiseColumn getBaseColumn(int x, int z, LevelHeightAccessor world, RandomState noiseConfig) {
|
|
- return new NoiseColumn(0, new BlockState[0]);
|
|
+ return new NoiseColumn(0, org.plazmamc.plazma.constants.Empty.BLOCK_STATE); // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java b/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java
|
|
index 399da9d43aefbb95897df4697860d5bce5317152..df7816c1c5f069d89a22dbd876a2d663ba68949f 100644
|
|
--- a/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java
|
|
+++ b/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java
|
|
@@ -110,7 +110,7 @@ public class LevelStorageSource {
|
|
}
|
|
|
|
public static DirectoryValidator parseValidator(Path allowedSymlinksFile) {
|
|
- if (Files.exists(allowedSymlinksFile, new LinkOption[0])) {
|
|
+ if (Files.exists(allowedSymlinksFile/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations
|
|
try {
|
|
BufferedReader bufferedreader = Files.newBufferedReader(allowedSymlinksFile);
|
|
|
|
@@ -189,7 +189,7 @@ public class LevelStorageSource {
|
|
}
|
|
|
|
public LevelStorageSource.LevelCandidates findLevelCandidates() throws LevelStorageException {
|
|
- if (!Files.isDirectory(this.baseDir, new LinkOption[0])) {
|
|
+ if (!Files.isDirectory(this.baseDir/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations
|
|
throw new LevelStorageException(Component.translatable("selectWorld.load_folder_access"));
|
|
} else {
|
|
try {
|
|
@@ -198,11 +198,12 @@ public class LevelStorageSource {
|
|
LevelStorageSource.LevelCandidates convertable_a;
|
|
|
|
try {
|
|
- List<LevelStorageSource.LevelDirectory> list = stream.filter((path) -> {
|
|
- return Files.isDirectory(path, new LinkOption[0]);
|
|
- }).map(LevelStorageSource.LevelDirectory::new).filter((convertable_b) -> {
|
|
- return Files.isRegularFile(convertable_b.dataFile(), new LinkOption[0]) || Files.isRegularFile(convertable_b.oldDataFile(), new LinkOption[0]);
|
|
- }).toList();
|
|
+ // Plazma start - Reduce allocations
|
|
+ List<LevelStorageSource.LevelDirectory> list = stream.filter(Files::isDirectory)
|
|
+ .map(LevelStorageSource.LevelDirectory::new)
|
|
+ .filter(convertable_b -> Files.isRegularFile(convertable_b.dataFile()) || Files.isRegularFile(convertable_b.oldDataFile()))
|
|
+ .toList();
|
|
+ // Plazma end
|
|
|
|
convertable_a = new LevelStorageSource.LevelCandidates(list);
|
|
} catch (Throwable throwable) {
|
|
@@ -312,7 +313,7 @@ public class LevelStorageSource {
|
|
private LevelSummary readLevelSummary(LevelStorageSource.LevelDirectory save, boolean locked) {
|
|
Path path = save.dataFile();
|
|
|
|
- if (Files.exists(path, new LinkOption[0])) {
|
|
+ if (Files.exists(path/*, new LinkOption[0]*/)) { // Plazma - Reduce allocations
|
|
try {
|
|
if (Files.isSymbolicLink(path)) {
|
|
List<ForbiddenSymlinkInfo> list = this.worldDirValidator.validateSymlink(path);
|
|
@@ -411,7 +412,7 @@ public class LevelStorageSource {
|
|
|
|
public boolean levelExists(String name) {
|
|
try {
|
|
- return Files.isDirectory(this.getLevelPath(name), new LinkOption[0]);
|
|
+ return Files.isDirectory(this.getLevelPath(name)/*, new LinkOption[0]*/); // Plazma - Reduce allocations
|
|
} catch (InvalidPathException invalidpathexception) {
|
|
return false;
|
|
}
|
|
@@ -752,7 +753,7 @@ public class LevelStorageSource {
|
|
}
|
|
|
|
public boolean hasWorldData() {
|
|
- return Files.exists(this.levelDirectory.dataFile(), new LinkOption[0]) || Files.exists(this.levelDirectory.oldDataFile(), new LinkOption[0]);
|
|
+ return Files.exists(this.levelDirectory.dataFile()/*, new LinkOption[0]*/) || Files.exists(this.levelDirectory.oldDataFile()/*, new LinkOption[0]*/); // Plazma - Reduce allocations
|
|
}
|
|
|
|
public void close() throws IOException {
|
|
diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
|
|
index 63e187c65cb855031f286aad0d25ac4694f7a331..e0f085169fafa5e574caf368efa343514540b348 100644
|
|
--- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
|
|
+++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
|
|
@@ -124,7 +124,7 @@ public class PlayerDataStorage {
|
|
String[] astring = this.playerDir.list();
|
|
|
|
if (astring == null) {
|
|
- astring = new String[0];
|
|
+ astring = org.plazmamc.plazma.constants.Empty.STRING; // Plazma - Reduce allocations
|
|
}
|
|
|
|
for (int i = 0; i < astring.length; ++i) {
|
|
diff --git a/src/main/java/net/minecraft/world/scores/Team.java b/src/main/java/net/minecraft/world/scores/Team.java
|
|
index f00791b89fdb1bb0fb358eff2af2e687bda15e85..aa16c93a4333b603729e2704b92f6d38aec0fd7b 100644
|
|
--- a/src/main/java/net/minecraft/world/scores/Team.java
|
|
+++ b/src/main/java/net/minecraft/world/scores/Team.java
|
|
@@ -70,7 +70,7 @@ public abstract class Team {
|
|
public final int id;
|
|
|
|
public static String[] getAllNames() {
|
|
- return BY_NAME.keySet().toArray(new String[0]);
|
|
+ return BY_NAME.keySet().toArray(org.plazmamc.plazma.constants.Empty.STRING); // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Nullable
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index fb2d05e43df3bfb72b1f6e325736dd3cbc6c3096..de4e1d713e5ec182ea8d4832b8359556095ac214 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -426,7 +426,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
public void sendTitle(Title title) {
|
|
Preconditions.checkNotNull(title, "Title is null");
|
|
setTitleTimes(title.getFadeIn(), title.getStay(), title.getFadeOut());
|
|
- setSubtitle(title.getSubtitle() == null ? new BaseComponent[0] : title.getSubtitle());
|
|
+ setSubtitle(title.getSubtitle() == null ? org.plazmamc.plazma.constants.Empty.BASE_COMPONENT : title.getSubtitle()); // Plazma - Reduce allocations
|
|
showTitle(title.getTitle());
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
|
index c5d1ba7a1be3f102edcdfdc05fc50b30ef1f775b..66006d9ff581ac96f13389261de0cd647279b98a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
|
@@ -610,7 +610,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|
throw new IllegalArgumentException("Invalid page number " + page + "/" + CraftMetaBook.this.getPageCount());
|
|
}
|
|
|
|
- BaseComponent[] newText = text == null ? new BaseComponent[0] : text;
|
|
+ BaseComponent[] newText = text == null ? org.plazmamc.plazma.constants.Empty.BASE_COMPONENT : text; // Plazma - Reduce allocations
|
|
CraftMetaBook.this.pages.set(page - 1, this.componentsToPage(newText));
|
|
}
|
|
|
|
@@ -623,7 +623,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|
public void addPage(final BaseComponent[]... pages) {
|
|
for (BaseComponent[] page : pages) {
|
|
if (page == null) {
|
|
- page = new BaseComponent[0];
|
|
+ page = org.plazmamc.plazma.constants.Empty.BASE_COMPONENT; // Plazma - Reduce allocations
|
|
}
|
|
|
|
CraftMetaBook.this.internalAddPage(this.componentsToPage(page));
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java
|
|
index b25dc23b81687dd4d4e70b3615ffb91f8c03c68b..acb98770b9d01e930642a5794f9179660b411c02 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/WeakCollection.java
|
|
@@ -164,7 +164,7 @@ public final class WeakCollection<T> implements Collection<T> {
|
|
|
|
@Override
|
|
public Object[] toArray() {
|
|
- return this.toArray(new Object[0]);
|
|
+ return this.toArray(org.plazmamc.plazma.constants.Empty.OBJECT); // Plazma - Reduce allocations
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/org/plazmamc/plazma/constants/Empty.java b/src/main/java/org/plazmamc/plazma/constants/Empty.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..2b6eb7997986ab73ccb3b1baca945a3234ae916e
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/plazmamc/plazma/constants/Empty.java
|
|
@@ -0,0 +1,20 @@
|
|
+package org.plazmamc.plazma.constants;
|
|
+
|
|
+public interface Empty {
|
|
+
|
|
+ int[] INT = new int[0];
|
|
+ long[] LONG = new long[0];
|
|
+ byte[] BYTE = new byte[0];
|
|
+
|
|
+ Object[] OBJECT = new Object[0];
|
|
+ String[] STRING = new String[0];
|
|
+ StackTraceElement[] TRACE = new StackTraceElement[0];
|
|
+ java.util.concurrent.CompletableFuture<?>[] FUTURE = new java.util.concurrent.CompletableFuture[0];
|
|
+
|
|
+ net.minecraft.world.level.block.state.BlockState[] BLOCK_STATE = new net.minecraft.world.level.block.state.BlockState[0];
|
|
+ net.minecraft.world.entity.Entity[] ENTITY = new net.minecraft.world.entity.Entity[0];
|
|
+
|
|
+ @SuppressWarnings("deprecation")
|
|
+ net.md_5.bungee.api.chat.BaseComponent[] BASE_COMPONENT = new net.md_5.bungee.api.chat.BaseComponent[0];
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/org/purpurmc/purpur/command/PurpurCommand.java b/src/main/java/org/purpurmc/purpur/command/PurpurCommand.java
|
|
index 2621e54879e9ab0029a875f1d09eee67878b90d5..e7e959368c01de69261618d1eb749bebba3527af 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/command/PurpurCommand.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/command/PurpurCommand.java
|
|
@@ -57,7 +57,7 @@ public class PurpurCommand extends Command {
|
|
} else if (args[0].equalsIgnoreCase("version")) {
|
|
Command verCmd = org.bukkit.Bukkit.getServer().getCommandMap().getCommand("version");
|
|
if (verCmd != null) {
|
|
- return verCmd.execute(sender, commandLabel, new String[0]);
|
|
+ return verCmd.execute(sender, commandLabel, org.plazmamc.plazma.constants.Empty.STRING); // Plazma - Reduce allocations
|
|
}
|
|
}
|
|
|