mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-14 14:33:57 +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;
|
package com.jozufozu.flywheel.api.visual;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.instance.Instance;
|
import com.jozufozu.flywheel.api.instance.Instance;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
|
||||||
public interface BlockEntityVisual<T extends BlockEntity> extends Visual {
|
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.backend.Engine;
|
||||||
import com.jozufozu.flywheel.api.event.RenderContext;
|
import com.jozufozu.flywheel.api.event.RenderContext;
|
||||||
import com.jozufozu.flywheel.api.event.RenderStage;
|
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.Plan;
|
||||||
import com.jozufozu.flywheel.api.task.TaskExecutor;
|
import com.jozufozu.flywheel.api.task.TaskExecutor;
|
||||||
import com.jozufozu.flywheel.api.visual.DynamicVisual;
|
import com.jozufozu.flywheel.api.visual.DynamicVisual;
|
||||||
@ -227,7 +228,9 @@ public class VisualizationManagerImpl implements VisualizationManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var instances = visual.getCrumblingInstances();
|
List<Instance> instances = new ArrayList<>();
|
||||||
|
|
||||||
|
visual.collectCrumblingInstances(instances::add);
|
||||||
|
|
||||||
if (instances.isEmpty()) {
|
if (instances.isEmpty()) {
|
||||||
// The visual doesn't want to render anything crumbling.
|
// The visual doesn't want to render anything crumbling.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.jozufozu.flywheel.vanilla;
|
package com.jozufozu.flywheel.vanilla;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.joml.AxisAngle4f;
|
import org.joml.AxisAngle4f;
|
||||||
import org.joml.Quaternionf;
|
import org.joml.Quaternionf;
|
||||||
@ -89,8 +89,8 @@ public class BellVisual extends AbstractBlockEntityVisual<BellBlockEntity> imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instance> getCrumblingInstances() {
|
public void collectCrumblingInstances(Consumer<Instance> consumer) {
|
||||||
return List.of(bell);
|
consumer.accept(bell);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,8 +2,8 @@ package com.jozufozu.flywheel.vanilla;
|
|||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.joml.Quaternionf;
|
import org.joml.Quaternionf;
|
||||||
|
|
||||||
@ -161,8 +161,10 @@ public class ChestVisual<T extends BlockEntity & LidBlockEntity> extends Abstrac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instance> getCrumblingInstances() {
|
public void collectCrumblingInstances(Consumer<Instance> consumer) {
|
||||||
return List.of(bottom, lid, lock);
|
consumer.accept(bottom);
|
||||||
|
consumer.accept(lid);
|
||||||
|
consumer.accept(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.jozufozu.flywheel.vanilla;
|
package com.jozufozu.flywheel.vanilla;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.joml.Quaternionf;
|
import org.joml.Quaternionf;
|
||||||
|
|
||||||
@ -126,8 +126,9 @@ public class ShulkerBoxVisual extends AbstractBlockEntityVisual<ShulkerBoxBlockE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instance> getCrumblingInstances() {
|
public void collectCrumblingInstances(Consumer<Instance> consumer) {
|
||||||
return List.of(base, lid);
|
consumer.accept(base);
|
||||||
|
consumer.accept(lid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user