-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update to Java 21 & Minecraft 1.20.6 * Small code refactor --------- Co-authored-by: shurik204 <iwmdiif@gmail.com>
- Loading branch information
Showing
30 changed files
with
257 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
14 changes: 13 additions & 1 deletion
14
src/main/java/me/shurik/bettersuggestions/client/data/ClientScoreboardValue.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,4 +1,16 @@ | ||
package me.shurik.bettersuggestions.client.data; | ||
|
||
import me.shurik.bettersuggestions.utils.Scoreboards; | ||
|
||
// Client doesn't have access to `ScoreboardObjective`s so we store the name instead | ||
public record ClientScoreboardValue(String objective, int score) {} | ||
public record ClientScoreboardValue(String objective, int score) implements Scoreboards.ScoreboardValue { | ||
@Override | ||
public String getObjective() { | ||
return objective; | ||
} | ||
|
||
@Override | ||
public int getScore() { | ||
return score; | ||
} | ||
} |
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
8 changes: 4 additions & 4 deletions
8
src/main/java/me/shurik/bettersuggestions/client/network/ClientPacketSender.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,12 +1,12 @@ | ||
package me.shurik.bettersuggestions.client.network; | ||
|
||
import me.shurik.bettersuggestions.network.ModPackets; | ||
import me.shurik.bettersuggestions.utils.ByteBufUtils; | ||
import me.shurik.bettersuggestions.network.packet.EntityCommandTagsRequestC2SPacket; | ||
import me.shurik.bettersuggestions.network.packet.EntityScoresRequestC2SPacket; | ||
import net.minecraft.entity.Entity; | ||
|
||
public class ClientPacketSender { | ||
public static void sendEntityCommandTagsRequest(Entity entity) { sendEntityCommandTagsRequest(entity.getId()); } | ||
public static void sendEntityCommandTagsRequest(int entityId) { ClientNetworking.send(ModPackets.EntityCommandTagsRequestC2SPacketID, ByteBufUtils.withInt(entityId)); } | ||
public static void sendEntityCommandTagsRequest(int entityId) { ClientNetworking.send(new EntityCommandTagsRequestC2SPacket(entityId)); } | ||
public static void sendEntityScoresRequest(Entity entity) { sendEntityScoresRequest(entity.getId()); } | ||
public static void sendEntityScoresRequest(int entityId) { ClientNetworking.send(ModPackets.EntityScoresRequestC2SPacketID, ByteBufUtils.withInt(entityId)); } | ||
public static void sendEntityScoresRequest(int entityId) { ClientNetworking.send(new EntityScoresRequestC2SPacket(entityId)); } | ||
} |
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
13 changes: 0 additions & 13 deletions
13
src/main/java/me/shurik/bettersuggestions/network/ModPackets.java
This file was deleted.
Oops, something went wrong.
22 changes: 5 additions & 17 deletions
22
src/main/java/me/shurik/bettersuggestions/network/ServerNetworking.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,38 +1,26 @@ | ||
package me.shurik.bettersuggestions.network; | ||
|
||
import me.shurik.bettersuggestions.utils.ByteBufUtils; | ||
import me.shurik.bettersuggestions.utils.Scoreboards.ScoreboardScoreContainer; | ||
import net.fabricmc.fabric.api.networking.v1.PlayerLookup; | ||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.network.packet.CustomPayload; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.Identifier; | ||
|
||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
public class ServerNetworking { | ||
public static PacketByteBuf createEntityCommandTagsBuffer(int entityId, Set<String> commandTags) { | ||
return ByteBufUtils.writeCollection(ByteBufUtils.withInt(entityId), commandTags, PacketByteBuf::writeString); | ||
} | ||
|
||
public static PacketByteBuf createEntityScoresBuffer(int entityId, Collection<ScoreboardScoreContainer> scores) { | ||
return ByteBufUtils.writeCollection(ByteBufUtils.withInt(entityId), scores, ByteBufUtils::writeScoreboardValue); | ||
} | ||
|
||
// Copy of Fabric PlayerLookup.tracking | ||
public static Collection<ServerPlayerEntity> tracking(Entity entity) { | ||
return PlayerLookup.tracking(entity); | ||
} | ||
|
||
public static void broadcastFromEntity(Entity entity, Identifier packetId, PacketByteBuf buf) { | ||
public static void broadcastFromEntity(Entity entity, CustomPayload packet) { | ||
for (ServerPlayerEntity player : tracking(entity)) { | ||
send(player, packetId, buf); | ||
send(player, packet); | ||
} | ||
} | ||
|
||
public static void send(ServerPlayerEntity player, Identifier packetId, PacketByteBuf buf) { | ||
ServerPlayNetworking.send(player, packetId, buf); | ||
public static void send(ServerPlayerEntity player, CustomPayload packet) { | ||
ServerPlayNetworking.send(player, packet); | ||
} | ||
} |
Oops, something went wrong.