Skip to content

Commit

Permalink
Changes for version 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorLinfoot committed May 15, 2024
1 parent deff5bc commit a6e03ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.15.10

# Mod Properties
mod_version = 0.3.3
mod_version = 0.4.0
maven_group = net.hypixel
archives_base_name = HypixelModAPI
mod_api_version = 0.3.3
mod_api_version = 0.4.0

# Dependencies
# check this on https://modmuss50.me/fabric.html
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/hypixel/modapi/fabric/FabricModAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.hypixel.modapi.fabric.event.HypixelModAPICallback;
import net.hypixel.modapi.fabric.payload.ClientboundHypixelPayload;
import net.hypixel.modapi.fabric.payload.ServerboundHypixelPayload;
import net.minecraft.client.MinecraftClient;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.packet.CustomPayload;
Expand All @@ -31,6 +32,7 @@ public static void reloadRegistrations() {
for (String identifier : HypixelModAPI.getInstance().getRegistry().getClientboundIdentifiers()) {
try {
registerClientbound(identifier);
LOGGER.info("Registered clientbound packet with identifier '{}'", identifier);
} catch (Exception e) {
LOGGER.error("Failed to register clientbound packet with identifier '{}'", identifier, e);
}
Expand All @@ -39,6 +41,7 @@ public static void reloadRegistrations() {
for (String identifier : HypixelModAPI.getInstance().getRegistry().getServerboundIdentifiers()) {
try {
registerServerbound(identifier);
LOGGER.info("Registered serverbound packet with identifier '{}'", identifier);
} catch (Exception e) {
LOGGER.error("Failed to register serverbound packet with identifier '{}'", identifier, e);
}
Expand All @@ -47,8 +50,14 @@ public static void reloadRegistrations() {

private static void registerPacketSender() {
HypixelModAPI.getInstance().setPacketSender((packet) -> {
if (MinecraftClient.getInstance().getNetworkHandler() == null) {
// The client is not connected to a server, so we can't send the packet
return false;
}

ServerboundHypixelPayload payload = new ServerboundHypixelPayload(packet);
ClientPlayNetworking.send(payload);
return true;
});
}

Expand Down

0 comments on commit a6e03ca

Please sign in to comment.