Skip to content

Commit 4344117

Browse files
authored
1.21.20
1 parent 9cc88d0 commit 4344117

27 files changed

+106
-34
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5547,4 +5547,12 @@ public void setHudElementVisibility(boolean visible, HudElement... elements) {
55475547
pk.visible = visible;
55485548
this.dataPacket(pk);
55495549
}
5550+
5551+
/**
5552+
* Close form windows sent with showFormWindow
5553+
*/
5554+
public void closeFormWindows() {
5555+
this.formWindows.clear();
5556+
this.dataPacket(new ClientboundCloseFormPacket());
5557+
}
55505558
}

src/main/java/cn/nukkit/inventory/transaction/data/UseItemData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
public class UseItemData implements TransactionData {
1515

1616
public int actionType;
17+
public int triggerType;
1718
public BlockVector3 blockPos;
1819
public BlockFace face;
1920
public int hotbarSlot;
2021
public Item itemInHand;
2122
public Vector3 playerPos;
2223
public Vector3f clickPos;
2324
public int blockRuntimeId;
25+
public int clientInteractPrediction;
2426
}

src/main/java/cn/nukkit/item/ItemPotion.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public boolean onUse(Player player, int ticksUsed) {
7474
if (consumeEvent.isCancelled()) {
7575
return false;
7676
}
77-
Potion potion = Potion.getPotion(this.getDamage()).setSplash(false);
77+
Potion potion = Potion.getPotion(this.getDamage());
7878

7979
if (player.isAdventure() || player.isSurvival()) {
8080
--this.count;
@@ -83,6 +83,7 @@ public boolean onUse(Player player, int ticksUsed) {
8383
}
8484

8585
if (potion != null) {
86+
potion.setSplash(false);
8687
potion.applyPotion(player);
8788
}
8889
return true;

src/main/java/cn/nukkit/level/particle/Particle.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public abstract class Particle extends Vector3 {
2828
public static final int TYPE_SNOWBALL_POOF = 15;
2929
public static final int TYPE_HUGE_EXPLODE = 16;
3030
public static final int TYPE_HUGE_EXPLODE_SEED = 17;
31-
public static final int TYPE_WIND_EXPLOSION = 18;
31+
public static final int BREEZE_WIND_EXPLOSION = 18;
3232
public static final int TYPE_MOB_FLAME = 19;
3333
public static final int TYPE_HEART = 20;
3434
public static final int TYPE_TERRAIN = 21;
@@ -99,6 +99,10 @@ public abstract class Particle extends Vector3 {
9999
public static final int TYPE_CHERRY_LEAVES = 87;
100100
public static final int TYPE_DUST_PLUME = 88;
101101
public static final int TYPE_WHITE_SMOKE = 89;
102+
public static final int TYPE_VAULT_CONNECTION = 90;
103+
public static final int TYPE_WIND_EXPLOSION = 91;
104+
public static final int TYPE_WOLF_ARMOR_BREAK = 92;
105+
public static final int TYPE_OMINOUS_ITEM_SPAWNER = 93;
102106

103107
public static Integer getParticleIdByName(String name) {
104108
name = name.toUpperCase();

src/main/java/cn/nukkit/network/protocol/ChangeDimensionPacket.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class ChangeDimensionPacket extends DataPacket {
1919

2020
public boolean respawn;
2121

22+
public Integer loadingScreenId = null;
23+
2224
@Override
2325
public void decode() {
2426

@@ -30,6 +32,10 @@ public void encode() {
3032
this.putVarInt(this.dimension);
3133
this.putVector3f(this.x, this.y, this.z);
3234
this.putBoolean(this.respawn);
35+
this.putBoolean(this.loadingScreenId != null);
36+
if (this.loadingScreenId != null) {
37+
this.putLInt(this.loadingScreenId);
38+
}
3339
}
3440

3541
@Override
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package cn.nukkit.network.protocol;
2+
3+
import lombok.ToString;
4+
5+
@ToString
6+
public class ClientboundCloseFormPacket extends DataPacket {
7+
8+
public static final byte NETWORK_ID = ProtocolInfo.__INTERNAL__CLIENTBOUND_CLOSE_FORM_PACKET;
9+
10+
@Override
11+
public byte pid() {
12+
return NETWORK_ID;
13+
}
14+
15+
@Override
16+
public void decode() {
17+
}
18+
19+
@Override
20+
public void encode() {
21+
this.reset();
22+
// No payload
23+
}
24+
}

src/main/java/cn/nukkit/network/protocol/DisconnectPacket.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
*/
88
@ToString
99
public class DisconnectPacket extends DataPacket {
10+
1011
public static final byte NETWORK_ID = ProtocolInfo.DISCONNECT_PACKET;
1112

12-
public boolean hideDisconnectionScreen = false;
13+
public boolean hideDisconnectionScreen;
1314
public String message;
15+
public String filteredMessage = "";
1416

1517
@Override
1618
public byte pid() {
@@ -22,6 +24,7 @@ public void decode() {
2224
this.getVarInt(); // Disconnect fail reason
2325
this.hideDisconnectionScreen = this.getBoolean();
2426
this.message = this.getString();
27+
this.filteredMessage = this.getString();
2528
}
2629

2730
@Override
@@ -31,8 +34,7 @@ public void encode() {
3134
this.putBoolean(this.hideDisconnectionScreen);
3235
if (!this.hideDisconnectionScreen) {
3336
this.putString(this.message);
37+
this.putString(this.filteredMessage);
3438
}
3539
}
36-
37-
3840
}

src/main/java/cn/nukkit/network/protocol/InventoryContentPacket.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public byte pid() {
2525

2626
public int inventoryId;
2727
public Item[] slots = new Item[0];
28+
public int dynamicContainerId;
2829

2930
@Override
3031
public DataPacket clean() {
@@ -45,6 +46,7 @@ public void encode() {
4546
for (Item slot : this.slots) {
4647
this.putSlot(slot);
4748
}
49+
this.putUnsignedVarInt(this.dynamicContainerId);
4850
}
4951

5052
@Override

src/main/java/cn/nukkit/network/protocol/InventorySlotPacket.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
@ToString
1111
public class InventorySlotPacket extends DataPacket {
12+
1213
public static final byte NETWORK_ID = ProtocolInfo.INVENTORY_SLOT_PACKET;
1314

1415
@Override
@@ -19,19 +20,18 @@ public byte pid() {
1920
public int inventoryId;
2021
public int slot;
2122
public Item item;
23+
public int dynamicContainerId;
2224

2325
@Override
2426
public void decode() {
25-
this.inventoryId = (int) this.getUnsignedVarInt();
26-
this.slot = (int) this.getUnsignedVarInt();
27-
this.item = this.getSlot();
2827
}
2928

3029
@Override
3130
public void encode() {
3231
this.reset();
3332
this.putUnsignedVarInt(this.inventoryId);
3433
this.putUnsignedVarInt(this.slot);
34+
this.putUnsignedVarInt(this.dynamicContainerId);
3535
this.putSlot(this.item);
3636
}
3737
}

src/main/java/cn/nukkit/network/protocol/InventoryTransactionPacket.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,15 @@ public void encode() {
7373
UseItemData useItemData = (UseItemData) this.transactionData;
7474

7575
this.putUnsignedVarInt(useItemData.actionType);
76+
this.putUnsignedVarInt(useItemData.triggerType);
7677
this.putBlockVector3(useItemData.blockPos);
7778
this.putBlockFace(useItemData.face);
7879
this.putVarInt(useItemData.hotbarSlot);
7980
this.putSlot(useItemData.itemInHand);
8081
this.putVector3f(useItemData.playerPos.asVector3f());
8182
this.putVector3f(useItemData.clickPos);
8283
this.putUnsignedVarInt(useItemData.blockRuntimeId);
84+
this.putUnsignedVarInt(useItemData.clientInteractPrediction);
8385
break;
8486
case TYPE_USE_ITEM_ON_ENTITY:
8587
UseItemOnEntityData useItemOnEntityData = (UseItemOnEntityData) this.transactionData;
@@ -135,13 +137,15 @@ public void decode() {
135137
UseItemData itemData = new UseItemData();
136138

137139
itemData.actionType = (int) this.getUnsignedVarInt();
140+
itemData.triggerType = (int) this.getUnsignedVarInt();
138141
itemData.blockPos = this.getBlockVector3();
139142
itemData.face = this.getBlockFace();
140143
itemData.hotbarSlot = this.getVarInt();
141144
itemData.itemInHand = this.getSlot();
142145
itemData.playerPos = this.getVector3f().asVector3();
143146
itemData.clickPos = this.getVector3f();
144147
itemData.blockRuntimeId = (int) this.getUnsignedVarInt();
148+
itemData.clientInteractPrediction = (int) this.getUnsignedVarInt();
145149

146150
this.transactionData = itemData;
147151
break;

0 commit comments

Comments
 (0)