From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Tue, 9 Nov 2021 16:53:39 -0500 Subject: [PATCH] reduce allocs Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0 You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java index c0d123bff1825366c30aadd3ad8a7fde68ef74e4..7764b1f86aca33dc227bf4357c20839b8820eb67 100644 --- a/src/main/java/com/destroystokyo/paper/PaperCommand.java +++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java @@ -214,7 +214,7 @@ public class PaperCommand extends Command { case "version": Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); if (ver != null) { - ver.execute(sender, commandLabel, new String[0]); + ver.execute(sender, commandLabel, me.titaniumtown.Constants.EMPTY_string_arr); // JettPack break; } // else - fall through to default 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..cd5499e750764eaa5e361e73eb581bfce7f9f7c1 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 { this.entityToIndex.defaultReturnValue(Integer.MIN_VALUE); } - protected static final Entity[] EMPTY_LIST = new Entity[0]; + // protected static final Entity[] EMPTY_LIST = new Entity[0]; // JettPack - protected Entity[] entities = EMPTY_LIST; + protected Entity[] entities = me.titaniumtown.Constants.EMPTY_entity_arr; // JettPack 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..27b6dc17a38f80abad2f959c90ffa5ef81635e1a 100644 --- a/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java +++ b/src/main/java/com/destroystokyo/paper/util/maplist/IBlockDataList.java @@ -20,7 +20,7 @@ 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 = me.titaniumtown.Constants.EMPTY_long_arr; // JettPack private long[] byIndex = EMPTY_LIST; private int size; diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java index 47b5f75d9f27cf3ab947fd1f69cbd609fb9f2749..a919e8a2aa10ba01d7f389985591a0681c1b4426 100644 --- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java +++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java @@ -63,7 +63,7 @@ public final class ChunkEntitySlices { } } - return ret.toArray(new org.bukkit.entity.Entity[0]); + return ret.toArray(me.titaniumtown.Constants.EMPTY_bukkit_entity_arr); // JettPack } // Paper end - optimise CraftChunk#getEntities @@ -189,7 +189,7 @@ public final class ChunkEntitySlices { protected static final class BasicEntityList { - protected static final Entity[] EMPTY = new Entity[0]; + // protected static final Entity[] EMPTY = new Entity[0]; // JettPack protected static final int DEFAULT_CAPACITY = 4; protected E[] storage; @@ -200,7 +200,7 @@ public final class ChunkEntitySlices { } public BasicEntityList(final int cap) { - this.storage = (E[])(cap <= 0 ? EMPTY : new Entity[cap]); + this.storage = (E[])(cap <= 0 ? me.titaniumtown.Constants.EMPTY_entity_arr : new Entity[cap]); // JettPack } public boolean isEmpty() { @@ -212,7 +212,7 @@ public final class ChunkEntitySlices { } private void resize() { - if (this.storage == EMPTY) { + if (this.storage == me.titaniumtown.Constants.EMPTY_entity_arr) { // JettPack this.storage = (E[])new Entity[DEFAULT_CAPACITY]; } else { this.storage = Arrays.copyOf(this.storage, this.storage.length * 2); diff --git a/src/main/java/me/titaniumtown/Constants.java b/src/main/java/me/titaniumtown/Constants.java new file mode 100644 index 0000000000000000000000000000000000000000..9ede2f067eacc1d418a8d6223f4052b81410d3b3 --- /dev/null +++ b/src/main/java/me/titaniumtown/Constants.java @@ -0,0 +1,22 @@ +package me.titaniumtown; + +import net.minecraft.core.Direction; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.core.BlockPos; + +public final class Constants { + + public static final Direction[] ALL_Direction = Direction.values(); + public static final Direction[] VERTICAL_Direction = {Direction.DOWN, Direction.UP}; + public static final Direction[] HORIZONTAL_Direction = {Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH}; + public static final Direction.Axis[] ALL_AXIS_Direction = Direction.Axis.values(); + + public static final EquipmentSlot[] ALL_EquipmentSlot = EquipmentSlot.values(); + public static final int[] EMPTY_int_arr = new int[0]; + public static final int[] ZERO_int_arr = new int[]{0}; + public static final byte[] EMPTY_byte_arr = new byte[0]; + public static final String[] EMPTY_string_arr = new String[0]; + public static final long[] EMPTY_long_arr = new long[0]; + public static final org.bukkit.entity.Entity[] EMPTY_bukkit_entity_arr = new org.bukkit.entity.Entity[0]; + public static final net.minecraft.world.entity.Entity[] EMPTY_entity_arr = new net.minecraft.world.entity.Entity[0]; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/ByteArrayTag.java b/src/main/java/net/minecraft/nbt/ByteArrayTag.java index 3dd8a189c26f41759c59c3b9d0e5282038989a9f..147beddf8ef369cdae4b1ed2dcd0d7b2fd865315 100644 --- a/src/main/java/net/minecraft/nbt/ByteArrayTag.java +++ b/src/main/java/net/minecraft/nbt/ByteArrayTag.java @@ -170,7 +170,7 @@ public class ByteArrayTag extends CollectionTag { } public void clear() { - this.data = new byte[0]; + this.data = me.titaniumtown.Constants.EMPTY_byte_arr; // JettPack } @Override diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java index 210f81e380cb38c2d5d69849e593d2fdb54e8856..bf2faf02785689e2296f9bae146f8865fc105c66 100644 --- a/src/main/java/net/minecraft/nbt/CompoundTag.java +++ b/src/main/java/net/minecraft/nbt/CompoundTag.java @@ -365,7 +365,7 @@ public class CompoundTag implements Tag { throw new ReportedException(this.createReport(key, ByteArrayTag.TYPE, var3)); } - return new byte[0]; + return me.titaniumtown.Constants.EMPTY_byte_arr; // JettPack } public int[] getIntArray(String key) { @@ -377,7 +377,7 @@ public class CompoundTag implements Tag { throw new ReportedException(this.createReport(key, IntArrayTag.TYPE, var3)); } - return new int[0]; + return me.titaniumtown.Constants.EMPTY_int_arr; // JettPack } public long[] getLongArray(String key) { @@ -389,7 +389,7 @@ public class CompoundTag implements Tag { throw new ReportedException(this.createReport(key, LongArrayTag.TYPE, var3)); } - return new long[0]; + return me.titaniumtown.Constants.EMPTY_long_arr; // JettPack } 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 a14b01cee7a8d7022c4fa7264d349a76be143ba5..44f441d6c102fa5bd50071cae991a8a6ba0ec713 100644 --- a/src/main/java/net/minecraft/nbt/IntArrayTag.java +++ b/src/main/java/net/minecraft/nbt/IntArrayTag.java @@ -184,7 +184,7 @@ public class IntArrayTag extends CollectionTag { } public void clear() { - this.data = new int[0]; + this.data = me.titaniumtown.Constants.EMPTY_int_arr; // JettPack } @Override diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java index ea68b26e506e48d8238b7ee4266e61b211d52bd2..5d7d160a1e575903999c00da9faf5359949ce1cb 100644 --- a/src/main/java/net/minecraft/nbt/ListTag.java +++ b/src/main/java/net/minecraft/nbt/ListTag.java @@ -221,7 +221,7 @@ public class ListTag extends CollectionTag { } } - return new int[0]; + return me.titaniumtown.Constants.EMPTY_int_arr; // JettPack } public long[] getLongArray(int index) { @@ -232,7 +232,7 @@ public class ListTag extends CollectionTag { } } - return new long[0]; + return me.titaniumtown.Constants.EMPTY_long_arr; // JettPack } public double getDouble(int index) { diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java index e2c8f716af55ebb7e4233c2a3d6515f8f4a239fa..2f5c021b6849acb81064d55418707921424b649b 100644 --- a/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/Main.java @@ -76,7 +76,7 @@ public class Main { OptionSpec optionspec6 = optionparser.accepts("safeMode", "Loads level with vanilla datapack only"); OptionSpec optionspec7 = optionparser.accepts("help").forHelp(); OptionSpec optionspec8 = optionparser.accepts("singleplayer").withRequiredArg(); - OptionSpec optionspec9 = optionparser.accepts("universe").withRequiredArg().defaultsTo(".", new String[0]); + OptionSpec optionspec9 = optionparser.accepts("universe").withRequiredArg().defaultsTo(".", me.titaniumtown.Constants.EMPTY_string_arr); // JettPack OptionSpec optionspec10 = optionparser.accepts("world").withRequiredArg(); OptionSpec optionspec11 = optionparser.accepts("port").withRequiredArg().ofType(Integer.class).defaultsTo(-1, new Integer[0]); OptionSpec optionspec12 = optionparser.accepts("serverId").withRequiredArg(); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java index 91e5784cf6552fc9cfab371756751ea73e206ec1..4fbb9110ce27df22df141fb2c123abf172e51bac 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -76,6 +76,8 @@ public class ServerChunkCache extends ChunkSource { final com.destroystokyo.paper.util.concurrent.WeakSeqLock loadedChunkMapSeqLock = new com.destroystokyo.paper.util.concurrent.WeakSeqLock(); final Long2ObjectOpenHashMap loadedChunkMap = new Long2ObjectOpenHashMap<>(8192, 0.5f); + private final java.util.ArrayList cachedChunkList = new java.util.ArrayList<>(); // JettPack - reduce allocs + private final LevelChunk[] lastLoadedChunks = new LevelChunk[4 * 4]; public boolean firstRunSpawnCounts = true; // Pufferfish @@ -933,6 +935,16 @@ public class ServerChunkCache extends ChunkSource { this.clearCache(); } + // JettPack start - lithium: reduce allocs + private java.util.ArrayList redirectChunksListClone(int initialArraySize) { + java.util.ArrayList list = this.cachedChunkList; + list.clear(); // Ensure the list is empty before re-using it + list.ensureCapacity(initialArraySize); + + return list; + } + // JettPack end + private void tickChunks() { long i = this.level.getGameTime(); long j = i - this.lastInhabitedUpdate; @@ -1024,7 +1036,7 @@ public class ServerChunkCache extends ChunkSource { iterator1 = this.entityTickingChunks.iterator(); } else { iterator1 = this.entityTickingChunks.unsafeIterator(); - List shuffled = Lists.newArrayListWithCapacity(this.entityTickingChunks.size()); + java.util.ArrayList shuffled = this.redirectChunksListClone(this.entityTickingChunks.size()); // JettPack - reduce allocs while (iterator1.hasNext()) { shuffled.add(iterator1.next()); } diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java index e80176708db486190dd527e3ade5fc690ceb39f7..4fa44b576404438d08085e1d8c82fa96206eae50 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java @@ -313,7 +313,7 @@ public class ServerEntity { if (this.entity instanceof LivingEntity) { List> list = Lists.newArrayList(); - EquipmentSlot[] aenumitemslot = EquipmentSlot.values(); + EquipmentSlot[] aenumitemslot = me.titaniumtown.Constants.ALL_EquipmentSlot; // JettPack int i = aenumitemslot.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index 8cdacd7ed9a26e6757eeff89545fde21ddb80fd2..75b885da98b308ed8894fc95e604076d8593461e 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -846,7 +846,7 @@ public class ServerLevel extends Level implements WorldGenLevel { BlockPos blockposition2 = blockposition.set(j + randomX, randomY, k + randomZ); BlockState iblockdata = com.destroystokyo.paper.util.maplist.IBlockDataList.getBlockDataFromRaw(raw); - iblockdata.randomTick(this, blockposition2, this.randomTickRandom); + iblockdata.randomTick(this, blockposition2.immutable(), this.randomTickRandom); // JettPack - reduce allocs // We drop the fluid tick since LAVA is ALREADY TICKED by the above method (See LiquidBlock). // TODO CHECK ON UPDATE } @@ -1099,7 +1099,7 @@ public class ServerLevel extends Level implements WorldGenLevel { public static List getCurrentlyTickingEntities() { Entity ticking = currentlyTickingEntity.get(); - List ret = java.util.Arrays.asList(ticking == null ? new Entity[0] : new Entity[] { ticking }); + List ret = java.util.Arrays.asList(ticking == null ? me.titaniumtown.Constants.EMPTY_entity_arr : new Entity[] { ticking }); // JettPack return ret; } diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java index 3125af569ec2bb1cd613a9dd96c3a181d723006d..534c7a702e96523bd2e3cf0bc20c7c63929b4f07 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -220,7 +220,7 @@ public class ServerPlayerGameMode { if (event.isCancelled()) { // Let the client know the block still exists // Paper start - brute force neighbor blocks for any attached blocks - for (Direction dir : Direction.values()) { + for (Direction dir : me.titaniumtown.Constants.ALL_Direction) { // JettPack this.player.connection.send(new ClientboundBlockUpdatePacket(level, pos.relative(dir))); } // Paper end @@ -407,7 +407,7 @@ public class ServerPlayerGameMode { this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Brute force all possible updates - for (Direction dir : Direction.values()) { + for (Direction dir : me.titaniumtown.Constants.ALL_Direction) { // JettPack this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos.relative(dir))); } diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java index 8982562721c3a5a5a3305e90bd8b5bc21585a425..08ec8433931fc4347b4e679b9359895ade82d7f6 100644 --- a/src/main/java/net/minecraft/server/players/StoredUserList.java +++ b/src/main/java/net/minecraft/server/players/StoredUserList.java @@ -95,7 +95,7 @@ public abstract class StoredUserList> { } public String[] getUserList() { - return (String[]) this.map.keySet().toArray(new String[0]); + return (String[]) this.map.keySet().toArray(me.titaniumtown.Constants.EMPTY_string_arr); // JettPack } // CraftBukkit start diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java index 5d8e9bdf5538b19681f21949368d862fab8a89ad..97c744508cc535418eba65fa722859c81c22d647 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 = me.titaniumtown.Constants.EMPTY_long_arr; // JettPack private final int size; public ZeroBitStorage(int size) { diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index a6681690e1e556440320c492bf2a8e617008baa1..5b0a904673db2eb98296807730ce9454b8740aa9 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3020,7 +3020,7 @@ public abstract class LivingEntity extends Entity { @Nullable private Map collectEquipmentChanges() { Map map = null; - EquipmentSlot[] aenumitemslot = EquipmentSlot.values(); + EquipmentSlot[] aenumitemslot = me.titaniumtown.Constants.ALL_EquipmentSlot; // Jettpack int i = aenumitemslot.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java index 35ff7abd8251b0af6c23fbb63804db632ec5b85d..def1aadb3002441b34bebb24cf727b1b91a688ba 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -1011,7 +1011,7 @@ public abstract class Mob extends LivingEntity { @Override protected void dropCustomDeathLoot(DamageSource source, int lootingMultiplier, boolean allowDrops) { super.dropCustomDeathLoot(source, lootingMultiplier, allowDrops); - EquipmentSlot[] aenumitemslot = EquipmentSlot.values(); + EquipmentSlot[] aenumitemslot = me.titaniumtown.Constants.ALL_EquipmentSlot; // JettPack - reduce allocs int j = aenumitemslot.length; for (int k = 0; k < j; ++k) { @@ -1069,7 +1069,7 @@ public abstract class Mob extends LivingEntity { } boolean flag = true; - EquipmentSlot[] aenumitemslot = EquipmentSlot.values(); + EquipmentSlot[] aenumitemslot = me.titaniumtown.Constants.ALL_EquipmentSlot; // JettPack - reduce allocs int j = aenumitemslot.length; for (int k = 0; k < j; ++k) { @@ -1156,7 +1156,7 @@ public abstract class Mob extends LivingEntity { float f = difficulty.getSpecialMultiplier(); this.enchantSpawnedWeapon(f); - EquipmentSlot[] aenumitemslot = EquipmentSlot.values(); + EquipmentSlot[] aenumitemslot = me.titaniumtown.Constants.ALL_EquipmentSlot; // JettPack - reduce allocs int i = aenumitemslot.length; for (int j = 0; j < i; ++j) { @@ -1367,7 +1367,7 @@ public abstract class Mob extends LivingEntity { t0.setInvulnerable(this.isInvulnerable()); if (flag) { t0.setCanPickUpLoot(this.canPickUpLoot()); - EquipmentSlot[] aenumitemslot = EquipmentSlot.values(); + EquipmentSlot[] aenumitemslot = me.titaniumtown.Constants.ALL_EquipmentSlot; // JettPack - reduce allocs int i = aenumitemslot.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/entity/monster/Shulker.java b/src/main/java/net/minecraft/world/entity/monster/Shulker.java index a9dfe190f46230077e2e1bf9aacbf5375651f216..431a07a8aa3c5c94eda582c37ef6afc56efdec45 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Shulker.java +++ b/src/main/java/net/minecraft/world/entity/monster/Shulker.java @@ -355,7 +355,7 @@ public class Shulker extends AbstractGolem implements Enemy { @Nullable protected Direction findAttachableSurface(BlockPos pos) { - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack int i = aenumdirection.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java index 5c6b2bc734c4f49395856975ff77bfbae2b0e85a..dc5c38973cffc3c13ce8f5a83cf9a3d88cecd96a 100644 --- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java @@ -226,7 +226,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { return; } // CraftBukkit end - EquipmentSlot[] aenumitemslot = EquipmentSlot.values(); + EquipmentSlot[] aenumitemslot = me.titaniumtown.Constants.ALL_EquipmentSlot; // JettPack - reduce allocs int i = aenumitemslot.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java index 66f808cabcf6a9a6584849b285f1c60133adc7b4..4d0f9131d1bad591b96b2156bd870447104b5a30 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -387,7 +387,7 @@ public final class ItemStack { // Brute force all possible updates BlockPos placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition(); - for (Direction dir : Direction.values()) { + for (Direction dir : me.titaniumtown.Constants.ALL_Direction) { // JettPack ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir))); } SignItem.openSign = null; // SPIGOT-6758 - Reset on early return @@ -946,7 +946,7 @@ public final class ItemStack { int k; if (ItemStack.shouldShowInTooltip(i, ItemStack.TooltipPart.MODIFIERS)) { - EquipmentSlot[] aenumitemslot = EquipmentSlot.values(); + EquipmentSlot[] aenumitemslot = me.titaniumtown.Constants.ALL_EquipmentSlot; // JettPack k = aenumitemslot.length; diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java index 9e3f9099cc47e6c6e40d11ef6d6e83fbf19a3cf7..b9c1db394ee35ed1acead620f7e9e47c60fa1532 100644 --- a/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java +++ b/src/main/java/net/minecraft/world/item/crafting/ShapedRecipe.java @@ -242,7 +242,7 @@ public class ShapedRecipe implements CraftingRecipe { } if (pattern.length == l) { - return new String[0]; + return me.titaniumtown.Constants.EMPTY_string_arr; // JettPack } else { String[] astring1 = new String[pattern.length - l - k]; diff --git a/src/main/java/net/minecraft/world/item/enchantment/Enchantments.java b/src/main/java/net/minecraft/world/item/enchantment/Enchantments.java index ef36f0a9b1849dd3152c0a1c81cded5c4f06aa3c..31f36d9cff9407dbe1d20bffc9a76e940afbff34 100644 --- a/src/main/java/net/minecraft/world/item/enchantment/Enchantments.java +++ b/src/main/java/net/minecraft/world/item/enchantment/Enchantments.java @@ -42,8 +42,8 @@ public class Enchantments { public static final Enchantment MULTISHOT = Enchantments.register("multishot", new MultiShotEnchantment(Enchantment.Rarity.RARE, new EquipmentSlot[]{EquipmentSlot.MAINHAND})); public static final Enchantment QUICK_CHARGE = Enchantments.register("quick_charge", new QuickChargeEnchantment(Enchantment.Rarity.UNCOMMON, new EquipmentSlot[]{EquipmentSlot.MAINHAND})); public static final Enchantment PIERCING = Enchantments.register("piercing", new ArrowPiercingEnchantment(Enchantment.Rarity.COMMON, new EquipmentSlot[]{EquipmentSlot.MAINHAND})); - public static final Enchantment MENDING = Enchantments.register("mending", new MendingEnchantment(Enchantment.Rarity.RARE, EquipmentSlot.values())); - public static final Enchantment VANISHING_CURSE = Enchantments.register("vanishing_curse", new VanishingCurseEnchantment(Enchantment.Rarity.VERY_RARE, EquipmentSlot.values())); + public static final Enchantment MENDING = Enchantments.register("mending", new MendingEnchantment(Enchantment.Rarity.RARE, me.titaniumtown.Constants.ALL_EquipmentSlot)); // JettPack + public static final Enchantment VANISHING_CURSE = Enchantments.register("vanishing_curse", new VanishingCurseEnchantment(Enchantment.Rarity.VERY_RARE, me.titaniumtown.Constants.ALL_EquipmentSlot)); // JettPack // CraftBukkit start static { diff --git a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java index 2f9f15d99f8b31e9f13f7f32378b2a9e09bcb5e5..aa565ab33700c92ca607463bdc0dcaef5a9accf1 100644 --- a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java +++ b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java @@ -15,9 +15,17 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula @Override public Optional getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState) { - return super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState).map((max) -> { - return this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, max); - }); + // JettPack start - lithium: reduce allocs + Optional optionalBlastResistance = super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState); + if (optionalBlastResistance.isPresent()) { + float blastResistance = optionalBlastResistance.get(); + float effectiveExplosionResistance = this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, blastResistance); + if (effectiveExplosionResistance != blastResistance) { + return Optional.of(effectiveExplosionResistance); + } + } + return optionalBlastResistance; + // Jettpack end } @Override diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java index 90aa1d75b5c23e5ee27ceae9f6ef90de913a6601..364ecdbe5bbe837b76451bb032fc52f41d8e0dca 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -111,7 +111,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public static final int MAX_LEVEL_SIZE = 30000000; public static final int LONG_PARTICLE_CLIP_RANGE = 512; public static final int SHORT_PARTICLE_CLIP_RANGE = 32; - private static final Direction[] DIRECTIONS = Direction.values(); public static final int MAX_BRIGHTNESS = 15; public static final int TICKS_PER_DAY = 24000; public static final int MAX_ENTITY_SPAWN_Y = 20000000; @@ -209,7 +208,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public org.bukkit.entity.Entity[] getChunkEntities(int chunkX, int chunkZ) { io.papermc.paper.world.ChunkEntitySlices slices = this.entitySliceManager.getChunk(chunkX, chunkZ); if (slices == null) { - return new org.bukkit.entity.Entity[0]; + return me.titaniumtown.Constants.EMPTY_bukkit_entity_arr; // JettPack } return slices.getChunkEntities(); } @@ -1299,7 +1298,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public int getBestNeighborSignal(BlockPos pos) { int i = 0; - Direction[] aenumdirection = Level.DIRECTIONS; + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int j = aenumdirection.length; for (int k = 0; k < j; ++k) { diff --git a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java index 4d1f94c576b65e067efce95d5ef8c0078453b494..ea6072a8ebc57bb2f4a223f5923361777247ccf8 100644 --- a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java @@ -191,7 +191,7 @@ public abstract class BaseFireBlock extends Block { } else { BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable(); boolean flag = false; - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack int i = aenumdirection.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/level/block/BuddingAmethystBlock.java b/src/main/java/net/minecraft/world/level/block/BuddingAmethystBlock.java index 02fc3ede12eadbf72e26e31b1c475c7f5b2ad73a..1653e09e0cdc4d2b0db91194861bf5a91f99c10d 100644 --- a/src/main/java/net/minecraft/world/level/block/BuddingAmethystBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BuddingAmethystBlock.java @@ -12,7 +12,7 @@ import net.minecraft.world.level.material.PushReaction; public class BuddingAmethystBlock extends AmethystBlock { public static final int GROWTH_CHANCE = 5; - private static final Direction[] DIRECTIONS = Direction.values(); + private static final Direction[] DIRECTIONS = me.titaniumtown.Constants.ALL_Direction; // JettPack public BuddingAmethystBlock(BlockBehaviour.Properties settings) { super(settings); 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 fb8b8a9733ac50096d8406487ab1ae167ef5f7b1..3d0438dd6f51c399782b177b75f048064be58c12 100644 --- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java @@ -373,7 +373,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 ? me.titaniumtown.Constants.ZERO_int_arr : me.titaniumtown.Constants.EMPTY_int_arr; // Jettpack } @Override @@ -422,7 +422,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 ? me.titaniumtown.Constants.ZERO_int_arr : me.titaniumtown.Constants.EMPTY_int_arr; // Jettpack } @Override @@ -459,7 +459,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { @Override public int[] getSlotsForFace(Direction side) { - return new int[0]; + return me.titaniumtown.Constants.EMPTY_int_arr; // Jettpack } @Override diff --git a/src/main/java/net/minecraft/world/level/block/ConcretePowderBlock.java b/src/main/java/net/minecraft/world/level/block/ConcretePowderBlock.java index 0ccdcf43d208e3d35b5e6fcd04245b29012d828c..290fd93bc21285b6a04558250b4afe93bcd1a3d7 100644 --- a/src/main/java/net/minecraft/world/level/block/ConcretePowderBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ConcretePowderBlock.java @@ -67,7 +67,7 @@ public class ConcretePowderBlock extends FallingBlock { private static boolean touchesLiquid(BlockGetter world, BlockPos pos) { boolean flag = false; BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable(); - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/level/block/CoralBlock.java b/src/main/java/net/minecraft/world/level/block/CoralBlock.java index 3b1dd57d266bdaa617ec4013b39ebbf608e08f1f..1590506e0fe98239a24f4c5df94ca35dbe6a52ef 100644 --- a/src/main/java/net/minecraft/world/level/block/CoralBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CoralBlock.java @@ -46,7 +46,7 @@ public class CoralBlock extends Block { } protected boolean scanForWater(BlockGetter world, BlockPos pos) { - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/level/block/DiodeBlock.java b/src/main/java/net/minecraft/world/level/block/DiodeBlock.java index 9c764d2273d70b8dffcaa7f324544cb48f12acc3..14db3ab0eaa3b3a259366a6ca73026bf07ddfed8 100644 --- a/src/main/java/net/minecraft/world/level/block/DiodeBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DiodeBlock.java @@ -86,7 +86,7 @@ public abstract class DiodeBlock extends HorizontalDirectionalBlock { dropResources(state, world, pos, tileentity); world.removeBlock(pos, false); - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java index d8e4fda2d501545e5f891bca317e2aa5f9368f47..ee47460d66156d9629435bfcaa40d32b61ff4093 100644 --- a/src/main/java/net/minecraft/world/level/block/FireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java @@ -137,7 +137,7 @@ public class FireBlock extends BaseFireBlock { if (!this.canBurn(iblockdata) && !iblockdata.isFaceSturdy(world, blockposition1, Direction.UP)) { BlockState iblockdata1 = this.defaultBlockState(); - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { @@ -320,7 +320,7 @@ public class FireBlock extends BaseFireBlock { } private boolean isValidFireLocation(BlockGetter world, BlockPos pos) { - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { @@ -339,7 +339,7 @@ public class FireBlock extends BaseFireBlock { return 0; } else { int i = 0; - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int j = aenumdirection.length; for (int k = 0; k < j; ++k) { diff --git a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java index 4f27969196fe21b38e81d070fe5c0a999dd320dc..81368e748037733c75b48fa0e0157ec773e1e3e4 100644 --- a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java @@ -36,7 +36,7 @@ public class FrostedIceBlock extends IceBlock { if ((random.nextInt(3) == 0 || this.fewerNeigboursThan(world, pos, 4)) && world.getMaxLocalRawBrightness(pos) > 11 - state.getValue(AGE) - state.getLightBlock(world, pos) && this.slightlyMelt(state, world, pos)) { BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); - for(Direction direction : Direction.values()) { + for(Direction direction : me.titaniumtown.Constants.ALL_Direction) { // JettPack - reduce allocs mutableBlockPos.setWithOffset(pos, direction); BlockState blockState = world.getBlockStateIfLoaded(mutableBlockPos); // Paper if (blockState == null) { continue; } // Paper @@ -74,7 +74,7 @@ public class FrostedIceBlock extends IceBlock { int i = 0; BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); - for(Direction direction : Direction.values()) { + for(Direction direction : me.titaniumtown.Constants.ALL_Direction) { // JettPack - reduce allocs mutableBlockPos.setWithOffset(pos, direction); // Paper start BlockState blockState = world.getBlockStateIfLoaded(mutableBlockPos); diff --git a/src/main/java/net/minecraft/world/level/block/LeavesBlock.java b/src/main/java/net/minecraft/world/level/block/LeavesBlock.java index 0ce900235fd083545a208132079510b5ca3c9cab..1afd59499a71d07222c08ccbc6248e30c24b31bb 100644 --- a/src/main/java/net/minecraft/world/level/block/LeavesBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LeavesBlock.java @@ -84,7 +84,7 @@ public class LeavesBlock extends Block { private static BlockState updateDistance(BlockState state, LevelAccessor world, BlockPos pos) { int i = 7; BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int j = aenumdirection.length; for (int k = 0; k < j; ++k) { diff --git a/src/main/java/net/minecraft/world/level/block/MultifaceBlock.java b/src/main/java/net/minecraft/world/level/block/MultifaceBlock.java index babffeec9aa8a1526767f2d9fcedd146fc8a2e05..390e9b1f76a6fbbd34c638b4135c31d088901c13 100644 --- a/src/main/java/net/minecraft/world/level/block/MultifaceBlock.java +++ b/src/main/java/net/minecraft/world/level/block/MultifaceBlock.java @@ -52,7 +52,6 @@ public class MultifaceBlock extends Block { enummap.put(Direction.UP, MultifaceBlock.UP_AABB); enummap.put(Direction.DOWN, MultifaceBlock.DOWN_AABB); }); - protected static final Direction[] DIRECTIONS = Direction.values(); private final ImmutableMap shapesCache; private final boolean canRotate; private final boolean canMirrorX; @@ -73,7 +72,7 @@ public class MultifaceBlock extends Block { @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { - Direction[] aenumdirection = MultifaceBlock.DIRECTIONS; + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack int i = aenumdirection.length; for (int j = 0; j < i; ++j) { @@ -99,7 +98,7 @@ public class MultifaceBlock extends Block { @Override public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { boolean flag = false; - Direction[] aenumdirection = MultifaceBlock.DIRECTIONS; + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack int i = aenumdirection.length; for (int j = 0; j < i; ++j) { @@ -185,7 +184,7 @@ public class MultifaceBlock extends Block { private BlockState mapDirections(BlockState state, Function mirror) { BlockState iblockdata1 = state; - Direction[] aenumdirection = MultifaceBlock.DIRECTIONS; + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack int i = aenumdirection.length; for (int j = 0; j < i; ++j) { @@ -200,7 +199,7 @@ public class MultifaceBlock extends Block { } public boolean spreadFromRandomFaceTowardRandomDirection(BlockState state, ServerLevel world, BlockPos pos, Random random) { - List list = Lists.newArrayList(MultifaceBlock.DIRECTIONS); + List list = Lists.newArrayList(me.titaniumtown.Constants.ALL_Direction); // JettPack Collections.shuffle(list); return list.stream().filter((enumdirection) -> { @@ -211,7 +210,7 @@ public class MultifaceBlock extends Block { } public boolean spreadFromFaceTowardRandomDirection(BlockState state, LevelAccessor world, BlockPos pos, Direction from, Random random, boolean postProcess) { - List list = Arrays.asList(MultifaceBlock.DIRECTIONS); + List list = Arrays.asList(me.titaniumtown.Constants.ALL_Direction); // JettPack Collections.shuffle(list, random); return list.stream().anyMatch((enumdirection1) -> { @@ -232,7 +231,7 @@ public class MultifaceBlock extends Block { } protected boolean canSpread(BlockState state, BlockGetter world, BlockPos pos, Direction from) { - return Stream.of(MultifaceBlock.DIRECTIONS).anyMatch((enumdirection1) -> { + return Stream.of(me.titaniumtown.Constants.ALL_Direction).anyMatch((enumdirection1) -> { // JettPack return this.getSpreadFromFaceTowardDirection(state, world, pos, from, enumdirection1).isPresent(); }); } @@ -330,7 +329,7 @@ public class MultifaceBlock extends Block { private static VoxelShape calculateMultifaceShape(BlockState state) { VoxelShape voxelshape = Shapes.empty(); - Direction[] aenumdirection = MultifaceBlock.DIRECTIONS; + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack int i = aenumdirection.length; for (int j = 0; j < i; ++j) { @@ -345,13 +344,13 @@ public class MultifaceBlock extends Block { } protected static boolean hasAnyFace(BlockState state) { - return Arrays.stream(MultifaceBlock.DIRECTIONS).anyMatch((enumdirection) -> { + return Arrays.stream(me.titaniumtown.Constants.ALL_Direction).anyMatch((enumdirection) -> { // JettPack return MultifaceBlock.hasFace(state, enumdirection); }); } private static boolean hasAnyVacantFace(BlockState state) { - return Arrays.stream(MultifaceBlock.DIRECTIONS).anyMatch((enumdirection) -> { + return Arrays.stream(me.titaniumtown.Constants.ALL_Direction).anyMatch((enumdirection) -> { // JettPack return !MultifaceBlock.hasFace(state, enumdirection); }); } diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneOreBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneOreBlock.java index 0bea8d5be72c08236841e7313e20751af8ddb83a..5d7ab3949033e29d88349623547b5ff65573d153 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneOreBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneOreBlock.java @@ -136,7 +136,7 @@ public class RedStoneOreBlock extends Block { private static void spawnParticles(Level world, BlockPos pos) { double d0 = 0.5625D; Random random = world.random; - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java index 037330bcb10039c013b2ed5fd68dee16ede20fbe..ec89c162ad7de9d1647934efd02b2581b4689a6d 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java @@ -392,7 +392,7 @@ public class RedStoneWireBlock extends Block { Set set = Sets.newHashSet(); set.add(pos); - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int j = aenumdirection.length; for (int k = 0; k < j; ++k) { @@ -449,7 +449,7 @@ public class RedStoneWireBlock extends Block { private void checkCornerChangeAt(Level world, BlockPos pos) { if (world.getBlockState(pos).is((Block) this)) { world.updateNeighborsAt(pos, this); - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { @@ -482,7 +482,7 @@ public class RedStoneWireBlock extends Block { if (!moved && !state.is(newState.getBlock())) { super.onRemove(state, world, pos, newState, moved); if (!world.isClientSide) { - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java index 954b86bea345a8e0e3a8dd425f356db6f5cd496f..93a2dade36a08a17eae34181f087114eca706872 100644 --- a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java @@ -34,7 +34,7 @@ public class RedstoneTorchBlock extends TorchBlock { @Override public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { @@ -48,7 +48,7 @@ public class RedstoneTorchBlock extends TorchBlock { @Override public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean moved) { if (!moved) { - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { diff --git a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java index 842997ea9f25a05d74a2e8300e44cc39a7e9cd96..d0401376198cbb595abb20ee0d63504fca3b00f9 100644 --- a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java @@ -62,7 +62,7 @@ public class SpongeBlock extends Block { Tuple tuple = (Tuple) queue.poll(); BlockPos blockposition1 = (BlockPos) tuple.getA(); int j = (Integer) tuple.getB(); - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int k = aenumdirection.length; for (int l = 0; l < k; ++l) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java index bc028de0ac71e69e8d714db5f65286f306544bf1..6278115e3511fe2176b29122e2c733498f31bb5a 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java @@ -363,7 +363,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { public int getParticleAmount() { int i = 0; - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int j = aenumdirection.length; for (int k = 0; k < j; ++k) { diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java index c9c18cf84e4ee5c253bbc64a4b41e91f9f4c4bc7..6ec908eda3855b926958cd546acd9055fb8569b8 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java @@ -163,7 +163,7 @@ public class PistonBaseBlock extends DirectionalBlock { } private boolean getNeighborSignal(Level world, BlockPos pos, Direction pistonFace) { - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; int j; @@ -180,7 +180,7 @@ public class PistonBaseBlock extends DirectionalBlock { return true; } else { BlockPos blockposition1 = pos.above(); - Direction[] aenumdirection1 = Direction.values(); + Direction[] aenumdirection1 = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs j = aenumdirection1.length; diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java index 05c46f3b3bce5225b819d86e6e06729a5093e092..d17fb373c43b9bc3c18e3b34fd5f70d95d4d3215 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java @@ -1080,7 +1080,7 @@ public abstract class BlockBehaviour { private static final class Cache { - private static final Direction[] DIRECTIONS = Direction.values(); + private static final Direction[] DIRECTIONS = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs private static final int SUPPORT_TYPE_COUNT = SupportType.values().length; protected final boolean solidRender; final boolean propagatesSkylightDown; @@ -1120,7 +1120,7 @@ public abstract class BlockBehaviour { if (!this.collisionShape.isEmpty() && block.getOffsetType() != BlockBehaviour.OffsetType.NONE) { throw new IllegalStateException(String.format("%s has a collision shape and an offset type, but is not marked as dynamicShape in its properties.", Registry.BLOCK.getKey(block))); } else { - this.largeCollisionShape = Arrays.stream(Direction.Axis.values()).anyMatch((enumdirection_enumaxis) -> { + this.largeCollisionShape = Arrays.stream(me.titaniumtown.Constants.ALL_AXIS_Direction).anyMatch((enumdirection_enumaxis) -> { return this.collisionShape.min(enumdirection_enumaxis) < 0.0D || this.collisionShape.max(enumdirection_enumaxis) > 1.0D; }); this.faceSturdy = new boolean[BlockBehaviour.BlockStateBase.Cache.DIRECTIONS.length * BlockBehaviour.BlockStateBase.Cache.SUPPORT_TYPE_COUNT]; diff --git a/src/main/java/net/minecraft/world/level/lighting/BlockLightEngine.java b/src/main/java/net/minecraft/world/level/lighting/BlockLightEngine.java index 37d7165dfd17da03428f8dbbbf95aa8005be289c..3994fbc9c81ecec1864f16f1c28600381b3d3fb7 100644 --- a/src/main/java/net/minecraft/world/level/lighting/BlockLightEngine.java +++ b/src/main/java/net/minecraft/world/level/lighting/BlockLightEngine.java @@ -13,7 +13,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.apache.commons.lang3.mutable.MutableInt; public final class BlockLightEngine extends LayerLightEngine { - private static final Direction[] DIRECTIONS = Direction.values(); + private static final Direction[] DIRECTIONS = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs private final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); private final MutableInt mutableInt = new MutableInt(); // Paper diff --git a/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java b/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java index 4f7b63f2cc8a69fa8efb3a84f6abc3d3dcf05b49..fa7dac236d7456f152193743a17794c75a4cd0d9 100644 --- a/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java +++ b/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java @@ -22,7 +22,7 @@ public abstract class LayerLightSectionStorage> protected static final int LIGHT_ONLY = 1; protected static final int EMPTY = 2; protected static final DataLayer EMPTY_DATA = new DataLayer(); - private static final Direction[] DIRECTIONS = Direction.values(); + private static final Direction[] DIRECTIONS = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs private final LightLayer layer; private final LightChunkGetter chunkSource; protected final LongSet dataSectionSet = new LongOpenHashSet(); diff --git a/src/main/java/net/minecraft/world/level/lighting/SkyLightEngine.java b/src/main/java/net/minecraft/world/level/lighting/SkyLightEngine.java index d122475c1a9d340046c478087d3ff5bf1ff8932c..a8913009d873d8e646489ffde8ecc780d4b0df02 100644 --- a/src/main/java/net/minecraft/world/level/lighting/SkyLightEngine.java +++ b/src/main/java/net/minecraft/world/level/lighting/SkyLightEngine.java @@ -12,7 +12,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.apache.commons.lang3.mutable.MutableInt; public final class SkyLightEngine extends LayerLightEngine { - private static final Direction[] DIRECTIONS = Direction.values(); + private static final Direction[] DIRECTIONS = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs private static final Direction[] HORIZONTALS = new Direction[]{Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST}; private final MutableInt mutableInt = new MutableInt(); // Paper diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java index 8e15976c83c71b8f335511e6747d56d3c8ff6856..657120ddfdc27094de6f38f47375bb281925b0bb 100644 --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java +++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java @@ -125,7 +125,7 @@ public abstract class LavaFluid extends FlowingFluid { } private boolean hasFlammableNeighbours(LevelReader world, BlockPos pos) { - Direction[] aenumdirection = Direction.values(); + Direction[] aenumdirection = me.titaniumtown.Constants.ALL_Direction; // JettPack - reduce allocs int i = aenumdirection.length; for (int j = 0; j < i; ++j) { 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 35c39aed9583275ef25d32c783715798b52bdb63..b470da69f271d1a5ebb9727c0c34944e85ce3a51 100644 --- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java @@ -119,7 +119,7 @@ public class PlayerDataStorage { String[] astring = this.playerDir.list(); if (astring == null) { - astring = new String[0]; + astring = me.titaniumtown.Constants.EMPTY_string_arr; // JettPack } for (int i = 0; i < astring.length; ++i) {