Skip to content

Commit e79feea

Browse files
authored
Fixes
- Fixed updating boss bar text making client disconnect - Fixed ghost absorption hearts - Fixed some skins not displaying properly - Fixed painting placement checks and added new paintings from 1.21 - Fixed glow berries growing on already grown cave vines - Fixed hopper minecart activation - Fixed mangrove wood not working as furnace fuel - Fixed fungus and new trees not growing past y 255 - Fixed crimson planks hardness and resistance - Fixed turtle eggs placing wrong amount - Fixed Player.showFormWindow returning invalid id if failed, now returns -1 instead - Fixed drops of some deepslate ores - Fixed missing translations for /clear - Avoid multiple gamerule calls in level tick loop - Mending no longer attempts to repair non damaged items - getMin/MaxBlockY is now directly accessible through ChunkManager
1 parent 95c506e commit e79feea

Some content is hidden

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

66 files changed

+320
-396
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ protected void handleMovement(Vector3 newPos) {
21022102
server.getPluginManager().callEvent(waterFrostEvent);
21032103
if (!waterFrostEvent.isCancelled()) {
21042104
level.setBlockAt((int) block.x, (int) block.y, (int) block.z, Block.ICE_FROSTED, 0);
2105-
level.scheduleUpdate(level.getBlock(this.chunk, block.getFloorX(), block.getFloorY(), block.getFloorZ(), true), ThreadLocalRandom.current().nextInt(20, 40));
2105+
level.scheduleUpdate(level.getBlock(this.chunk, (int) block.getX(), (int) block.getY(), (int) block.getZ(), true), ThreadLocalRandom.current().nextInt(20, 40));
21062106
}
21072107
}
21082108
}
@@ -2466,7 +2466,7 @@ public EntityInteractable getEntityPlayerLookingAt(int maxDistance) {
24662466
Block block;
24672467
while (itr.hasNext()) {
24682468
block = itr.next();
2469-
entity = getEntityAtPosition(nearbyEntities, block.getFloorX(), block.getFloorY(), block.getFloorZ());
2469+
entity = getEntityAtPosition(nearbyEntities, (int) block.getX(), (int) block.getY(), (int) block.getZ());
24702470
if (entity != null) {
24712471
break;
24722472
}
@@ -6210,7 +6210,7 @@ public int showFormWindow(FormWindow window) {
62106210
* @return form id to use in {@link PlayerFormRespondedEvent}
62116211
*/
62126212
public int showFormWindow(FormWindow window, int id) {
6213-
if (formOpen) return 0;
6213+
if (formOpen) return -1;
62146214
ModalFormRequestPacket packet = new ModalFormRequestPacket();
62156215
packet.formId = id;
62166216
packet.data = window.getJSONData();
@@ -6940,17 +6940,19 @@ public boolean pickupEntity(Entity entity, boolean near) {
69406940

69416941
IntArrayList itemsWithMending = new IntArrayList();
69426942
for (int i = 0; i < 4; i++) {
6943-
if (this.inventory.getArmorItem(i).hasEnchantment(Enchantment.ID_MENDING)) {
6943+
Item item = inventory.getArmorItem(i);
6944+
if (item.getDamage() != 0 && item.hasEnchantment(Enchantment.ID_MENDING)) {
69446945
itemsWithMending.add(this.inventory.getSize() + i);
69456946
}
69466947
}
69476948

6948-
if (this.inventory.getItemInHandFast().hasEnchantment(Enchantment.ID_MENDING)) {
6949+
Item hand = inventory.getItemInHandFast();
6950+
if (hand.getDamage() != 0 && hand.hasEnchantment(Enchantment.ID_MENDING)) {
69496951
itemsWithMending.add(this.inventory.getHeldItemIndex());
69506952
}
69516953

69526954
Item offhand = this.getOffhandInventory().getItem(0);
6953-
if (offhand.getId() == Item.SHIELD && offhand.hasEnchantment(Enchantment.ID_MENDING)) {
6955+
if (offhand.getId() == Item.SHIELD && offhand.getDamage() != 0 && offhand.hasEnchantment(Enchantment.ID_MENDING)) {
69546956
itemsWithMending.add(-1);
69556957
}
69566958

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ public BlockLayer getLayer() {
972972
return this.layer;
973973
}
974974

975-
protected static boolean canConnectToFullSolid(Block down) {
975+
public static boolean canConnectToFullSolid(Block down) {
976976
if (down.isTransparent()) {
977977
switch (down.getId()) {
978978
case BEACON:

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ public int onUpdate(int type) {
7979
this.getLevel().useBreakOn(this, null, null, true);
8080
break;
8181
case Level.BLOCK_UPDATE_RANDOM:
82-
if (!this.tryGrowItself()) {
83-
this.tryGrow();
84-
}
82+
this.tryGrow();
8583
break;
8684
}
8785
return type;
@@ -171,16 +169,6 @@ private boolean tryGrow() {
171169
return true;
172170
}
173171

174-
private boolean tryGrowItself() {
175-
if (this.hasBerries() || ThreadLocalRandom.current().nextFloat() >= CHANCE_OF_BERRIES_ON_GROWTH) {
176-
return false;
177-
}
178-
179-
BlockCaveVines blockCaveVines = this.getStateWithBerries(this);
180-
this.getLevel().setBlock(this, blockCaveVines, true, true);
181-
return true;
182-
}
183-
184172
public BlockCaveVines getStateWithBerries(Position position) {
185173
if (this.getDamage() == 0) {
186174
return (BlockCaveVines) Block.get(CAVE_VINES_HEAD_WITH_BERRIES, 0, position);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public int getId() {
2424
}
2525

2626
@Override
27-
public int getBurnChance() {
28-
return 0;
27+
public double getHardness() {
28+
return 2;
2929
}
3030

3131
@Override
32-
public int getBurnAbility() {
33-
return 0;
32+
public double getResistance() {
33+
return 3;
3434
}
3535

3636
@Override

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,4 @@ public double getResistance() {
3636
public Item[] getDrops(Item item) {
3737
return new Item[0];
3838
}
39-
40-
@Override
41-
public boolean canSilkTouch() {
42-
return true;
43-
}
4439
}

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

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,26 @@ public BlockOre() {
1414

1515
@Override
1616
public Item[] getDrops(Item item) {
17-
if (!this.canHarvest(item) || item.getTier() < this.getToolTier()) {
17+
if (item.isPickaxe() && item.getTier() >= this.getToolTier()) {
18+
if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
19+
return new Item[]{this.toItem()};
20+
}
21+
22+
int rawMaterial = this.getRawMaterial();
23+
if (rawMaterial == BlockID.AIR) {
24+
return super.getDrops(item);
25+
}
26+
27+
int amount = 1;
28+
int fortuneLevel = NukkitMath.clamp(item.getEnchantmentLevel(Enchantment.ID_FORTUNE_DIGGING), 0, 3);
29+
if (fortuneLevel > 0) {
30+
amount += ThreadLocalRandom.current().nextInt(fortuneLevel + 1);
31+
}
32+
33+
return new Item[]{Item.get(rawMaterial, this.getRawMaterialMeta(), amount)};
34+
} else {
1835
return new Item[0];
1936
}
20-
21-
if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
22-
return new Item[]{this.toItem()};
23-
}
24-
25-
int rawMaterial = this.getRawMaterial();
26-
if (rawMaterial == BlockID.AIR) {
27-
return super.getDrops(item);
28-
}
29-
30-
float multiplier = this.getDropMultiplier();
31-
int amount = (int) multiplier;
32-
if (amount > 1) {
33-
amount = 1 + ThreadLocalRandom.current().nextInt(amount);
34-
}
35-
int fortuneLevel = NukkitMath.clamp(item.getEnchantmentLevel(Enchantment.ID_FORTUNE_DIGGING), 0, 3);
36-
if (fortuneLevel > 0) {
37-
int increase = ThreadLocalRandom.current().nextInt((int)(multiplier * fortuneLevel) + 1);
38-
amount += increase;
39-
}
40-
return new Item[]{ Item.get(rawMaterial, this.getRawMaterialMeta(), amount) };
4137
}
4238

4339
protected abstract int getRawMaterial();

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

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package cn.nukkit.block;
22

33
import cn.nukkit.item.Item;
4-
import cn.nukkit.item.ItemTool;
4+
import cn.nukkit.item.ItemID;
55
import cn.nukkit.item.enchantment.Enchantment;
66
import cn.nukkit.utils.Utils;
77

@@ -11,28 +11,13 @@
1111
* @author MagicDroidX
1212
* Nukkit Project
1313
*/
14-
public class BlockOreCoal extends BlockSolid {
14+
public class BlockOreCoal extends BlockOre {
1515

1616
@Override
1717
public int getId() {
1818
return COAL_ORE;
1919
}
2020

21-
@Override
22-
public double getHardness() {
23-
return 3;
24-
}
25-
26-
@Override
27-
public double getResistance() {
28-
return 3;
29-
}
30-
31-
@Override
32-
public int getToolType() {
33-
return ItemTool.TYPE_PICKAXE;
34-
}
35-
3621
@Override
3722
public String getName() {
3823
return "Coal Ore";
@@ -66,17 +51,12 @@ public Item[] getDrops(Item item) {
6651
}
6752

6853
@Override
69-
public int getDropExp() {
70-
return Utils.rand(0, 2);
54+
protected int getRawMaterial() {
55+
return ItemID.COAL;
7156
}
7257

7358
@Override
74-
public boolean canHarvestWithHand() {
75-
return false;
76-
}
77-
78-
@Override
79-
public boolean canSilkTouch() {
80-
return true;
59+
public int getDropExp() {
60+
return Utils.rand(0, 2);
8161
}
8262
}
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
package cn.nukkit.block;
22

3-
import cn.nukkit.item.ItemID;
43
import cn.nukkit.utils.BlockColor;
5-
import cn.nukkit.utils.Utils;
64

7-
public class BlockOreCoalDeepslate extends BlockOre {
5+
public class BlockOreCoalDeepslate extends BlockOreCoal {
86

97
public BlockOreCoalDeepslate() {
108
}
119

12-
@Override
13-
protected int getRawMaterial() {
14-
return ItemID.COAL;
15-
}
16-
1710
@Override
1811
public int getId() {
1912
return DEEPSLATE_COAL_ORE;
@@ -33,9 +26,4 @@ public String getName() {
3326
public BlockColor getColor() {
3427
return BlockColor.DEEPSLATE_GRAY;
3528
}
36-
37-
@Override
38-
public int getDropExp() {
39-
return Utils.rand(0, 2);
40-
}
4129
}

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package cn.nukkit.block;
22

3+
import cn.nukkit.item.Item;
34
import cn.nukkit.item.ItemID;
5+
import cn.nukkit.item.enchantment.Enchantment;
6+
import cn.nukkit.math.NukkitMath;
47
import cn.nukkit.utils.Utils;
58

9+
import java.util.concurrent.ThreadLocalRandom;
10+
611
public class BlockOreCopper extends BlockOre {
712

813
public BlockOreCopper() {
@@ -33,4 +38,27 @@ protected float getDropMultiplier() {
3338
public int getDropExp() {
3439
return Utils.rand(0, 2);
3540
}
41+
42+
@Override
43+
public Item[] getDrops(Item item) {
44+
if (item.isPickaxe() && item.getTier() >= this.getToolTier()) {
45+
if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
46+
return new Item[]{this.toItem()};
47+
}
48+
49+
float multiplier = this.getDropMultiplier();
50+
int amount = (int) multiplier;
51+
if (amount > 1) {
52+
amount = 2 + ThreadLocalRandom.current().nextInt(amount + 1);
53+
}
54+
int fortuneLevel = NukkitMath.clamp(item.getEnchantmentLevel(Enchantment.ID_FORTUNE_DIGGING), 0, 3);
55+
if (fortuneLevel > 0) {
56+
int increase = ThreadLocalRandom.current().nextInt((int)(multiplier * fortuneLevel) + 1);
57+
amount += increase;
58+
}
59+
return new Item[]{ Item.get(this.getRawMaterial(), this.getRawMaterialMeta(), amount) };
60+
} else {
61+
return new Item[0];
62+
}
63+
}
3664
}

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

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cn.nukkit.block;
22

33
import cn.nukkit.item.Item;
4+
import cn.nukkit.item.ItemID;
45
import cn.nukkit.item.ItemTool;
56
import cn.nukkit.item.enchantment.Enchantment;
67
import cn.nukkit.utils.Utils;
@@ -11,28 +12,13 @@
1112
* @author MagicDroidX
1213
* Nukkit Project
1314
*/
14-
public class BlockOreDiamond extends BlockSolid {
15+
public class BlockOreDiamond extends BlockOre {
1516

1617
@Override
1718
public int getId() {
1819
return DIAMOND_ORE;
1920
}
2021

21-
@Override
22-
public double getHardness() {
23-
return 3;
24-
}
25-
26-
@Override
27-
public double getResistance() {
28-
return 3;
29-
}
30-
31-
@Override
32-
public int getToolType() {
33-
return ItemTool.TYPE_PICKAXE;
34-
}
35-
3622
@Override
3723
public String getName() {
3824
return "Diamond Ore";
@@ -66,17 +52,17 @@ public Item[] getDrops(Item item) {
6652
}
6753

6854
@Override
69-
public int getDropExp() {
70-
return Utils.rand(3, 7);
55+
protected int getRawMaterial() {
56+
return ItemID.DIAMOND;
7157
}
7258

7359
@Override
74-
public boolean canHarvestWithHand() {
75-
return false;
60+
public int getDropExp() {
61+
return Utils.rand(3, 7);
7662
}
77-
63+
7864
@Override
79-
public boolean canSilkTouch() {
80-
return true;
65+
public int getToolTier() {
66+
return ItemTool.TIER_IRON;
8167
}
8268
}

0 commit comments

Comments
 (0)