-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to hide hud elements (#2183)
- Loading branch information
Showing
5 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/cn/nukkit/network/protocol/SetHudPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cn.nukkit.network.protocol; | ||
|
||
import cn.nukkit.network.protocol.types.HudElement; | ||
import it.unimi.dsi.fastutil.objects.ObjectArrayList; | ||
import lombok.ToString; | ||
|
||
import java.util.List; | ||
|
||
@ToString | ||
public class SetHudPacket extends DataPacket { | ||
|
||
public static final byte NETWORK_ID = ProtocolInfo.__INTERNAL__SET_HUD_PACKET; | ||
|
||
public final List<HudElement> elements = new ObjectArrayList<>(); | ||
public boolean visible; | ||
|
||
@Override | ||
public byte pid() { | ||
return NETWORK_ID; | ||
} | ||
|
||
@Override | ||
public void decode() { | ||
} | ||
|
||
@Override | ||
public void encode() { | ||
this.reset(); | ||
this.putUnsignedVarInt(this.elements.size()); | ||
for (HudElement element : this.elements) { | ||
this.putUnsignedVarInt(element.ordinal()); | ||
} | ||
this.putBoolean(this.visible); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/cn/nukkit/network/protocol/types/HudElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cn.nukkit.network.protocol.types; | ||
|
||
public enum HudElement { | ||
|
||
PAPER_DOLL, | ||
ARMOR, | ||
TOOL_TIPS, | ||
TOUCH_CONTROLS, | ||
CROSSHAIR, | ||
HOTBAR, | ||
HEALTH, | ||
PROGRESS_BAR, | ||
FOOD_BAR, | ||
AIR_BUBBLES_BAR, | ||
VEHICLE_HEALTH, | ||
/** | ||
* @since v671 | ||
*/ | ||
EFFECTS_BAR, | ||
/** | ||
* @since v671 | ||
*/ | ||
ITEM_TEXT_POPUP | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters