mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-10 12:34:11 +01:00
Crumbling inheritance
- Instead of returning a list, collect crumbling instances via consumer. - This is much friendlier to inheritance and generally better represents the behavior we want from Visuals.
This commit is contained in:
parent
64df7ed981
commit
8221616eff
@ -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<T extends BlockEntity> extends Visual {
|
||||
List<Instance> 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<Instance> consumer);
|
||||
}
|
||||
|
@ -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<Instance> instances = new ArrayList<>();
|
||||
|
||||
visual.collectCrumblingInstances(instances::add);
|
||||
|
||||
if (instances.isEmpty()) {
|
||||
// The visual doesn't want to render anything crumbling.
|
||||
|
@ -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<BellBlockEntity> imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Instance> getCrumblingInstances() {
|
||||
return List.of(bell);
|
||||
public void collectCrumblingInstances(Consumer<Instance> consumer) {
|
||||
consumer.accept(bell);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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<T extends BlockEntity & LidBlockEntity> extends Abstrac
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Instance> getCrumblingInstances() {
|
||||
return List.of(bottom, lid, lock);
|
||||
public void collectCrumblingInstances(Consumer<Instance> consumer) {
|
||||
consumer.accept(bottom);
|
||||
consumer.accept(lid);
|
||||
consumer.accept(lock);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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<ShulkerBoxBlockE
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Instance> getCrumblingInstances() {
|
||||
return List.of(base, lid);
|
||||
public void collectCrumblingInstances(Consumer<Instance> consumer) {
|
||||
consumer.accept(base);
|
||||
consumer.accept(lid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user