diff --git a/src/main/java/com/jozufozu/flywheel/api/visual/BlockEntityVisual.java b/src/main/java/com/jozufozu/flywheel/api/visual/BlockEntityVisual.java index 461de922c..3436a303c 100644 --- a/src/main/java/com/jozufozu/flywheel/api/visual/BlockEntityVisual.java +++ b/src/main/java/com/jozufozu/flywheel/api/visual/BlockEntityVisual.java @@ -1,11 +1,17 @@ package com.jozufozu.flywheel.api.visual; -import java.util.List; +import java.util.function.Consumer; import com.jozufozu.flywheel.api.instance.Instance; import net.minecraft.world.level.block.entity.BlockEntity; public interface BlockEntityVisual extends Visual { - List getCrumblingInstances(); + /** + * Collect all instances that should render with a crumbling overlay + * when the block corresponding to this visual is being broken. + * + * @param consumer A consumer to provide instances to. + */ + void collectCrumblingInstances(Consumer consumer); } diff --git a/src/main/java/com/jozufozu/flywheel/impl/visualization/VisualizationManagerImpl.java b/src/main/java/com/jozufozu/flywheel/impl/visualization/VisualizationManagerImpl.java index 625ac7a17..c09ca4d7c 100644 --- a/src/main/java/com/jozufozu/flywheel/impl/visualization/VisualizationManagerImpl.java +++ b/src/main/java/com/jozufozu/flywheel/impl/visualization/VisualizationManagerImpl.java @@ -10,6 +10,7 @@ import com.jozufozu.flywheel.api.backend.BackendManager; import com.jozufozu.flywheel.api.backend.Engine; import com.jozufozu.flywheel.api.event.RenderContext; import com.jozufozu.flywheel.api.event.RenderStage; +import com.jozufozu.flywheel.api.instance.Instance; import com.jozufozu.flywheel.api.task.Plan; import com.jozufozu.flywheel.api.task.TaskExecutor; import com.jozufozu.flywheel.api.visual.DynamicVisual; @@ -227,7 +228,9 @@ public class VisualizationManagerImpl implements VisualizationManager { continue; } - var instances = visual.getCrumblingInstances(); + List instances = new ArrayList<>(); + + visual.collectCrumblingInstances(instances::add); if (instances.isEmpty()) { // The visual doesn't want to render anything crumbling. diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java index d6126d5af..aded9687b 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.vanilla; -import java.util.List; +import java.util.function.Consumer; import org.joml.AxisAngle4f; import org.joml.Quaternionf; @@ -89,8 +89,8 @@ public class BellVisual extends AbstractBlockEntityVisual imple } @Override - public List getCrumblingInstances() { - return List.of(bell); + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(bell); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java index 01df7480c..e5ed24fdd 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java @@ -2,8 +2,8 @@ package com.jozufozu.flywheel.vanilla; import java.util.Calendar; import java.util.EnumMap; -import java.util.List; import java.util.Map; +import java.util.function.Consumer; import org.joml.Quaternionf; @@ -161,8 +161,10 @@ public class ChestVisual extends Abstrac } @Override - public List getCrumblingInstances() { - return List.of(bottom, lid, lock); + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(bottom); + consumer.accept(lid); + consumer.accept(lock); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java index c04326622..efa9491e8 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.vanilla; -import java.util.List; +import java.util.function.Consumer; import org.joml.Quaternionf; @@ -126,8 +126,9 @@ public class ShulkerBoxVisual extends AbstractBlockEntityVisual getCrumblingInstances() { - return List.of(base, lid); + public void collectCrumblingInstances(Consumer consumer) { + consumer.accept(base); + consumer.accept(lid); } @Override