mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 07:26:48 +01:00
Miscellaneous documentation
This commit is contained in:
parent
f21566d1fc
commit
e3b1172925
3 changed files with 53 additions and 7 deletions
|
@ -16,6 +16,15 @@ public interface IInstance {
|
|||
|
||||
void remove();
|
||||
|
||||
/**
|
||||
* When an instance is reset, the instance is deleted and re-created.
|
||||
*
|
||||
* <p>
|
||||
* This is used to handle things like block state changes.
|
||||
* </p>
|
||||
*
|
||||
* @return true if this instance should be reset
|
||||
*/
|
||||
boolean shouldReset();
|
||||
|
||||
void update();
|
||||
|
|
|
@ -49,17 +49,41 @@ public abstract class InstanceManager<T> implements MaterialManager.OriginShiftL
|
|||
materialManager.addListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given object capable of being instanced at all?
|
||||
*
|
||||
* @return false if on object cannot be instanced.
|
||||
*/
|
||||
protected abstract boolean canInstance(T obj);
|
||||
|
||||
/**
|
||||
* Is the given object currently capable of being instanced?
|
||||
*
|
||||
* <p>
|
||||
* This won't be the case for TEs or entities that are outside of loaded chunks.
|
||||
* </p>
|
||||
*
|
||||
* @return true if the object is currently capable of being instanced.
|
||||
*/
|
||||
protected abstract boolean canCreateInstance(T obj);
|
||||
|
||||
@Nullable
|
||||
protected abstract IInstance createRaw(T obj);
|
||||
|
||||
protected abstract boolean canCreateInstance(T entity);
|
||||
|
||||
/**
|
||||
* Ticks the InstanceManager.
|
||||
*
|
||||
* <p>
|
||||
* {@link ITickableInstance}s get ticked.
|
||||
* <br>
|
||||
* Queued updates are processed.
|
||||
* </p>
|
||||
*/
|
||||
public void tick(double cameraX, double cameraY, double cameraZ) {
|
||||
tick++;
|
||||
processQueuedUpdates();
|
||||
|
||||
// integer camera pos
|
||||
// integer camera pos as a micro-optimization
|
||||
int cX = (int) cameraX;
|
||||
int cY = (int) cameraY;
|
||||
int cZ = (int) cameraZ;
|
||||
|
@ -117,7 +141,7 @@ public abstract class InstanceManager<T> implements MaterialManager.OriginShiftL
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized void queueAdd(T obj) {
|
||||
public void queueAdd(T obj) {
|
||||
if (!Backend.getInstance()
|
||||
.canUseInstancing()) return;
|
||||
|
||||
|
@ -126,6 +150,17 @@ public abstract class InstanceManager<T> implements MaterialManager.OriginShiftL
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the instance associated with an object.
|
||||
*
|
||||
* <p>
|
||||
* By default this is the only hook an IInstance has to change its internal state. This is the lowest frequency
|
||||
* update hook IInstance gets. For more frequent updates, see {@link ITickableInstance} and
|
||||
* {@link IDynamicInstance}.
|
||||
* </p>
|
||||
*
|
||||
* @param obj the object to update.
|
||||
*/
|
||||
public void update(T obj) {
|
||||
if (!Backend.getInstance()
|
||||
.canUseInstancing()) return;
|
||||
|
@ -135,9 +170,11 @@ public abstract class InstanceManager<T> implements MaterialManager.OriginShiftL
|
|||
|
||||
if (instance != null) {
|
||||
|
||||
// resetting instances is by default used to handle block state changes.
|
||||
if (instance.shouldReset()) {
|
||||
// delete and re-create the instance.
|
||||
// resetting an instance supersedes updating it.
|
||||
removeInternal(obj, instance);
|
||||
|
||||
createInternal(obj);
|
||||
} else {
|
||||
instance.update();
|
||||
|
@ -146,7 +183,7 @@ public abstract class InstanceManager<T> implements MaterialManager.OriginShiftL
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized void queueUpdate(T obj) {
|
||||
public void queueUpdate(T obj) {
|
||||
if (!Backend.getInstance()
|
||||
.canUseInstancing()) return;
|
||||
synchronized (queuedUpdates) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class RenderHooksMixin {
|
|||
private RenderTypeBuffers renderBuffers;
|
||||
|
||||
@Inject(at = @At(value = "INVOKE", target = "net.minecraft.client.renderer.WorldRenderer.compileChunksUntil(J)V"), method = "renderLevel")
|
||||
private void setupFrame(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f p_228426_9_, CallbackInfo ci) {
|
||||
private void setupFrame(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_, ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projection, CallbackInfo ci) {
|
||||
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, stack, info, gameRenderer, lightTexture, Clipping.HELPER));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue