├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── build-1204.yml ├── .gitignore ├── LICENSE.md ├── README.md ├── ROADMAP.md ├── build-data ├── dev-imports.txt └── reobf-mappings-patch.tiny ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── logo.webp ├── patches ├── api │ ├── 0001-Mirai-Configuration.patch │ ├── 0002-Disable-reload-command.patch │ ├── 0003-Add-last-tick-time-API.patch │ ├── 0004-Optimize-Spigot-event-bus.patch │ ├── 0005-Skip-event-if-no-listeners.patch │ ├── 0006-Lobotomize-stuck-villagers.patch │ ├── 0007-Set-multiple-Team-settings-at-once.patch │ ├── 0008-Smooth-Teleports.patch │ └── 0009-Mirai-Add-Higher-Java-Versions-Support-for-SIMD.patch └── server │ ├── 0001-Mirai-Branding-Changes.patch │ ├── 0002-Mirai-Configuration.patch │ ├── 0003-Time-Utilities.patch │ ├── 0004-Reduce-constants-allocations.patch │ ├── 0005-lithium-fast-util.patch │ ├── 0006-lithium-HashedReferenceList.patch │ ├── 0007-lithium-CompactSineLUT.patch │ ├── 0008-lithium-fast-retrieval.patch │ ├── 0009-Add-last-tick-time-API.patch │ ├── 0010-Add-config-for-logging-login-location.patch │ ├── 0011-Global-Eula-file.patch │ ├── 0012-Stop-wasting-resources-on-JsonList-get.patch │ ├── 0013-Configurable-max-bees-in-hive.patch │ ├── 0014-Remove-TickTask.patch │ ├── 0015-Make-a-field-final.patch │ ├── 0016-Don-t-create-new-random-instance.patch │ ├── 0017-Use-LinkedBlockingDeque-in-IAsyncTaskHandler.patch │ ├── 0018-Use-MCUtil.asyncExecutor-for-MAIN_WORKER_EXECUTOR-in.patch │ ├── 0019-Remove-Spigot-tick-limiter.patch │ ├── 0020-Configurable-flight-checks.patch │ ├── 0021-Don-t-save-Fireworks.patch │ ├── 0022-Do-not-drop-items-from-Give-command.patch │ ├── 0023-Do-not-process-chat-commands-before-player-has-joine.patch │ ├── 0024-Fix-cow-rotation-when-shearing-mooshroom.patch │ ├── 0025-End-gateway-should-check-if-entity-can-use-portal.patch │ ├── 0026-Arrows-should-not-reset-despawn-counter.patch │ ├── 0027-Fix-rotating-UP-DOWN-CW-and-CCW.patch │ ├── 0028-Fix-outdated-server-showing-in-ping-before-server-fu.patch │ ├── 0029-Dont-send-useless-entity-packets.patch │ ├── 0030-Skip-events-if-there-s-no-listeners.patch │ ├── 0031-Alternative-Keepalive-Handling.patch │ ├── 0032-Logger-settings-suppressing-pointless-logs.patch │ ├── 0033-Add-5-second-tps-average-in-tps.patch │ ├── 0034-Fix-stuck-in-portals.patch │ ├── 0035-Entities-can-use-portals-configuration.patch │ ├── 0036-lithium-replace-AI-goal-set-with-optimized-collectio.patch │ ├── 0037-vmp-skip-entity-move-if-movement-is-zero.patch │ ├── 0038-Don-t-send-fire-packets-if-player-has-Fire-Resistanc.patch │ ├── 0039-lithium-cached-hashcode.patch │ ├── 0040-lithium-store-gamerules-in-fastutil-hashmap.patch │ ├── 0041-carpetfixes-BiomeAccess-prediction.patch │ ├── 0042-Configurable-enchantment-table-book-animation-tick.patch │ ├── 0043-Skip-cloning-loot-parameters.patch │ ├── 0044-lithium-precompute-shape-arrays.patch │ ├── 0045-MC-121706-Fix-mobs-not-looking-up-and-down-when-stra.patch │ ├── 0046-vmp-spawn_density_cap.patch │ ├── 0047-lithium-entity.fast_elytra_check.patch │ ├── 0048-lithium-entity.fast_hand_swing.patch │ ├── 0049-c2me-opts-math.patch │ ├── 0050-lithium-entity.fast_powder_snow_check.patch │ ├── 0051-lithium-collections.attributes.patch │ ├── 0052-lithium-collections.entity_by_type.patch │ ├── 0053-lithium-collections.entity_filtering.patch │ ├── 0054-lithium-chunk.serialization.patch │ ├── 0055-Configurable-criterion-triggers.patch │ ├── 0056-Set-item-stuck-sleep-to-15-ticks.patch │ ├── 0057-Smarter-statistics-ticking.patch │ ├── 0058-some-entity-micro-opts.patch │ ├── 0059-Fast-speed-check.patch │ ├── 0060-lithium-cache-iterate-outwards.patch │ ├── 0061-lithium-ai.raid.patch │ ├── 0062-lithium-block.moving_block_shapes.patch │ ├── 0063-lithium-gen.patch │ ├── 0064-vmp-use-linked-map-for-entity-trackers-for-faster-it.patch │ ├── 0065-c2me-reduce_allocs.patch │ ├── 0066-lithium-ai.sensor.secondary_poi.patch │ ├── 0067-Optimize-default-values-for-configs.patch │ ├── 0068-Fix-hunger-saturation-depleting-on-peaceful.patch │ ├── 0069-Fix-mobs-attacking-themselves.patch │ ├── 0070-Fix-brewing-stands-resetting-their-brewTime-when-bei.patch │ ├── 0071-lithium-world.tick_scheduler.patch │ ├── 0072-Save-Json-list-asynchronously.patch │ ├── 0073-Swaps-the-predicate-order-of-collision.patch │ ├── 0074-Cache-block-break-animation-packet.patch │ ├── 0075-Use-more-fastutil-data-structures.patch │ ├── 0076-Optimize-Math.round-and-Math.hypot-functions.patch │ ├── 0077-Faster-Sheep.getOffspringColor.patch │ ├── 0078-Pre-compute-VarLong-sizes.patch │ ├── 0079-Optimize-VarLong-write.patch │ ├── 0080-reduce-work-done-by-game-event-system.patch │ ├── 0081-reduce-sensor-work.patch │ ├── 0082-Configurable-chat-message-signatures.patch │ ├── 0083-Fix-MC-238526.patch │ ├── 0084-Lobotomize-stuck-villagers.patch │ ├── 0085-Set-multiple-Team-settings-at-once.patch │ ├── 0086-Smooth-Teleports.patch │ ├── 0087-Don-t-double-save-the-json-lists.patch │ ├── 0088-Don-t-wander-into-non-ticking-chunks.patch │ ├── 0089-Optimize-CraftServer.getWorld-UUID.patch │ ├── 0090-Configurable-mobs-from-spawners-picking-up-loot.patch │ ├── 0091-Async-Pathfinding.patch │ ├── 0092-Multithreaded-Tracker.patch │ ├── 0093-Sync-event-calls-on-async-threads.patch │ ├── 0094-Add-Higher-Java-Versions-Support-for-SIMD.patch │ └── 0095-LinearPurpur-Add-Linear-region-format.patch └── settings.gradle.kts /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.java] 2 | charset=utf-8 3 | end_of_line=lf 4 | insert_final_newline=true 5 | indent_style=space 6 | indent_size=4 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.sh text eol=lf 4 | gradlew text eol=lf 5 | *.bat text eol=crlf 6 | 7 | *.jar binary 8 | -------------------------------------------------------------------------------- /.github/workflows/build-1204.yml: -------------------------------------------------------------------------------- 1 | name: Build Mirai 1.20.4 2 | 3 | on: push 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout Git Repository 10 | uses: actions/checkout@main 11 | - name: Validate Gradle Wrapper 12 | uses: gradle/wrapper-validation-action@main 13 | - name: Set up JDK (GraalVM) 14 | uses: graalvm/setup-graalvm@main 15 | with: 16 | java-version: 17 17 | github-token: ${{ secrets.GITHUB_TOKEN }} 18 | - name: Pull Gradle Cache 19 | uses: actions/cache@main 20 | id: gradle-cache 21 | with: 22 | path: ~/.gradle 23 | key: ${{ runner.os }}-maven-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}-java-${{ matrix.java }} 24 | - name: Configure Git 25 | run: | 26 | git config --global user.email "no-reply@github.com" 27 | git config --global user.name "Github Actions" 28 | chmod +x gradlew 29 | - name: Patch 30 | run: | 31 | ./gradlew -Dorg.gradle.jvmargs="-Dfile.encoding=UTF-8 -Dgraal.CompilerConfiguration=community -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true -Dgraal.SpeculativeGuardMovement=true -Dgraal.WriteableCodeCache=true --add-modules jdk.incubator.vector" applyPatches --stacktrace --no-daemon 32 | - name: Build 33 | run: | 34 | ./gradlew -Dorg.gradle.jvmargs="-Dfile.encoding=UTF-8 -Dgraal.CompilerConfiguration=community -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true -Dgraal.SpeculativeGuardMovement=true -Dgraal.WriteableCodeCache=true --add-modules jdk.incubator.vector" createReobfPaperclipJar --stacktrace --no-daemon 35 | - name: Rename Paperclip Jar 36 | run: mv build/libs/Mirai-paperclip-1.20.4-R0.1-SNAPSHOT-reobf.jar ./mirai-1.20.4.jar 37 | - name: Release 38 | if: github.ref_name == 'ver/1.20.4' 39 | uses: marvinpinto/action-automatic-releases@master 40 | with: 41 | title: "Mirai-1.20.4" 42 | automatic_release_tag: "1.20.4" 43 | repo_token: "${{ secrets.GITHUB_TOKEN }}" 44 | files: ./mirai-1.20.4.jar 45 | prerelease: false 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac filesystem dust 2 | .DS_Store/ 3 | .DS_Store 4 | 5 | # Linux temp files 6 | *~ 7 | 8 | # IntelliJ 9 | *.iml 10 | .idea 11 | 12 | # Gradle 13 | !gradle/wrapper/gradle-wrapper.jar 14 | .gradle 15 | build 16 | 17 | # Mirai 18 | build-data 19 | run 20 | 21 | mirai-server 22 | mirai-api 23 | paper-api-generator 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Mirai Face 2 |
3 |

Mirai

4 |

A powerful Minecraft Server Software coming from the future

5 |

❗If you are looking for alternatives of Mirai, Gale or Leaf maybe is a good choice.❗

6 |
This project is experimental under development, its usage in production environment is discouraged if you are not ready to face possible bugs.
7 | 8 | [![Build status](https://img.shields.io/github/actions/workflow/status/Dreeam-qwq/Mirai/build-1204.yml?branch=ver%2F1.20.4&style=for-the-badge)](https://github.com/Dreeam-qwq/Mirai/releases) 9 | [![Discord](https://img.shields.io/discord/1145991395388162119?color=5865F2&label=discord&style=for-the-badge)](https://discord.gg/gfgAwdSEuM) 10 |
11 | 12 | ## Features 13 | 14 | - **Fork of [Pufferfish](https://github.com/pufferfish-gg/Pufferfish)** for the best performance. 15 | - **Contains [Lithium](https://github.com/CaffeineMC/lithium-fabric) patches** which respect Vanilla parity. 16 | - **Efficient redstone** relying on [Alternate Current](https://github.com/SpaceWalkerRS/alternate-current), up to 4 times faster than Eigencraft's algorithm. 17 | - **(WIP) Implements [C2ME](https://github.com/RelativityMC/C2ME-fabric)** to improve chunk generation speed, I/O and loading. 18 | - **Async Pathfinding and Multithreaded Entity Tracker** from [Petal](https://github.com/Bloom-host/Petal) which drastically reduce entity load. 19 | - **Configurable chat report system** to disallow players from reporting others' messages to Mojang. 20 | - **Reduced bandwidth consumption and CPU usage** from avoiding sending useless packets in certain situations. 21 | - **Pre-tweaked** configuration files to reach optimal performance with minimal impact on normal behaviors. 22 | - **Login location** hiding feature, which adds another security layer in the logs for admins. 23 | - **Bugfixes** for several Minecraft issues. 24 | - **Faster process** for Vanilla methods. 25 | - **Plugin compatibility** with Spigot & Paper plugins. 26 | 27 | ## Downloads 28 | The latest successful build can be downloaded here: 29 | 30 | [mirai-1.20.4.jar](https://github.com/Dreeam-qwq/Mirai/releases/tag/1.20.4) 31 | 32 | **Please note Java >= 17 is required, and Java >=19 is recommended.** 33 | 34 | You can also clone this repository and build it yourself. 35 | If you are interested in making a fork, check out this template [there](https://github.com/PaperMC/paperweight-examples)! 36 | 37 | ## Building 38 | In order to distribute and use this server software, you need a paperclip file: 39 | 40 | ```bash 41 | ./gradlew applyPatches && ./gradlew createReobfPaperclipJar 42 | ``` 43 | 44 | ## License 45 | Patches are licensed under GPL-3.0. 46 | All other files are licensed under MIT. 47 | 48 | ## bStats 49 | [![](https://bstats.org/signatures/server-implementation/mirai.svg)](https://bstats.org/plugin/server-implementation/Mirai/18351) 50 | 51 | Made with on Earth. 52 | -------------------------------------------------------------------------------- /ROADMAP.md: -------------------------------------------------------------------------------- 1 | # Roadmap 2 | 3 | `plan`, I maybe will to do this, maybe not. 4 | 5 | ## 0x0 6 | 7 | In general, keeping update Minecraft version of mirai 8 | 9 | replace some patches with Gale's version 10 | 11 | ## 0x1 12 | 13 | Keeping update the code of Lithium patches from upstream. 14 | 15 | Fully port c2me from the upstream. 16 | 17 | Add some optimization patches from other forks. 18 | 19 | ## C2ME 20 | 21 | | C2ME | Mirai | Status | 22 | |--------------------------------------|-------|-------------------| 23 | | c2me-base | 24 | | c2me-client-uncapvd | | Clientside | 25 | | c2me-fixes-chunkio-threading-issues | 26 | | c2me-fixes-general-threading-issues | 27 | | c2me-fixes-worldgen-threading-issues | 28 | | c2me-fixes-worldgen-vanilla-bugs | 29 | | c2me-natives-opts | | Empty in upstream | 30 | | c2me-notickvd | | NO | 31 | | c2me-opts-allocs | 1 | 32 | | c2me-opts-chunk-access | 33 | | c2me-opts-chunkio | 34 | | c2me-opts-math | 1 | 35 | | c2me-opts-scheduling | 36 | | c2me-opts-worldgen-biome-cache | 37 | | c2me-opts-worldgen-general | 38 | | c2me-opts-worldgen-vanilla | 39 | | c2me-rewrites-chunkio | 40 | | c2me-server-utils | 41 | | c2me-threading-chunkio | 42 | | c2me-threading-lighting | 43 | | c2me-threading-scheduling | 44 | | c2me-threading-worldgen | 45 | 46 | 47 | ## Lithium 48 | 49 | | Lithium | Mirai | Status | 50 | |-----------------|-------|-------------------| 51 | | ai | 52 | | alloc | 53 | | block | 54 | | cached_hashcode | 55 | | client | 56 | | compat | 57 | | config | 58 | | chunk | 59 | | collections | 60 | | entity | 61 | | gen | 62 | | item | 63 | | math | 64 | | profiler | 65 | | hopper | 66 | | reflection | 67 | | shapes | 68 | | state | 69 | | util | 70 | | world | 71 | 72 | ## VMP 73 | 74 | ## Slumber 75 | 76 | ## FerriteCore 77 | 78 | ## CarpetFixes -------------------------------------------------------------------------------- /build-data/dev-imports.txt: -------------------------------------------------------------------------------- 1 | # You can use this file to import files from minecraft libraries into the project 2 | # format: 3 | # 4 | # both fully qualified and a file based syntax are accepted for : 5 | # authlib com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java 6 | # datafixerupper com.mojang.datafixers.DataFixerBuilder 7 | # datafixerupper com/mojang/datafixers/util/Either.java 8 | # To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId: 9 | # minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter 10 | # minecraft net/minecraft/world/level/entity/LevelEntityGetter.java -------------------------------------------------------------------------------- /build-data/reobf-mappings-patch.tiny: -------------------------------------------------------------------------------- 1 | # We would like for paperweight to generate 100% perfect reobf mappings (and deobf mappings for that matter). 2 | # But unfortunately it's not quite there yet - and it may be some time before that happens. Generating perfect mappings 3 | # from Spigot's mappings is extremely difficult due to Spigot's bad tooling and bad mappings. To add insult to injury 4 | # we remap Spigot's _source code_ which is a lot more complex and error-prone than bytecode remapping. So with all that 5 | # said, this file exists to help fill in the gap. 6 | # 7 | # We will continue to improve paperweight and will work on fixing these issues so they don't come up in the first place, 8 | # but these mappings exist to prevent these issues from holding everything else in Paper up while we work through all 9 | # of these issues. Due to the complex nature of mappings generation and the debugging difficulty involved it may take 10 | # a significant amount of time for us to track down every possible issue, so this file will likely be around and in 11 | # use - at least in some capacity - for a long time. 12 | # 13 | # If you are adding mappings patches which are correcting for issues in paperweight's reobf mappings generation, 14 | # unrelated to any changes in your patches, we ask that you PR the mapping to Paper so more users can benefit rather 15 | # than keep the fix for your own fork. If the mappings patch is there to correct reobf for changes made in your patches, 16 | # then obviously it doesn't make any sense to PR them upstream. 17 | 18 | tiny 2 0 mojang+yarn spigot 19 | 20 | # Workaround by MoritzR200 (see issue#87) 21 | c net/minecraft/server/dedicated/DedicatedServerProperties net/minecraft/server/dedicated/DedicatedServerProperties 22 | m (Ljava/lang/String;)Ljava/lang/String; lambda$new$3 d 23 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | java 3 | `maven-publish` 4 | id("com.github.johnrengelman.shadow") version "8.1.1" apply false 5 | id("io.papermc.paperweight.patcher") version "1.5.12-SNAPSHOT" 6 | } 7 | 8 | repositories { 9 | mavenCentral() 10 | maven("https://repo.papermc.io/repository/maven-public/") { 11 | content { onlyForConfigurations("paperclip") } 12 | } 13 | } 14 | 15 | dependencies { 16 | remapper("net.fabricmc:tiny-remapper:0.10.1:fat") 17 | decompiler("org.vineflower:vineflower:1.9.3") 18 | paperclip("io.papermc:paperclip:3.0.4-SNAPSHOT") 19 | } 20 | 21 | subprojects { 22 | apply(plugin = "java") 23 | apply(plugin = "maven-publish") 24 | 25 | java { 26 | toolchain { 27 | languageVersion.set(JavaLanguageVersion.of(17)) 28 | } 29 | } 30 | 31 | tasks.withType { 32 | options.encoding = Charsets.UTF_8.name() 33 | options.release.set(17) 34 | } 35 | tasks.withType { 36 | options.encoding = Charsets.UTF_8.name() 37 | } 38 | tasks.withType { 39 | filteringCharset = Charsets.UTF_8.name() 40 | } 41 | 42 | repositories { 43 | mavenLocal() 44 | mavenCentral() 45 | maven("https://oss.sonatype.org/content/groups/public/") 46 | maven("https://repo.papermc.io/repository/maven-public/") 47 | maven("https://ci.emc.gs/nexus/content/groups/aikar/") 48 | maven("https://repo.aikar.co/content/groups/aikar") 49 | maven("https://repo.md-5.net/content/repositories/releases/") 50 | maven("https://hub.spigotmc.org/nexus/content/groups/public/") 51 | maven("https://jitpack.io") 52 | maven("https://repo.codemc.io/repository/maven-public/") 53 | } 54 | } 55 | 56 | paperweight { 57 | serverProject.set(project(":mirai-server")) 58 | 59 | remapRepo.set("https://maven.fabricmc.net/") 60 | decompileRepo.set("https://maven.quiltmc.org/") 61 | 62 | useStandardUpstream("pufferfish") { 63 | url.set(github("pufferfish-gg", "Pufferfish")) 64 | ref.set(providers.gradleProperty("pufferfishRef")) 65 | 66 | withStandardPatcher { 67 | apiSourceDirPath.set("pufferfish-api") 68 | serverSourceDirPath.set("pufferfish-server") 69 | 70 | apiPatchDir.set(layout.projectDirectory.dir("patches/api")) 71 | serverPatchDir.set(layout.projectDirectory.dir("patches/server")) 72 | 73 | apiOutputDir.set(layout.projectDirectory.dir("mirai-api")) 74 | serverOutputDir.set(layout.projectDirectory.dir("mirai-server")) 75 | } 76 | 77 | patchTasks.register("generatedApi") { 78 | isBareDirectory = true 79 | upstreamDirPath = "paper-api-generator/generated" 80 | patchDir = layout.projectDirectory.dir("patches/generated-api") 81 | outputDir = layout.projectDirectory.dir("paper-api-generator/generated") 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.caching=true 2 | org.gradle.parallel=true 3 | org.gradle.vfs.watch=false 4 | org.gradle.jvmargs = -Xmx4G 5 | 6 | group=dev.etil.mirai 7 | version=1.20.4-R0.1-SNAPSHOT 8 | mcVersion=1.20.4 9 | pufferfishRef=f5fa99a04ddcc3424bb0fbeea74033f0e5e651a2 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dreeam-qwq/Mirai/d7a2c6d3487598b781d2dbec9dbb0ea53a74c9d9/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 1>&2 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 48 | echo. 1>&2 49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 50 | echo location of your Java installation. 1>&2 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 1>&2 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 62 | echo. 1>&2 63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 64 | echo location of your Java installation. 1>&2 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /logo.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dreeam-qwq/Mirai/d7a2c6d3487598b781d2dbec9dbb0ea53a74c9d9/logo.webp -------------------------------------------------------------------------------- /patches/api/0001-Mirai-Configuration.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Etil <81570777+etil2jz@users.noreply.github.com> 3 | Date: Thu, 2 Dec 2021 16:06:46 +0100 4 | Subject: [PATCH] Mirai Configuration 5 | 6 | 7 | diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java 8 | index 9af4bc16da09e59009c47911219e99450cdf2aa5..deb7d97778afcf080c510be67cf7174ce7f15e40 100644 9 | --- a/src/main/java/org/bukkit/Server.java 10 | +++ b/src/main/java/org/bukkit/Server.java 11 | @@ -2198,6 +2198,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi 12 | } 13 | // Paper end 14 | 15 | + // Mirai start 16 | + @NotNull 17 | + public org.bukkit.configuration.file.YamlConfiguration getMiraiConfig() { 18 | + throw new UnsupportedOperationException("Not supported yet."); 19 | + } 20 | + // Mirai end 21 | + 22 | /** 23 | * Sends the component to the player 24 | * 25 | -------------------------------------------------------------------------------- /patches/api/0002-Disable-reload-command.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Ivan Pekov 3 | Date: Mon, 19 Oct 2020 15:48:06 +0300 4 | Subject: [PATCH] Disable reload command 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | diff --git a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java 10 | index 3ec32b46264cfff857b50129b5e0fa5584943ec6..e783c46037cf560516928fe1c62e34657514a689 100644 11 | --- a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java 12 | +++ b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java 13 | @@ -21,6 +21,17 @@ public class ReloadCommand extends BukkitCommand { 14 | @Override 15 | public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { // Paper 16 | if (!testPermission(sender)) return true; 17 | + // Yatopia start - disable reload command 18 | + if (Boolean.parseBoolean(System.getProperty("mirai.DisableReloadCommand", "true"))) { 19 | + sender.sendMessage(net.kyori.adventure.text.Component.text("Operation denied.", net.kyori.adventure.text.format.NamedTextColor.RED )); 20 | + sender.sendMessage(net.kyori.adventure.text.Component.text("Reload command SHOULD NEVER EVER EVER be used in whatever circumstances.", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); 21 | + sender.sendMessage(net.kyori.adventure.text.Component.text("Mirai has intentionally disabled it in order to stop you using it, instead of restarting your server.", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); 22 | + sender.sendMessage(net.kyori.adventure.text.Component.text("---------------------------------------------", net.kyori.adventure.text.format.NamedTextColor.GREEN)); 23 | + sender.sendMessage(net.kyori.adventure.text.Component.text("RESTART YOUR SERVER AND NEVER USE /reload", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); 24 | + sender.sendMessage(net.kyori.adventure.text.Component.text("For plugin developers: learn what a HOTSWAP AGENT is and stop using /reload", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); 25 | + return true; 26 | + } 27 | + // Yatopia end 28 | 29 | // Paper start - Reload permissions.yml & require confirm 30 | boolean confirmed = System.getProperty("LetMeReload") != null; 31 | -------------------------------------------------------------------------------- /patches/api/0003-Add-last-tick-time-API.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Ivan Pekov 3 | Date: Sun, 27 Sep 2020 18:01:50 +0300 4 | Subject: [PATCH] Add last tick time API 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java 10 | index 48fab492609e0bae459d20cc2eae78b87e37ab75..dda4a24db309f6fdda678bb051d9fb166479e9c6 100644 11 | --- a/src/main/java/org/bukkit/Bukkit.java 12 | +++ b/src/main/java/org/bukkit/Bukkit.java 13 | @@ -2675,6 +2675,16 @@ public final class Bukkit { 14 | return server.isStopping(); 15 | } 16 | 17 | + // Yatopia start 18 | + @Deprecated 19 | + public static long getLastTickMs() { 20 | + return server.getLastTickMs(); 21 | + } 22 | + @NotNull public static java.time.Duration getLastTickDuration() { 23 | + return server.getLastTickDuration(); 24 | + } 25 | + // Yatopia end 26 | + 27 | /** 28 | * Returns the {@link com.destroystokyo.paper.entity.ai.MobGoals} manager 29 | * 30 | diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java 31 | index deb7d97778afcf080c510be67cf7174ce7f15e40..9bfce338e45cff78e376a55ca1d763eadbec658d 100644 32 | --- a/src/main/java/org/bukkit/Server.java 33 | +++ b/src/main/java/org/bukkit/Server.java 34 | @@ -2352,6 +2352,26 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi 35 | */ 36 | boolean isStopping(); 37 | 38 | + // Yatopia start 39 | + /** 40 | + * Returns the duration the last tick took in milliseconds. 41 | + * 42 | + * @return long duration value 43 | + * @deprecated newer method with java's Duration and a possibility to convert it from millis to something else 44 | + */ 45 | + @Deprecated 46 | + default long getLastTickMs() { 47 | + return getLastTickDuration().toMillis(); 48 | + } 49 | + /** 50 | + * Returns the duration in {@link java.time.Duration} the last tick took. 51 | + * 52 | + * @return duration 53 | + */ 54 | + @NotNull 55 | + java.time.Duration getLastTickDuration(); 56 | + // Yatopia end 57 | + 58 | /** 59 | * Returns the {@link com.destroystokyo.paper.entity.ai.MobGoals} manager 60 | * 61 | -------------------------------------------------------------------------------- /patches/api/0004-Optimize-Spigot-event-bus.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Bjarne Koll 3 | Date: Thu, 9 Dec 2021 01:53:30 +0100 4 | Subject: [PATCH] Optimize Spigot event bus 5 | 6 | Original code by lynxplay, licensed under GPL v3 7 | You can find the original code on https://github.com/lynxplay/ktp 8 | 9 | This patch contains a lot of small optimizations to the spigot event bus 10 | to improve its speed as much as possible, allowing for a large amount of 11 | events to be published by the server without impacting the overall 12 | performance too much. 13 | 14 | diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java 15 | index 8ec56cd6b8e0f5c5dd8c7c88b4671e18dcf109d0..caae79275802bc5e5a5385d6a11903dfa84325d1 100644 16 | --- a/src/main/java/org/bukkit/event/Event.java 17 | +++ b/src/main/java/org/bukkit/event/Event.java 18 | @@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull; 19 | */ 20 | public abstract class Event { 21 | private String name; 22 | - private final boolean async; 23 | + private final net.kyori.adventure.util.TriState async; // KTP - optimize spigot event bus 24 | 25 | /** 26 | * The default constructor is defined for cleaner code. This constructor 27 | @@ -32,9 +32,35 @@ public abstract class Event { 28 | * by default from default constructor 29 | */ 30 | public Event(boolean isAsync) { 31 | + // KTP start - optimize spigot event bus 32 | + this(net.kyori.adventure.util.TriState.byBoolean(isAsync)); 33 | + } 34 | + 35 | + /** 36 | + * This constructor is used to explicitly declare an event as synchronous 37 | + * or asynchronous or potentially unset. 38 | + * 39 | + * @param isAsync true indicates the event will fire asynchronously, false 40 | + * by default from default constructor, unset indicates that the event may be called on either the server thread or off the server 41 | + * thread. 42 | + */ 43 | + public Event(@NotNull final net.kyori.adventure.util.TriState isAsync) { 44 | this.async = isAsync; 45 | } 46 | 47 | + /** 48 | + * Returns a tristate that, when resolving to true or false, has the exact indications defined by {@link #isAsynchronous()}. 49 | + *

50 | + * If the tristate resolves to NOT_SET, the event may or may not have been fired off the main thread, meaning a plugin would have 51 | + * to validate what thread the spigot event bus was called on. 52 | + * 53 | + * @return the tristate enum. 54 | + */ 55 | + public final @NotNull net.kyori.adventure.util.TriState asynchronous() { 56 | + return this.async; 57 | + } 58 | + // KTP end - optimize spigot event bus 59 | + 60 | // Paper start 61 | /** 62 | * Calls the event and tests if cancelled. 63 | @@ -92,7 +118,7 @@ public abstract class Event { 64 | * @return false by default, true if the event fires asynchronously 65 | */ 66 | public final boolean isAsynchronous() { 67 | - return async; 68 | + return this.async == net.kyori.adventure.util.TriState.TRUE; // KTP - optimize spigot event bus 69 | } 70 | 71 | public enum Result { 72 | diff --git a/src/main/java/org/bukkit/plugin/RegisteredListener.java b/src/main/java/org/bukkit/plugin/RegisteredListener.java 73 | index 3b3d9642a8d63798dc28f2f8df77f0466451cbff..8d3605f25e97a375971705c737bc7bacbac045cd 100644 74 | --- a/src/main/java/org/bukkit/plugin/RegisteredListener.java 75 | +++ b/src/main/java/org/bukkit/plugin/RegisteredListener.java 76 | @@ -62,8 +62,10 @@ public class RegisteredListener { 77 | * @throws EventException If an event handler throws an exception. 78 | */ 79 | public void callEvent(@NotNull final Event event) throws EventException { 80 | - if (event instanceof Cancellable) { 81 | - if (((Cancellable) event).isCancelled() && isIgnoringCancelled()) { 82 | + // KTP start - optimize spigot event bus 83 | + if (isIgnoringCancelled()) { 84 | + if (event instanceof Cancellable cancellable && cancellable.isCancelled()) { 85 | + // KTP end - optimize spigot event bus 86 | return; 87 | } 88 | } 89 | diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java 90 | index 90953bfc81168068a281be4d2d3942d5e7dd69ff..496c22e3860aaf1c46003687fc7ae1a5257b9555 100644 91 | --- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java 92 | +++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java 93 | @@ -323,4 +323,12 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm 94 | } 95 | 96 | // Paper end 97 | + 98 | + // KTP start - expose addURL 99 | + @Override 100 | + public void addURL(final URL url) { 101 | + super.addURL(url); 102 | + } 103 | + // KTP end - expose addURL 104 | + 105 | } 106 | -------------------------------------------------------------------------------- /patches/api/0005-Skip-event-if-no-listeners.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Simon Gardling 3 | Date: Mon, 13 Dec 2021 11:28:08 -0500 4 | Subject: [PATCH] Skip event if no listeners 5 | 6 | Original code by GaleMC, licensed under GPL v3 7 | You can find the original code on https://github.com/GaleMC/Gale 8 | 9 | This patch is based on the following patch: 10 | "skip event if no listeners" 11 | By: Simon Gardling 12 | As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack) 13 | Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) 14 | 15 | diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java 16 | index bd4d1a40f53784662174d426533ef4b5433a15b7..286e22babe56ceaac1093d6204f6e695b4eb7bb6 100644 17 | --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java 18 | +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java 19 | @@ -635,6 +635,19 @@ public final class SimplePluginManager implements PluginManager { 20 | HandlerList handlers = event.getHandlers(); 21 | RegisteredListener[] listeners = handlers.getRegisteredListeners(); 22 | 23 | + // Gale start - JettPack - skip events without listeners 24 | + if (listeners.length == 0) { 25 | + return; 26 | + } 27 | + // Gale end - JettPack - skip events without listeners 28 | + 29 | + // Paper - replace callEvent by merging to below method 30 | + if (event.isAsynchronous() && server.isPrimaryThread()) { 31 | + throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously."); 32 | + } else if (!event.isAsynchronous() && !server.isPrimaryThread() && !server.isStopping() ) { 33 | + throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously."); 34 | + } 35 | + 36 | for (RegisteredListener registration : listeners) { 37 | if (!registration.getPlugin().isEnabled()) { 38 | continue; 39 | -------------------------------------------------------------------------------- /patches/api/0006-Lobotomize-stuck-villagers.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: BillyGalbreath 3 | Date: Mon, 24 Jan 2022 20:42:22 -0600 4 | Subject: [PATCH] Lobotomize stuck villagers 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | diff --git a/src/main/java/org/bukkit/entity/Villager.java b/src/main/java/org/bukkit/entity/Villager.java 10 | index c61e7e41aeb3d4f5f4ac47da8890051d8e97340d..94578a640cc44d7f36bca5824504162b68821425 100644 11 | --- a/src/main/java/org/bukkit/entity/Villager.java 12 | +++ b/src/main/java/org/bukkit/entity/Villager.java 13 | @@ -328,4 +328,13 @@ public interface Villager extends AbstractVillager { 14 | */ 15 | public void clearReputations(); 16 | // Paper end 17 | + 18 | + // Purpur start 19 | + /** 20 | + * Check if villager is currently lobotomized 21 | + * 22 | + * @return True if lobotomized 23 | + */ 24 | + boolean isLobotomized(); 25 | + // Purpur end 26 | } 27 | -------------------------------------------------------------------------------- /patches/api/0007-Set-multiple-Team-settings-at-once.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Cryptite 3 | Date: Sat, 13 Aug 2022 08:40:03 -0500 4 | Subject: [PATCH] Set multiple Team settings at once 5 | 6 | Original code by Cryptite, licensed under MIT 7 | You can find the original code on https://github.com/Cryptite/Slice 8 | 9 | diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java 10 | index cacb58d25c249e2ecd6083ed0f30d5ffb345220a..5192fdb618f09c40da501b42c3ed3c66f270b269 100644 11 | --- a/src/main/java/org/bukkit/scoreboard/Team.java 12 | +++ b/src/main/java/org/bukkit/scoreboard/Team.java 13 | @@ -514,6 +514,24 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience { 14 | boolean hasEntity(@NotNull org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException; 15 | // Paper end - improve scoreboard entries 16 | 17 | + //Slice start 18 | + /** 19 | + * Fully set all team options, combining all 5 options into one packet send, rather than one packet sent 20 | + * for every single option change. 21 | + * @param displayName New display name 22 | + * @param prefix New prefix 23 | + * @param suffix New suffix 24 | + * @param color new color 25 | + * @param options A Paired list of options 26 | + * @throws IllegalStateException 27 | + */ 28 | + void teamOptions(@Nullable net.kyori.adventure.text.Component displayName, 29 | + @Nullable net.kyori.adventure.text.Component prefix, 30 | + @Nullable net.kyori.adventure.text.Component suffix, 31 | + @Nullable net.kyori.adventure.text.format.NamedTextColor color, 32 | + @NotNull java.util.List> options) throws IllegalStateException; 33 | + //Slice end 34 | + 35 | /** 36 | * Represents an option which may be applied to this team. 37 | */ 38 | -------------------------------------------------------------------------------- /patches/api/0008-Smooth-Teleports.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Cryptite 3 | Date: Sat, 13 Aug 2022 08:58:21 -0500 4 | Subject: [PATCH] Smooth Teleports 5 | 6 | Original code by Cryptite, licensed under MIT 7 | You can find the original code on https://github.com/Cryptite/Slice 8 | 9 | diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java 10 | index 31aa6ef5fc2b3b88c72f5a15b8cc7a0e50c29f46..47c485099f7667590669309e82bdcabf5e4ebb74 100644 11 | --- a/src/main/java/org/bukkit/entity/Player.java 12 | +++ b/src/main/java/org/bukkit/entity/Player.java 13 | @@ -3482,6 +3482,19 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM 14 | String getClientBrandName(); 15 | // Paper end 16 | 17 | + /** 18 | + * This abuses some of how Minecraft works and allows teleporting a player to another world without 19 | + * triggering typical respawn packets. All of natural state of chunk resends, entity adds/removes, etc still 20 | + * happen but the visual "refresh" of a world change is hidden. Depending on the destination location/world, 21 | + * this can act as a "smooth teleport" to a world if the new world is very similar looking to the old one. 22 | + * 23 | + * @param location New location to teleport this Player to 24 | + */ 25 | + // Slice start 26 | + @org.jetbrains.annotations.ApiStatus.Experimental 27 | + void teleportWithoutRespawn(@NotNull Location location); 28 | + // Slice end 29 | + 30 | // Paper start - Teleport API 31 | /** 32 | * Sets the player's rotation. 33 | -------------------------------------------------------------------------------- /patches/api/0009-Mirai-Add-Higher-Java-Versions-Support-for-SIMD.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> 3 | Date: Mon, 22 May 2023 08:06:21 +0800 4 | Subject: [PATCH] Mirai: Add Higher Java Versions Support for SIMD 5 | 6 | 7 | diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java 8 | index ab5fea0b03224bf249352ce340e94704ff713345..3f19714cf810e4b0a1bc0e903bc9f1907cce1741 100644 9 | --- a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java 10 | +++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java 11 | @@ -15,7 +15,7 @@ public class SIMDChecker { 12 | @Deprecated 13 | public static boolean canEnable(Logger logger) { 14 | try { 15 | - if (SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19) { 16 | + if (SIMDDetection.getJavaVersion() < 17) { // Mirai - Add Higher Java Versions Support for SIMD 17 | return false; 18 | } else { 19 | SIMDDetection.testRun = true; 20 | -------------------------------------------------------------------------------- /patches/server/0003-Time-Utilities.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: YatopiaMC 3 | Date: Fri, 23 Oct 2020 09:20:01 -0700 4 | Subject: [PATCH] Time Utilities 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | diff --git a/src/main/java/org/yatopiamc/yatopia/server/util/TimeUtils.java b/src/main/java/org/yatopiamc/yatopia/server/util/TimeUtils.java 10 | new file mode 100644 11 | index 0000000000000000000000000000000000000000..d521a902022af05f87f54ce5a7c77ce18b48862c 12 | --- /dev/null 13 | +++ b/src/main/java/org/yatopiamc/yatopia/server/util/TimeUtils.java 14 | @@ -0,0 +1,18 @@ 15 | +package org.yatopiamc.yatopia.server.util; 16 | + 17 | +import java.util.concurrent.TimeUnit; 18 | + 19 | +public class TimeUtils { 20 | + 21 | + public static String getFriendlyName(TimeUnit unit) { 22 | + return switch (unit) { 23 | + case NANOSECONDS -> "ns"; 24 | + case MILLISECONDS -> "ms"; 25 | + case MICROSECONDS -> "micros"; 26 | + case SECONDS -> "s"; 27 | + case MINUTES -> "m"; 28 | + case DAYS -> "d"; 29 | + case HOURS -> "h"; 30 | + }; 31 | + } 32 | +} 33 | -------------------------------------------------------------------------------- /patches/server/0005-lithium-fast-util.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Tue, 14 Dec 2021 12:04:01 -0500 4 | Subject: [PATCH] lithium: fast util 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java 10 | index 392406722b0a040c1d41fdc1154d75d39f6e9c86..b5d9d256ad40e1318d8451810ae03f7cf8f6ede5 100644 11 | --- a/src/main/java/net/minecraft/core/Direction.java 12 | +++ b/src/main/java/net/minecraft/core/Direction.java 13 | @@ -197,7 +197,7 @@ public enum Direction implements StringRepresentable { 14 | } 15 | 16 | public Direction getOpposite() { 17 | - return from3DDataValue(this.oppositeIndex); 18 | + return VALUES[this.oppositeIndex]; // JettPack - lithium: fast util 19 | } 20 | 21 | public Direction getClockWise(Direction.Axis axis) { 22 | @@ -466,7 +466,7 @@ public enum Direction implements StringRepresentable { 23 | } 24 | 25 | public static Direction getRandom(RandomSource random) { 26 | - return Util.getRandom(VALUES, random); 27 | + return VALUES[random.nextInt(VALUES.length)]; // JettPack - lithium: fast util 28 | } 29 | 30 | public static Direction getNearest(double x, double y, double z) { 31 | diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java 32 | index 67d595f75e0c3bffdb27b85b25ccd1f0bf1427d5..ed0910b3f8214ab885d8b7debfc1a348d73bc081 100644 33 | --- a/src/main/java/net/minecraft/world/phys/AABB.java 34 | +++ b/src/main/java/net/minecraft/world/phys/AABB.java 35 | @@ -16,6 +16,15 @@ public class AABB { 36 | public final double maxY; 37 | public final double maxZ; 38 | 39 | + // JettPack start - lithium: fast_util 40 | + static { 41 | + assert Direction.Axis.X.ordinal() == 0; 42 | + assert Direction.Axis.Y.ordinal() == 1; 43 | + assert Direction.Axis.Z.ordinal() == 2; 44 | + assert Direction.Axis.values().length == 3; 45 | + } 46 | + // JettPack end 47 | + 48 | public AABB(double x1, double y1, double z1, double x2, double y2, double z2) { 49 | this.minX = Math.min(x1, x2); 50 | this.minY = Math.min(y1, y2); 51 | @@ -81,11 +90,26 @@ public class AABB { 52 | } 53 | 54 | public double min(Direction.Axis axis) { 55 | - return axis.choose(this.minX, this.minY, this.minZ); 56 | + // JettPack start - lithium: fast_util 57 | + return switch (axis.ordinal()) { 58 | + case 0 -> this.minX; //X 59 | + case 1 -> this.minY; //Y 60 | + case 2 -> this.minZ; //Z 61 | + default -> throw new IllegalArgumentException(); 62 | + }; 63 | + 64 | + // JettPack end 65 | } 66 | 67 | public double max(Direction.Axis axis) { 68 | - return axis.choose(this.maxX, this.maxY, this.maxZ); 69 | + // JettPack start - lithium: fast_util 70 | + return switch (axis.ordinal()) { 71 | + case 0 -> this.maxX; //X 72 | + case 1 -> this.maxY; //Y 73 | + case 2 -> this.maxZ; //Z 74 | + default -> throw new IllegalArgumentException(); 75 | + }; 76 | + // JettPack end 77 | } 78 | 79 | @Override 80 | -------------------------------------------------------------------------------- /patches/server/0008-lithium-fast-retrieval.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Wed, 15 Dec 2021 11:20:48 -0500 4 | Subject: [PATCH] lithium: fast retrieval 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java b/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java 10 | index ee692b49c62f36287bf9d008861f5d47e0e42c00..78632156fdcb1e4567b4c30813310dc8af2b82bb 100644 11 | --- a/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java 12 | +++ b/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java 13 | @@ -33,7 +33,7 @@ public class EntitySectionStorage { 14 | } 15 | 16 | public void forEachAccessibleNonEmptySection(AABB box, AbortableIterationConsumer> consumer) { 17 | - int i = 2; 18 | + // Mirai start - lithium: fast retrieval 19 | int j = SectionPos.posToSectionCoord(box.minX - 2.0D); 20 | int k = SectionPos.posToSectionCoord(box.minY - 4.0D); 21 | int l = SectionPos.posToSectionCoord(box.minZ - 2.0D); 22 | @@ -41,25 +41,67 @@ public class EntitySectionStorage { 23 | int n = SectionPos.posToSectionCoord(box.maxY + 0.0D); 24 | int o = SectionPos.posToSectionCoord(box.maxZ + 2.0D); 25 | 26 | - for(int p = j; p <= m; ++p) { 27 | - long q = SectionPos.asLong(p, 0, 0); 28 | - long r = SectionPos.asLong(p, -1, -1); 29 | - LongIterator longIterator = this.sectionIds.subSet(q, r + 1L).iterator(); 30 | - 31 | - while(longIterator.hasNext()) { 32 | - long s = longIterator.nextLong(); 33 | - int t = SectionPos.y(s); 34 | - int u = SectionPos.z(s); 35 | - if (t >= k && t <= n && u >= l && u <= o) { 36 | - EntitySection entitySection = this.sections.get(s); 37 | - if (entitySection != null && !entitySection.isEmpty() && entitySection.getStatus().isAccessible() && consumer.accept(entitySection).shouldAbort()) { 38 | - return; 39 | + if (m >= j + 4 || o >= l + 4) { 40 | + // Vanilla is likely more optimized when shooting entities with TNT cannons over huge distances. 41 | + // Choosing a cutoff of 4 chunk size, as it becomes more likely that these entity sections do not exist when 42 | + // they are far away from the shot entity (player despawn range, position maybe not on the ground, etc) 43 | + for (int p = j; p <= m; p++) { 44 | + long q = SectionPos.asLong(p, 0, 0); 45 | + long r = SectionPos.asLong(p, -1, -1); 46 | + LongIterator longIterator = this.sectionIds.subSet(q, r + 1L).iterator(); 47 | + 48 | + while (longIterator.hasNext()) { 49 | + long s = longIterator.nextLong(); 50 | + int t = SectionPos.y(s); 51 | + int u = SectionPos.z(s); 52 | + if (t >= k && t <= n && u >= l && u <= o) { 53 | + EntitySection entitySection = this.sections.get(s); 54 | + if (entitySection != null && !entitySection.isEmpty() && entitySection.getStatus().isAccessible()) { 55 | + consumer.accept(entitySection); 56 | + } 57 | } 58 | } 59 | } 60 | + } else { 61 | + // Vanilla order of the AVL long set is sorting by ascending long value. The x, y, z positions are packed into 62 | + // a long with the x position's lowest 22 bits placed at the MSB. 63 | + // Therefore, the long is negative iff the 22th bit of the x position is set, which happens iff the x position 64 | + // is negative. A positive x position will never have its 22th bit set, as these big coordinates are far outside 65 | + // the world. y and z positions are treated as unsigned when sorting by ascending long value, as their sign bits 66 | + // are placed somewhere inside the packed long 67 | + for (int x = j; x <= m; x++) { 68 | + for (int z = Math.max(l, 0); z <= o; z++) { 69 | + this.forEachInColumn(x, k, n, z, consumer); 70 | + } 71 | + 72 | + int bound = Math.min(-1, o); 73 | + for (int z = l; z <= bound; z++) { 74 | + this.forEachInColumn(x, k, n, z, consumer); 75 | + } 76 | + } 77 | } 78 | + // Mirai end 79 | + } 80 | 81 | + // Mirai start - lithium: fast retrieval 82 | + private void forEachInColumn(int x, int k, int n, int z, AbortableIterationConsumer> consumer) { 83 | + // y from negative to positive, but y is treated as unsigned 84 | + for (int y = Math.max(k, 0); y <= n; y++) { 85 | + this.consumeSection(SectionPos.asLong(x, y, z), consumer); 86 | + } 87 | + int bound = Math.min(-1, n); 88 | + for (int y = k; y <= bound; y++) { 89 | + this.consumeSection(SectionPos.asLong(x, y, z), consumer); 90 | + } 91 | + } 92 | + 93 | + private void consumeSection(long pos, AbortableIterationConsumer> consumer) { 94 | + EntitySection entitySection = this.sections.get(pos); 95 | + if (entitySection != null && !entitySection.isEmpty() && entitySection.getStatus().isAccessible()) { 96 | + consumer.accept(entitySection); 97 | + } 98 | } 99 | + // Mirai end 100 | 101 | public LongStream getExistingSectionPositionsInChunk(long chunkPos) { 102 | int i = ChunkPos.getX(chunkPos); 103 | -------------------------------------------------------------------------------- /patches/server/0009-Add-last-tick-time-API.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Ivan Pekov 3 | Date: Sun, 27 Sep 2020 18:30:10 +0300 4 | Subject: [PATCH] Add last tick time API 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java 10 | index 68de58849f541ddf8cccdc11beb4245c01f62258..1f3596ce6919b775e11a1ddcba20ff9423f1c561 100644 11 | --- a/src/main/java/net/minecraft/server/MinecraftServer.java 12 | +++ b/src/main/java/net/minecraft/server/MinecraftServer.java 13 | @@ -1125,6 +1125,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { 27 | return false; 28 | } : this::haveTime); 29 | + lastTickDuration = java.time.Duration.ofNanos(System.nanoTime() - tickStart); // Yatopia 30 | this.profiler.popPush("nextTickWait"); 31 | this.mayHaveDelayedTasks = true; 32 | this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + i, this.nextTickTimeNanos); 33 | diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java 34 | index 1ee264c16ce24df492b556e086ceba28de6b0552..7805b768efac13e4481099cdb190f68231950f26 100644 35 | --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java 36 | +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java 37 | @@ -3230,6 +3230,12 @@ public final class CraftServer implements Server { 38 | public CraftPotionBrewer getPotionBrewer() { 39 | return this.potionBrewer; 40 | } 41 | - 42 | // Paper end 43 | + 44 | + // Yatopia start 45 | + @Override 46 | + public java.time.Duration getLastTickDuration() { 47 | + return net.minecraft.server.MinecraftServer.lastTickDuration; 48 | + } 49 | + // Yatopia end 50 | } 51 | diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java 52 | index 9eb2823cc8f83bad2626fc77578b0162d9ed5782..d7c8f2737c64e0036bccc7ef3d73af7af2d3b1d3 100644 53 | --- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java 54 | +++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java 55 | @@ -1,7 +1,5 @@ 56 | package org.spigotmc; 57 | 58 | -import net.minecraft.server.MinecraftServer; 59 | -import org.bukkit.ChatColor; 60 | import org.bukkit.command.Command; 61 | import org.bukkit.command.CommandSender; 62 | 63 | @@ -42,6 +40,16 @@ public class TicksPerSecondCommand extends Command 64 | builder.append(net.kyori.adventure.text.Component.text("TPS from last 1m, 5m, 15m: ", net.kyori.adventure.text.format.NamedTextColor.GOLD)); 65 | builder.append(net.kyori.adventure.text.Component.join(net.kyori.adventure.text.JoinConfiguration.commas(true), tpsAvg)); 66 | sender.sendMessage(builder.asComponent()); 67 | + // Yatopia start - Last tick duration API 68 | + java.time.Duration lastTickDuration = org.bukkit.Bukkit.getLastTickDuration(); 69 | + sender.sendMessage(net.kyori.adventure.text.Component.text() 70 | + .append(net.kyori.adventure.text.Component.text("Last tick: ", net.kyori.adventure.text.format.NamedTextColor.GOLD)) 71 | + .append(TicksPerSecondCommand.formatTo(lastTickDuration, java.util.concurrent.TimeUnit.MILLISECONDS)) 72 | + .append(net.kyori.adventure.text.Component.text(" (", net.kyori.adventure.text.format.NamedTextColor.GOLD)) 73 | + .append(TicksPerSecondCommand.formatTo(lastTickDuration, java.util.concurrent.TimeUnit.NANOSECONDS)) 74 | + .append(net.kyori.adventure.text.Component.text(")", net.kyori.adventure.text.format.NamedTextColor.GOLD)) 75 | + .build()); 76 | + // Yatopia end 77 | if (args.length > 0 && args[0].equals("mem") && sender.hasPermission("bukkit.command.tpsmemory")) { 78 | sender.sendMessage(net.kyori.adventure.text.Component.text() 79 | .append(net.kyori.adventure.text.Component.text("Current Memory Usage: ", net.kyori.adventure.text.format.NamedTextColor.GOLD)) 80 | @@ -66,4 +74,16 @@ public class TicksPerSecondCommand extends Command 81 | return net.kyori.adventure.text.Component.text(amount, color); 82 | // Paper end 83 | } 84 | + 85 | + // Yatopia start - Last tick duration API 86 | + public static net.kyori.adventure.text.Component formatTo(java.time.Duration duration, java.util.concurrent.TimeUnit unit) { 87 | + java.util.concurrent.TimeUnit nanosUnit = java.util.concurrent.TimeUnit.NANOSECONDS; 88 | + long nanos = duration.toNanos(); 89 | + long toAskedUnit = unit.convert(nanos, nanosUnit); 90 | + long ms = nanosUnit.toMillis(nanos); 91 | + net.kyori.adventure.text.format.TextColor startingColor = ms < 40 ? net.kyori.adventure.text.format.NamedTextColor.GREEN : (ms < 50) ? net.kyori.adventure.text.format.NamedTextColor.YELLOW : net.kyori.adventure.text.format.NamedTextColor.RED; 92 | + return net.kyori.adventure.text.Component.text(toAskedUnit, startingColor) 93 | + .append(net.kyori.adventure.text.Component.text(org.yatopiamc.yatopia.server.util.TimeUtils.getFriendlyName(unit), net.kyori.adventure.text.format.NamedTextColor.GOLD)); 94 | + } 95 | + // Yatopia end 96 | } 97 | -------------------------------------------------------------------------------- /patches/server/0010-Add-config-for-logging-login-location.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Simon Gardling 3 | Date: Wed, 20 Jan 2021 16:36:48 -0500 4 | Subject: [PATCH] Add config for logging login location 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 10 | index d4e242b74f77e29099421450ced16481d3f1af13..af9303f211c340473b6b236216ff19d3417e4b28 100644 11 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 12 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 13 | @@ -131,4 +131,9 @@ public class MiraiConfig { 14 | return config.getStringList(key); 15 | } 16 | 17 | + public static boolean logPlayerLoginLoc; 18 | + private static void logPlayerLoc() { 19 | + logPlayerLoginLoc = getBoolean("log-player-login-location", true, 20 | + "Whether or not player login location should be written in logs."); 21 | + } 22 | } 23 | diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java 24 | index 391290638df8329ef21ae5f6d66947c21459fe2c..6bebab48ca808ce3c9c1944a5c08fed8d9efc5fa 100644 25 | --- a/src/main/java/net/minecraft/server/players/PlayerList.java 26 | +++ b/src/main/java/net/minecraft/server/players/PlayerList.java 27 | @@ -486,7 +486,13 @@ public abstract class PlayerList { 28 | scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam); 29 | } 30 | // Paper end - Configurable player collision 31 | - PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ()); 32 | + // Yatopia start - configurable logging of player login location 33 | + if (dev.etil.mirai.MiraiConfig.logPlayerLoginLoc) { 34 | + PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ()); 35 | + } else { 36 | + PlayerList.LOGGER.info("{}[{}] logged in with entity id {}", player.getName().getString(), s1, player.getId()); 37 | + } 38 | + // Yatopia end - configurable logging of player login location 39 | } 40 | 41 | public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) { 42 | -------------------------------------------------------------------------------- /patches/server/0011-Global-Eula-file.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: tr7zw 3 | Date: Sat, 25 Jul 2020 17:16:18 +0200 4 | Subject: [PATCH] Global Eula file 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | diff --git a/src/main/java/net/minecraft/server/Eula.java b/src/main/java/net/minecraft/server/Eula.java 10 | index 4996694ec43a894cbbb363e48bfdff6b6ae17b5f..0b4121601c417943ca0089ef3907d8c2c75662c3 100644 11 | --- a/src/main/java/net/minecraft/server/Eula.java 12 | +++ b/src/main/java/net/minecraft/server/Eula.java 13 | @@ -16,11 +16,25 @@ public class Eula { 14 | 15 | public Eula(Path eulaFile) { 16 | this.file = eulaFile; 17 | - this.agreed = SharedConstants.IS_RUNNING_IN_IDE || this.readFile(); 18 | + this.agreed = SharedConstants.IS_RUNNING_IN_IDE || globalEula() || this.readFile(eulaFile); // Yatopia - global eula file 19 | } 20 | 21 | - private boolean readFile() { 22 | - try (InputStream inputStream = Files.newInputStream(this.file)) { 23 | + // Yatopia start - global eula file 24 | + private boolean globalEula() { 25 | + java.io.File globalEula = new java.io.File(System.getProperty("user.home"), "eula.txt"); 26 | + 27 | + if (globalEula.exists()) { 28 | + System.out.println("Loaded global eula file from " + globalEula.getAbsolutePath()); 29 | + return readFile(globalEula.toPath()); 30 | + } else { 31 | + System.out.println("No global eula file found at " + globalEula.getAbsolutePath()); 32 | + } 33 | + return false; 34 | + } 35 | + // Yatopia end 36 | + 37 | + private boolean readFile(java.nio.file.Path path) { 38 | + try (InputStream inputStream = Files.newInputStream(path)) { 39 | Properties properties = new Properties(); 40 | properties.load(inputStream); 41 | return Boolean.parseBoolean(properties.getProperty("eula", "false")); 42 | -------------------------------------------------------------------------------- /patches/server/0012-Stop-wasting-resources-on-JsonList-get.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Ivan Pekov 3 | Date: Fri, 4 Sep 2020 10:07:42 +0300 4 | Subject: [PATCH] Stop wasting resources on JsonList#get 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java 10 | index 6bebab48ca808ce3c9c1944a5c08fed8d9efc5fa..061550fff84074579eb26f277811e1477f1ddb2f 100644 11 | --- a/src/main/java/net/minecraft/server/players/PlayerList.java 12 | +++ b/src/main/java/net/minecraft/server/players/PlayerList.java 13 | @@ -736,6 +736,8 @@ public abstract class PlayerList { 14 | if (getBans().isBanned(gameprofile) && (gameprofilebanentry = getBans().get(gameprofile)) != null) { 15 | // Paper end - Fix MC-158900 16 | 17 | + // Yatopia start - Stop wasting resources on JsonList#get 18 | + if (!gameprofilebanentry.hasExpired()) { 19 | ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason()); 20 | if (gameprofilebanentry.getExpires() != null) { 21 | ichatmutablecomponent.append((Component) Component.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires()))); 22 | @@ -743,6 +745,10 @@ public abstract class PlayerList { 23 | 24 | // return chatmessage; 25 | event.disallow(PlayerLoginEvent.Result.KICK_BANNED, io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent)); // Paper - Adventure 26 | + } else { 27 | + getBans().remove(gameprofile); 28 | + } 29 | + // Yatopia end 30 | } else if (!this.isWhiteListed(gameprofile, event)) { // Paper - ProfileWhitelistVerifyEvent 31 | //ichatmutablecomponent = Component.translatable("multiplayer.disconnect.not_whitelisted"); // Paper 32 | //event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.whitelistMessage)); // Spigot // Paper - Adventure - moved to isWhitelisted 33 | diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java 34 | index 15e17852c19bef8fe52ec0e91be5c6a74e2d56a2..7eec181fb3ffed4dfb6d254350b7e0cb6bacddbe 100644 35 | --- a/src/main/java/net/minecraft/server/players/StoredUserList.java 36 | +++ b/src/main/java/net/minecraft/server/players/StoredUserList.java 37 | @@ -55,9 +55,12 @@ public abstract class StoredUserList> { 38 | @Nullable 39 | public V get(K key) { 40 | // Paper start - Use ConcurrentHashMap in JsonList 41 | - return (V) this.map.computeIfPresent(this.getKeyForUser(key), (k, v) -> { 42 | + // Yatopia start - Stop wasting resources on JsonList#get 43 | + return this.map.get(this.getKeyForUser(key)); 44 | + /*return (V) this.map.computeIfPresent(this.getKeyForUser(key), (k, v) -> { 45 | return v.hasExpired() ? null : v; 46 | - }); 47 | + });*/ 48 | + // Yatopia end 49 | // Paper end - Use ConcurrentHashMap in JsonList 50 | } 51 | 52 | @@ -105,7 +108,8 @@ public abstract class StoredUserList> { 53 | public void save() throws IOException { 54 | this.removeExpired(); // Paper - remove expired values before saving 55 | JsonArray jsonarray = new JsonArray(); 56 | - Stream stream = this.map.values().stream().map((jsonlistentry) -> { // CraftBukkit - decompile error 57 | + // Yatopia start - Stop wasting resources on JsonList#get 58 | + /*Stream stream = this.map.values().stream().map((jsonlistentry) -> { // CraftBukkit - decompile error 59 | JsonObject jsonobject = new JsonObject(); 60 | 61 | Objects.requireNonNull(jsonlistentry); 62 | @@ -113,7 +117,13 @@ public abstract class StoredUserList> { 63 | }); 64 | 65 | Objects.requireNonNull(jsonarray); 66 | - stream.forEach(jsonarray::add); 67 | + stream.forEach(jsonarray::add);*/ 68 | + for (V value : this.map.values()) { 69 | + JsonObject obj = new JsonObject(); 70 | + value.serialize(obj); 71 | + jsonarray.add(obj); 72 | + } 73 | + // Yatopia end 74 | BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); 75 | 76 | try { 77 | -------------------------------------------------------------------------------- /patches/server/0013-Configurable-max-bees-in-hive.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Etil <81570777+etil2jz@users.noreply.github.com> 3 | Date: Thu, 9 Dec 2021 15:39:29 +0100 4 | Subject: [PATCH] Configurable max bees in hive 5 | 6 | 7 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 8 | index af9303f211c340473b6b236216ff19d3417e4b28..15973a524157b3301960365c7e9dd09b6bbeec91 100644 9 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 10 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 11 | @@ -136,4 +136,11 @@ public class MiraiConfig { 12 | logPlayerLoginLoc = getBoolean("log-player-login-location", true, 13 | "Whether or not player login location should be written in logs."); 14 | } 15 | + 16 | + public static int maxBees; 17 | + private static void maximumBees() { 18 | + maxBees = getInt("max-bees-in-hive", 3, 19 | + "This value defines how many bees can fit in a hive.", 20 | + "Allowing more bees in a hive can reduce the number of ticking hives."); 21 | + } 22 | } 23 | diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java 24 | index dfd364ac4b7551a13c4c6c100b5e62c0dfb10595..f3299759067698f73d296268c1a5277c5644a2ea 100644 25 | --- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java 26 | +++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java 27 | @@ -43,7 +43,7 @@ public class BeehiveBlockEntity extends BlockEntity { 28 | private final List stored = Lists.newArrayList(); 29 | @Nullable 30 | public BlockPos savedFlowerPos; 31 | - public int maxBees = 3; // CraftBukkit - allow setting max amount of bees a hive can hold 32 | + public int maxBees = dev.etil.mirai.MiraiConfig.maxBees; // CraftBukkit - allow setting max amount of bees a hive can hold // Mirai - configurable max bees in hive 33 | 34 | public BeehiveBlockEntity(BlockPos pos, BlockState state) { 35 | super(BlockEntityType.BEEHIVE, pos, state); 36 | -------------------------------------------------------------------------------- /patches/server/0014-Remove-TickTask.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: foss-mc <69294560+foss-mc@users.noreply.github.com> 3 | Date: Thu, 1 Jul 2021 11:59:11 +0000 4 | Subject: [PATCH] Remove TickTask 5 | 6 | Original code by PatinaMC, licensed under GPL v3 7 | You can find the original code on https://github.com/PatinaMC/Patina 8 | 9 | diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java 10 | index 1f3596ce6919b775e11a1ddcba20ff9423f1c561..7658261b55119b8fe08b5c5080adc6de272fd89e 100644 11 | --- a/src/main/java/net/minecraft/server/MinecraftServer.java 12 | +++ b/src/main/java/net/minecraft/server/MinecraftServer.java 13 | @@ -191,7 +191,7 @@ import org.bukkit.event.server.ServerLoadEvent; 14 | 15 | import co.aikar.timings.MinecraftTimings; // Paper 16 | 17 | -public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, AutoCloseable { 18 | +public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, CommandSource, AutoCloseable { // Patina 19 | 20 | private static MinecraftServer SERVER; // Paper 21 | public static final Logger LOGGER = LogUtils.getLogger(); 22 | @@ -1346,19 +1346,21 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop {}; 32 | } 33 | // Paper end 34 | - return new TickTask(this.tickCount, runnable); 35 | + return runnable; // Patina 36 | } 37 | 38 | + /* // Patina 39 | protected boolean shouldRun(TickTask ticktask) { 40 | return ticktask.getTick() + 3 < this.tickCount || this.haveTime(); 41 | } 42 | + */ 43 | 44 | @Override 45 | public boolean pollTask() { 46 | @@ -1460,10 +1462,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop loadStatusIcon() { 58 | Optional optional = Optional.of(this.getFile("server-icon.png").toPath()).filter((path) -> { 59 | diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java 60 | index 1cf8c819c0d7776c3b33d6594ca81abe3c2a719d..6e7d7faae4c1ab3f4d232b189d95578bb84e7d24 100644 61 | --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java 62 | +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java 63 | @@ -876,10 +876,12 @@ public class ServerChunkCache extends ChunkSource { 64 | return runnable; 65 | } 66 | 67 | + /* // Patina 68 | @Override 69 | protected boolean shouldRun(Runnable task) { 70 | return true; 71 | } 72 | + */ 73 | 74 | @Override 75 | protected boolean scheduleExecutables() { 76 | diff --git a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java 77 | index 83701fbfaa56a232593ee8f11a3afb8941238bfa..9b71f38bf10b63c0a4304a053540c9c00099bf47 100644 78 | --- a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java 79 | +++ b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java 80 | @@ -29,7 +29,7 @@ public abstract class BlockableEventLoop implements Profiler 81 | 82 | protected abstract R wrapRunnable(Runnable runnable); 83 | 84 | - protected abstract boolean shouldRun(R task); 85 | + //protected abstract boolean shouldRun(R task); // Patina 86 | 87 | public boolean isSameThread() { 88 | return Thread.currentThread() == this.getRunningThread(); 89 | @@ -120,7 +120,7 @@ public abstract class BlockableEventLoop implements Profiler 90 | R runnable = this.pendingRunnables.peek(); 91 | if (runnable == null) { 92 | return false; 93 | - } else if (this.blockingCount == 0 && !this.shouldRun(runnable)) { 94 | + } else if (this.blockingCount == 0 && !true/*this.shouldRun(runnable)*/) { // Patina 95 | return false; 96 | } else { 97 | this.doRunTask(this.pendingRunnables.remove()); 98 | -------------------------------------------------------------------------------- /patches/server/0015-Make-a-field-final.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: foss-mc <69294560+foss-mc@users.noreply.github.com> 3 | Date: Thu, 1 Jul 2021 12:11:49 +0000 4 | Subject: [PATCH] Make a field final 5 | 6 | Original code by PatinaMC, licensed under GPL v3 7 | You can find the original code on https://github.com/PatinaMC/Patina 8 | 9 | diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java 10 | index f341813e9713e39bfe142ca34b751de3d8efd25b..cd5c943e127c0ae06f4aac94f1838290608a66e7 100644 11 | --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java 12 | +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java 13 | @@ -64,7 +64,7 @@ public class CommandSourceStack implements ExecutionCommandSource currentCommand = new java.util.concurrent.ConcurrentHashMap<>(); // CraftBukkit // Paper - Thread Safe Vanilla Command permission checking 18 | + public final java.util.Map currentCommand = new java.util.concurrent.ConcurrentHashMap<>(); // CraftBukkit // Paper - Thread Safe Vanilla Command permission checking // Patina - make a field final 19 | public boolean bypassSelectorPermissions = false; // Paper - add bypass for selector permissions 20 | 21 | public CommandSourceStack(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String name, Component displayName, MinecraftServer server, @Nullable Entity entity) { 22 | -------------------------------------------------------------------------------- /patches/server/0016-Don-t-create-new-random-instance.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: foss-mc <69294560+foss-mc@users.noreply.github.com> 3 | Date: Thu, 1 Jul 2021 12:17:44 +0000 4 | Subject: [PATCH] Don't create new random instance 5 | 6 | Original code by PatinaMC, licensed under GPL v3 7 | You can find the original code on https://github.com/PatinaMC/Patina 8 | 9 | diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java 10 | index d1f20a8a3ccea1f074624163eb96da023142a459..918bd7a64d024df75b7aff39ba3b1d53635a0619 100644 11 | --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java 12 | +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java 13 | @@ -452,7 +452,7 @@ public class ServerPlayer extends Player { 14 | long l = k * k; 15 | int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; 16 | int j1 = this.getCoprime(i1); 17 | - int k1 = RandomSource.create().nextInt(i1); 18 | + int k1 = worldserver.random.nextInt(i1); // Patina - don't create new random instance 19 | 20 | for (int l1 = 0; l1 < i1; ++l1) { 21 | int i2 = (k1 + j1 * l1) % i1; 22 | @@ -489,7 +489,7 @@ public class ServerPlayer extends Player { 23 | long l = k * k; 24 | int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; 25 | int j1 = this.getCoprime(i1); 26 | - int k1 = RandomSource.create().nextInt(i1); 27 | + int k1 = world.random.nextInt(i1); // Patina - don't create new random instance 28 | 29 | for (int l1 = 0; l1 < i1; ++l1) { 30 | int i2 = (k1 + j1 * l1) % i1; 31 | diff --git a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java 32 | index 1ef089dbf83de35d875c00efdf468c397be56978..c345f10cbf7f3451edc604f97cdf959d70639e17 100644 33 | --- a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java 34 | +++ b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java 35 | @@ -349,7 +349,7 @@ public class QueryThreadGs4 extends GenericThread { 36 | this.identBytes[2] = bs[5]; 37 | this.identBytes[3] = bs[6]; 38 | this.ident = new String(this.identBytes, StandardCharsets.UTF_8); 39 | - this.challenge = RandomSource.create().nextInt(16777216); 40 | + this.challenge = java.util.concurrent.ThreadLocalRandom.current().nextInt(16777216); // Patina - don't create new random instance 41 | this.challengeBytes = String.format(Locale.ROOT, "\t%s%d\u0000", this.ident, this.challenge).getBytes(StandardCharsets.UTF_8); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /patches/server/0017-Use-LinkedBlockingDeque-in-IAsyncTaskHandler.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Simon Gardling 3 | Date: Thu, 8 Jul 2021 15:03:15 -0400 4 | Subject: [PATCH] Use LinkedBlockingDeque in IAsyncTaskHandler 5 | 6 | Original code by Titaniumtown, licensed under GPL v3 7 | You can find the original code on https://gitlab.com/Titaniumtown/JettPack 8 | 9 | diff --git a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java 10 | index 9b71f38bf10b63c0a4304a053540c9c00099bf47..78eefe5d51f94b3fdcc42ccdab97bf2035a68afd 100644 11 | --- a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java 12 | +++ b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java 13 | @@ -1,13 +1,13 @@ 14 | package net.minecraft.util.thread; 15 | 16 | import com.google.common.collect.ImmutableList; 17 | -import com.google.common.collect.Queues; 18 | +//import com.google.common.collect.Queues; // JettPack 19 | import com.mojang.logging.LogUtils; 20 | import java.util.List; 21 | -import java.util.Queue; 22 | +//import java.util.Queue; // JettPack 23 | import java.util.concurrent.CompletableFuture; 24 | import java.util.concurrent.Executor; 25 | -import java.util.concurrent.locks.LockSupport; 26 | +//import java.util.concurrent.locks.LockSupport; // JettPack 27 | import java.util.function.BooleanSupplier; 28 | import java.util.function.Supplier; 29 | import net.minecraft.util.profiling.metrics.MetricCategory; 30 | @@ -15,12 +15,15 @@ import net.minecraft.util.profiling.metrics.MetricSampler; 31 | import net.minecraft.util.profiling.metrics.MetricsRegistry; 32 | import net.minecraft.util.profiling.metrics.ProfilerMeasured; 33 | import org.slf4j.Logger; 34 | +import java.util.concurrent.LinkedBlockingDeque; // JettPack 35 | +import java.util.concurrent.TimeUnit; // JettPack 36 | 37 | public abstract class BlockableEventLoop implements ProfilerMeasured, ProcessorHandle, Executor { 38 | private final String name; 39 | private static final Logger LOGGER = LogUtils.getLogger(); 40 | - private final Queue pendingRunnables = Queues.newConcurrentLinkedQueue(); 41 | + private final LinkedBlockingDeque pendingRunnables = new LinkedBlockingDeque<>(); // JettPack 42 | private int blockingCount; 43 | + private R next = null; // JettPack 44 | 45 | protected BlockableEventLoop(String name) { 46 | this.name = name; 47 | @@ -89,7 +92,7 @@ public abstract class BlockableEventLoop implements Profiler 48 | @Override 49 | public void tell(R runnable) { 50 | this.pendingRunnables.add(runnable); 51 | - LockSupport.unpark(this.getRunningThread()); 52 | + //LockSupport.unpark(this.getRunningThread()); // JettPack 53 | } 54 | 55 | @Override 56 | @@ -117,15 +120,20 @@ public abstract class BlockableEventLoop implements Profiler 57 | } 58 | 59 | public boolean pollTask() { 60 | - R runnable = this.pendingRunnables.peek(); 61 | - if (runnable == null) { 62 | - return false; 63 | - } else if (this.blockingCount == 0 && !true/*this.shouldRun(runnable)*/) { // Patina 64 | + // JettPack start 65 | + if (this.next == null && !this.pendingRunnables.isEmpty()) { 66 | + this.waitForTasks(); 67 | + } 68 | + 69 | + if (this.next == null) { 70 | return false; 71 | } else { 72 | - this.doRunTask(this.pendingRunnables.remove()); 73 | + R r2 = this.next; 74 | + this.next = null; 75 | + this.doRunTask(r2); 76 | return true; 77 | } 78 | + // JettPack end 79 | } 80 | 81 | public void managedBlock(BooleanSupplier stopCondition) { 82 | @@ -144,8 +152,15 @@ public abstract class BlockableEventLoop implements Profiler 83 | } 84 | 85 | protected void waitForTasks() { 86 | - Thread.yield(); 87 | - LockSupport.parkNanos("waiting for tasks", 100000L); 88 | + // JettPack start 89 | + if (this.next != null) { 90 | + throw new IllegalStateException("next != null"); 91 | + } 92 | + try { 93 | + this.next = this.pendingRunnables.poll(100L, TimeUnit.MICROSECONDS); 94 | + } catch (InterruptedException ignored) { 95 | + } 96 | + // JettPack end 97 | } 98 | 99 | protected void doRunTask(R task) { 100 | -------------------------------------------------------------------------------- /patches/server/0018-Use-MCUtil.asyncExecutor-for-MAIN_WORKER_EXECUTOR-in.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Simon Gardling 3 | Date: Thu, 8 Jul 2021 17:03:31 -0400 4 | Subject: [PATCH] Use MCUtil.asyncExecutor for MAIN_WORKER_EXECUTOR in 5 | SystemUtils 6 | 7 | Original code by Titaniumtown, licensed under GPL v3 8 | You can find the original code on https://gitlab.com/Titaniumtown/JettPack 9 | 10 | diff --git a/src/main/java/me/titaniumtown/ServerWorkerWrapper.java b/src/main/java/me/titaniumtown/ServerWorkerWrapper.java 11 | new file mode 100644 12 | index 0000000000000000000000000000000000000000..934e0834188a170c2aae18d519eecdc755243f35 13 | --- /dev/null 14 | +++ b/src/main/java/me/titaniumtown/ServerWorkerWrapper.java 15 | @@ -0,0 +1,21 @@ 16 | +package me.titaniumtown; 17 | + 18 | +import com.google.common.base.Preconditions; 19 | +import net.minecraft.Util; 20 | + 21 | +public final class ServerWorkerWrapper implements Runnable { 22 | + private final Runnable internalRunnable; 23 | + 24 | + public ServerWorkerWrapper(Runnable runnable) { 25 | + this.internalRunnable = Preconditions.checkNotNull(runnable, "internalRunnable"); 26 | + } 27 | + 28 | + @Override 29 | + public void run() { 30 | + try { 31 | + this.internalRunnable.run(); 32 | + } catch (Throwable throwable) { 33 | + Util.onThreadException(Thread.currentThread(), throwable); 34 | + } 35 | + } 36 | +} 37 | diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java 38 | index b40864e41e1506884fdefefbf3cf4833a8f706c3..e243893422efb63d2bb02b45b81da60d51cbf202 100644 39 | --- a/src/main/java/net/minecraft/Util.java 40 | +++ b/src/main/java/net/minecraft/Util.java 41 | @@ -80,6 +80,12 @@ import net.minecraft.util.TimeSource; 42 | import net.minecraft.util.datafix.DataFixers; 43 | import net.minecraft.world.level.block.state.properties.Property; 44 | import org.slf4j.Logger; 45 | +// JettPack start 46 | +import java.util.concurrent.AbstractExecutorService; 47 | +import me.titaniumtown.ServerWorkerWrapper; 48 | +import io.papermc.paper.util.MCUtil; 49 | +import java.util.Collections; 50 | +// JettPack end 51 | 52 | public class Util { 53 | static final Logger LOGGER = LogUtils.getLogger(); 54 | @@ -171,7 +177,46 @@ public class Util { 55 | if (i <= 0) { 56 | executorService = MoreExecutors.newDirectExecutorService(); 57 | } else { 58 | - executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<>(), target -> new io.papermc.paper.util.ServerWorkerThread(target, s, priorityModifier)); 59 | + //executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<>(), target -> new io.papermc.paper.util.ServerWorkerThread(target, s, priorityModifier)); // JettPack 60 | + // JettPack start 61 | + executorService = Integer.getInteger("Paper.WorkerThreadCount", i) <= 0 ? MoreExecutors.newDirectExecutorService() : new AbstractExecutorService() { 62 | + private volatile boolean shutdown = false; 63 | + 64 | + @Override 65 | + public List shutdownNow() { 66 | + this.shutdown = true; 67 | + return Collections.emptyList(); 68 | + } 69 | + 70 | + @Override 71 | + public void shutdown() { 72 | + this.shutdown = true; 73 | + } 74 | + 75 | + @Override 76 | + public boolean isShutdown() { 77 | + return this.shutdown; 78 | + } 79 | + 80 | + @Override 81 | + public boolean isTerminated() { 82 | + return this.shutdown; 83 | + } 84 | + 85 | + @Override 86 | + public boolean awaitTermination(long l2, TimeUnit timeUnit) { 87 | + if (!this.shutdown) { 88 | + throw new UnsupportedOperationException(); 89 | + } 90 | + return true; 91 | + } 92 | + 93 | + @Override 94 | + public void execute(Runnable runnable) { 95 | + MCUtil.asyncExecutor.execute(new ServerWorkerWrapper(runnable)); 96 | + } 97 | + }; 98 | + // JettPack end 99 | } 100 | /* 101 | @Override 102 | -------------------------------------------------------------------------------- /patches/server/0019-Remove-Spigot-tick-limiter.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Simon Gardling 3 | Date: Mon, 6 Dec 2021 10:34:33 -0500 4 | Subject: [PATCH] Remove Spigot tick limiter 5 | 6 | Original code by Titaniumtown, licensed under GPL v3 7 | You can find the original code on https://gitlab.com/Titaniumtown/JettPack 8 | 9 | diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java 10 | index 98b66704d334ed3163146a7a13a91c36a639e1d4..75b1b1094aa3845822a9603fcc03f69eb9d8e0c5 100644 11 | --- a/src/main/java/net/minecraft/world/level/Level.java 12 | +++ b/src/main/java/net/minecraft/world/level/Level.java 13 | @@ -180,8 +180,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { 14 | public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray 15 | public final co.aikar.timings.WorldTimingsHandler timings; // Paper 16 | public static BlockPos lastPhysicsProblem; // Spigot 17 | - private org.spigotmc.TickLimiter entityLimiter; 18 | - private org.spigotmc.TickLimiter tileLimiter; 19 | + //private org.spigotmc.TickLimiter entityLimiter; // JettPack - remove tick limiter 20 | + //private org.spigotmc.TickLimiter tileLimiter; // JettPack - remove tick limiter 21 | private int tileTickPosition; 22 | public final Map explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions 23 | public java.util.ArrayDeque redstoneUpdateInfos; // Paper - Faster redstone torch rapid clock removal; Move from Map in BlockRedstoneTorch to here 24 | @@ -298,8 +298,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { 25 | // CraftBukkit end 26 | this.timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings 27 | this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper - Option to keep spawn chunks loaded 28 | - this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); 29 | - this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); 30 | + //this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); // JettPack - remove tick limiter 31 | + //this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); // JettPack - remove tick limiter 32 | this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray 33 | // Paper start - optimise collisions 34 | this.minSection = io.papermc.paper.util.WorldUtil.getMinSection(this); 35 | diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java 36 | index 1cf6d4f854d89c515e48e1fb365eb95ff9340765..10adb1850650fb4eb1c8890cf9d56570bfdb8b61 100644 37 | --- a/src/main/java/org/spigotmc/SpigotWorldConfig.java 38 | +++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java 39 | @@ -452,6 +452,7 @@ public class SpigotWorldConfig 40 | this.hangingTickFrequency = this.getInt( "hanging-tick-frequency", 100 ); 41 | } 42 | 43 | + /* JettPack - remove tick limiter 44 | public int tileMaxTickTime; 45 | public int entityMaxTickTime; 46 | private void maxTickTimes() 47 | @@ -460,6 +461,7 @@ public class SpigotWorldConfig 48 | this.entityMaxTickTime = this.getInt("max-tick-time.entity", 50); 49 | this.log("Tile Max Tick Time: " + this.tileMaxTickTime + "ms Entity max Tick Time: " + this.entityMaxTickTime + "ms"); 50 | } 51 | + */ 52 | 53 | public int thunderChance; 54 | private void thunderChance() 55 | diff --git a/src/main/java/org/spigotmc/TickLimiter.java b/src/main/java/org/spigotmc/TickLimiter.java 56 | deleted file mode 100644 57 | index 4074538ea6090bf99d8ab04b1e98c2832a0e9a98..0000000000000000000000000000000000000000 58 | --- a/src/main/java/org/spigotmc/TickLimiter.java 59 | +++ /dev/null 60 | @@ -1,20 +0,0 @@ 61 | -package org.spigotmc; 62 | - 63 | -public class TickLimiter { 64 | - 65 | - private final int maxTime; 66 | - private long startTime; 67 | - 68 | - public TickLimiter(int maxtime) { 69 | - this.maxTime = maxtime; 70 | - } 71 | - 72 | - public void initTick() { 73 | - this.startTime = System.currentTimeMillis(); 74 | - } 75 | - 76 | - public boolean shouldContinue() { 77 | - long remaining = System.currentTimeMillis() - this.startTime; 78 | - return remaining < this.maxTime; 79 | - } 80 | -} 81 | -------------------------------------------------------------------------------- /patches/server/0020-Configurable-flight-checks.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: l_MrBoom_l 3 | Date: Wed, 30 Sep 2020 18:20:12 +0300 4 | Subject: [PATCH] Configurable flight checks 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 10 | index 15973a524157b3301960365c7e9dd09b6bbeec91..8717e40515dbc7cfbb5b45ce706f5c720596b5fc 100644 11 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 12 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 13 | @@ -143,4 +143,13 @@ public class MiraiConfig { 14 | "This value defines how many bees can fit in a hive.", 15 | "Allowing more bees in a hive can reduce the number of ticking hives."); 16 | } 17 | + 18 | + public static boolean checkFlying; 19 | + public static boolean checkVehicleFlying; 20 | + private static void flightChecks() { 21 | + checkFlying = getBoolean("checks.flight", true, 22 | + "Whether or not vanilla anticheat should check for players flying."); 23 | + checkVehicleFlying = getBoolean("checks.vehicle-flight", true, 24 | + "Whether or not vanilla anticheat should check for passengers flying."); 25 | + } 26 | } 27 | diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java 28 | index 4b9d1369dbd35ed41c1149cd6edb08fdbdcd920d..73628e325c240509e9c4f0dcd2d808b2f7966108 100644 29 | --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java 30 | +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java 31 | @@ -341,7 +341,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl 32 | ++this.tickCount; 33 | this.knownMovePacketCount = this.receivedMovePacketCount; 34 | if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) { 35 | - if (++this.aboveGroundTickCount > 80) { 36 | + if (dev.etil.mirai.MiraiConfig.checkFlying && ++this.aboveGroundTickCount > 80) { // Yatopia - Configurable flight checks 37 | ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString()); 38 | this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingPlayer, org.bukkit.event.player.PlayerKickEvent.Cause.FLYING_PLAYER); // Paper - use configurable kick message & kick event cause 39 | return; 40 | @@ -360,7 +360,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl 41 | this.vehicleLastGoodY = this.lastVehicle.getY(); 42 | this.vehicleLastGoodZ = this.lastVehicle.getZ(); 43 | if (this.clientVehicleIsFloating && this.player.getRootVehicle().getControllingPassenger() == this.player) { 44 | - if (++this.aboveGroundVehicleTickCount > 80) { 45 | + if (dev.etil.mirai.MiraiConfig.checkVehicleFlying && ++this.aboveGroundVehicleTickCount > 80) { // Yatopia - Configurable flight checks 46 | ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString()); 47 | this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingVehicle, org.bukkit.event.player.PlayerKickEvent.Cause.FLYING_VEHICLE); // Paper - use configurable kick message & kick event cause 48 | return; 49 | -------------------------------------------------------------------------------- /patches/server/0021-Don-t-save-Fireworks.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Aikar 3 | Date: Sat, 28 Dec 2013 21:25:06 -0500 4 | Subject: [PATCH] Don't save Fireworks 5 | 6 | Original code by Starlis, licensed under GPL v3 7 | You can find the original code on https://github.com/starlis/empirecraft 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java 10 | index fca27f98989bf106060ba08196255fe32f850df5..d154a5d84cbb56f62a028d32ff48e9eb0a5dd829 100644 11 | --- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java 12 | +++ b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java 13 | @@ -357,4 +357,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { 14 | public boolean isAttackable() { 15 | return false; 16 | } 17 | + 18 | + // EMC start 19 | + @Override 20 | + public boolean shouldBeSaved() { 21 | + return false; 22 | + } 23 | + // EMC end 24 | } 25 | -------------------------------------------------------------------------------- /patches/server/0022-Do-not-drop-items-from-Give-command.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Aikar 3 | Date: Thu, 14 Jan 2016 00:49:14 -0500 4 | Subject: [PATCH] Do not drop items from Give command 5 | 6 | Original code by Starlis, licensed under GPL v3 7 | You can find the original code on https://github.com/starlis/empirecraft 8 | 9 | diff --git a/src/main/java/net/minecraft/server/commands/GiveCommand.java b/src/main/java/net/minecraft/server/commands/GiveCommand.java 10 | index d601d287e94a59ff93b8a83a44dac02544d211df..831d882826d50fae437a882edd2a3bfc5fde88d9 100644 11 | --- a/src/main/java/net/minecraft/server/commands/GiveCommand.java 12 | +++ b/src/main/java/net/minecraft/server/commands/GiveCommand.java 13 | @@ -57,6 +57,7 @@ public class GiveCommand { 14 | l -= i1; 15 | ItemStack itemstack1 = item.createItemStack(i1, false); 16 | boolean flag = entityplayer.getInventory().add(itemstack1); 17 | + if (true) { continue; } // EMC - never drop items 18 | ItemEntity entityitem; 19 | 20 | if (flag && itemstack1.isEmpty()) { 21 | -------------------------------------------------------------------------------- /patches/server/0023-Do-not-process-chat-commands-before-player-has-joine.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: chickeneer 3 | Date: Tue, 3 Aug 2021 10:39:44 -0500 4 | Subject: [PATCH] Do not process chat/commands before player has joined 5 | 6 | Original code by Starlis, licensed under GPL v3 7 | You can find the original code on https://github.com/starlis/empirecraft 8 | 9 | diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java 10 | index 73628e325c240509e9c4f0dcd2d808b2f7966108..a684c44d4d5f1189f2eb935f3605c331c520ef92 100644 11 | --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java 12 | +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java 13 | @@ -2254,6 +2254,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl 14 | if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales 15 | this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false)); 16 | return Optional.empty(); 17 | + } else if (player.joining) { return Optional.empty(); // EMC - do not handle chat messages before they joined 18 | } else { 19 | this.player.resetLastActionTime(); 20 | return optional; 21 | -------------------------------------------------------------------------------- /patches/server/0024-Fix-cow-rotation-when-shearing-mooshroom.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: William Blake Galbreath 3 | Date: Fri, 3 May 2019 23:53:16 -0500 4 | Subject: [PATCH] Fix cow rotation when shearing mooshroom 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java 10 | index 7a82ba6e29fde33841c049e8520300aa66608f34..471e355b863805422a4aa79766a35f6558a6a46a 100644 11 | --- a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java 12 | +++ b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java 13 | @@ -199,7 +199,13 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder 3 | Date: Sat, 21 Mar 2020 18:33:05 -0500 4 | Subject: [PATCH] End gateway should check if entity can use portal 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java 10 | index 1ec80f9c901dff1c9f29befa5a8e3c3f6f37aaf7..9717b37aef9f487502e696c209ae209ab3b8f000 100644 11 | --- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java 12 | +++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java 13 | @@ -177,6 +177,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { 14 | 15 | public static void teleportEntity(Level world, BlockPos pos, BlockState state, Entity entity, TheEndGatewayBlockEntity blockEntity) { 16 | if (world instanceof ServerLevel && !blockEntity.isCoolingDown()) { 17 | + if (!entity.canChangeDimensions()) return; // Purpur 18 | ServerLevel worldserver = (ServerLevel) world; 19 | 20 | blockEntity.teleportCooldown = 100; 21 | -------------------------------------------------------------------------------- /patches/server/0026-Arrows-should-not-reset-despawn-counter.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: William Blake Galbreath 3 | Date: Wed, 4 Nov 2020 13:12:50 -0600 4 | Subject: [PATCH] Arrows should not reset despawn counter 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | This prevents keeping arrows alive indefinitely (such as when the block 10 | the arrow is stuck in gets removed, like a piston head going up/down) 11 | 12 | diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java 13 | index 42ebd91196ae420eee57f4380abc558555457163..b81e049b73e70c6798194cdb328bfbfc2fe6fe0e 100644 14 | --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java 15 | +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java 16 | @@ -319,7 +319,7 @@ public abstract class AbstractArrow extends Projectile { 17 | Vec3 vec3d = this.getDeltaMovement(); 18 | 19 | this.setDeltaMovement(vec3d.multiply((double) (this.random.nextFloat() * 0.2F), (double) (this.random.nextFloat() * 0.2F), (double) (this.random.nextFloat() * 0.2F))); 20 | - this.life = 0; 21 | + // this.life = 0; // Purpur - do not reset despawn counter 22 | } 23 | 24 | @Override 25 | -------------------------------------------------------------------------------- /patches/server/0027-Fix-rotating-UP-DOWN-CW-and-CCW.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: William Blake Galbreath 3 | Date: Wed, 6 Jan 2021 02:19:29 -0600 4 | Subject: [PATCH] Fix rotating UP/DOWN CW and CCW 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java 10 | index b5d9d256ad40e1318d8451810ae03f7cf8f6ede5..c44ed3da99979d97d4ded96082586a544be73729 100644 11 | --- a/src/main/java/net/minecraft/core/Direction.java 12 | +++ b/src/main/java/net/minecraft/core/Direction.java 13 | @@ -253,6 +253,12 @@ public enum Direction implements StringRepresentable { 14 | case EAST: 15 | var10000 = SOUTH; 16 | break; 17 | + // Purpur start 18 | + case UP: 19 | + return UP; 20 | + case DOWN: 21 | + return DOWN; 22 | + // Purpur end 23 | default: 24 | throw new IllegalStateException("Unable to get Y-rotated facing of " + this); 25 | } 26 | @@ -365,6 +371,12 @@ public enum Direction implements StringRepresentable { 27 | case EAST: 28 | var10000 = NORTH; 29 | break; 30 | + // Purpur start 31 | + case UP: 32 | + return UP; 33 | + case DOWN: 34 | + return DOWN; 35 | + // Purpur end 36 | default: 37 | throw new IllegalStateException("Unable to get CCW facing of " + this); 38 | } 39 | -------------------------------------------------------------------------------- /patches/server/0028-Fix-outdated-server-showing-in-ping-before-server-fu.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: William Blake Galbreath 3 | Date: Tue, 4 Jun 2019 15:50:08 -0500 4 | Subject: [PATCH] Fix 'outdated server' showing in ping before server fully 5 | boots 6 | 7 | Original code by PurpurMC, licensed under MIT 8 | You can find the original code on https://github.com/PurpurMC/Purpur 9 | 10 | diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java 11 | index 2c13147bc063a09bb7907d6f90c3a1e811a09eb1..3edb0c392cec7fdabebad81da1a8b06a700fbfca 100644 12 | --- a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java 13 | +++ b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java 14 | @@ -153,6 +153,7 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene 15 | this.connection.send(new ClientboundStatusResponsePacket(ping)); 16 | // CraftBukkit end 17 | */ 18 | + if (MinecraftServer.getServer().getStatus().version().isEmpty()) return; // Purpur - do not respond to pings before we know the protocol version 19 | com.destroystokyo.paper.network.StandardPaperServerListPingEventImpl.processRequest(MinecraftServer.getServer(), this.connection); 20 | // Paper end 21 | } 22 | -------------------------------------------------------------------------------- /patches/server/0029-Dont-send-useless-entity-packets.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: William Blake Galbreath 3 | Date: Sat, 6 Jul 2019 17:00:04 -0500 4 | Subject: [PATCH] Dont send useless entity packets 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 10 | index 8717e40515dbc7cfbb5b45ce706f5c720596b5fc..d867baee944627e1a1419611fac2d3385350b182 100644 11 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 12 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 13 | @@ -152,4 +152,10 @@ public class MiraiConfig { 14 | checkVehicleFlying = getBoolean("checks.vehicle-flight", true, 15 | "Whether or not vanilla anticheat should check for passengers flying."); 16 | } 17 | + 18 | + public static boolean dontSendUselessEntityPackets; 19 | + private static void uselessEntityPackets() { 20 | + dontSendUselessEntityPackets = getBoolean("dont-send-useless-entity-packets", true, 21 | + "Whether or not server should send entity packets with null movements."); 22 | + } 23 | } 24 | diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java 25 | index da459fa2bd8ad4b05a0ae99552db2709a5169c2a..b99eeae741c1042ae5d925957a87481c113f9502 100644 26 | --- a/src/main/java/net/minecraft/server/level/ServerEntity.java 27 | +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java 28 | @@ -206,6 +206,7 @@ public class ServerEntity { 29 | flag4 = true; 30 | flag5 = true; 31 | } 32 | + if (dev.etil.mirai.MiraiConfig.dontSendUselessEntityPackets && isUselessPacket(packet1)) packet1 = null; // Purpur 33 | } 34 | 35 | if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { 36 | @@ -278,6 +279,21 @@ public class ServerEntity { 37 | }); 38 | } 39 | 40 | + // Purpur start 41 | + private boolean isUselessPacket(Packet possibleUselessPacket) { 42 | + if (possibleUselessPacket instanceof ClientboundMoveEntityPacket packet) { 43 | + if (possibleUselessPacket instanceof ClientboundMoveEntityPacket.Pos) { 44 | + return packet.getXa() == 0 && packet.getYa() == 0 && packet.getZa() == 0; 45 | + } else if (possibleUselessPacket instanceof ClientboundMoveEntityPacket.PosRot) { 46 | + return packet.getXa() == 0 && packet.getYa() == 0 && packet.getZa() == 0 && packet.getyRot() == 0 && packet.getxRot() == 0; 47 | + } else if (possibleUselessPacket instanceof ClientboundMoveEntityPacket.Rot) { 48 | + return packet.getyRot() == 0 && packet.getxRot() == 0; 49 | + } 50 | + } 51 | + return false; 52 | + } 53 | + // Purpur end 54 | + 55 | public void removePairing(ServerPlayer player) { 56 | this.entity.stopSeenByPlayer(player); 57 | player.connection.send(new ClientboundRemoveEntitiesPacket(new int[]{this.entity.getId()})); 58 | -------------------------------------------------------------------------------- /patches/server/0030-Skip-events-if-there-s-no-listeners.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: William Blake Galbreath 3 | Date: Sat, 4 Apr 2020 03:07:59 -0500 4 | Subject: [PATCH] Skip events if there's no listeners 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java 10 | index b7f338e982d0dcab99137ab6dc200b82ac6b7cba..32f355b1b33cf2b7b7a276fb0fd98314a962e685 100644 11 | --- a/src/main/java/net/minecraft/commands/Commands.java 12 | +++ b/src/main/java/net/minecraft/commands/Commands.java 13 | @@ -506,6 +506,7 @@ public class Commands { 14 | private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { 15 | // Paper end - Perf: Async command map building 16 | new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper - Brigadier API 17 | + if (PlayerCommandSendEvent.getHandlerList().getRegisteredListeners().length > 0) { // Purpur - skip all this crap if there's nothing listening 18 | PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); 19 | event.getPlayer().getServer().getPluginManager().callEvent(event); 20 | 21 | @@ -516,6 +517,7 @@ public class Commands { 22 | } 23 | } 24 | // CraftBukkit end 25 | + } // Purpur - skip event 26 | player.connection.send(new ClientboundCommandsPacket(rootcommandnode)); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /patches/server/0031-Alternative-Keepalive-Handling.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: William Blake Galbreath 3 | Date: Fri, 11 Oct 2019 00:17:39 -0500 4 | Subject: [PATCH] Alternative Keepalive Handling 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 10 | index d867baee944627e1a1419611fac2d3385350b182..9c1f2ca42871d234e0ec591ccc6070eccf74eb11 100644 11 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 12 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 13 | @@ -158,4 +158,11 @@ public class MiraiConfig { 14 | dontSendUselessEntityPackets = getBoolean("dont-send-useless-entity-packets", true, 15 | "Whether or not server should send entity packets with null movements."); 16 | } 17 | + 18 | + public static boolean useAlternateKeepAlive; 19 | + private static void alternateKeepAlive() { 20 | + useAlternateKeepAlive = getBoolean("use-alternate-keepalive", true, 21 | + "Whether or not server should use an alternative keepalive algorithm.", 22 | + "This can drastically reduce players timeouts due to a bad connection."); 23 | + } 24 | } 25 | diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java 26 | index 0306771b8f90dcdd77f151c19c6c2d75c41f8feb..26fde0b352a6388390b155b18649975c4d18cc31 100644 27 | --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java 28 | +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java 29 | @@ -51,6 +51,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack 30 | private long keepAliveTime = Util.getMillis(); // Paper 31 | private boolean keepAlivePending; 32 | private long keepAliveChallenge; 33 | + private it.unimi.dsi.fastutil.longs.LongList keepAlives = new it.unimi.dsi.fastutil.longs.LongArrayList(); // Purpur 34 | private int latency; 35 | private volatile boolean suspendFlushingOnServerThread = false; 36 | public final java.util.Map packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks 37 | @@ -91,6 +92,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack 38 | 39 | @Override 40 | public void handleKeepAlive(ServerboundKeepAlivePacket packet) { 41 | + // Purpur start 42 | + if (dev.etil.mirai.MiraiConfig.useAlternateKeepAlive) { 43 | + long id = packet.getId(); 44 | + if (!keepAlives.isEmpty() && keepAlives.contains(id)) { 45 | + int ping = (int) (Util.getMillis() - id); 46 | + this.latency = (this.latency * 3 + ping) / 4; 47 | + keepAlives.clear(); // we got a valid response, lets roll with it and forget the rest 48 | + } 49 | + } else 50 | + // Purpur end 51 | //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - handle ServerboundKeepAlivePacket async 52 | if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { 53 | int i = (int) (Util.getMillis() - this.keepAliveTime); 54 | @@ -209,6 +220,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack 55 | long currentTime = Util.getMillis(); 56 | long elapsedTime = currentTime - this.keepAliveTime; 57 | 58 | + // Purpur start 59 | + if (dev.etil.mirai.MiraiConfig.useAlternateKeepAlive) { 60 | + if (elapsedTime >= 1000L) { // 1 second 61 | + if (!processedDisconnect && keepAlives.size() * 1000L >= KEEPALIVE_LIMIT) { 62 | + LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); 63 | + disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); 64 | + } else { 65 | + keepAliveTime = currentTime; // hijack this field for 1 second intervals 66 | + keepAlives.add(currentTime); // currentTime is ID 67 | + send(new ClientboundKeepAlivePacket(currentTime)); 68 | + } 69 | + } 70 | + } else 71 | + // Purpur end 72 | + 73 | if (this.keepAlivePending) { 74 | if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected 75 | ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info 76 | -------------------------------------------------------------------------------- /patches/server/0034-Fix-stuck-in-portals.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: William Blake Galbreath 3 | Date: Thu, 14 Jan 2021 16:48:10 -0600 4 | Subject: [PATCH] Fix stuck in portals 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 10 | index 916805b5f1befc1a3a82ab706be87df6d5542321..f9353df394ae6b74df2f1d8a4745be4ec9928645 100644 11 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 12 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 13 | @@ -184,4 +184,11 @@ public class MiraiConfig { 14 | "Whether or not server should stop saying", 15 | "'Detected setBlock in a far chunk.'"); 16 | } 17 | + 18 | + public static boolean playerFixStuckPortal; 19 | + private static void fixStuckPortal() { 20 | + playerFixStuckPortal = getBoolean("player-fix-stuck-in-portal", false, 21 | + "Whether or not players can reset portal cooldown by", 22 | + "walking to another block in case they are stuck."); 23 | + } 24 | } 25 | diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java 26 | index c29333711774520dfed99683363725f5abd4df04..df0c72df057f147043ff03edf26a5f643203dd47 100644 27 | --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java 28 | +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java 29 | @@ -1248,6 +1248,7 @@ public class ServerPlayer extends Player { 30 | playerlist.sendPlayerPermissionLevel(this); 31 | worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); 32 | this.unsetRemoved(); 33 | + this.portalPos = io.papermc.paper.util.MCUtil.toBlockPosition(exit); // Purpur 34 | 35 | // CraftBukkit end 36 | this.setServerLevel(worldserver); 37 | diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java 38 | index 1d9331fe9ce7308eda2e7da2ae726810d455f090..d6f28bb03bd10e7cf6a6c3d1321207329388ffdc 100644 39 | --- a/src/main/java/net/minecraft/world/entity/Entity.java 40 | +++ b/src/main/java/net/minecraft/world/entity/Entity.java 41 | @@ -3125,12 +3125,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 42 | return Vec3.directionFromRotation(this.getRotationVector()); 43 | } 44 | 45 | + public BlockPos portalPos = BlockPos.ZERO; // Purpur 46 | public void handleInsidePortal(BlockPos pos) { 47 | if (this.isOnPortalCooldown()) { 48 | + if (!(dev.etil.mirai.MiraiConfig.playerFixStuckPortal && this instanceof Player && !pos.equals(portalPos))) // Purpur 49 | this.setPortalCooldown(); 50 | } else { 51 | if (!this.level().isClientSide && !pos.equals(this.portalEntrancePos)) { 52 | this.portalEntrancePos = pos.immutable(); 53 | + portalPos = BlockPos.ZERO; // Purpur 54 | } 55 | 56 | this.isInsidePortal = true; 57 | -------------------------------------------------------------------------------- /patches/server/0035-Entities-can-use-portals-configuration.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: William Blake Galbreath 3 | Date: Mon, 17 Aug 2020 19:32:05 -0500 4 | Subject: [PATCH] Entities can use portals configuration 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 10 | index f9353df394ae6b74df2f1d8a4745be4ec9928645..6bd032d296d6c0d0cd33b88aebe479a375804e4d 100644 11 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 12 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 13 | @@ -191,4 +191,10 @@ public class MiraiConfig { 14 | "Whether or not players can reset portal cooldown by", 15 | "walking to another block in case they are stuck."); 16 | } 17 | + 18 | + public static boolean entitiesCanUsePortals; 19 | + private static void entitiesPortal() { 20 | + entitiesCanUsePortals = getBoolean("entities-can-use-portals", true, 21 | + "Whether or not entities should be able to use portals."); 22 | + } 23 | } 24 | diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java 25 | index d6f28bb03bd10e7cf6a6c3d1321207329388ffdc..672262600e189333b6fa23f3cff4585858bb9abc 100644 26 | --- a/src/main/java/net/minecraft/world/entity/Entity.java 27 | +++ b/src/main/java/net/minecraft/world/entity/Entity.java 28 | @@ -3130,7 +3130,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 29 | if (this.isOnPortalCooldown()) { 30 | if (!(dev.etil.mirai.MiraiConfig.playerFixStuckPortal && this instanceof Player && !pos.equals(portalPos))) // Purpur 31 | this.setPortalCooldown(); 32 | - } else { 33 | + } else if (dev.etil.mirai.MiraiConfig.entitiesCanUsePortals || this instanceof ServerPlayer) { // Purpur 34 | if (!this.level().isClientSide && !pos.equals(this.portalEntrancePos)) { 35 | this.portalEntrancePos = pos.immutable(); 36 | portalPos = BlockPos.ZERO; // Purpur 37 | @@ -3838,7 +3838,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 38 | } 39 | 40 | public boolean canChangeDimensions() { 41 | - return !this.isPassenger() && !this.isVehicle() && isAlive() && valid; // Paper - Fix item duplication and teleport issues 42 | + return !this.isPassenger() && !this.isVehicle() && isAlive() && valid && (dev.etil.mirai.MiraiConfig.entitiesCanUsePortals || this instanceof ServerPlayer); // Paper - Fix item duplication and teleport issues // Purpur 43 | } 44 | 45 | public float getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState, float max) { 46 | -------------------------------------------------------------------------------- /patches/server/0036-lithium-replace-AI-goal-set-with-optimized-collectio.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Sun, 12 Dec 2021 16:41:06 -0500 4 | Subject: [PATCH] lithium: replace AI goal set with optimized collection 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java 10 | index 1635818fc4b1788c0d397085239df6dd75b210ab..64408d9de19e7a3526f6e16cf9071313da12873b 100644 11 | --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java 12 | +++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java 13 | @@ -13,6 +13,7 @@ import java.util.function.Supplier; 14 | import java.util.stream.Stream; 15 | import net.minecraft.util.profiling.ProfilerFiller; 16 | import org.slf4j.Logger; 17 | +import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; // Lithium 18 | 19 | public class GoalSelector { 20 | private static final Logger LOGGER = LogUtils.getLogger(); 21 | @@ -28,7 +29,7 @@ public class GoalSelector { 22 | } 23 | }; 24 | private final Map lockedFlags = new EnumMap<>(Goal.Flag.class); 25 | - private final Set availableGoals = Sets.newLinkedHashSet(); 26 | + public final Set availableGoals = new ObjectLinkedOpenHashSet<>(); // Lithium - replace AI goal set with optimized collection 27 | private final Supplier profiler; 28 | private final EnumSet disabledFlags = EnumSet.noneOf(Goal.Flag.class); // Paper unused, but dummy to prevent plugins from crashing as hard. Theyll need to support paper in a special case if this is super important, but really doesn't seem like it would be. 29 | private final com.destroystokyo.paper.util.set.OptimizedSmallEnumSet goalTypes = new com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector 30 | -------------------------------------------------------------------------------- /patches/server/0037-vmp-skip-entity-move-if-movement-is-zero.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: ishland 3 | Date: Sun, 12 Dec 2021 17:19:00 -0500 4 | Subject: [PATCH] vmp: skip entity move if movement is zero 5 | 6 | Original code by RelativityMC, licensed under MIT 7 | You can find the original code on https://github.com/RelativityMC/VMP-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java 10 | index 672262600e189333b6fa23f3cff4585858bb9abc..59efaf31e35016569f1f3793e46f1b7ff280f039 100644 11 | --- a/src/main/java/net/minecraft/world/entity/Entity.java 12 | +++ b/src/main/java/net/minecraft/world/entity/Entity.java 13 | @@ -316,6 +316,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 14 | public float yRotO; 15 | public float xRotO; 16 | private AABB bb; 17 | + private boolean boundingBoxChanged = false; // Mirai - vmp: skip entity move if movement is zero 18 | public boolean onGround; 19 | public boolean horizontalCollision; 20 | public boolean verticalCollision; 21 | @@ -1086,6 +1087,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 22 | // Paper end - detailed watchdog information 23 | 24 | public void move(MoverType movementType, Vec3 movement) { 25 | + // Mirai start - vmp: skip entity move if movement is zero 26 | + if (!boundingBoxChanged && movement.equals(Vec3.ZERO)) { 27 | + boundingBoxChanged = false; 28 | + return; 29 | + } 30 | + // Mirai end 31 | final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity 32 | // Paper start - detailed watchdog information 33 | io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main"); 34 | @@ -4090,6 +4097,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 35 | } 36 | 37 | public final void setBoundingBox(AABB boundingBox) { 38 | + if (!this.bb.equals(boundingBox)) boundingBoxChanged = true; // Mirai - vmp: skip entity move if movement is zero 39 | // CraftBukkit start - block invalid bounding boxes 40 | double minX = boundingBox.minX, 41 | minY = boundingBox.minY, 42 | -------------------------------------------------------------------------------- /patches/server/0038-Don-t-send-fire-packets-if-player-has-Fire-Resistanc.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Tom 3 | Date: Thu, 23 Sep 2021 08:56:42 -0500 4 | Subject: [PATCH] Don't send fire packets if player has Fire Resistance 5 | 6 | Original code by Cryptite, licensed under MIT 7 | You can find the original code on https://github.com/Cryptite/Slice 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java 10 | index 59efaf31e35016569f1f3793e46f1b7ff280f039..a0f102537ca5c7d88fd96e622431234cbf52dd44 100644 11 | --- a/src/main/java/net/minecraft/world/entity/Entity.java 12 | +++ b/src/main/java/net/minecraft/world/entity/Entity.java 13 | @@ -887,7 +887,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 14 | 15 | this.checkBelowWorld(); 16 | if (!this.level().isClientSide) { 17 | - this.setSharedFlagOnFire(this.remainingFireTicks > 0); 18 | + // Slice start 19 | + if (this instanceof net.minecraft.world.entity.LivingEntity livingEntity) { 20 | + this.setSharedFlagOnFire(this.remainingFireTicks > 0 && !livingEntity.hasEffect(net.minecraft.world.effect.MobEffects.FIRE_RESISTANCE)); 21 | + } else { 22 | + this.setSharedFlagOnFire(this.remainingFireTicks > 0); 23 | + } 24 | + // Slice end 25 | } 26 | 27 | this.firstTick = false; 28 | -------------------------------------------------------------------------------- /patches/server/0039-lithium-cached-hashcode.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: jellysquid3 3 | Date: Wed, 15 Dec 2021 11:30:23 -0500 4 | Subject: [PATCH] lithium: cached hashcode 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java 10 | index 73d6f881a7d4d8ff96040d34ac502e5b0937d577..2653798bc5454dccf97e73c39514394eb2c3f1c8 100644 11 | --- a/src/main/java/net/minecraft/world/level/block/Block.java 12 | +++ b/src/main/java/net/minecraft/world/level/block/Block.java 13 | @@ -614,11 +614,18 @@ public class Block extends BlockBehaviour implements ItemLike { 14 | private final BlockState first; 15 | private final BlockState second; 16 | private final Direction direction; 17 | + private int hash; // JettPack 18 | 19 | public BlockStatePairKey(BlockState self, BlockState other, Direction facing) { 20 | this.first = self; 21 | this.second = other; 22 | this.direction = facing; 23 | + // JettPack start - lithium: cached_hashcode 24 | + int hash = this.first.hashCode(); 25 | + hash = 31 * hash + this.second.hashCode(); 26 | + hash = 31 * hash + this.direction.hashCode(); 27 | + this.hash = hash; 28 | + // JettPack end 29 | } 30 | 31 | public boolean equals(Object object) { 32 | @@ -634,11 +641,7 @@ public class Block extends BlockBehaviour implements ItemLike { 33 | } 34 | 35 | public int hashCode() { 36 | - int i = this.first.hashCode(); 37 | - 38 | - i = 31 * i + this.second.hashCode(); 39 | - i = 31 * i + this.direction.hashCode(); 40 | - return i; 41 | + return this.hash; // JettPack 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /patches/server/0040-lithium-store-gamerules-in-fastutil-hashmap.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Tue, 21 Dec 2021 09:43:24 -0500 4 | Subject: [PATCH] lithium: store gamerules in fastutil hashmap 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java 10 | index c246981987017a2f86c5d632929356855e2b5714..30f32453c719cc9768eae664d4bf221a4b75d322 100644 11 | --- a/src/main/java/net/minecraft/world/level/GameRules.java 12 | +++ b/src/main/java/net/minecraft/world/level/GameRules.java 13 | @@ -27,6 +27,7 @@ import net.minecraft.network.protocol.game.ClientboundGameEventPacket; 14 | import net.minecraft.server.MinecraftServer; 15 | import net.minecraft.server.level.ServerPlayer; 16 | import org.slf4j.Logger; 17 | +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; // JettPack 18 | 19 | public class GameRules { 20 | 21 | @@ -134,14 +135,16 @@ public class GameRules { 22 | 23 | public GameRules() { 24 | // Paper start - Perf: Use array for gamerule storage 25 | - this((Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> { 26 | + // JettPack start - lithium: store gamerules in fastutil hashmap 27 | + this(new Object2ObjectOpenHashMap<>((Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> { 28 | return ((GameRules.Type) entry.getValue()).createRule(); 29 | - }))); 30 | + })))); 31 | + // JettPack end 32 | // Paper end - Perf: Use array for gamerule storage 33 | } 34 | 35 | private GameRules(Map, GameRules.Value> rules) { 36 | - this.rules = rules; 37 | + this.rules = new Object2ObjectOpenHashMap<>(rules); // JettPack - lithium: store gamerules in fastutil hashmap 38 | 39 | // Paper start - Perf: Use array for gamerule storage 40 | int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1; 41 | -------------------------------------------------------------------------------- /patches/server/0042-Configurable-enchantment-table-book-animation-tick.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: etil2jz <81570777+etil2jz@users.noreply.github.com> 3 | Date: Fri, 24 Jun 2022 20:10:19 +0200 4 | Subject: [PATCH] Configurable enchantment table book animation tick 5 | 6 | 7 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 8 | index bca7260d38cb84fcfca19b2781f16f898d26d86e..b913cdda1625facd5a9a57ae3c6844072d3935e6 100644 9 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 10 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 11 | @@ -197,4 +197,11 @@ public class MiraiConfig { 12 | entitiesCanUsePortals = getBoolean("entities-can-use-portals", true, 13 | "Whether or not entities should be able to use portals."); 14 | } 15 | + 16 | + public static boolean bookAnimationTick; 17 | + private static void bookTicking() { 18 | + bookAnimationTick = getBoolean("enchantment-table-book-animation-tick", false, 19 | + "Whether or not server should animate enchantment table book.", 20 | + "Disabling it can save MSPT, especially with quite a lot of enchantment tables."); 21 | + } 22 | } 23 | diff --git a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java 24 | index 65e1381bb2d10bd212463feb602c60f8fdb9ade1..528a722919e5ab79ff71236fd713ed614713af2a 100644 25 | --- a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java 26 | +++ b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java 27 | @@ -48,6 +48,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable 28 | } 29 | 30 | public static void bookAnimationTick(Level world, BlockPos pos, BlockState state, EnchantmentTableBlockEntity blockEntity) { 31 | + if (!dev.etil.mirai.MiraiConfig.bookAnimationTick) return; // Mirai - skip enchantment table book tick 32 | blockEntity.oOpen = blockEntity.open; 33 | blockEntity.oRot = blockEntity.rot; 34 | Player player = world.getNearestPlayer((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 3.0D, false); 35 | -------------------------------------------------------------------------------- /patches/server/0043-Skip-cloning-loot-parameters.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: etil2jz <81570777+etil2jz@users.noreply.github.com> 3 | Date: Fri, 4 Mar 2022 19:57:07 +0100 4 | Subject: [PATCH] Skip cloning loot parameters 5 | 6 | 7 | diff --git a/src/main/java/net/minecraft/advancements/Advancement.java b/src/main/java/net/minecraft/advancements/Advancement.java 8 | index a053d30f171c0c022888f098313b50f73c434180..45b9a67a0f12c38ad7fc9966e750d6b5f76cd14c 100644 9 | --- a/src/main/java/net/minecraft/advancements/Advancement.java 10 | +++ b/src/main/java/net/minecraft/advancements/Advancement.java 11 | @@ -40,7 +40,7 @@ public record Advancement(Optional parent, Optional parent, Optional display, AdvancementRewards rewards, Map> criteria, AdvancementRequirements requirements, boolean sendsTelemetryEvent) { 15 | - this(parent, display, rewards, Map.copyOf(criteria), requirements, sendsTelemetryEvent, display.map(Advancement::decorateName)); 16 | + this(parent, display, rewards, criteria, requirements, sendsTelemetryEvent, display.map(Advancement::decorateName)); // Mirai - Skip cloning loot parameters 17 | } 18 | 19 | private static DataResult validate(Advancement advancement) { 20 | -------------------------------------------------------------------------------- /patches/server/0044-lithium-precompute-shape-arrays.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: jellysquid3 3 | Date: Sat, 1 Jan 2022 03:59:58 -0500 4 | Subject: [PATCH] lithium: precompute shape arrays 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java 10 | index 4cbe84a009b4e2597176c470a606c586d5a75879..1a37036a7e11e203225fa04bd81b3594435f9f1f 100644 11 | --- a/src/main/java/net/minecraft/core/Direction.java 12 | +++ b/src/main/java/net/minecraft/core/Direction.java 13 | @@ -39,7 +39,7 @@ public enum Direction implements StringRepresentable { 14 | private final Direction.Axis axis; 15 | private final Direction.AxisDirection axisDirection; 16 | private final Vec3i normal; 17 | - private static final Direction[] VALUES = values(); 18 | + public static final Direction[] VALUES = values(); // JettPack 19 | private static final Direction[] BY_3D_DATA = Arrays.stream(VALUES).sorted(Comparator.comparingInt((direction) -> { 20 | return direction.data3d; 21 | })).toArray((i) -> { 22 | diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java 23 | index a544db042c8d2ecec8d323770552c4f10ca758a6..c04da8da5b40430b61972bce32cec4e8c0370bac 100644 24 | --- a/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java 25 | +++ b/src/main/java/net/minecraft/world/phys/shapes/CubePointRange.java 26 | @@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.doubles.AbstractDoubleList; 27 | 28 | public class CubePointRange extends AbstractDoubleList { 29 | private final int parts; 30 | + private double scale; // JettPack - lithium: shapes.precompute_shape_arrays 31 | 32 | CubePointRange(int sectionCount) { 33 | if (sectionCount <= 0) { 34 | @@ -11,10 +12,11 @@ public class CubePointRange extends AbstractDoubleList { 35 | } else { 36 | this.parts = sectionCount; 37 | } 38 | + this.scale = 1.0D / sectionCount; // JettPack - lithium: shapes.precompute_shape_arrays 39 | } 40 | 41 | public double getDouble(int i) { 42 | - return (double)i / (double)this.parts; 43 | + return i * this.scale; // JettPack - lithium: shapes.precompute_shape_arrays 44 | } 45 | 46 | public int size() { 47 | diff --git a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java 48 | index 110405e6e70d980d3e09f04d79562b32a7413071..62d72bd9e7b0ee31cea0d43f3568762ce1ec29fb 100644 49 | --- a/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java 50 | +++ b/src/main/java/net/minecraft/world/phys/shapes/CubeVoxelShape.java 51 | @@ -5,6 +5,8 @@ import net.minecraft.core.Direction; 52 | import net.minecraft.util.Mth; 53 | 54 | public final class CubeVoxelShape extends VoxelShape { 55 | + private DoubleList[] list; // Gale - Lithium - cache CubeVoxelShape shape array 56 | + 57 | protected CubeVoxelShape(DiscreteVoxelShape voxels) { 58 | super(voxels); 59 | this.initCache(); // Paper - optimise collisions 60 | @@ -12,7 +14,15 @@ public final class CubeVoxelShape extends VoxelShape { 61 | 62 | @Override 63 | protected DoubleList getCoords(Direction.Axis axis) { 64 | - return new CubePointRange(this.shape.getSize(axis)); 65 | + // Gale start - Lithium - cache CubeVoxelShape shape array 66 | + if (this.list == null) { 67 | + this.list = new DoubleList[Direction.Axis.VALUES.length]; 68 | + for (Direction.Axis existingAxis : Direction.Axis.VALUES) { 69 | + this.list[existingAxis.ordinal()] = new CubePointRange(this.shape.getSize(axis)); 70 | + } 71 | + } 72 | + return this.list[axis.ordinal()]; 73 | + // Gale end - Lithium - cache CubeVoxelShape shape array 74 | } 75 | 76 | @Override 77 | -------------------------------------------------------------------------------- /patches/server/0045-MC-121706-Fix-mobs-not-looking-up-and-down-when-stra.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Krakenied 3 | Date: Sun, 9 Oct 2022 01:50:39 +0200 4 | Subject: [PATCH] MC-121706 - Fix mobs not looking up and down when strafing 5 | 6 | Original code by PurpurMC, licensed under MIT 7 | You can find the original code on https://github.com/PurpurMC/Purpur 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java 10 | index 87fb10096fc9dade33c663234b1cecc34d3d77bb..874c7b29a261b1b5ad6e86ca219ff935870aecb0 100644 11 | --- a/src/main/java/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java 12 | +++ b/src/main/java/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java 13 | @@ -119,9 +119,9 @@ public class RangedBowAttackGoal extends Go 14 | } 15 | 16 | this.mob.lookAt(livingEntity, 30.0F, 30.0F); 17 | - } else { 18 | + } //else { // Purpur - fix MC-121706 19 | this.mob.getLookControl().setLookAt(livingEntity, 30.0F, 30.0F); 20 | - } 21 | + //} // Purpur 22 | 23 | if (this.mob.isUsingItem()) { 24 | if (!bl && this.seeTime < -60) { 25 | -------------------------------------------------------------------------------- /patches/server/0046-vmp-spawn_density_cap.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: ishland 3 | Date: Sat, 4 Dec 2021 12:09:59 +0100 4 | Subject: [PATCH] vmp: spawn_density_cap 5 | 6 | Original code by RelativityMC, licensed under MIT 7 | You can find the original code on https://github.com/RelativityMC/VMP-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java 10 | index 84c766e09898cfc07d6e07e80f4b9aa318050a62..5777c898778c9a6ccded89c4496f718c07a1124a 100644 11 | --- a/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java 12 | +++ b/src/main/java/net/minecraft/world/level/LocalMobCapCalculator.java 13 | @@ -47,16 +47,25 @@ public class LocalMobCapCalculator { 14 | } 15 | 16 | static class MobCounts { 17 | - private final Object2IntMap counts = new Object2IntOpenHashMap<>(MobCategory.values().length); 18 | + // private final Object2IntMap counts = new Object2IntOpenHashMap<>(MobCategory.values().length); // Mirai 19 | + private final int[] spawnGroupDensities = new int[MobCategory.values().length]; // Mirai 20 | 21 | + // Mirai start 22 | + /** 23 | + * @author ishland 24 | + * @reason opt: replace with array access 25 | + */ 26 | public void add(MobCategory spawnGroup) { 27 | - this.counts.computeInt(spawnGroup, (group, density) -> { 28 | - return density == null ? 1 : density + 1; 29 | - }); 30 | + this.spawnGroupDensities[spawnGroup.ordinal()]++; 31 | } 32 | 33 | + /** 34 | + * @author ishland 35 | + * @reason opt: replace with array access 36 | + */ 37 | public boolean canSpawn(MobCategory spawnGroup) { 38 | - return this.counts.getOrDefault(spawnGroup, 0) < spawnGroup.getMaxInstancesPerChunk(); 39 | + return this.spawnGroupDensities[spawnGroup.ordinal()] < spawnGroup.getMaxInstancesPerChunk(); 40 | } 41 | + // Mirai end 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /patches/server/0047-lithium-entity.fast_elytra_check.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Sat, 8 Jan 2022 04:32:41 +0100 4 | Subject: [PATCH] lithium: entity.fast_elytra_check 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java 10 | index 7600992d6dedb3abcc0bfede5f4ff87aac14109c..db5f9ca0cfe9d0d53702b96207bec5e2d95ce6fc 100644 11 | --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java 12 | +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java 13 | @@ -3530,6 +3530,8 @@ public abstract class LivingEntity extends Entity implements Attackable { 14 | } 15 | 16 | private void updateFallFlying() { 17 | + if (!this.isFallFlying()) return; // Mirai 18 | + 19 | boolean flag = this.getSharedFlag(7); 20 | 21 | if (flag && !this.onGround() && !this.isPassenger() && !this.hasEffect(MobEffects.LEVITATION)) { 22 | -------------------------------------------------------------------------------- /patches/server/0048-lithium-entity.fast_hand_swing.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Sun, 9 Jan 2022 06:03:28 +0100 4 | Subject: [PATCH] lithium: entity.fast_hand_swing 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java 10 | index db5f9ca0cfe9d0d53702b96207bec5e2d95ce6fc..a763db35318b177dc49cabcd283ff913cf831751 100644 11 | --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java 12 | +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java 13 | @@ -2538,6 +2538,8 @@ public abstract class LivingEntity extends Entity implements Attackable { 14 | } 15 | 16 | protected void updateSwingTime() { 17 | + if (!this.swinging && this.swingTime == 0) return; // Mirai 18 | + 19 | int i = this.getCurrentSwingDuration(); 20 | 21 | if (this.swinging) { 22 | -------------------------------------------------------------------------------- /patches/server/0050-lithium-entity.fast_powder_snow_check.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Sat, 8 Jan 2022 03:51:28 +0100 4 | Subject: [PATCH] lithium: entity.fast_powder_snow_check 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java 10 | index fb33e84aa3e6bf660a00c116b9c0c8ea6f2bbf3e..729008cd749b972eea3ff4feb10d5cb3e7f73d58 100644 11 | --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java 12 | +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java 13 | @@ -581,11 +581,11 @@ public abstract class LivingEntity extends Entity implements Attackable { 14 | } 15 | 16 | protected void tryAddFrost() { 17 | - if (!this.getBlockStateOnLegacy().isAir()) { 18 | + //if (!this.getBlockStateOnLegacy().isAir()) { // Mirai 19 | int i = this.getTicksFrozen(); 20 | 21 | if (i > 0) { 22 | - AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED); 23 | + AttributeInstance attributemodifiable = this.getBlockStateOnLegacy().isAir() ? null : this.getAttribute(Attributes.MOVEMENT_SPEED); // Mirai 24 | 25 | if (attributemodifiable == null) { 26 | return; 27 | @@ -595,7 +595,7 @@ public abstract class LivingEntity extends Entity implements Attackable { 28 | 29 | attributemodifiable.addTransientModifier(new AttributeModifier(LivingEntity.SPEED_MODIFIER_POWDER_SNOW_UUID, "Powder snow slow", (double) f, AttributeModifier.Operation.ADDITION)); 30 | } 31 | - } 32 | + //} // Mirai 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /patches/server/0051-lithium-collections.attributes.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Sun, 9 Jan 2022 17:53:11 +0100 4 | Subject: [PATCH] lithium: collections.attributes 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java 10 | index 3087f8359b098682a345399c85395de8a15b6eed..493bd49176dfd0a1d94f425bfd102ab16bfaedc9 100644 11 | --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java 12 | +++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java 13 | @@ -17,11 +17,13 @@ import net.minecraft.nbt.CompoundTag; 14 | import net.minecraft.nbt.ListTag; 15 | import net.minecraft.resources.ResourceLocation; 16 | import org.slf4j.Logger; 17 | +import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; // Mirai 18 | +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; // Mirai 19 | 20 | public class AttributeMap { 21 | private static final Logger LOGGER = LogUtils.getLogger(); 22 | - private final Map attributes = Maps.newHashMap(); 23 | - private final Set dirtyAttributes = Sets.newHashSet(); 24 | + private final Map attributes = new Reference2ReferenceOpenHashMap<>(0); // Mirai 25 | + private final Set dirtyAttributes = new ReferenceOpenHashSet<>(0); // Mirai 26 | private final AttributeSupplier supplier; 27 | private final java.util.function.Function createInstance; // Pufferfish 28 | 29 | -------------------------------------------------------------------------------- /patches/server/0052-lithium-collections.entity_by_type.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Fri, 7 Jan 2022 06:43:30 +0100 4 | Subject: [PATCH] lithium: collections.entity_by_type 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java 10 | index 50a9f33aa31e9273c7c52d4bb2b02f0f884f7ba5..9698c093dd8c18a5a5a4b157c3799191841552e2 100644 11 | --- a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java 12 | +++ b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java 13 | @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList; 14 | import com.google.common.collect.Iterators; 15 | import com.google.common.collect.Lists; 16 | import com.google.common.collect.Maps; 17 | +import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; // JettPack 18 | import java.util.AbstractCollection; 19 | import java.util.Collection; 20 | import java.util.Collections; 21 | @@ -13,7 +14,7 @@ import java.util.Map; 22 | import java.util.stream.Collectors; 23 | 24 | public class ClassInstanceMultiMap extends AbstractCollection { 25 | - private final Map, List> byClass = Maps.newHashMap(); 26 | + private final Map, List> byClass = new Reference2ReferenceOpenHashMap<>(); // JettPack 27 | private final Class baseClass; 28 | private final List allInstances = Lists.newArrayList(); 29 | 30 | @@ -58,7 +59,7 @@ public class ClassInstanceMultiMap extends AbstractCollection { 31 | if (!this.baseClass.isAssignableFrom(type)) { 32 | throw new IllegalArgumentException("Don't know how to search for " + type); 33 | } else { 34 | - List list = this.byClass.computeIfAbsent(type, (typeClass) -> { 35 | + List list = this.byClass.computeIfAbsent(type, (typeClass) -> { // JettPack - decomp fix 36 | return this.allInstances.stream().filter(typeClass::isInstance).collect(Collectors.toList()); 37 | }); 38 | return Collections.unmodifiableCollection(list); 39 | -------------------------------------------------------------------------------- /patches/server/0053-lithium-collections.entity_filtering.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Sat, 8 Jan 2022 03:33:04 +0100 4 | Subject: [PATCH] lithium: collections.entity_filtering 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java 10 | index 9698c093dd8c18a5a5a4b157c3799191841552e2..6f181fc878a96b09f126ea8d3b19ce3ee4588e19 100644 11 | --- a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java 12 | +++ b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java 13 | @@ -56,15 +56,32 @@ public class ClassInstanceMultiMap extends AbstractCollection { 14 | } 15 | 16 | public Collection find(Class type) { 17 | - if (!this.baseClass.isAssignableFrom(type)) { 18 | - throw new IllegalArgumentException("Don't know how to search for " + type); 19 | - } else { 20 | - List list = this.byClass.computeIfAbsent(type, (typeClass) -> { // JettPack - decomp fix 21 | - return this.allInstances.stream().filter(typeClass::isInstance).collect(Collectors.toList()); 22 | - }); 23 | - return Collections.unmodifiableCollection(list); 24 | + // JettPack start 25 | + Collection collection = this.byClass.get(type); 26 | + 27 | + if (collection == null) { 28 | + collection = this.createAllOfType(type); 29 | } 30 | + 31 | + return (Collection) Collections.unmodifiableCollection(collection); 32 | + // JettPack end 33 | + } 34 | + 35 | + // JettPack start 36 | + private Collection createAllOfType(Class type) { 37 | + List list = new java.util.ArrayList<>(); 38 | + 39 | + for (T allElement : this.allInstances) { 40 | + if (type.isInstance(allElement)) { 41 | + list.add(allElement); 42 | + } 43 | + } 44 | + 45 | + this.byClass.put(type, list); 46 | + 47 | + return list; 48 | } 49 | + // JettPack end 50 | 51 | @Override 52 | public Iterator iterator() { 53 | -------------------------------------------------------------------------------- /patches/server/0055-Configurable-criterion-triggers.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Mykyta Komarnytskyy 3 | Date: Sat, 24 Oct 2020 21:08:17 -0500 4 | Subject: [PATCH] Configurable criterion triggers 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | This patch adds toggles for three criterion triggers that are called every tick. These can be very unnecessary, and especially in the case of CriterionTriggerEnterBlock, quite heavy. 10 | 11 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 12 | index 3b7b0a672626ef40f6c1c32e7e87becff4fb5a83..512e57219eb67c184af68740f6f913e837a0cd3c 100644 13 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 14 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 15 | @@ -204,4 +204,16 @@ public class MiraiConfig { 16 | "Whether or not server should animate enchantment table book.", 17 | "Disabling it can save MSPT, especially with quite a lot of enchantment tables."); 18 | } 19 | + 20 | + public static boolean criterionTriggerEnterBlock; 21 | + public static boolean criterionTriggerTick; 22 | + public static boolean criterionTriggerLocation; 23 | + private static void criterionTriggers() { 24 | + criterionTriggerEnterBlock = getBoolean("criterion-trigger.enter-block", true, 25 | + "Whether or not server should listen to block enter triggers."); 26 | + criterionTriggerTick = getBoolean("criterion-trigger.tick", true, 27 | + "Whether or not server should listen to tick triggers."); 28 | + criterionTriggerLocation = getBoolean("criterion-trigger.location", true, 29 | + "Whether or not server should listen to location triggers."); 30 | + } 31 | } 32 | diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java 33 | index 23536c5b10dfdb81e1815fd76e5b937a653160a3..055cc564d69fd4ff4717d137f260f4000d692760 100644 34 | --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java 35 | +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java 36 | @@ -707,7 +707,7 @@ public class ServerPlayer extends Player { 37 | 38 | @Override 39 | protected void onInsideBlock(BlockState state) { 40 | - CriteriaTriggers.ENTER_BLOCK.trigger(this, state); 41 | + if (dev.etil.mirai.MiraiConfig.criterionTriggerEnterBlock) CriteriaTriggers.ENTER_BLOCK.trigger(this, state); // Mirai 42 | } 43 | 44 | @Override 45 | @@ -754,7 +754,7 @@ public class ServerPlayer extends Player { 46 | } 47 | } 48 | 49 | - CriteriaTriggers.TICK.trigger(this); 50 | + if (dev.etil.mirai.MiraiConfig.criterionTriggerTick) CriteriaTriggers.TICK.trigger(this); // Mirai 51 | if (this.levitationStartPos != null) { 52 | CriteriaTriggers.LEVITATION.trigger(this, this.levitationStartPos, this.tickCount - this.levitationStartTime); 53 | } 54 | @@ -830,9 +830,7 @@ public class ServerPlayer extends Player { 55 | this.connection.send(new ClientboundSetExperiencePacket(this.experienceProgress, this.totalExperience, this.experienceLevel)); 56 | } 57 | 58 | - if (this.tickCount % 20 == 0) { 59 | - CriteriaTriggers.LOCATION.trigger(this); 60 | - } 61 | + if (dev.etil.mirai.MiraiConfig.criterionTriggerLocation && this.tickCount % 20 == 0) CriteriaTriggers.LOCATION.trigger(this); // Mirai 62 | 63 | // CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border 64 | if (this.oldLevel == -1) { 65 | -------------------------------------------------------------------------------- /patches/server/0056-Set-item-stuck-sleep-to-15-ticks.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: tr7zw 3 | Date: Fri, 31 Jul 2020 21:48:14 -0500 4 | Subject: [PATCH] Set item stuck sleep to 15 ticks 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java 10 | index a39db702063887cf530f272deaf4f334047cc7d4..b47651547d5009f9f2fdec43360fc4dd474b5d09 100644 11 | --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java 12 | +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java 13 | @@ -168,7 +168,7 @@ public class ItemEntity extends Entity implements TraceableEntity { 14 | 15 | if (this.level().isClientSide) { 16 | this.noPhysics = false; 17 | - } else { 18 | + } else if (!this.onGround || this.noPhysics || this.tickCount % 15 == 0) { // Mirai 19 | this.noPhysics = !this.level().noCollision(this, this.getBoundingBox().deflate(1.0E-7D)); 20 | if (this.noPhysics) { 21 | this.moveTowardsClosestSpace(this.getX(), (this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D, this.getZ()); 22 | -------------------------------------------------------------------------------- /patches/server/0057-Smarter-statistics-ticking.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Mykyta Komarnytskyy 3 | Date: Sat, 24 Oct 2020 21:03:53 -0500 4 | Subject: [PATCH] Smarter statistics ticking 5 | 6 | Original code by YatopiaMC, licensed under MIT 7 | You can find the original code on https://github.com/YatopiaMC/Yatopia 8 | 9 | In vanilla, statistics that count time spent for an action (i.e. time played or sneak time) are incremented every tick. This is retarded. With this patch and a configured interval of 20, the statistics are only ticked every 20th tick and are incremented by 20 ticks at a time. This means a lot less ticking with the same accurate counting. 10 | With an interval of 20, this patch saves roughly 3ms per tick on a server w/ 80 players online. 11 | 12 | diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 13 | index 44a17a8e763455e834dcf488044a0f4907ce346e..daa9490e1e8f6b1475ebfcab5b6afce0ce28243d 100644 14 | --- a/src/main/java/net/minecraft/world/entity/player/Player.java 15 | +++ b/src/main/java/net/minecraft/world/entity/player/Player.java 16 | @@ -276,19 +276,21 @@ public abstract class Player extends LivingEntity { 17 | this.moveCloak(); 18 | if (!this.level().isClientSide) { 19 | this.foodData.tick(this); 20 | - this.awardStat(Stats.PLAY_TIME); 21 | - this.awardStat(Stats.TOTAL_WORLD_TIME); 22 | - if (this.isAlive()) { 23 | - this.awardStat(Stats.TIME_SINCE_DEATH); 24 | - } 25 | - 26 | - if (this.isDiscrete()) { 27 | - this.awardStat(Stats.CROUCH_TIME); 28 | - } 29 | - 30 | - if (!this.isSleeping()) { 31 | - this.awardStat(Stats.TIME_SINCE_REST); 32 | + // Mirai start 33 | + if (tickCount % 20 == 0) { 34 | + this.awardStat(Stats.PLAY_TIME, 20); 35 | + this.awardStat(Stats.TOTAL_WORLD_TIME, 20); 36 | + if (this.isAlive()) { 37 | + this.awardStat(Stats.TIME_SINCE_DEATH, 20); 38 | + } 39 | + if (this.isDiscrete()) { 40 | + this.awardStat(Stats.CROUCH_TIME, 20); 41 | + } 42 | + if (!this.isSleeping()) { 43 | + this.awardStat(Stats.TIME_SINCE_REST, 20); 44 | + } 45 | } 46 | + // Mirai end 47 | } 48 | 49 | int i = 29999999; 50 | -------------------------------------------------------------------------------- /patches/server/0058-some-entity-micro-opts.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Simon Gardling 3 | Date: Fri, 14 Jan 2022 12:00:42 -0500 4 | Subject: [PATCH] some entity micro opts 5 | 6 | Original code by Titaniumtown, licensed under GPL v3 7 | You can find the original code on https://gitlab.com/Titaniumtown/JettPack 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java 10 | index a0f102537ca5c7d88fd96e622431234cbf52dd44..75f31732066edf0887ea8a27c8d5fbecaa37db23 100644 11 | --- a/src/main/java/net/minecraft/world/entity/Entity.java 12 | +++ b/src/main/java/net/minecraft/world/entity/Entity.java 13 | @@ -2034,12 +2034,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 14 | } 15 | } 16 | 17 | + // JettPack start - allow passing BlockPos to getLightLevelDependentMagicValue 18 | /** @deprecated */ 19 | @Deprecated 20 | public float getLightLevelDependentMagicValue() { 21 | - return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ()) ? this.level().getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())) : 0.0F; 22 | + return this.level().getLightLevelDependentMagicValue(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())); 23 | } 24 | 25 | + public float getLightLevelDependentMagicValue(BlockPos pos) { 26 | + return this.level().hasChunkAt(this.getBlockX(), this.getBlockZ()) ? this.level().getLightLevelDependentMagicValue(pos) : 0.0F; 27 | + } 28 | + // JettPack end 29 | + 30 | public void absMoveTo(double x, double y, double z, float yaw, float pitch) { 31 | this.absMoveTo(x, y, z); 32 | this.setYRot(yaw % 360.0F); 33 | @@ -4704,6 +4710,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 34 | LOGGER.error("New entity position is invalid! Tried to set invalid position ({},{},{}) for entity {} located at {}, entity info: {}", newX, newY, newZ, entity.getClass().getName(), entity.position, entityInfo, new Throwable()); 35 | return false; 36 | } 37 | + 38 | + // JettPack start 39 | + public final int getPositionHashCode() { 40 | + return this.position.hashCode(); 41 | + } 42 | + // JettPack end 43 | + 44 | public final void setPosRaw(double x, double y, double z) { 45 | this.setPosRaw(x, y, z, false); 46 | } 47 | diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java 48 | index 423128622d9ab233096b2b0f297b642f6d658869..d404d8d47ca9575a53ce03eb50b9a87eabc33355 100644 49 | --- a/src/main/java/net/minecraft/world/entity/Mob.java 50 | +++ b/src/main/java/net/minecraft/world/entity/Mob.java 51 | @@ -1720,15 +1720,31 @@ public abstract class Mob extends LivingEntity implements Targeting { 52 | 53 | } 54 | 55 | + // JettPack start - cache eye blockpos 56 | + private BlockPos cached_eye_blockpos; 57 | + private int cached_position_hashcode; 58 | + // JettPack end 59 | public boolean isSunBurnTick() { 60 | if (this.level().isDay() && !this.level().isClientSide) { 61 | - float f = this.getLightLevelDependentMagicValue(); 62 | - BlockPos blockposition = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); 63 | + // JettPack start - optimizations and cache eye blockpos 64 | + int positionHashCode = this.getPositionHashCode(); 65 | + if (this.cached_position_hashcode != positionHashCode) { 66 | + this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); 67 | + this.cached_position_hashcode = positionHashCode; 68 | + } 69 | + 70 | + float f = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness 71 | + 72 | + // Check brightness first 73 | + if (f <= 0.5F) return false; 74 | + if (this.random.nextFloat() * 30.0F >= (f - 0.4F) * 2.0F) return false; 75 | + 76 | boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow; 77 | 78 | - if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && !flag && this.level().canSeeSky(blockposition)) { 79 | + if (!flag && this.level().canSeeSky(this.cached_eye_blockpos)) { // JettPack - move brightness checks up 80 | return true; 81 | } 82 | + // JettPack end 83 | } 84 | 85 | return false; 86 | -------------------------------------------------------------------------------- /patches/server/0059-Fast-speed-check.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Jacob 3 | Date: Wed, 19 Jan 2022 16:55:38 -0700 4 | Subject: [PATCH] Fast speed check 5 | 6 | Original code by NFT-Worlds, licensed under GPL v3 7 | You can find the original code on https://github.com/NFT-Worlds/Server 8 | 9 | etil2jz's note: 10 | NFT-Worlds is related to Stellar devs, known for countless paid forks mostly taking open source patches, 11 | doing questionable/buggy ones, and claiming breathtaking performance improvements. Never ever pay for 12 | any of those Spigot forks! 13 | 14 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 15 | index 512e57219eb67c184af68740f6f913e837a0cd3c..870cea7d725059020204234f0c7a3ade440e1965 100644 16 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 17 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 18 | @@ -216,4 +216,11 @@ public class MiraiConfig { 19 | criterionTriggerLocation = getBoolean("criterion-trigger.location", true, 20 | "Whether or not server should listen to location triggers."); 21 | } 22 | + 23 | + public static boolean fastSpeedCheck; 24 | + private static void speedCheck() { 25 | + fastSpeedCheck = getBoolean("fast-speed-check", true, 26 | + "Whether or not server should use a faster method", 27 | + "to check when entity delta movement is null."); 28 | + } 29 | } 30 | diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java 31 | index 75f31732066edf0887ea8a27c8d5fbecaa37db23..94b0eb9f2ec9f23fc6e5667d38809eec13add9d4 100644 32 | --- a/src/main/java/net/minecraft/world/entity/Entity.java 33 | +++ b/src/main/java/net/minecraft/world/entity/Entity.java 34 | @@ -1257,7 +1257,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 35 | } 36 | 37 | this.tryCheckInsideBlocks(); 38 | - float f = this.getBlockSpeedFactor(); 39 | + // NFT-Worlds start 40 | + float f; 41 | + if (dev.etil.mirai.MiraiConfig.fastSpeedCheck) { 42 | + if (this.getDeltaMovement().x == 0 && this.getDeltaMovement().z == 0) { 43 | + f = 1; 44 | + } else { 45 | + f = this.getBlockSpeedFactor(); 46 | + } 47 | + } else { 48 | + f = this.getBlockSpeedFactor(); 49 | + } 50 | + // NFT-Worlds stop 51 | 52 | this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f)); 53 | // Paper start - remove expensive streams from here 54 | -------------------------------------------------------------------------------- /patches/server/0061-lithium-ai.raid.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: jellysquid3 3 | Date: Tue, 18 Jan 2022 10:37:18 -0500 4 | Subject: [PATCH] lithium: ai.raid 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java 10 | index eaa2943b667967f93f28d9d794d702fdaeb670ec..410ba320637ff94c1f318226a588d8ecb92dc45a 100644 11 | --- a/src/main/java/net/minecraft/world/entity/raid/Raid.java 12 | +++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java 13 | @@ -271,7 +271,16 @@ public class Raid { 14 | this.status = Raid.RaidStatus.STOPPED; 15 | } 16 | 17 | + private boolean isBarDirty; // JettPack 18 | public void tick() { 19 | + // JettPack start - lithium: ai.raid 20 | + if (this.isBarDirty) { 21 | + this.raidEvent.setProgress(Mth.clamp(this.getHealthOfLivingRaiders() / this.totalHealth, 0.0F, 1.0F)); 22 | + 23 | + this.isBarDirty = false; 24 | + } 25 | + // JettPack end 26 | + 27 | if (!this.isStopped()) { 28 | if (this.status == Raid.RaidStatus.ONGOING) { 29 | boolean flag = this.active; 30 | @@ -642,7 +651,7 @@ public class Raid { 31 | } 32 | 33 | public void updateBossbar() { 34 | - this.raidEvent.setProgress(Mth.clamp(this.getHealthOfLivingRaiders() / this.totalHealth, 0.0F, 1.0F)); 35 | + this.isBarDirty = true; // JettPack - lithium: ai.raid 36 | } 37 | 38 | public float getHealthOfLivingRaiders() { 39 | diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java 40 | index cdbc925ef61b8b439415f0a89368227890bcecb2..b345aa9e407692301200af4fa7c2c087578c59ea 100644 41 | --- a/src/main/java/net/minecraft/world/entity/raid/Raider.java 42 | +++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java 43 | @@ -46,8 +46,9 @@ import net.minecraft.world.phys.Vec3; 44 | public abstract class Raider extends PatrollingMonster { 45 | 46 | protected static final EntityDataAccessor IS_CELEBRATING = SynchedEntityData.defineId(Raider.class, EntityDataSerializers.BOOLEAN); 47 | + public static final ItemStack CACHED_OMINOUS_BANNER = Raid.getLeaderBannerInstance(); // JettPack - lithium: ai.raid 48 | static final Predicate ALLOWED_ITEMS = (entityitem) -> { 49 | - return !entityitem.hasPickUpDelay() && entityitem.isAlive() && ItemStack.matches(entityitem.getItem(), Raid.getLeaderBannerInstance()); 50 | + return !entityitem.hasPickUpDelay() && entityitem.isAlive() && ItemStack.matches(entityitem.getItem(), CACHED_OMINOUS_BANNER); // JettPack - lithium: ai.raid 51 | }; 52 | @Nullable 53 | protected Raid raid; 54 | @@ -149,7 +150,7 @@ public abstract class Raider extends PatrollingMonster { 55 | } 56 | } 57 | 58 | - if (!itemstack.isEmpty() && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance()) && entityhuman != null) { 59 | + if (!itemstack.isEmpty() && ItemStack.matches(itemstack, CACHED_OMINOUS_BANNER) && entityhuman != null) { // JettPack - lithium: ai.raid 60 | MobEffectInstance mobeffect = entityhuman.getEffect(MobEffects.BAD_OMEN); 61 | byte b0 = 1; 62 | int i; 63 | @@ -311,6 +312,7 @@ public abstract class Raider extends PatrollingMonster { 64 | public class ObtainRaidLeaderBannerGoal extends Goal { 65 | 66 | private final T mob; 67 | + private static final ItemStack CACHED_OMINOUS_BANNER = Raid.getLeaderBannerInstance(); // JettPack 68 | 69 | public ObtainRaidLeaderBannerGoal(T entityraider) { // CraftBukkit - decompile error 70 | this.mob = entityraider; 71 | @@ -322,7 +324,7 @@ public abstract class Raider extends PatrollingMonster { 72 | if (!this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || !this.mob.canPickUpLoot()) return false; // Paper - respect game and entity rules for picking up items 73 | Raid raid = this.mob.getCurrentRaid(); 74 | 75 | - if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), Raid.getLeaderBannerInstance())) { 76 | + if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), CACHED_OMINOUS_BANNER)) { // JettPack - lithium: ai.raid 77 | Raider entityraider = raid.getLeader(this.mob.getWave()); 78 | 79 | if (entityraider == null || !entityraider.isAlive()) { 80 | -------------------------------------------------------------------------------- /patches/server/0064-vmp-use-linked-map-for-entity-trackers-for-faster-it.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: ishland 3 | Date: Sat, 12 Mar 2022 16:03:35 +0100 4 | Subject: [PATCH] vmp: use linked map for entity trackers for faster iteration 5 | 6 | Original code by RelativityMC, licensed under MIT 7 | You can find the original code on https://github.com/RelativityMC/VMP-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java 10 | index da1dc26ce76cab20bb56d5a5d806410857f38ea6..78101db03353529ade85b67d12851daea34d3cb5 100644 11 | --- a/src/main/java/net/minecraft/server/level/ChunkMap.java 12 | +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java 13 | @@ -107,6 +107,8 @@ import org.slf4j.Logger; 14 | import org.bukkit.craftbukkit.generator.CustomChunkGenerator; 15 | // CraftBukkit end 16 | 17 | +import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap; // Mirai - vmp: use linked map for entity trackers for faster iteration 18 | + 19 | public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider { 20 | 21 | private static final byte CHUNK_TYPE_REPLACEABLE = -1; 22 | @@ -251,7 +253,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider 23 | // Paper - rewrite chunk system 24 | this.tickingGenerated = new AtomicInteger(); 25 | this.playerMap = new PlayerMap(); 26 | - this.entityMap = new Int2ObjectOpenHashMap(); 27 | + this.entityMap = new Int2ObjectLinkedOpenHashMap<>(); // Mirai - vmp: use linked map for entity trackers for faster iteration 28 | this.chunkTypeCache = new Long2ByteOpenHashMap(); 29 | this.chunkSaveCooldowns = new Long2LongOpenHashMap(); 30 | this.unloadQueue = Queues.newConcurrentLinkedQueue(); 31 | -------------------------------------------------------------------------------- /patches/server/0066-lithium-ai.sensor.secondary_poi.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: 2No2Name <2No2Name@web.de> 3 | Date: Tue, 15 Mar 2022 07:14:26 +0100 4 | Subject: [PATCH] lithium: ai.sensor.secondary_poi 5 | 6 | Original code by CaffeineMC, licensed under LGPL v3 7 | You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java 10 | index cb1d91f9fe98f21c2afbe3894dfd9bca3bdd3ba6..d3f1a26cf3b68d85b8d8daef73730f5c4af76cf1 100644 11 | --- a/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java 12 | +++ b/src/main/java/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java 13 | @@ -22,6 +22,12 @@ public class SecondaryPoiSensor extends Sensor { 14 | 15 | @Override 16 | protected void doTick(ServerLevel world, Villager entity) { 17 | + // Mirai start - lithium: ai.sensor.secondary_poi 18 | + if (entity.getVillagerData().getProfession().secondaryPoi().isEmpty()) { 19 | + entity.getBrain().eraseMemory(MemoryModuleType.SECONDARY_JOB_SITE); 20 | + return; 21 | + } 22 | + // Mirai end 23 | ResourceKey resourceKey = world.dimension(); 24 | BlockPos blockPos = entity.blockPosition(); 25 | List list = Lists.newArrayList(); 26 | -------------------------------------------------------------------------------- /patches/server/0068-Fix-hunger-saturation-depleting-on-peaceful.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: etil2jz <81570777+etil2jz@users.noreply.github.com> 3 | Date: Fri, 22 Apr 2022 18:50:49 +0200 4 | Subject: [PATCH] Fix hunger saturation depleting on peaceful 5 | 6 | The food saturation value is depleted on peaceful, even though 7 | the displayed hunger bar never goes down. Hunger (or any related value, including saturation) 8 | should not go down on peaceful. See https://bugs.mojang.com/browse/MC-31819. 9 | 10 | diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 11 | index daa9490e1e8f6b1475ebfcab5b6afce0ce28243d..263add99b628338cc319f5dbf94152c866aad8ba 100644 12 | --- a/src/main/java/net/minecraft/world/entity/player/Player.java 13 | +++ b/src/main/java/net/minecraft/world/entity/player/Player.java 14 | @@ -1866,6 +1866,7 @@ public abstract class Player extends LivingEntity { 15 | } 16 | 17 | public void causeFoodExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) { 18 | + if (this.level().getDifficulty() == Difficulty.PEACEFUL) return; // Mirai - fix hunger saturation depleting on peaceful 19 | // CraftBukkit end 20 | if (!this.abilities.invulnerable) { 21 | if (!this.level().isClientSide) { 22 | -------------------------------------------------------------------------------- /patches/server/0069-Fix-mobs-attacking-themselves.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: etil2jz <81570777+etil2jz@users.noreply.github.com> 3 | Date: Fri, 29 Apr 2022 12:08:22 +0200 4 | Subject: [PATCH] Fix mobs attacking themselves 5 | 6 | If an entity is provoked by a second one using commands, 7 | the second will join in the fight against itself, 8 | causing it to attack itself repeatedly. See https://bugs.mojang.com/browse/MC-110386. 9 | 10 | diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java 11 | index 80ef4b6649da3049f21624926fa38595d76c5da5..92982ebb6423d479f06d80632167931508ef053c 100644 12 | --- a/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java 13 | +++ b/src/main/java/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java 14 | @@ -114,6 +114,7 @@ public class HurtByTargetGoal extends TargetGoal { 15 | } 16 | 17 | protected void alertOther(Mob mob, LivingEntity target) { 18 | + if (mob == target) return; // Mirai - avoid entities with suicidal thoughts /s 19 | mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /patches/server/0070-Fix-brewing-stands-resetting-their-brewTime-when-bei.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: etil2jz <81570777+etil2jz@users.noreply.github.com> 3 | Date: Sun, 8 May 2022 16:34:27 +0200 4 | Subject: [PATCH] Fix brewing stands resetting their brewTime when being 5 | unloaded 6 | 7 | 8 | diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java 9 | index c57efcb9a79337ec791e4e8f6671612f0a82b441..111b9bfac0aafa0170c6e273662c4635963a0d34 100644 10 | --- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java 11 | +++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java 12 | @@ -301,6 +301,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements 13 | ContainerHelper.loadAllItems(nbt, this.items); 14 | this.brewTime = nbt.getShort("BrewTime"); 15 | this.fuel = nbt.getByte("Fuel"); 16 | + this.ingredient = net.minecraft.core.registries.BuiltInRegistries.ITEM.get(new net.minecraft.resources.ResourceLocation(nbt.getString("Mirai.ingredient"))); // Mirai - fix brewing stands resetting their brewTime when being unloaded 17 | } 18 | 19 | @Override 20 | @@ -309,6 +310,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements 21 | nbt.putShort("BrewTime", (short) this.brewTime); 22 | ContainerHelper.saveAllItems(nbt, this.items); 23 | nbt.putByte("Fuel", (byte) this.fuel); 24 | + nbt.putString("Mirai.ingredient", net.minecraft.core.registries.BuiltInRegistries.ITEM.getKey(this.ingredient).toString()); // Mirai - fix brewing stands resetting their brewTime when being unloaded 25 | } 26 | 27 | @Override 28 | -------------------------------------------------------------------------------- /patches/server/0072-Save-Json-list-asynchronously.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?= 3 | 4 | Date: Thu, 2 Apr 2020 11:16:18 +0800 5 | Subject: [PATCH] Save Json list asynchronously 6 | 7 | Original code by Akarin-project, licensed under GPL v3 8 | You can find the original code on https://github.com/Akarin-project/Akarin 9 | 10 | diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java 11 | index 7eec181fb3ffed4dfb6d254350b7e0cb6bacddbe..d57f19409b5b7e4d81a6bb3748824695fdbe7dc5 100644 12 | --- a/src/main/java/net/minecraft/server/players/StoredUserList.java 13 | +++ b/src/main/java/net/minecraft/server/players/StoredUserList.java 14 | @@ -106,6 +106,7 @@ public abstract class StoredUserList> { 15 | } 16 | 17 | public void save() throws IOException { 18 | + Runnable runnable = () -> { // Akarin - Save json list async 19 | this.removeExpired(); // Paper - remove expired values before saving 20 | JsonArray jsonarray = new JsonArray(); 21 | // Yatopia start - Stop wasting resources on JsonList#get 22 | @@ -124,6 +125,7 @@ public abstract class StoredUserList> { 23 | jsonarray.add(obj); 24 | } 25 | // Yatopia end 26 | + try { 27 | BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); 28 | 29 | try { 30 | @@ -143,6 +145,11 @@ public abstract class StoredUserList> { 31 | if (bufferedwriter != null) { 32 | bufferedwriter.close(); 33 | } 34 | + } catch (IOException e) { 35 | + StoredUserList.LOGGER.warn("Failed to async save " + this.file, e); // Akarin - Save json list async 36 | + } 37 | + }; // Akarin - Save json list async 38 | + io.papermc.paper.util.MCUtil.scheduleAsyncTask(runnable); // Akarin - Save json list async 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /patches/server/0073-Swaps-the-predicate-order-of-collision.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?= 3 | 4 | Date: Fri, 10 Apr 2020 15:47:15 +0800 5 | Subject: [PATCH] Swaps the predicate order of collision 6 | 7 | Original code by Akarin-project, licensed under GPL v3 8 | You can find the original code on https://github.com/Akarin-project/Akarin 9 | 10 | diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java 11 | index 94b0eb9f2ec9f23fc6e5667d38809eec13add9d4..2fa030f9523361f2740c85799cc5689542d8d8c2 100644 12 | --- a/src/main/java/net/minecraft/world/entity/Entity.java 13 | +++ b/src/main/java/net/minecraft/world/entity/Entity.java 14 | @@ -2151,8 +2151,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S 15 | public void playerTouch(Player player) {} 16 | 17 | public void push(Entity entity) { 18 | + if (entity.noPhysics || this.noPhysics) return; // Akarin - Test this earlier 19 | if (!this.isPassengerOfSameVehicle(entity)) { 20 | - if (!entity.noPhysics && !this.noPhysics) { 21 | + if (true || !entity.noPhysics && !this.noPhysics) { // Akarin - Moved up 22 | if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper - Collision option for requiring a player participant 23 | double d0 = entity.getX() - this.getX(); 24 | double d1 = entity.getZ() - this.getZ(); 25 | -------------------------------------------------------------------------------- /patches/server/0074-Cache-block-break-animation-packet.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: VytskaLT 3 | Date: Sat, 17 Apr 2021 10:43:08 +0300 4 | Subject: [PATCH] Cache block break animation packet 5 | 6 | Original code by Electroid, licensed under GPL v3 7 | You can find the original code on https://github.com/Electroid/SportPaper 8 | 9 | diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java 10 | index f4d4f466c223cb0471e9d995b73df6d43742c1c6..2669313303077c83aec31df36cd807bcf65b90ed 100644 11 | --- a/src/main/java/net/minecraft/server/level/ServerLevel.java 12 | +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java 13 | @@ -1788,6 +1788,7 @@ public class ServerLevel extends Level implements WorldGenLevel { 14 | if (entity instanceof Player) entityhuman = (Player) entity; 15 | // CraftBukkit end 16 | 17 | + ClientboundBlockDestructionPacket packet = null; // SportPaper - Cache block break animation packet 18 | while (iterator.hasNext()) { 19 | ServerPlayer entityplayer = (ServerPlayer) iterator.next(); 20 | 21 | @@ -1803,7 +1804,10 @@ public class ServerLevel extends Level implements WorldGenLevel { 22 | // CraftBukkit end 23 | 24 | if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { 25 | - entityplayer.connection.send(new ClientboundBlockDestructionPacket(entityId, pos, progress)); 26 | + // SportPaper start 27 | + if (packet == null) packet = new ClientboundBlockDestructionPacket(entityId, pos, progress); 28 | + entityplayer.connection.send(packet); 29 | + // SportPaper end 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /patches/server/0075-Use-more-fastutil-data-structures.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: nopjmp 3 | Date: Mon, 20 Dec 2021 19:16:11 -0600 4 | Subject: [PATCH] Use more fastutil data structures 5 | 6 | Original code by nopjmp, licensed under MIT 7 | You can find the original code on https://github.com/nopjmp/Dionysus 8 | 9 | diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java 10 | index a53dd1ea02bd19826cd9fd337459b08e9533bce8..d4fcb40c84f70f8a86e19651e4068ea61db39a10 100644 11 | --- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java 12 | +++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java 13 | @@ -3,7 +3,6 @@ package net.minecraft.server.network; 14 | import net.minecraft.SharedConstants; 15 | import net.minecraft.network.Connection; 16 | import net.minecraft.network.chat.Component; 17 | -import net.minecraft.network.chat.MutableComponent; 18 | import net.minecraft.network.protocol.handshake.ClientIntent; 19 | import net.minecraft.network.protocol.handshake.ClientIntentionPacket; 20 | import net.minecraft.network.protocol.handshake.ServerHandshakePacketListener; 21 | @@ -13,8 +12,8 @@ import net.minecraft.server.MinecraftServer; 22 | 23 | // CraftBukkit start 24 | import java.net.InetAddress; 25 | -import java.util.HashMap; 26 | // CraftBukkit end 27 | +import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; // Dionysus 28 | 29 | public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketListener { 30 | 31 | @@ -24,7 +23,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL 32 | static final java.util.regex.Pattern PROP_PATTERN = java.util.regex.Pattern.compile("\\w{0,16}"); 33 | // Spigot end 34 | // CraftBukkit start - add fields 35 | - private static final HashMap throttleTracker = new HashMap(); 36 | + private static final Object2LongOpenHashMap throttleTracker = new Object2LongOpenHashMap<>(); // Dionysus 37 | private static int throttleCounter = 0; 38 | // CraftBukkit end 39 | private static final Component IGNORE_STATUS_REASON = Component.translatable("disconnect.ignoring_status_request"); 40 | @@ -51,7 +50,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL 41 | InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); 42 | 43 | synchronized (ServerHandshakePacketListenerImpl.throttleTracker) { 44 | - if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) { 45 | + if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.getLong(address) < connectionThrottle) { // Dionysus 46 | ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime); 47 | Component chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle); // Paper - Configurable connection throttle kick message 48 | this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); 49 | @@ -65,13 +64,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL 50 | ServerHandshakePacketListenerImpl.throttleCounter = 0; 51 | 52 | // Cleanup stale entries 53 | - java.util.Iterator iter = ServerHandshakePacketListenerImpl.throttleTracker.entrySet().iterator(); 54 | - while (iter.hasNext()) { 55 | - java.util.Map.Entry entry = (java.util.Map.Entry) iter.next(); 56 | - if (entry.getValue() > connectionThrottle) { 57 | - iter.remove(); 58 | - } 59 | - } 60 | + ServerHandshakePacketListenerImpl.throttleTracker.object2LongEntrySet().removeIf(entry -> entry.getLongValue() > connectionThrottle); // Dionysus 61 | } 62 | } 63 | } // Paper - Unix domain socket support 64 | -------------------------------------------------------------------------------- /patches/server/0077-Faster-Sheep.getOffspringColor.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: etil2jz <81570777+etil2jz@users.noreply.github.com> 3 | Date: Wed, 29 Jun 2022 02:49:45 +0200 4 | Subject: [PATCH] Faster Sheep.getOffspringColor 5 | 6 | Original code by fxmorin, licensed under MIT 7 | You can find the original code on https://github.com/fxmorin/carpet-fixes (Yarn mappings) 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/animal/Sheep.java b/src/main/java/net/minecraft/world/entity/animal/Sheep.java 10 | index 1d80678f7e8f658e43616f0baf723f096a99122a..b5318186a2847a2775c85e2bb9634faa1bd61860 100644 11 | --- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java 12 | +++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java 13 | @@ -418,21 +418,56 @@ public class Sheep extends Animal implements Shearable { 14 | return super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt); 15 | } 16 | 17 | + // Mirai start 18 | + private static DyeColor properDye(DyeColor firstColor, DyeColor secondColor) { 19 | + if (firstColor.equals(secondColor)) return firstColor; 20 | + switch (firstColor) { 21 | + case WHITE -> { 22 | + switch (secondColor) { 23 | + case BLUE -> {return DyeColor.LIGHT_BLUE;} 24 | + case GRAY -> {return DyeColor.LIGHT_GRAY;} 25 | + case BLACK -> {return DyeColor.GRAY;} 26 | + case GREEN -> {return DyeColor.LIME;} 27 | + case RED -> {return DyeColor.PINK;} 28 | + } 29 | + } 30 | + case BLUE -> { 31 | + switch (secondColor) { 32 | + case WHITE -> {return DyeColor.LIGHT_BLUE;} 33 | + case GREEN -> {return DyeColor.CYAN;} 34 | + case RED -> {return DyeColor.PURPLE;} 35 | + } 36 | + } 37 | + case RED -> { 38 | + switch (secondColor) { 39 | + case YELLOW -> {return DyeColor.ORANGE;} 40 | + case WHITE -> {return DyeColor.PINK;} 41 | + case BLUE -> {return DyeColor.PURPLE;} 42 | + } 43 | + } 44 | + case GREEN -> { 45 | + switch (secondColor) { 46 | + case BLUE -> {return DyeColor.CYAN;} 47 | + case WHITE -> {return DyeColor.LIME;} 48 | + } 49 | + } 50 | + case YELLOW -> {if (secondColor.equals(DyeColor.RED)) return DyeColor.ORANGE;} 51 | + case PURPLE -> {if (secondColor.equals(DyeColor.PINK)) return DyeColor.MAGENTA;} 52 | + case PINK -> {if (secondColor.equals(DyeColor.PURPLE)) return DyeColor.MAGENTA;} 53 | + case GRAY -> {if (secondColor.equals(DyeColor.WHITE)) return DyeColor.LIGHT_GRAY;} 54 | + case BLACK -> {if (secondColor.equals(DyeColor.WHITE)) return DyeColor.GRAY;} 55 | + } 56 | + return null; 57 | + } 58 | + 59 | private DyeColor getOffspringColor(Animal firstParent, Animal secondParent) { 60 | - DyeColor enumcolor = ((Sheep) firstParent).getColor(); 61 | - DyeColor enumcolor1 = ((Sheep) secondParent).getColor(); 62 | - CraftingContainer inventorycrafting = Sheep.makeContainer(enumcolor, enumcolor1); 63 | - Optional optional = this.level().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error 64 | - return ((CraftingRecipe) recipeholder.value()).assemble(inventorycrafting, this.level().registryAccess()); 65 | - }).map(ItemStack::getItem); 66 | - 67 | - Objects.requireNonNull(DyeItem.class); 68 | - optional = optional.filter(DyeItem.class::isInstance); 69 | - Objects.requireNonNull(DyeItem.class); 70 | - return (DyeColor) optional.map(DyeItem.class::cast).map(DyeItem::getDyeColor).orElseGet(() -> { 71 | - return this.level().random.nextBoolean() ? enumcolor : enumcolor1; 72 | - }); 73 | + DyeColor firstColor = ((Sheep) firstParent).getColor(); 74 | + DyeColor secondColor = ((Sheep) secondParent).getColor(); 75 | + DyeColor col = properDye(firstColor, secondColor); 76 | + if (col == null) col = this.level().random.nextBoolean() ? firstColor : secondColor; 77 | + return col; 78 | } 79 | + // Mirai end 80 | 81 | private static CraftingContainer makeContainer(DyeColor firstColor, DyeColor secondColor) { 82 | TransientCraftingContainer transientcraftingcontainer = new TransientCraftingContainer(new AbstractContainerMenu((MenuType) null, -1) { 83 | -------------------------------------------------------------------------------- /patches/server/0081-reduce-sensor-work.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: peaches94 3 | Date: Sun, 10 Jul 2022 15:44:38 -0500 4 | Subject: [PATCH] reduce sensor work 5 | 6 | Original code by Bloom-host, licensed under GPL v3 7 | You can find the original code on https://github.com/Bloom-host/Petal 8 | 9 | this patch is focused around the sensors used for ai 10 | delete the line of sight cache less often and use a faster nearby comparison 11 | 12 | diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java 13 | index c4d2359e3a3953158cea6addcb226a0e7beff8ea..a14ac795a71d4fdec8e756b990a36705957b7aa6 100644 14 | --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java 15 | +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java 16 | @@ -1024,12 +1024,14 @@ public abstract class LivingEntity extends Entity implements Attackable { 17 | } 18 | 19 | if (entity != null) { 20 | - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); 21 | + // petal start - only do itemstack lookup if we need to 22 | + //ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); 23 | EntityType entitytypes = entity.getType(); 24 | 25 | - if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL) || entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD) || entitytypes == EntityType.PIGLIN && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.PIGLIN_BRUTE && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) { 26 | + if (entitytypes == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL) || entitytypes == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD) || entitytypes == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) { 27 | d0 *= 0.5D; 28 | } 29 | + // petal end 30 | } 31 | 32 | return d0; 33 | diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java 34 | index d404d8d47ca9575a53ce03eb50b9a87eabc33355..d5ea89212adffd2321fa167d08278c24898a182b 100644 35 | --- a/src/main/java/net/minecraft/world/entity/Mob.java 36 | +++ b/src/main/java/net/minecraft/world/entity/Mob.java 37 | @@ -907,10 +907,10 @@ public abstract class Mob extends LivingEntity implements Targeting { 38 | return; 39 | } 40 | // Paper end - Allow nerfed mobs to jump and float 41 | + int i = this.level().getServer().getTickCount() + this.getId(); // petal - move up 42 | this.level().getProfiler().push("sensing"); 43 | - this.sensing.tick(); 44 | + if (i % 10 == 0) this.sensing.tick(); // petal - only refresh line of sight cache every half second 45 | this.level().getProfiler().pop(); 46 | - int i = this.level().getServer().getTickCount() + this.getId(); 47 | 48 | if (i % 2 != 0 && this.tickCount > 1) { 49 | this.level().getProfiler().push("targetSelector"); 50 | -------------------------------------------------------------------------------- /patches/server/0083-Fix-MC-238526.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: etil2jz <81570777+etil2jz@users.noreply.github.com> 3 | Date: Mon, 8 Aug 2022 11:21:49 +0200 4 | Subject: [PATCH] Fix MC-238526 5 | 6 | 7 | diff --git a/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java b/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java 8 | index 9b897cf53f4bb5d366e6ac88dbed93c59d8fe541..14fece98ed3ea7c0ddd6fece4b6da1aebf01ef40 100644 9 | --- a/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java 10 | +++ b/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java 11 | @@ -77,6 +77,6 @@ public abstract class WaterAnimal extends PathfinderMob { 12 | i = world.getMinecraftWorld().paperConfig().entities.spawning.wateranimalSpawnHeight.maximum.or(i); 13 | j = world.getMinecraftWorld().paperConfig().entities.spawning.wateranimalSpawnHeight.minimum.or(j); 14 | // Paper end - Make water animal spawn height configurable 15 | - return pos.getY() >= j && pos.getY() <= i && world.getFluidState(pos.below()).is(FluidTags.WATER) && world.getBlockState(pos.above()).is(Blocks.WATER); 16 | + return ((reason == MobSpawnType.SPAWNER) || (pos.getY() >= j && pos.getY() <= i)) && world.getFluidState(pos.below()).is(FluidTags.WATER) && world.getBlockState(pos.above()).is(Blocks.WATER); // Mirai 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /patches/server/0086-Smooth-Teleports.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Cryptite 3 | Date: Sat, 13 Aug 2022 08:58:14 -0500 4 | Subject: [PATCH] Smooth Teleports 5 | 6 | Original code by Cryptite, licensed under MIT 7 | You can find the original code on https://github.com/Cryptite/Slice 8 | 9 | diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java 10 | index 60073e8e74cb44a76a952bfe10b6ac24e24cf152..0c5e18d314733920a1b7b4a56d29293a69b1d7c5 100644 11 | --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java 12 | +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java 13 | @@ -281,6 +281,7 @@ public class ServerPlayer extends Player { 14 | public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent 15 | public @Nullable String clientBrandName = null; // Paper - Brand support 16 | public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event 17 | + public boolean smoothWorldTeleport; // Slice 18 | 19 | // Paper start - replace player chunk loader 20 | private final java.util.concurrent.atomic.AtomicReference viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1)); 21 | diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java 22 | index a002aa85eadd0bcd004fe8f47e7e68c82d8652a8..814d0aa44f25d5e2256b991347daee1239fce6ac 100644 23 | --- a/src/main/java/net/minecraft/server/players/PlayerList.java 24 | +++ b/src/main/java/net/minecraft/server/players/PlayerList.java 25 | @@ -956,10 +956,10 @@ public abstract class PlayerList { 26 | ServerLevel worldserver2 = entityplayer1.serverLevel(); 27 | LevelData worlddata = worldserver2.getLevelData(); 28 | 29 | - entityplayer1.connection.send(new ClientboundRespawnPacket(entityplayer1.createCommonSpawnInfo(worldserver2), (byte) i)); 30 | + if (!entityplayer.smoothWorldTeleport) entityplayer1.connection.send(new ClientboundRespawnPacket(entityplayer1.createCommonSpawnInfo(worldserver2), (byte) i)); // Slice 31 | entityplayer1.connection.send(new ClientboundSetChunkCacheRadiusPacket(worldserver1.getWorld().getSendViewDistance())); // Spigot // Paper - replace old player chunk management 32 | entityplayer1.connection.send(new ClientboundSetSimulationDistancePacket(worldserver1.getWorld().getSimulationDistance())); // Spigot // Paper - replace old player chunk management 33 | - entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver2.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit 34 | + if (!entityplayer.smoothWorldTeleport) entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver2.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit // Slice 35 | entityplayer1.connection.send(new ClientboundSetDefaultSpawnPositionPacket(worldserver1.getSharedSpawnPos(), worldserver1.getSharedSpawnAngle())); 36 | entityplayer1.connection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); 37 | entityplayer1.connection.send(new ClientboundSetExperiencePacket(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel)); 38 | diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java 39 | index 39b25c2478eadd373383a3445a7f27ea30d18550..fed596e3a93920a10737557fc84384d53abf2b43 100644 40 | --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java 41 | +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java 42 | @@ -1225,6 +1225,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { 43 | // Paper end 44 | } 45 | 46 | + // Slice start 47 | + public void teleportWithoutRespawn(Location location) { 48 | + ServerPlayer serverPlayer = getHandle(); 49 | + serverPlayer.smoothWorldTeleport = true; 50 | + teleport(location); 51 | + serverPlayer.smoothWorldTeleport = false; 52 | + } 53 | + // Slice end 54 | + 55 | @Override 56 | public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) { 57 | // Paper start - Teleport API 58 | -------------------------------------------------------------------------------- /patches/server/0087-Don-t-double-save-the-json-lists.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: PureGero 3 | Date: Sun, 27 Feb 2022 19:21:10 +1000 4 | Subject: [PATCH] Don't double save the json lists 5 | 6 | Original code by MultiPaper, licensed under GPL v3 7 | You can find the original code on https://github.com/MultiPaper/MultiPaper 8 | 9 | diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java 10 | index 935dac757280731bfeb0a8f033cbe315ecac46da..ea8b84758cf7cc2b8394467481a175dc3ef9e507 100644 11 | --- a/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java 12 | +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java 13 | @@ -45,13 +45,13 @@ public class DedicatedPlayerList extends PlayerList { 14 | @Override 15 | public void op(GameProfile profile) { 16 | super.op(profile); 17 | - this.saveOps(); 18 | + // this.saveOps(); // MultiPaper - don't double save the op list 19 | } 20 | 21 | @Override 22 | public void deop(GameProfile profile) { 23 | super.deop(profile); 24 | - this.saveOps(); 25 | + // this.saveOps(); // MultiPaper - don't double save the op list 26 | } 27 | 28 | @Override 29 | -------------------------------------------------------------------------------- /patches/server/0088-Don-t-wander-into-non-ticking-chunks.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: PureGero 3 | Date: Thu, 14 Apr 2022 10:58:25 +1000 4 | Subject: [PATCH] Don't wander into non-ticking chunks 5 | 6 | Original code by MultiPaper, licensed under GPL v3 7 | You can find the original code on https://github.com/MultiPaper/MultiPaper 8 | 9 | diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java 10 | index 676e1580849e8942eb41c7a3a80f464138b22764..9e527884c154c968ae0c93cb4282ea06f8ca3a24 100644 11 | --- a/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java 12 | +++ b/src/main/java/net/minecraft/world/entity/ai/goal/RandomStrollGoal.java 13 | @@ -2,6 +2,9 @@ package net.minecraft.world.entity.ai.goal; 14 | 15 | import java.util.EnumSet; 16 | import javax.annotation.Nullable; 17 | + 18 | +import net.minecraft.core.BlockPos; 19 | +import net.minecraft.server.level.ServerLevel; 20 | import net.minecraft.world.entity.PathfinderMob; 21 | import net.minecraft.world.entity.ai.util.DefaultRandomPos; 22 | import net.minecraft.world.phys.Vec3; 23 | @@ -49,7 +52,7 @@ public class RandomStrollGoal extends Goal { 24 | } 25 | 26 | Vec3 vec3 = this.getPosition(); 27 | - if (vec3 == null) { 28 | + if (vec3 == null || !((ServerLevel) this.mob.level()).isPositionEntityTicking(BlockPos.containing(vec3))) { // MultiPaper - don't wander into non-ticking chunks 29 | return false; 30 | } else { 31 | this.wantedX = vec3.x; 32 | diff --git a/src/main/java/net/minecraft/world/entity/animal/Squid.java b/src/main/java/net/minecraft/world/entity/animal/Squid.java 33 | index f60c4cd0543fd5d50fa7e2c1a9e8381227adb540..0d6b4971e73cc1cc5ff54fa48d5ef18b14f8db89 100644 34 | --- a/src/main/java/net/minecraft/world/entity/animal/Squid.java 35 | +++ b/src/main/java/net/minecraft/world/entity/animal/Squid.java 36 | @@ -135,6 +135,7 @@ public class Squid extends WaterAnimal { 37 | } 38 | 39 | if (!this.level().isClientSide) { 40 | + if ((tx != 0 || ty != 0 || tz != 0) && !((ServerLevel) this.level()).isPositionEntityTicking(BlockPos.containing(position().add(tx, ty, tz)))) tx = ty = tz = 0; // MultiPaper - don't allow squids to wander into non-ticking chunks 41 | this.setDeltaMovement((double)(this.tx * this.speed), (double)(this.ty * this.speed), (double)(this.tz * this.speed)); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /patches/server/0089-Optimize-CraftServer.getWorld-UUID.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: PureGero 3 | Date: Sun, 26 Jun 2022 11:17:27 +1000 4 | Subject: [PATCH] Optimize CraftServer.getWorld(UUID) 5 | 6 | Original code by MultiPaper, licensed under GPL v3 7 | You can find the original code on https://github.com/MultiPaper/MultiPaper 8 | 9 | diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java 10 | index 363d30bf7a961157b335f8eba3079a49e6b05942..172aa3b9a4e33be14910b8016bbf9f3a83d1785f 100644 11 | --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java 12 | +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java 13 | @@ -43,6 +43,8 @@ import java.util.logging.Logger; 14 | import java.util.stream.Collectors; 15 | import javax.imageio.ImageIO; 16 | // import jline.console.ConsoleReader; 17 | + 18 | +import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; 19 | import net.minecraft.advancements.AdvancementHolder; 20 | import net.minecraft.commands.CommandSourceStack; 21 | import net.minecraft.commands.Commands; 22 | @@ -279,6 +281,7 @@ public final class CraftServer implements Server { 23 | protected final DedicatedServer console; 24 | protected final DedicatedPlayerList playerList; 25 | private final Map worlds = new LinkedHashMap(); 26 | + private final Map worldsByUUID = new Object2ObjectLinkedOpenHashMap<>(); // MultiPaper - optimize getWorld(UUID) 27 | private final Map, Registry> registries = new HashMap<>(); 28 | private YamlConfiguration configuration; 29 | private YamlConfiguration commandsConfiguration; 30 | @@ -1444,6 +1447,7 @@ public final class CraftServer implements Server { 31 | this.getLogger().log(Level.SEVERE, null, ex); 32 | } 33 | 34 | + this.worldsByUUID.remove(world.getUID()); // MultiPaper - optimize getWorld(UUID) 35 | this.worlds.remove(world.getName().toLowerCase(java.util.Locale.ENGLISH)); 36 | this.console.removeLevel(handle); 37 | return true; 38 | @@ -1462,6 +1466,7 @@ public final class CraftServer implements Server { 39 | 40 | @Override 41 | public World getWorld(UUID uid) { 42 | + if (true) return this.worldsByUUID.get(uid); // MultiPaper - optimize getWorld(UUID) 43 | for (World world : this.worlds.values()) { 44 | if (world.getUID().equals(uid)) { 45 | return world; 46 | @@ -1485,6 +1490,7 @@ public final class CraftServer implements Server { 47 | System.out.println("World " + world.getName() + " is a duplicate of another world and has been prevented from loading. Please delete the uid.dat file from " + world.getName() + "'s world directory if you want to be able to load the duplicate world."); 48 | return; 49 | } 50 | + this.worldsByUUID.put(world.getUID(), world); // MultiPaper - optimize getWorld(UUID) 51 | this.worlds.put(world.getName().toLowerCase(java.util.Locale.ENGLISH), world); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /patches/server/0090-Configurable-mobs-from-spawners-picking-up-loot.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: etil2jz <81570777+etil2jz@users.noreply.github.com> 3 | Date: Wed, 31 Aug 2022 11:19:23 +0200 4 | Subject: [PATCH] Configurable mobs from spawners picking up loot 5 | 6 | 7 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 8 | index e8cde60fa80928308dd948d423c0b85cb2794b8a..be6d2fd0890119a4f6a6c97379fa5f48a066a6f7 100644 9 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 10 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 11 | @@ -249,4 +249,15 @@ public class MiraiConfig { 12 | "standing on a 1x1 block while being stuck."); 13 | villagerLobotomizeCheckInterval = getInt("villager.lobotomize.check-interval", 100); 14 | } 15 | + 16 | + public static boolean skeletonPickupLoot; 17 | + public static boolean zombiePickupLoot; 18 | + private static void spawnersPickupLoot() { 19 | + skeletonPickupLoot = getBoolean("disable-spawners-pick-up-items.skeleton", false, 20 | + "Whether or not skeletons from spawners should be able to", 21 | + "pick up items on the ground."); 22 | + zombiePickupLoot = getBoolean("disable-spawners-pick-up-items.zombie", false, 23 | + "Whether or not zombies from spawners should be able to", 24 | + "pick up items on the ground."); 25 | + } 26 | } 27 | diff --git a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java 28 | index 586e3e92ccc275446df6dbbff9bf010a37a9aa8f..9b9445271232250df9161393df46187c662b452f 100644 29 | --- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java 30 | +++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java 31 | @@ -159,7 +159,13 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo 32 | this.populateDefaultEquipmentSlots(randomsource, difficulty); 33 | this.populateDefaultEquipmentEnchantments(randomsource, difficulty); 34 | this.reassessWeaponGoal(); 35 | - this.setCanPickUpLoot(this.level().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.skeletons || randomsource.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper - Add world settings for mobs picking up loot 36 | + // Mirai start 37 | + if (dev.etil.mirai.MiraiConfig.skeletonPickupLoot && spawnReason == MobSpawnType.SPAWNER) { 38 | + this.setCanPickUpLoot(false); 39 | + } else { 40 | + this.setCanPickUpLoot(this.level().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.skeletons || randomsource.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper - Add world settings for mobs picking up loot 41 | + } 42 | + // Mirai end 43 | if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { 44 | LocalDate localdate = LocalDate.now(); 45 | int i = localdate.get(ChronoField.DAY_OF_MONTH); 46 | diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java 47 | index 5c40e994007dbf46ebc12c1e6a6ca90379471b74..7670436f1b1b1ed852fc166b0368e3ca2046d79b 100644 48 | --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java 49 | +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java 50 | @@ -512,7 +512,13 @@ public class Zombie extends Monster { 51 | Object object = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt); 52 | float f = difficulty.getSpecialMultiplier(); 53 | 54 | - this.setCanPickUpLoot(this.level().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.zombies || randomsource.nextFloat() < 0.55F * f); // Paper - Add world settings for mobs picking up loot 55 | + // Mirai start 56 | + if (dev.etil.mirai.MiraiConfig.zombiePickupLoot && spawnReason == MobSpawnType.SPAWNER) { 57 | + this.setCanPickUpLoot(false); 58 | + } else { 59 | + this.setCanPickUpLoot(this.level().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.zombies || randomsource.nextFloat() < 0.55F * f); // Paper - Add world settings for mobs picking up loot 60 | + } 61 | + // Mirai end 62 | if (object == null) { 63 | object = new Zombie.ZombieGroupData(Zombie.getSpawnAsBabyOdds(randomsource), true); 64 | } 65 | -------------------------------------------------------------------------------- /patches/server/0093-Sync-event-calls-on-async-threads.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: rafaelflromao <12960698+rafaelflromao@users.noreply.github.com> 3 | Date: Mon, 12 Jun 2023 06:01:40 +0100 4 | Subject: [PATCH] Sync event calls on async threads 5 | 6 | 7 | diff --git a/src/main/java/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java 8 | index 1cdab691bef60250fb4f3ff35d270caa99e3af6b..5d1dc477e1ac07a1fefdc182bbb9ee0c2dde828f 100644 9 | --- a/src/main/java/dev/etil/mirai/MiraiConfig.java 10 | +++ b/src/main/java/dev/etil/mirai/MiraiConfig.java 11 | @@ -289,4 +289,16 @@ public class MiraiConfig { 12 | enableAsyncEntityTracker = temp; 13 | } 14 | } 15 | + 16 | + public static boolean enableSyncEventCallsOnAsyncThreads; 17 | + public static boolean enableSyncEventCallsOnAsyncThreadsInitialized; 18 | + private static void syncEventCallsOnAsyncThreads() { 19 | + boolean temp = getBoolean("enable-sync-event-calls-on-async-threads", true, 20 | + "Whether or not sync event calls on async threads should be enabled. (If async entity tracker is enabled, this is enabled.)", 21 | + "You may encounter issues with plugins."); 22 | + if (!enableSyncEventCallsOnAsyncThreadsInitialized) { 23 | + enableSyncEventCallsOnAsyncThreadsInitialized = true; 24 | + enableSyncEventCallsOnAsyncThreads = temp; 25 | + } 26 | + } 27 | } 28 | diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java 29 | index 32bd9b4e4f77598806962cb6a91c0f04455a7133..21844207d3acf8b86367db95a23f5cbc57fb44c5 100644 30 | --- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java 31 | +++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java 32 | @@ -41,7 +41,7 @@ class PaperEventManager { 33 | throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously."); 34 | } else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) { 35 | // Mirai start 36 | - if (dev.etil.mirai.MiraiConfig.enableAsyncEntityTracker) { 37 | + if (dev.etil.mirai.MiraiConfig.enableAsyncEntityTracker || dev.etil.mirai.MiraiConfig.enableSyncEventCallsOnAsyncThreads) { 38 | MinecraftServer.getServer().executeBlocking(event::callEvent); 39 | return; 40 | } else { 41 | -------------------------------------------------------------------------------- /patches/server/0094-Add-Higher-Java-Versions-Support-for-SIMD.patch: -------------------------------------------------------------------------------- 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2 | From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> 3 | Date: Thu, 28 Dec 2023 04:00:37 -0500 4 | Subject: [PATCH] Add Higher Java Versions Support for SIMD 5 | 6 | 7 | diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java 8 | index 14e98404514971162ac93e13415b0011c6800a01..5ed739e83786595616b221c4a10c25f06e62d726 100644 9 | --- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java 10 | +++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java 11 | @@ -94,7 +94,7 @@ public class PufferfishConfig { 12 | // Attempt to detect vectorization 13 | try { 14 | SIMDDetection.isEnabled = SIMDDetection.canEnable(PufferfishLogger.LOGGER); 15 | - SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19; 16 | + SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17; // Mirai - Add Higher Java Versions Support for SIMD 17 | } catch (NoClassDefFoundError | Exception ignored) { 18 | ignored.printStackTrace(); 19 | } 20 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | maven("https://repo.papermc.io/repository/maven-public/") 5 | } 6 | } 7 | 8 | rootProject.name = "Mirai" 9 | 10 | include("mirai-api", "mirai-server", "paper-api-generator") 11 | --------------------------------------------------------------------------------