mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-29 23:48:00 +01:00
Accidentally made this public, but let's make intentional because why not?
This commit is contained in:
parent
60c81cc095
commit
39b491b5ed
2 changed files with 18 additions and 3 deletions
|
@ -7,6 +7,7 @@ import com.google.gson.JsonParseException;
|
||||||
import com.minelittlepony.pony.data.IPony;
|
import com.minelittlepony.pony.data.IPony;
|
||||||
import com.minelittlepony.pony.data.Pony;
|
import com.minelittlepony.pony.data.Pony;
|
||||||
import com.minelittlepony.pony.data.PonyLevel;
|
import com.minelittlepony.pony.data.PonyLevel;
|
||||||
|
import com.minelittlepony.util.math.MathUtil;
|
||||||
import com.voxelmodpack.hdskins.ISkinCacheClearListener;
|
import com.voxelmodpack.hdskins.ISkinCacheClearListener;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
|
@ -121,13 +122,19 @@ public class PonyManager implements IResourceManagerReloadListener, ISkinCacheCl
|
||||||
return getBackgroundPony(uuid);
|
return getBackgroundPony(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPony getBackgroundPony(UUID uuid) {
|
/**
|
||||||
|
* Gets a random background pony determined by the given uuid.
|
||||||
|
*
|
||||||
|
* Useful for mods that offer customisation, especially ones that have a whole lot of NPCs.
|
||||||
|
*
|
||||||
|
* @param uuid A UUID. Either a user or an entity.
|
||||||
|
*/
|
||||||
|
public IPony getBackgroundPony(UUID uuid) {
|
||||||
if (getNumberOfPonies() == 0 || isUser(uuid)) {
|
if (getNumberOfPonies() == 0 || isUser(uuid)) {
|
||||||
return getPony(getDefaultSkin(uuid));
|
return getPony(getDefaultSkin(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
int bgi = uuid.hashCode() % getNumberOfPonies();
|
int bgi = MathUtil.mod(uuid.hashCode(), getNumberOfPonies());
|
||||||
while (bgi < 0) bgi += getNumberOfPonies();
|
|
||||||
|
|
||||||
return getPony(backgroundPonyList.get(bgi));
|
return getPony(backgroundPonyList.get(bgi));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,14 @@ public class MathUtil {
|
||||||
return MathHelper.clamp(num, -limit, limit);
|
return MathHelper.clamp(num, -limit, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int mod(int value, int mod) {
|
||||||
|
value %= mod;
|
||||||
|
|
||||||
|
while (value < 0) value += mod;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public static float sensibleAngle(float angle) {
|
public static float sensibleAngle(float angle) {
|
||||||
angle %= 360;
|
angle %= 360;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue