mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 08:59:23 +00:00
68 lines
3.8 KiB
Diff
68 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: wangxyper <wangxyper@163.com>
|
|
Date: Wed, 11 Jan 2023 16:58:19 +0800
|
|
Subject: [PATCH] Hearse: Fix some concurrent problems
|
|
|
|
Original license: MIT
|
|
Original project: https://github.com/NaturalCodeClub/HearseRewrite
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
|
index 26e1b4060f2a93cb659170f83e6ce64086e0eb0c..d6951b05128fea7eb5f1b40837cea77e0c209165 100644
|
|
--- a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
|
+++ b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
|
@@ -423,8 +423,10 @@ public final class EntityLookup implements LevelEntityGetter<Entity> {
|
|
final ChunkEntitySlices old = this.getChunk(entity.sectionX, entity.sectionZ);
|
|
final ChunkEntitySlices slices = this.getOrCreateChunk(newSectionX, newSectionZ);
|
|
|
|
- if (!old.removeEntity(entity, entity.sectionY)) {
|
|
- LOGGER.warn("Could not remove entity " + entity + " from its old chunk section (" + entity.sectionX + "," + entity.sectionY + "," + entity.sectionZ + ") since it was not contained in the section");
|
|
+ if (old!=null){
|
|
+ if (!old.removeEntity(entity, entity.sectionY)) {
|
|
+ LOGGER.warn("Could not remove entity " + entity + " from its old chunk section (" + entity.sectionX + "," + entity.sectionY + "," + entity.sectionZ + ") since it was not contained in the section");
|
|
+ }
|
|
}
|
|
|
|
if (!slices.addEntity(entity, newSectionY)) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
|
index 8db20db72cd51046213625fac46c35854c59ec5d..4d40526cc90c19ff5a1569c8d6d828a0d0b73ccb 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java
|
|
@@ -3,6 +3,7 @@ package net.minecraft.world.entity.ai.sensing;
|
|
import com.google.common.collect.ImmutableSet;
|
|
import com.mojang.datafixers.util.Pair;
|
|
import it.unimi.dsi.fastutil.longs.Long2LongMap;
|
|
+import it.unimi.dsi.fastutil.longs.Long2LongMaps;
|
|
import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap;
|
|
import java.util.Optional;
|
|
import java.util.Set;
|
|
@@ -23,7 +24,7 @@ public class NearestBedSensor extends Sensor<Mob> {
|
|
private static final int CACHE_TIMEOUT = 40;
|
|
private static final int BATCH_SIZE = 5;
|
|
private static final int RATE = 20;
|
|
- private final Long2LongMap batchCache = new Long2LongOpenHashMap();
|
|
+ private final Long2LongMap batchCache = Long2LongMaps.synchronize(new Long2LongOpenHashMap());
|
|
private int triedCount;
|
|
private long lastUpdate;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java
|
|
index 9babe636176da3c40598eb5bdac0919a1704eaa0..58c6b1f67aedf5ab2167fd070604fc0d8f710435 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java
|
|
@@ -2,13 +2,14 @@ package net.minecraft.world.entity.ai.sensing;
|
|
|
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
|
+import it.unimi.dsi.fastutil.ints.IntSets;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.Mob;
|
|
|
|
public class Sensing {
|
|
private final Mob mob;
|
|
- private final IntSet seen = new IntOpenHashSet();
|
|
- private final IntSet unseen = new IntOpenHashSet();
|
|
+ private final IntSet seen = IntSets.synchronize(new IntOpenHashSet());
|
|
+ private final IntSet unseen = IntSets.synchronize(new IntOpenHashSet());
|
|
|
|
public Sensing(Mob owner) {
|
|
this.mob = owner;
|