Code cleanup

This commit is contained in:
FlorianMichael 2023-12-07 00:46:00 +01:00
parent 1cac6e5e16
commit 4269453a5e
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 9 additions and 18 deletions

View File

@ -23,6 +23,4 @@ public interface IDownloadingTerrainScreen {
void viaFabricPlus$setReady();
boolean viaFabricPlus$isReady();
}

View File

@ -121,17 +121,15 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH
@Inject(method = "onPlayerSpawnPosition", at = @At("RETURN"))
public void moveDownloadingTerrainClosing(PlayerSpawnPositionS2CPacket packet, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_19, VersionEnum.r1_20_2)) {
if (this.client.currentScreen instanceof DownloadingTerrainScreen downloadingTerrainScreen) {
((IDownloadingTerrainScreen) downloadingTerrainScreen).viaFabricPlus$setReady();
}
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.r1_19, VersionEnum.r1_20_2) && this.client.currentScreen instanceof IDownloadingTerrainScreen mixinDownloadingTerrainScreen) {
mixinDownloadingTerrainScreen.viaFabricPlus$setReady();
}
}
@Inject(method = "onPlayerPositionLook", at = @At("RETURN"))
private void closeDownloadingTerrain(PlayerPositionLookS2CPacket packet, CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1) && this.client.currentScreen instanceof DownloadingTerrainScreen downloadingTerrainScreen) {
((IDownloadingTerrainScreen) downloadingTerrainScreen).viaFabricPlus$setReady();
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1) && this.client.currentScreen instanceof IDownloadingTerrainScreen mixinDownloadingTerrainScreen) {
mixinDownloadingTerrainScreen.viaFabricPlus$setReady();
}
}

View File

@ -47,7 +47,7 @@ public abstract class MixinDownloadingTerrainScreen extends Screen implements ID
private int viaFabricPlus$tickCounter;
@Unique
private boolean viaFabricPlus$isReady;
private boolean viaFabricPlus$ready;
@Unique
private boolean viaFabricPlus$closeOnNextTick = false;
@ -73,15 +73,15 @@ public abstract class MixinDownloadingTerrainScreen extends Screen implements ID
}
} else {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_1tor1_19_2)) {
this.viaFabricPlus$closeOnNextTick = this.viaFabricPlus$isReady || System.currentTimeMillis() > this.loadStartTime + 2000;
this.viaFabricPlus$closeOnNextTick = this.viaFabricPlus$ready || System.currentTimeMillis() > this.loadStartTime + 2000;
} else {
this.viaFabricPlus$closeOnNextTick = this.viaFabricPlus$isReady;
this.viaFabricPlus$closeOnNextTick = this.viaFabricPlus$ready;
}
}
}
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
if (this.viaFabricPlus$isReady) {
if (this.viaFabricPlus$ready) {
this.close();
}
@ -95,14 +95,9 @@ public abstract class MixinDownloadingTerrainScreen extends Screen implements ID
}
}
@Override
public boolean viaFabricPlus$isReady() {
return viaFabricPlus$isReady;
}
@Override
public void viaFabricPlus$setReady() {
viaFabricPlus$isReady = true;
viaFabricPlus$ready = true;
}
}