mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
88 lines
4.2 KiB
Diff
88 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 17 Apr 2016 17:27:09 -0400
|
|
Subject: [PATCH] Prevent Fire from loading chunks & wrongly spread
|
|
|
|
This causes the nether to spam unload/reload chunks, plus overall
|
|
bad behavior.
|
|
|
|
This also stops fire from spreading to illegal locations.
|
|
|
|
|
|
|
|
This shouldn't need to be included in post 1.14 versions, as blocks no longer tick without at least 1 radius
|
|
chunk loaded.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java
|
|
index 700078c2fd536cc22351eadf51503efb9acd9df9..85170008de6e77cfb8e4f55ae440a8428d868af4 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/FireBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java
|
|
@@ -134,7 +134,7 @@ public class FireBlock extends BaseFireBlock {
|
|
BooleanProperty blockstateboolean = (BooleanProperty) FireBlock.PROPERTY_BY_DIRECTION.get(enumdirection);
|
|
|
|
if (blockstateboolean != null) {
|
|
- iblockdata1 = (BlockState) iblockdata1.setValue(blockstateboolean, this.canBurn(world.getBlockState(pos.relative(enumdirection))));
|
|
+ iblockdata1 = (BlockState) iblockdata1.setValue(blockstateboolean, this.canBurn(world.getTypeIfLoaded(pos.relative(enumdirection)))); // Paper - prevent chunk loads
|
|
}
|
|
}
|
|
|
|
@@ -214,6 +214,7 @@ public class FireBlock extends BaseFireBlock {
|
|
}
|
|
|
|
blockposition_mutableblockposition.setWithOffset((Vec3i) pos, l, j1, i1);
|
|
+ if (blockposition_mutableblockposition.isInvalidYLocation() || !world.hasChunkAt(blockposition_mutableblockposition)) continue; // Paper
|
|
int l1 = this.getFireOdds((LevelReader) world, (BlockPos) blockposition_mutableblockposition);
|
|
|
|
if (l1 > 0) {
|
|
@@ -259,10 +260,16 @@ public class FireBlock extends BaseFireBlock {
|
|
}
|
|
|
|
private void trySpread(Level world, BlockPos blockposition, int i, Random random, int j, BlockPos sourceposition) { // CraftBukkit add sourceposition
|
|
- int k = this.getBurnOdd(world.getBlockState(blockposition));
|
|
+ // Paper start
|
|
+ final BlockState iblockdata = world.getTypeIfLoaded(blockposition);
|
|
+ if (iblockdata == null) {
|
|
+ return;
|
|
+ }
|
|
+ int k = this.getBurnOdd(iblockdata);
|
|
+ // Paper end
|
|
|
|
if (random.nextInt(i) < k) {
|
|
- BlockState iblockdata = world.getBlockState(blockposition);
|
|
+ //IBlockData iblockdata = world.getType(blockposition); // Paper
|
|
|
|
// CraftBukkit start
|
|
org.bukkit.block.Block theBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
@@ -308,7 +315,7 @@ public class FireBlock extends BaseFireBlock {
|
|
for (int j = 0; j < i; ++j) {
|
|
Direction enumdirection = aenumdirection[j];
|
|
|
|
- if (this.canBurn(world.getBlockState(pos.relative(enumdirection)))) {
|
|
+ if (this.canBurn(world.getTypeIfLoaded(pos.relative(enumdirection)))) { // Paper - prevent chunk loads
|
|
return true;
|
|
}
|
|
}
|
|
@@ -326,7 +333,12 @@ public class FireBlock extends BaseFireBlock {
|
|
|
|
for (int k = 0; k < j; ++k) {
|
|
Direction enumdirection = aenumdirection[k];
|
|
- BlockState iblockdata = iworldreader.getBlockState(pos.relative(enumdirection));
|
|
+ // Paper start
|
|
+ BlockState iblockdata = iworldreader.getTypeIfLoaded(pos.relative(enumdirection));
|
|
+ if (iblockdata == null) {
|
|
+ continue;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
i = Math.max(this.getFlameOdds(iblockdata), i);
|
|
}
|
|
@@ -337,7 +349,7 @@ public class FireBlock extends BaseFireBlock {
|
|
|
|
@Override
|
|
protected boolean canBurn(BlockState state) {
|
|
- return this.getFlameOdds(state) > 0;
|
|
+ return state != null && this.getFlameOdds(state) > 0; // Paper - iblockdata can be nullable if chunk is unloaded now
|
|
}
|
|
|
|
@Override
|