Skip to content

Commit 2efad49

Browse files
authored
1.21.50 & fixes (#2205)
- Updated for Minecraft 1.21.50 - Fixed double chest placement in certain rotations - Fixed some block updates possibly loading chunks - Fixed some leaves decaying even when wood is nearby - Fixed some chunks not being saved on server restart - Fixed lightning ignoring BlockIgniteEvent result - Fixed barrel inventory saving - Fixed ItemSignBirch name - Fixed PlayerMoveEvent not being called when only rotation changes
1 parent 047d00a commit 2efad49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+261
-158
lines changed

build.gradle.kts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ tasks {
115115
archiveClassifier.set("")
116116

117117
exclude("javax/annotation/**")
118+
119+
// These platforms are not popular, make the jar a bit smaller by not including optional Snappy support
120+
exclude("org/xerial/snappy/native/AIX/**")
121+
exclude("org/xerial/snappy/native/FreeBSD/**")
122+
exclude("org/xerial/snappy/native/SunOS/**")
123+
exclude("org/xerial/snappy/native/Linux/loongarch64/**")
124+
exclude("org/xerial/snappy/native/Linux/ppc/**")
125+
exclude("org/xerial/snappy/native/Linux/ppc64/**")
126+
exclude("org/xerial/snappy/native/Linux/ppc64le/**")
127+
exclude("org/xerial/snappy/native/Linux/s390x/**")
118128
}
119129

120130
runShadow {

gradle/libs.versions.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
junit = "5.9.2"
33
log4j = "2.20.0"
44
jline = "3.22.0"
5-
fastutilmaps = "8.5.13-SNAPSHOT"
5+
fastutilmaps = "8.5.15-SNAPSHOT"
66

77
[libraries]
88
network = { group = "org.cloudburstmc.netty", name = "netty-transport-raknet", version = "1.0.0.CR3-SNAPSHOT" }
99
epoll = { group = "io.netty", name = "netty-transport-native-epoll", version = "4.1.101.Final" }
10-
fastutil = { group = "com.nukkitx", name = "fastutil-lite", version = "8.1.1" }
11-
fastutil-long-long-maps = { group = "org.cloudburstmc.fastutil.maps", name = "long-long-maps", version.ref = "fastutilmaps" }
10+
fastutil = { group = "it.unimi.dsi", name = "fastutil-core", version = "8.5.15" }
1211
fastutil-int-short-maps = { group = "org.cloudburstmc.fastutil.maps", name = "int-short-maps", version.ref = "fastutilmaps" }
13-
fastutil-object-int-maps = { group = "org.cloudburstmc.fastutil.maps", name = "object-int-maps", version.ref = "fastutilmaps" }
14-
fastutil-object-object-maps = { group = "org.cloudburstmc.fastutil.maps", name = "object-object-maps", version.ref = "fastutilmaps" }
12+
fastutil-long-byte-maps = { group = "org.cloudburstmc.fastutil.maps", name = "long-byte-maps", version.ref = "fastutilmaps" }
1513
guava = { group = "com.google.guava", name = "guava", version = "33.2.1-jre" }
1614
gson = { group = "com.google.code.gson", name = "gson", version = "2.10.1" }
1715
snakeyaml = { group = "org.yaml", name = "snakeyaml", version = "1.33" }
@@ -23,7 +21,7 @@ jopt-simple = { group = "net.sf.jopt-simple", name = "jopt-simple", version = "5
2321
blockstateupdater = { group = "org.cloudburstmc", name = "block-state-updater", version = "1.21.30-SNAPSHOT" }
2422
lmbda = { group = "org.lanternpowered", name = "lmbda", version = "2.0.0" }
2523
noise = { group = "net.daporkchop.lib", name = "noise", version = "0.5.6-SNAPSHOT" }
26-
lombok = { group = "org.projectlombok", name = "lombok", version = "1.18.34" }
24+
lombok = { group = "org.projectlombok", name = "lombok", version = "1.18.36" }
2725

2826
# Logging dependencies
2927
log4j-api = { group = "org.apache.logging.log4j", name = "log4j-api", version.ref = "log4j" }
@@ -43,7 +41,7 @@ junit-jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engi
4341
log4j = [ "log4j-api", "log4j-core" ]
4442
terminal = [ "jline-terminal", "jline-terminal-jna", "jline-reader", "terminal-console" ]
4543
junit = [ "junit-jupiter-api", "junit-jupiter-engine" ]
46-
fastutilmaps = [ "fastutil-long-long-maps", "fastutil-int-short-maps", "fastutil-object-int-maps", "fastutil-object-object-maps" ]
44+
fastutilmaps = [ "fastutil-int-short-maps", "fastutil-long-byte-maps" ]
4745

4846
[plugins]
4947
shadow = { id = "com.github.johnrengelman.shadow", version = "8.0.0" }

src/main/java/cn/nukkit/Player.java

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,9 +1901,32 @@ protected void handleMovement(Vector3 newPos) {
19011901
double distanceSquared = newPos.distanceSquared(this);
19021902
if (distanceSquared == 0) {
19031903
if (this.lastYaw != this.yaw || this.lastPitch != this.pitch) {
1904-
this.lastYaw = this.yaw;
1905-
this.lastPitch = this.pitch;
1906-
this.needSendRotation = true;
1904+
if (!this.firstMove) {
1905+
Location from = new Location(this.x, this.y, this.z, this.lastYaw, this.lastPitch, this.level);
1906+
Location to = this.getLocation();
1907+
1908+
PlayerMoveEvent moveEvent = new PlayerMoveEvent(this, from, to);
1909+
this.server.getPluginManager().callEvent(moveEvent);
1910+
1911+
if (moveEvent.isCancelled()) {
1912+
this.teleport(from, null);
1913+
return;
1914+
}
1915+
1916+
this.lastYaw = to.yaw;
1917+
this.lastPitch = to.pitch;
1918+
1919+
if (!to.equals(moveEvent.getTo())) { // If plugins modify the destination
1920+
this.teleport(moveEvent.getTo(), null);
1921+
} else {
1922+
this.needSendRotation = true;
1923+
}
1924+
} else {
1925+
this.lastYaw = this.yaw;
1926+
this.lastPitch = this.pitch;
1927+
this.needSendRotation = true;
1928+
this.firstMove = false;
1929+
}
19071930
}
19081931

19091932
if (this.speed == null) speed = new Vector3(0, 0, 0);
@@ -1987,13 +2010,7 @@ protected void handleMovement(Vector3 newPos) {
19872010
this.updateFallState(this.onGround);
19882011
// Replacement for this.fastMove(dx, dy, dz) end
19892012

1990-
Location from = new Location(
1991-
this.lastX,
1992-
this.lastY,
1993-
this.lastZ,
1994-
this.lastYaw,
1995-
this.lastPitch,
1996-
this.level);
2013+
Location from = new Location(this.lastX, this.lastY, this.lastZ, this.lastYaw, this.lastPitch, this.level);
19972014
Location to = this.getLocation();
19982015

19992016
if (!this.firstMove) {
@@ -2027,9 +2044,9 @@ protected void handleMovement(Vector3 newPos) {
20272044

20282045
this.lastYaw = to.yaw;
20292046
this.lastPitch = to.pitch;
2030-
}
20312047

2032-
this.firstMove = false;
2048+
this.firstMove = false;
2049+
}
20332050

20342051
if (this.speed == null) speed = new Vector3(from.x - to.x, from.y - to.y, from.z - to.z);
20352052
else this.speed.setComponents(from.x - to.x, from.y - to.y, from.z - to.z);

src/main/java/cn/nukkit/block/Block.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import cn.nukkit.level.Level;
1111
import cn.nukkit.level.MovingObjectPosition;
1212
import cn.nukkit.level.Position;
13+
import cn.nukkit.level.format.FullChunk;
1314
import cn.nukkit.level.persistence.PersistentDataContainer;
1415
import cn.nukkit.math.AxisAlignedBB;
1516
import cn.nukkit.math.BlockFace;
@@ -639,9 +640,34 @@ public Block getSide(BlockLayer layer, BlockFace face, int step) {
639640
if (this.isValid()) {
640641
return this.getLevel().getBlock(super.getSide(face, step), layer, true);
641642
}
642-
Block block = Block.get(Item.AIR, 0, Position.fromObject(new Vector3(this.x, this.y, this.z).getSide(face, step)));
643-
block.layer = layer;
644-
return block;
643+
return Block.get(AIR, 0, Position.fromObject(new Vector3(this.x, this.y, this.z).getSide(face, step)), layer);
644+
}
645+
646+
protected Block getSideIfLoaded(BlockFace face) {
647+
if (this.isValid()) {
648+
return this.level.getBlock(null,
649+
(int) this.x + face.getXOffset(), (int) this.y + face.getYOffset(), (int) this.z + face.getZOffset(),
650+
BlockLayer.NORMAL, false);
651+
}
652+
return Block.get(AIR, 0, Position.fromObject(new Vector3(this.x, this.y, this.z).getSide(face, 1)), BlockLayer.NORMAL);
653+
}
654+
655+
protected Block getSideIfLoadedOrNull(BlockFace face) {
656+
if (this.isValid()) {
657+
int cx = ((int) this.x + face.getXOffset()) >> 4;
658+
int cz = ((int) this.z + face.getZOffset()) >> 4;
659+
660+
FullChunk chunk = this.level.getChunkIfLoaded(cx, cz);
661+
if (chunk == null) {
662+
return null;
663+
}
664+
665+
return this.level.getBlock(chunk,
666+
(int) this.x + face.getXOffset(), (int) this.y + face.getYOffset(), (int) this.z + face.getZOffset(),
667+
BlockLayer.NORMAL, false);
668+
}
669+
670+
return Block.get(AIR, 0, Position.fromObject(new Vector3(this.x, this.y, this.z).getSide(face, 1)), BlockLayer.NORMAL);
645671
}
646672

647673
public Block up() {

src/main/java/cn/nukkit/block/BlockAzaleaLeaves.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ public Item[] getDrops(Item item) {
6060
}
6161
}
6262

63-
@Override
64-
protected void setOnDecayDamage() {
65-
this.setCheckDecay(false);
66-
}
67-
6863
@Override
6964
protected boolean canDropApple() {
7065
return false;

src/main/java/cn/nukkit/block/BlockCactus.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ public int onUpdate(int type) {
8686
if (down.getId() != SAND && down.getId() != CACTUS) {
8787
this.getLevel().useBreakOn(this);
8888
} else {
89-
for (int side = 2; side <= 5; ++side) {
90-
Block block = getSide(BlockFace.fromIndex(side));
91-
if (!block.canBeFlowedInto()) {
89+
for (BlockFace side : BlockFace.Plane.HORIZONTAL) {
90+
if (!getSide(side).canBeFlowedInto()) {
9291
this.getLevel().useBreakOn(this);
9392
}
9493
}

src/main/java/cn/nukkit/block/BlockChest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,16 @@ public boolean place(Item item, Block block, Block target, BlockFace face, doubl
6666
BlockEntityChest chest = null;
6767
this.setDamage(Block.FACES2534[player != null ? player.getDirection().getHorizontalIndex() : 0]);
6868

69-
for (int side = 2; side <= 5; ++side) {
70-
if ((this.getDamage() == 4 || this.getDamage() == 5) && (side == 4 || side == 5)) {
69+
for (BlockFace side : BlockFace.Plane.HORIZONTAL) {
70+
if ((this.getDamage() == 4 || this.getDamage() == 5) && (side == BlockFace.WEST || side == BlockFace.EAST)) {
7171
continue;
72-
} else if ((this.getDamage() == 3 || this.getDamage() == 2) && (side == 2 || side == 3)) {
72+
} else if ((this.getDamage() == 3 || this.getDamage() == 2) && (side == BlockFace.NORTH || side == BlockFace.SOUTH)) {
7373
continue;
7474
}
75-
Block c = this.getSide(BlockFace.fromIndex(side));
76-
if (c instanceof BlockChest && c.getDamage() == this.getDamage()) {
75+
Block c = this.getSide(side);
76+
if (c instanceof BlockChest &&
77+
(c.getDamage() == this.getDamage() || (c.getDamage() == 0 && this.getDamage() == 2))) { // leveldb states, idk
78+
7779
BlockEntity blockEntity = this.getLevel().getBlockEntity(c);
7880
if (blockEntity instanceof BlockEntityChest && !((BlockEntityChest) blockEntity).isPaired()) {
7981
chest = (BlockEntityChest) blockEntity;

src/main/java/cn/nukkit/block/BlockFire.java

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import cn.nukkit.item.ItemBlock;
1717
import cn.nukkit.level.GameRule;
1818
import cn.nukkit.level.Level;
19+
import cn.nukkit.level.format.FullChunk;
1920
import cn.nukkit.math.AxisAlignedBB;
2021
import cn.nukkit.math.BlockFace;
2122
import cn.nukkit.potion.Effect;
@@ -126,7 +127,7 @@ public int onUpdate(int type) {
126127
this.getLevel().canBlockSeeSky(this.west()) ||
127128
this.getLevel().canBlockSeeSky(this.south()) ||
128129
this.getLevel().canBlockSeeSky(this.north()))
129-
) {
130+
) {
130131

131132
this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
132133
}
@@ -158,12 +159,14 @@ public int onUpdate(int type) {
158159

159160
//TODO: decrease the o if the rainfall values are high
160161

161-
this.tryToCatchBlockOnFire(this.east(), 300 + o, meta);
162-
this.tryToCatchBlockOnFire(this.west(), 300 + o, meta);
163-
this.tryToCatchBlockOnFire(this.down(), 250 + o, meta);
164-
this.tryToCatchBlockOnFire(this.up(), 250 + o, meta);
165-
this.tryToCatchBlockOnFire(this.south(), 300 + o, meta);
166-
this.tryToCatchBlockOnFire(this.north(), 300 + o, meta);
162+
this.tryToCatchBlockOnFire(this.getSideIfLoaded(BlockFace.EAST), 300 + o, meta);
163+
this.tryToCatchBlockOnFire(this.getSideIfLoaded(BlockFace.WEST), 300 + o, meta);
164+
this.tryToCatchBlockOnFire(this.getSideIfLoaded(BlockFace.DOWN), 250 + o, meta);
165+
this.tryToCatchBlockOnFire(this.getSideIfLoaded(BlockFace.UP), 250 + o, meta);
166+
this.tryToCatchBlockOnFire(this.getSideIfLoaded(BlockFace.SOUTH), 300 + o, meta);
167+
this.tryToCatchBlockOnFire(this.getSideIfLoaded(BlockFace.NORTH), 300 + o, meta);
168+
169+
int dif = 40 + this.getLevel().getServer().getDifficulty() * 7;
167170

168171
for (int x = (int) (this.x - 1); x <= (int) (this.x + 1); ++x) {
169172
for (int z = (int) (this.z - 1); z <= (int) (this.z + 1); ++z) {
@@ -175,11 +178,16 @@ public int onUpdate(int type) {
175178
k += (y - (this.y + 1)) * 100;
176179
}
177180

178-
Block block = this.getLevel().getBlock(x, y, z);
181+
FullChunk chunk = this.getLevel().getChunkIfLoaded(x >> 4, z >> 4);
182+
if (chunk == null) {
183+
continue;
184+
}
185+
186+
Block block = this.getLevel().getBlock(chunk, x, y, z, false);
179187
int chance = getChanceOfNeighborsEncouragingFire(block);
180188

181189
if (chance > 0) {
182-
int t = (chance + 40 + this.getLevel().getServer().getDifficulty() * 7) / (meta + 30);
190+
int t = (chance + dif) / (meta + 30);
183191

184192
//TODO: decrease the t if the rainfall values are high
185193

@@ -210,8 +218,12 @@ public int onUpdate(int type) {
210218
}
211219

212220
private void tryToCatchBlockOnFire(Block block, int bound, int damage) {
213-
if (Utils.random.nextInt(bound) < block.getBurnAbility()) {
221+
int burnAbility = block.getBurnAbility();
222+
if (burnAbility == 0) {
223+
return;
224+
}
214225

226+
if (Utils.random.nextInt(bound) < burnAbility) {
215227
if (Utils.random.nextInt(damage + 10) < 5) {
216228
int meta = damage + (Utils.random.nextInt(5) >> 2);
217229

@@ -246,12 +258,12 @@ private static int getChanceOfNeighborsEncouragingFire(Block block) {
246258
return 0;
247259
} else {
248260
int chance = 0;
249-
chance = Math.max(chance, block.east().getBurnChance());
250-
chance = Math.max(chance, block.west().getBurnChance());
251-
chance = Math.max(chance, block.down().getBurnChance());
252-
chance = Math.max(chance, block.up().getBurnChance());
253-
chance = Math.max(chance, block.south().getBurnChance());
254-
chance = Math.max(chance, block.north().getBurnChance());
261+
chance = Math.max(chance, block.getSideIfLoaded(BlockFace.EAST).getBurnChance());
262+
chance = Math.max(chance, block.getSideIfLoaded(BlockFace.WEST).getBurnChance());
263+
chance = Math.max(chance, block.getSideIfLoaded(BlockFace.DOWN).getBurnChance());
264+
chance = Math.max(chance, block.getSideIfLoaded(BlockFace.UP).getBurnChance());
265+
chance = Math.max(chance, block.getSideIfLoaded(BlockFace.SOUTH).getBurnChance());
266+
chance = Math.max(chance, block.getSideIfLoaded(BlockFace.NORTH).getBurnChance());
255267
return chance;
256268
}
257269
}

0 commit comments

Comments
 (0)