Skip to content

Commit

Permalink
Add back sun burn tick optimization of Gale
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Feb 3, 2024
1 parent 25091d3 commit 0fd3883
Show file tree
Hide file tree
Showing 26 changed files with 76 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Sun, 9 Jul 2023 14:50:57 +0800
Subject: [PATCH] sync with Gale's Optimize-villager-data-storage.patch
Subject: [PATCH] Sync with Gale's Optimize-villager-data-storage.patch


diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java b/src/main/java/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Sat, 3 Feb 2024 04:25:45 -0500
Subject: [PATCH] Sync with Gale's Optimize-sun-burn-tick.patch


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index fc77f4ec5234ad0d450a8fa74f316b4355033022..e518c53123f04475d66dd2383ba9034d5ed17ef5 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -567,13 +567,29 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}

// Purpur start - copied from Mob
+ // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
+ private BlockPos cached_eye_blockpos;
+ private int cached_position_hashcode;
+ // Gale end - JettPack - optimize sun burn tick - cache eye blockpos
+
public boolean isSunBurnTick() {
if (this.level().isDay() && !this.level().isClientSide) {
- float f = this.getLightLevelDependentMagicValue();
- BlockPos blockposition = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
+ // Gale start - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
+ int positionHashCode = this.position.hashCode();
+ if (this.cached_position_hashcode != positionHashCode) {
+ this.cached_eye_blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
+ this.cached_position_hashcode = positionHashCode;
+ }
+
+ float f = this.getLightLevelDependentMagicValue(cached_eye_blockpos); // Pass BlockPos to getBrightness
+
+ // Check brightness first
+ if (f <= 0.5F) return false;
+ if (this.random.nextFloat() * 30.0F >= (f - 0.4F) * 2.0F) return false;
+ // Gale end - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow;

- if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && !flag && this.level().canSeeSky(blockposition)) {
+ if (!flag && this.level().canSeeSky(this.cached_eye_blockpos)) { // Gale - JettPack - optimize sun burn tick - optimizations and cache eye blockpos
return true;
}
}
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index b171c53efae9cc39bc68164fbe0f90afb47769be..8d18d64ef57b6270f098ff1fab8d8a30bb779b44 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -1733,11 +1733,6 @@ public abstract class Mob extends LivingEntity implements Targeting {

}

- // Gale start - JettPack - optimize sun burn tick - cache eye blockpos
- private BlockPos cached_eye_blockpos;
- private int cached_position_hashcode;
- // Gale end - JettPack - optimize sun burn tick - cache eye blockpos
-
public boolean isSunBurnTick() {
return super.isSunBurnTick();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This patch was ported downstream from the Petal fork.
Makes most pathfinding-related work happen asynchronously

diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index b171c53efae9cc39bc68164fbe0f90afb47769be..21d5abd15e833c77983692b59475a77c66ca3ecc 100644
index 8d18d64ef57b6270f098ff1fab8d8a30bb779b44..11b2833e01da8a7abd720f3a08ac5f747a20508f 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -294,6 +294,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Cache minecart vehicle collision results to prevent lag causing by massive stack
The known issue: entity can't enter the minecart after enabling this!

diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
index c809e370ab61811c7e2fa3d6f207ae04fcb6749b..30db428ade01213ccd9956cd739747b5de3f1a2e 100644
index eb5bd5cfd131042e366872bf599a315d83dc732b..a855289c9bd52bea33c1f7a15fa2cbba90855713 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
@@ -5,6 +5,8 @@ import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -64,7 +64,7 @@ index c809e370ab61811c7e2fa3d6f207ae04fcb6749b..30db428ade01213ccd9956cd739747b5
while (iterator1.hasNext()) {
Entity entity1 = (Entity) iterator1.next();
diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java
index d6646f4db522aa4a5404acf17fb34bfe01a5763a..475d53b5b5ef82f982f3619eb161e76db095b73f 100644
index 393c8d887e0de195d6bd95c9c3273b03d7b3eb03..f4b954c8f4fa09a099c9aa95f2165072a891b1f8 100644
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
@@ -205,6 +205,7 @@ public class LeafConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Faster Random for xaeroMapServerID generation


diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java
index 475d53b5b5ef82f982f3619eb161e76db095b73f..c871d3c03b384a3f7e4c8c919b9d565ebe4e8a77 100644
index f4b954c8f4fa09a099c9aa95f2165072a891b1f8..8db4b1268e7bc18d60cc53f2753a73c2fc3ec242 100644
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
@@ -2,7 +2,7 @@ package org.dreeam.leaf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Fix casting in Purpur world config


diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 9d10d7f4b71026d79d469f82d09c77f84dafd604..307d2703d61285dfe5225be27d8933098b4aa67c 100644
index 359dc08ffa2c89f5194387d01b42c3aec536e117..88c9389f27f51a6423dfa4c71cf353b8b417e602 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -678,7 +678,7 @@ public class PurpurWorldConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Fix sprint glitch


diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 46d4e0b239e9c7bd45b052c84ddcdbe545582af3..4a0af738a4eefe6512b56d23cd01685961b21b9c 100644
index 645fba328cbc2cd28ee1b3968fcb315f92ed22ec..cadb6ebde38658aba251de1259db6449cefc9c9d 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1430,7 +1430,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Fix keepalive kicked name


diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index 66255eeab8cae6ce150ca888b9db3c2f88c4b00b..16d8b36c19a7209b8b6348622de351e51cb75470 100644
index 1610f21bbfbca0d12ca12373e56d90a54ac7c9f7..89b9520b4abad6040e60fbbf6844976ec46463b9 100644
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -241,7 +241,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Replace `thenApply` with `thenCompose`. Once one task is completed then the next
to prevent blocking threads while waiting to complete all tasks

diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
index 169edd91e25f3c1d27f8a9e2bca58a6143c8a891..3212768d1d8e8922bd88de407add163868837b42 100644
index b40864e41e1506884fdefefbf3cf4833a8f706c3..4b52a487296c8ea4d4159ec74582f13eb3ffbe36 100644
--- a/src/main/java/net/minecraft/Util.java
+++ b/src/main/java/net/minecraft/Util.java
@@ -409,9 +409,11 @@ public class Util {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ But still recommend to turn-off `checkForMinecartNearItemWhileActive`
Since `Reduce-hopper-item-checks.patch` will cause lag under massive dropped items

diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index 1f61dc925624c493ae458748e8422383104b022f..4ba2285e9d5ec3444c73419f8fab040a96a03c0e 100644
index 414948ac6ad0b6919bedb119f4942a2881211825..397199aa5e9290287adc64abd3bb333bb96cec83 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -1,7 +1,9 @@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Add Pufferfish DAB support for Camel, Sniffer, Warden
https://github.com/pufferfish-gg/Pufferfish/issues/83

diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
index 637beec8d5a1d39748db9e87bfb9a999f2c728ec..4e63d5587669ba62b2ad760e3dc83511bb199d0f 100644
index 7b87ea3578f3bb8b7e93054171a0f66c0e0d1262..b0ec4b9623e0efa2f9bebdd704a77ce16f7e4cd6 100644
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
@@ -168,9 +168,11 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
Expand All @@ -26,7 +26,7 @@ index 637beec8d5a1d39748db9e87bfb9a999f2c728ec..4e63d5587669ba62b2ad760e3dc83511
CamelAi.updateActivity(this);
super.customServerAiStep();
diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
index 7e8de65d7e5f9251d8ea4fb9bd3a4044457e0bda..dd8e71a392e8675d7d334555ddc24d7d8a60a758 100644
index 4e7867e7239eb573b287a70eee8191bdf434f686..2c6c153187f97cd07157d72cbe4c9829161f74b7 100644
--- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
+++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java
@@ -527,8 +527,10 @@ public class Sniffer extends Animal {
Expand All @@ -41,7 +41,7 @@ index 7e8de65d7e5f9251d8ea4fb9bd3a4044457e0bda..dd8e71a392e8675d7d334555ddc24d7d
SnifferAi.updateActivity(this);
super.customServerAiStep();
diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
index 25ee9670c37c4342993c3aed8417ff050bbcb779..29aec157722b4d5f19bfe082e287bfb5edd95dd0 100644
index 141c41c05623ab5802ae3e03ee772d310efda3a8..695458d1d45169ae36344984a5b66fa8c3ee907d 100644
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
@@ -319,7 +319,7 @@ public class Warden extends Monster implements VibrationSystem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Optimizes "image in map" maps, without requiring the map to be locked, which som
This has the disadvantage that the vanilla map data will never be updated while the CraftMapRenderer is not present, but that's not a huuuge problem for u

diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
index 6cfd169c2c32b644d70907358c2d4a2087c00a68..c065ee1e68b5274d30f252d296b0c16a2adbf3c8 100644
index 8d3c1897044f9a2bbe1911e1a72dc9a00fb246df..03112a42d1cf3460af5d5ce9d1fdd03854d5e8c1 100644
--- a/src/main/java/net/minecraft/world/item/MapItem.java
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
@@ -325,7 +325,7 @@ public class MapItem extends ComplexItem {
Expand All @@ -24,7 +24,7 @@ index 6cfd169c2c32b644d70907358c2d4a2087c00a68..c065ee1e68b5274d30f252d296b0c16a
}

diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java
index 635f09b234c723b79d35686105c2c3335f868e6a..3368e4d398132c64969b018e4fe8b7bbe8f2f364 100644
index 26c7a5020e9fd9dac212c6540dc79cad26e64796..ac21530de2ecb4c5b1ded30abf2bca473c813701 100644
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
@@ -206,6 +206,7 @@ public class LeafConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ index 440d3d72d8b2dac14f83a83caa5ae9dbf3e979b6..cb430ae1628cbf48a002991fd1c5674e

// Purpur start - borrowed and modified code from ThrownPotion#onHitBlock and ThrownPotion#dowseFire
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java
index b64ecadae45c2126b92963ac8d118dde76126ddd..be46cc7423886900344b2ece0efd6615cd32b9ee 100644
index 785196e6f4677074890ca965e9add85ccfd0e6e3..c2d9b3110756fa35829f0c01c06331f95ca7998d 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java
@@ -45,7 +45,14 @@ public class ThrownEgg extends ThrowableItemProjectile {
Expand All @@ -50,7 +50,7 @@ index b64ecadae45c2126b92963ac8d118dde76126ddd..be46cc7423886900344b2ece0efd6615

@Override
diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java
index 3368e4d398132c64969b018e4fe8b7bbe8f2f364..f41f3da6021d71ad7291d9401282c473aaca7e33 100644
index ac21530de2ecb4c5b1ded30abf2bca473c813701..d6510b90913245f68a5828ef7097381edbbc1780 100644
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
@@ -314,6 +314,8 @@ public class LeafConfig {
Expand Down

0 comments on commit 0fd3883

Please sign in to comment.