mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 16:53:42 +01:00
Fix ConcurrentModificationException preparing frame for rendering.
This commit is contained in:
parent
affb8abfbd
commit
2e5d7a734f
2 changed files with 19 additions and 15 deletions
|
@ -25,7 +25,7 @@ import java.util.ArrayList;
|
|||
|
||||
public class ContraptionKineticRenderer extends InstancedTileRenderer<ContraptionProgram> {
|
||||
|
||||
protected ArrayList<com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance> actors = new ArrayList<>();
|
||||
protected ArrayList<ActorInstance> actors = new ArrayList<>();
|
||||
|
||||
private final WeakReference<RenderedContraption> contraption;
|
||||
|
||||
|
@ -46,25 +46,25 @@ public class ContraptionKineticRenderer extends InstancedTileRenderer<Contraptio
|
|||
|
||||
@Override
|
||||
public void tick() {
|
||||
actors.forEach(com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance::tick);
|
||||
actors.forEach(ActorInstance::tick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginFrame(double cameraX, double cameraY, double cameraZ) {
|
||||
super.beginFrame(cameraX, cameraY, cameraZ);
|
||||
|
||||
actors.forEach(com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance::beginFrame);
|
||||
actors.forEach(ActorInstance::beginFrame);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance createActor(Pair<Template.BlockInfo, MovementContext> actor) {
|
||||
public ActorInstance createActor(Pair<Template.BlockInfo, MovementContext> actor) {
|
||||
Template.BlockInfo blockInfo = actor.getLeft();
|
||||
MovementContext context = actor.getRight();
|
||||
|
||||
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state);
|
||||
|
||||
if (movementBehaviour != null && movementBehaviour.hasSpecialInstancedRendering()) {
|
||||
com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance instance = movementBehaviour.createInstance(this, context);
|
||||
ActorInstance instance = movementBehaviour.createInstance(this, context);
|
||||
|
||||
actors.add(instance);
|
||||
|
||||
|
|
|
@ -44,10 +44,7 @@ public abstract class InstancedTileRenderer<P extends BasicProgram> {
|
|||
}
|
||||
|
||||
public void beginFrame(double cameraX, double cameraY, double cameraZ) {
|
||||
if (queuedAdditions.size() > 0) {
|
||||
queuedAdditions.forEach(this::addInternal);
|
||||
queuedAdditions.clear();
|
||||
}
|
||||
processQueuedAdditions();
|
||||
if (dynamicInstances.size() > 0)
|
||||
dynamicInstances.values().forEach(IDynamicInstance::beginFrame);
|
||||
}
|
||||
|
@ -111,12 +108,6 @@ public abstract class InstancedTileRenderer<P extends BasicProgram> {
|
|||
}
|
||||
}
|
||||
|
||||
public <T extends TileEntity> void queueAdd(T tile) {
|
||||
if (!Backend.canUseInstancing()) return;
|
||||
|
||||
queuedAdditions.add(tile);
|
||||
}
|
||||
|
||||
public <T extends TileEntity> void update(T tile) {
|
||||
if (!Backend.canUseInstancing()) return;
|
||||
|
||||
|
@ -144,6 +135,19 @@ public abstract class InstancedTileRenderer<P extends BasicProgram> {
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized <T extends TileEntity> void queueAdd(T tile) {
|
||||
if (!Backend.canUseInstancing()) return;
|
||||
|
||||
queuedAdditions.add(tile);
|
||||
}
|
||||
|
||||
protected synchronized void processQueuedAdditions() {
|
||||
if (queuedAdditions.size() > 0) {
|
||||
queuedAdditions.forEach(this::addInternal);
|
||||
queuedAdditions.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void addInternal(TileEntity tile) {
|
||||
getInstance(tile, true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue