forked from End-Tech/syncmatica
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make SyncmaticaPayload.java be an inner Class of the SyncmaticaPacket
- Loading branch information
1 parent
c73e81e
commit 0d40f40
Showing
13 changed files
with
107 additions
and
112 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
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
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
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
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
45 changes: 0 additions & 45 deletions
45
src/main/java/ch/endte/syncmatica/network/payload/SyncData.java
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
src/main/java/ch/endte/syncmatica/network/payload/SyncmaticaPacket.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,70 @@ | ||
package ch.endte.syncmatica.network.payload; | ||
|
||
import javax.annotation.Nonnull; | ||
import ch.endte.syncmatica.Syncmatica; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.network.codec.PacketCodec; | ||
import net.minecraft.network.packet.CustomPayload; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class SyncmaticaPacket | ||
{ | ||
private final PacketByteBuf packet; | ||
private final PacketType type; | ||
private final Identifier channel; | ||
|
||
public SyncmaticaPacket(@Nonnull Identifier channel, @Nonnull PacketByteBuf packet) | ||
{ | ||
this.channel = channel; | ||
this.packet = packet; | ||
this.type = PacketType.getType(channel); | ||
} | ||
|
||
public PacketType getType() | ||
{ | ||
return this.type; | ||
} | ||
|
||
public Identifier getChannel() | ||
{ | ||
return this.channel; | ||
} | ||
|
||
public PacketByteBuf getPacket() | ||
{ | ||
return new PacketByteBuf(this.packet); | ||
} | ||
|
||
protected static SyncmaticaPacket fromPacket(PacketByteBuf input) | ||
{ | ||
return new SyncmaticaPacket(input.readIdentifier(), new PacketByteBuf(input.readBytes(input.readableBytes()))); | ||
} | ||
|
||
protected void toPacket(PacketByteBuf output) | ||
{ | ||
output.writeIdentifier(this.channel); | ||
output.writeBytes(this.packet.readBytes(this.packet.readableBytes())); | ||
} | ||
|
||
public record Payload(SyncmaticaPacket data) implements CustomPayload | ||
{ | ||
public static final Id<Payload> ID = new Id<>(Syncmatica.NETWORK_ID); | ||
public static final PacketCodec<PacketByteBuf, Payload> CODEC = CustomPayload.codecOf(Payload::write, Payload::new); | ||
|
||
public Payload(PacketByteBuf input) | ||
{ | ||
this(SyncmaticaPacket.fromPacket(input)); | ||
} | ||
|
||
private void write(PacketByteBuf output) | ||
{ | ||
data.toPacket(output); | ||
} | ||
|
||
@Override | ||
public Id<Payload> getId() | ||
{ | ||
return ID; | ||
} | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
src/main/java/ch/endte/syncmatica/network/payload/SyncmaticaPayload.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.