Upstream has released updates that appears to apply and compile correctly Paper Changes: cfed00cf Fix Light Command a6ff84ad Revert Nibble patch, causing issues still f1a8eb7f Use a finalizer for light packet instead of onPacketDone 03c9bb05 Optimize NibbleArray to use pooled buffers d0a528b1 Move delayed init down later in tick, improve accuracy of startup time cc477e6a Force Plugins that use delayed tasks for init back in their place 597263fd Don't skip full player connection tick when dead e2c23475 Revert loaded entity list (#3304) fa87db6b Move another NetworkManager util into the inner class (#3303) 841c7d18 Make loaded entity list logic more consistent (#3301) 36f34f01 Updated Upstream (Bukkit/CraftBukkit) 5ca5f131 Rebuild all patches using the new rebuild pattern 1ccff6fa Add villager reputation API 5c0bfffa Speed up rebuilding patches and reduce diff f37381ea Optimize Network Manager to not need synchronization 8f9df2ed Anti Xray cleanup 878c66f1 No-Tick view distance implementation - Closes #3196 b87743c1 Stop copy-on-write operations for updating light data 97a9c972 Optimize isOutsideRange to use distance maps b4e629a2 Use distance map to optimise entity tracker / Misc Utils d80d1517 Optimize Entity Ticking to Loaded Chunks only 31d7686d Add item slot helper methods for various inventories (#3221) 75e1e3b3 Mob Goal API c7bc393a Revert "Don't flush packet queue off main thread" 1abd2bd2 Don't flush packet queue off main thread a4ed58a9 Clean up Direct Memory Region Files Fix for different Java versions 55e35019 Set cap on JDK per-thread native byte buffer cache b5101f4f Cleanup Region Files Direct Memory on close 81e655d7 Optimize Voxel Shape Merging ed9fc11f Sync position on teleportation 9c326fce Nanothing to see here 3e9fc24b Attempt to fix FastLogin maybe 932e97f3 Rename to AsyncPlayerSendSuggestionsEvent to be consistent in naming 0dd19075 AsyncSendPlayerSuggestionsEvent Brigadier Event a9e20e5f Fix being kicked in survival for block picking - Fixes #3277 4d20537e Expose game version (#3274) 85fb0015 Validate PickItem Packet and kick for invalid - Fixes #3256 5729bc71 Special case Keep Alive packets from Anti Xray a76b7740 Improved oversized chunk data packet handling a6f78170 Use Vanilla Bed Search for non players (Villagers) 68fb98b5 Fix 2 plugin specific issues with loot drop and pathfinders 6e41f7b7 Update Activation Range 2.0 with more villager controls 57dd3971 Updated Upstream (Bukkit/CraftBukkit) a6a197b1 Bump API ASM version to follow server 5ab48ad9 Fix commodore (#3264) 87e7ee7e Improve Async Login to avoid firing in middle of Entity Ticking 8ce3dd5f [CI-SKIP] Fix Mojang API Brigadier dep - THIS IS NOT A NEW BUILD 00d760a5 Fix build due to spigot changing the build timestamp process 842e040c Updated Upstream (Bukkit/CraftBukkit/Spigot) c03260a2 Add getter and setter for villager's numberOfRestocksToday (#3231) fe366fbe null check tracker for entity metadata update - Fixes #3070 fdf41b74 Implement Brigadier Mojang API e0ea2e0e Entity Activation Range 2.0! Major improvements to restoring behavior 10396d28 Fix Tracking Range mismatch on Vehicle/Passenger checks 68994c64 Add a config to turn off Optimized TickList #3145 d847d336 Improve blocking players from opening inventories while sleeping ac4f6b50 Clean up Timings and Async Chunk Configs fcf89e85 Improve mid tick chunk loading, Fix Oversleep, other improvements ab36835c Improve random ticking behaviour - Fixes #3181 a6ac47e5 Fix numerous item duplication issues and teleport issues b7402f11 Add phantom creative and insomniac controls (#3222) 75819fac Fix Potion#toItemStack swapping the extended and upgraded constructor values (#3216) cb15cfa4 Improve Async Login so pending connections dont get exposed f275e9cb Optimize Hoppers - Major Boost - Got2GoFast! 0106485c Improvements to watchdog changes 65934b1f Fix build for last commit. 5am commits are great 3f436029 Don't process watchdog until server has fully started and ticked. 938bd972 Don't fire BlockFade on worldgen threads - Fixes #3208 509a828e Fix loading spawn chunks when async chunks is off 8a91bfd2 Improvements to async login bf698865 Revert "Re-track players that dismount from other players" 82b98418 Fix some issues with async login as well another source of sync loads aa241d2b Allow multiple callbacks to schedule for Callback Executor a2064a41 Add PlayerAttackEntityCooldownResetEvent This event is called when processing a player's attack on an entity right before their attack strength cd is reset, there are no existing events that fire within this period of time so it was impossible to capture the players attack strength via API prior to this commit. f48d4299 Allow sleeping players to float eeb2f67d Fix Bed respawn deviating too far from vanilla (#3195) 68a7b9fe Move player to spawn point if spawn in unloaded world f29c7ebd Improve async login (#3189) 9fd36824 Fix Citizens Player NPC tracking issue - Fixes #3186
162 lines
8.2 KiB
Diff
162 lines
8.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Sotr <i@omc.hk>
|
|
Date: Wed, 15 Apr 2020 03:51:50 +0700
|
|
Subject: [PATCH] Optimize door interact with pathfinding
|
|
|
|
|
|
diff --git a/src/main/java/io/akarin/server/IndexedBlockPosition.java b/src/main/java/io/akarin/server/IndexedBlockPosition.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..83bf1d4cab653a9edcc8352609433a8fd12bd1b3
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/akarin/server/IndexedBlockPosition.java
|
|
@@ -0,0 +1,35 @@
|
|
+package io.akarin.server;
|
|
+
|
|
+import net.minecraft.server.BlockPosition;
|
|
+
|
|
+public class IndexedBlockPosition {
|
|
+ private final int index;
|
|
+ private final BlockPosition position;
|
|
+
|
|
+ public IndexedBlockPosition(int index, BlockPosition position) {
|
|
+ this.index = index;
|
|
+ this.position = position;
|
|
+ }
|
|
+
|
|
+ public static IndexedBlockPosition of(int index, BlockPosition position) {
|
|
+ return new IndexedBlockPosition(index, position);
|
|
+ }
|
|
+
|
|
+ public int index() {
|
|
+ return index;
|
|
+ }
|
|
+
|
|
+ public BlockPosition get() {
|
|
+ return position;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int hashCode() {
|
|
+ return position.hashCode();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean equals(Object obj) {
|
|
+ return position.equals(obj);
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java b/src/main/java/net/minecraft/server/BehaviorInteractDoor.java
|
|
index 01d9c2d92c580c9fabbb8bb4e8c93f3cc511ccf9..3db22c5f4df6fe68474839c3889ffbe5440f54dc 100644
|
|
--- a/src/main/java/net/minecraft/server/BehaviorInteractDoor.java
|
|
+++ b/src/main/java/net/minecraft/server/BehaviorInteractDoor.java
|
|
@@ -1,7 +1,9 @@
|
|
package net.minecraft.server;
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
+import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Sets;
|
|
+import io.akarin.server.IndexedBlockPosition;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
@@ -19,32 +21,63 @@ public class BehaviorInteractDoor extends Behavior<EntityLiving> {
|
|
BehaviorController<?> behaviorcontroller = entityliving.getBehaviorController();
|
|
PathEntity pathentity = (PathEntity) behaviorcontroller.getMemory(MemoryModuleType.PATH).get();
|
|
List<GlobalPos> list = (List) behaviorcontroller.getMemory(MemoryModuleType.INTERACTABLE_DOORS).get();
|
|
+ // Akarin start - remove stream
|
|
+ /*
|
|
List<BlockPosition> list1 = (List) pathentity.d().stream().map((pathpoint) -> {
|
|
return new BlockPosition(pathpoint.a, pathpoint.b, pathpoint.c);
|
|
}).collect(Collectors.toList());
|
|
- Set<BlockPosition> set = this.a(worldserver, list, list1);
|
|
+ */
|
|
+
|
|
+ List<PathPoint> points = pathentity.getPoints();
|
|
+ java.util.Map<BlockPosition, Integer> list1 = new java.util.HashMap<BlockPosition, Integer>(points.size());
|
|
+ for (int index = 0; index < points.size(); index++) {
|
|
+ PathPoint point = points.get(index);
|
|
+ list1.put(new BlockPosition(point.a, point.b, point.c), index);
|
|
+ }
|
|
+
|
|
+ // Akarin end
|
|
+ Set<io.akarin.server.IndexedBlockPosition> set = this.a(worldserver, list, list1); // Akarin - IndexedBlockPosition
|
|
int j = pathentity.f() - 1;
|
|
|
|
this.a(worldserver, list1, set, j, entityliving, behaviorcontroller);
|
|
}
|
|
|
|
- private Set<BlockPosition> a(WorldServer worldserver, List<GlobalPos> list, List<BlockPosition> list1) {
|
|
+ private Set<io.akarin.server.IndexedBlockPosition> a(WorldServer worldserver, List<GlobalPos> list, java.util.Map<BlockPosition, Integer> list1) { // Akarin - List -> Map, IndexedBlockPosition
|
|
+ // Akarin start - remove stream
|
|
+ /*
|
|
Stream stream = list.stream().filter((globalpos) -> {
|
|
return globalpos.getDimensionManager() == worldserver.getWorldProvider().getDimensionManager();
|
|
}).map(GlobalPos::getBlockPosition);
|
|
|
|
list1.getClass();
|
|
return (Set) stream.filter(list1::contains).collect(Collectors.toSet());
|
|
+ */
|
|
+
|
|
+ Set<io.akarin.server.IndexedBlockPosition> set = Sets.newHashSet();
|
|
+ DimensionManager manager = worldserver.getWorldProvider().getDimensionManager();
|
|
+
|
|
+ for (GlobalPos globalPos : list) {
|
|
+ if (globalPos.getDimensionManager() == manager) {
|
|
+ BlockPosition position = globalPos.getBlockPosition();
|
|
+ Integer index = list1.get(position);
|
|
+ if (index != null) // contains
|
|
+ set.add(IndexedBlockPosition.of(index, position));
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return set;
|
|
+ // Akarin end
|
|
}
|
|
|
|
- private void a(WorldServer worldserver, List<BlockPosition> list, Set<BlockPosition> set, int i, EntityLiving entityliving, BehaviorController<?> behaviorcontroller) {
|
|
- set.forEach((blockposition) -> {
|
|
- int j = list.indexOf(blockposition);
|
|
+ private void a(WorldServer worldserver, java.util.Map<BlockPosition, Integer> list, Set<io.akarin.server.IndexedBlockPosition> set, int i, EntityLiving entityliving, BehaviorController<?> behaviorcontroller) { // Akarin - List -> Map, IndexedBlockPosition
|
|
+ set.forEach((indexedblockposition) -> { // Akarin - IndexedBlockPosition
|
|
+ BlockPosition blockposition = indexedblockposition.get(); // Akarin - IndexedBlockPosition
|
|
+ // int j = list.indexOf(blockposition); // Akarin - IndexedBlockPosition
|
|
IBlockData iblockdata = worldserver.getType(blockposition);
|
|
Block block = iblockdata.getBlock();
|
|
|
|
if (TagsBlock.WOODEN_DOORS.isTagged(block) && block instanceof BlockDoor) {
|
|
- boolean flag = j >= i;
|
|
+ boolean flag = indexedblockposition.index() >= i; // Akarin - IndexedBlockPosition
|
|
|
|
// CraftBukkit start - entities opening doors
|
|
org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.world, blockposition));
|
|
@@ -74,14 +107,14 @@ public class BehaviorInteractDoor extends Behavior<EntityLiving> {
|
|
a(worldserver, list, i, entityliving, behaviorcontroller);
|
|
}
|
|
|
|
- public static void a(WorldServer worldserver, List<BlockPosition> list, int i, EntityLiving entityliving, BehaviorController<?> behaviorcontroller) {
|
|
+ public static void a(WorldServer worldserver, java.util.Map<BlockPosition, Integer> list, int i, EntityLiving entityliving, BehaviorController<?> behaviorcontroller) { // Akarin - List -> Map
|
|
behaviorcontroller.getMemory(MemoryModuleType.OPENED_DOORS).ifPresent((set) -> {
|
|
Iterator iterator = set.iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
GlobalPos globalpos = (GlobalPos) iterator.next();
|
|
BlockPosition blockposition = globalpos.getBlockPosition();
|
|
- int j = list.indexOf(blockposition);
|
|
+ int j = list.getOrDefault(blockposition, -1); // Akarin - List -> Map
|
|
|
|
if (worldserver.getWorldProvider().getDimensionManager() != globalpos.getDimensionManager()) {
|
|
iterator.remove();
|
|
diff --git a/src/main/java/net/minecraft/server/BehaviorSleep.java b/src/main/java/net/minecraft/server/BehaviorSleep.java
|
|
index dfe0f66500ab2ea733fd5ef84d7d80f32e2dfaab..46eb633084a2eb48cb0a42c5df2b69b9e93b22e1 100644
|
|
--- a/src/main/java/net/minecraft/server/BehaviorSleep.java
|
|
+++ b/src/main/java/net/minecraft/server/BehaviorSleep.java
|
|
@@ -57,7 +57,7 @@ public class BehaviorSleep extends Behavior<EntityLiving> {
|
|
protected void a(WorldServer worldserver, EntityLiving entityliving, long i) {
|
|
if (i > this.a) {
|
|
entityliving.getBehaviorController().getMemory(MemoryModuleType.OPENED_DOORS).ifPresent((set) -> {
|
|
- BehaviorInteractDoor.a(worldserver, (List) ImmutableList.of(), 0, entityliving, entityliving.getBehaviorController());
|
|
+ BehaviorInteractDoor.a(worldserver, com.google.common.collect.ImmutableMap.of(), 0, entityliving, entityliving.getBehaviorController()); // Akarin - List -> Map
|
|
});
|
|
entityliving.entitySleep(((GlobalPos) entityliving.getBehaviorController().getMemory(MemoryModuleType.HOME).get()).getBlockPosition());
|
|
}
|