mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
* init 1.21.4, and boom! * build change, but weight not work * just work * Build changes, and delete timings * Fix API patches (#406) * Fix API patches * merge --------- Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> * 0006/0129 * 0009/0129 * 0011/0129 * 0018/0129 * 0030/0129 * 0035/0129 * 0043/0129 * 0048/0129 * 0049/0129 * 0057/0129 * 0065/0129 * 0086/0129 (#408) * 0072/0129 * 0080/0129 * Readd patch infos * 0086/0129 * Delete applied patches * 0087/0129 * 0091/0129 * 0097/0129 * 0101/0129 * 102/129 * 0107/0129 * 0112/0129 * 0118/0129 * 0129/0129, 100% patched * fix some * server work * Protocol... (#409) * Jade v7 * Fix changed part for Jade * Formatting imports, add Lms Paster protocol * REI payloads 5/8 * Add REI support, remove unnecessary content in Jade * Rename * Make jade better * Make action work * fix action jar * Fix some protocol * Fix bot action, and entity tickCount * Fix Warden GameEventListener register on load * Fix extra Raider drop * Fix grindstone overstacking * Update Paper, and some doc * Merge * [ci skip] Update Action --------- Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
44 lines
2.4 KiB
Diff
44 lines
2.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Sat, 22 Jul 2023 12:00:59 +0800
|
|
Subject: [PATCH] Fix villagers dont release memory
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 12f37226992986fb633c36e651fc098e46937646..ab63de942e3a34a84666877a202c4a191391a28b 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -3837,7 +3837,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return this;
|
|
}
|
|
|
|
- private Entity teleportCrossDimension(ServerLevel level, TeleportTransition teleportTransition) {
|
|
+ protected Entity teleportCrossDimension(ServerLevel level, TeleportTransition teleportTransition) { // Leaves - private -> protected
|
|
List<Entity> passengers = this.getPassengers();
|
|
List<Entity> list = new ArrayList<>(passengers.size());
|
|
this.ejectPassengers();
|
|
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
|
|
index 2b83262e4a13eae86df82913ce4f3121e3631a43..6b565fcf91e1d94b649dac90bf3c923930d252f8 100644
|
|
--- a/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -1017,4 +1017,19 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
Optional<Long> memory = this.brain.getMemory(MemoryModuleType.LAST_SLEPT);
|
|
return memory.filter(_long -> gameTime - _long < 24000L).isPresent();
|
|
}
|
|
+
|
|
+ // Leaves start - fixes a memory leak when villagers get moved to another world
|
|
+ @Override
|
|
+ public Entity teleportCrossDimension(ServerLevel world, net.minecraft.world.level.portal.TeleportTransition transition) {
|
|
+ if (org.leavesmc.leaves.LeavesConfig.performance.villagersDontReleaseMemoryFix) {
|
|
+ this.releaseAllPois();
|
|
+ this.getBrain().eraseMemory(MemoryModuleType.HOME);
|
|
+ this.getBrain().eraseMemory(MemoryModuleType.JOB_SITE);
|
|
+ this.getBrain().eraseMemory(MemoryModuleType.POTENTIAL_JOB_SITE);
|
|
+ this.getBrain().eraseMemory(MemoryModuleType.MEETING_POINT);
|
|
+ this.refreshBrain(transition.newLevel());
|
|
+ }
|
|
+ return super.teleportCrossDimension(world, transition);
|
|
+ }
|
|
+ // Leaves end - fixes a memory leak when villagers get moved to another world
|
|
}
|