Skip to content

Commit

Permalink
Revert fillycam to what it was before when turning off the syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Jul 23, 2024
1 parent fb6c1f6 commit bb35cdf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ private void rebuildContent() {
visual.setEnabled(true);
});
} else {
PresetDetector.getInstance().revertFillyCam();
dimensions = new EntityScale(dimensions.body(), dimensions.camera(), true);
updateDimensions();
}
Expand Down
38 changes: 34 additions & 4 deletions src/main/java/com/minelittlepony/bigpony/minelittlepony/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

public class Main extends PresetDetector implements ClientModInitializer {

private boolean oldFillyCam;
private boolean writing;

@Override
public void onInitializeClient() {
INSTANCE = this;
Expand All @@ -31,7 +34,7 @@ public void onInitializeClient() {
&& entity instanceof PlayerEntity player
&& BigPonyClient.isClientPlayer(player)
&& isPony(player)) {
model.getAttributes().visualHeight = entity.getHeight() / model.getSize().scaleFactor();
model.getAttributes().visualHeight = entity.getHeight();
}
});
PonyDataCallback.EVENT.register((sender, data, env) -> {
Expand All @@ -41,6 +44,30 @@ && isPony(player)) {
detectPreset(sender.getGameProfile()).thenAccept(holder.getScaling()::setDimensions);
}
});

PonyConfig.getInstance().onChangedExternally(config -> {
if (!writing) {
oldFillyCam = isFillyCam();
}
});
PonyConfig.getInstance().fillycam.onChanged(fillyCam -> {
if (!writing) {
oldFillyCam = isFillyCam();
}
});
oldFillyCam = isFillyCam();
}

public void setFillyCam(boolean enable) {
oldFillyCam = isFillyCam();
writing = true;
PonyConfig.getInstance().fillycam.set(enable);
writing = false;
}

@Override
public void revertFillyCam() {
PonyConfig.getInstance().fillycam.set(oldFillyCam);
}

@Override
Expand All @@ -57,7 +84,8 @@ public boolean isPony(PlayerEntity player) {
public CompletableFuture<EntityScale> detectPreset(GameProfile profile) {
return SkinDetecter.getInstance().loadSkin(profile).thenApplyAsync(skin -> {
// Turn on filly cam so we can get the camera parameters
PonyConfig.getInstance().fillycam.set(true);
boolean fillyCam = isFillyCam();
setFillyCam(true);

Pony pony = Pony.getManager().getPony(skin);
Size size = pony.metadata().size();
Expand All @@ -69,8 +97,10 @@ public CompletableFuture<EntityScale> detectPreset(GameProfile profile) {
);

// We turn off filly cam because it's not needed and might cause issues with buckets if left enabled
PonyConfig.getInstance().fillycam.set(false);
PonyConfig.getInstance().save();
setFillyCam(false);
if (!fillyCam) {
PonyConfig.getInstance().save();
}
return scale;
}, MinecraftClient.getInstance());
}
Expand Down

0 comments on commit bb35cdf

Please sign in to comment.