-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added connect four * whoopsie fixes * changed tie to 3 * changed to four in a row due to copyright purposes * fine then intellij * Minor style changes * Update en_us.json Co-authored-by: Frederik van der Els <[email protected]> * Update TwoPlayerGameType.java * changed code in response to review * changed translates to `connectFour` and renamed `TwoPlayerGameType` to `TwoPlayerGame` * changed field to not create new object every time * updated to 1.21.3 * fixed issue with color not rendering * updated to new c2c system * Update ConnectFourCommand.java Co-authored-by: Joseph Burton <[email protected]> * Update ConnectFourCommand.java Co-authored-by: Joseph Burton <[email protected]> * made changes, added UUID to C2CFriendlyByteBuf * fix wildcard imports * fixed failure of tests * updated translates * i blame the fact that intellij kept crashing * push * push * push * push * push * push * push * Fix disconnect event * push * push --------- Co-authored-by: Frederik van der Els <[email protected]> Co-authored-by: Frederik van der Els <[email protected]> Co-authored-by: Joseph Burton <[email protected]>
- Loading branch information
1 parent
549d41d
commit 64b6948
Showing
21 changed files
with
850 additions
and
203 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
7 changes: 5 additions & 2 deletions
7
src/main/java/net/earthcomputer/clientcommands/c2c/C2CPacketListener.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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
package net.earthcomputer.clientcommands.c2c; | ||
|
||
import net.earthcomputer.clientcommands.c2c.packets.MessageC2CPacket; | ||
import net.earthcomputer.clientcommands.c2c.packets.PutConnectFourPieceC2CPacket; | ||
import net.earthcomputer.clientcommands.c2c.packets.PutTicTacToeMarkC2CPacket; | ||
import net.earthcomputer.clientcommands.c2c.packets.StartTicTacToeGameC2CPacket; | ||
import net.earthcomputer.clientcommands.c2c.packets.StartTwoPlayerGameC2CPacket; | ||
import net.minecraft.network.ClientboundPacketListener; | ||
|
||
public interface C2CPacketListener extends ClientboundPacketListener { | ||
void onMessageC2CPacket(MessageC2CPacket packet); | ||
|
||
void onStartTicTacToeGameC2CPacket(StartTicTacToeGameC2CPacket packet); | ||
void onStartTwoPlayerGameC2CPacket(StartTwoPlayerGameC2CPacket packet); | ||
|
||
void onPutTicTacToeMarkC2CPacket(PutTicTacToeMarkC2CPacket packet); | ||
|
||
void onPutConnectFourPieceC2CPacket(PutConnectFourPieceC2CPacket packet); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/net/earthcomputer/clientcommands/c2c/packets/PutConnectFourPieceC2CPacket.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,37 @@ | ||
package net.earthcomputer.clientcommands.c2c.packets; | ||
|
||
import net.earthcomputer.clientcommands.c2c.C2CFriendlyByteBuf; | ||
import net.earthcomputer.clientcommands.c2c.C2CPacket; | ||
import net.earthcomputer.clientcommands.c2c.C2CPacketListener; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.Packet; | ||
import net.minecraft.network.protocol.PacketFlow; | ||
import net.minecraft.network.protocol.PacketType; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.UUID; | ||
|
||
public record PutConnectFourPieceC2CPacket(String sender, UUID senderUUID, int x) implements C2CPacket { | ||
public static final StreamCodec<C2CFriendlyByteBuf, PutConnectFourPieceC2CPacket> CODEC = Packet.codec(PutConnectFourPieceC2CPacket::write, PutConnectFourPieceC2CPacket::new); | ||
public static final PacketType<PutConnectFourPieceC2CPacket> ID = new PacketType<>(PacketFlow.CLIENTBOUND, ResourceLocation.fromNamespaceAndPath("clientcommands", "put_connect_four_piece")); | ||
|
||
public PutConnectFourPieceC2CPacket(C2CFriendlyByteBuf buf) { | ||
this(buf.getSender(), buf.getSenderUUID(), buf.readVarInt()); | ||
} | ||
|
||
public void write(C2CFriendlyByteBuf buf) { | ||
buf.writeVarInt(this.x); | ||
} | ||
|
||
@Override | ||
public PacketType<? extends Packet<C2CPacketListener>> type() { | ||
return ID; | ||
} | ||
|
||
@Override | ||
public void handle(C2CPacketListener handler) { | ||
handler.onPutConnectFourPieceC2CPacket(this); | ||
} | ||
} |
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
33 changes: 0 additions & 33 deletions
33
src/main/java/net/earthcomputer/clientcommands/c2c/packets/StartTicTacToeGameC2CPacket.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
src/main/java/net/earthcomputer/clientcommands/c2c/packets/StartTwoPlayerGameC2CPacket.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,39 @@ | ||
package net.earthcomputer.clientcommands.c2c.packets; | ||
|
||
import net.earthcomputer.clientcommands.c2c.C2CFriendlyByteBuf; | ||
import net.earthcomputer.clientcommands.c2c.C2CPacket; | ||
import net.earthcomputer.clientcommands.c2c.C2CPacketListener; | ||
import net.earthcomputer.clientcommands.features.TwoPlayerGame; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.Packet; | ||
import net.minecraft.network.protocol.PacketFlow; | ||
import net.minecraft.network.protocol.PacketType; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.UUID; | ||
|
||
public record StartTwoPlayerGameC2CPacket(String sender, UUID senderUUID, boolean accept, TwoPlayerGame<?, ?> game) implements C2CPacket { | ||
public static final StreamCodec<C2CFriendlyByteBuf, StartTwoPlayerGameC2CPacket> CODEC = Packet.codec(StartTwoPlayerGameC2CPacket::write, StartTwoPlayerGameC2CPacket::new); | ||
public static final PacketType<StartTwoPlayerGameC2CPacket> ID = new PacketType<>(PacketFlow.CLIENTBOUND, ResourceLocation.fromNamespaceAndPath("clientcommands", "start_two_player_game")); | ||
|
||
public StartTwoPlayerGameC2CPacket(C2CFriendlyByteBuf buf) { | ||
this(buf.getSender(), buf.getSenderUUID(), buf.readBoolean(), TwoPlayerGame.getById(buf.readResourceLocation())); | ||
} | ||
|
||
public void write(C2CFriendlyByteBuf buf) { | ||
buf.writeBoolean(this.accept); | ||
buf.writeResourceLocation(this.game.getId()); | ||
} | ||
|
||
@Override | ||
public void handle(C2CPacketListener handler) { | ||
handler.onStartTwoPlayerGameC2CPacket(this); | ||
} | ||
|
||
@Override | ||
public PacketType<? extends Packet<C2CPacketListener>> type() { | ||
return ID; | ||
} | ||
} |
Oops, something went wrong.