Skip to content

Commit

Permalink
[fix] server-side not detecting incompatible clients post-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
JackFred2 committed Aug 20, 2023
1 parent 48bd675 commit c1c627d
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# WhereIsIt
# Where Is It

Minecraft mod to locate items in nearby inventories. Press Y over an item to search.

![An example image of the mod showing 4 results](https://i.imgur.com/lvebo0v.png)

## Requirements

- [Fabric API](https://modrinth.com/mod/fabric-api)
Expand Down
Binary file added images/config.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/enchantment filtering.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nested searching.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/server side.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/standard.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* <li>numberOfOtherPositions: Collection&lt;BlockPos&gt;</li>
*/
public record ClientboundResultsPacket(long id, Collection<SearchResult> results) implements FabricPacket {
public static final PacketType<ClientboundResultsPacket> TYPE = PacketType.create(WhereIsIt.id("c2s_searchforitem"), ClientboundResultsPacket::new);
public static final PacketType<ClientboundResultsPacket> TYPE = PacketType.create(WhereIsIt.id("s2c_founditem"), ClientboundResultsPacket::new);
public static final long WHEREIS_COMMAND_ID = -1L;

public ClientboundResultsPacket(FriendlyByteBuf buf) {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/red/jackf/whereisit/search/SearchHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static void handleFromPacket(ServerboundSearchForItemPacket packet, Serve
}

public static void handle(SearchRequest request, ServerPlayer player) {
// clear last server side results
ServerSideRenderer.fadeServerSide(player);

// check rate limit for players
Expand All @@ -44,8 +45,6 @@ public static void handle(SearchRequest request, ServerPlayer player) {
RateLimiter.add(player, time);
}

// clear last server side results

// empty requests
if (!request.hasCriteria()) {
WhereIsIt.LOGGER.warn("Empty request from {}", player.getGameProfile().getName());
Expand Down Expand Up @@ -96,7 +95,7 @@ public static void handle(SearchRequest request, ServerPlayer player) {

// send to player
if (!results.isEmpty()) {
if (WhereIsItConfig.INSTANCE.getConfig().getCommon().forceServerSideHighlightsOnly) {
if (WhereIsItConfig.INSTANCE.getConfig().getCommon().forceServerSideHighlightsOnly || !ServerPlayNetworking.canSend(player, ClientboundResultsPacket.TYPE)) {
ServerSideRenderer.doServersideRendering(player, results.values());
} else {
// send packet
Expand Down

0 comments on commit c1c627d

Please sign in to comment.