Package net.minecraft.resource
Class SimpleResourceReload<S>
java.lang.Object
net.minecraft.resource.SimpleResourceReload<S>
- Type Parameters:
S- the result type for each reloader in the reload
- All Implemented Interfaces:
ResourceReload
- Direct Known Subclasses:
ProfiledResourceReload
public class SimpleResourceReload<S> extends Object implements ResourceReload
A simple implementation of resource reload.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSimpleResourceReload.Factory<S> -
Field Summary
Fields Modifier and Type Field Description private intappliedCountprotected CompletableFuture<List<S>>applyStageFutureprotected ResourceManagermanagerprivate AtomicIntegerpreparedCountprotected CompletableFuture<Unit>prepareStageFutureprivate intreloaderCountprivate inttoApplyCountprivate AtomicIntegertoPrepareCountprivate Set<ResourceReloader>waitingReloaders -
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleResourceReload(Executor prepareExecutor, Executor applyExecutor, ResourceManager manager, List<ResourceReloader> reloaders, SimpleResourceReload.Factory<S> factory, CompletableFuture<Unit> initialStage) -
Method Summary
Modifier and Type Method Description static SimpleResourceReload<Void>create(ResourceManager manager, List<ResourceReloader> reloaders, Executor prepareExecutor, Executor applyExecutor, CompletableFuture<Unit> initialStage)Creates a simple resource reload without additional results.floatgetProgress()Returns a fraction between 0 and 1 indicating the progress of this reload.booleanisComplete()Returns if this reload has completed, either normally or abnormally.booleanisPrepareStageComplete()voidthrowException()Throws an unchecked exception from this reload, if there is any.CompletableFuture<Unit>whenComplete()Returns a future for the reload.
-
Field Details
-
manager
-
prepareStageFuture
-
applyStageFuture
-
waitingReloaders
-
reloaderCount
private final int reloaderCount -
toApplyCount
private int toApplyCount -
appliedCount
private int appliedCount -
toPrepareCount
-
preparedCount
-
-
Constructor Details
-
SimpleResourceReload
protected SimpleResourceReload(Executor prepareExecutor, Executor applyExecutor, ResourceManager manager, List<ResourceReloader> reloaders, SimpleResourceReload.Factory<S> factory, CompletableFuture<Unit> initialStage)
-
-
Method Details
-
create
public static SimpleResourceReload<Void> create(ResourceManager manager, List<ResourceReloader> reloaders, Executor prepareExecutor, Executor applyExecutor, CompletableFuture<Unit> initialStage)Creates a simple resource reload without additional results. -
whenComplete
Returns a future for the reload. The returned future is completed when the reload completes.- Specified by:
whenCompletein interfaceResourceReload
-
getProgress
@Environment(CLIENT) public float getProgress()Returns a fraction between 0 and 1 indicating the progress of this reload.- Specified by:
getProgressin interfaceResourceReload
-
isPrepareStageComplete
@Environment(CLIENT) public boolean isPrepareStageComplete()- Specified by:
isPrepareStageCompletein interfaceResourceReload
-
isComplete
@Environment(CLIENT) public boolean isComplete()Returns if this reload has completed, either normally or abnormally.- Specified by:
isCompletein interfaceResourceReload
-
throwException
@Environment(CLIENT) public void throwException()Throws an unchecked exception from this reload, if there is any. Does nothing if the reload has not completed or terminated.- Specified by:
throwExceptionin interfaceResourceReload
-