Skip to content

Commit

Permalink
Fixed random crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
LudoCrypt committed Aug 17, 2021
1 parent 20eb559 commit 9055afe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/main/java/com/terraformersmc/vistas/Vistas.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.apache.logging.log4j.Logger;

import com.terraformersmc.vistas.config.VistasConfig;
import com.terraformersmc.vistas.registry.VistasRegistry;
import com.terraformersmc.vistas.util.PanoramicScreenshots;

import net.fabricmc.api.ClientModInitializer;
Expand All @@ -18,7 +17,6 @@ public class Vistas implements ClientModInitializer {
public void onInitializeClient() {
VistasConfig.init();
PanoramicScreenshots.registerKeyBinding();
VistasRegistry.registerApiPanoramas();
}

public static Identifier id(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class MinecraftClientMixin implements MinecraftClientAccess {

@Inject(method = "tick", at = @At("HEAD"))
private void vistas$tick(CallbackInfo ci) {
if (VistasRegistry.PANORAMA_REGISTRY.isEmpty()) {
VistasRegistry.registerApiPanoramas();
}
if (this.getCurrentPanorama() == null) {
this.setCurrentPanorama(VistasRegistry.getChosenPanorama());
VistasConfig.getInstance().panorama = VistasRegistry.PANORAMA_REGISTRY.getId(this.getCurrentPanorama()).toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ protected TitleScreenMixin(Text title) {

if (this.isVistasReadyToChange == true) {
this.isVistasReadyToChange = false;
this.isVistas = VistasRegistry.PANORAMA_REGISTRY.getId(panorama).equals(Vistas.id("default")) && new Random().nextDouble() < 1.0E-4D;
if (VistasRegistry.PANORAMA_REGISTRY.getId(panorama) != null) {
this.isVistas = VistasRegistry.PANORAMA_REGISTRY.getId(panorama).equals(Vistas.id("default")) && new Random().nextDouble() < 1.0E-4D;
} else {
this.isVistas = false;
}
}
}
backgroundRenderers.forEach((rcmr) -> rcmr.render(delta, MathHelper.clamp(MathHelper.clamp(f, 0.0F, 1.0F) * ((float) rcmr.panorama.visualSettings.alpha / 255.0F), 0.0F, 1.0F)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ protected void apply(HashMap<Identifier, PanoramaGroup> prepared, ResourceManage
Registry.register(VistasRegistry.PANORAMA_REGISTRY, id, group);
}
});
VistasRegistry.setCurrentPanorama(VistasRegistry.getChosenPanorama());
}

protected void add(Identifier id, PanoramaGroup panGroup) {
Expand Down

0 comments on commit 9055afe

Please sign in to comment.