-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
categorize helper methods to `util` package
- Loading branch information
Showing
23 changed files
with
285 additions
and
184 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
3 changes: 3 additions & 0 deletions
3
src/api/java/mcp/mobius/waila/api/__internal__/package-info.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,7 @@ | ||
/** | ||
* Internal package, do not touch. | ||
*/ | ||
@ApiStatus.Internal | ||
package mcp.mobius.waila.api.__internal__; | ||
|
||
import org.jetbrains.annotations.ApiStatus; |
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
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 mcp.mobius.waila.api.util; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public final class WCodecs { | ||
|
||
public static <B extends ByteBuf, V> @NotNull StreamCodec<B, @Nullable V> nullable(StreamCodec<B, V> codec) { | ||
return new StreamCodec<>() { | ||
@Override | ||
@SuppressWarnings("NullableProblems") | ||
public @Nullable V decode(B b) { | ||
return FriendlyByteBuf.readNullable(b, codec); | ||
} | ||
|
||
@Override | ||
public void encode(B o, V v) { | ||
FriendlyByteBuf.writeNullable(o, v, codec); | ||
} | ||
}; | ||
} | ||
|
||
private WCodecs() { | ||
} | ||
|
||
} |
Oops, something went wrong.