Skip to content

Commit

Permalink
1.21.20
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriM1 authored Aug 13, 2024
1 parent 9cc88d0 commit 4344117
Show file tree
Hide file tree
Showing 27 changed files with 106 additions and 34 deletions.
8 changes: 8 additions & 0 deletions src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -5547,4 +5547,12 @@ public void setHudElementVisibility(boolean visible, HudElement... elements) {
pk.visible = visible;
this.dataPacket(pk);
}

/**
* Close form windows sent with showFormWindow
*/
public void closeFormWindows() {
this.formWindows.clear();
this.dataPacket(new ClientboundCloseFormPacket());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
public class UseItemData implements TransactionData {

public int actionType;
public int triggerType;
public BlockVector3 blockPos;
public BlockFace face;
public int hotbarSlot;
public Item itemInHand;
public Vector3 playerPos;
public Vector3f clickPos;
public int blockRuntimeId;
public int clientInteractPrediction;
}
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/item/ItemPotion.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public boolean onUse(Player player, int ticksUsed) {
if (consumeEvent.isCancelled()) {
return false;
}
Potion potion = Potion.getPotion(this.getDamage()).setSplash(false);
Potion potion = Potion.getPotion(this.getDamage());

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

if (potion != null) {
potion.setSplash(false);
potion.applyPotion(player);
}
return true;
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/cn/nukkit/level/particle/Particle.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class Particle extends Vector3 {
public static final int TYPE_SNOWBALL_POOF = 15;
public static final int TYPE_HUGE_EXPLODE = 16;
public static final int TYPE_HUGE_EXPLODE_SEED = 17;
public static final int TYPE_WIND_EXPLOSION = 18;
public static final int BREEZE_WIND_EXPLOSION = 18;
public static final int TYPE_MOB_FLAME = 19;
public static final int TYPE_HEART = 20;
public static final int TYPE_TERRAIN = 21;
Expand Down Expand Up @@ -99,6 +99,10 @@ public abstract class Particle extends Vector3 {
public static final int TYPE_CHERRY_LEAVES = 87;
public static final int TYPE_DUST_PLUME = 88;
public static final int TYPE_WHITE_SMOKE = 89;
public static final int TYPE_VAULT_CONNECTION = 90;
public static final int TYPE_WIND_EXPLOSION = 91;
public static final int TYPE_WOLF_ARMOR_BREAK = 92;
public static final int TYPE_OMINOUS_ITEM_SPAWNER = 93;

public static Integer getParticleIdByName(String name) {
name = name.toUpperCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class ChangeDimensionPacket extends DataPacket {

public boolean respawn;

public Integer loadingScreenId = null;

@Override
public void decode() {

Expand All @@ -30,6 +32,10 @@ public void encode() {
this.putVarInt(this.dimension);
this.putVector3f(this.x, this.y, this.z);
this.putBoolean(this.respawn);
this.putBoolean(this.loadingScreenId != null);
if (this.loadingScreenId != null) {
this.putLInt(this.loadingScreenId);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cn.nukkit.network.protocol;

import lombok.ToString;

@ToString
public class ClientboundCloseFormPacket extends DataPacket {

public static final byte NETWORK_ID = ProtocolInfo.__INTERNAL__CLIENTBOUND_CLOSE_FORM_PACKET;

@Override
public byte pid() {
return NETWORK_ID;
}

@Override
public void decode() {
}

@Override
public void encode() {
this.reset();
// No payload
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
*/
@ToString
public class DisconnectPacket extends DataPacket {

public static final byte NETWORK_ID = ProtocolInfo.DISCONNECT_PACKET;

public boolean hideDisconnectionScreen = false;
public boolean hideDisconnectionScreen;
public String message;
public String filteredMessage = "";

@Override
public byte pid() {
Expand All @@ -22,6 +24,7 @@ public void decode() {
this.getVarInt(); // Disconnect fail reason
this.hideDisconnectionScreen = this.getBoolean();
this.message = this.getString();
this.filteredMessage = this.getString();
}

@Override
Expand All @@ -31,8 +34,7 @@ public void encode() {
this.putBoolean(this.hideDisconnectionScreen);
if (!this.hideDisconnectionScreen) {
this.putString(this.message);
this.putString(this.filteredMessage);
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public byte pid() {

public int inventoryId;
public Item[] slots = new Item[0];
public int dynamicContainerId;

@Override
public DataPacket clean() {
Expand All @@ -45,6 +46,7 @@ public void encode() {
for (Item slot : this.slots) {
this.putSlot(slot);
}
this.putUnsignedVarInt(this.dynamicContainerId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
@ToString
public class InventorySlotPacket extends DataPacket {

public static final byte NETWORK_ID = ProtocolInfo.INVENTORY_SLOT_PACKET;

@Override
Expand All @@ -19,19 +20,18 @@ public byte pid() {
public int inventoryId;
public int slot;
public Item item;
public int dynamicContainerId;

@Override
public void decode() {
this.inventoryId = (int) this.getUnsignedVarInt();
this.slot = (int) this.getUnsignedVarInt();
this.item = this.getSlot();
}

@Override
public void encode() {
this.reset();
this.putUnsignedVarInt(this.inventoryId);
this.putUnsignedVarInt(this.slot);
this.putUnsignedVarInt(this.dynamicContainerId);
this.putSlot(this.item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ public void encode() {
UseItemData useItemData = (UseItemData) this.transactionData;

this.putUnsignedVarInt(useItemData.actionType);
this.putUnsignedVarInt(useItemData.triggerType);
this.putBlockVector3(useItemData.blockPos);
this.putBlockFace(useItemData.face);
this.putVarInt(useItemData.hotbarSlot);
this.putSlot(useItemData.itemInHand);
this.putVector3f(useItemData.playerPos.asVector3f());
this.putVector3f(useItemData.clickPos);
this.putUnsignedVarInt(useItemData.blockRuntimeId);
this.putUnsignedVarInt(useItemData.clientInteractPrediction);
break;
case TYPE_USE_ITEM_ON_ENTITY:
UseItemOnEntityData useItemOnEntityData = (UseItemOnEntityData) this.transactionData;
Expand Down Expand Up @@ -135,13 +137,15 @@ public void decode() {
UseItemData itemData = new UseItemData();

itemData.actionType = (int) this.getUnsignedVarInt();
itemData.triggerType = (int) this.getUnsignedVarInt();
itemData.blockPos = this.getBlockVector3();
itemData.face = this.getBlockFace();
itemData.hotbarSlot = this.getVarInt();
itemData.itemInHand = this.getSlot();
itemData.playerPos = this.getVector3f().asVector3();
itemData.clickPos = this.getVector3f();
itemData.blockRuntimeId = (int) this.getUnsignedVarInt();
itemData.clientInteractPrediction = (int) this.getUnsignedVarInt();

this.transactionData = itemData;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ public byte pid() {
return NETWORK_ID;
}

private static final Item AIR = Item.get(Item.AIR);

public long eid;
public Item[] slots = new Item[4];
public Item body = AIR;

@Override
public void decode() {
Expand All @@ -27,6 +30,7 @@ public void decode() {
this.slots[1] = this.getSlot();
this.slots[2] = this.getSlot();
this.slots[3] = this.getSlot();
this.body = this.getSlot();
}

@Override
Expand All @@ -37,5 +41,6 @@ public void encode() {
this.putSlot(this.slots[1]);
this.putSlot(this.slots[2]);
this.putSlot(this.slots[3]);
this.putSlot(this.body);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public enum PlayerArmorDamageFlag {
HELMET,
CHESTPLATE,
LEGGINGS,
BOOTS
BOOTS,
BODY
}
}
11 changes: 8 additions & 3 deletions src/main/java/cn/nukkit/network/protocol/ProtocolInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public interface ProtocolInfo {
* Actual Minecraft: PE protocol version
*/
@SuppressWarnings("UnnecessaryBoxing")
int CURRENT_PROTOCOL = Integer.valueOf("686"); // DO NOT REMOVE BOXING
int CURRENT_PROTOCOL = Integer.valueOf("712"); // DO NOT REMOVE BOXING

List<Integer> SUPPORTED_PROTOCOLS = Ints.asList(685, CURRENT_PROTOCOL);
List<Integer> SUPPORTED_PROTOCOLS = Ints.asList(CURRENT_PROTOCOL);

String MINECRAFT_VERSION_NETWORK = "1.21.2";
String MINECRAFT_VERSION_NETWORK = "1.21.20";
String MINECRAFT_VERSION = 'v' + MINECRAFT_VERSION_NETWORK;

byte BATCH_PACKET = (byte) 0xff;
Expand Down Expand Up @@ -230,4 +230,9 @@ public interface ProtocolInfo {
byte __INTERNAL__SET_PLAYER_INVENTORY_OPTIONS_PACKET = (byte) 207;
byte __INTERNAL__SET_HUD_PACKET = (byte) 208;
byte __INTERNAL__AWARD_ACHIEVEMENT_PACKET = (byte) 209;
byte __INTERNAL__CLIENTBOUND_CLOSE_FORM_PACKET = (byte) 210;
byte __INTERNAL__SERVERBOUND_LOADING_SCREEN_PACKET = (byte) 212;
byte __INTERNAL__JIGSAW_STRUCTURE_DATA_PACKET = (byte) 213;
byte __INTERNAL__CURRENT_STRUCTURE_FEATURE_PACKET = (byte) 214;
byte __INTERNAL__SERVERBOUND_DIAGNOSTICS_PACKET = (byte) 215;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ private void encodeBehaviourPacks(ResourcePack[] packs) {
this.putString(entry.getPackId().toString());
this.putString(entry.getPackVersion());
this.putLLong(entry.getPackSize());
this.putString(""); // encryption key
this.putString(entry.getEncryptionKey());
this.putString(""); // sub-pack name
this.putString(""); // content identity
this.putString(!entry.getEncryptionKey().isEmpty() ? entry.getPackId().toString() : "");
this.putBoolean(false); // scripting
}
}
Expand All @@ -61,10 +61,11 @@ private void encodeResourcePacks(ResourcePack[] packs) {
this.putString(entry.getPackId().toString());
this.putString(entry.getPackVersion());
this.putLLong(entry.getPackSize());
this.putString(entry.getEncryptionKey()); // encryption key
this.putString(entry.getEncryptionKey());
this.putString(""); // sub-pack name
this.putString(!entry.getEncryptionKey().equals("") ? entry.getPackId().toString() : ""); // content identity
this.putString(!entry.getEncryptionKey().isEmpty() ? entry.getPackId().toString() : "");
this.putBoolean(false); // scripting
this.putBoolean(false); // isAddonPack
this.putBoolean(false); // raytracing capable
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class SetEntityLinkPacket extends DataPacket {
public long riderUniqueId; //to
public byte type;
public byte immediate;
public boolean riderInitiated = false;
public boolean riderInitiated;
public float vehicleAngularVelocity;

@Override
public void decode() {
Expand All @@ -33,6 +34,7 @@ public void encode() {
this.putByte(this.type);
this.putByte(this.immediate);
this.putBoolean(this.riderInitiated);
this.putLFloat(this.vehicleAngularVelocity);
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/cn/nukkit/network/protocol/SetTitlePacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class SetTitlePacket extends DataPacket {
public int fadeOutTime = 0;
public String xuid = "";
public String platformOnlineId = "";
public String filteredTitleText = "";

@Override
public byte pid() {
Expand Down Expand Up @@ -50,5 +51,6 @@ public void encode() {
this.putVarInt(fadeOutTime);
this.putString(this.xuid);
this.putString(this.platformOnlineId);
this.putString(this.filteredTitleText);
}
}
2 changes: 2 additions & 0 deletions src/main/java/cn/nukkit/network/protocol/StopSoundPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class StopSoundPacket extends DataPacket {

public String name;
public boolean stopAll;
public boolean stopMusicLegacy;

@Override
public byte pid() {
Expand All @@ -25,5 +26,6 @@ public void encode() {
this.reset();
this.putString(this.name);
this.putBoolean(this.stopAll);
this.putBoolean(this.stopMusicLegacy);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum Type {
BASE,
SPECTATOR,
COMMANDS,
EDITOR
EDITOR,
LOADING_SCREEN
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ public class EntityLink {
public byte type;
public boolean immediate;
public boolean riderInitiated;
public float vehicleAngularVelocity;

public EntityLink(long fromEntityUniquieId, long toEntityUniquieId, byte type, boolean immediate, boolean riderInitiated) {
this(fromEntityUniquieId, toEntityUniquieId, type, immediate, riderInitiated, 0f);
}

public EntityLink(long fromEntityUniquieId, long toEntityUniquieId, byte type, boolean immediate, boolean riderInitiated, float vehicleAngularVelocity) {
this.fromEntityUniquieId = fromEntityUniquieId;
this.toEntityUniquieId = toEntityUniquieId;
this.type = type;
this.immediate = immediate;
this.riderInitiated = riderInitiated;
this.vehicleAngularVelocity = vehicleAngularVelocity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ public enum HudElement {
FOOD_BAR,
AIR_BUBBLES_BAR,
VEHICLE_HEALTH,
/**
* @since v671
*/
EFFECTS_BAR,
/**
* @since v671
*/
ITEM_TEXT_POPUP
}
Loading

0 comments on commit 4344117

Please sign in to comment.