-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Fabric 1.20.5, drop support for all prior versions
- Loading branch information
Showing
10 changed files
with
145 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
minecraft_version=1.18 | ||
fabric_version=0.46.6+1.18 | ||
loader_version=0.15.6 | ||
minecraft_version=1.20.5 | ||
fabric_version=0.97.8+1.20.5 | ||
loader_version=0.15.11 |
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
29 changes: 29 additions & 0 deletions
29
networking-fabric/src/main/java/wtf/choco/network/fabric/FabricMessageReceiver.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,29 @@ | ||
package wtf.choco.network.fabric; | ||
|
||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import wtf.choco.network.data.NamespacedKey; | ||
import wtf.choco.network.receiver.MessageReceiver; | ||
|
||
public interface FabricMessageReceiver extends MessageReceiver { | ||
|
||
public void sendMessage(@NotNull RawDataPayload payload); | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @deprecated you don't need to implement this for Fabric types. Implement | ||
* {@link #sendMessage(RawDataPayload)} instead | ||
*/ | ||
@Deprecated | ||
@Override | ||
default void sendMessage(@NotNull NamespacedKey channel, byte @NotNull [] message) { | ||
FriendlyByteBuf byteBuf = PacketByteBufs.create(); | ||
byteBuf.writeBytes(message); | ||
this.sendMessage(new RawDataPayload(byteBuf.array())); | ||
} | ||
|
||
} |
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
48 changes: 48 additions & 0 deletions
48
networking-fabric/src/main/java/wtf/choco/network/fabric/RawDataPayload.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,48 @@ | ||
package wtf.choco.network.fabric; | ||
|
||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public final class RawDataPayload implements CustomPacketPayload { | ||
|
||
public static final StreamCodec<FriendlyByteBuf, RawDataPayload> CODEC = StreamCodec.ofMember( | ||
(payload, buffer) -> buffer.writeBytes(payload.data()), | ||
buffer -> { | ||
byte[] bytes = new byte[buffer.readableBytes()]; | ||
buffer.readBytes(bytes); | ||
return new RawDataPayload(bytes); | ||
} | ||
); | ||
|
||
private static CustomPacketPayload.Type<RawDataPayload> type; | ||
|
||
@ApiStatus.Internal | ||
static void setType(@NotNull CustomPacketPayload.Type<RawDataPayload> type) { | ||
RawDataPayload.type = type; | ||
} | ||
|
||
@ApiStatus.Internal | ||
static CustomPacketPayload.Type<RawDataPayload> getType() { | ||
return type; | ||
} | ||
|
||
private final byte[] data; | ||
|
||
public RawDataPayload(byte[] data) { | ||
this.data = data; | ||
} | ||
|
||
public byte[] data() { | ||
return data; | ||
} | ||
|
||
@Override | ||
public Type<? extends CustomPacketPayload> type() { | ||
return type; | ||
} | ||
|
||
} |
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