Remap CraftBukkit to Mojang+Yarn Mappings

By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
CraftBukkit/Spigot
2024-12-11 22:26:55 +01:00
parent a265d64138
commit 30e4583dbe
1780 changed files with 44628 additions and 41274 deletions

View File

@@ -1,23 +1,22 @@
--- a/net/minecraft/world/level/entity/EntityAccess.java
+++ b/net/minecraft/world/level/entity/EntityAccess.java
@@ -6,6 +6,10 @@
@@ -5,6 +5,9 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.AABB;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public interface EntityAccess {
int getId();
@@ -24,6 +28,12 @@
@@ -24,6 +27,12 @@
void setRemoved(Entity.RemovalReason entity_removalreason);
void setRemoved(Entity.RemovalReason reason);
+ // CraftBukkit start - add Bukkit remove cause
+ default void setRemoved(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
+ setRemoved(entity_removalreason);
+ this.setRemoved(entity_removalreason);
+ }
+ // CraftBukkit end
+

View File

@@ -1,80 +1,95 @@
--- a/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
+++ b/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
@@ -32,6 +32,12 @@
import net.minecraft.world.level.ChunkCoordIntPair;
@@ -29,8 +29,13 @@
import net.minecraft.util.CsvOutput;
import net.minecraft.util.VisibleForDebug;
import net.minecraft.world.entity.Entity;
-import net.minecraft.world.level.ChunkPos;
import org.slf4j.Logger;
+import net.minecraft.world.level.ChunkPos;
+// CraftBukkit start
+import net.minecraft.world.level.chunk.storage.EntityStorage;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class PersistentEntitySectionManager<T extends EntityAccess> implements AutoCloseable {
static final Logger LOGGER = LogUtils.getLogger();
@@ -55,6 +61,16 @@
@@ -55,6 +60,16 @@
this.entityGetter = new LevelEntityGetterAdapter<>(this.visibleEntityStorage, this.sectionStorage);
}
+ // CraftBukkit start - add method to get all entities in chunk
+ public List<Entity> getEntities(ChunkCoordIntPair chunkCoordIntPair) {
+ return sectionStorage.getExistingSectionsInChunk(chunkCoordIntPair.toLong()).flatMap(EntitySection::getEntities).map(entity -> (Entity) entity).collect(Collectors.toList());
+ public List<Entity> getEntities(ChunkPos chunkCoordIntPair) {
+ return this.sectionStorage.getExistingSectionsInChunk(chunkCoordIntPair.toLong()).flatMap(EntitySection::getEntities).map(entity -> (Entity) entity).collect(Collectors.toList());
+ }
+
+ public boolean isPending(long pair) {
+ return chunkLoadStatuses.get(pair) == b.PENDING;
+ return this.chunkLoadStatuses.get(pair) == ChunkLoadStatus.PENDING;
+ }
+ // CraftBukkit end
+
void removeSectionIfEmpty(long i, EntitySection<T> entitysection) {
if (entitysection.isEmpty()) {
this.sectionStorage.remove(i);
@@ -196,6 +212,12 @@
void removeSectionIfEmpty(long sectionPos, EntitySection<T> section) {
if (section.isEmpty()) {
this.sectionStorage.remove(sectionPos);
@@ -196,27 +211,35 @@
}
private boolean storeChunkSections(long i, Consumer<T> consumer) {
private boolean storeChunkSections(long chunkPos, Consumer<T> action) {
- PersistentEntitySectionManager.ChunkLoadStatus persistententitysectionmanager_b = (PersistentEntitySectionManager.ChunkLoadStatus) this.chunkLoadStatuses.get(chunkPos);
+ // CraftBukkit start - add boolean for event call
+ return storeChunkSections(i, consumer, false);
+ return this.storeChunkSections(chunkPos, action, false);
+ }
+
+ private boolean storeChunkSections(long i, Consumer<T> consumer, boolean callEvent) {
+ // CraftBukkit end
PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i);
if (persistententitysectionmanager_b == PersistentEntitySectionManager.b.PENDING) {
@@ -207,6 +229,7 @@
+ PersistentEntitySectionManager.ChunkLoadStatus persistententitysectionmanager_b = (PersistentEntitySectionManager.ChunkLoadStatus) this.chunkLoadStatuses.get(i);
+
if (persistententitysectionmanager_b == PersistentEntitySectionManager.ChunkLoadStatus.PENDING) {
return false;
} else {
- List<T> list = (List) this.sectionStorage.getExistingSectionsInChunk(chunkPos).flatMap((entitysection) -> {
+ List<T> list = (List) this.sectionStorage.getExistingSectionsInChunk(i).flatMap((entitysection) -> {
return entitysection.getEntities().filter(EntityAccess::shouldBeSaved);
}).collect(Collectors.toList());
if (list.isEmpty()) {
if (persistententitysectionmanager_b == PersistentEntitySectionManager.b.LOADED) {
+ if (callEvent) CraftEventFactory.callEntitiesUnloadEvent(((EntityStorage) permanentStorage).level, new ChunkCoordIntPair(i), ImmutableList.of()); // CraftBukkit
this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkCoordIntPair(i), ImmutableList.of()));
if (persistententitysectionmanager_b == PersistentEntitySectionManager.ChunkLoadStatus.LOADED) {
- this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkPos(chunkPos), ImmutableList.of()));
+ if (callEvent) CraftEventFactory.callEntitiesUnloadEvent(((EntityStorage) this.permanentStorage).level, new ChunkPos(i), ImmutableList.of()); // CraftBukkit
+ this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkPos(i), ImmutableList.of()));
}
@@ -215,6 +238,7 @@
this.requestChunkLoad(i);
return true;
} else if (persistententitysectionmanager_b == PersistentEntitySectionManager.ChunkLoadStatus.FRESH) {
- this.requestChunkLoad(chunkPos);
+ this.requestChunkLoad(i);
return false;
} else {
+ if (callEvent) CraftEventFactory.callEntitiesUnloadEvent(((EntityStorage) permanentStorage).level, new ChunkCoordIntPair(i), list.stream().map(entity -> (Entity) entity).collect(Collectors.toList())); // CraftBukkit
this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkCoordIntPair(i), list));
list.forEach(consumer);
- this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkPos(chunkPos), list));
- list.forEach(action);
+ if (callEvent) CraftEventFactory.callEntitiesUnloadEvent(((EntityStorage) this.permanentStorage).level, new ChunkPos(i), list.stream().map(entity -> (Entity) entity).collect(Collectors.toList())); // CraftBukkit
+ this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkPos(i), list));
+ list.forEach(consumer);
return true;
@@ -238,7 +262,7 @@
private boolean processChunkUnload(long i) {
boolean flag = this.storeChunkSections(i, (entityaccess) -> {
}
}
@@ -238,7 +261,7 @@
private boolean processChunkUnload(long chunkPos) {
boolean flag = this.storeChunkSections(chunkPos, (entityaccess) -> {
entityaccess.getPassengersAndSelf().forEach(this::unloadEntity);
- });
+ }, true); // CraftBukkit - add boolean for event call
if (!flag) {
return false;
@@ -249,24 +273,28 @@
@@ -249,24 +272,28 @@
}
private void unloadEntity(EntityAccess entityaccess) {
- entityaccess.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK);
+ entityaccess.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveEvent.Cause.UNLOAD); // CraftBukkit - add Bukkit remove cause
entityaccess.setLevelCallback(EntityInLevelCallback.NULL);
private void unloadEntity(EntityAccess entity) {
- entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK);
+ entity.setRemoved(Entity.RemovalReason.UNLOADED_TO_CHUNK, EntityRemoveEvent.Cause.UNLOAD); // CraftBukkit - add Bukkit remove cause
entity.setLevelCallback(EntityInLevelCallback.NULL);
}
private void processUnloads() {
@@ -92,15 +107,15 @@
chunkentities.getEntities().forEach((entityaccess) -> {
this.addEntity(entityaccess, true);
});
this.chunkLoadStatuses.put(chunkentities.getPos().toLong(), PersistentEntitySectionManager.b.LOADED);
this.chunkLoadStatuses.put(chunkentities.getPos().toLong(), PersistentEntitySectionManager.ChunkLoadStatus.LOADED);
+ // CraftBukkit start - call entity load event
+ List<Entity> entities = getEntities(chunkentities.getPos());
+ CraftEventFactory.callEntitiesLoadEvent(((EntityStorage) permanentStorage).level, chunkentities.getPos(), entities);
+ List<Entity> entities = this.getEntities(chunkentities.getPos());
+ CraftEventFactory.callEntitiesLoadEvent(((EntityStorage) this.permanentStorage).level, chunkentities.getPos(), entities);
+ // CraftBukkit end
}
}
@@ -292,7 +320,7 @@
@@ -292,7 +319,7 @@
}
public void autoSave() {
@@ -109,7 +124,7 @@
boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN;
if (flag) {
@@ -311,7 +339,7 @@
@@ -311,7 +338,7 @@
while (!longset.isEmpty()) {
this.permanentStorage.flush(false);
this.processPendingLoads();
@@ -118,13 +133,13 @@
boolean flag = this.chunkVisibility.get(i) == Visibility.HIDDEN;
return flag ? this.processChunkUnload(i) : this.storeChunkSections(i, (entityaccess) -> {
@@ -323,7 +351,15 @@
@@ -323,7 +350,15 @@
}
public void close() throws IOException {
- this.saveAll();
+ // CraftBukkit start - add save boolean
+ close(true);
+ this.close(true);
+ }
+
+ public void close(boolean save) throws IOException {
@@ -135,19 +150,19 @@
this.permanentStorage.close();
}
@@ -350,7 +386,7 @@
@@ -350,7 +385,7 @@
public void dumpSections(Writer writer) throws IOException {
CSVWriter csvwriter = CSVWriter.builder().addColumn("x").addColumn("y").addColumn("z").addColumn("visibility").addColumn("load_status").addColumn("entity_count").build(writer);
CsvOutput csvwriter = CsvOutput.builder().addColumn("x").addColumn("y").addColumn("z").addColumn("visibility").addColumn("load_status").addColumn("entity_count").build(writer);
- this.sectionStorage.getAllChunksWithExistingSections().forEach((i) -> {
+ this.sectionStorage.getAllChunksWithExistingSections().forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error
PersistentEntitySectionManager.b persistententitysectionmanager_b = (PersistentEntitySectionManager.b) this.chunkLoadStatuses.get(i);
PersistentEntitySectionManager.ChunkLoadStatus persistententitysectionmanager_b = (PersistentEntitySectionManager.ChunkLoadStatus) this.chunkLoadStatuses.get(i);
this.sectionStorage.getExistingSectionPositionsInChunk(i).forEach((j) -> {
@@ -394,7 +430,7 @@
@@ -394,7 +429,7 @@
private EntitySection<T> currentSection;
a(final EntityAccess entityaccess, final long i, final EntitySection entitysection) {
Callback(final EntityAccess entityaccess, final long i, final EntitySection entitysection) {
- this.entity = entityaccess;
+ this.entity = (T) entityaccess; // CraftBukkit - decompile error
this.currentSectionKey = i;