Skip to content

Commit

Permalink
Allow packets to be cloned
Browse files Browse the repository at this point in the history
  • Loading branch information
Alemiz112 committed Sep 10, 2024
1 parent 3292436 commit e0a9b18
Show file tree
Hide file tree
Showing 214 changed files with 2,103 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.ADD_BEHAVIOR_TREE;
}

@Override
public AddBehaviorTreePacket clone() {
try {
return (AddBehaviorTreePacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.ADD_ENTITY;
}

@Override
public AddEntityPacket clone() {
try {
return (AddEntityPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@ public PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.ADD_HANGING_ENTITY;
}

@Override
public AddHangingEntityPacket clone() {
try {
return (AddHangingEntityPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.ADD_ITEM_ENTITY;
}

@Override
public AddItemEntityPacket clone() {
try {
return (AddItemEntityPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.ADD_PAINTING;
}

@Override
public AddPaintingPacket clone() {
return (AddPaintingPacket) super.clone();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.ADD_PLAYER;
}

@Override
public AddPlayerPacket clone() {
try {
return (AddPlayerPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,14 @@ public PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.ADD_VOLUME_ENTITY;
}

@Override
public AddVolumeEntityPacket clone() {
try {
return (AddVolumeEntityPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.ADVENTURE_SETTINGS;
}

@Override
public AdventureSettingsPacket clone() {
try {
return (AdventureSettingsPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,14 @@ public PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.AGENT_ACTION_EVENT;
}

@Override
public AgentActionEventPacket clone() {
try {
return (AgentActionEventPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.AGENT_ANIMATION;
}

@Override
public AgentAnimationPacket clone() {
try {
return (AgentAnimationPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,14 @@ public PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.ANIMATE_ENTITY;
}

@Override
public AnimateEntityPacket clone() {
try {
return (AnimateEntityPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,14 @@ public enum Action {
ROW_RIGHT,
ROW_LEFT,
}

@Override
public AnimatePacket clone() {
try {
return (AnimatePacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ public PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.ANVIL_DAMAGE;
}

@Override
public AnvilDamagePacket clone() {
try {
return (AnvilDamagePacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.AUTOMATION_CLIENT_CONNECT;
}

@Override
public AutomationClientConnectPacket clone() {
try {
return (AutomationClientConnectPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.AVAILABLE_COMMANDS;
}

@Override
public AvailableCommandsPacket clone() {
try {
return (AvailableCommandsPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ public PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.AVAILABLE_ENTITY_IDENTIFIERS;
}

@Override
public AvailableEntityIdentifiersPacket clone() {
try {
return (AvailableEntityIdentifiersPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ public PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.AWARD_ACHIEVEMENT;
}
}

@Override
public AwardAchievementPacket clone() {
try {
return (AwardAchievementPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
import org.cloudburstmc.protocol.common.MinecraftPacket;
import org.cloudburstmc.protocol.common.PacketSignal;

public interface BedrockPacket extends MinecraftPacket {
public interface BedrockPacket extends MinecraftPacket, Cloneable {

PacketSignal handle(BedrockPacketHandler handler);

BedrockPacketType getPacketType();

/**
* Creates a new instance of this packet using Object.clone()
* Will throw a {@link UnsupportedOperationException} if the packet implements {@link io.netty.util.ReferenceCounted}
* @return a new instance of this packet
*/
BedrockPacket clone();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ public PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.BIOME_DEFINITIONS_LIST;
}

@Override
public BiomeDefinitionListPacket clone() {
try {
return (BiomeDefinitionListPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.BLOCK_ENTITY_DATA;
}

@Override
public BlockEntityDataPacket clone() {
try {
return (BlockEntityDataPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.BLOCK_EVENT;
}

@Override
public BlockEventPacket clone() {
try {
return (BlockEventPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.BLOCK_PICK_REQUEST;
}

@Override
public BlockPickRequestPacket clone() {
try {
return (BlockPickRequestPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ public enum Action {
SWAP_PAGES,
SIGN_BOOK
}

@Override
public BookEditPacket clone() {
try {
return (BookEditPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,14 @@ public enum Action {
UPDATE_STYLE,
QUERY
}

@Override
public BossEventPacket clone() {
try {
return (BossEventPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,14 @@ public void setClear(boolean value) {
public void setClear(OptionalBoolean clear) {
this.clear = clear;
}

@Override
public CameraInstructionPacket clone() {
try {
return (CameraInstructionPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ public final PacketSignal handle(BedrockPacketHandler handler) {
public BedrockPacketType getPacketType() {
return BedrockPacketType.CAMERA;
}

@Override
public CameraPacket clone() {
try {
return (CameraPacket) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

Loading

0 comments on commit e0a9b18

Please sign in to comment.