Skip to content

Commit 7f87d9c

Browse files
committed
change: add all 1.3.2 features to 1.19.2 forge version
1 parent 3d0d1c7 commit 7f87d9c

7 files changed

Lines changed: 97 additions & 68 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ forge_version=1.19.2-43.1.47
99
# yarn, latest version can be found on https://fabricmc.net/use
1010
yarn_mappings=1.19.2+build.9
1111
# Mod Properties
12-
mod_version=1.3.0+1.19.2
12+
mod_version=1.3.2+1.19.2
1313
maven_group=com.abdelaziz.fastload
1414
archives_base_name=Fastload-Reforged
1515
mod_id=fastload

src/main/java/com/abdelaziz/fastload/config/FLConfig.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,8 @@
1212
import java.nio.file.StandardOpenOption;
1313
import java.util.Properties;
1414

15+
@SuppressWarnings("SameParameterValue")
1516
public class FLConfig {
16-
//Config Variables
17-
protected static final int RAW_CHUNK_TRY_LIMIT;
18-
protected static final boolean CLOSE_LOADING_SCREEN_UNSAFELY;
19-
protected static final boolean DEBUG;
20-
protected static final int RAW_CHUNK_PREGEN_RADIUS;
21-
protected static final int RAW_PRE_RENDER_RADIUS;
22-
2317
static {
2418
final Properties properties = new Properties();
2519
final Properties newProperties = new Properties();
@@ -57,8 +51,7 @@ public class FLConfig {
5751
comment.write("\n# 'debug' = debug (log) all things happening in fastload to aid in diagnosing issues.");
5852
comment.write("\n# Enabled = true, Disabled = false");
5953
comment.write("\n#");
60-
comment.write("\n# 'pre_render_radius' = how many chunks are loaded until 'building terrain' is completed.");
61-
comment.write("\n# Keep in mind that for safety reasons, pre-rendering may not always fully complete");
54+
comment.write("\n# 'pre_render_radius' = how many chunks are loaded until 'building terrain' is completed. Adjusts with FOV to decide how many chunks are visible");
6255
comment.write("\n# Min = 0, Max = 32 or your render distance, Whichever is smaller. Set 0 to disable. Must be a positive Integer");
6356
comment.write("\n#");
6457
comment.write("\n# 'pregen_chunk_radius' = how many chunks (from 441 Loading) are pre-generated until the server starts");
@@ -70,6 +63,13 @@ public class FLConfig {
7063
}
7164
}
7265

66+
//Config Variables
67+
protected static final int RAW_CHUNK_TRY_LIMIT;
68+
protected static final boolean CLOSE_LOADING_SCREEN_UNSAFELY;
69+
protected static final boolean DEBUG;
70+
protected static final int RAW_CHUNK_PREGEN_RADIUS;
71+
protected static final int RAW_PRE_RENDER_RADIUS;
72+
7373
public static void loadClass() {
7474
}
7575

src/main/java/com/abdelaziz/fastload/config/FLMath.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ public class FLMath {
1616
private static final int PARSED_PREGEN_RADIUS = parseMinMax(RAW_CHUNK_PREGEN_RADIUS, PREGEN_RADIUS_BOUND, 0);
1717
//RENDER_RADIUS// Cannot be parsed as parsing dynamically changes. No point in making it a field
1818
private static final int PARSED_CHUNK_TRY_LIMIT = Math.max(RAW_CHUNK_TRY_LIMIT, 1);
19-
//Parsing
20-
private static final Supplier<Double> RENDER_DISTANCE = () ->
21-
MinecraftClient.getInstance().worldRenderer != null ?
22-
Math.min(MinecraftClient.getInstance().worldRenderer.getViewDistance(), RENDER_RADIUS_BOUND)
23-
: RENDER_RADIUS_BOUND;
2419

2520
//Unchanged Constant Getters
2621
public static int getChunkTryLimit() {
@@ -31,6 +26,12 @@ public static Boolean getDebug() {
3126
return DEBUG;
3227
}
3328

29+
//Parsing
30+
private static final Supplier<Double> RENDER_DISTANCE = () ->
31+
MinecraftClient.getInstance().worldRenderer != null ?
32+
Math.min(MinecraftClient.getInstance().worldRenderer.getViewDistance(), RENDER_RADIUS_BOUND)
33+
: RENDER_RADIUS_BOUND;
34+
3435
private static int getRenderDistance() {
3536
return RENDER_DISTANCE.get().intValue();
3637
}
@@ -43,9 +44,11 @@ public static int getPregenRadius(boolean raw) {
4344
if (PARSED_PREGEN_RADIUS == 0) {
4445
return 1;
4546
}
47+
4648
if (raw) {
4749
return PARSED_PREGEN_RADIUS;
4850
}
51+
4952
return PARSED_PREGEN_RADIUS + 1;
5053
}
5154

@@ -56,10 +59,12 @@ private static int getSquareArea(boolean worldProgressTracker, int toCalc, boole
5659
if (!raw) {
5760
i++;
5861
}
62+
5963
if (worldProgressTracker) {
6064
i++;
6165
i++;
6266
}
67+
6368
return i * i;
6469
}
6570

src/main/java/com/abdelaziz/fastload/mixin/DownloadingTerrainScreenMixin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111

1212
@Mixin(DownloadingTerrainScreen.class)
1313
public class DownloadingTerrainScreenMixin {
14-
1514
//Code is from 'kennytv'. All credits are to this person. This is not our code.
1615
//Permission granted to do so from MIT License of 'forcecloseloadingscreen'.
1716
@Shadow private boolean closeOnNextTick;
1817

1918
@Inject(at = @At("HEAD"), method = "setReady")
2019
public void tick(final CallbackInfo ci) {
2120
if (FLMath.getDebug()) FastLoad.LOGGER.info("DTS will now close on next tick");
22-
closeOnNextTick = true;
21+
if (FLMath.getCloseUnsafe() || FLMath.getCloseSafe()) closeOnNextTick = true;
2322
}
2423
}

src/main/java/com/abdelaziz/fastload/mixin/MinecraftClientMixin.java

Lines changed: 63 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.abdelaziz.fastload.mixin;
22

33
import com.abdelaziz.fastload.FastLoad;
4-
import com.abdelaziz.fastload.config.FLConfig;
54
import com.abdelaziz.fastload.util.mixin.MinecraftClientMixinInterface;
65
import com.abdelaziz.fastload.util.screen.BuildingTerrainScreen;
76
import net.minecraft.client.MinecraftClient;
@@ -33,6 +32,7 @@ public abstract class MinecraftClientMixin implements MinecraftClientMixinInterf
3332

3433
//Original code is from 'kennytv, forceloadingscreen' under the 'MIT' License.
3534
//Code is heavily modified to suit Fastload's needs
35+
3636
//Pre Renderer Log Constants
3737
@SuppressWarnings("FieldCanBeLocal")
3838
private final int chunkTryLimit = getChunkTryLimit();
@@ -55,43 +55,34 @@ public abstract class MinecraftClientMixin implements MinecraftClientMixinInterf
5555
public ClientPlayerEntity player;
5656
@Shadow
5757
private boolean windowFocused;
58-
@Shadow
59-
private volatile boolean running;
58+
6059
//Checkers
6160
private boolean justLoaded = false;
6261
private boolean shouldLoad = false;
6362
private boolean playerJoined = false;
6463
private boolean showRDDOnce = false;
65-
//Boolean to Initiate Pre-render
64+
@Shadow
65+
private volatile boolean running;
66+
//Boolean Pre-render
6667
private boolean isBuilding = false;
68+
private boolean closeBuild = false;
69+
6770
//Storage
6871
private Float oldPitch = null;
6972
private Integer oldChunkLoadedCountStorage = null;
7073
private Integer oldChunkBuildCountStorage = null;
74+
7175
//Warning Constants
7276
private int preparationWarnings = 0;
7377
private int buildingWarnings = 0;
74-
// Set this to 0 to start timer for Pause Menu Cancellation
75-
private int timeDown = timeDownGoal;
76-
77-
//Basic Logger
78-
private static void log(String toLog) {
79-
FastLoad.LOGGER.info(toLog);
80-
}
81-
82-
//Logs Difference in Render and Pre-render distances
83-
private static void logRenderDistanceDifference() {
84-
if (!getPreRenderRadius().equals(getPreRenderRadius(true)))
85-
log("Pre-rendering radius changed to "
86-
+ getPreRenderRadius() + " from " + getPreRenderRadius(true)
87-
+ " to protect from chunks not loading past your given render distance. " +
88-
"To resolve this, please adjust your render distance accordingly");
89-
}
9078

9179
@Shadow
9280
public void setScreen(@Nullable Screen screen) {
9381
}
9482

83+
// Set this to 0 to start timer for Pause Menu Cancellation
84+
private int timeDown = timeDownGoal;
85+
9586
//Checks if Player is ready
9687
public void canPlayerLoad() {
9788
shouldLoad = true;
@@ -107,6 +98,20 @@ private Camera getCamera() {
10798
return gameRenderer.getCamera();
10899
}
109100

101+
//Basic Logger
102+
private static void log(String toLog) {
103+
FastLoad.LOGGER.info(toLog);
104+
}
105+
106+
//Logs Difference in Render and Pre-render distances
107+
private static void logRenderDistanceDifference() {
108+
if (!getPreRenderRadius().equals(getPreRenderRadius(true)))
109+
log("Pre-rendering radius changed to "
110+
+ getPreRenderRadius() + " from " + getPreRenderRadius(true)
111+
+ " to protect from chunks not loading past your given render distance. " +
112+
"To resolve this, please adjust your render distance accordingly");
113+
}
114+
110115
//Logs Goal Versus amount Pre-renderer could load
111116
private void logPreRendering(int chunkLoadedCount) {
112117
log("Goal (Loaded Chunks): " + getPreRenderArea());
@@ -120,21 +125,27 @@ private void logBuilding(int chunkBuildCount, int chunkBuildCountGoal) {
120125

121126
private void stopBuilding(int chunkLoadedCount, int chunkBuildCount, int chunkBuildCountGoal) {
122127
if (playerJoined) {
128+
closeBuild = true;
123129
if (debug) {
124130
logBuilding(chunkBuildCount, chunkBuildCountGoal);
125131
logPreRendering(chunkLoadedCount);
126132
}
133+
127134
isBuilding = false;
135+
128136
if (!windowFocused) {
129137
timeDown = 0;
130138
if (debug) log("Temporarily Cancelling Pause Menu to enable Renderer");
131139
}
140+
132141
assert this.player != null;
142+
133143
if (oldPitch != null) {
134144
getCamera().setRotation(this.player.getYaw(), oldPitch);
135145
if (this.player.getPitch() != oldPitch) this.player.setPitch(oldPitch);
136146
oldPitch = null;
137147
}
148+
138149
playerJoined = false;
139150
oldChunkLoadedCountStorage = 0;
140151
oldChunkBuildCountStorage = 0;
@@ -152,26 +163,31 @@ private void setScreen(final Screen screen, final CallbackInfo ci) {
152163
showRDDOnce = false;
153164
oldPitch = null;
154165
}
166+
155167
//Stop Pause Menu interfering with rendering
156168
if (timeDown < timeDownGoal && screen instanceof GameMenuScreen && !windowFocused) {
157169
ci.cancel();
158170
setScreen(null);
159171
}
172+
160173
//Log Pre-Render Initiation
161174
if (screen instanceof BuildingTerrainScreen) {
162175
if (debug) log("Successfully Initiated Building Terrain");
163176
}
177+
164178
//Close Progress Screen
165179
if (screen instanceof ProgressScreen && getCloseUnsafe()) {
166180
ci.cancel();
167181
if (debug) log("Progress Screen Successfully Cancelled");
168182
}
183+
169184
//Close Downloading Terrain Screen ASAP
170185
if (screen instanceof DownloadingTerrainScreen && shouldLoad && playerJoined && running) {
171186
if (debug) log("Downloading Terrain Accessed!");
172187
shouldLoad = false;
173188
justLoaded = true;
174189
showRDDOnce = true;
190+
175191
// Switch to Pre-render Phase
176192
if (getCloseSafe()) {
177193
ci.cancel();
@@ -217,17 +233,13 @@ private void onRender(boolean tick, CallbackInfo ci) {
217233
if (this.world != null) {
218234
//Optimisations
219235
assert player != null;
220-
221236
if (oldPitch == null) {
222237
oldPitch = this.player.getPitch();
223238
}
224-
225239
this.player.setPitch(0);
226-
227240
if (debug) {
228241
log("Pitch:" + oldPitch);
229242
}
230-
231243
int chunkLoadedCount = this.world.getChunkManager().getLoadedChunkCount();
232244
int chunkBuildCount = this.worldRenderer.getCompletedChunkCount();
233245
double FOV = this.options.getFov().getValue();
@@ -261,6 +273,7 @@ The reason for this function (within the if() check, below this comment paragrap
261273
stopBuilding(chunkLoadedCount, chunkBuildCount, (int) chunkBuildCountGoal);
262274
}
263275
}
276+
264277
//Same warning system but for building chunks
265278
if (oldChunkBuildCountStorage == chunkBuildCount) {
266279
buildingWarnings++;
@@ -271,34 +284,43 @@ The reason for this function (within the if() check, below this comment paragrap
271284
stopBuilding(chunkLoadedCount, chunkBuildCount, (int) chunkBuildCountGoal);
272285
}
273286
}
274-
//Log Warnings
275-
final int spamLimit = 2;
276-
if (preparationWarnings > 0) {
277-
if (oldPreparationWarningCache == preparationWarnings && preparationWarnings > spamLimit) {
278-
log("FL_WARN# Same prepared chunk count returned " + preparationWarnings + " time(s) in a row! Had it be " + chunkTryLimit + " time(s) in a row, chunk preparation would've stopped");
279-
if (debug) logPreRendering(chunkLoadedCount);
280-
}
281-
if (chunkLoadedCount > oldChunkLoadedCountStorage) {
282-
preparationWarnings = 0;
283-
}
284-
}
285-
if (buildingWarnings > 0) {
286-
if (oldBuildingWarningCache == buildingWarnings && buildingWarnings > spamLimit) {
287-
log("FL_WARN# Same built chunk count returned " + buildingWarnings + " time(s) in a row! Had it be " + chunkTryLimit + " time(s) in a row, chunk building would've stopped");
288-
if (debug) logPreRendering(chunkLoadedCount);
287+
288+
if (!closeBuild) {
289+
//Log Warnings
290+
final int spamLimit = 2;
291+
if (preparationWarnings > 0) {
292+
if (oldPreparationWarningCache == preparationWarnings && preparationWarnings > spamLimit) {
293+
log("FL_WARN# Same prepared chunk count returned " + preparationWarnings + " time(s) in a row! Had it be " + chunkTryLimit + " time(s) in a row, chunk preparation would've stopped");
294+
if (debug) logPreRendering(chunkLoadedCount);
295+
}
296+
297+
if (chunkLoadedCount > oldChunkLoadedCountStorage) {
298+
preparationWarnings = 0;
299+
}
289300
}
290-
if (chunkBuildCount > oldChunkBuildCountStorage) {
291-
buildingWarnings = 0;
301+
302+
if (buildingWarnings > 0) {
303+
if (oldBuildingWarningCache == buildingWarnings && buildingWarnings > spamLimit) {
304+
log("FL_WARN# Same built chunk count returned " + buildingWarnings + " time(s) in a row! Had it be " + chunkTryLimit + " time(s) in a row, chunk building would've stopped");
305+
if (debug) logPreRendering(chunkLoadedCount);
306+
}
307+
308+
if (chunkBuildCount > oldChunkBuildCountStorage) {
309+
buildingWarnings = 0;
310+
}
292311
}
293312
}
294313
}
314+
295315
//Next two if() statements stop building when their respective tasks are completed
296316
oldChunkLoadedCountStorage = chunkLoadedCount;
297317
oldChunkBuildCountStorage = chunkBuildCount;
318+
298319
if (chunkLoadedCount >= getPreRenderArea() && chunkBuildCount >= chunkBuildCountGoal / 4.0) {
299320
stopBuilding(chunkLoadedCount, chunkBuildCount, (int) chunkBuildCountGoal);
300321
log("Successfully prepared sufficient chunks! Stopping...");
301322
}
323+
302324
if (chunkBuildCount >= chunkBuildCountGoal && chunkLoadedCount >= getPreRenderArea() / 4.0) {
303325
log("Built Sufficient Chunks! Stopping...");
304326
stopBuilding(chunkLoadedCount, chunkBuildCount, (int) chunkBuildCountGoal);

src/main/java/com/abdelaziz/fastload/mixin/WorldGenerationProcessLoggerMixin.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,19 @@
77

88
import net.minecraft.server.WorldGenerationProgressLogger;
99

10-
1110
@Mixin(value = WorldGenerationProgressLogger.class, priority = 1200)
1211
public class WorldGenerationProcessLoggerMixin {
1312
@Shadow
1413
@Final
1514
@Mutable
1615
private int totalCount = FLMath.getProgressArea();
17-
@Shadow
18-
private int generatedCount;
19-
2016
@ModifyVariable(method = "<init>", at = @At("HEAD"), argsOnly = true)
2117
private static int setRadius(int radius) {
2218
return FLMath.getPregenRadius(false);
2319
}
2420

21+
@Shadow
22+
private int generatedCount;
2523
/**
2624
* @author Fluffy Bumblebee
2725
* @reason Cancel C2ME's interference

0 commit comments

Comments
 (0)