Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dd7ef6701a | |||
| 43036f971c | |||
| 25ce58c40d | |||
| 106f1edb09 | |||
| eea830188f | |||
| f517cc0b8a | |||
| d90c8567d3 | |||
| 78b3a8a6e7 | |||
| 2f93769135 | |||
| 4e277ad91e | |||
| 1620687dba | |||
| 7b7eb911c9 |
@@ -68,7 +68,11 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("fun.bm.lophine:lophine-api:$VERSION")
|
||||
compileOnly("fun.bm.lophine:lophine-api:26.2.build.+")
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
|
||||
}
|
||||
```
|
||||
|
||||
@@ -86,7 +90,7 @@ dependencies {
|
||||
<dependency>
|
||||
<groupId>fun.bm.lophine</groupId>
|
||||
<artifactId>lophine-api</artifactId>
|
||||
<version>$VERSION</version>
|
||||
<version>[26.2.build,)</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
+6
-2
@@ -67,7 +67,11 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("fun.bm.lophine:lophine-api:$VERSION")
|
||||
compileOnly("fun.bm.lophine:lophine-api:26.2.build.+")
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,7 +89,7 @@ dependencies {
|
||||
<dependency>
|
||||
<groupId>fun.bm.lophine</groupId>
|
||||
<artifactId>lophine-api</artifactId>
|
||||
<version>$VERSION</version>
|
||||
<version>[26.2.build,)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||
|
||||
plugins {
|
||||
java // TODO java launcher tasks
|
||||
id("moe.luminolmc.hyacinthusweight.patcher")
|
||||
id("fun.bm.comfreyweight.patcher")
|
||||
}
|
||||
|
||||
paperweight {
|
||||
|
||||
+4
-4
@@ -2,14 +2,14 @@ group=fun.bm.lophine
|
||||
mcVersion=26.2
|
||||
apiVersion=26.2
|
||||
channel=STABLE
|
||||
clipVersion=1.0.0
|
||||
weightVersion=2.0.15
|
||||
clipVersion=1.0.1
|
||||
weightVersion=1.0.0
|
||||
# true for release, false for skip release, pre for pre-release
|
||||
release=pre
|
||||
release=true
|
||||
# true for push to repo, false for skip push repo, auto for detect by release value
|
||||
pushRepo=auto
|
||||
|
||||
foliaRef=602048cb815db2ded68cca8cd43f480b983185a1
|
||||
foliaRef=e48800d446d2bdeb24a8d31d671554440687e846
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
org.gradle.caching=true
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
`maven-publish`
|
||||
idea
|
||||
- id("io.papermc.paperweight.core")
|
||||
+ id("moe.luminolmc.hyacinthusweight.core") // TODO Later - rebrand
|
||||
+ id("fun.bm.comfreyweight.core")
|
||||
id("io.papermc.fill.gradle") version "1.0.12"
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
dependencies {
|
||||
mache("io.papermc:mache:26.2+build.1")
|
||||
- paperclip("io.papermc:paperclip:3.0.4")
|
||||
+ hyacinthusclip("fun.bm:morninggloryclip:${providers.gradleProperty("clipVersion").get()}") // TODO Later - rebrand
|
||||
+ morninggloryclip("fun.bm:morninggloryclip:${providers.gradleProperty("clipVersion").get()}")
|
||||
}
|
||||
|
||||
paperweight {
|
||||
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Luminol Config System
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java
|
||||
index a4d608d64b7d3477c9144d93547fd3b4f39a1b02..2a75f8fbd2e5f41ca138740319d34683915e3b5b 100644
|
||||
index e2939cc39a8c103e4c4d7b01d39b5546486e4fbc..a557d488e4e289a61aeb9aed0cc133a0a7ce8f8c 100644
|
||||
--- a/net/minecraft/server/Main.java
|
||||
+++ b/net/minecraft/server/Main.java
|
||||
@@ -107,6 +107,7 @@ public class Main {
|
||||
@@ -110,6 +110,7 @@ public class Main {
|
||||
JvmProfiler.INSTANCE.start(Environment.SERVER);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Correct player respawn place
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index fbe0ef19bfabfc42d9e0e08e17b08159321b3804..44b3dfbf529630d8cca9a4270ae2a7c94c5a077c 100644
|
||||
index 57f93d978fe48fdf6e77b7bfb9f1de060e1a8524..924d5f3236d9ba9836f39fc844392099df9cd25c 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -511,8 +511,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -43,7 +43,7 @@ index fbe0ef19bfabfc42d9e0e08e17b08159321b3804..44b3dfbf529630d8cca9a4270ae2a7c9
|
||||
if (inChunk == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -2018,7 +2030,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -1997,7 +2009,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
}
|
||||
|
||||
if (newLevel.dimension() == lastDimension) {
|
||||
|
||||
+59
-56
@@ -1,11 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Sun, 28 Jun 2026 18:54:50 +0800
|
||||
Subject: [PATCH] Configurable region format framework
|
||||
Subject: [PATCH] Anonymous Object: Configurable region format framework
|
||||
|
||||
As requested by the original author, this patch will be anonymous and hide the original commit address.
|
||||
This patch is used with permission from the original author.
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java b/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
|
||||
index a814512fcfb85312474ae2c2c21443843bf57831..2e084a5b28cbe4737f48c25e10af589213525362 100644
|
||||
index a814512fcfb85312474ae2c2c21443843bf57831..9d69a022872e06b320bee46329cd8889f74fbbaa 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
|
||||
@@ -8,9 +8,9 @@ public interface ChunkSystemRegionFileStorage {
|
||||
@@ -13,15 +16,15 @@ index a814512fcfb85312474ae2c2c21443843bf57831..2e084a5b28cbe4737f48c25e10af5892
|
||||
public boolean moonrise$doesRegionFileNotExistNoIO(final int chunkX, final int chunkZ);
|
||||
|
||||
- public RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ);
|
||||
+ public abomination.IRegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ); // Luminol - Configurable region file format
|
||||
+ public io.anonymous.anonymous.data.RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ); // Anonymous - Configurable region file format
|
||||
|
||||
- public RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException;
|
||||
+ public abomination.IRegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException; // Luminol - Configurable region file format
|
||||
+ public io.anonymous.anonymous.data.RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException; // Anonymous - Configurable region file format
|
||||
|
||||
public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(
|
||||
final int chunkX, final int chunkZ, final CompoundTag compound
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java b/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java
|
||||
index 3bb9b58ee97464687e348e23b99159226415c267..fc264727141c3897e6c06819b9713d4f6395baf0 100644
|
||||
index 3bb9b58ee97464687e348e23b99159226415c267..4c3ad63f17bb4a04f982b36ad3f53d3c0f58bdb5 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java
|
||||
@@ -1273,7 +1273,7 @@ public final class MoonriseRegionFileIO {
|
||||
@@ -29,7 +32,7 @@ index 3bb9b58ee97464687e348e23b99159226415c267..fc264727141c3897e6c06819b9713d4f
|
||||
// Paper start - flush regionfiles on save
|
||||
if (this.world.paperConfig().chunks.flushRegionsOnSave) {
|
||||
- final RegionFile regionFile = this.regionDataController.getCache().moonrise$getRegionFileIfLoaded(this.chunkX, this.chunkZ);
|
||||
+ final abomination.IRegionFile regionFile = this.regionDataController.getCache().moonrise$getRegionFileIfLoaded(this.chunkX, this.chunkZ); // Luminol - Add configurable region file
|
||||
+ final io.anonymous.anonymous.data.RegionFile regionFile = this.regionDataController.getCache().moonrise$getRegionFileIfLoaded(this.chunkX, this.chunkZ); // Anonymous - Configurable region file format
|
||||
if (regionFile != null) {
|
||||
regionFile.flush();
|
||||
} // else: evicted from cache, which should have called flush
|
||||
@@ -38,12 +41,12 @@ index 3bb9b58ee97464687e348e23b99159226415c267..fc264727141c3897e6c06819b9713d4f
|
||||
public static interface IORunnable {
|
||||
|
||||
- public void run(final RegionFile regionFile) throws IOException;
|
||||
+ public void run(final abomination.IRegionFile regionFile) throws IOException; // Luminol - Configurable region file format
|
||||
+ public void run(final io.anonymous.anonymous.data.RegionFile regionFile) throws IOException; // Anonymous - Configurable region file format
|
||||
|
||||
}
|
||||
}
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkBuffer.java b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkBuffer.java
|
||||
index 51c126735ace8fdde89ad97b5cab62f244212db0..c7d4d944eb198ac53a3eeae717a25c7d5815c8c1 100644
|
||||
index 51c126735ace8fdde89ad97b5cab62f244212db0..ea2f45964fb8c617f90938597c230b50d83744aa 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkBuffer.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/storage/ChunkSystemChunkBuffer.java
|
||||
@@ -8,5 +8,5 @@ public interface ChunkSystemChunkBuffer {
|
||||
@@ -51,10 +54,10 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..c7d4d944eb198ac53a3eeae717a25c7d
|
||||
public void moonrise$setWriteOnClose(final boolean value);
|
||||
|
||||
- public void moonrise$write(final RegionFile regionFile) throws IOException;
|
||||
+ public void moonrise$write(final abomination.IRegionFile regionFile) throws IOException; // Luminol - Configurable region file format
|
||||
+ public void moonrise$write(final io.anonymous.anonymous.data.RegionFile regionFile) throws IOException; // Anonymous - Configurable region file format
|
||||
}
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index a49c46eb7df50fc3c5587a2c3668ab6edc887107..83b9aab16124ddcc416f7b4cd95084e1c64fe5b7 100644
|
||||
index a49c46eb7df50fc3c5587a2c3668ab6edc887107..c74f76b46259204b33b69ad08bb03c81b8b36961 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -986,10 +986,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -62,16 +65,16 @@ index a49c46eb7df50fc3c5587a2c3668ab6edc887107..83b9aab16124ddcc416f7b4cd95084e1
|
||||
for (ServerLevel level : this.getAllLevels()) {
|
||||
String storageName = level.getChunkSource().chunkMap.getStorageName();
|
||||
- LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", LEGACY_WORLD_NAMES_FOR_REALMS_LOG.getOrDefault(storageName, storageName));
|
||||
+ LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", LEGACY_WORLD_NAMES_FOR_REALMS_LOG.getOrDefault(storageName, storageName)); // Luminol - configurable region format
|
||||
+ LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", LEGACY_WORLD_NAMES_FOR_REALMS_LOG.getOrDefault(storageName, storageName)); // Anonymous - Configurable region format
|
||||
}
|
||||
|
||||
- LOGGER.info("ThreadedAnvilChunkStorage: All dimensions are saved");
|
||||
+ LOGGER.info("ThreadedChunkStorage: All dimensions are saved"); // Luminol - configurable region format
|
||||
+ LOGGER.info("ThreadedChunkStorage: All dimensions are saved"); // Anonymous - configurable region format
|
||||
}
|
||||
|
||||
return result;
|
||||
diff --git a/net/minecraft/util/worldupdate/FileToUpgrade.java b/net/minecraft/util/worldupdate/FileToUpgrade.java
|
||||
index a7f2cfa9277c898038f6b9e0a3401db51012b64c..db4dba8849eb27f8f84acc3297e342da4700d839 100644
|
||||
index a7f2cfa9277c898038f6b9e0a3401db51012b64c..7b96f3ec2738875a3ed7aa34347c0f174b6579c5 100644
|
||||
--- a/net/minecraft/util/worldupdate/FileToUpgrade.java
|
||||
+++ b/net/minecraft/util/worldupdate/FileToUpgrade.java
|
||||
@@ -4,5 +4,5 @@ import java.util.List;
|
||||
@@ -79,10 +82,10 @@ index a7f2cfa9277c898038f6b9e0a3401db51012b64c..db4dba8849eb27f8f84acc3297e342da
|
||||
import net.minecraft.world.level.chunk.storage.RegionFile;
|
||||
|
||||
-public record FileToUpgrade(RegionFile file, List<ChunkPos> chunksToUpgrade) {
|
||||
+public record FileToUpgrade(abomination.IRegionFile file, List<ChunkPos> chunksToUpgrade) { // Luminol - Configurable region file format
|
||||
+public record FileToUpgrade(io.anonymous.anonymous.data.RegionFile file, List<ChunkPos> chunksToUpgrade) { // Anonymous - Configurable region file format
|
||||
}
|
||||
diff --git a/net/minecraft/util/worldupdate/RegionStorageUpgrader.java b/net/minecraft/util/worldupdate/RegionStorageUpgrader.java
|
||||
index b228cd6c54e8c8998923ab332882d99092769c67..140ef4959fa2fe5b9cd251955c93683e8e69d5ba 100644
|
||||
index b228cd6c54e8c8998923ab332882d99092769c67..2dd3d0afd8f58e5e68a361dd38c95da06b4d133b 100644
|
||||
--- a/net/minecraft/util/worldupdate/RegionStorageUpgrader.java
|
||||
+++ b/net/minecraft/util/worldupdate/RegionStorageUpgrader.java
|
||||
@@ -36,7 +36,7 @@ import org.slf4j.Logger;
|
||||
@@ -90,7 +93,7 @@ index b228cd6c54e8c8998923ab332882d99092769c67..140ef4959fa2fe5b9cd251955c93683e
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final String NEW_DIRECTORY_PREFIX = "new_";
|
||||
- private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
||||
+ private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\." + me.earthme.luminol.config.modules.function.RegionFormatConfig.regionFormat.getArgument() + "$"); // Luminol - Configurable region file format
|
||||
+ private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\." + me.earthme.luminol.config.modules.function.RegionFormatConfig.regionFormat.getArgument() + "$"); // Anonymous - Configurable region file format
|
||||
private final DataFixer dataFixer;
|
||||
private final UpgradeProgress upgradeProgress;
|
||||
private final String type;
|
||||
@@ -99,8 +102,8 @@ index b228cd6c54e8c8998923ab332882d99092769c67..140ef4959fa2fe5b9cd251955c93683e
|
||||
List<ChunkPos> chunkPositions = Lists.newArrayList();
|
||||
|
||||
- try (RegionFile regionSource = new RegionFile(info, regionFile.toPath(), regionFolder, true)) {
|
||||
+ var regionFileInfo = new me.earthme.luminol.utils.RegionCreatorInfo(info, regionFile.toPath(), regionFolder, true); // Luminol - Configurable region file format
|
||||
+ try (abomination.IRegionFile regionSource = me.earthme.luminol.config.modules.function.RegionFormatConfig.regionFormat.getCreator().create(regionFileInfo)) { // Luminol - Configurable region file format
|
||||
+ var regionFileInfo = new io.anonymous.anonymous.utils.RegionCreatorInfo(info, regionFile.toPath(), regionFolder, true); // Anonymous - Configurable region file format
|
||||
+ try (io.anonymous.anonymous.data.RegionFile regionSource = me.earthme.luminol.config.modules.function.RegionFormatConfig.regionFormat.getCreator().newFile(regionFileInfo)) { // Anonymous - Configurable region file format
|
||||
for (int x = 0; x < 32; x++) {
|
||||
for (int z = 0; z < 32; z++) {
|
||||
ChunkPos pos = new ChunkPos(x + xOffset, z + zOffset);
|
||||
@@ -109,12 +112,12 @@ index b228cd6c54e8c8998923ab332882d99092769c67..140ef4959fa2fe5b9cd251955c93683e
|
||||
}
|
||||
|
||||
- private void onFileFinished(final RegionFile regionFile) {
|
||||
+ private void onFileFinished(final abomination.IRegionFile regionFile) { // Luminol - Configurable region file format
|
||||
+ private void onFileFinished(final io.anonymous.anonymous.data.RegionFile regionFile) { // Anonymous - Configurable region file format
|
||||
if (this.recreateRegionFiles) {
|
||||
if (this.previousWriteFuture != null) {
|
||||
this.previousWriteFuture.join();
|
||||
diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..d3350dee1d6d5bc15dcdfba3611f93addb767392 100644
|
||||
index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..821924f85a507589a039832be8657e1dc3c0ce0c 100644
|
||||
--- a/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.world.level.ChunkPos;
|
||||
@@ -122,7 +125,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..d3350dee1d6d5bc15dcdfba3611f93ad
|
||||
import org.slf4j.Logger;
|
||||
|
||||
-public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile { // Paper - rewrite chunk system
|
||||
+public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile , abomination.IRegionFile{ // Paper - rewrite chunk system // Luminol - Configurable region file format
|
||||
+public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile , io.anonymous.anonymous.data.RegionFile{ // Paper - rewrite chunk system // Anonymous - Configurable region file format
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final int MAX_CHUNK_SIZE = 500 * 1024 * 1024; // Paper - don't write garbage data to disk if writing serialization fails
|
||||
private static final int SECTOR_BYTES = 4096;
|
||||
@@ -131,7 +134,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..d3350dee1d6d5bc15dcdfba3611f93ad
|
||||
}
|
||||
|
||||
- boolean recalculateHeader() throws IOException {
|
||||
+ public boolean recalculateHeader() throws IOException { // Luminol - Configurable region file format
|
||||
+ public boolean recalculateHeader() throws IOException { // Anonymous - Configurable region file format
|
||||
if (!this.canRecalcHeader) {
|
||||
return false;
|
||||
}
|
||||
@@ -140,7 +143,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..d3350dee1d6d5bc15dcdfba3611f93ad
|
||||
}
|
||||
|
||||
- protected synchronized void write(final ChunkPos pos, final ByteBuffer data) throws IOException {
|
||||
+ public synchronized void write(final ChunkPos pos, final ByteBuffer data) throws IOException { // Luminol - Configurable region file format
|
||||
+ public synchronized void write(final ChunkPos pos, final ByteBuffer data) throws IOException { // Anonymous - Configurable region file format
|
||||
int offsetIndex = getOffsetIndex(pos);
|
||||
int offset = this.offsets.get(offsetIndex);
|
||||
int sectorNumber = getSectorNumber(offset);
|
||||
@@ -149,7 +152,7 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..d3350dee1d6d5bc15dcdfba3611f93ad
|
||||
|
||||
@Override
|
||||
- public final void moonrise$write(final RegionFile regionFile) throws IOException {
|
||||
+ public final void moonrise$write(final abomination.IRegionFile regionFile) throws IOException { // Luminol - Configurable region file format
|
||||
+ public final void moonrise$write(final io.anonymous.anonymous.data.RegionFile regionFile) throws IOException { // Anonymous - Configurable region file format
|
||||
regionFile.write(this.pos, ByteBuffer.wrap(this.buf, 0, this.count));
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
@@ -158,12 +161,12 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..d3350dee1d6d5bc15dcdfba3611f93ad
|
||||
}
|
||||
|
||||
- synchronized boolean isOversized(int x, int z) {
|
||||
+ public synchronized boolean isOversized(int x, int z) { // Luminol - Configurable region file format
|
||||
+ public synchronized boolean isOversized(int x, int z) { // Anonymous - Configurable region file format
|
||||
return this.oversized[getChunkIndex(x, z)] == 1;
|
||||
}
|
||||
|
||||
- synchronized void setOversized(int x, int z, boolean oversized) throws IOException {
|
||||
+ public synchronized void setOversized(int x, int z, boolean oversized) throws IOException { // Luminol - Configurable region file format
|
||||
+ public synchronized void setOversized(int x, int z, boolean oversized) throws IOException { // Anonymous - Configurable region file format
|
||||
final int offset = getChunkIndex(x, z);
|
||||
boolean previous = this.oversized[offset] == 1;
|
||||
this.oversized[offset] = (byte) (oversized ? 1 : 0);
|
||||
@@ -172,12 +175,12 @@ index 3de7fd2b084c38e72d7a6bc416880a881f514ad3..d3350dee1d6d5bc15dcdfba3611f93ad
|
||||
}
|
||||
|
||||
- synchronized net.minecraft.nbt.CompoundTag getOversizedData(int x, int z) throws IOException {
|
||||
+ public synchronized net.minecraft.nbt.CompoundTag getOversizedData(int x, int z) throws IOException { // Luminol - Configurable region file format
|
||||
+ public synchronized net.minecraft.nbt.CompoundTag getOversizedData(int x, int z) throws IOException { // Anonymous - Configurable region file format
|
||||
Path file = getOversizedFile(x, z);
|
||||
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new java.util.zip.InflaterInputStream(Files.newInputStream(file))))) {
|
||||
return net.minecraft.nbt.NbtIo.read((java.io.DataInput) out);
|
||||
diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977ebfb18517 100644
|
||||
index 63b40c420030d935bb81a219fb33defe0946e21f..e0e19f091f6b85d7788259cfcc53cc3db848b68e 100644
|
||||
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -19,7 +19,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||
@@ -185,7 +188,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
public static final String ANVIL_EXTENSION = ".mca";
|
||||
private static final int MAX_CACHE_SIZE = 256;
|
||||
- private final Long2ObjectLinkedOpenHashMap<RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>();
|
||||
+ private final Long2ObjectLinkedOpenHashMap<abomination.IRegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>(); // Luminol - Configurable region file format
|
||||
+ private final Long2ObjectLinkedOpenHashMap<io.anonymous.anonymous.data.RegionFile> regionCache = new Long2ObjectLinkedOpenHashMap<>(); // Anonymous - Configurable region file format
|
||||
private final RegionStorageInfo info;
|
||||
private final Path folder;
|
||||
private final boolean sync;
|
||||
@@ -194,7 +197,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
public static ChunkPos getRegionFileCoordinates(Path file) {
|
||||
String fileName = file.getFileName().toString();
|
||||
- if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
|
||||
+ if (!fileName.startsWith("r.") || !fileName.endsWith(getExtensionName())) { // Luminol - Configurable region file format
|
||||
+ if (!fileName.startsWith("r.") || !fileName.endsWith(getExtensionName())) { // Anonymous - Configurable region file format
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -203,32 +206,32 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
private final it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet nonExistingRegionFiles = new it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet();
|
||||
private static String getRegionFileName(final int chunkX, final int chunkZ) {
|
||||
- return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + ".mca";
|
||||
+ return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + getExtensionName(); // Luminol - Configurable region file format
|
||||
+ return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + getExtensionName(); // Anonymous - Configurable region file format
|
||||
}
|
||||
+ // Luminol start - Configurable region file format
|
||||
+ public static abomination.IRegionFile createNew(RegionStorageInfo info, Path filePath, Path folder, boolean sync) throws IOException{
|
||||
+ final me.earthme.luminol.enums.EnumRegionFormat regionFormat = me.earthme.luminol.config.modules.function.RegionFormatConfig.regionFormat;
|
||||
+ // Anonymous start - Configurable region file format
|
||||
+ public static io.anonymous.anonymous.data.RegionFile createNew(RegionStorageInfo info, Path filePath, Path folder, boolean sync) throws IOException{
|
||||
+ final io.anonymous.anonymous.enums.EnumRegionFormat regionFormat = me.earthme.luminol.config.modules.function.RegionFormatConfig.regionFormat;
|
||||
+ final String fullFileName = filePath.getFileName().toString();
|
||||
+ final String[] fullNameSplit = fullFileName.split("\\.");
|
||||
+ final String extensionName = fullNameSplit[fullNameSplit.length - 1];
|
||||
+
|
||||
+ if (!regionFormat.getArgument().equalsIgnoreCase(extensionName)) {
|
||||
+ // delayed crash
|
||||
+ // raise a delayed crash
|
||||
+ io.papermc.paper.threadedregions.RegionizedServer.getInstance().addTask(() -> {
|
||||
+ new RuntimeException("Invalid region file format: " + extensionName + " expected " + regionFormat.getArgument());
|
||||
+ throw new RuntimeException("Invalid region file format: " + extensionName + " expected " + regionFormat.getArgument());
|
||||
+ });
|
||||
+
|
||||
+
|
||||
+ throw new IOException("Invalid region file format: " + extensionName + " expected " + regionFormat.getArgument());
|
||||
+ }
|
||||
+
|
||||
+ return regionFormat.getCreator().create(new me.earthme.luminol.utils.RegionCreatorInfo(info, filePath, folder, sync));
|
||||
+ return regionFormat.getCreator().newFile(new io.anonymous.anonymous.utils.RegionCreatorInfo(info, filePath, folder, sync));
|
||||
+ }
|
||||
+
|
||||
+ public static String getExtensionName() {
|
||||
+ return "." + me.earthme.luminol.config.modules.function.RegionFormatConfig.regionFormat.getArgument();
|
||||
+ }
|
||||
+ // Luminol end
|
||||
+ // Anonymous end
|
||||
|
||||
private boolean doesRegionFilePossiblyExist(final long position) {
|
||||
synchronized (this.nonExistingRegionFiles) {
|
||||
@@ -237,17 +240,17 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
|
||||
@Override
|
||||
- public synchronized final RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) {
|
||||
+ public synchronized final abomination.IRegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) { // Luminol - Configurable region file format
|
||||
+ public synchronized final io.anonymous.anonymous.data.RegionFile moonrise$getRegionFileIfLoaded(final int chunkX, final int chunkZ) { // Anonymous - Configurable region file format
|
||||
return this.regionCache.getAndMoveToFirst(ChunkPos.pack(chunkX >> REGION_SHIFT, chunkZ >> REGION_SHIFT));
|
||||
}
|
||||
|
||||
@Override
|
||||
- public synchronized final RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException {
|
||||
+ public synchronized final abomination.IRegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException { // Luminol - Configurable region file format
|
||||
+ public synchronized final io.anonymous.anonymous.data.RegionFile moonrise$getRegionFileIfExists(final int chunkX, final int chunkZ) throws IOException { // Anonymous - Configurable region file format
|
||||
final long key = ChunkPos.pack(chunkX >> REGION_SHIFT, chunkZ >> REGION_SHIFT);
|
||||
|
||||
- RegionFile ret = this.regionCache.getAndMoveToFirst(key);
|
||||
+ abomination.IRegionFile ret = this.regionCache.getAndMoveToFirst(key); // Luminol - Configurable region file format
|
||||
+ io.anonymous.anonymous.data.RegionFile ret = this.regionCache.getAndMoveToFirst(key); // Anonymous - Configurable region file format
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
@@ -256,7 +259,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
FileUtil.createDirectoriesSafe(this.folder);
|
||||
|
||||
- ret = new RegionFile(this.info, regionPath, this.folder, this.sync);
|
||||
+ ret = this.createNew(this.info, regionPath, this.folder, this.sync); // Luminol - Configurable region file format
|
||||
+ ret = this.createNew(this.info, regionPath, this.folder, this.sync); // Anonymous - Configurable region file format
|
||||
|
||||
this.regionCache.putAndMoveToFirst(key, ret);
|
||||
|
||||
@@ -265,7 +268,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
|
||||
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||
- final RegionFile regionFile = this.getRegionFile(pos);
|
||||
+ final abomination.IRegionFile regionFile = this.getRegionFile(pos); // Luminol - Configurable region file format
|
||||
+ final io.anonymous.anonymous.data.RegionFile regionFile = this.getRegionFile(pos); // Anonymous - Configurable region file format
|
||||
|
||||
// note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input
|
||||
// (and, the regionfile parameter is unused for writing until the write call)
|
||||
@@ -274,7 +277,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||
if (writeData.result() == ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.DELETE) {
|
||||
- final RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ);
|
||||
+ final abomination.IRegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Luminol - Configurable region file format
|
||||
+ final io.anonymous.anonymous.data.RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Anonymous - Configurable region file format
|
||||
if (regionFile != null) {
|
||||
regionFile.clear(pos);
|
||||
} // else: didn't exist
|
||||
@@ -283,7 +286,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
final int chunkX, final int chunkZ
|
||||
) throws IOException {
|
||||
- final RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ);
|
||||
+ final abomination.IRegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Luminol - Configurable region file format
|
||||
+ final io.anonymous.anonymous.data.RegionFile regionFile = this.moonrise$getRegionFileIfExists(chunkX, chunkZ); // Anonymous - Configurable region file format
|
||||
|
||||
final DataInputStream input = regionFile == null ? null : regionFile.getChunkDataInputStream(new ChunkPos(chunkX, chunkZ));
|
||||
|
||||
@@ -292,7 +295,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||
final ChunkPos headerChunkPos = SerializableChunkData.getChunkCoordinate(ret);
|
||||
- final RegionFile regionFile = this.getRegionFile(pos);
|
||||
+ final abomination.IRegionFile regionFile = this.getRegionFile(pos); // Luminol - Configurable region file format
|
||||
+ final io.anonymous.anonymous.data.RegionFile regionFile = this.getRegionFile(pos); // Anonymous - Configurable region file format
|
||||
|
||||
if (regionFile.getRecalculateCount() != readData.recalculateCount()) {
|
||||
return null;
|
||||
@@ -301,7 +304,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
// Paper end - rewrite chunk system
|
||||
// Paper start - rewrite chunk system
|
||||
- public RegionFile getRegionFile(ChunkPos pos) throws IOException {
|
||||
+ public abomination.IRegionFile getRegionFile(ChunkPos pos) throws IOException { // Luminol - Configurable region file format
|
||||
+ public io.anonymous.anonymous.data.RegionFile getRegionFile(ChunkPos pos) throws IOException { // Anonymous - Configurable region file format
|
||||
return this.getRegionFile(pos, false);
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
@@ -310,7 +313,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
}
|
||||
|
||||
- @org.jetbrains.annotations.Contract("_, false -> !null") private @Nullable RegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit
|
||||
+ @org.jetbrains.annotations.Contract("_, false -> !null") private abomination.@Nullable IRegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit // Luminol - Configurable region file format
|
||||
+ @org.jetbrains.annotations.Contract("_, false -> !null") private io.anonymous.anonymous.data.RegionFile getRegionFile(final ChunkPos pos, boolean existingOnly) throws IOException { // CraftBukkit // Anonymous - Configurable region file format
|
||||
// Paper start - rewrite chunk system
|
||||
if (existingOnly) {
|
||||
return this.moonrise$getRegionFileIfExists(pos.x(), pos.z());
|
||||
@@ -319,7 +322,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
final long key = ChunkPos.pack(pos.x() >> REGION_SHIFT, pos.z() >> REGION_SHIFT);
|
||||
|
||||
- RegionFile ret = this.regionCache.getAndMoveToFirst(key);
|
||||
+ abomination.IRegionFile ret = this.regionCache.getAndMoveToFirst(key); // Luminol - Configurable region file format
|
||||
+ io.anonymous.anonymous.data.RegionFile ret = this.regionCache.getAndMoveToFirst(key); // Anonymous - Configurable region file format
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
@@ -328,7 +331,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
FileUtil.createDirectoriesSafe(this.folder);
|
||||
|
||||
- ret = new RegionFile(this.info, regionPath, this.folder, this.sync);
|
||||
+ ret = this.createNew(this.info, regionPath, this.folder, this.sync); // Luminol - Configurable region file format
|
||||
+ ret = this.createNew(this.info, regionPath, this.folder, this.sync); // Anonymous - Configurable region file format
|
||||
|
||||
this.regionCache.putAndMoveToFirst(key, ret);
|
||||
|
||||
@@ -337,7 +340,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
}
|
||||
|
||||
- private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException {
|
||||
+ private static CompoundTag readOversizedChunk(abomination.IRegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // Luminol - Configurable region file format
|
||||
+ private static CompoundTag readOversizedChunk(io.anonymous.anonymous.data.RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // Anonymous - Configurable region file format
|
||||
synchronized (regionfile) {
|
||||
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
|
||||
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x(), chunkCoordinate.z());
|
||||
@@ -346,7 +349,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
public @Nullable CompoundTag read(final ChunkPos pos) throws IOException {
|
||||
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
- RegionFile region = this.getRegionFile(pos, true);
|
||||
+ abomination.IRegionFile region = this.getRegionFile(pos, true); // Luminol - Configurable region file format
|
||||
+ io.anonymous.anonymous.data.RegionFile region = this.getRegionFile(pos, true); // Anonymous - Configurable region file format
|
||||
if (region == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -355,7 +358,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
public void scanChunk(final ChunkPos pos, final StreamTagVisitor scanner) throws IOException {
|
||||
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
- RegionFile region = this.getRegionFile(pos, true);
|
||||
+ abomination.IRegionFile region = this.getRegionFile(pos, true); // Luminol - Configurable region file format
|
||||
+ io.anonymous.anonymous.data.RegionFile region = this.getRegionFile(pos, true); // Anonymous - Configurable region file format
|
||||
if (region == null) {
|
||||
return;
|
||||
}
|
||||
@@ -364,7 +367,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
public void write(final ChunkPos pos, final @Nullable CompoundTag value) throws IOException {
|
||||
if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) {
|
||||
- RegionFile region = this.getRegionFile(pos, value == null); // CraftBukkit // Paper - rewrite chunk system
|
||||
+ abomination.IRegionFile region = this.getRegionFile(pos, value == null); // CraftBukkit // Paper - rewrite chunk system // Luminol - Configurable region file format
|
||||
+ io.anonymous.anonymous.data.RegionFile region = this.getRegionFile(pos, value == null); // CraftBukkit // Paper - rewrite chunk system // Anonymous - Configurable region file format
|
||||
// Paper start - rewrite chunk system
|
||||
if (region == null) {
|
||||
// if the RegionFile doesn't exist, no point in deleting from it
|
||||
@@ -373,7 +376,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
synchronized (this) {
|
||||
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
|
||||
- for (final RegionFile regionFile : this.regionCache.values()) {
|
||||
+ for (final abomination.IRegionFile regionFile : this.regionCache.values()) { // Luminol - Configurable region file format
|
||||
+ for (final io.anonymous.anonymous.data.RegionFile regionFile : this.regionCache.values()) { // Anonymous - Configurable region file format
|
||||
try {
|
||||
regionFile.close();
|
||||
} catch (final IOException ex) {
|
||||
@@ -382,7 +385,7 @@ index 63b40c420030d935bb81a219fb33defe0946e21f..2e67e69862cbf5d804de50193442977e
|
||||
synchronized (this) {
|
||||
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
|
||||
- for (final RegionFile regionFile : this.regionCache.values()) {
|
||||
+ for (final abomination.IRegionFile regionFile : this.regionCache.values()) { // Luminol - Configurable region file format
|
||||
+ for (final io.anonymous.anonymous.data.RegionFile regionFile : this.regionCache.values()) { // Anonymous - Configurable region file format
|
||||
try {
|
||||
regionFile.flush();
|
||||
} catch (final IOException ex) {
|
||||
+2
-2
@@ -6,10 +6,10 @@ Subject: [PATCH] Do not enable any debug subscriptions
|
||||
Really this would really crash the server by accident when the operators used F3 + J or toggled the debug synchronizer
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 44b3dfbf529630d8cca9a4270ae2a7c94c5a077c..34cc36f6bdf435593d16f2e7af280a27be048280 100644
|
||||
index 924d5f3236d9ba9836f39fc844392099df9cd25c..fe34f2e648df9fd1174522baa5913976104b8d04 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -3504,7 +3504,8 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -3483,7 +3483,8 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
}
|
||||
|
||||
public Set<DebugSubscription<?>> debugSubscriptions() {
|
||||
|
||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Fix riding statistics desync
|
||||
Referred to: https://github.com/CraftCanvasMC/Canvas/commit/057175b0c10d5a4d1d9059fd9d077750c32633b2
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 34cc36f6bdf435593d16f2e7af280a27be048280..98d1ab3aa8dfbe571371d01544da2750339ce988 100644
|
||||
index fe34f2e648df9fd1174522baa5913976104b8d04..fee4749c7938779f63155297bf9c7aeb0ca21709 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -2537,7 +2537,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -2516,7 +2516,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ index 34cc36f6bdf435593d16f2e7af280a27be048280..98d1ab3aa8dfbe571371d01544da2750
|
||||
int distance = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
|
||||
Entity vehicle = this.getVehicle();
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index a2b57f62b745dd21e215f919d335f14f5cb1706f..2cf8bdf6c4ab04ab42829b7af5eb89e6bd509d7a 100644
|
||||
index 07310ae30817fc88227355739074615969b48184..47eef926f57053ace7ea140261570c4970822062 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4198,7 +4198,13 @@ public abstract class Entity
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ Almost the same bug as:
|
||||
https://github.com/PaperMC/Folia/pull/418 and https://github.com/PaperMC/Folia/issues/393
|
||||
|
||||
diff --git a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
index 501a0e89cc7bcfce6793f059b080b38666e0fb64..ad35eafa457f706879ba8a9c92b3a34e620ee2d6 100644
|
||||
index d0dba5cc351903fb762e231a95f302479794185f..fb00f70505a6c548cd1311d7ea55c6a501e814e3 100644
|
||||
--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
+++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
@@ -264,7 +264,8 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ index c6434ff2e5c211887c2e98c8462a49e0e1cb5b21..534f103234eb92571c664cbcfea4ce4e
|
||||
} else {entity.inactiveTick();} // Paper - EAR 2
|
||||
profiler.pop();
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 2cf8bdf6c4ab04ab42829b7af5eb89e6bd509d7a..a52d5c0ba970d666fd57e075d14350ff07401bac 100644
|
||||
index 47eef926f57053ace7ea140261570c4970822062..7953b7ece0b5e3f41e85252cdfd8e400fab212ae 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -387,6 +387,7 @@ public abstract class Entity
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ Subject: [PATCH] Fix player auto saving ignores interval
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 98d1ab3aa8dfbe571371d01544da2750339ce988..264de9099b19779f20ad23c41d0967670759ae12 100644
|
||||
index fee4749c7938779f63155297bf9c7aeb0ca21709..5668906866917f7bb6088ae16146d917d2b840b0 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -208,7 +208,7 @@ import org.slf4j.Logger;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ Subject: [PATCH] Force disable builtin spark plugin
|
||||
The spark passed down from paper has some memory leaking issue, so we fully removed it from the code to prevent that memory leaking issue.
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 83b9aab16124ddcc416f7b4cd95084e1c64fe5b7..7683c12d48d23dd43bce3d3b5633029c596930a5 100644
|
||||
index c74f76b46259204b33b69ad08bb03c81b8b36961..cc8364891a5d2196e8809479db984b67b5bcb079 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -672,8 +672,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ index c1faaf7d514c23d756aa626fa93aabd8bb503463..0c5fb17e7cce18eac68183cc3b5de6fc
|
||||
// If the event is cancelled we move the player back to their old location.
|
||||
if (event.isCancelled()) {
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index a52d5c0ba970d666fd57e075d14350ff07401bac..72f89eaba2ca8b66fa07a6378d93917dec83c688 100644
|
||||
index 7953b7ece0b5e3f41e85252cdfd8e400fab212ae..343e4bb41acfab4e50729aa5dbe2a071dac376a3 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4476,12 +4476,25 @@ public abstract class Entity
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ index b31b55f00e2ce1bd6c1011fe852bd1dbb37de524..75c36cbf86e56d4993169688a13f22cc
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 72f89eaba2ca8b66fa07a6378d93917dec83c688..6b7382f06a8c76b216b081e66789fe51466b1e29 100644
|
||||
index 343e4bb41acfab4e50729aa5dbe2a071dac376a3..c04917f31585d9d670cc98cda8eb36187f4261d7 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4460,6 +4460,7 @@ public abstract class Entity
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ On folia, entity usually cannot move out of the tickregion, but sometimes it act
|
||||
Reference from : https://github.com/KaiijuMC/Kaiiju/blob/ver/1.20.1/patches/server/0040-Teleport-async-if-we-cannot-move-entity-off-main.patch
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 6b7382f06a8c76b216b081e66789fe51466b1e29..8c909108a0c468f353837787188c12f907369b9b 100644
|
||||
index c04917f31585d9d670cc98cda8eb36187f4261d7..9270b887448023b6ace2e7fae6b632755ce90600 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1163,6 +1163,19 @@ public abstract class Entity
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ index 13d7965fd4f99f0848b080349df41f8b1c31a19b..5b83f2edd6afe94c28bf491afab737e9
|
||||
nmsEntity.stopRiding();
|
||||
nmsEntity.teleportAsync(
|
||||
diff --git a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
index ad35eafa457f706879ba8a9c92b3a34e620ee2d6..790c1bcf11150d31bf90c32345e4eb40de9a6a41 100644
|
||||
index fb00f70505a6c548cd1311d7ea55c6a501e814e3..4df9a3356cfdee52761db47694e59779976840db 100644
|
||||
--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
+++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
@@ -99,7 +99,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
|
||||
|
||||
@@ -228,7 +228,7 @@ index 5a72fa0d72bfdb927293abe921c57f6ae964a6ec..f8344f640f119e3865f2718d1abd0ede
|
||||
|
||||
private void uncaughtException(final Thread thread, final Throwable thr) {
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 7683c12d48d23dd43bce3d3b5633029c596930a5..ab61d18845827ac835edf92651d0b510358106ff 100644
|
||||
index cc8364891a5d2196e8809479db984b67b5bcb079..7c67a8a6cf83ab80d3a8b37c5ff03e7a56497bc9 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -236,7 +236,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -275,10 +275,10 @@ index 534f103234eb92571c664cbcfea4ce4e990d3ea8..c4d9d890db784d376b876d70f0468df6
|
||||
// CraftBukkit start
|
||||
private final ResourceKey<LevelStem> typeKey;
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 264de9099b19779f20ad23c41d0967670759ae12..ab6229ee412cf2aa5affc87510230c587765080b 100644
|
||||
index 5668906866917f7bb6088ae16146d917d2b840b0..4efbd0f840d74a3d96b28d38e48cba72d5c6fb9b 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1705,7 +1705,30 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -1694,7 +1694,30 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
|
||||
ServerLevel origin = this.level();
|
||||
ServerPlayer.RespawnConfig respawnConfig = this.getRespawnConfig();
|
||||
@@ -310,7 +310,7 @@ index 264de9099b19779f20ad23c41d0967670759ae12..ab6229ee412cf2aa5affc87510230c58
|
||||
|
||||
// modified based off PlayerList#respawn
|
||||
|
||||
@@ -1756,8 +1779,8 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -1745,8 +1768,8 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
// now the respawn logic is complete
|
||||
|
||||
// last, call the function callback
|
||||
@@ -429,7 +429,7 @@ index 48f51b0f94df3e59c9410129489c63a4287bc0bc..2682f8702785b1e501748a308c5e394b
|
||||
private final Vec2 spawnAngle;
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 8c909108a0c468f353837787188c12f907369b9b..1dd0ce3f8af52f5ba0da1d6617489a0de2c971b2 100644
|
||||
index 9270b887448023b6ace2e7fae6b632755ce90600..66ddbdb130867a508ba161a570d101dbe6353246 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -392,6 +392,9 @@ public abstract class Entity
|
||||
@@ -495,7 +495,7 @@ index 8c909108a0c468f353837787188c12f907369b9b..1dd0ce3f8af52f5ba0da1d6617489a0d
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -4864,6 +4886,13 @@ public abstract class Entity
|
||||
@@ -4868,6 +4890,13 @@ public abstract class Entity
|
||||
ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(initialPosition),
|
||||
ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkZ(initialPosition)
|
||||
);
|
||||
@@ -509,7 +509,7 @@ index 8c909108a0c468f353837787188c12f907369b9b..1dd0ce3f8af52f5ba0da1d6617489a0d
|
||||
|
||||
// first, remove entity/passengers from world
|
||||
EntityTreeNode passengerTree = this.detachPassengers();
|
||||
@@ -4921,6 +4950,10 @@ public abstract class Entity
|
||||
@@ -4925,6 +4954,10 @@ public abstract class Entity
|
||||
if (info.postTeleportTransition() != null) {
|
||||
info.postTeleportTransition().onTransition(teleported);
|
||||
}
|
||||
|
||||
+12
@@ -53,3 +53,15 @@ index c4d9d890db784d376b876d70f0468df6edb75168..0641b98ef3298eb682ceae83f60b730f
|
||||
} finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); } // Folia - profiler
|
||||
if (this.paperConfig().unsupportedSettings.ticking.blockEntities) { // Paper - option to disable ticking
|
||||
profiler.popPush("blockEntities");
|
||||
diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java
|
||||
index 6efaa78faca15c7a48bdffb24480d1bac29f3ba8..31619890f1bd4f458b6f9a31fac8cefaafe09e8e 100644
|
||||
--- a/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/net/minecraft/world/entity/EntityType.java
|
||||
@@ -73,6 +73,7 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T>,
|
||||
private final float spawnDimensionsScale;
|
||||
private final FeatureFlagSet requiredFeatures;
|
||||
private final boolean allowedInPeaceful;
|
||||
+ public volatile dev.kaiijumc.kaiiju.KaiijuEntityLimits.EntityLimit entityLimit;
|
||||
|
||||
public static Identifier getKey(final EntityType<?> type) {
|
||||
return BuiltInRegistries.ENTITY_TYPE.getKey(type);
|
||||
|
||||
+10
-9
@@ -8,10 +8,10 @@ As part of: Kaiiju (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2e
|
||||
Licensed under: GPL-3.0 (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2ec408e6411e6f752379da/LICENSE)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 1dd0ce3f8af52f5ba0da1d6617489a0de2c971b2..cf70a8e2fe2fe70bcdf71f8112479031d80d8b75 100644
|
||||
index 66ddbdb130867a508ba161a570d101dbe6353246..df82f900580ad1b71960eab890a7a6215f578421 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4676,14 +4676,18 @@ public abstract class Entity
|
||||
@@ -4676,15 +4676,19 @@ public abstract class Entity
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
@@ -28,13 +28,14 @@ index 1dd0ce3f8af52f5ba0da1d6617489a0de2c971b2..cf70a8e2fe2fe70bcdf71f8112479031
|
||||
portalInfoCompletable.complete(
|
||||
new net.minecraft.world.level.portal.TeleportTransition(
|
||||
- destination, Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, Direction.WEST.toYRot(), 0.0f,
|
||||
- Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)),
|
||||
+ destination, finalPos, this.getDeltaMovement(), Direction.WEST.toYRot(), 0.0f, // Kaiiju - Vanilla end teleportation
|
||||
false, false,
|
||||
- Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)),
|
||||
+ /*Relative.union(Relative.DELTA, Set.of(Relative.X_ROT))*/Set.of(), // Kaiiju - Vanilla end teleportation
|
||||
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL
|
||||
)
|
||||
@@ -4698,11 +4702,15 @@ public abstract class Entity
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL,
|
||||
TeleportTransition.PassengerTeleportationMode.POSITION_RIDER
|
||||
@@ -4700,11 +4704,15 @@ public abstract class Entity
|
||||
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
BlockPos adjustedSpawn = destination.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, spawnPos);
|
||||
@@ -49,10 +50,10 @@ index 1dd0ce3f8af52f5ba0da1d6617489a0de2c971b2..cf70a8e2fe2fe70bcdf71f8112479031
|
||||
new net.minecraft.world.level.portal.TeleportTransition(
|
||||
- destination, Vec3.atBottomCenterOf(adjustedSpawn), Vec3.ZERO, 0.0f, 0.0f,
|
||||
+ destination, finalPos, this.getDeltaMovement(), 0.0f, 0.0f, // Kaiiju - Vanilla end teleportation
|
||||
false, false,
|
||||
Relative.union(Relative.DELTA, Relative.ROTATION),
|
||||
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL
|
||||
@@ -4881,6 +4889,10 @@ public abstract class Entity
|
||||
@@ -4885,6 +4893,10 @@ public abstract class Entity
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ index 1dd0ce3f8af52f5ba0da1d6617489a0de2c971b2..cf70a8e2fe2fe70bcdf71f8112479031
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(initialPosition),
|
||||
@@ -4955,9 +4967,14 @@ public abstract class Entity
|
||||
@@ -4959,9 +4971,14 @@ public abstract class Entity
|
||||
destination.levelUnloadStateLock.releaseRead();
|
||||
// Luminol end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Add config for server mod name
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index ab61d18845827ac835edf92651d0b510358106ff..d4e31bb829451a687bf567fd0357f46fd7d46902 100644
|
||||
index 7c67a8a6cf83ab80d3a8b37c5ff03e7a56497bc9..b2823c71ecb5e1f7a3c4c5b9f691d4cdb5419db3 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2072,7 +2072,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ index 480b6b2405706fd4d7158d0e160adafd84099887..137389f7ee97fc3a15c8f5f87c058065
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/block/EndPortalBlock.java b/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
index d42bb2a1721e4ab8c9956e18c3ca418b8d648c59..4f06daf619596d4116140b0710ea92c2c8552fc0 100644
|
||||
index 123df098fa987030fe3789f36ff95aeee2979834..35b0632faf2709f65f731cd42e575ee967937254 100644
|
||||
--- a/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
+++ b/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
@@ -76,6 +76,12 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal {
|
||||
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Add config for vanilla random
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index cf70a8e2fe2fe70bcdf71f8112479031d80d8b75..17650e196f1e5b79765651bf302291873a4eb509 100644
|
||||
index df82f900580ad1b71960eab890a7a6215f578421..39f2b44846c02796a3671a5dec75b7b34d8c488e 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -298,7 +298,7 @@ public abstract class Entity
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ Subject: [PATCH] Add force the data command to be enabled config
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index bc9f6cc286536b87513de81855ad0b61cf787c84..afbaf2116930d72ebb0c77745d02115abab14dc4 100644
|
||||
index 4ddb5e7ce3529466c3930caa9aa6b18158e9a63d..9b1dcfadd6d5ae868b087a18983d03e8bb86b56a 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -202,7 +202,9 @@ public class Commands {
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ Subject: [PATCH] Add back read-only datapack command & Fix datapack command
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index afbaf2116930d72ebb0c77745d02115abab14dc4..6823c41c08ca1a1baf9257fc861ae97bbcbe3a50 100644
|
||||
index 9b1dcfadd6d5ae868b087a18983d03e8bb86b56a..21f2b9866e1cf36421e10a945fb6fbaa251009ed 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -205,7 +205,7 @@ public class Commands {
|
||||
@@ -19,7 +19,7 @@ index afbaf2116930d72ebb0c77745d02115abab14dc4..6823c41c08ca1a1baf9257fc861ae97b
|
||||
DefaultGameModeCommands.register(this.dispatcher);
|
||||
//DialogCommand.register(this.dispatcher, context); // Folia - region threading - TODO
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index d4e31bb829451a687bf567fd0357f46fd7d46902..4f292468194baae343eeb077362e51dcfb6c0df1 100644
|
||||
index b2823c71ecb5e1f7a3c4c5b9f691d4cdb5419db3..a82cafadf2136d30ae7bca172062713a651373ac 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2415,6 +2415,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
+4
-4
@@ -17,7 +17,7 @@ index 52dcbcf64c3a510d4a4524b7d0ee226d9a73511d..051d601e7e809518e8d82ae4ae325905
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 4f292468194baae343eeb077362e51dcfb6c0df1..f0a3fdaf7e9d342b472b3db42f5b59b0f6691b49 100644
|
||||
index a82cafadf2136d30ae7bca172062713a651373ac..e43aa6daa8d4465764348be5b82be5f163ef0819 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1743,7 +1743,46 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -106,7 +106,7 @@ index 0641b98ef3298eb682ceae83f60b730f3bf90103..cea4bc7036dfd8777c151a0dd811fc13
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index ab6229ee412cf2aa5affc87510230c587765080b..f0c574e039f80ff0227239356de8d61ef06a0936 100644
|
||||
index 4efbd0f840d74a3d96b28d38e48cba72d5c6fb9b..8e4bbb224d036cf9f33667aec57bbc339c9e8377 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -441,7 +441,9 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -183,10 +183,10 @@ index f03fa06c0ba56f7f5e1e45bc1568a490751efde3..eee1c14249addbf4714df733870da974
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 17650e196f1e5b79765651bf302291873a4eb509..f218b7f6ce32d7ac959255e59c620d6fd420bf8e 100644
|
||||
index 39f2b44846c02796a3671a5dec75b7b34d8c488e..fe0208815dbf53855d47956925b817570f6ae5b0 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -6468,4 +6468,6 @@ public abstract class Entity
|
||||
@@ -6479,4 +6479,6 @@ public abstract class Entity
|
||||
return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition());
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ index 58e557923dfe6cee39ec45e7f5aa43a5ded9f107..57a35d7a801621fc461e896eb2bba533
|
||||
this.scheduler.regionFailed(this, false, thr);
|
||||
// regionFailed will schedule a shutdown, so we should avoid letting this region tick further
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index 6823c41c08ca1a1baf9257fc861ae97bbcbe3a50..0fa14f60310b063f419620539fd40898627b46b9 100644
|
||||
index 21f2b9866e1cf36421e10a945fb6fbaa251009ed..aa7931c9b6dc3bba2c8dfecff8df2db302ad905b 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -259,7 +259,11 @@ public class Commands {
|
||||
|
||||
+6
-6
@@ -5,10 +5,10 @@ Subject: [PATCH] Add missing teleportation event APIs for folia
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index f0c574e039f80ff0227239356de8d61ef06a0936..093c48e2379c01f45277b88f6c1b19b107a46326 100644
|
||||
index 8e4bbb224d036cf9f33667aec57bbc339c9e8377..4397f77d0169a3eefd347d3097657de4f6d37ef8 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1814,6 +1814,9 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -1803,6 +1803,9 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
if (finalRespawnCompleteCallback != null) { // Luminol - Level hot unload apis
|
||||
finalRespawnCompleteCallback.accept(ServerPlayer.this); // Luminol - Level hot unload apis
|
||||
}
|
||||
@@ -19,7 +19,7 @@ index f0c574e039f80ff0227239356de8d61ef06a0936..093c48e2379c01f45277b88f6c1b19b1
|
||||
);
|
||||
});
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index f218b7f6ce32d7ac959255e59c620d6fd420bf8e..2ae0cf7c9a4febfa79a9eab2f0e9309a61a78f56 100644
|
||||
index fe0208815dbf53855d47956925b817570f6ae5b0..90b5d7806af8913735c4105b6e347bfdb78094e0 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4553,6 +4553,31 @@ public abstract class Entity
|
||||
@@ -72,7 +72,7 @@ index f218b7f6ce32d7ac959255e59c620d6fd420bf8e..2ae0cf7c9a4febfa79a9eab2f0e9309a
|
||||
// need to load chunks so we can create the platform
|
||||
destination.moonrise$loadChunksAsync(
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
@@ -4696,6 +4732,17 @@ public abstract class Entity
|
||||
@@ -4698,6 +4734,17 @@ public abstract class Entity
|
||||
);
|
||||
} else {
|
||||
BlockPos spawnPos = destination.getRespawnData().pos();
|
||||
@@ -90,7 +90,7 @@ index f218b7f6ce32d7ac959255e59c620d6fd420bf8e..2ae0cf7c9a4febfa79a9eab2f0e9309a
|
||||
// need to load chunk for heightmap
|
||||
destination.moonrise$loadChunksAsync(
|
||||
spawnPos, 0,
|
||||
@@ -4751,7 +4798,17 @@ public abstract class Entity
|
||||
@@ -4755,7 +4802,17 @@ public abstract class Entity
|
||||
WorldBorder destinationBorder = destination.getWorldBorder();
|
||||
double dimensionScale = net.minecraft.world.level.dimension.DimensionType.getTeleportationScale(origin.dimensionType(), destination.dimensionType());
|
||||
BlockPos targetPos = destination.getWorldBorder().clampToBounds(this.getX() * dimensionScale, this.getY(), this.getZ() * dimensionScale);
|
||||
@@ -108,7 +108,7 @@ index f218b7f6ce32d7ac959255e59c620d6fd420bf8e..2ae0cf7c9a4febfa79a9eab2f0e9309a
|
||||
ca.spottedleaf.concurrentutil.completable.CallbackCompletable<BlockUtil.FoundRectangle> portalFound
|
||||
= new ca.spottedleaf.concurrentutil.completable.CallbackCompletable<>();
|
||||
|
||||
@@ -4888,6 +4945,15 @@ public abstract class Entity
|
||||
@@ -4892,6 +4949,15 @@ public abstract class Entity
|
||||
if (!this.canPortalAsync(destination, takePassengers)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ index f32d118e1e925b2155cef3fcdcb1e194c541e242..2d5d4170e1f45ae9113c37623b406686
|
||||
// this is copy on write to allow packet processing to iterate safely
|
||||
private final CopyOnWriteArrayList<ServerPlayer> localPlayers = new CopyOnWriteArrayList<>();
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index f0a3fdaf7e9d342b472b3db42f5b59b0f6691b49..ac49bcc53951c025de0160fd8afd319b1f3d1347 100644
|
||||
index e43aa6daa8d4465764348be5b82be5f163ef0819..f4274e844018992bba7c32d2146198efc034631e 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1973,6 +1973,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ Subject: [PATCH] Add config for waypoint restoration
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index 0fa14f60310b063f419620539fd40898627b46b9..9800ae1d3c49800b0c7342d43d696109b5b72cf4 100644
|
||||
index aa7931c9b6dc3bba2c8dfecff8df2db302ad905b..c67ea715f02086e5a39cc5832ccdc0b32199db93 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -267,7 +267,7 @@ public class Commands {
|
||||
@@ -18,7 +18,7 @@ index 0fa14f60310b063f419620539fd40898627b46b9..9800ae1d3c49800b0c7342d43d696109
|
||||
WorldBorderCommand.register(this.dispatcher);
|
||||
if (JvmProfiler.INSTANCE.isAvailable()) {
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index ac49bcc53951c025de0160fd8afd319b1f3d1347..c91902632d0e97b814e387454b119edb62b67413 100644
|
||||
index f4274e844018992bba7c32d2146198efc034631e..42ee15c813761702031d5a63f0d080b135be2e0f 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -3127,8 +3127,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -47,7 +47,7 @@ index 402e2f01f2b3a8e9ce5c818f07581b4dab38fc26..a1c3f3e5c7c3f32e0bdead33ebd72c76
|
||||
//this.updateSkyBrightness(); // Folia - region threading - delay until first tick
|
||||
// Paper start - rewrite chunk system
|
||||
diff --git a/net/minecraft/world/waypoints/WaypointTransmitter.java b/net/minecraft/world/waypoints/WaypointTransmitter.java
|
||||
index 2866b750a28cc32c2913d3c1afee95f05956982c..f0b62f49382eb808dcd6b6b654b99b9f7763c342 100644
|
||||
index 07af92310ee5c8bba04e6175b6faac629632e4de..79561456c3b0877974ae1519443ebf8bd07533da 100644
|
||||
--- a/net/minecraft/world/waypoints/WaypointTransmitter.java
|
||||
+++ b/net/minecraft/world/waypoints/WaypointTransmitter.java
|
||||
@@ -76,7 +76,8 @@ public interface WaypointTransmitter extends Waypoint {
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ A part of Leaf(https://github.com/Winds-Studio/Leaf/blob/edb0504069139beaa6f39ef
|
||||
License: https://github.com/Winds-Studio/Leaf/blob/edb0504069139beaa6f39efa4702370c2576b3fc/LICENSE.md
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index c91902632d0e97b814e387454b119edb62b67413..4b6f961e695155db1d6cc86496491017bf3a6383 100644
|
||||
index 42ee15c813761702031d5a63f0d080b135be2e0f..1736816e26c255645d62696814cd539ee1ffed8d 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -217,7 +217,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
+2
-2
@@ -240,7 +240,7 @@ index 6e08d50794c4af4405f3e164a3fd46f376b3f78f..dd2d0940eece3e85078e574f66f71a4c
|
||||
|
||||
int getContainerSize();
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 2ae0cf7c9a4febfa79a9eab2f0e9309a61a78f56..6b3c691dcc9c9e4a8b2b43110aedd5d5131a9520 100644
|
||||
index 90b5d7806af8913735c4105b6e347bfdb78094e0..0ba8f401c9cd0e15187b4faee78667c543fded92 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -324,7 +324,7 @@ public abstract class Entity
|
||||
@@ -266,7 +266,7 @@ index 2ae0cf7c9a4febfa79a9eab2f0e9309a61a78f56..6b3c691dcc9c9e4a8b2b43110aedd5d5
|
||||
if (copy instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Luminol - Sync dragon part when teleportation or firstly created
|
||||
// vanilla code used to call remove _after_ copying, and some stuff is required to be after copy - so add hook here
|
||||
// for example, clearing of inventory after switching dimensions
|
||||
@@ -6140,8 +6142,29 @@ public abstract class Entity
|
||||
@@ -6151,8 +6153,29 @@ public abstract class Entity
|
||||
this.setBoundingBox(this.makeBoundingBox());
|
||||
}
|
||||
// Paper end - Block invalid positions and bounding box
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ VMP (https://github.com/RelativityMC/VMP-fabric)
|
||||
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 6b3c691dcc9c9e4a8b2b43110aedd5d5131a9520..d1298c499f6551d7a084f2d1ccd2a2b8b9a2475b 100644
|
||||
index 0ba8f401c9cd0e15187b4faee78667c543fded92..ae0504263666103a588b6855cb27304582c38938 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1155,8 +1155,14 @@ public abstract class Entity
|
||||
@@ -28,7 +28,7 @@ index 6b3c691dcc9c9e4a8b2b43110aedd5d5131a9520..d1298c499f6551d7a084f2d1ccd2a2b8
|
||||
final Vec3 originalMovement = delta; // Paper - Expose pre-collision velocity
|
||||
// Paper start - detailed watchdog information
|
||||
ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
@@ -5634,6 +5640,11 @@ public abstract class Entity
|
||||
@@ -5645,6 +5651,11 @@ public abstract class Entity
|
||||
}
|
||||
|
||||
public final void setBoundingBox(final AABB bb) {
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ As part of: Akarin (https://github.com/Akarin-project/Akarin)
|
||||
Licensed under: GPL-3.0-only (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index d1298c499f6551d7a084f2d1ccd2a2b8b9a2475b..1888210d014f9c00316059a7ccce086dfb0e3a0f 100644
|
||||
index ae0504263666103a588b6855cb27304582c38938..92cb0b1722bd5bcf9996c3f6b9b62c980b70e229 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -2441,8 +2441,8 @@ public abstract class Entity
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ License: GPL-3.0-only (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://github.com/GaleMC/Gale
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 1888210d014f9c00316059a7ccce086dfb0e3a0f..00bc928a19cb877698b34b7c039bee5fe8b5cda5 100644
|
||||
index 92cb0b1722bd5bcf9996c3f6b9b62c980b70e229..43e07a3c98e80f874f55411beac39e215ffdc3cf 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1302,8 +1302,17 @@ public abstract class Entity
|
||||
|
||||
@@ -137,7 +137,7 @@ index 2e71a1cbabf3405e3e4fd5349a1784d895e7e60c..42de919064680b1a464d813976ca5e69
|
||||
if (!itemStack.isEmpty()) {
|
||||
slots.add(Pair.of(slot, itemStack.copy()));
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 093c48e2379c01f45277b88f6c1b19b107a46326..b4d8cc8b520266abe1921b5e990c34fce3f1d982 100644
|
||||
index 4397f77d0169a3eefd347d3097657de4f6d37ef8..42e09148519596f95fc9c9c63df9c87e6ece3102 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1424,7 +1424,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
|
||||
@@ -26,10 +26,10 @@ index 47cd33bce908744e64356b585853d6a8ecf82443..bb4011d3c6a1d2a5aa66e68fe719cd5e
|
||||
loadFromJson(stream, output);
|
||||
} catch (IOException | JsonParseException e) {
|
||||
diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java
|
||||
index 2a75f8fbd2e5f41ca138740319d34683915e3b5b..0cc56b19d68f34994c9dbae578609eca7b7343cb 100644
|
||||
index a557d488e4e289a61aeb9aed0cc133a0a7ce8f8c..ca349619bcdd0682c9d66d54fc55cac268fc443b 100644
|
||||
--- a/net/minecraft/server/Main.java
|
||||
+++ b/net/minecraft/server/Main.java
|
||||
@@ -158,6 +158,8 @@ public class Main {
|
||||
@@ -167,6 +167,8 @@ public class Main {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ Subject: [PATCH] Add config to enable cross region damage trace
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index b4d8cc8b520266abe1921b5e990c34fce3f1d982..93c76c2faf75bf4901ecaba1e04d957d5ddddfca 100644
|
||||
index 42e09148519596f95fc9c9c63df9c87e6ece3102..444753590d3bc96ce68e25a3834d7abb86e20f94 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1448,6 +1448,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ index 97c514673a454b752ab86b944fd143725ca8090d..ba91d40d6d91588a4b39abfefcb17a36
|
||||
private final Reference2ReferenceOpenHashMap<RegionizedData<?>, Object> regionizedData = new Reference2ReferenceOpenHashMap<>();
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index 9800ae1d3c49800b0c7342d43d696109b5b72cf4..f9a8c79640ed6ca381e4482eaeab6b23db59419f 100644
|
||||
index c67ea715f02086e5a39cc5832ccdc0b32199db93..946094713bdb294d7d8beb03967b2a2488f5359b 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -299,7 +299,11 @@ public class Commands {
|
||||
@@ -48,7 +48,7 @@ index 9800ae1d3c49800b0c7342d43d696109b5b72cf4..f9a8c79640ed6ca381e4482eaeab6b23
|
||||
SaveOnCommand.register(this.dispatcher);
|
||||
SetPlayerIdleTimeoutCommand.register(this.dispatcher);
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 4b6f961e695155db1d6cc86496491017bf3a6383..e7f7f7927fc1e2ce45ea5dbf7cc9ec19197c599f 100644
|
||||
index 1736816e26c255645d62696814cd539ee1ffed8d..a0c285d2cb666d0f9bd0e859e0dac414254325c3 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1652,6 +1652,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ Subject: [PATCH] Add config to enable function command
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index f9a8c79640ed6ca381e4482eaeab6b23db59419f..1b2d3e2c23e8e03ae25e85a60b6ef0528e627f61 100644
|
||||
index 946094713bdb294d7d8beb03967b2a2488f5359b..3d9e8c5ba567efd363e0ed54059f67fbfe25e361 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -217,7 +217,11 @@ public class Commands {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ Subject: [PATCH] Add config to enable scoreboard command
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index 1b2d3e2c23e8e03ae25e85a60b6ef0528e627f61..916b5c8d524ffd7ccb953fe0f1cf020a1ea8dafb 100644
|
||||
index 3d9e8c5ba567efd363e0ed54059f67fbfe25e361..6642288dde528899d9bce7ccd8d92a199e8975c8 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -246,7 +246,11 @@ public class Commands {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ Subject: [PATCH] Add config to enable trigger command
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index 916b5c8d524ffd7ccb953fe0f1cf020a1ea8dafb..03f3fe221b14f0317947d74e25049bcce2ebeb66 100644
|
||||
index 6642288dde528899d9bce7ccd8d92a199e8975c8..77d7d83cc781baf19593227d20b827bf0be6ed28 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -274,7 +274,11 @@ public class Commands {
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ index 163999d50213e0167eb09f0eae883388849f28fa..5196431f52e81608a5575f8a262cd5c8
|
||||
double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1);
|
||||
if (rangeY != -1) {
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 00bc928a19cb877698b34b7c039bee5fe8b5cda5..db7281fcf1f4dc878a87ef9b8f24f2f9da12238a 100644
|
||||
index 43e07a3c98e80f874f55411beac39e215ffdc3cf..cddf44f5da5cba5603dcff4913b4658dcfcc48db 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -164,7 +164,7 @@ public abstract class Entity
|
||||
@@ -30,7 +30,7 @@ index 00bc928a19cb877698b34b7c039bee5fe8b5cda5..db7281fcf1f4dc878a87ef9b8f24f2f9
|
||||
// CraftBukkit start
|
||||
private static final int CURRENT_LEVEL = 2;
|
||||
static boolean isLevelAtLeast(ValueInput input, int level) {
|
||||
@@ -6579,4 +6579,48 @@ public abstract class Entity
|
||||
@@ -6590,4 +6590,48 @@ public abstract class Entity
|
||||
// Paper end
|
||||
|
||||
public boolean shouldTickHot() { return this.tickCount > 20 * 10 && this.isAlive(); } // KioCG
|
||||
@@ -80,10 +80,10 @@ index 00bc928a19cb877698b34b7c039bee5fe8b5cda5..db7281fcf1f4dc878a87ef9b8f24f2f9
|
||||
+ // Lophine end - Add config to enable raytracing tracker
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java
|
||||
index 6efaa78faca15c7a48bdffb24480d1bac29f3ba8..8a328a41673a3d720f0b1a5de8ce049e360fac1b 100644
|
||||
index 31619890f1bd4f458b6f9a31fac8cefaafe09e8e..50643bd0b546a1ff70031ea39e2610f219ef8a79 100644
|
||||
--- a/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/net/minecraft/world/entity/EntityType.java
|
||||
@@ -84,6 +84,11 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T>,
|
||||
@@ -85,6 +85,11 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T>,
|
||||
public final int passengerTickTimerId;
|
||||
public final int passengerInactiveTickTimerId;
|
||||
// Folia end - profiler
|
||||
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Spawn invulnerable time
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 93c76c2faf75bf4901ecaba1e04d957d5ddddfca..2985d5e2dde049a999a39f6edbb6696332f6d822 100644
|
||||
index 444753590d3bc96ce68e25a3834d7abb86e20f94..e64db3045ebf08600283a47960005827c1920f94 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -245,6 +245,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ index 08e253662a2c183c0ab53a51cc07485cff33bf2c..1bd678d668a1febc129f4cb4d0d95ea2
|
||||
};
|
||||
}
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index e7f7f7927fc1e2ce45ea5dbf7cc9ec19197c599f..1f13f7b016b4256e92989d83003a983d6ba1c750 100644
|
||||
index a0c285d2cb666d0f9bd0e859e0dac414254325c3..9614a22c4b67e5e3a46e46fa69d22c136d4beb4b 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2016,6 +2016,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@@ -33,7 +33,7 @@ index d2e9d46bbd9ee4ce45419b11499d7a7bc50f0219..848967dbe41694411603ef369cfdc3a0
|
||||
private final java.util.concurrent.atomic.AtomicBoolean disconnectionHandled = new java.util.concurrent.atomic.AtomicBoolean(false); // Folia - region threading - may be called concurrently during configuration stage
|
||||
private int receivedPackets;
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 1f13f7b016b4256e92989d83003a983d6ba1c750..f76e40f8bbea076ad620f7525d4d8666603a5175 100644
|
||||
index 9614a22c4b67e5e3a46e46fa69d22c136d4beb4b..5bc6baf2a13b78f65e5851a22ca79dbcaed957b2 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -296,6 +296,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -240,7 +240,7 @@ index 3021b70b941ed09c5c58b98d30830a2279b8339c..d289f59475b617ae527d123239297f69
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 2dae0f4249eade60ac55c9fa289dd146dc3675e1..239cad02f85f0d14d4abfa746ecdc4dd82b04657 100644
|
||||
index 2dae0f4249eade60ac55c9fa289dd146dc3675e1..f70f6501254b40cf76dc7f9bcd621a1f68e39ea9 100644
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -230,6 +230,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -251,16 +251,17 @@ index 2dae0f4249eade60ac55c9fa289dd146dc3675e1..239cad02f85f0d14d4abfa746ecdc4dd
|
||||
this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage));
|
||||
org.spigotmc.SpigotConfig.init((java.io.File) this.options.valueOf("spigot-settings"));
|
||||
org.spigotmc.SpigotConfig.registerCommands();
|
||||
@@ -251,6 +252,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
consoleThread.start(); // Paper - Enhance console tab completions for brigadier commands; start console thread after MinecraftServer.console & PaperConfig are initialized
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command
|
||||
if (false) this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark // Luminol - Force disable builtin spark
|
||||
+ this.getBotList().loadResumeBotInfo(); // Leaves - load resident bot info
|
||||
@@ -254,6 +255,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
|
||||
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
|
||||
|
||||
+ this.getBotList().loadResumeBotInfo(); // Leaves - load resident bot info
|
||||
+
|
||||
// this.worldData.setGameType(properties.gameMode.get()); // CraftBukkit - moved to world loading
|
||||
LOGGER.info("Default game type: {}", properties.gameMode.get());
|
||||
// Paper start - Unix domain socket support
|
||||
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
|
||||
index 5196431f52e81608a5575f8a262cd5c855b06182..6d43ca34f38192faf5bb4254d849c5ac51197f48 100644
|
||||
index 5196431f52e81608a5575f8a262cd5c855b06182..84c047ed0242778a9e6bca5e41561bd1bdcf633c 100644
|
||||
--- a/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -972,7 +972,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP
|
||||
@@ -272,7 +273,21 @@ index 5196431f52e81608a5575f8a262cd5c855b06182..6d43ca34f38192faf5bb4254d849c5ac
|
||||
org.spigotmc.AsyncCatcher.catchOp("entity track"); // Spigot
|
||||
// Paper start - ignore and warn about illegal addEntity calls instead of crashing server
|
||||
if (!entity.valid || entity.level() != this.level || entity.moonrise$getTrackedEntity() != null) { // Folia - region threading
|
||||
@@ -1389,6 +1389,13 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP
|
||||
@@ -1258,6 +1258,13 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP
|
||||
ServerPlayer player = conn.getPlayer();
|
||||
if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(player)) {
|
||||
this.removePlayer(player);
|
||||
+ // Leaves start - render bot
|
||||
+ if (entity instanceof org.leavesmc.leaves.bot.ServerBot bot) {
|
||||
+ if (bot.needSendFakeData(player)) {
|
||||
+ bot.sendFakeData(player.connection, false);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaves end - render bot
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1389,6 +1396,13 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP
|
||||
}
|
||||
} else {
|
||||
this.removePlayer(player);
|
||||
@@ -344,7 +359,7 @@ index cb11830c2f399c9706b20f8104686dc0d9b686f9..1c4c67410849f844946e4883585910fc
|
||||
ServerLevel.this.updateSleepingPlayerList();
|
||||
}
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 2985d5e2dde049a999a39f6edbb6696332f6d822..64943c193ae73795ddf8222a6f71ea5eb1705fe2 100644
|
||||
index e64db3045ebf08600283a47960005827c1920f94..a3d3a602ab86e27ae0c6e6207384dc0043279d47 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -232,7 +232,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -377,7 +392,7 @@ index 2985d5e2dde049a999a39f6edbb6696332f6d822..64943c193ae73795ddf8222a6f71ea5e
|
||||
AABB aabb = new AABB(this.blockPosition()).inflate(32.0, 10.0, 32.0);
|
||||
this.level()
|
||||
.getEntitiesOfClass(Mob.class, aabb, EntitySelector.NO_SPECTATORS)
|
||||
@@ -2161,6 +2161,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -2140,6 +2140,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
this.teleportSpectators(transition, oldLevel);
|
||||
@@ -542,7 +557,7 @@ index ca1e635b0fdf3d0d17447b43a558fe030536d297..ed50484ca24ef24b1e5bef9f6369dfa4
|
||||
|
||||
public @Nullable ServerPlayer getPlayer(final String playerName) {
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index db7281fcf1f4dc878a87ef9b8f24f2f9da12238a..b11637543c3ef8650ad5c65c2cab8a1cb6e95158 100644
|
||||
index cddf44f5da5cba5603dcff4913b4658dcfcc48db..9eaed81a330a22e7fd6585cd286ec61371e97272 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1263,7 +1263,7 @@ public abstract class Entity
|
||||
@@ -564,9 +579,18 @@ index db7281fcf1f4dc878a87ef9b8f24f2f9da12238a..b11637543c3ef8650ad5c65c2cab8a1c
|
||||
final boolean xZero = movement.x == 0.0;
|
||||
final boolean yZero = movement.y == 0.0;
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index cb1589e3aa663ca058fb5c3a24da700d4482cf35..d64c68651b7142869a06ce0200fb625cd45ae235 100644
|
||||
index cb1589e3aa663ca058fb5c3a24da700d4482cf35..1de8eac336e2dd6335c433b7708ce6b6684553c9 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2001,7 +2001,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
return 0; // CraftBukkit
|
||||
}
|
||||
|
||||
- protected void dropExperience(ServerLevel level, @Nullable Entity entity) {
|
||||
+ public void dropExperience(ServerLevel level, @Nullable Entity entity) {
|
||||
// CraftBukkit start - Update getExpReward() above if the removed if() changes!
|
||||
if (!(this instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time
|
||||
ExperienceOrb.awardWithDirection(level, this.position(), Vec3.ZERO, this.expToDrop, this instanceof ServerPlayer ? org.bukkit.entity.ExperienceOrb.SpawnReason.PLAYER_DEATH : org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, entity, this); // Paper
|
||||
@@ -3348,7 +3348,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
private void travelRidden(final Player controller, final Vec3 selfInput) {
|
||||
Vec3 riddenInput = this.getRiddenInput(controller, selfInput);
|
||||
|
||||
@@ -88,7 +88,7 @@ index 6c05b9276bdc267a36376f6c64592a50e4b2b36e..21d2c97b3d1e1d29c9de02b6acd58985
|
||||
result.add(player);
|
||||
if (result.size() >= limit) {
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index f76e40f8bbea076ad620f7525d4d8666603a5175..77bbc527b017c2ac42ebe4638457caf32868e3f6 100644
|
||||
index 5bc6baf2a13b78f65e5851a22ca79dbcaed957b2..803faa6b80a42d16687ea8b109973938d02f4a36 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1909,7 +1909,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -551,7 +551,7 @@ index ed50484ca24ef24b1e5bef9f6369dfa4b30c359c..575b4eabcaac48ae87b69dd037493ebf
|
||||
// Leaves end - fakeplayer support
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index d64c68651b7142869a06ce0200fb625cd45ae235..1fe317cf3251bff7bb3e0335452a5714d4d31017 100644
|
||||
index 1de8eac336e2dd6335c433b7708ce6b6684553c9..dae262a073acb3bb3464d169dd5a0b6d67f27846 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -276,7 +276,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@ index 20fa23988efbfb50c664fa48cc823adbe8e6ce58..1a95ccd745f4789225d711ab6fe497c6
|
||||
throw PacketUtils.makeReportedException(e, this.packet, this.listener);
|
||||
}
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 77bbc527b017c2ac42ebe4638457caf32868e3f6..6ba62c5c6af4fc060442de8dfb069d5fe8ac0c69 100644
|
||||
index 803faa6b80a42d16687ea8b109973938d02f4a36..6c5cdfebb3a362c51b3b940397e10536dc67afc8 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1998,11 +1998,30 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -98,7 +98,7 @@ index ae88e57974f631ff2494c35d6e02049ba5d38014..6b8073023833fc9e99684944802dc594
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 64943c193ae73795ddf8222a6f71ea5eb1705fe2..4034b4b9bd5e567b882169b5b1e17f75b64ba8db 100644
|
||||
index a3d3a602ab86e27ae0c6e6207384dc0043279d47..70f7cb6b38a90ca337bd52c18fa7bfd4016b552c 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1111,6 +1111,12 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -115,7 +115,7 @@ index 64943c193ae73795ddf8222a6f71ea5eb1705fe2..4034b4b9bd5e567b882169b5b1e17f75
|
||||
CrashReport report = CrashReport.forThrowable(t, "Ticking player");
|
||||
CrashReportCategory category = report.addCategory("Player being ticked");
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index b11637543c3ef8650ad5c65c2cab8a1cb6e95158..426e033e033147f5db6c2d9c96ab13af0fc553a8 100644
|
||||
index 9eaed81a330a22e7fd6585cd286ec61371e97272..acc9caf8559cd341ea17d3b58f13cdac7de18564 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1522,8 +1522,18 @@ public abstract class Entity
|
||||
|
||||
@@ -128,7 +128,7 @@ index 8cc4fe9feb57902a4b9a6a26e6175ac00a2cef65..9ab1a812e43145120859734075e2ac99
|
||||
// Paper start - fix converting txt to json file; moved from constructor
|
||||
}
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 4034b4b9bd5e567b882169b5b1e17f75b64ba8db..4c53b688ed6b26ca7231841f3235f9a824416bba 100644
|
||||
index 70f7cb6b38a90ca337bd52c18fa7bfd4016b552c..9a6f18fd0eb7e2aef174b25d14cfd0f5a3ade6af 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -260,6 +260,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -139,7 +139,7 @@ index 4034b4b9bd5e567b882169b5b1e17f75b64ba8db..4c53b688ed6b26ca7231841f3235f9a8
|
||||
private @Nullable Vec3 startingToFallPosition;
|
||||
private @Nullable Vec3 enteredNetherPosition;
|
||||
private @Nullable Vec3 enteredLavaOnVehiclePosition;
|
||||
@@ -2168,7 +2169,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -2147,7 +2148,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
this.lastSentFood = -1;
|
||||
this.teleportSpectators(transition, oldLevel);
|
||||
// Leaves start - bot support
|
||||
@@ -148,7 +148,7 @@ index 4034b4b9bd5e567b882169b5b1e17f75b64ba8db..4c53b688ed6b26ca7231841f3235f9a8
|
||||
this.server.getBotList().bots.forEach(bot -> bot.sendFakeDataIfNeed(this, true)); // Leaves - render bot
|
||||
}
|
||||
// Leaves end - bot support
|
||||
@@ -2805,6 +2806,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -2784,6 +2785,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
this.setShoulderEntityRight(oldPlayer.getShoulderEntityRight());
|
||||
this.setLastDeathLocation(oldPlayer.getLastDeathLocation());
|
||||
this.waypointIcon().copyFrom(oldPlayer.waypointIcon());
|
||||
@@ -160,7 +160,7 @@ index 4034b4b9bd5e567b882169b5b1e17f75b64ba8db..4c53b688ed6b26ca7231841f3235f9a8
|
||||
}
|
||||
|
||||
private void transferInventoryXpAndScore(final Player oldPlayer) {
|
||||
@@ -3084,6 +3090,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -3063,6 +3069,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
this.particleStatus = information.particleStatus();
|
||||
this.getEntityData().set(DATA_PLAYER_MODE_CUSTOMISATION, (byte)information.modelCustomisation());
|
||||
this.getEntityData().set(DATA_PLAYER_MAIN_HAND, information.mainHand());
|
||||
@@ -424,7 +424,7 @@ index b95c56e0699fbe16e65efcf010cd514f0ac0962f..0125d59551accd9005aa33a5c7cc8ec2
|
||||
return this.entityData.get(DATA_VALUE);
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index 1fe317cf3251bff7bb3e0335452a5714d4d31017..14a79e8ef5a98b1eef2f2d3e0c63f21cb5bb4dbf 100644
|
||||
index dae262a073acb3bb3464d169dd5a0b6d67f27846..0990e393c8695b17571d9a7646d895ab07ec30ba 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -623,7 +623,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
|
||||
@@ -40,7 +40,7 @@ index 57a35d7a801621fc461e896eb2bba533d9d5bc1b..ae424c8931a2f82c6c8d4ddd8422a2c1
|
||||
}
|
||||
// Luminol end - Add a config to enable tick command
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index 03f3fe221b14f0317947d74e25049bcce2ebeb66..6882e85fb6413e5c346c189a82b69f3e408aafba 100644
|
||||
index 77d7d83cc781baf19593227d20b827bf0be6ed28..82af03649c7537274aa54ed942e4aae589b97888 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -268,7 +268,7 @@ public class Commands {
|
||||
|
||||
+3
-3
@@ -21,10 +21,10 @@ index dd17339fe2f9d7660b20eed05b61d6231302aa82..d997e4f7ae6ee4e81f5fffe874f2895d
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 4c53b688ed6b26ca7231841f3235f9a824416bba..cef9c7887332b91e2466a97a5250db81f7af0dcf 100644
|
||||
index 9a6f18fd0eb7e2aef174b25d14cfd0f5a3ade6af..b43bbe461500782a75a49c9238bd4d4d81448d09 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -2360,7 +2360,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -2339,7 +2339,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
public boolean isInvulnerableTo(final ServerLevel level, final DamageSource source) {
|
||||
// Paper start - disable player cramming
|
||||
return (super.isInvulnerableTo(level, source) || this.isChangingDimension() && !source.is(DamageTypes.ENDER_PEARL) || !this.connection.hasClientLoaded())
|
||||
@@ -34,7 +34,7 @@ index 4c53b688ed6b26ca7231841f3235f9a824416bba..cef9c7887332b91e2466a97a5250db81
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index 14a79e8ef5a98b1eef2f2d3e0c63f21cb5bb4dbf..429116ab6bac69054a30b0c766ea5d0186877fae 100644
|
||||
index 0990e393c8695b17571d9a7646d895ab07ec30ba..386033fa4ba0fb705593e0c9f9cc6574c0ab55ac 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -4004,7 +4004,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ Subject: [PATCH] Restore vanilla ender pearl loading
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index cef9c7887332b91e2466a97a5250db81f7af0dcf..a17212c1910ce9490fe8df8c4ef507e25b89c545 100644
|
||||
index b43bbe461500782a75a49c9238bd4d4d81448d09..68e36ad03325cd6348dc4bbab37409b70bee6023 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -277,7 +277,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -51,7 +51,7 @@ index cef9c7887332b91e2466a97a5250db81f7af0dcf..a17212c1910ce9490fe8df8c4ef507e2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3568,11 +3570,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -3547,11 +3549,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
}
|
||||
|
||||
public void registerEnderPearl(final ThrownEnderpearl enderPearl) {
|
||||
@@ -89,7 +89,7 @@ index 516561a25d28f2c7bcc3e71c5f2f9da99c2899c3..eb652157ef25e83b897f52aff3c49c09
|
||||
|
||||
level.removePlayerImmediately(player, Entity.RemovalReason.UNLOADED_WITH_PLAYER);
|
||||
diff --git a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
index 790c1bcf11150d31bf90c32345e4eb40de9a6a41..7409b452567608dbdb36ac686791e604a267fb6a 100644
|
||||
index 4df9a3356cfdee52761db47694e59779976840db..3e6844a468d8e6c9cf3b0bd23e21a3cabc9b7f51 100644
|
||||
--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
+++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
@@ -31,7 +31,11 @@ import net.minecraft.world.phys.Vec3;
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Tue, 28 Jul 2026 15:08:10 +0800
|
||||
Subject: [PATCH] Anonymous Object: Fix wrong variable passing in
|
||||
RegionizedWorldData
|
||||
|
||||
As requested by the original author, this patch will be anonymous and hide the original commit address.
|
||||
This patch is used with permission from the original author.
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedWorldData.java b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
index 3a50e625160d0dad6bd8fa534b719087dae7881d..20439c632044ae9b4358bfba309b378b3de98601 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
@@ -841,7 +841,7 @@ public final class RegionizedWorldData {
|
||||
}
|
||||
|
||||
public void setTickingBlockEntities(final boolean to) {
|
||||
- this.tickingBlockEntities = true;
|
||||
+ this.tickingBlockEntities = to; // Anonymous - Fix wrong variable passing in RegionizedWorldData
|
||||
}
|
||||
|
||||
public List<TickingBlockEntity> getBlockEntityTickers() {
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Tue, 28 Jul 2026 15:08:28 +0800
|
||||
Subject: [PATCH] Anonymous Object: Fix wrong variable passing in
|
||||
ThreadedRegionizer
|
||||
|
||||
As requested by the original author, this patch will be anonymous and hide the original commit address.
|
||||
This patch is used with permission from the original author.
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/ThreadedRegionizer.java b/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
index a346b96500ae859e9469c80e2ff6b39c4d3d0b52..73e0aeb5a5e9bdd1f275dd64d1fffa32c389052d 100644
|
||||
--- a/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
+++ b/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
@@ -755,8 +755,8 @@ public final class ThreadedRegionizer<R extends ThreadedRegionizer.ThreadedRegio
|
||||
final int x1 = CoordinateUtils.getChunkX(k1);
|
||||
final int x2 = CoordinateUtils.getChunkX(k2);
|
||||
|
||||
- final int z1 = CoordinateUtils.getChunkZ(x1);
|
||||
- final int z2 = CoordinateUtils.getChunkZ(x2);
|
||||
+ final int z1 = CoordinateUtils.getChunkZ(k1); // Anonymous - Fix wrong variable passing in ThreadedRegionizer
|
||||
+ final int z2 = CoordinateUtils.getChunkZ(k2); // Anonymous - Fix wrong variable passing in ThreadedRegionizer
|
||||
|
||||
final int zCompare = Integer.compare(z1, z2);
|
||||
if (zCompare != 0) {
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Tue, 28 Jul 2026 15:08:42 +0800
|
||||
Subject: [PATCH] Anonymous Object: Fix wrong ticket update determination in
|
||||
RegionizedTaskQueue
|
||||
|
||||
As requested by the original author, this patch will be anonymous and hide the original commit address.
|
||||
This patch is used with permission from the original author.
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
index b264dbd13a392cde3f24ff75c0034985fda68ccc..fe0a6bd90cba4869a0ee11723832f2dee5039f62 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
@@ -289,14 +289,17 @@ public final class RegionizedTaskQueue {
|
||||
boolean executeTickTasks = allowedTickTasks > 0;
|
||||
boolean executeChunkTasks = allowedChunkTasks > 0;
|
||||
boolean executeGlobalTasks = true;
|
||||
+ boolean processedChunkTask = false; // Anonymous - Fix wrong ticket update determination in RegionizedTaskQueue
|
||||
|
||||
do {
|
||||
executeTickTasks = executeTickTasks && allowedTickTasks-- > 0 && tickTaskQueue.executeTask();
|
||||
executeChunkTasks = executeChunkTasks && allowedChunkTasks-- > 0 && chunkTaskQueue.executeTask();
|
||||
executeGlobalTasks = executeGlobalTasks && this.worldRegionTaskData.executeGlobalChunkTask();
|
||||
+
|
||||
+ processedChunkTask |= (executeChunkTasks | executeGlobalTasks); // Anonymous - Fix wrong ticket update determination in RegionizedTaskQueue
|
||||
} while (executeTickTasks | executeChunkTasks | executeGlobalTasks);
|
||||
|
||||
- if (allowedChunkTasks > 0) {
|
||||
+ if (processedChunkTask) { // Anonymous - Fix wrong ticket update determination in RegionizedTaskQueue
|
||||
// if we executed chunk tasks, we should try to process ticket updates for full status changes
|
||||
this.worldRegionTaskData.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates();
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Tue, 28 Jul 2026 15:09:06 +0800
|
||||
Subject: [PATCH] Anonymous Object: Lithium optimized collections for
|
||||
WeightedList
|
||||
|
||||
As requested by the original author, this patch will be anonymous and hide the original commit address.
|
||||
This patch is used with permission from the original author.
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/util/random/WeightedList.java b/net/minecraft/util/random/WeightedList.java
|
||||
index a8481259e42aa116e29bccd1e30fdfd91f51a8cc..49a558d6021db2d57eb2596206ea459fd33485e0 100644
|
||||
--- a/net/minecraft/util/random/WeightedList.java
|
||||
+++ b/net/minecraft/util/random/WeightedList.java
|
||||
@@ -23,7 +23,7 @@ public class WeightedList<E> { // Paper - non-final
|
||||
private final WeightedList.@Nullable Selector<E> selector;
|
||||
|
||||
protected WeightedList(final List<? extends Weighted<E>> items) { // Paper - protected
|
||||
- this.items = List.copyOf(items);
|
||||
+ this.items = items.size() > 4 ? new net.caffeinemc.mods.lithium.common.util.collections.HashedReferenceList(items) : new it.unimi.dsi.fastutil.objects.ReferenceArrayList<>(items); // Anonymous - Lithium optimized collections for WeightedList
|
||||
this.totalWeight = WeightedRandom.getTotalWeight(items, Weighted::weight);
|
||||
if (this.totalWeight == 0) {
|
||||
this.selector = null;
|
||||
+282
@@ -0,0 +1,282 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Tue, 28 Jul 2026 15:09:19 +0800
|
||||
Subject: [PATCH] Anonymous Object: Lithium optimized non poi block searching
|
||||
|
||||
As requested by the original author, this patch will be anonymous and hide the original commit address.
|
||||
This patch is used with permission from the original author.
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
index c6e9b155c2341c13d569f28f54f0c1d2d7313676..927635518c51375315390877d582b32fc38748df 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.PathfinderMob;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
|
||||
-public abstract class MoveToBlockGoal extends Goal {
|
||||
+public abstract class MoveToBlockGoal extends Goal implements net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.LithiumMoveToBlockGoal { // Anonymous - Lithium Optimizes move to block goal
|
||||
private static final int GIVE_UP_TICKS = 1200;
|
||||
private static final int STAY_TICKS = 1200;
|
||||
private static final int INTERVAL_TICKS = 200;
|
||||
@@ -133,4 +133,167 @@ public abstract class MoveToBlockGoal extends Goal {
|
||||
}
|
||||
|
||||
protected abstract boolean isValidTarget(LevelReader level, BlockPos pos);
|
||||
+ // Anonymous start - Lithium Optimizes move to block goal
|
||||
+ /**
|
||||
+ * Finds the nearest block matching the predicates.
|
||||
+ * <p>
|
||||
+ * Side effect: The matching block position is stored in the blockPos field.
|
||||
+ *
|
||||
+ * @return Whether a matching block was found.
|
||||
+ */
|
||||
+ @Override
|
||||
+ public boolean lithium$findNearestBlock(java.util.function.Predicate<net.minecraft.world.level.block.state.BlockState> requiredBlock, java.util.function.BiPredicate<net.minecraft.world.level.chunk.ChunkAccess,
|
||||
+ BlockPos.MutableBlockPos> lithium$isValidTarget, final boolean shouldChunkLoad) {
|
||||
+ //Center of the search starts 1 block below the mob's block position
|
||||
+ BlockPos center = this.mob.blockPosition().offset(0,-1,0);
|
||||
+
|
||||
+ //Range is +-(searchRange - 1), +-verticalSearchRange, +-(searchRange - 1)
|
||||
+ //Cache ChunkAccesses - getting them is surprisingly expensive - and track whether subchunks have the block
|
||||
+ final LevelReader levelReader = this.mob.level();
|
||||
+ net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CheckAndCacheBlockChecker checker = new net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CheckAndCacheBlockChecker(center,
|
||||
+ this.searchRange-1, this.verticalSearchRange,
|
||||
+ levelReader, requiredBlock, shouldChunkLoad);
|
||||
+ it.unimi.dsi.fastutil.longs.LongArrayList sortedChunksMaybeWithBlock = new it.unimi.dsi.fastutil.longs.LongArrayList(checker.getChunkSize());
|
||||
+ checker.initializeChunks(sortedChunksMaybeWithBlock::addLast);
|
||||
+
|
||||
+ if (checker.shouldStop()) {
|
||||
+ return false; //No chunks with the target block - return early
|
||||
+ }
|
||||
+
|
||||
+ final int minY = net.caffeinemc.mods.lithium.common.util.Pos.BlockCoord.getMinY(levelReader);
|
||||
+ final int maxY = net.caffeinemc.mods.lithium.common.util.Pos.BlockCoord.getMaxYInclusive(levelReader);
|
||||
+
|
||||
+ // Prefer chunk aware search because it also cuts iterations inside "empty" chunk sections
|
||||
+ if(!checker.hasUnloadedPossibleChunks()){
|
||||
+ return this.lithium$chunkAwareSearch(center, lithium$isValidTarget, checker, sortedChunksMaybeWithBlock, minY, maxY);
|
||||
+ }
|
||||
+
|
||||
+ // Use vanilla search because unordered search may observably alter chunk-loading behavior
|
||||
+ return this.lithium$vanillaOrderSearch(center, lithium$isValidTarget, checker, minY, maxY);
|
||||
+ }
|
||||
+
|
||||
+ private boolean lithium$vanillaOrderSearch(BlockPos center,
|
||||
+ java.util.function.BiPredicate<net.minecraft.world.level.chunk.ChunkAccess, BlockPos.MutableBlockPos> lithium$isValidTarget,
|
||||
+ net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CheckAndCacheBlockChecker checker, final int minY, final int maxY) {
|
||||
+ BlockPos.MutableBlockPos currentPos = new BlockPos.MutableBlockPos();
|
||||
+ final int centerY = center.getY();
|
||||
+
|
||||
+ for (int layer = this.verticalSearchStart; layer <= this.verticalSearchRange; layer = layer > 0 ? -layer : 1 - layer) {
|
||||
+ final int y = centerY + layer;
|
||||
+
|
||||
+ // Layer outside of build limit - skip
|
||||
+ // Note: this is likely to be hit because farms where this lags tend to be built at world floor
|
||||
+ if (y < minY || y > maxY) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ for (int ring = 0; ring < this.searchRange; ring++) {
|
||||
+ for (int dX = 0; dX <= ring; dX = dX > 0 ? -dX : 1 - dX) {
|
||||
+ for (int dZ = dX < ring && dX > -ring ? ring : 0; dZ <= ring; dZ = dZ > 0 ? -dZ : 1 - dZ) {
|
||||
+ currentPos.setWithOffset(center, dX, layer, dZ);
|
||||
+ if (this.mob.isWithinHome(currentPos) && checker.checkPosition(currentPos)) {
|
||||
+ // ChunkAccess is always loaded at this point
|
||||
+ net.minecraft.world.level.chunk.ChunkAccess chunkAccess = checker.getCachedChunkAccess(currentPos);
|
||||
+ if (lithium$isValidTarget.test(chunkAccess, currentPos)){
|
||||
+ this.blockPos = currentPos;
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ private boolean lithium$chunkAwareSearch(BlockPos center,
|
||||
+ java.util.function.BiPredicate<net.minecraft.world.level.chunk.ChunkAccess, BlockPos.MutableBlockPos> lithium$isValidTarget,
|
||||
+ net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CheckAndCacheBlockChecker checker, it.unimi.dsi.fastutil.longs.LongArrayList sortedChunksMaybeWithBlock,
|
||||
+ final int minY, final int maxY) {
|
||||
+ // Sort chunks by lowest sort order - has the earliest searched position
|
||||
+ // Note: In this search order, the closest point normally is also the closest point in the search
|
||||
+ sortedChunksMaybeWithBlock.sort((chunkLong0, chunkLong1) ->
|
||||
+ net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.NonPOISearchDistances.MoveToBlockGoalDistances.getMinimumSortOrderOfChunk(center, chunkLong0)
|
||||
+ - net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.NonPOISearchDistances.MoveToBlockGoalDistances.getMinimumSortOrderOfChunk(center, chunkLong1)
|
||||
+ );
|
||||
+
|
||||
+ java.util.function.Predicate<net.minecraft.world.level.block.state.BlockState> requiredBlock = checker.blockStatePredicate;
|
||||
+ final int minSectionY = checker.minSectionY;
|
||||
+
|
||||
+ BlockPos.MutableBlockPos foundPos = new BlockPos.MutableBlockPos();
|
||||
+ BlockPos.MutableBlockPos currentPos = new BlockPos.MutableBlockPos();
|
||||
+
|
||||
+ // Same layer order as vanilla - saves iterations if targets are found in the first layer
|
||||
+ for (int layer = this.verticalSearchStart; layer <= this.verticalSearchRange; layer = layer > 0 ? -layer : 1 - layer) {
|
||||
+ final int y = center.getY() + layer;
|
||||
+
|
||||
+ // Layer outside of build limit - skip
|
||||
+ // Note: this is likely to be hit because farms where this lags tend to be built at world floor
|
||||
+ if (y < minY || y > maxY) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final int chunkY = net.minecraft.core.SectionPos.blockToSectionCoord(y);
|
||||
+ final int ySectionIndex = chunkY - minSectionY;
|
||||
+
|
||||
+ int closestFound = Integer.MAX_VALUE;
|
||||
+ int ringMax = this.searchRange - 1;
|
||||
+
|
||||
+ // Iterate through slices of chunks that may have the target blockState
|
||||
+ for (long chunkPos: sortedChunksMaybeWithBlock) {
|
||||
+ final int chunkX = net.minecraft.world.level.ChunkPos.getX(chunkPos);
|
||||
+ final int chunkZ = net.minecraft.world.level.ChunkPos.getZ(chunkPos);
|
||||
+
|
||||
+ // Break since no subsequent chunks can be closer
|
||||
+ if (closestFound < net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.NonPOISearchDistances.MoveToBlockGoalDistances.getMinimumSortOrderOfChunk(center, chunkX, chunkZ)) {
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ // Skip if the current subchunk does not have the block
|
||||
+ if (!checker.checkCachedSection(chunkX, chunkY, chunkZ)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ net.minecraft.world.level.chunk.ChunkAccess chunkAccess = checker.getCachedChunkAccess(chunkPos);
|
||||
+ // If ChunkSection may have close enough targets, iterate layer in Paletted Container (x then z) order
|
||||
+ final int chunkBlockX = net.minecraft.core.SectionPos.sectionToBlockCoord(chunkX);
|
||||
+ int xMin = Math.max(center.getX() - ringMax, chunkBlockX);
|
||||
+ int xMax = Math.min(center.getX() + ringMax, chunkBlockX + 15);
|
||||
+ final int chunkBlockZ = net.minecraft.core.SectionPos.sectionToBlockCoord(chunkZ);
|
||||
+ int zMin = Math.max(center.getZ() - ringMax, chunkBlockZ);
|
||||
+ int zMax = Math.min(center.getZ() + ringMax, chunkBlockZ + 15);
|
||||
+ net.minecraft.world.level.chunk.LevelChunkSection levelChunkSection = chunkAccess.getSections()[ySectionIndex];
|
||||
+ for (int z = zMin; z <= zMax; z++) {
|
||||
+ for (int x = xMin; x <= xMax; x++) {
|
||||
+ int dX = x - center.getX();
|
||||
+ int dZ = z - center.getZ();
|
||||
+ int ring = net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.NonPOISearchDistances.MoveToBlockGoalDistances.getRing(dX, dZ);
|
||||
+ int currentDistance = net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.NonPOISearchDistances.MoveToBlockGoalDistances.getVanillaSortOrderInt(ring, dX, dZ);
|
||||
+ if (currentDistance < closestFound
|
||||
+ && this.mob.isWithinHome(currentPos.set(x, y, z))
|
||||
+ && requiredBlock.test(levelChunkSection.getBlockState(x & 15, y & 15, z & 15))
|
||||
+ && lithium$isValidTarget.test(chunkAccess, currentPos)) {
|
||||
+ // Constrain search size when we find a valid target
|
||||
+ ringMax = ring;
|
||||
+ xMin = Math.max(center.getX() - ringMax, chunkBlockX);
|
||||
+ xMax = Math.min(center.getX() + ringMax, chunkBlockX + 15);
|
||||
+ zMax = Math.min(center.getZ() + ringMax, chunkBlockZ + 15);
|
||||
+ foundPos.set(x, y, z);
|
||||
+ closestFound = currentDistance;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (closestFound < Integer.MAX_VALUE) {
|
||||
+ // Vanilla uses the mutable pos, no need to create immutable copy
|
||||
+ this.blockPos = foundPos;
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Anonymous end - Lithium Optimizes move to block goal
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||
index ff0f99d4b560a1c0721885b0eba5bd5ab2087bd7..99c076ee2fe0d8294398c5ef1f24a95da5eee89c 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||
@@ -25,6 +25,19 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
||||
private final Mob removerMob;
|
||||
private int ticksSinceReachedGoal;
|
||||
private static final int WAIT_AFTER_BLOCK_FOUND = 20;
|
||||
+ // Anonymous start - Lithium Optimize remove block goal
|
||||
+ private static final java.util.function.BiPredicate<ChunkAccess, BlockPos.MutableBlockPos> IS_VALID_TARGET_ABOVE_BIPREDICATE =
|
||||
+ RemoveBlockGoal::lithium$isValidTargetAbove;
|
||||
+ //Split check condition in order to use maybeHas
|
||||
+ private boolean lithium$isValidTargetBlock(net.minecraft.world.level.block.state.BlockState blockState){
|
||||
+ return blockState.is(this.blockToRemove);
|
||||
+ }
|
||||
+
|
||||
+ private static boolean lithium$isValidTargetAbove(ChunkAccess chunkAccess, BlockPos.MutableBlockPos mutable) {
|
||||
+ return chunkAccess.getBlockState(mutable.move(0, 1, 0)).isAir()
|
||||
+ && chunkAccess.getBlockState(mutable.move(0, 1, 0)).isAir();
|
||||
+ }
|
||||
+ // Anonymous end - Lithium Optimize remove block goal
|
||||
|
||||
public RemoveBlockGoal(final Block blockToRemove, final PathfinderMob mob, final double speedModifier, final int verticalSearchRange) {
|
||||
super(mob, speedModifier, 24, verticalSearchRange);
|
||||
@@ -39,7 +52,7 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
||||
} else if (this.nextStartTick > 0) {
|
||||
this.nextStartTick--;
|
||||
return false;
|
||||
- } else if (this.findNearestBlock()) {
|
||||
+ } else if (((net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.LithiumMoveToBlockGoal) this).lithium$findNearestBlock(this::lithium$isValidTargetBlock, IS_VALID_TARGET_ABOVE_BIPREDICATE, false)) { // Anonymous - Lithium Optimize remove block goal
|
||||
this.nextStartTick = reducedTickDelay(20);
|
||||
return true;
|
||||
} else {
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java b/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||
index 7022679c84e184999b416e06d1af2cc2500cb12b..78743515ff2afd1ea1f06432f33f41a03fc7988b 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||
@@ -16,6 +16,14 @@ import net.minecraft.world.entity.monster.hoglin.Hoglin;
|
||||
import net.minecraft.world.entity.monster.piglin.Piglin;
|
||||
|
||||
public class HoglinSpecificSensor extends Sensor<Hoglin> {
|
||||
+ // Anonymous start - Lithium Optimizes Hoglin repellent search.
|
||||
+ private static final java.util.function.Predicate<net.minecraft.world.level.block.state.BlockState> IS_VALID_REPELLENT_PREDICATE =
|
||||
+ HoglinSpecificSensor::lithium$isValidRepellent;
|
||||
+
|
||||
+ private static boolean lithium$isValidRepellent(net.minecraft.world.level.block.state.BlockState blockState) {
|
||||
+ return blockState.is(BlockTags.HOGLIN_REPELLENTS);
|
||||
+ }
|
||||
+ // Anonymous end - Lithium Optimizes Hoglin repellent search.
|
||||
@Override
|
||||
public Set<MemoryModuleType<?>> requires() {
|
||||
return ImmutableSet.of(
|
||||
@@ -30,8 +38,8 @@ public class HoglinSpecificSensor extends Sensor<Hoglin> {
|
||||
|
||||
@Override
|
||||
protected void doTick(final ServerLevel level, final Hoglin body) {
|
||||
- Brain<?> brain = body.getBrain();
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, this.findNearestRepellent(level, body));
|
||||
+ Brain<?> brain = body.getBrain();;
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CommonBlockSearchesCheckAndCache.blockPosFindClosestMatch(level, body, 8, 4, IS_VALID_REPELLENT_PREDICATE, true)); // Anonymous - Lithium Optimizes Hoglin repellent search.
|
||||
Optional<Piglin> adultPiglin = Optional.empty();
|
||||
int adultPiglinCount = 0;
|
||||
List<Hoglin> adultHoglins = Lists.newArrayList();
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java b/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||
index 060a53da799a3036a343cc6f1d73e3e5ca4b7af9..8594f559a5c8f5957348f7178464d5e9c5abc5ff 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||
@@ -26,6 +26,15 @@ import net.minecraft.world.level.block.CampfireBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class PiglinSpecificSensor extends Sensor<LivingEntity> {
|
||||
+ // Anonymous start - Lithium Optimizes Piglin repellent search.
|
||||
+ private static final java.util.function.Predicate<BlockState> IS_VALID_REPELLENT_PREDICATE =
|
||||
+ PiglinSpecificSensor::lithium$isValidRepellent;
|
||||
+ private static boolean lithium$isValidRepellent(BlockState blockState){
|
||||
+ final boolean isPiglinRepellent = blockState.is(BlockTags.PIGLIN_REPELLENTS);
|
||||
+ return isPiglinRepellent && blockState.is(Blocks.SOUL_CAMPFIRE) ?
|
||||
+ CampfireBlock.isLitCampfire(blockState) : isPiglinRepellent;
|
||||
+ }
|
||||
+ // Anonymous end - Lithium Optimizes Piglin repellent search.
|
||||
@Override
|
||||
public Set<MemoryModuleType<?>> requires() {
|
||||
return ImmutableSet.of(
|
||||
@@ -47,7 +56,7 @@ public class PiglinSpecificSensor extends Sensor<LivingEntity> {
|
||||
@Override
|
||||
protected void doTick(final ServerLevel level, final LivingEntity body) {
|
||||
Brain<?> brain = body.getBrain();
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, findNearestRepellent(level, body));
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CommonBlockSearchesCheckAndCache.blockPosFindClosestMatch(level, body, 8, 4, IS_VALID_REPELLENT_PREDICATE, true)); // Anonymous - Lithium Optimizes Piglin repellent search.
|
||||
Optional<Mob> nemesis = Optional.empty();
|
||||
Optional<Hoglin> huntableHoglin = Optional.empty();
|
||||
Optional<Hoglin> babyHoglin = Optional.empty();
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Tue, 28 Jul 2026 20:40:01 +0800
|
||||
Subject: [PATCH] Anonymous Object: Fix folia nether portal ticket placement
|
||||
|
||||
As requested by the original author, this patch will be anonymous and hide the original commit address.
|
||||
This patch is used with permission from the original author.
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/util/BlockUtil.java b/net/minecraft/util/BlockUtil.java
|
||||
index ea93ac07ec6d4e83d1d0904daf721132e2bbecc3..4252672ad2aaf03d50e5ea6a681e9964fd9a6137 100644
|
||||
--- a/net/minecraft/util/BlockUtil.java
|
||||
+++ b/net/minecraft/util/BlockUtil.java
|
||||
@@ -138,12 +138,20 @@ public class BlockUtil {
|
||||
public final BlockPos minCorner;
|
||||
public final int axis1Size;
|
||||
public final int axis2Size;
|
||||
+ public BlockPos foundOrigin; // Anonymous - Fix folia nether portal ticket placement
|
||||
|
||||
public FoundRectangle(final BlockPos minCorner, final int axis1Size, final int axis2Size) {
|
||||
this.minCorner = minCorner;
|
||||
this.axis1Size = axis1Size;
|
||||
this.axis2Size = axis2Size;
|
||||
+ this.foundOrigin = minCorner; // Anonymous - Fix folia nether portal ticket placement - prevent edge conditions(idk if someone would do this so just prevent it)
|
||||
}
|
||||
+ // Anonymous start - Fix folia nether portal ticket placement
|
||||
+ public FoundRectangle withFoundOrigin(BlockPos origin) {
|
||||
+ this.foundOrigin = origin;
|
||||
+ return this;
|
||||
+ }
|
||||
+ // Anonymous end
|
||||
}
|
||||
|
||||
public static class IntBounds {
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index acc9caf8559cd341ea17d3b58f13cdac7de18564..489011f9af49fa3407038bd2f00439443307d179 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4851,7 +4851,7 @@ public abstract class Entity
|
||||
portalInfoCompletable.complete(
|
||||
new TeleportTransition(destination, Vec3.atCenterOf(targetPos), Vec3.ZERO,
|
||||
90.0f, 0.0f,
|
||||
- TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET))
|
||||
+ TeleportTransition.PLAY_PORTAL_SOUND.then(ent -> ent.placePortalTicket(targetPos))) // Anonymous - Fix folia nether portal ticket placement
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -4863,7 +4863,7 @@ public abstract class Entity
|
||||
portalInfoCompletable.complete(
|
||||
net.minecraft.world.level.block.NetherPortalBlock.createDimensionTransition(
|
||||
destination, portal, originalPortalDirection, relativePos,
|
||||
- Entity.this, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET)
|
||||
+ Entity.this, TeleportTransition.PLAY_PORTAL_SOUND.then(ent -> ent.placePortalTicket(portal.foundOrigin)) // Anonymous - Fix folia nether portal ticket placement
|
||||
)
|
||||
);
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/block/NetherPortalBlock.java b/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
index 29fc9521c2c8333c999647dd833899393a838064..e8d2b52a3948755c8d3912a4ad1204cea5f78674 100644
|
||||
--- a/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
+++ b/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
@@ -204,7 +204,7 @@ public class NetherPortalBlock extends Block implements Portal {
|
||||
|
||||
return BlockUtil.getLargestRectangleAround(found, portalState.getValue(BlockStateProperties.HORIZONTAL_AXIS), 21, Direction.Axis.Y, 21, (pos) -> {
|
||||
return world.getBlockStateFromEmptyChunk(pos) == portalState;
|
||||
- });
|
||||
+ }).withFoundOrigin(found); // Anonymous - Fix folia nether portal ticket placement
|
||||
}
|
||||
// Folia end - region threading
|
||||
|
||||
@@ -148,10 +148,10 @@ index f5373786032b3f1db8e6c0c928c781998b2fe194..ca6be9faab3f93da7e91bf73997111b7
|
||||
CraftParticle.createParticleParam(particle, data), // Particle
|
||||
force,
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index efcb8b97cd685e1243c770bf3e8daf03615abb1d..4722e027ed5869516adddf696ac030fd84df834d 100644
|
||||
index 00749be3b16fd09c6b952c93631c808ff5657f20..0f6378ca80bea5d4d7f1cb7d788a57390bc27c59 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -128,6 +128,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
@@ -130,6 +130,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
return new CraftHumanEntity(server, (net.minecraft.world.entity.player.Player) entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ index 7fd08dac549261c50cf5723ef380ba90ea0da56f..7cfa9a5a1629c3af1e1105b137cbfc4c
|
||||
+ // Leaves end - replay mod api
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 4722e027ed5869516adddf696ac030fd84df834d..4d20f07ff4bf782e938ac990e2b9aaeb90b92db1 100644
|
||||
index 0f6378ca80bea5d4d7f1cb7d788a57390bc27c59..610e19b82919f05b0ebf20854e0f9b4a77a2b063 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -129,6 +129,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
@@ -131,6 +131,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
|
||||
if (entity instanceof org.leavesmc.leaves.bot.ServerBot bot) { return new org.leavesmc.leaves.entity.bot.CraftBot(server, bot); }
|
||||
|
||||
@@ -4,6 +4,7 @@ import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO;
|
||||
import com.github.luben.zstd.ZstdInputStream;
|
||||
import com.github.luben.zstd.ZstdOutputStream;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.anonymous.anonymous.data.RegionFile;
|
||||
import net.jpountz.lz4.LZ4Compressor;
|
||||
import net.jpountz.lz4.LZ4Factory;
|
||||
import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
@@ -26,7 +27,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
// LinearRegionFile_implementation_version_0_5byXymb
|
||||
// Just gonna use this string to inform other forks about updates ;-)
|
||||
public class LinearRegionFile implements IRegionFile {
|
||||
public class LinearRegionFile implements RegionFile {
|
||||
private static final long SUPERBLOCK = 0xc3ff13183cca9d9aL;
|
||||
private static final byte VERSION = 3;
|
||||
private static final int HEADER_SIZE = 27;
|
||||
@@ -489,15 +490,15 @@ public class LinearRegionFile implements IRegionFile {
|
||||
public DataOutputStream getChunkDataOutputStream(ChunkPos pos) {
|
||||
openRegionFile();
|
||||
openBucket(pos.x(), pos.z());
|
||||
return new DataOutputStream(new BufferedOutputStream(new LinearRegionFile.ChunkBuffer(pos)));
|
||||
return new DataOutputStream(new BufferedOutputStream(new ChunkBuffer(pos)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(CompoundTag data, ChunkPos pos) throws IOException {
|
||||
final DataOutputStream out = this.getChunkDataOutputStream(pos);
|
||||
|
||||
return new ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData(
|
||||
data, ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.WRITE,
|
||||
return new MoonriseRegionFileIO.RegionDataController.WriteData(
|
||||
data, MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.WRITE,
|
||||
out, regionFile -> out.close()
|
||||
);
|
||||
}
|
||||
|
||||
-1
@@ -21,5 +21,4 @@ public final class MathUtilities {
|
||||
int i = (int) d;
|
||||
return d > (double) i ? i + 1 : i;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,51 +19,35 @@ package dev.kaiijumc.kaiiju;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.github.classgraph.ClassGraph;
|
||||
import io.github.classgraph.ClassInfo;
|
||||
import io.github.classgraph.ScanResult;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class KaiijuEntityLimits {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final File CONFIG_FOLDER = new File("luminol_config");
|
||||
private static final File CONFIG_FOLDER = new File("shiroha_config");
|
||||
|
||||
protected static final String HEADER =
|
||||
"Per region entity limits for Kaiiju.\n"
|
||||
+ "If there are more of particular entity type in a region than limit, entity ticking will be throttled.\n"
|
||||
+ "Example: for Wither limit 100 & 300 Withers in a region -> 100 Withers tick every tick & every Wither ticks every 3 ticks.\n"
|
||||
+ "Available entities: GlowSquid, Ambient, Bat, Animal, Bee, Cat, Chicken, Cod, Cow, Dolphin, Fish, FishSchool, Fox, Golem, IronGolem, "
|
||||
+ "MushroomCow, Ocelot, Panda, Parrot, Perchable, Pig, PolarBear, PufferFish, Rabbit, Salmon, Sheep, Snowman, Squid, TropicalFish, Turtle, "
|
||||
+ "WaterAnimal, Wolf, Allay, Axolotl, Camel, Frog, Tadpole, Goat, Horse, HorseAbstract, HorseChestedAbstract, HorseDonkey, HorseMule, "
|
||||
+ "HorseSkeleton, HorseZombie, Llama, LlamaTrader, Sniffer, EnderCrystal, EnderDragon, Wither, ArmorStand, Hanging, ItemFrame, Leash, "
|
||||
+ "Painting, GlowItemFrame, FallingBlock, Item, TNTPrimed, Blaze, CaveSpider, Creeper, Drowned, Enderman, Endermite, Evoker, Ghast, "
|
||||
+ "GiantZombie, Guardian, GuardianElder, IllagerAbstract, IllagerIllusioner, IllagerWizard, MagmaCube, Monster, MonsterPatrolling, Phantom, "
|
||||
+ "ZombifiedPiglin, Pillager, Ravager, Shulker, Silverfish, Skeleton, SkeletonAbstract, SkeletonStray, SkeletonWither, Slime, Spider, Strider, Vex, "
|
||||
+ "Vindicator, Witch, Zoglin, Zombie, ZombieHusk, ZombieVillager, Hoglin, Piglin, PiglinAbstract, PiglinBrute, Warden, Villager, "
|
||||
+ "VillagerTrader, Arrow, DragonFireball, Egg, EnderPearl, EnderSignal, EvokerFangs, Fireball, FireballFireball, Fireworks, FishingHook, "
|
||||
+ "LargeFireball, LlamaSpit, Potion, Projectile, ProjectileThrowable, ShulkerBullet, SmallFireball, Snowball, SpectralArrow, ThrownExpBottle, "
|
||||
+ "ThrownTrident, TippedArrow, WitherSkull, Raider, ChestBoat, Boat, MinecartAbstract, MinecartChest, MinecartCommandBlock, MinecartContainer, "
|
||||
+ "MinecartFurnace, MinecartHopper, MinecartMobSpawner, MinecartRideable, MinecartTNT\n";
|
||||
+ "Entity names are named under the registry of minecraft's entity type";
|
||||
protected static final File ENTITY_LIMITS_FILE = new File(CONFIG_FOLDER, "kaiiju_entity_limits.yml");
|
||||
public static YamlConfiguration entityLimitsConfig;
|
||||
public static boolean enabled = false;
|
||||
|
||||
protected static Map<Class<? extends Entity>, EntityLimit> entityLimits;
|
||||
|
||||
static final String ENTITY_PREFIX = "Entity";
|
||||
|
||||
public static void init() {
|
||||
init(true);
|
||||
}
|
||||
@@ -84,8 +68,9 @@ public class KaiijuEntityLimits {
|
||||
entityLimitsConfig.options().header(HEADER);
|
||||
entityLimitsConfig.options().copyDefaults(true);
|
||||
entityLimitsConfig.set("enabled", enabled);
|
||||
entityLimitsConfig.set("Axolotl.limit", 1000);
|
||||
entityLimitsConfig.set("Axolotl.removal", 2000);
|
||||
entityLimitsConfig.set("axolotl.limit", 1000);
|
||||
entityLimitsConfig.set("axolotl.removal", 2000);
|
||||
|
||||
try {
|
||||
entityLimitsConfig.save(ENTITY_LIMITS_FILE);
|
||||
} catch (IOException ex) {
|
||||
@@ -96,62 +81,42 @@ public class KaiijuEntityLimits {
|
||||
|
||||
enabled = entityLimitsConfig.getBoolean("enabled");
|
||||
|
||||
entityLimits = new Object2ObjectOpenHashMap<>();
|
||||
try (ScanResult scanResult = new ClassGraph().enableAllInfo().acceptPackages("net.minecraft.world.entity").scan()) {
|
||||
Map<String, ClassInfo> entityClasses = new HashMap<>();
|
||||
for (ClassInfo classInfo : scanResult.getAllClasses()) {
|
||||
Class<?> entityClass = Class.forName(classInfo.getName());
|
||||
if (Entity.class.isAssignableFrom(entityClass)) {
|
||||
String entityName = extractEntityName(entityClass.getSimpleName());
|
||||
entityClasses.put(entityName, classInfo);
|
||||
}
|
||||
}
|
||||
|
||||
for (String key : entityLimitsConfig.getKeys(false)) {
|
||||
if (key.equals("enabled")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entityClasses.containsKey(key)) {
|
||||
LOGGER.error("Unknown entity '" + key + "' in kaiiju-entity-limits.yml, skipping");
|
||||
continue;
|
||||
}
|
||||
int limit = entityLimitsConfig.getInt(key + ".limit");
|
||||
int removal = entityLimitsConfig.getInt(key + ".removal");
|
||||
|
||||
if (limit < 1) {
|
||||
LOGGER.error(key + " has a limit less than the minimum of 1, ignoring");
|
||||
continue;
|
||||
}
|
||||
if (removal <= limit && removal != -1) {
|
||||
LOGGER.error(key + " has a removal limit that is less than or equal to its limit, setting removal to limit * 10");
|
||||
removal = limit * 10;
|
||||
}
|
||||
|
||||
entityLimits.put((Class<? extends Entity>) Class.forName(entityClasses.get(key).getName()), new EntityLimit(limit, removal));
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityLimit getEntityLimit(Entity entity) {
|
||||
return entityLimits.get(entity.getClass());
|
||||
}
|
||||
for (String key : entityLimitsConfig.getKeys(false)) {
|
||||
if (key.equals("enabled")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
private static String extractEntityName(String input) {
|
||||
int prefixLength = ENTITY_PREFIX.length();
|
||||
final Optional<Holder.Reference<EntityType<?>>> lookup = BuiltInRegistries.ENTITY_TYPE.get(Identifier.fromNamespaceAndPath(Identifier.DEFAULT_NAMESPACE, key));
|
||||
if (lookup.isEmpty()) {
|
||||
LOGGER.error("Unknown entity '{}' in kaiiju-entity-limits.yml, skipping", key);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (input.length() <= prefixLength || !input.startsWith(ENTITY_PREFIX)) {
|
||||
return input;
|
||||
} else {
|
||||
return input.substring(prefixLength);
|
||||
final EntityType<?> value = lookup.get().value();
|
||||
|
||||
int limit = entityLimitsConfig.getInt(key + ".limit");
|
||||
int removal = entityLimitsConfig.getInt(key + ".removal");
|
||||
|
||||
if (limit < 1) {
|
||||
LOGGER.error("{} has a limit less than the minimum of 1, ignoring", key);
|
||||
continue;
|
||||
}
|
||||
if (removal <= limit && removal != -1) {
|
||||
LOGGER.error("{} has a removal limit that is less than or equal to its limit, setting removal to limit * 10", key);
|
||||
removal = limit * 10;
|
||||
}
|
||||
|
||||
value.entityLimit = new EntityLimit(limit, removal);
|
||||
}
|
||||
}
|
||||
|
||||
public record EntityLimit(int limit, int removal) {
|
||||
@Override
|
||||
public String toString() {
|
||||
public @NonNull String toString() {
|
||||
return "EntityLimit{limit=" + limit + ", removal=" + removal + "}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ public class KaiijuEntityThrottler {
|
||||
public EntityThrottlerReturn tickLimiterShouldSkip(Entity entity) {
|
||||
EntityThrottlerReturn retVal = new EntityThrottlerReturn();
|
||||
if (entity.isRemoved()) return retVal;
|
||||
KaiijuEntityLimits.EntityLimit entityLimit = KaiijuEntityLimits.getEntityLimit(entity);
|
||||
|
||||
KaiijuEntityLimits.EntityLimit entityLimit = entity.getType().entityLimit;
|
||||
|
||||
if (entityLimit != null) {
|
||||
TickInfo tickInfo = entityLimitTickInfoMap.computeIfAbsent(entityLimit, el -> {
|
||||
|
||||
+3
-37
@@ -1,12 +1,9 @@
|
||||
package fun.bm.lophine.config.modules.experiment;
|
||||
|
||||
import fun.bm.lophine.enums.GlobalEntitiesCounterType;
|
||||
import me.earthme.luminol.config.ConfigManager;
|
||||
import me.earthme.luminol.config.ConfigsInstance;
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
import me.earthme.luminol.config.flags.DoNotLoad;
|
||||
import me.earthme.luminol.config.flags.HotReloadUnsupported;
|
||||
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
|
||||
@@ -16,46 +13,15 @@ public class GlobalEntitiesCounter implements IConfigModule {
|
||||
@ConfigInfo(name = "version")
|
||||
public static GlobalEntitiesCounterType type = GlobalEntitiesCounterType.DISABLED;
|
||||
|
||||
@DoNotLoad
|
||||
private static boolean enabled;
|
||||
@DoNotLoad
|
||||
private static boolean async;
|
||||
@DoNotLoad
|
||||
private static boolean defaultModule;
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return enabled;
|
||||
return type.isEnabled();
|
||||
}
|
||||
|
||||
public static boolean isAsync() {
|
||||
return async;
|
||||
return type.isAsync();
|
||||
}
|
||||
|
||||
public static boolean isDefaultModule() {
|
||||
return defaultModule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeFinalLoad() {
|
||||
ConfigsInstance configsInstance = ConfigManager.getConfigs("lophine");
|
||||
try {
|
||||
Boolean enabled0 = configsInstance.getConfigOrigin("experiment.global_entities_counter.enabled");
|
||||
Boolean async0 = configsInstance.getConfigOrigin("experiment.global_entities_counter.async");
|
||||
if (enabled0 != null) {
|
||||
if (enabled0) {
|
||||
if (async0 != null && async0) {
|
||||
type = GlobalEntitiesCounterType.DEFAULT_ASYNC;
|
||||
} else {
|
||||
type = GlobalEntitiesCounterType.DEFAULT_SYNC;
|
||||
}
|
||||
}
|
||||
}
|
||||
configsInstance.removeConfig("experiment.global_entities_counter.enabled");
|
||||
configsInstance.removeConfig("experiment.global_entities_counter.async");
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
enabled = type != GlobalEntitiesCounterType.DISABLED;
|
||||
async = type == GlobalEntitiesCounterType.DEFAULT_ASYNC;
|
||||
defaultModule = type == GlobalEntitiesCounterType.DEFAULT_SYNC || type == GlobalEntitiesCounterType.DEFAULT_ASYNC;
|
||||
return type.isDefaultModule();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,30 @@
|
||||
package fun.bm.lophine.enums;
|
||||
|
||||
public enum GlobalEntitiesCounterType {
|
||||
DISABLED,
|
||||
DEFAULT_SYNC,
|
||||
DEFAULT_ASYNC,
|
||||
PRECISE
|
||||
DISABLED(false, false, false),
|
||||
DEFAULT_SYNC(true, false, true),
|
||||
DEFAULT_ASYNC(true, true, true),
|
||||
PRECISE(true, false, false);
|
||||
|
||||
private boolean enabled;
|
||||
private boolean async;
|
||||
private boolean defaultModule;
|
||||
|
||||
private GlobalEntitiesCounterType(boolean enabled, boolean async, boolean defaultModule) {
|
||||
this.enabled = enabled;
|
||||
this.async = async;
|
||||
this.defaultModule = defaultModule;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public boolean isAsync() {
|
||||
return async;
|
||||
}
|
||||
|
||||
public boolean isDefaultModule() {
|
||||
return defaultModule;
|
||||
}
|
||||
}
|
||||
|
||||
-4
@@ -23,7 +23,6 @@ import io.sentry.Breadcrumb;
|
||||
import io.sentry.Sentry;
|
||||
import io.sentry.SentryEvent;
|
||||
import io.sentry.SentryLevel;
|
||||
import io.sentry.protocol.Message;
|
||||
import io.sentry.protocol.User;
|
||||
import me.earthme.luminol.config.modules.misc.SentryConfig;
|
||||
import org.apache.logging.log4j.Level;
|
||||
@@ -67,9 +66,6 @@ public class PufferfishSentryAppender extends AbstractAppender {
|
||||
private void logException(LogEvent e) {
|
||||
SentryEvent event = new SentryEvent(e.getThrown());
|
||||
|
||||
Message sentryMessage = new Message();
|
||||
sentryMessage.setMessage(e.getMessage().getFormattedMessage());
|
||||
|
||||
event.setThrowable(e.getThrown());
|
||||
event.setLevel(getLevel(e.getLevel()));
|
||||
event.setLogger(e.getLoggerName());
|
||||
|
||||
@@ -26,10 +26,6 @@ public class SentryManager {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(SentryManager.class);
|
||||
|
||||
private SentryManager() {
|
||||
|
||||
}
|
||||
|
||||
private static boolean initialized = false;
|
||||
|
||||
public static synchronized void init(Level logLevel) {
|
||||
|
||||
+1795
File diff suppressed because it is too large
Load Diff
+1
-2
@@ -1,10 +1,9 @@
|
||||
package me.earthme.luminol.utils;
|
||||
package io.anonymous.anonymous.data;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet;
|
||||
import me.earthme.luminol.data.BufferedLinearRegionFile;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+4
-3
@@ -1,4 +1,5 @@
|
||||
package abomination;
|
||||
package io.anonymous.anonymous.data;
|
||||
|
||||
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -10,7 +11,7 @@ import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface IRegionFile extends ChunkSystemRegionFile, AutoCloseable {
|
||||
public interface RegionFile extends ChunkSystemRegionFile, AutoCloseable {
|
||||
Path getPath();
|
||||
|
||||
DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException;
|
||||
@@ -39,5 +40,5 @@ public interface IRegionFile extends ChunkSystemRegionFile, AutoCloseable {
|
||||
|
||||
default int getRecalculateCount() {
|
||||
return 0;
|
||||
} // Luminol - Configurable region file format
|
||||
} // Anonymous - Configurable region file format
|
||||
}
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
package me.earthme.luminol.enums;
|
||||
package io.anonymous.anonymous.enums;
|
||||
|
||||
import abomination.LinearRegionFile;
|
||||
import io.anonymous.anonymous.data.BufferedLinearRegionFile;
|
||||
import io.anonymous.anonymous.utils.RegionFileFactory;
|
||||
import me.earthme.luminol.config.modules.function.RegionFormatConfig;
|
||||
import me.earthme.luminol.data.BufferedLinearRegionFile;
|
||||
import me.earthme.luminol.utils.IRegionCreateFunction;
|
||||
import net.minecraft.world.level.chunk.storage.RegionFile;
|
||||
|
||||
public enum EnumRegionFormat {
|
||||
@@ -12,14 +12,14 @@ public enum EnumRegionFormat {
|
||||
B_LINEAR("b_linear", (info) -> new BufferedLinearRegionFile(info.filePath(), RegionFormatConfig.linearCompressionLevel, RegionFormatConfig.blinearFlusher));
|
||||
|
||||
private final String argument;
|
||||
private final IRegionCreateFunction creator;
|
||||
private final RegionFileFactory creator;
|
||||
|
||||
EnumRegionFormat(String argument, IRegionCreateFunction creator) {
|
||||
EnumRegionFormat(String argument, RegionFileFactory creator) {
|
||||
this.argument = argument;
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public IRegionCreateFunction getCreator() {
|
||||
public RegionFileFactory getCreator() {
|
||||
return this.creator;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package me.earthme.luminol.utils;
|
||||
package io.anonymous.anonymous.utils;
|
||||
|
||||
import net.minecraft.world.level.chunk.storage.RegionStorageInfo;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package io.anonymous.anonymous.utils;
|
||||
|
||||
import io.anonymous.anonymous.data.RegionFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RegionFileFactory {
|
||||
RegionFile newFile(RegionCreatorInfo info) throws IOException;
|
||||
}
|
||||
+2
-2
@@ -2,6 +2,8 @@ package me.earthme.luminol.config.modules.function;
|
||||
|
||||
import abomination.LinearRegionFile;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import io.anonymous.anonymous.data.BufferedLinearRegionFileFlusher;
|
||||
import io.anonymous.anonymous.enums.EnumRegionFormat;
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.IllegalFormatConversionExceptionWithOrigin;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
@@ -9,8 +11,6 @@ import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
import me.earthme.luminol.config.flags.DoNotLoad;
|
||||
import me.earthme.luminol.config.flags.HotReloadUnsupported;
|
||||
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
import me.earthme.luminol.enums.EnumRegionFormat;
|
||||
import me.earthme.luminol.utils.BufferedLinearRegionFileFlusher;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +0,0 @@
|
||||
package me.earthme.luminol.utils;
|
||||
|
||||
import abomination.IRegionFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IRegionCreateFunction {
|
||||
IRegionFile create(RegionCreatorInfo info) throws IOException;
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* This file is part of Lithium
|
||||
*
|
||||
* Lithium is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Lithium is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Lithium. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.caffeinemc.mods.lithium.common.ai.non_poi_block_search;
|
||||
|
||||
import net.caffeinemc.mods.lithium.common.util.collections.FixedChunkAccessSectionBitBuffer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* This is intended to be used to optimize Non-POI block searches by pre-checking the ChunkSections, getting the
|
||||
* ChunkAccesses which then allows for returning early or only calling getBlockState in possible ChunkSections.
|
||||
* <p>
|
||||
* Note: Please correctly specify shouldChunkLoad based on whether the getBlockState in vanilla can chunk load or not.
|
||||
* The default in game is that it can. Setting it to true will mean that the search will assume that unloaded chunks
|
||||
* may have the target and will chunk load then search them if and when it reaches it.
|
||||
*
|
||||
* @author jcw780
|
||||
*/
|
||||
public class CheckAndCacheBlockChecker {
|
||||
private final FixedChunkAccessSectionBitBuffer chunkSections2MaybeContainsMatchingBlock;
|
||||
private final LevelReader levelReader;
|
||||
public final boolean shouldChunkLoad;
|
||||
public final Predicate<BlockState> blockStatePredicate;
|
||||
private int unloadedPossibleChunkSections = 0;
|
||||
public final int minSectionY;
|
||||
|
||||
public CheckAndCacheBlockChecker(BlockPos origin, int horizontalRangeInclusive, int verticalRangeInclusive, LevelReader levelReader,
|
||||
Predicate<BlockState> blockStatePredicate, boolean shouldChunkLoad) {
|
||||
this.chunkSections2MaybeContainsMatchingBlock = new FixedChunkAccessSectionBitBuffer(origin, horizontalRangeInclusive, verticalRangeInclusive);
|
||||
this.levelReader = levelReader;
|
||||
this.shouldChunkLoad = shouldChunkLoad;
|
||||
this.blockStatePredicate = blockStatePredicate;
|
||||
this.minSectionY = levelReader.getMinSectionY();
|
||||
}
|
||||
|
||||
public void initializeChunks() {
|
||||
this.initializeChunks(null);
|
||||
}
|
||||
|
||||
public void initializeChunks(Consumer<Long> chunkCollector) {
|
||||
final boolean nullChunkCollector = chunkCollector == null;
|
||||
for (long chunkPos : this.chunkSections2MaybeContainsMatchingBlock.getChunkPosInRange()) {
|
||||
int x = ChunkPos.getX(chunkPos);
|
||||
int z = ChunkPos.getZ(chunkPos);
|
||||
boolean chunkMaybeHas = false;
|
||||
|
||||
//Never load chunks in the first pass to avoid observably altering chunk loading behavior
|
||||
//Otherwise full region will be loaded vs partial region if the search finds the block early.
|
||||
ChunkAccess chunkAccess = levelReader.getChunk(x, z, ChunkStatus.FULL, false);
|
||||
if (chunkAccess != null) {
|
||||
this.chunkSections2MaybeContainsMatchingBlock.setChunkAccess(chunkPos, chunkAccess);
|
||||
for (int y : this.chunkSections2MaybeContainsMatchingBlock.getSectionYInRange()) {
|
||||
chunkMaybeHas = this.checkChunkSection(chunkAccess, x, y, z) || chunkMaybeHas;
|
||||
}
|
||||
} else if (this.shouldChunkLoad) {
|
||||
/* If the search may chunk load then it is possible that target blocks may be revealed when the search
|
||||
* reaches it. Since we cannot load the chunks and check now, we cannot definitively exclude subchunks
|
||||
* inside the chunk. This means that we must flag subchunks that are within build limit - otherwise air
|
||||
* anyway - for the search.
|
||||
*/
|
||||
for (int y : this.chunkSections2MaybeContainsMatchingBlock.getSectionYInRange()) {
|
||||
this.chunkSections2MaybeContainsMatchingBlock.setChunkSectionStatus(SectionPos.asLong(x, y, z),
|
||||
!levelReader.isOutsideBuildHeight(SectionPos.sectionToBlockCoord(y)));
|
||||
++this.unloadedPossibleChunkSections;
|
||||
}
|
||||
chunkMaybeHas = true;
|
||||
|
||||
}
|
||||
|
||||
if (!nullChunkCollector && chunkMaybeHas) {
|
||||
chunkCollector.accept(chunkPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getChunkSize() {
|
||||
return this.chunkSections2MaybeContainsMatchingBlock.numChunks;
|
||||
}
|
||||
|
||||
public boolean hasUnloadedPossibleChunks() {
|
||||
return this.unloadedPossibleChunkSections > 0;
|
||||
}
|
||||
|
||||
private boolean checkChunkSection(ChunkAccess chunkAccess, int chunkX, int chunkY, int chunkZ) {
|
||||
final int chunkSectionYIndex = chunkY - this.minSectionY;
|
||||
LevelChunkSection[] chunkSections = chunkAccess.getSections();
|
||||
if (chunkSectionYIndex >= 0
|
||||
&& chunkSectionYIndex < chunkSections.length
|
||||
&& chunkSections[chunkSectionYIndex].maybeHas(blockStatePredicate)) {
|
||||
this.chunkSections2MaybeContainsMatchingBlock.setChunkSectionStatus(
|
||||
SectionPos.asLong(chunkX, chunkY, chunkZ), true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkCachedSection(int chunkX, int chunkY, int chunkZ) {
|
||||
return this.chunkSections2MaybeContainsMatchingBlock.getChunkSectionBit(chunkX, chunkY, chunkZ);
|
||||
}
|
||||
|
||||
public ChunkAccess getCachedChunkAccess(long chunkPos) {
|
||||
return this.chunkSections2MaybeContainsMatchingBlock.getChunkAccess(chunkPos);
|
||||
}
|
||||
|
||||
public ChunkAccess getCachedChunkAccess(BlockPos blockPos) {
|
||||
return this.chunkSections2MaybeContainsMatchingBlock.getChunkAccess(blockPos);
|
||||
}
|
||||
|
||||
public boolean shouldStop() {
|
||||
return this.chunkSections2MaybeContainsMatchingBlock.hasNoTrueChunkSections();
|
||||
}
|
||||
|
||||
public boolean checkPosition(BlockPos blockPos) {
|
||||
if (!this.chunkSections2MaybeContainsMatchingBlock.getChunkSectionBit(blockPos)) return false;
|
||||
ChunkAccess chunkAccess = this.chunkSections2MaybeContainsMatchingBlock.getChunkAccess(blockPos);
|
||||
if (chunkAccess == null) {
|
||||
if (!this.shouldChunkLoad) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final int chunkX = SectionPos.blockToSectionCoord(blockPos.getX());
|
||||
final int chunkY = SectionPos.blockToSectionCoord(blockPos.getY());
|
||||
final int chunkZ = SectionPos.blockToSectionCoord(blockPos.getZ());
|
||||
chunkAccess = levelReader.getChunk(chunkX, chunkZ, ChunkStatus.FULL, true);
|
||||
//this chunkAccess cannot be null and reach here because it should throw earlier
|
||||
assert chunkAccess != null;
|
||||
this.chunkSections2MaybeContainsMatchingBlock.setChunkAccess(blockPos, chunkAccess);
|
||||
if (!checkChunkSection(chunkAccess, chunkX, chunkY, chunkZ)) {
|
||||
--this.unloadedPossibleChunkSections;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return blockStatePredicate.test(chunkAccess.getBlockState(blockPos));
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of Lithium
|
||||
*
|
||||
* Lithium is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Lithium is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Lithium. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.caffeinemc.mods.lithium.common.ai.non_poi_block_search;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Uses CheckAndCacheBlockChecker to improve common block searches
|
||||
*/
|
||||
public class CommonBlockSearchesCheckAndCache {
|
||||
/**
|
||||
* Optimizes BlockPos::findClosestMatch
|
||||
* [Vanilla Copy] search order and chunk-loading - even though the latter is unlikely to be observable in vanilla.
|
||||
*/
|
||||
public static Optional<BlockPos> blockPosFindClosestMatch(LevelReader levelReader, LivingEntity livingEntity,
|
||||
int horizontalRange, int verticalRange,
|
||||
Predicate<BlockState> blockStatePredicate,
|
||||
boolean shouldChunkLoad) {
|
||||
BlockPos mobPos = livingEntity.blockPosition();
|
||||
CheckAndCacheBlockChecker checker = new CheckAndCacheBlockChecker(
|
||||
mobPos, horizontalRange, verticalRange, levelReader, blockStatePredicate, shouldChunkLoad);
|
||||
checker.initializeChunks();
|
||||
if (checker.shouldStop()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return BlockPos.findClosestMatch(mobPos, horizontalRange, verticalRange, checker::checkPosition);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This file is part of Lithium
|
||||
*
|
||||
* Lithium is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Lithium is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Lithium. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.caffeinemc.mods.lithium.common.ai.non_poi_block_search;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public interface LithiumMoveToBlockGoal {
|
||||
boolean lithium$findNearestBlock(Predicate<BlockState> requiredBlock,
|
||||
BiPredicate<ChunkAccess, BlockPos.MutableBlockPos> lithium$isValidTarget,
|
||||
final boolean shouldChunkLoad);
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is part of Lithium
|
||||
*
|
||||
* Lithium is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Lithium is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Lithium. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.caffeinemc.mods.lithium.common.ai.non_poi_block_search;
|
||||
|
||||
import net.caffeinemc.mods.lithium.common.util.Distances;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
|
||||
public class NonPOISearchDistances {
|
||||
public static class MoveToBlockGoalDistances {
|
||||
public static int getMinimumSortOrderOfChunk(BlockPos center, final long chunkPos) {
|
||||
return getMinimumSortOrderOfChunk(center, ChunkPos.getX(chunkPos), ChunkPos.getZ(chunkPos));
|
||||
}
|
||||
|
||||
public static int getMinimumSortOrderOfChunk(BlockPos center, final int chunkX, final int chunkZ) {
|
||||
final int dX = Distances.getClosestBlockCoordInSection(center.getX(), chunkX) - center.getX();
|
||||
final int dZ = Distances.getClosestBlockCoordInSection(center.getZ(), chunkZ) - center.getZ();
|
||||
|
||||
//This will always get the closest one due to the nature of the search
|
||||
return getVanillaSortOrderInt(getRing(dX, dZ), dX, dZ);
|
||||
}
|
||||
|
||||
public static int getRing(final int dX, final int dZ) {
|
||||
return Math.max(Math.abs(dX), Math.abs(dZ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort order function for 1 layer of MoveToBlockGoal findNearestBlock
|
||||
* This is equivalent to:
|
||||
* int withinRingX = Math.abs(dX) * 2 - (dX > 0 ? 1 : 0);
|
||||
* int withinRingZ = Math.abs(dZ) * 2 - (dZ > 0 ? 1 : 0);
|
||||
* return ring << 16 | withinRingX << 8 | withinRingZ;
|
||||
* <p>
|
||||
* This works because the search prioritizes in order of:
|
||||
* 1. The distance of y from the center - Not used
|
||||
* 2. Whether y is - or + (+ is closer) - Not used
|
||||
* 3. The square ring that the block is in (outer is further)
|
||||
* 4. The distance of x from the center
|
||||
* 5. Whether x is - or + (+ is closer)
|
||||
* 6. The distance of z from the center
|
||||
* 7. Whether z is - or + (+ is closer)
|
||||
* <p>
|
||||
* Note: The bit-packing only works for horizontal search ranges of <=128.
|
||||
* You can convert to longs if you somehow exceed that, but also seriously consider POIs instead.
|
||||
*
|
||||
* @param ring Which square ring the block is at relative to the center
|
||||
* @param dX Relative x position of the block to the center
|
||||
* @param dZ Relative z position of the block to the center
|
||||
*/
|
||||
public static int getVanillaSortOrderInt(final int ring, final int dX, final int dZ) {
|
||||
return (ring << 16 | Math.abs(dX) << 9 | Math.abs(dZ) << 1) - ((dX > 0 ? 1 : 0) << 8 | (dZ > 0 ? 1 : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of Lithium
|
||||
*
|
||||
* Lithium is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Lithium is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Lithium. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.caffeinemc.mods.lithium.common.util;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
|
||||
public class Distances {
|
||||
|
||||
public static long getMinChunkToBlockDistanceL2Sq(BlockPos origin, int chunkX, int chunkZ) {
|
||||
int chunkMinX = SectionPos.sectionToBlockCoord(chunkX);
|
||||
int chunkMinZ = SectionPos.sectionToBlockCoord(chunkZ);
|
||||
|
||||
int xDistance = origin.getX() - chunkMinX;
|
||||
if (xDistance > 0) {
|
||||
xDistance = Math.max(0, xDistance - 15);
|
||||
}
|
||||
int zDistance = origin.getZ() - chunkMinZ;
|
||||
if (zDistance > 0) {
|
||||
zDistance = Math.max(0, zDistance - 15);
|
||||
}
|
||||
|
||||
return (long) xDistance * (long) xDistance + (long) zDistance * (long) zDistance;
|
||||
}
|
||||
|
||||
public static BlockPos getClosestPosInChunk(BlockPos origin, int chunkX, int chunkZ) {
|
||||
int closestX = getClosestBlockCoordInSection(origin.getX(), chunkX);
|
||||
int closestZ = getClosestBlockCoordInSection(origin.getZ(), chunkZ);
|
||||
return new BlockPos(closestX, origin.getY(), closestZ);
|
||||
}
|
||||
|
||||
public static boolean isWithinCubeRadius(BlockPos origin, int radius, BlockPos pos) {
|
||||
return Math.abs(pos.getX() - origin.getX()) <= radius &&
|
||||
Math.abs(pos.getZ() - origin.getZ()) <= radius;
|
||||
}
|
||||
|
||||
public static boolean isWithinSphereRadius(BlockPos origin, long radiusSq, BlockPos pos) {
|
||||
return distanceSq(origin, pos) <= radiusSq;
|
||||
}
|
||||
|
||||
public static int getClosestBlockCoordInSection(int blockCoord, int sectionCoord) {
|
||||
final int minBlockInSection = SectionPos.sectionToBlockCoord(sectionCoord);
|
||||
return Math.min(Math.max(blockCoord, minBlockInSection), minBlockInSection + 15);
|
||||
}
|
||||
|
||||
public static long getMinSectionDistanceSq(BlockPos origin, int chunkX, int chunkY, int chunkZ) {
|
||||
int originX = origin.getX(), originY = origin.getY(), originZ = origin.getZ();
|
||||
long distX = getClosestBlockCoordInSection(originX, chunkX) - originX;
|
||||
long distY = getClosestBlockCoordInSection(originY, chunkY) - originY;
|
||||
long distZ = getClosestBlockCoordInSection(originZ, chunkZ) - originZ;
|
||||
|
||||
return distX * distX + distY * distY + distZ * distZ;
|
||||
}
|
||||
|
||||
public static long distanceSq(BlockPos a, BlockPos b) {
|
||||
long dx = a.getX() - b.getX();
|
||||
long dy = a.getY() - b.getY();
|
||||
long dz = a.getZ() - b.getZ();
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
|
||||
public static int distanceSqInt(BlockPos a, BlockPos b) {
|
||||
int dx = a.getX() - b.getX();
|
||||
int dy = a.getY() - b.getY();
|
||||
int dz = a.getZ() - b.getZ();
|
||||
// Check overflows to avoid silent incorrect results
|
||||
return Math.addExact(Math.addExact(Math.multiplyExact(dx, dx), Math.multiplyExact(dy, dy)), Math.multiplyExact(dz, dz));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* This file is part of Lithium
|
||||
*
|
||||
* Lithium is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Lithium is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Lithium. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.caffeinemc.mods.lithium.common.util;
|
||||
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.LevelHeightAccessor;
|
||||
|
||||
public class Pos {
|
||||
|
||||
public static class BlockCoord {
|
||||
public static int getYSize(LevelHeightAccessor view) {
|
||||
return view.getHeight();
|
||||
}
|
||||
|
||||
public static int getMinY(LevelHeightAccessor view) {
|
||||
return view.getMinY();
|
||||
}
|
||||
|
||||
public static int getMaxYInclusive(LevelHeightAccessor view) {
|
||||
return view.getMaxY();
|
||||
}
|
||||
|
||||
public static int getMaxYExclusive(LevelHeightAccessor view) {
|
||||
return view.getMaxY() + 1;
|
||||
}
|
||||
|
||||
public static int getMaxInSectionCoord(int sectionCoord) {
|
||||
return 15 + getMinInSectionCoord(sectionCoord);
|
||||
}
|
||||
|
||||
public static int getMaxYInSectionIndex(LevelHeightAccessor view, int sectionIndex) {
|
||||
return getMaxInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex));
|
||||
}
|
||||
|
||||
public static int getMinInSectionCoord(int sectionCoord) {
|
||||
return SectionPos.sectionToBlockCoord(sectionCoord);
|
||||
}
|
||||
|
||||
public static int getMinYInSectionIndex(LevelHeightAccessor view, int sectionIndex) {
|
||||
return getMinInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex));
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChunkCoord {
|
||||
public static int fromBlockCoord(int blockCoord) {
|
||||
return SectionPos.blockToSectionCoord(blockCoord);
|
||||
}
|
||||
|
||||
public static int fromBlockSize(int i) {
|
||||
return i >> 4; //same method as fromBlockCoord, just be clear about coord/size semantic difference
|
||||
}
|
||||
}
|
||||
|
||||
public static class SectionYCoord {
|
||||
public static int getNumYSections(LevelHeightAccessor view) {
|
||||
return view.getSectionsCount();
|
||||
}
|
||||
|
||||
public static int getMinYSection(LevelHeightAccessor view) {
|
||||
return view.getMinSectionY();
|
||||
}
|
||||
|
||||
public static int getMaxYSectionInclusive(LevelHeightAccessor view) {
|
||||
return view.getMaxSectionY();
|
||||
}
|
||||
|
||||
public static int getMaxYSectionExclusive(LevelHeightAccessor view) {
|
||||
return view.getMaxSectionY() + 1;
|
||||
}
|
||||
|
||||
public static int fromSectionIndex(LevelHeightAccessor view, int sectionCoord) {
|
||||
return sectionCoord + SectionYCoord.getMinYSection(view);
|
||||
}
|
||||
|
||||
public static int fromBlockCoord(int blockCoord) {
|
||||
return SectionPos.blockToSectionCoord(blockCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SectionYIndex {
|
||||
public static int getNumYSections(LevelHeightAccessor view) {
|
||||
return view.getSectionsCount();
|
||||
}
|
||||
|
||||
public static int getMinYSectionIndex(LevelHeightAccessor view) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getMaxYSectionIndexInclusive(LevelHeightAccessor view) {
|
||||
return view.getSectionsCount() - 1;
|
||||
}
|
||||
|
||||
public static int getMaxYSectionIndexExclusive(LevelHeightAccessor view) {
|
||||
return view.getSectionsCount();
|
||||
}
|
||||
|
||||
|
||||
public static int fromSectionCoord(LevelHeightAccessor view, int sectionCoord) {
|
||||
return sectionCoord - SectionYCoord.getMinYSection(view);
|
||||
}
|
||||
|
||||
public static int fromBlockCoord(LevelHeightAccessor view, int blockCoord) {
|
||||
return fromSectionCoord(view, SectionPos.blockToSectionCoord(blockCoord));
|
||||
}
|
||||
}
|
||||
}
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* This file is part of Lithium
|
||||
*
|
||||
* Lithium is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Lithium is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Lithium. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.caffeinemc.mods.lithium.common.util.collections;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntIterable;
|
||||
import it.unimi.dsi.fastutil.ints.IntIterator;
|
||||
import it.unimi.dsi.fastutil.longs.LongIterable;
|
||||
import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collections;
|
||||
|
||||
public class FixedChunkAccessSectionBitBuffer {
|
||||
public final int xMin, yMin, zMin;
|
||||
public final int xLength, yLength, zLength, numChunks, numSections;
|
||||
|
||||
public final BitSet chunkSectionBits;
|
||||
public final ArrayList<ChunkAccess> chunkAccesses;
|
||||
|
||||
public FixedChunkAccessSectionBitBuffer(int x0, int x1, int y0, int y1, int z0, int z1) {
|
||||
this.xMin = Math.min(x0, x1);
|
||||
this.yMin = Math.min(y0, y1);
|
||||
this.zMin = Math.min(z0, z1);
|
||||
|
||||
this.xLength = Math.max(x0, x1) - this.xMin + 1;
|
||||
this.yLength = Math.max(y0, y1) - this.yMin + 1;
|
||||
this.zLength = Math.max(z0, z1) - this.zMin + 1;
|
||||
|
||||
this.numChunks = xLength * zLength;
|
||||
this.numSections = yLength * xLength * zLength;
|
||||
|
||||
this.chunkSectionBits = new BitSet(numSections);
|
||||
this.chunkAccesses = new ArrayList<>(Collections.nCopies(xLength * zLength, null));
|
||||
}
|
||||
|
||||
public FixedChunkAccessSectionBitBuffer(BlockPos center, int horizontalRangeInclusive, int verticalRangeInclusive) {
|
||||
this(SectionPos.blockToSectionCoord(center.getX() - horizontalRangeInclusive),
|
||||
SectionPos.blockToSectionCoord(center.getX() + horizontalRangeInclusive),
|
||||
SectionPos.blockToSectionCoord(center.getY() - verticalRangeInclusive),
|
||||
SectionPos.blockToSectionCoord(center.getY() + verticalRangeInclusive),
|
||||
SectionPos.blockToSectionCoord(center.getZ() - horizontalRangeInclusive),
|
||||
SectionPos.blockToSectionCoord(center.getZ() + horizontalRangeInclusive)
|
||||
);
|
||||
}
|
||||
|
||||
public int getSectionIndex(int x, int y, int z) {
|
||||
int dx = x - this.xMin;
|
||||
int dy = y - this.yMin;
|
||||
int dz = z - this.zMin;
|
||||
|
||||
return (dx * this.zLength + dz) * this.yLength + dy;
|
||||
}
|
||||
|
||||
public int getSectionIndex(long sectionPos) {
|
||||
return this.getSectionIndex(
|
||||
SectionPos.x(sectionPos),
|
||||
SectionPos.y(sectionPos),
|
||||
SectionPos.z(sectionPos)
|
||||
);
|
||||
}
|
||||
|
||||
public boolean getChunkSectionBit(BlockPos blockPos) {
|
||||
return this.getChunkSectionBit(SectionPos.blockToSectionCoord(blockPos.getX()), SectionPos.blockToSectionCoord(blockPos.getY()), SectionPos.blockToSectionCoord(blockPos.getZ()));
|
||||
}
|
||||
|
||||
public boolean getChunkSectionBit(int chunkX, int chunkY, int chunkZ) {
|
||||
return this.chunkSectionBits.get(this.getSectionIndex(chunkX, chunkY, chunkZ));
|
||||
}
|
||||
|
||||
public void setChunkSectionStatus(long sectionPos, boolean value) {
|
||||
this.chunkSectionBits.set(this.getSectionIndex(sectionPos), value);
|
||||
}
|
||||
|
||||
public int getChunkIndex(int x, int z) {
|
||||
int dx = x - this.xMin;
|
||||
int dz = z - this.zMin;
|
||||
|
||||
return dx * this.zLength + dz;
|
||||
}
|
||||
|
||||
public int getChunkIndex(long chunkPos) {
|
||||
return this.getChunkIndex(ChunkPos.getX(chunkPos), ChunkPos.getZ(chunkPos));
|
||||
}
|
||||
|
||||
public ChunkAccess getChunkAccess(long chunkPos) {
|
||||
return this.chunkAccesses.get(this.getChunkIndex(chunkPos));
|
||||
}
|
||||
|
||||
public ChunkAccess getChunkAccess(BlockPos blockPos) {
|
||||
return this.getChunkAccess(ChunkPos.pack(blockPos));
|
||||
}
|
||||
|
||||
public void setChunkAccess(long chunkPos, ChunkAccess chunkAccess) {
|
||||
this.chunkAccesses.set(this.getChunkIndex(chunkPos), chunkAccess);
|
||||
}
|
||||
|
||||
public void setChunkAccess(BlockPos blockPos, ChunkAccess chunkAccess) {
|
||||
this.setChunkAccess(ChunkPos.pack(blockPos), chunkAccess);
|
||||
}
|
||||
|
||||
public boolean hasNoTrueChunkSections() {
|
||||
return this.chunkSectionBits.nextSetBit(0) == -1;
|
||||
}
|
||||
|
||||
public LongIterable getChunkPosInRange() {
|
||||
return new LongIterable() {
|
||||
@Override
|
||||
public @NotNull LongIterator iterator() {
|
||||
return getChunkPosInRangeIterator();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public LongIterator getChunkPosInRangeIterator() {
|
||||
final int xMin = this.xMin;
|
||||
final int xMax = this.xMin + this.xLength - 1;
|
||||
final int zMin = this.zMin;
|
||||
final int zMax = this.zMin + this.zLength - 1;
|
||||
return new LongIterator() {
|
||||
int x = xMin;
|
||||
int z = zMin;
|
||||
|
||||
@Override
|
||||
public long nextLong() {
|
||||
long result = ChunkPos.pack(x, z);
|
||||
if (z < zMax) {
|
||||
z++;
|
||||
} else {
|
||||
z = zMin;
|
||||
x++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return x <= xMax;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public IntIterable getSectionYInRange() {
|
||||
return new IntIterable() {
|
||||
@Override
|
||||
public @NotNull IntIterator iterator() {
|
||||
return getSectionYInRangeIterator();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public IntIterator getSectionYInRangeIterator() {
|
||||
final int yMin = this.yMin;
|
||||
final int yLimit = yMin + this.yLength;
|
||||
return new IntIterator() {
|
||||
int y = yMin;
|
||||
|
||||
@Override
|
||||
public int nextInt() {
|
||||
return y++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return y < yLimit;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
+293
@@ -0,0 +1,293 @@
|
||||
/*
|
||||
* This file is part of Lithium
|
||||
*
|
||||
* Lithium is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Lithium is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Lithium. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.caffeinemc.mods.lithium.common.util.collections;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Wraps a {@link List} with a hash table which provides O(1) lookups for {@link Collection#contains(Object)}. The type
|
||||
* contained by this list must use reference-equality semantics.
|
||||
*/
|
||||
@SuppressWarnings("SuspiciousMethodCalls")
|
||||
public class HashedReferenceList<T> implements List<T> {
|
||||
private final ReferenceArrayList<T> list;
|
||||
private final Reference2IntOpenHashMap<T> counter;
|
||||
|
||||
public HashedReferenceList(Collection<T> list) {
|
||||
this.list = new ReferenceArrayList<>();
|
||||
this.list.addAll(list);
|
||||
|
||||
this.counter = new Reference2IntOpenHashMap<>();
|
||||
this.counter.defaultReturnValue(0);
|
||||
|
||||
for (T obj : this.list) {
|
||||
this.counter.addTo(obj, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return this.list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.list.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return this.counter.containsKey(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return this.listIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return this.list.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T1> T1[] toArray(T1 @NotNull [] a) {
|
||||
return this.list.toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(T t) {
|
||||
this.trackReferenceAdded(t);
|
||||
|
||||
return this.list.add(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
this.trackReferenceRemoved(o);
|
||||
|
||||
return this.list.remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
for (Object obj : c) {
|
||||
if (!this.counter.containsKey(obj)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends T> c) {
|
||||
for (T obj : c) {
|
||||
this.trackReferenceAdded(obj);
|
||||
}
|
||||
|
||||
return this.list.addAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends T> c) {
|
||||
for (T obj : c) {
|
||||
this.trackReferenceAdded(obj);
|
||||
}
|
||||
|
||||
return this.list.addAll(index, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(@NotNull Collection<?> c) {
|
||||
if (this.size() >= 2 && c.size() > 4 && c instanceof List) {
|
||||
//HashReferenceList uses reference equality, so using ReferenceOpenHashSet is fine
|
||||
c = new ReferenceOpenHashSet<>(c);
|
||||
}
|
||||
this.counter.keySet().removeAll(c);
|
||||
return this.list.removeAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(@NotNull Collection<?> c) {
|
||||
this.counter.keySet().retainAll(c);
|
||||
return this.list.retainAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.counter.clear();
|
||||
this.list.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return this.list.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T set(int index, T element) {
|
||||
T prev = this.list.set(index, element);
|
||||
|
||||
if (prev != element) {
|
||||
if (prev != null) {
|
||||
this.trackReferenceRemoved(prev);
|
||||
}
|
||||
|
||||
this.trackReferenceAdded(element);
|
||||
}
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, T element) {
|
||||
this.trackReferenceAdded(element);
|
||||
|
||||
this.list.add(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T remove(int index) {
|
||||
T prev = this.list.remove(index);
|
||||
|
||||
if (prev != null) {
|
||||
this.trackReferenceRemoved(prev);
|
||||
}
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
return this.list.indexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
return this.list.lastIndexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<T> listIterator() {
|
||||
return this.listIterator(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<T> listIterator(int index) {
|
||||
return new ListIterator<>() {
|
||||
private final ListIterator<T> inner = HashedReferenceList.this.list.listIterator(index);
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return this.inner.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
return this.inner.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrevious() {
|
||||
return this.inner.hasPrevious();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T previous() {
|
||||
return this.inner.previous();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextIndex() {
|
||||
return this.inner.nextIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int previousIndex() {
|
||||
return this.inner.previousIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
int last = this.previousIndex();
|
||||
|
||||
if (last == -1) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
T prev = HashedReferenceList.this.get(last);
|
||||
|
||||
if (prev != null) {
|
||||
HashedReferenceList.this.trackReferenceRemoved(prev);
|
||||
}
|
||||
|
||||
this.inner.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(T t) {
|
||||
int last = this.previousIndex();
|
||||
|
||||
if (last == -1) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
T prev = HashedReferenceList.this.get(last);
|
||||
|
||||
if (prev != t) {
|
||||
if (prev != null) {
|
||||
HashedReferenceList.this.trackReferenceRemoved(prev);
|
||||
}
|
||||
|
||||
HashedReferenceList.this.trackReferenceAdded(t);
|
||||
}
|
||||
|
||||
this.inner.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(T t) {
|
||||
HashedReferenceList.this.trackReferenceAdded(t);
|
||||
|
||||
this.inner.add(t);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> subList(int fromIndex, int toIndex) {
|
||||
return this.list.subList(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
private void trackReferenceAdded(T t) {
|
||||
this.counter.addTo(t, 1);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void trackReferenceRemoved(Object o) {
|
||||
if (this.counter.addTo((T) o, -1) <= 1) {
|
||||
this.counter.removeInt(o);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public record BotCreateState(String rawName, String fullName, String skinName, S
|
||||
}
|
||||
|
||||
public void spawnWithSkin(Consumer<Bot> consumer) {
|
||||
Bukkit.getAsyncScheduler().runNow(MinecraftInternalPlugin.INSTANCE, (task0) -> {
|
||||
Bukkit.getAsyncScheduler().runNow(MinecraftInternalPlugin.INSTANCE, (_) -> {
|
||||
this.mojangAPISkin();
|
||||
Bukkit.getRegionScheduler().execute(
|
||||
MinecraftInternalPlugin.INSTANCE,
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.core.UUIDUtil;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtAccounter;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
@@ -34,7 +35,10 @@ import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BotDataStorage {
|
||||
|
||||
@@ -42,7 +46,7 @@ public class BotDataStorage {
|
||||
private final File botDir;
|
||||
private final File botListFile;
|
||||
|
||||
private CompoundTag savedBotList;
|
||||
private final CompoundTag savedBotList;
|
||||
|
||||
public BotDataStorage(LevelStorageSource.@NotNull LevelStorageAccess session, String dataDir, String listFileName) {
|
||||
this.botDir = session.getLevelPath(new LevelResource(dataDir)).toFile();
|
||||
@@ -52,7 +56,11 @@ public class BotDataStorage {
|
||||
this.savedBotList = new CompoundTag();
|
||||
if (this.botListFile.exists() && this.botListFile.isFile()) {
|
||||
try {
|
||||
Optional.of(NbtIo.readCompressed(this.botListFile.toPath(), NbtAccounter.unlimitedHeap())).ifPresent(tag -> this.savedBotList = tag);
|
||||
Optional.of(NbtIo.readCompressed(this.botListFile.toPath(), NbtAccounter.unlimitedHeap())).ifPresent(tag -> {
|
||||
for (Map.Entry<String, Tag> entry : tag.entrySet()) {
|
||||
savedBotList.put(entry.getKey().toLowerCase(Locale.ROOT), entry.getValue());
|
||||
}
|
||||
});
|
||||
} catch (Exception exception) {
|
||||
BotDataStorage.LOGGER.warn("Failed to load player data list");
|
||||
}
|
||||
@@ -60,7 +68,6 @@ public class BotDataStorage {
|
||||
}
|
||||
|
||||
public void save(Player player) {
|
||||
boolean flag = true;
|
||||
try {
|
||||
CompoundTag nbt = TagUtil.saveEntityWithoutId(player);
|
||||
File file = new File(this.botDir, player.getStringUUID() + ".dat");
|
||||
@@ -76,20 +83,19 @@ public class BotDataStorage {
|
||||
NbtIo.writeCompressed(nbt, file.toPath());
|
||||
} catch (Exception exception) {
|
||||
BotDataStorage.LOGGER.warn("Failed to save fakeplayer data for {}", player.getScoreboardName(), exception);
|
||||
flag = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (flag && player instanceof ServerBot bot) {
|
||||
if (player instanceof ServerBot bot) {
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
nbt.putString("name", bot.createState.fullName());
|
||||
nbt.store("uuid", UUIDUtil.CODEC, bot.getUUID());
|
||||
nbt.putBoolean("resume", bot.resume);
|
||||
this.savedBotList.put(bot.createState.fullName(), nbt);
|
||||
this.savedBotList.put(bot.createState.fullName().toLowerCase(Locale.ROOT), nbt);
|
||||
this.saveBotList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Optional<ValueInput> load(@NotNull ServerBot bot, ProblemReporter reporter) {
|
||||
return this.load(bot.nameAndId().name(), bot.nameAndId().id().toString()).map(nbt -> {
|
||||
ValueInput valueInput = TagValueInput.create(reporter, bot.registryAccess(), nbt);
|
||||
@@ -98,27 +104,27 @@ public class BotDataStorage {
|
||||
});
|
||||
}
|
||||
|
||||
public void removeSavedData(@NotNull ServerBot bot) {
|
||||
this.load(bot.nameAndId().name(), bot.nameAndId().id().toString());
|
||||
public void removeSavedData(String name) {
|
||||
this.savedBotList.remove(name.toLowerCase(Locale.ROOT));
|
||||
this.saveBotList();
|
||||
}
|
||||
|
||||
private Optional<CompoundTag> load(String name, String uuid) {
|
||||
File file = new File(this.botDir, uuid + ".dat");
|
||||
|
||||
if (file.exists() && file.isFile()) {
|
||||
try {
|
||||
Optional<CompoundTag> optional = Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap()));
|
||||
if (!file.delete()) {
|
||||
throw new IOException("Failed to delete fakeplayer data");
|
||||
}
|
||||
this.savedBotList.remove(name);
|
||||
this.saveBotList();
|
||||
return optional;
|
||||
} catch (Exception exception) {
|
||||
BotDataStorage.LOGGER.warn("Failed to load fakeplayer data for {}", name);
|
||||
}
|
||||
if (!file.exists() || !file.isFile()) {
|
||||
LOGGER.warn("Failed to load bot {}, the file {} DOES NOT EXIST!", name, file);
|
||||
return Optional.empty();
|
||||
}
|
||||
try {
|
||||
Optional<CompoundTag> optional = Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap()));
|
||||
if (!file.delete()) {
|
||||
throw new IOException("Failed to delete fakeplayer data");
|
||||
}
|
||||
this.removeSavedData(name);
|
||||
return optional;
|
||||
} catch (Exception exception) {
|
||||
BotDataStorage.LOGGER.warn("Failed to load fakeplayer data for {}", name);
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -153,4 +159,12 @@ public class BotDataStorage {
|
||||
public CompoundTag getSavedBotList() {
|
||||
return savedBotList;
|
||||
}
|
||||
|
||||
public UUID getUUIDFromLower(String lowerName) {
|
||||
return savedBotList.getCompoundOrEmpty(lowerName).read("uuid", UUIDUtil.CODEC).orElseThrow();
|
||||
}
|
||||
|
||||
public String getNameFromLower(String lowerName) {
|
||||
return savedBotList.getCompoundOrEmpty(lowerName).getString("name").orElseThrow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ import fun.bm.lophine.config.modules.function.OldFeatureConfig;
|
||||
import io.papermc.paper.adventure.PaperAdventure;
|
||||
import io.papermc.paper.profile.MutablePropertyMap;
|
||||
import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
import io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler;
|
||||
import io.papermc.paper.util.MCUtil;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
@@ -76,7 +76,7 @@ public class BotList {
|
||||
private final BotDataStorage resumeDataStorage;
|
||||
|
||||
private final Map<UUID, ServerBot> botsByUUID = Maps.newHashMap();
|
||||
private final Map<String, ServerBot> botsByName = Maps.newHashMap();
|
||||
private final Map<String, ServerBot> botsByLowerName = Maps.newHashMap();
|
||||
private final Map<String, Set<String>> botsNameByWorldUuid = Maps.newHashMap();
|
||||
private final Map<String, Set<String>> legacyBotsNameByWorldUuid = Maps.newHashMap();
|
||||
|
||||
@@ -141,20 +141,24 @@ public class BotList {
|
||||
return this.loadNewBot(fullName, this.resumeDataStorage);
|
||||
}
|
||||
|
||||
public ServerBot loadNewBot(String fullName, BotDataStorage storage) {
|
||||
if (botsByName.containsKey(fullName)) {
|
||||
public ServerBot loadNewBot(String inputName, BotDataStorage storage) {
|
||||
String lowerName = inputName.toLowerCase(Locale.ROOT);
|
||||
if (botsByLowerName.containsKey(lowerName)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
UUID uuid = BotUtil.getBotUUID(fullName);
|
||||
|
||||
BotLoadEvent event = new BotLoadEvent(fullName, uuid);
|
||||
if (!storage.getSavedBotList().contains(lowerName)) {
|
||||
return null;
|
||||
}
|
||||
String name = storage.getNameFromLower(lowerName);
|
||||
UUID uuid = storage.getUUIDFromLower(lowerName);
|
||||
BotLoadEvent event = new BotLoadEvent(name, uuid);
|
||||
this.server.server.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ServerBot bot = new ServerBot(this.server, this.server.getLevel(Level.OVERWORLD), new GameProfile(uuid, fullName));
|
||||
ServerBot bot = new ServerBot(this.server, this.server.getLevel(Level.OVERWORLD), new GameProfile(uuid, name));
|
||||
bot.connection = new ServerBotPacketListenerImpl(this.server, bot);
|
||||
Optional<ValueInput> optional;
|
||||
try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(bot.problemPath(), LOGGER)) {
|
||||
@@ -182,7 +186,7 @@ public class BotList {
|
||||
ServerLevel world = this.server.getLevel(resourcekey);
|
||||
return this.placeNewBot(bot, world, bot.getLocation(), nbt);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to load bot {}", fullName, e);
|
||||
LOGGER.error("Failed to load bot {}", inputName, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -213,18 +217,20 @@ public class BotList {
|
||||
bot.connection.teleport(bot.getX(), bot.getY(), bot.getZ(), bot.getYRot(), bot.getXRot());
|
||||
|
||||
this.bots.add(bot);
|
||||
this.botsByName.put(bot.getScoreboardName().toLowerCase(Locale.ROOT), bot);
|
||||
this.botsByLowerName.put(bot.getScoreboardName().toLowerCase(Locale.ROOT), bot);
|
||||
this.botsByUUID.put(bot.getUUID(), bot);
|
||||
|
||||
bot.suppressTrackerForLogin = true;
|
||||
|
||||
Runnable task = () -> {
|
||||
world.addNewPlayer(bot);
|
||||
optional.ifPresent(nbt -> {
|
||||
bot.loadAndSpawnEnderPearls(nbt);
|
||||
bot.loadAndSpawnParentVehicle(nbt);
|
||||
});
|
||||
|
||||
world.getCurrentWorldData().connections.add(bot.connection.connection);
|
||||
world.addNewPlayer(bot);
|
||||
|
||||
BotJoinEvent event1 = new BotJoinEvent(bot.getBukkitEntity(), PaperAdventure.asAdventure(Component.translatable("multiplayer.player.joined", bot.getDisplayName())).style(Style.style(NamedTextColor.YELLOW)));
|
||||
this.server.server.getPluginManager().callEvent(event1);
|
||||
|
||||
@@ -255,22 +261,7 @@ public class BotList {
|
||||
return bot;
|
||||
}
|
||||
|
||||
/*
|
||||
* return true if async
|
||||
*/
|
||||
public boolean removeBot(@NotNull ServerBot bot, @NotNull BotRemoveEvent.RemoveReason reason, @Nullable CommandSender remover, boolean save, boolean resume, boolean async) {
|
||||
if (async && !TickThread.isTickThreadFor(bot.level(), bot.getX(), bot.getZ())) {
|
||||
bot.getBukkitEntity().taskScheduler.schedule((Entity unused) -> this.removeBot(bot, reason, remover, save, resume), null, 1L);
|
||||
return true; // async always return true
|
||||
}
|
||||
return this.removeBot(bot, remover, reason, save, resume);
|
||||
}
|
||||
|
||||
public boolean removeBot(@NotNull ServerBot bot, @NotNull BotRemoveEvent.RemoveReason reason, @Nullable CommandSender remover, boolean save, boolean resume) {
|
||||
return this.removeBot(bot, reason, remover, save, resume, true);
|
||||
}
|
||||
|
||||
public boolean removeBot(@NotNull ServerBot bot, @Nullable CommandSender remover, @NotNull BotRemoveEvent.RemoveReason reason, boolean save, boolean resume) {
|
||||
BotRemoveEvent event = new BotRemoveEvent(bot.getBukkitEntity(), reason, remover, PaperAdventure.asAdventure(Component.translatable("multiplayer.player.left", bot.getDisplayName())).style(Style.style(NamedTextColor.YELLOW)), save);
|
||||
this.server.server.getPluginManager().callEvent(event);
|
||||
|
||||
@@ -279,13 +270,13 @@ public class BotList {
|
||||
}
|
||||
|
||||
if (bot.removeTaskId != -1) {
|
||||
((FoliaGlobalRegionScheduler) Bukkit.getGlobalRegionScheduler()).cancelTask(bot.removeTaskId);
|
||||
Bukkit.getScheduler().cancelTask(bot.removeTaskId);
|
||||
bot.removeTaskId = -1;
|
||||
}
|
||||
|
||||
bot.disconnect();
|
||||
|
||||
this.resumeDataStorage.removeSavedData(bot);
|
||||
this.resumeDataStorage.removeSavedData(bot.nameAndId().name());
|
||||
if (event.shouldSave()) {
|
||||
if (resume) {
|
||||
this.resumeDataStorage.save(bot);
|
||||
@@ -293,6 +284,7 @@ public class BotList {
|
||||
this.manualSaveDataStorage.save(bot);
|
||||
}
|
||||
} else {
|
||||
bot.dropExperience(bot.level(), null);
|
||||
bot.dropAll(true);
|
||||
botsNameByWorldUuid.getOrDefault(bot.level().uuid.toString(), new HashSet<>()).remove(bot.getBukkitEntity().getName());
|
||||
}
|
||||
@@ -327,7 +319,7 @@ public class BotList {
|
||||
bot.retireScheduler();
|
||||
|
||||
this.bots.remove(bot);
|
||||
this.botsByName.remove(bot.getScoreboardName().toLowerCase(Locale.ROOT));
|
||||
this.botsByLowerName.remove(bot.getScoreboardName().toLowerCase(Locale.ROOT));
|
||||
|
||||
UUID uuid = bot.getUUID();
|
||||
ServerBot bot1 = this.botsByUUID.get(uuid);
|
||||
@@ -400,7 +392,9 @@ public class BotList {
|
||||
return;
|
||||
}
|
||||
CompoundTag savedBotList = this.getResumeBotList().copy();
|
||||
for (String fullName : savedBotList.keySet()) {
|
||||
for (Map.Entry<String, Tag> entry : savedBotList.entrySet()) {
|
||||
String lowerName = entry.getKey();
|
||||
String fullName = ((CompoundTag) entry.getValue()).getStringOr("name", lowerName);
|
||||
UUID levelUuid = BotUtil.getBotLevel(fullName, this.resumeDataStorage);
|
||||
if (levelUuid == null) {
|
||||
LOGGER.warn("Bot {} has no world UUID, skipping loading.", fullName);
|
||||
@@ -416,6 +410,7 @@ public class BotList {
|
||||
private void loadLegacyResumeBotInfo() {
|
||||
CompoundTag savedBotList = this.getManualSavedBotList().copy();
|
||||
for (String fullName : savedBotList.keySet()) {
|
||||
// Legacy format saved fullName as the key
|
||||
CompoundTag nbt = savedBotList.getCompound(fullName).orElseThrow();
|
||||
if (!nbt.getBoolean("resume").orElse(false)) {
|
||||
continue;
|
||||
@@ -461,7 +456,7 @@ public class BotList {
|
||||
|
||||
@Nullable
|
||||
public ServerBot getBotByName(@NotNull String name) {
|
||||
return this.botsByName.get(name.toLowerCase(Locale.ROOT));
|
||||
return this.botsByLowerName.get(name.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public CompoundTag getManualSavedBotList() {
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.minecraft.stats.ServerStatsCounter;
|
||||
import net.minecraft.stats.Stat;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -45,7 +44,7 @@ public class BotStatsCounter extends ServerStatsCounter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parse(@NonNull DataFixer fixerUpper, @NonNull JsonElement json) {
|
||||
public void parse(DataFixer fixerUpper, JsonElement json) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
package org.leavesmc.leaves.bot;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import fun.bm.lophine.carpet.config.modules.FakePlayerCompatConfig;
|
||||
import fun.bm.lophine.config.modules.function.FakeplayerConfig;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.component.ItemContainerContents;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -38,66 +34,23 @@ public class BotUtil {
|
||||
public static void replenishment(@NotNull ItemStack itemStack, NonNullList<ItemStack> itemStackList) {
|
||||
int count = itemStack.getMaxStackSize() / 2;
|
||||
if (itemStack.getCount() <= 8 && count > 8) {
|
||||
if (pullMatchingStack(itemStack, itemStackList, count)) {
|
||||
return;
|
||||
}
|
||||
if (FakePlayerCompatConfig.fakePlayerAutoReplenishmentFormShulkerBox) {
|
||||
pullMatchingStackFromShulkerBox(itemStack, itemStackList, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean pullMatchingStack(@NotNull ItemStack targetStack, NonNullList<ItemStack> itemStackList, int transferLimit) {
|
||||
for (ItemStack inventoryStack : itemStackList) {
|
||||
if (inventoryStack == ItemStack.EMPTY || inventoryStack == targetStack) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ItemStack.isSameItemSameComponents(inventoryStack, targetStack)) {
|
||||
if (inventoryStack.getCount() > transferLimit) {
|
||||
targetStack.setCount(targetStack.getCount() + transferLimit);
|
||||
inventoryStack.setCount(inventoryStack.getCount() - transferLimit);
|
||||
} else {
|
||||
targetStack.setCount(targetStack.getCount() + inventoryStack.getCount());
|
||||
inventoryStack.setCount(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean pullMatchingStackFromShulkerBox(@NotNull ItemStack targetStack, NonNullList<ItemStack> itemStackList, int transferLimit) {
|
||||
for (ItemStack containerStack : itemStackList) {
|
||||
if (containerStack == ItemStack.EMPTY || !containerStack.is(ItemTags.SHULKER_BOXES)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemContainerContents contents = containerStack.getOrDefault(DataComponents.CONTAINER, ItemContainerContents.EMPTY);
|
||||
NonNullList<ItemStack> shulkerItems = NonNullList.withSize(contents.items.size(), ItemStack.EMPTY);
|
||||
contents.copyInto(shulkerItems);
|
||||
|
||||
for (int slot = 0; slot < shulkerItems.size(); slot++) {
|
||||
ItemStack shulkerStack = shulkerItems.get(slot);
|
||||
if (shulkerStack.isEmpty() || !ItemStack.isSameItemSameComponents(shulkerStack, targetStack)) {
|
||||
for (ItemStack itemStack1 : itemStackList) {
|
||||
if (itemStack1 == ItemStack.EMPTY || itemStack1 == itemStack) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int moved = Math.min(Math.min(transferLimit, shulkerStack.getCount()), targetStack.getMaxStackSize() - targetStack.getCount());
|
||||
if (moved <= 0) {
|
||||
return false;
|
||||
if (ItemStack.isSameItemSameComponents(itemStack1, itemStack)) {
|
||||
if (itemStack1.getCount() > count) {
|
||||
itemStack.setCount(itemStack.getCount() + count);
|
||||
itemStack1.setCount(itemStack1.getCount() - count);
|
||||
} else {
|
||||
itemStack.setCount(itemStack.getCount() + itemStack1.getCount());
|
||||
itemStack1.setCount(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
targetStack.grow(moved);
|
||||
shulkerStack.shrink(moved);
|
||||
shulkerItems.set(slot, shulkerStack.isEmpty() ? ItemStack.EMPTY : shulkerStack);
|
||||
containerStack.set(DataComponents.CONTAINER, ItemContainerContents.fromItems(shulkerItems));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void replaceTool(@NotNull EquipmentSlot slot, @NotNull ServerBot bot) {
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ServerBot extends ServerPlayer {
|
||||
private static final int AUTO_FISH_ENTITY_DELAY = 20;
|
||||
|
||||
private final List<AbstractBotAction<?>> actions;
|
||||
private final Map<String, AbstractBotConfig<?, ?>> configs;
|
||||
private final Map<String, AbstractBotConfig<?>> configs;
|
||||
|
||||
public boolean resume = false;
|
||||
public BotCreateState createState;
|
||||
@@ -116,9 +116,10 @@ public class ServerBot extends ServerPlayer {
|
||||
this.gameMode = new ServerBotGameMode(this);
|
||||
|
||||
this.actions = new ArrayList<>();
|
||||
ImmutableMap.Builder<String, AbstractBotConfig<?, ?>> configBuilder = ImmutableMap.builder();
|
||||
for (AbstractBotConfig<?, ?> config : Configs.getConfigs()) {
|
||||
configBuilder.put(config.getName(), config.create().setBot(this));
|
||||
|
||||
ImmutableMap.Builder<String, AbstractBotConfig<?>> configBuilder = ImmutableMap.builder();
|
||||
for (Configs<?> config : Configs.getConfigs()) {
|
||||
configBuilder.put(config.getName(), config.create(this));
|
||||
}
|
||||
this.configs = configBuilder.build();
|
||||
|
||||
@@ -147,7 +148,7 @@ public class ServerBot extends ServerPlayer {
|
||||
this.joining = false;
|
||||
}
|
||||
|
||||
// this.resetOperationCountPerTick(); // Leaves - player operation limiter
|
||||
//this.resetOperationCountPerTick(); // Leaves - player operation limiter // Lophine
|
||||
this.wardenSpawnTracker.tick();
|
||||
if (this.invulnerableTime > 0) {
|
||||
this.invulnerableTime--;
|
||||
@@ -303,19 +304,6 @@ public class ServerBot extends ServerPlayer {
|
||||
this.stopUsingItem();
|
||||
teleportTransition.postTeleportTransition().onTransition(this);
|
||||
this.isChangingDimension = false;
|
||||
|
||||
// Lophine - We don't have this
|
||||
/* if (LeavesConfig.modify.netherPortalFix) {
|
||||
final ResourceKey<Level> fromDim = fromLevel.dimension();
|
||||
final ResourceKey<Level> toDim = level().dimension();
|
||||
if (!((fromDim != Level.OVERWORLD || toDim != Level.NETHER) && (fromDim != Level.NETHER || toDim != Level.OVERWORLD))) {
|
||||
BlockPos fromPortal = org.leavesmc.leaves.util.ReturnPortalManager.findPortalAt(this, fromDim, lastPos);
|
||||
BlockPos toPos = this.blockPosition();
|
||||
if (fromPortal != null) {
|
||||
org.leavesmc.leaves.util.ReturnPortalManager.storeReturnPortal(this, toDim, toPos, fromPortal);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (this.isBlocking()) {
|
||||
this.stopUsingItem();
|
||||
}
|
||||
@@ -348,10 +336,8 @@ public class ServerBot extends ServerPlayer {
|
||||
ItemStack item = this.getItemInHand(hand);
|
||||
|
||||
if (!item.isEmpty()) {
|
||||
if (FakePlayerCompatConfig.fakePlayerAutoReplenishment) {
|
||||
BotUtil.replenishment(item, getInventory().getNonEquipmentItems());
|
||||
}
|
||||
if (FakePlayerCompatConfig.fakePlayerAutoReplaceTool && BotUtil.isDamage(item, 10)) {
|
||||
BotUtil.replenishment(item, getInventory().getNonEquipmentItems());
|
||||
if (BotUtil.isDamage(item, 10)) {
|
||||
BotUtil.replaceTool(hand == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND, this);
|
||||
}
|
||||
}
|
||||
@@ -421,7 +407,7 @@ public class ServerBot extends ServerPlayer {
|
||||
|
||||
if (!this.configs.isEmpty()) {
|
||||
ValueOutput.TypedOutputList<CompoundTag> configNbt = nbt.list("configs", CompoundTag.CODEC);
|
||||
for (AbstractBotConfig<?, ?> config : this.configs.values()) {
|
||||
for (AbstractBotConfig<?> config : this.configs.values()) {
|
||||
configNbt.add(config.save(new CompoundTag()));
|
||||
}
|
||||
}
|
||||
@@ -432,31 +418,23 @@ public class ServerBot extends ServerPlayer {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
this.setShiftKeyDown(nbt.getBooleanOr("isShiftKeyDown", false));
|
||||
|
||||
CompoundTag createNbt = nbt.read("createStatus", CompoundTag.CODEC)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Missing bot createStatus"));
|
||||
String rawName = createNbt.getString("rawName")
|
||||
.orElseGet(() -> createNbt.getString("realName")
|
||||
.orElseThrow(() -> new IllegalArgumentException("Missing bot rawName")));
|
||||
String name = createNbt.getString("name")
|
||||
.orElseThrow(() -> new IllegalArgumentException("Missing bot name"));
|
||||
String skinName = createNbt.getStringOr("skinName", rawName);
|
||||
CompoundTag createNbt = nbt.read("createStatus", CompoundTag.CODEC).orElseThrow();
|
||||
BotCreateState.Builder createBuilder = BotCreateState
|
||||
.builder(rawName, null) // Convert from legacy version, consider to use ca.spottedleaf.dataconverter.minecraft.MCDataConverter instead for release version
|
||||
.name(name);
|
||||
.builder(createNbt.getString("rawName")
|
||||
.orElseGet(() -> createNbt.getString("realName")
|
||||
.orElseThrow()), null) // Convert from legacy version, consider to use ca.spottedleaf.dataconverter.minecraft.MCDataConverter instead for release version
|
||||
.name(createNbt.getString("name").orElseThrow());
|
||||
|
||||
String[] skin = null;
|
||||
if (createNbt.contains("skin")) {
|
||||
ListTag skinTag = createNbt.getList("skin")
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid bot skin list"));
|
||||
ListTag skinTag = createNbt.getList("skin").orElseThrow();
|
||||
skin = new String[skinTag.size()];
|
||||
for (int i = 0; i < skinTag.size(); i++) {
|
||||
final int skinIndex = i;
|
||||
skin[i] = skinTag.getString(i)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid bot skin entry at index " + skinIndex));
|
||||
skin[i] = skinTag.getString(i).orElseThrow();
|
||||
}
|
||||
}
|
||||
|
||||
createBuilder.skinName(skinName).skin(skin);
|
||||
createBuilder.skinName(createNbt.getString("skinName").orElseThrow()).skin(skin);
|
||||
createBuilder.createReason(BotCreateEvent.CreateReason.INTERNAL).creator(null);
|
||||
|
||||
this.createState = createBuilder.build();
|
||||
@@ -466,17 +444,11 @@ public class ServerBot extends ServerPlayer {
|
||||
if (FakePlayerCompatConfig.fakePlayerReloadAction && nbt.list("actions", CompoundTag.CODEC).isPresent()) {
|
||||
ValueInput.TypedInputList<CompoundTag> actionNbt = nbt.list("actions", CompoundTag.CODEC).orElseThrow();
|
||||
actionNbt.forEach(actionTag -> {
|
||||
try {
|
||||
String actionName = actionTag.getString("actionName")
|
||||
.orElseThrow(() -> new IllegalArgumentException("Missing actionName"));
|
||||
AbstractBotAction<?> action = Actions.getForName(actionName);
|
||||
if (action != null) {
|
||||
AbstractBotAction<?> newAction = action.create();
|
||||
newAction.load(actionTag);
|
||||
this.actions.add(newAction);
|
||||
}
|
||||
} catch (RuntimeException exception) {
|
||||
LophineLogger.LOGGER.warn("Skipped invalid saved action for bot {}", this.getScoreboardName(), exception);
|
||||
Actions<?> holder = Actions.getByName(actionTag.getString("actionName").orElseThrow());
|
||||
if (holder != null) {
|
||||
AbstractBotAction<?> newAction = holder.create();
|
||||
newAction.load(actionTag);
|
||||
this.actions.add(newAction);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -484,17 +456,12 @@ public class ServerBot extends ServerPlayer {
|
||||
if (nbt.list("configs", CompoundTag.CODEC).isPresent()) {
|
||||
ValueInput.TypedInputList<CompoundTag> configNbt = nbt.list("configs", CompoundTag.CODEC).orElseThrow();
|
||||
for (CompoundTag configTag : configNbt) {
|
||||
try {
|
||||
String configName = configTag.getString("configName")
|
||||
.orElseThrow(() -> new IllegalArgumentException("Missing configName"));
|
||||
AbstractBotConfig<?, ?> config = Configs.getConfig(configName);
|
||||
if (config != null) {
|
||||
config.setBot(this);
|
||||
config.load(configTag);
|
||||
}
|
||||
} catch (RuntimeException exception) {
|
||||
LophineLogger.LOGGER.warn("Skipped invalid saved config for bot {}", this.getScoreboardName(), exception);
|
||||
String key = configTag.getString("configName").orElseThrow();
|
||||
if (!this.configs.containsKey(key)) {
|
||||
LophineLogger.LOGGER.warn("Trying to load a unknown config \"{}\", discard.", key);
|
||||
continue;
|
||||
}
|
||||
this.configs.get(key).load(configTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,7 +490,7 @@ public class ServerBot extends ServerPlayer {
|
||||
|
||||
playerConnection.send(this.getAddEntityPacket(entityTracker.serverEntity));
|
||||
if (login) {
|
||||
Bukkit.getGlobalRegionScheduler().runDelayed(MinecraftInternalPlugin.INSTANCE, (task) -> playerConnection.send(new ClientboundRotateHeadPacket(this, (byte) ((getYRot() * 256f) / 360f))), 10);
|
||||
Bukkit.getGlobalRegionScheduler().runDelayed(MinecraftInternalPlugin.INSTANCE, (_) -> playerConnection.send(new ClientboundRotateHeadPacket(this, (byte) ((getYRot() * 256f) / 360f))), 10);
|
||||
} else {
|
||||
playerConnection.send(new ClientboundRotateHeadPacket(this, (byte) ((getYRot() * 256f) / 360f)));
|
||||
}
|
||||
@@ -573,6 +540,11 @@ public class ServerBot extends ServerPlayer {
|
||||
getServer().getBotList().removeBot(this, BotRemoveEvent.RemoveReason.DEATH, null, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getBaseExperienceReward(@NotNull ServerLevel level) {
|
||||
return this.isSpectator() ? 0 : Math.min(this.experienceLevel * 7, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startRiding(@NotNull Entity vehicle, boolean force, boolean sendGameEvent) {
|
||||
if (super.startRiding(vehicle, force, sendGameEvent)) {
|
||||
@@ -764,15 +736,15 @@ public class ServerBot extends ServerPlayer {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T, E extends AbstractBotConfig<T, E>> AbstractBotConfig<T, E> getConfig(@NotNull AbstractBotConfig<T, E> config) {
|
||||
return (AbstractBotConfig<T, E>) Objects.requireNonNull(this.configs.get(config.getName()));
|
||||
public <T> AbstractBotConfig<T> getConfig(@NotNull Configs<? extends AbstractBotConfig<T>> config) {
|
||||
return (AbstractBotConfig<T>) Objects.requireNonNull(this.configs.get(config.getName()));
|
||||
}
|
||||
|
||||
public Collection<AbstractBotConfig<?, ?>> getAllConfigs() {
|
||||
public Collection<AbstractBotConfig<?>> getAllConfigs() {
|
||||
return configs.values();
|
||||
}
|
||||
|
||||
public <T, E extends AbstractBotConfig<T, E>> T getConfigValue(@NotNull AbstractBotConfig<T, E> config) {
|
||||
public <T> T getConfigValue(@NotNull Configs<? extends AbstractBotConfig<T>> config) {
|
||||
return this.getConfig(config).getValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ServerBotGameMode extends ServerPlayerGameMode {
|
||||
this.level.sendBlockUpdated(pos, blockState, blockState, 3);
|
||||
return false;
|
||||
} else {
|
||||
BlockState blockState1 = /*isNoBlockUpdate() ? blockState : */block.playerWillDestroy(this.level, pos, blockState, this.player); // Leaves - no block update
|
||||
BlockState blockState1 = /*isNoBlockUpdate() ? blockState : */block.playerWillDestroy(this.level, pos, blockState, this.player); // Leaves - no block update // Lophine
|
||||
boolean flag = this.level.removeBlock(pos, false);
|
||||
if (flag) {
|
||||
block.destroy(this.level, pos, blockState1);
|
||||
|
||||
@@ -56,6 +56,11 @@ public class ServerBotPacketListenerImpl extends ServerGamePacketListenerImpl {
|
||||
public void tick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasClientLoaded() {
|
||||
return true; // Don't kick me out!
|
||||
}
|
||||
|
||||
public static class BotConnection extends Connection {
|
||||
|
||||
public BotConnection() {
|
||||
|
||||
@@ -17,49 +17,54 @@
|
||||
|
||||
package org.leavesmc.leaves.bot.agent;
|
||||
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import fun.bm.lophine.bot.BotActionGuiContainer;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.command.CommandContext;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Actions {
|
||||
public class Actions<T extends AbstractBotAction<T>> {
|
||||
|
||||
private static final Map<String, AbstractBotAction<?>> actionsByName = new HashMap<>();
|
||||
private static final Map<Class<?>, AbstractBotAction<?>> actionsByClass = new HashMap<>();
|
||||
private static final Map<String, Actions<? extends AbstractBotAction<?>>> actionsByName = new HashMap<>();
|
||||
private static final Map<Class<? extends BotAction<?>>, Actions<? extends AbstractBotAction<?>>> actionsByClass = new HashMap<>();
|
||||
|
||||
static {
|
||||
register(new ServerAttackAction(), AttackAction.class);
|
||||
register(new ServerBreakBlockAction(), BreakBlockAction.class);
|
||||
register(new ServerDropAction(), DropAction.class);
|
||||
register(new ServerJumpAction(), JumpAction.class);
|
||||
register(new ServerSneakAction(), SneakAction.class);
|
||||
register(new ServerUseItemAutoAction(), UseItemAutoAction.class);
|
||||
register(new ServerUseItemAction(), UseItemAction.class);
|
||||
register(new ServerUseItemOnAction(), UseItemOnAction.class);
|
||||
register(new ServerUseItemToAction(), UseItemToAction.class);
|
||||
register(new ServerUseItemOffhandAction(), UseItemOffhandAction.class);
|
||||
register(new ServerUseItemOnOffhandAction(), UseItemOnOffhandAction.class);
|
||||
register(new ServerUseItemToOffhandAction(), UseItemToOffhandAction.class);
|
||||
register(new ServerLookAction(), LookAction.class);
|
||||
register(new ServerFishAction(), FishAction.class);
|
||||
register(new ServerSwimAction(), SwimAction.class);
|
||||
register(new ServerRotationAction(), RotationAction.class);
|
||||
register(new ServerMoveAction(), MoveAction.class);
|
||||
register(new ServerMountAction(), MountAction.class);
|
||||
register(new ServerSwapAction(), SwapAction.class);
|
||||
register(AttackAction.class, ServerAttackAction::new);
|
||||
register(BreakBlockAction.class, ServerBreakBlockAction::new);
|
||||
register(DropAction.class, ServerDropAction::new);
|
||||
register(JumpAction.class, ServerJumpAction::new);
|
||||
register(SneakAction.class, ServerSneakAction::new);
|
||||
register(UseItemAutoAction.class, ServerUseItemAutoAction::new);
|
||||
register(UseItemAction.class, ServerUseItemAction::new);
|
||||
register(UseItemOnAction.class, ServerUseItemOnAction::new);
|
||||
register(UseItemToAction.class, ServerUseItemToAction::new);
|
||||
register(UseItemOffhandAction.class, ServerUseItemOffhandAction::new);
|
||||
register(UseItemOnOffhandAction.class, ServerUseItemOnOffhandAction::new);
|
||||
register(UseItemToOffhandAction.class, ServerUseItemToOffhandAction::new);
|
||||
register(LookAction.class, ServerLookAction::new);
|
||||
register(FishAction.class, ServerFishAction::new);
|
||||
register(SwimAction.class, ServerSwimAction::new);
|
||||
register(RotationAction.class, ServerRotationAction::new);
|
||||
register(MoveAction.class, ServerMoveAction::new);
|
||||
register(MountAction.class, ServerMountAction::new);
|
||||
register(SwapAction.class, ServerSwapAction::new);
|
||||
}
|
||||
|
||||
public static boolean register(@NotNull AbstractBotAction<?> action, Class<?> type) {
|
||||
public static <T extends AbstractBotAction<T>> boolean register(Class<? extends BotAction<?>> apiType, @NotNull Supplier<T> creator) {
|
||||
AbstractBotAction<T> action = creator.get();
|
||||
if (!actionsByName.containsKey(action.getName())) {
|
||||
actionsByName.put(action.getName(), action);
|
||||
actionsByClass.put(type, action);
|
||||
Actions<?> actions = new Actions<>(creator.get().getName(), apiType, creator);
|
||||
actionsByName.put(action.getName(), actions);
|
||||
actionsByClass.put(apiType, actions);
|
||||
if (action.getGuiData() != null) {
|
||||
BotActionGuiContainer.registerGuiRootNode(action.getGuiData());
|
||||
}
|
||||
@@ -68,14 +73,37 @@ public class Actions {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean register(@NotNull AbstractBotAction<?> action) {
|
||||
return register(action, action.getClass());
|
||||
private final String name;
|
||||
private final Class<?> apiType;
|
||||
private final Supplier<T> creator;
|
||||
|
||||
private Actions(String name, Class<? extends BotAction<?>> apiType, Supplier<T> creator) {
|
||||
this.name = name;
|
||||
this.apiType = apiType;
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Class<?> getType() {
|
||||
return apiType;
|
||||
}
|
||||
|
||||
public T create() {
|
||||
return creator.get();
|
||||
}
|
||||
|
||||
public T createByCommand(CommandContext context) throws CommandSyntaxException {
|
||||
T action = create();
|
||||
action.loadCommand(context);
|
||||
return action;
|
||||
}
|
||||
|
||||
public static boolean unregister(@NotNull String name) {
|
||||
AbstractBotAction<?> action = actionsByName.remove(name);
|
||||
Actions<?> action = actionsByName.remove(name);
|
||||
BotActionGuiContainer.unregisterGuiRootNode(name);
|
||||
|
||||
if (action != null) {
|
||||
actionsByClass.remove(action.getClass());
|
||||
return true;
|
||||
@@ -85,7 +113,7 @@ public class Actions {
|
||||
|
||||
@NotNull
|
||||
@Contract(pure = true)
|
||||
public static Collection<AbstractBotAction<?>> getAll() {
|
||||
public static Collection<Actions<? extends AbstractBotAction<?>>> getAll() {
|
||||
return actionsByName.values();
|
||||
}
|
||||
|
||||
@@ -95,12 +123,12 @@ public class Actions {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AbstractBotAction<?> getForName(String name) {
|
||||
public static Actions<?> getByName(String name) {
|
||||
return actionsByName.get(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AbstractBotAction<?> getForClass(@NotNull Class<?> type) {
|
||||
public static Actions<?> getByClass(@NotNull Class<?> type) {
|
||||
return actionsByClass.get(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,41 +19,76 @@ package org.leavesmc.leaves.bot.agent;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.configs.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@SuppressWarnings({"unused"})
|
||||
public class Configs {
|
||||
private static final Map<Class<?>, AbstractBotConfig<?, ?>> configs = new HashMap<>();
|
||||
public class Configs<E extends AbstractBotConfig<?>> {
|
||||
|
||||
public static final SkipSleepConfig SKIP_SLEEP = register(new SkipSleepConfig());
|
||||
public static final AlwaysSendDataConfig ALWAYS_SEND_DATA = register(new AlwaysSendDataConfig());
|
||||
public static final SpawnPhantomConfig SPAWN_PHANTOM = register(new SpawnPhantomConfig());
|
||||
public static final SimulationDistanceConfig SIMULATION_DISTANCE = register(new SimulationDistanceConfig());
|
||||
public static final TickTypeConfig TICK_TYPE = register(new TickTypeConfig());
|
||||
public static final LocatorBarConfig ENABLE_LOCATOR_BAR = register(new LocatorBarConfig());
|
||||
private static final Map<String, Configs<? extends AbstractBotConfig<?>>> configs = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
public static AbstractBotConfig<?, ?> getConfig(String name) {
|
||||
public static final Configs<SkipSleepConfig> SKIP_SLEEP = register(SkipSleepConfig.class, SkipSleepConfig::new);
|
||||
public static final Configs<AlwaysSendDataConfig> ALWAYS_SEND_DATA = register(AlwaysSendDataConfig.class, AlwaysSendDataConfig::new);
|
||||
public static final Configs<SpawnPhantomConfig> SPAWN_PHANTOM = register(SpawnPhantomConfig.class, SpawnPhantomConfig::new);
|
||||
public static final Configs<SimulationDistanceConfig> SIMULATION_DISTANCE = register(SimulationDistanceConfig.class, SimulationDistanceConfig::new);
|
||||
public static final Configs<TickTypeConfig> TICK_TYPE = register(TickTypeConfig.class, TickTypeConfig::new);
|
||||
public static final Configs<LocatorBarConfig> ENABLE_LOCATOR_BAR = register(LocatorBarConfig.class, LocatorBarConfig::new);
|
||||
|
||||
private final Class<? extends AbstractBotConfig<?>> configClass;
|
||||
private final Supplier<? extends AbstractBotConfig<?>> configCreator;
|
||||
private final String name;
|
||||
|
||||
private Configs(Class<? extends AbstractBotConfig<?>> configClass, Supplier<? extends AbstractBotConfig<?>> configCreator, String name) {
|
||||
this.configClass = configClass;
|
||||
this.configCreator = configCreator;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public E create() {
|
||||
return (E) configCreator.get();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public E create(ServerBot bot) {
|
||||
E config = (E) configCreator.get();
|
||||
config.setBot(bot);
|
||||
return config;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Optional<Configs<?>> getConfig(String name) {
|
||||
return configs.values().stream()
|
||||
.filter(config -> config.getName().equals(name))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
.filter(config -> config.name.equals(name))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Optional<Configs<?>> getConfig(Class<? extends AbstractBotConfig<T>> configClass) {
|
||||
return configs.values().stream()
|
||||
.filter(config -> config.configClass.equals(configClass))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Contract(pure = true)
|
||||
public static Collection<AbstractBotConfig<?, ?>> getConfigs() {
|
||||
public static Collection<Configs<? extends AbstractBotConfig<?>>> getConfigs() {
|
||||
return configs.values();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T, E extends AbstractBotConfig<T, E>> @NotNull E register(AbstractBotConfig<T, E> instance) {
|
||||
configs.put(instance.getClass(), instance);
|
||||
return (E) instance;
|
||||
private static <T, E extends AbstractBotConfig<T>> @NotNull Configs<E> register(Class<? extends AbstractBotConfig<T>> configClass, Supplier<AbstractBotConfig<T>> configCreator) {
|
||||
String name = configCreator.get().getName();
|
||||
Configs<E> config = new Configs<>(configClass, configCreator, name);
|
||||
configs.put(name, config);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* This file is part of Leaves (https://github.com/LeavesMC/Leaves)
|
||||
*
|
||||
* Leaves is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Leaves is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Leaves. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.leavesmc.leaves.bot.agent;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
+3
-10
@@ -30,20 +30,19 @@ import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.ExtraData;
|
||||
import org.leavesmc.leaves.command.CommandContext;
|
||||
import org.leavesmc.leaves.command.WrappedArgument;
|
||||
import org.leavesmc.leaves.entity.bot.actions.CraftBotAction;
|
||||
import org.leavesmc.leaves.event.bot.BotActionExecuteEvent;
|
||||
import org.leavesmc.leaves.event.bot.BotActionStopEvent;
|
||||
import org.leavesmc.leaves.util.UpdateSuppressionException;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public abstract class AbstractBotAction<E extends AbstractBotAction<E>> {
|
||||
|
||||
private final String name;
|
||||
private final Map<Integer, List<Pair<String, WrappedArgument<?>>>> arguments;
|
||||
private final Supplier<E> creator;
|
||||
private UUID uuid;
|
||||
private int currentFork = 0;
|
||||
|
||||
@@ -61,10 +60,9 @@ public abstract class AbstractBotAction<E extends AbstractBotAction<E>> {
|
||||
|
||||
protected GuiRootNode guiData;
|
||||
|
||||
public AbstractBotAction(String name, Supplier<E> creator) {
|
||||
public AbstractBotAction(String name) {
|
||||
this.name = name;
|
||||
this.uuid = UUID.randomUUID();
|
||||
this.creator = creator;
|
||||
this.arguments = new HashMap<>();
|
||||
|
||||
this.cancel = false;
|
||||
@@ -75,7 +73,7 @@ public abstract class AbstractBotAction<E extends AbstractBotAction<E>> {
|
||||
|
||||
public abstract boolean doTick(@NotNull ServerBot bot);
|
||||
|
||||
public abstract Object asCraft();
|
||||
public abstract CraftBotAction<?, E> asCraft();
|
||||
|
||||
public String getActionDataString() {
|
||||
return getActionDataString(new ExtraData(new ArrayList<>()));
|
||||
@@ -201,11 +199,6 @@ public abstract class AbstractBotAction<E extends AbstractBotAction<E>> {
|
||||
public void loadCommand(@NotNull CommandContext context) throws CommandSyntaxException {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public E create() {
|
||||
return this.creator.get();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
+2
-4
@@ -17,11 +17,9 @@
|
||||
|
||||
package org.leavesmc.leaves.bot.agent.actions;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class AbstractStateBotAction<E extends AbstractStateBotAction<E>> extends AbstractBotAction<E> {
|
||||
public AbstractStateBotAction(String name, Supplier<E> creator) {
|
||||
super(name, creator);
|
||||
public AbstractStateBotAction(String name) {
|
||||
super(name);
|
||||
this.setDoNumber(-1);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -24,15 +24,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.agent.ExtraData;
|
||||
import org.leavesmc.leaves.command.CommandContext;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||
import static org.leavesmc.leaves.command.ArgumentNode.ArgumentSuggestions.strings;
|
||||
|
||||
public abstract class AbstractTimerBotAction<E extends AbstractTimerBotAction<E>> extends AbstractBotAction<E> {
|
||||
|
||||
public AbstractTimerBotAction(String name, Supplier<E> creator, GuiRootNode guiData) {
|
||||
super(name, creator);
|
||||
public AbstractTimerBotAction(String name, GuiRootNode guiData) {
|
||||
super(name);
|
||||
String[] delaySuggestions = {"0", "5", "10", "20"};
|
||||
String[] intervalSuggestions = {"20", "0", "5", "10"};
|
||||
this.addArgument("delay", integer(0)).suggests(strings(delaySuggestions)).setOptional(true);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user