2021-06-16 20:19:33 +02:00
|
|
|
package com.jozufozu.flywheel.mixin;
|
2021-06-04 06:23:06 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
import org.spongepowered.asm.mixin.injection.At;
|
2021-06-07 11:43:36 +02:00
|
|
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
2021-06-04 06:23:06 +02:00
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
import com.jozufozu.flywheel.backend.Backend;
|
|
|
|
import com.jozufozu.flywheel.backend.instancing.IInstanceRendered;
|
|
|
|
|
2021-06-07 11:43:36 +02:00
|
|
|
import net.minecraft.client.renderer.WorldRenderer;
|
2021-06-04 06:23:06 +02:00
|
|
|
import net.minecraft.client.world.ClientWorld;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
2021-06-07 11:43:36 +02:00
|
|
|
@Mixin(WorldRenderer.class)
|
2021-06-04 06:23:06 +02:00
|
|
|
public class CancelEntityRenderMixin {
|
|
|
|
|
2021-06-07 11:43:36 +02:00
|
|
|
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getAllEntities()Ljava/lang/Iterable;"))
|
|
|
|
private Iterable<Entity> filterEntities(ClientWorld world) {
|
|
|
|
Iterable<Entity> entities = world.getAllEntities();
|
2021-06-07 00:46:16 +02:00
|
|
|
if (Backend.getInstance().canUseInstancing()) {
|
2021-06-04 06:23:06 +02:00
|
|
|
|
2021-06-07 11:43:36 +02:00
|
|
|
ArrayList<Entity> filtered = Lists.newArrayList(entities);
|
|
|
|
filtered.removeIf(tile -> tile instanceof IInstanceRendered && !((IInstanceRendered) tile).shouldRenderNormally());
|
2021-06-04 06:23:06 +02:00
|
|
|
|
2021-06-07 11:43:36 +02:00
|
|
|
return filtered;
|
2021-06-04 06:23:06 +02:00
|
|
|
}
|
2021-06-07 11:43:36 +02:00
|
|
|
return entities;
|
2021-06-04 06:23:06 +02:00
|
|
|
}
|
|
|
|
}
|