9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/leaves-server/minecraft-patches/features/0051-Cache-ignite-odds.patch
violetc d5c9306a7f 1.21.4 (#413)
* init 1.21.4, and boom!

* build change, but weight not work

* just work

* Build changes, and delete timings

* Fix API patches (#406)

* Fix API patches

* merge

---------

Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com>

* 0006/0129

* 0009/0129

* 0011/0129

* 0018/0129

* 0030/0129

* 0035/0129

* 0043/0129

* 0048/0129

* 0049/0129

* 0057/0129

* 0065/0129

* 0086/0129 (#408)

* 0072/0129

* 0080/0129

* Readd patch infos

* 0086/0129

* Delete applied patches

* 0087/0129

* 0091/0129

* 0097/0129

* 0101/0129

* 102/129

* 0107/0129

* 0112/0129

* 0118/0129

* 0129/0129, 100% patched

* fix some

* server work

* Protocol... (#409)

* Jade v7

* Fix changed part for Jade

* Formatting imports, add Lms Paster protocol

* REI payloads 5/8

* Add REI support, remove unnecessary content in Jade

* Rename

* Make jade better

* Make action work

* fix action jar

* Fix some protocol

* Fix bot action, and entity tickCount

* Fix Warden GameEventListener register on load

* Fix extra Raider drop

* Fix grindstone overstacking

* Update Paper, and some doc

* Merge

* [ci skip] Update Action

---------

Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
2025-02-14 23:55:46 +08:00

64 lines
3.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <58360096+s-yh-china@users.noreply.github.com>
Date: Wed, 5 Jul 2023 17:42:24 +0800
Subject: [PATCH] Cache ignite odds
diff --git a/net/minecraft/world/level/block/FireBlock.java b/net/minecraft/world/level/block/FireBlock.java
index 7340c664fdcf991a2549c8f07f6ab093bbe6e4e8..d9796f683de7c0c12f45f62597792f80c66c60b7 100644
--- a/net/minecraft/world/level/block/FireBlock.java
+++ b/net/minecraft/world/level/block/FireBlock.java
@@ -225,6 +225,7 @@ public class FireBlock extends BaseFireBlock {
this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue, pos);
// CraftBukkit end
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
+ Object2IntOpenHashMap<BlockPos> blockPositionIgniteCache = new Object2IntOpenHashMap<>(); // Leaves - cache ignite odds
for (int i1 = -1; i1 <= 1; i1++) {
for (int i2 = -1; i2 <= 1; i2++) {
@@ -236,7 +237,7 @@ public class FireBlock extends BaseFireBlock {
}
mutableBlockPos.setWithOffset(pos, i1, i3, i2);
- int igniteOdds = this.getIgniteOdds(level, mutableBlockPos);
+ int igniteOdds = this.getIgniteOdds(level, mutableBlockPos, org.leavesmc.leaves.LeavesConfig.performance.cacheIgniteOdds ? blockPositionIgniteCache : null); // Leaves - cache ignite odds
if (igniteOdds > 0) {
int i5 = (igniteOdds + 40 + level.getDifficulty().getId() * 7) / (ageValue + 30);
if (isIncreasedFireBurnout) {
@@ -340,20 +341,33 @@ public class FireBlock extends BaseFireBlock {
return false;
}
+ // Leaves start - cache ignite odds
private int getIgniteOdds(LevelReader level, BlockPos pos) {
+ return getIgniteOdds(level, pos, null);
+ }
+
+ private int getIgniteOdds(LevelReader level, BlockPos pos, @org.jetbrains.annotations.Nullable Object2IntOpenHashMap<BlockPos> cache) {
if (!level.isEmptyBlock(pos)) {
return 0;
} else {
int i = 0;
for (Direction direction : Direction.values()) {
- BlockState blockState = level.getBlockState(pos.relative(direction));
- i = Math.max(this.getIgniteOdds(blockState), i);
+ if (cache != null) {
+ i = Math.max(cache.computeIfAbsent(pos, key -> {
+ BlockState blockState = level.getBlockState(pos.relative(direction));
+ return this.getIgniteOdds(blockState);
+ }), i);
+ } else {
+ BlockState blockState = level.getBlockState(pos.relative(direction));
+ i = Math.max(this.getIgniteOdds(blockState), i);
+ }
}
return i;
}
}
+ // Leaves end - cache ignite odds
@Override
protected boolean canBurn(BlockState state) {