Skip to content

Commit

Permalink
Version bump to 0.9.3 - fix server crash
Browse files Browse the repository at this point in the history
  • Loading branch information
3TUSK committed Aug 28, 2024
1 parent ee94da9 commit bb7d5de
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod_name=VoteMe
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=BSD-3-Clause
# The mod version. See https://semver.org/
mod_version=0.9.2
mod_version=0.9.3
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
24 changes: 15 additions & 9 deletions src/main/java/org/teacon/voteme/network/ShowCounterPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,7 @@ public Type<ShowCounterPacket> type() {
}

public void handle(IPayloadContext context) {
if (!this.infos.isEmpty()) {
// neoforge claims this is sufficient
if (FMLEnvironment.dist == Dist.CLIENT) {
ShowCounterPacket p = ShowCounterPacket.this;
String artifactName = VoteArtifactNames.client().getName(p.artifactUUID);
CounterScreen gui = new CounterScreen(p.artifactUUID, artifactName, p.invIndex, p.category, p.infos);
context.enqueueWork(() -> Minecraft.getInstance().setScreen(gui));
}
}
Handler.handle(this, context);
}

public static Optional<ShowCounterPacket> create(int inventoryId, UUID artifactID, ResourceLocation categoryID, MinecraftServer server) {
Expand Down Expand Up @@ -121,6 +113,20 @@ public static Optional<ShowCounterPacket> create(int inventoryId, Consumer<UUID>
return Optional.empty();
}

static final class Handler {
public static void handle(ShowCounterPacket packet, IPayloadContext context) {
if (!packet.infos.isEmpty()) {
// neoforge claims this is sufficient
if (FMLEnvironment.dist == Dist.CLIENT) {
ShowCounterPacket p = packet;
String artifactName = VoteArtifactNames.client().getName(p.artifactUUID);
CounterScreen gui = new CounterScreen(p.artifactUUID, artifactName, p.invIndex, p.category, p.infos);
context.enqueueWork(() -> Minecraft.getInstance().setScreen(gui));
}
}
}
}

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public static final class Info {
Expand Down
23 changes: 14 additions & 9 deletions src/main/java/org/teacon/voteme/network/ShowVoterPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,7 @@ public Type<ShowVoterPacket> type() {
}

public void handle(IPayloadContext context) {
// forge needs a separate class
if (FMLEnvironment.dist == Dist.CLIENT) {
ShowVoterPacket p = ShowVoterPacket.this;
String artifactName = VoteArtifactNames.client().getName(p.artifactID);
if (!artifactName.isEmpty()) {
VoterScreen gui = new VoterScreen(p.artifactID, artifactName, p.infos, p.comments);
context.enqueueWork(() -> Minecraft.getInstance().setScreen(gui));
}
};
Handler.handle(this, context);
}

public static Optional<ShowVoterPacket> create(UUID artifactID, ServerPlayer player) {
Expand All @@ -101,6 +93,19 @@ public static Optional<ShowVoterPacket> create(UUID artifactID, ServerPlayer pla
return Optional.empty();
}

static final class Handler {
static void handle(ShowVoterPacket packet, IPayloadContext context) {
// forge needs a separate class
if (FMLEnvironment.dist == Dist.CLIENT) {
String artifactName = VoteArtifactNames.client().getName(packet.artifactID);
if (!artifactName.isEmpty()) {
VoterScreen gui = new VoterScreen(packet.artifactID, artifactName, packet.infos, packet.comments);
context.enqueueWork(() -> Minecraft.getInstance().setScreen(gui));
}
};
}
}

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public static final class Info {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.teacon.voteme.network;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.UUIDUtil;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.teacon.voteme.network;

import com.google.common.primitives.ImmutableIntArray;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import org.apache.commons.lang3.tuple.Pair;
Expand Down

0 comments on commit bb7d5de

Please sign in to comment.