Skip to content

Commit 789e805

Browse files
committed
more
1 parent 375831e commit 789e805

16 files changed

Lines changed: 1009 additions & 9 deletions
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package net.dmulloy2.protocol.wrappers.game.clientbound;
2+
3+
import com.comphenix.protocol.PacketType;
4+
import com.comphenix.protocol.events.PacketContainer;
5+
import net.dmulloy2.protocol.AbstractPacket;
6+
import org.bukkit.inventory.ItemStack;
7+
8+
import java.util.List;
9+
10+
/**
11+
* Wrapper for {@code ClientboundContainerSetContentPacket} (Play phase, clientbound).
12+
*
13+
* <p>Packet structure:
14+
* <ul>
15+
* <li>{@code int containerId} – ID of the container whose contents are being set</li>
16+
* <li>{@code int stateId} – state ID used for sync with the server</li>
17+
* <li>{@code List<ItemStack> items} – full slot contents</li>
18+
* <li>{@code ItemStack carriedItem} – item currently held on the cursor</li>
19+
* </ul>
20+
*/
21+
public class WrappedClientboundContainerSetContentPacket extends AbstractPacket {
22+
23+
public static final PacketType TYPE = PacketType.Play.Server.WINDOW_ITEMS;
24+
25+
public WrappedClientboundContainerSetContentPacket() {
26+
super(new PacketContainer(TYPE), TYPE);
27+
handle.getModifier().writeDefaults();
28+
}
29+
30+
public WrappedClientboundContainerSetContentPacket(PacketContainer packet) {
31+
super(packet, TYPE);
32+
}
33+
34+
public int getContainerId() {
35+
return handle.getIntegers().read(0);
36+
}
37+
38+
public void setContainerId(int containerId) {
39+
handle.getIntegers().write(0, containerId);
40+
}
41+
42+
public int getStateId() {
43+
return handle.getIntegers().read(1);
44+
}
45+
46+
public void setStateId(int stateId) {
47+
handle.getIntegers().write(1, stateId);
48+
}
49+
50+
public List<ItemStack> getItems() {
51+
return handle.getItemListModifier().read(0);
52+
}
53+
54+
public void setItems(List<ItemStack> items) {
55+
handle.getItemListModifier().write(0, items);
56+
}
57+
58+
public ItemStack getCarriedItem() {
59+
return handle.getItemModifier().read(0);
60+
}
61+
62+
public void setCarriedItem(ItemStack carriedItem) {
63+
handle.getItemModifier().write(0, carriedItem);
64+
}
65+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package net.dmulloy2.protocol.wrappers.game.clientbound;
2+
3+
import com.comphenix.protocol.PacketType;
4+
import com.comphenix.protocol.events.PacketContainer;
5+
import com.comphenix.protocol.wrappers.BukkitConverters;
6+
import net.dmulloy2.protocol.AbstractPacket;
7+
import org.bukkit.util.Vector;
8+
9+
import java.util.Optional;
10+
11+
/**
12+
* Wrapper for {@code ClientboundDamageEventPacket} (Play phase, clientbound).
13+
*
14+
* <p>Packet structure:
15+
* <ul>
16+
* <li>{@code int entityId} – entity that received the damage</li>
17+
* <li>{@code Holder<DamageType> sourceType} – damage type (not exposed; use the raw modifier)</li>
18+
* <li>{@code int sourceCauseId} – entity ID of the damage cause, or {@code 0} if absent</li>
19+
* <li>{@code int sourceDirectId} – entity ID of the direct source, or {@code 0} if absent</li>
20+
* <li>{@code Optional<Vector> sourcePosition} – world position of the damage source, if any</li>
21+
* </ul>
22+
*/
23+
public class WrappedClientboundDamageEventPacket extends AbstractPacket {
24+
25+
public static final PacketType TYPE = PacketType.Play.Server.DAMAGE_EVENT;
26+
27+
public WrappedClientboundDamageEventPacket() {
28+
super(new PacketContainer(TYPE), TYPE);
29+
handle.getModifier().writeDefaults();
30+
}
31+
32+
public WrappedClientboundDamageEventPacket(PacketContainer packet) {
33+
super(packet, TYPE);
34+
}
35+
36+
public int getEntityId() {
37+
return handle.getIntegers().read(0);
38+
}
39+
40+
public void setEntityId(int entityId) {
41+
handle.getIntegers().write(0, entityId);
42+
}
43+
44+
public int getSourceCauseId() {
45+
return handle.getIntegers().read(1);
46+
}
47+
48+
public void setSourceCauseId(int sourceCauseId) {
49+
handle.getIntegers().write(1, sourceCauseId);
50+
}
51+
52+
public int getSourceDirectId() {
53+
return handle.getIntegers().read(2);
54+
}
55+
56+
public void setSourceDirectId(int sourceDirectId) {
57+
handle.getIntegers().write(2, sourceDirectId);
58+
}
59+
60+
public Optional<Vector> getSourcePosition() {
61+
return handle.getOptionals(BukkitConverters.getVectorConverter()).read(0);
62+
}
63+
64+
public void setSourcePosition(Optional<Vector> sourcePosition) {
65+
handle.getOptionals(BukkitConverters.getVectorConverter()).write(0, sourcePosition);
66+
}
67+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package net.dmulloy2.protocol.wrappers.game.clientbound;
2+
3+
import com.comphenix.protocol.PacketType;
4+
import com.comphenix.protocol.events.PacketContainer;
5+
import net.dmulloy2.protocol.AbstractPacket;
6+
7+
/**
8+
* Wrapper for {@code ClientboundInitializeBorderPacket} (Play phase, clientbound).
9+
*
10+
* <p>Packet structure:
11+
* <ul>
12+
* <li>{@code double newCenterX}</li>
13+
* <li>{@code double newCenterZ}</li>
14+
* <li>{@code double oldSize}</li>
15+
* <li>{@code double newSize}</li>
16+
* <li>{@code long lerpTime}</li>
17+
* <li>{@code int newAbsoluteMaxSize}</li>
18+
* <li>{@code int warningBlocks}</li>
19+
* <li>{@code int warningTime}</li>
20+
* </ul>
21+
*/
22+
public class WrappedClientboundInitializeBorderPacket extends AbstractPacket {
23+
24+
public static final PacketType TYPE = PacketType.Play.Server.INITIALIZE_BORDER;
25+
26+
public WrappedClientboundInitializeBorderPacket() {
27+
super(new PacketContainer(TYPE), TYPE);
28+
handle.getModifier().writeDefaults();
29+
}
30+
31+
public WrappedClientboundInitializeBorderPacket(PacketContainer packet) {
32+
super(packet, TYPE);
33+
}
34+
35+
public double getNewCenterX() {
36+
return handle.getDoubles().read(0);
37+
}
38+
39+
public void setNewCenterX(double newCenterX) {
40+
handle.getDoubles().write(0, newCenterX);
41+
}
42+
43+
public double getNewCenterZ() {
44+
return handle.getDoubles().read(1);
45+
}
46+
47+
public void setNewCenterZ(double newCenterZ) {
48+
handle.getDoubles().write(1, newCenterZ);
49+
}
50+
51+
public double getOldSize() {
52+
return handle.getDoubles().read(2);
53+
}
54+
55+
public void setOldSize(double oldSize) {
56+
handle.getDoubles().write(2, oldSize);
57+
}
58+
59+
public double getNewSize() {
60+
return handle.getDoubles().read(3);
61+
}
62+
63+
public void setNewSize(double newSize) {
64+
handle.getDoubles().write(3, newSize);
65+
}
66+
67+
public long getLerpTime() {
68+
return handle.getLongs().read(0);
69+
}
70+
71+
public void setLerpTime(long lerpTime) {
72+
handle.getLongs().write(0, lerpTime);
73+
}
74+
75+
public int getNewAbsoluteMaxSize() {
76+
return handle.getIntegers().read(0);
77+
}
78+
79+
public void setNewAbsoluteMaxSize(int newAbsoluteMaxSize) {
80+
handle.getIntegers().write(0, newAbsoluteMaxSize);
81+
}
82+
83+
public int getWarningBlocks() {
84+
return handle.getIntegers().read(1);
85+
}
86+
87+
public void setWarningBlocks(int warningBlocks) {
88+
handle.getIntegers().write(1, warningBlocks);
89+
}
90+
91+
public int getWarningTime() {
92+
return handle.getIntegers().read(2);
93+
}
94+
95+
public void setWarningTime(int warningTime) {
96+
handle.getIntegers().write(2, warningTime);
97+
}
98+
}

src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundHorseScreenOpenPacket.java renamed to src/main/java/net/dmulloy2/protocol/wrappers/game/clientbound/WrappedClientboundMountScreenOpenPacket.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import net.dmulloy2.protocol.AbstractPacket;
66

77
/**
8-
* Wrapper for {@code ClientboundHorseScreenOpenPacket} (Play phase, clientbound).
8+
* Wrapper for {@code ClientboundMountScreenOpenPacket} (Play phase, clientbound).
99
*
1010
* <p>Packet structure:
1111
* <ul>
@@ -14,16 +14,16 @@
1414
* <li>{@code int entityId} – entity ID of the horse</li>
1515
* </ul>
1616
*/
17-
public class WrappedClientboundHorseScreenOpenPacket extends AbstractPacket {
17+
public class WrappedClientboundMountScreenOpenPacket extends AbstractPacket {
1818

1919
public static final PacketType TYPE = PacketType.Play.Server.OPEN_WINDOW_HORSE;
2020

21-
public WrappedClientboundHorseScreenOpenPacket() {
21+
public WrappedClientboundMountScreenOpenPacket() {
2222
super(new PacketContainer(TYPE), TYPE);
2323
handle.getModifier().writeDefaults();
2424
}
2525

26-
public WrappedClientboundHorseScreenOpenPacket(PacketContainer packet) {
26+
public WrappedClientboundMountScreenOpenPacket(PacketContainer packet) {
2727
super(packet, TYPE);
2828
}
2929

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package net.dmulloy2.protocol.wrappers.game.clientbound;
2+
3+
import com.comphenix.protocol.PacketType;
4+
import com.comphenix.protocol.events.PacketContainer;
5+
import com.comphenix.protocol.wrappers.WrappedChatComponent;
6+
import net.dmulloy2.protocol.AbstractPacket;
7+
8+
/**
9+
* Wrapper for {@code ClientboundOpenScreenPacket} (Play phase, clientbound).
10+
*
11+
* <p>Packet structure:
12+
* <ul>
13+
* <li>{@code int containerId} – ID assigned to this container session</li>
14+
* <li>{@code MenuType<?> type} – inventory menu type (not exposed; use the raw modifier)</li>
15+
* <li>{@code Component title} – display title shown in the inventory screen</li>
16+
* </ul>
17+
*/
18+
public class WrappedClientboundOpenScreenPacket extends AbstractPacket {
19+
20+
public static final PacketType TYPE = PacketType.Play.Server.OPEN_WINDOW;
21+
22+
public WrappedClientboundOpenScreenPacket() {
23+
super(new PacketContainer(TYPE), TYPE);
24+
handle.getModifier().writeDefaults();
25+
}
26+
27+
public WrappedClientboundOpenScreenPacket(PacketContainer packet) {
28+
super(packet, TYPE);
29+
}
30+
31+
public int getContainerId() {
32+
return handle.getIntegers().read(0);
33+
}
34+
35+
public void setContainerId(int containerId) {
36+
handle.getIntegers().write(0, containerId);
37+
}
38+
39+
public WrappedChatComponent getTitle() {
40+
return handle.getChatComponents().read(0);
41+
}
42+
43+
public void setTitle(WrappedChatComponent title) {
44+
handle.getChatComponents().write(0, title);
45+
}
46+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package net.dmulloy2.protocol.wrappers.game.clientbound;
2+
3+
import com.comphenix.protocol.PacketType;
4+
import com.comphenix.protocol.events.PacketContainer;
5+
import com.comphenix.protocol.wrappers.EnumWrappers;
6+
import com.comphenix.protocol.wrappers.WrappedPositionMoveRotation;
7+
import net.dmulloy2.protocol.AbstractPacket;
8+
9+
import java.util.Set;
10+
11+
/**
12+
* Wrapper for {@code ClientboundPlayerPositionPacket} (Play phase, clientbound).
13+
*
14+
* <p>Packet structure:
15+
* <ul>
16+
* <li>{@code int id} – teleport confirmation ID</li>
17+
* <li>{@code PositionMoveRotation change} – new position, delta, yaw and pitch</li>
18+
* <li>{@code Set<Relative> relatives} – which components are relative rather than absolute</li>
19+
* </ul>
20+
*/
21+
public class WrappedClientboundPlayerPositionPacket extends AbstractPacket {
22+
23+
public static final PacketType TYPE = PacketType.Play.Server.POSITION;
24+
25+
public WrappedClientboundPlayerPositionPacket() {
26+
super(new PacketContainer(TYPE), TYPE);
27+
handle.getModifier().writeDefaults();
28+
}
29+
30+
public WrappedClientboundPlayerPositionPacket(PacketContainer packet) {
31+
super(packet, TYPE);
32+
}
33+
34+
public int getId() {
35+
return handle.getIntegers().read(0);
36+
}
37+
38+
public void setId(int id) {
39+
handle.getIntegers().write(0, id);
40+
}
41+
42+
public WrappedPositionMoveRotation getChange() {
43+
return handle.getPositionMoveRotations().read(0);
44+
}
45+
46+
public void setChange(WrappedPositionMoveRotation change) {
47+
handle.getPositionMoveRotations().write(0, change);
48+
}
49+
50+
public Set<EnumWrappers.RelativeArgument> getRelatives() {
51+
return handle.getSets(EnumWrappers.getRelativeArgumentConverter()).read(0);
52+
}
53+
54+
public void setRelatives(Set<EnumWrappers.RelativeArgument> relatives) {
55+
handle.getSets(EnumWrappers.getRelativeArgumentConverter()).write(0, relatives);
56+
}
57+
}

0 commit comments

Comments
 (0)