Skip to content

Commit

Permalink
Added #1049 server config for BPI size tolerance.
Browse files Browse the repository at this point in the history
  • Loading branch information
LtxProgrammer committed Sep 29, 2024
1 parent 5a689af commit f7750b0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/main/java/net/ltxprogrammer/changed/ChangedConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public static class Server {
public final ForgeConfigSpec.ConfigValue<List<? extends String>> whitelistCoverBlocks;
public final ForgeConfigSpec.ConfigValue<Boolean> playerControllingAbilities;
public final ForgeConfigSpec.ConfigValue<Boolean> isGrabEnabled;
public final ForgeConfigSpec.ConfigValue<Double> bpiSizeTolerance;

public Server(ForgeConfigSpec.Builder builder) {
builder.comment("Should transfurred players have a nametag");
Expand All @@ -116,6 +117,8 @@ public Server(ForgeConfigSpec.Builder builder) {
playerControllingAbilities = builder.define("playerControllingAbilities", true);
builder.comment("Can latexes use the grab ability on players.");
isGrabEnabled = builder.define("isGrabEnabled", true);
builder.comment("Acceptable model scaling through BPI (Default: +/- 5%)");
bpiSizeTolerance = builder.defineInRange("bpiSizeTolerance", 0.05, 0.01, 0.95);
}

public Stream<RegistryElementPredicate<Block>> getBlacklistedCoverBlocks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected void init() {
}

private double convertToScaledValue() {
return (this.value * BasicPlayerInfo.SIZE_TOLERANCE * 2) - BasicPlayerInfo.SIZE_TOLERANCE + 1.0;
return (this.value * BasicPlayerInfo.getSizeTolerance() * 2) - BasicPlayerInfo.getSizeTolerance() + 1.0;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected boolean isEntityUprightType(@NotNull T entity) {
}

protected void scaleForBPI(BasicPlayerInfo bpi, PoseStack poseStack) {
float forcedLimit = Mth.clamp(bpi.getSize(), 1.0f - BasicPlayerInfo.SIZE_TOLERANCE, 1.05f + BasicPlayerInfo.SIZE_TOLERANCE);
float forcedLimit = Mth.clamp(bpi.getSize(), 1.0f - BasicPlayerInfo.getSizeTolerance(), 1.05f + BasicPlayerInfo.getSizeTolerance());
poseStack.scale(forcedLimit, forcedLimit, forcedLimit);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.ltxprogrammer.changed.entity;

import net.ltxprogrammer.changed.Changed;
import net.ltxprogrammer.changed.util.Color3;
import net.minecraft.Util;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -12,7 +13,9 @@
* This is basic info about the player, that they set.
*/
public class BasicPlayerInfo {
public static final float SIZE_TOLERANCE = 0.05f;
public static float getSizeTolerance() {
return (float) Changed.config.server.bpiSizeTolerance.get().doubleValue();
}

// Default values here are based on Colin's properties
// When the player is TF'd these values will copy over to the latex representative
Expand Down Expand Up @@ -68,7 +71,7 @@ public static BasicPlayerInfo random(Random random) {
info.irisRightColor = random.nextFloat() > 0.05f ? info.irisLeftColor : Util.getRandom(IRIS_COLORS, random); // 5% for dichrome eyes
info.eyeStyle = Util.getRandom(EyeStyle.values(), random);
info.overrideOthersToMatchStyle = false;
info.size = (random.nextFloat() * (random.nextBoolean() ? SIZE_TOLERANCE : -SIZE_TOLERANCE)) + 1.0f;
info.size = (random.nextFloat() * (random.nextBoolean() ? getSizeTolerance() : -getSizeTolerance())) + 1.0f;
return info;
}

Expand Down Expand Up @@ -133,11 +136,11 @@ public EyeStyle getEyeStyle() {
}

public float getSize() {
return Mth.clamp(size, 1.0f - SIZE_TOLERANCE, 1.0f + SIZE_TOLERANCE);
return Mth.clamp(size, 1.0f - getSizeTolerance(), 1.0f + getSizeTolerance());
}

public double getSizeValueForConfiguration() {
return (size - 1.0f + SIZE_TOLERANCE) / (SIZE_TOLERANCE * 2);
return (size - 1.0f + getSizeTolerance()) / (getSizeTolerance() * 2);
}

public void copyFrom(BasicPlayerInfo other) {
Expand Down

0 comments on commit f7750b0

Please sign in to comment.