Utils
Bento Util has a Utils class that currently only contains tryParse and stringify methods I frequently use in other Bento modules. Maybe this can be useful to you too!
tryParse methods
Section titled “tryParse methods”If you need tryParse methods for ints, longs, floats, or doubles, you can use the com.google.common.primitives package.
Examples:
// NumbersByte byteVal = Utils.tryParseByte("127");Short shortVal = Utils.tryParseShort("32767");
BigInteger bigInteger = Utils.tryParseBigInteger("340282366920938463463374607431768211455");BigDecimal bigDecimal = Utils.tryParseBigDecimal("3.14159265358979323846264338327950288419716939937510");
// VectorsVec2f vec2f = Utils.tryParseVec2f("0.5, -1.5");Vec3i vec3i = Utils.tryParseVec3i("-5, 0, 5");Vec3d vec3d = Utils.tryParseVec3d("-0.003, 54.4, 30");
BlockPos blockPos = Utils.tryParseBlockPos("-10, 0, 10");ChunkPos chunkPos = Utils.tryParseChunkPos("42, 0");stringify methods
Section titled “stringify methods”There is a collection of stringify methods that work on the following types:
ItemBlockEntityTypeVec2fVec3iVec3dBlockPosChunkPos
Items, blocks, and entities are formatted as identifier strings, and if the namespace is minecraft it is excluded. All vectors are formatted as either x, y, z or x, y.
Example:
Utils.stringify(Items.DIAMOND); // "diamond"