mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-22 08:19:26 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@1e7dd72 Remove 'fix Vanilla Minecart speed' patch (#10068) PaperMC/Paper@e7e1c8a Fix and add new scoreboard API (#10037) PaperMC/Paper@49f9f6f Add Registry#getKey (#10066) PaperMC/Paper@4adca3d Update to adventure 4.15 (#10045) PaperMC/Paper@ff7b9b0 Increase default custom payload channel size limit (#10006) PaperMC/Paper@1cda66e Hotfix Entity isInRain reobf issue PaperMC/Paper@61768e0 [ci skip] Remove no longer needed mappings change PaperMC/Paper@e035fd7 Updated Upstream (Bukkit/CraftBukkit/Spigot) PaperMC/Paper@c215ce1 [ci skip] cleanup patch diff from last commit PaperMC/Paper@4fdda9e Keep newlines in outdated client/server message (#10042) PaperMC/Paper@f483b38 fix NPE on EntityTeleportEvent getTo (#10016) PaperMC/Paper@dc62150 Catch async usage of playsound (#10021) PaperMC/Paper@0d6a0c3 Fix command block async message (again) (#10082) PaperMC/Paper@d1f507f Don't fire 2 game events for certain cauldron interactions (#8904) PaperMC/Paper@a401585 Fix campfire recipes not always outputting full result (#8754) PaperMC/Paper@88d28d6 Fix long loading screen when refreshing skins (#10026) PaperMC/Paper@c081104 Add experience points api (#9688) PaperMC/Paper@8221b08 Fix global sound event gamerule not being respected (#8727) PaperMC/Paper@3c0d6aa Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10085) PaperMC/Paper@2c3ccb8 Add drops to shear events (#5678) PaperMC/Paper@b2ffb1b Add PlayerShieldDisableEvent (#9177) PaperMC/Paper@2951732 Add HiddenPotionEffect API (#9910) PaperMC/Paper@e4ab50d Properly disallow async Player#chat (#8123) PaperMC/Paper@5e978d3 Fix Folia scheduler tasks not canceling when plugin disable (#10091) PaperMC/Paper@e56e53f Fix some component bugs in login disconnect packet (#10090) PaperMC/Paper@3484ae9 Call entity_die game event after event cancel check (#10096) PaperMC/Paper@0ae58c0 cleanup player death event adventure logic (#10095) PaperMC/Paper@1281f4f Make region/lock shift accessors per world PaperMC/Paper@983377b Correctly check if bucket dispenses will succeed for event (#10109) PaperMC/Paper@58e120b [ci skip] Remove extraneous diff added in 1.20.3 update (#10101) PaperMC/Paper@816bacc Call EntityChangeBlockEvent for cake eating (#10105) PaperMC/Paper@692db0c fix CustomModelData being removed (#10113) PaperMC/Paper@509876d Keep fully frozen entities fully activated (#10103) PaperMC/Paper@1fa48d1 include relative flags in PlayerTeleportEvent (#8190) PaperMC/Paper@ae001ae Fix untrack event not being called for all 'untracks' (#10110) PaperMC/Paper@259bc76 Pass system properties to maven repo session (#10117) PaperMC/Paper@b2a6d57 Validate ResourceLocation in NBT reading PaperMC/Paper@7eaff48 [ci skip] Replace some magic values with constant references PaperMC/Paper@19a6202 Fix experience & improvements to block events (#8067) PaperMC/Paper@8379027 Fix cmd permission levels for command blocks (#7404) PaperMC/Paper@a93acc4 Fix EntityChangePoseEvent being called during worldgen (#10120) PaperMC/Paper@25a99b1 Fix BlockDestroyEvents effectBlock not being set (#10131) PaperMC/Paper@a58e29d Fix a borked update of 'Properly handle BlockBreakEvent#isDropItems' (#10134) PaperMC/Paper@570cfb4 Validate missed resource location parsing PaperMC/Paper@e46276e Fixup NamespacedKey parsing PaperMC/Paper@f1c5f01 [ci skip] Fix typo PaperMC/Paper@07b956e Fix tests by disabling them
96 lines
4.8 KiB
Diff
96 lines
4.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Sun, 24 Dec 2023 16:54:07 +0000
|
|
Subject: [PATCH] Optimise check inside blocks and fluids
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index e6bcc60810c551e92e7f01f49cfbff58735b97ed..78787a972b9fbc6dd5caaad06e5047133f2a1993 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -1980,18 +1980,37 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
BlockPos blockposition1 = BlockPos.containing(axisalignedbb.maxX - offset, axisalignedbb.maxY - offset, axisalignedbb.maxZ - offset);
|
|
// Sakura end
|
|
|
|
- if (this.level().hasChunksAt(blockposition, blockposition1)) {
|
|
+ // Sakura start - optimise check inside blocks
|
|
+ if (blockposition1.getY() >= level.getMinBuildHeight() || blockposition.getY() < level.getMaxBuildHeight()) {
|
|
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
|
|
|
+ net.minecraft.world.level.chunk.ChunkAccess chunk = null;
|
|
+ int lastChunkX = Integer.MIN_VALUE;
|
|
+ int lastChunkZ = Integer.MIN_VALUE;
|
|
+
|
|
for (int i = blockposition.getX(); i <= blockposition1.getX(); ++i) {
|
|
- for (int j = blockposition.getY(); j <= blockposition1.getY(); ++j) {
|
|
- for (int k = blockposition.getZ(); k <= blockposition1.getZ(); ++k) {
|
|
+ final int chunkX = i >> 4;
|
|
+ for (int k = blockposition.getZ(); k <= blockposition1.getZ(); ++k) {
|
|
+ final int chunkZ = k >> 4;
|
|
+
|
|
+ if (lastChunkX != chunkX || lastChunkZ != chunkZ) {
|
|
+ chunk = level.getChunkIfLoadedImmediately(chunkX, chunkZ);
|
|
+ lastChunkX = chunkX;
|
|
+ lastChunkZ = chunkZ;
|
|
+ }
|
|
+
|
|
+ if (chunk == null) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ for (int j = blockposition.getY(); j <= blockposition1.getY(); ++j) {
|
|
if (!this.isAlive()) {
|
|
return;
|
|
}
|
|
|
|
blockposition_mutableblockposition.set(i, j, k);
|
|
- BlockState iblockdata = this.level().getBlockState(blockposition_mutableblockposition);
|
|
+ BlockState iblockdata = chunk.getBlockState(blockposition_mutableblockposition);
|
|
+ // Sakura end
|
|
|
|
try {
|
|
iblockdata.entityInside(this.level(), blockposition_mutableblockposition, this);
|
|
@@ -4782,7 +4801,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
}
|
|
|
|
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
|
|
- if (this.touchingUnloadedChunk()) {
|
|
+ if (false) { // Sakura
|
|
return false;
|
|
} else {
|
|
AABB axisalignedbb = this.getBoundingBox().deflate(0.001D);
|
|
@@ -4799,11 +4818,30 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
int k1 = 0;
|
|
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
|
|
|
+ // Sakura start
|
|
+ net.minecraft.world.level.chunk.ChunkAccess chunk = null;
|
|
+ int lastChunkX = Integer.MIN_VALUE;
|
|
+ int lastChunkZ = Integer.MIN_VALUE;
|
|
+
|
|
for (int l1 = i; l1 < j; ++l1) {
|
|
- for (int i2 = k; i2 < l; ++i2) {
|
|
- for (int j2 = i1; j2 < j1; ++j2) {
|
|
+ final int chunkX = l1 >> 4;
|
|
+ for (int j2 = i1; j2 < j1; ++j2) {
|
|
+ final int chunkZ = j2 >> 4;
|
|
+
|
|
+ if (chunkX != lastChunkX || chunkZ != lastChunkZ) {
|
|
+ chunk = level.getChunkIfLoadedImmediately(chunkX, chunkZ);
|
|
+ lastChunkX = chunkX;
|
|
+ lastChunkZ = chunkZ;
|
|
+ }
|
|
+
|
|
+ if (chunk == null) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ for (int i2 = k; i2 < l; ++i2) {
|
|
blockposition_mutableblockposition.set(l1, i2, j2);
|
|
- FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition);
|
|
+ FluidState fluid = chunk.getFluidState(blockposition_mutableblockposition);
|
|
+ // Sakura end
|
|
|
|
if (fluid.is(tag)) {
|
|
double d2 = (double) ((float) i2 + fluid.getHeight(this.level(), blockposition_mutableblockposition));
|