Replace truncating the hashed seed with encoding it into base32
This commit is contained in:
+14
-2
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.wrapperInterfaces.world;
|
||||
|
||||
import com.google.common.primitives.Longs;
|
||||
import com.seibel.distanthorizons.api.interfaces.world.IDhApiLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
||||
@@ -26,10 +27,12 @@ import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
|
||||
import org.apache.commons.codec.binary.Base32;
|
||||
|
||||
/** Can be either a Server world or a Client world. */
|
||||
public interface ILevelWrapper extends IDhApiLevelWrapper, IBindable
|
||||
{
|
||||
Base32 base32 = new Base32(true);
|
||||
|
||||
@Override
|
||||
IDimensionTypeWrapper getDimensionType();
|
||||
@@ -38,12 +41,21 @@ public interface ILevelWrapper extends IDhApiLevelWrapper, IBindable
|
||||
String getDimensionName();
|
||||
|
||||
long getHashedSeed();
|
||||
/**
|
||||
* Returns the result of {@link #getHashedSeed()}, encoded into a short string. <br>
|
||||
* Prefer using this method over stringifying the number directly.
|
||||
*/
|
||||
default String getHashedSeedEncoded()
|
||||
{
|
||||
String encoded = base32.encodeAsString(Longs.toByteArray(this.getHashedSeed()));
|
||||
return encoded.substring(0, 13).toLowerCase(); // Remaining 3 chars are padding
|
||||
}
|
||||
|
||||
/**
|
||||
* A string intended to uniquely identify this level.
|
||||
*/
|
||||
@Override
|
||||
default String getDhIdentifier() { return this.getDimensionName() + "_" + this.getHashedSeed(); }
|
||||
@Override
|
||||
String getDhIdentifier();
|
||||
|
||||
@Override
|
||||
boolean hasCeiling();
|
||||
|
||||
+2
-2
@@ -45,12 +45,12 @@ public interface IServerLevelWrapper extends ILevelWrapper
|
||||
.replaceAll(" ", "_");
|
||||
|
||||
levelKeyPrefix += (!levelKeyPrefix.isEmpty() ? "_" : "") + cleanWorldFolderName
|
||||
+ "_" + this.getHashedSeed();
|
||||
+ "_" + this.getHashedSeedEncoded();
|
||||
}
|
||||
|
||||
if (levelKeyPrefix.isEmpty())
|
||||
{
|
||||
levelKeyPrefix = String.valueOf(this.getHashedSeed());
|
||||
levelKeyPrefix = this.getHashedSeedEncoded();
|
||||
}
|
||||
|
||||
String mainPart = "@" + dimensionName;
|
||||
|
||||
Reference in New Issue
Block a user