mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-01 01:46:39 +01:00
Instanced entities are compatible with optifine
- Fix mixin related crash on startup - Change defaultRequire to 0
This commit is contained in:
parent
c58674d678
commit
195a7348f3
2 changed files with 19 additions and 2 deletions
|
@ -1,9 +1,11 @@
|
||||||
package com.jozufozu.flywheel.mixin;
|
package com.jozufozu.flywheel.mixin;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Group;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
@ -13,20 +15,35 @@ import com.jozufozu.flywheel.backend.instancing.IInstanceRendered;
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.util.ClassInheritanceMultiMap;
|
||||||
|
|
||||||
@Mixin(WorldRenderer.class)
|
@Mixin(WorldRenderer.class)
|
||||||
public class CancelEntityRenderMixin {
|
public class CancelEntityRenderMixin {
|
||||||
|
|
||||||
|
@Group(name = "entityFilter", min = 1, max = 1)
|
||||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getAllEntities()Ljava/lang/Iterable;"))
|
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getAllEntities()Ljava/lang/Iterable;"))
|
||||||
private Iterable<Entity> filterEntities(ClientWorld world) {
|
private Iterable<Entity> filterEntities(ClientWorld world) {
|
||||||
Iterable<Entity> entities = world.getAllEntities();
|
Iterable<Entity> entities = world.getAllEntities();
|
||||||
if (Backend.getInstance().canUseInstancing()) {
|
if (Backend.getInstance().canUseInstancing()) {
|
||||||
|
|
||||||
ArrayList<Entity> filtered = Lists.newArrayList(entities);
|
ArrayList<Entity> filtered = Lists.newArrayList(entities);
|
||||||
filtered.removeIf(tile -> tile instanceof IInstanceRendered && !((IInstanceRendered) tile).shouldRenderNormally());
|
filtered.removeIf(entity -> entity instanceof IInstanceRendered && !((IInstanceRendered) entity).shouldRenderNormally());
|
||||||
|
|
||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
return entities;
|
return entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Group(name = "entityFilter")
|
||||||
|
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ClassInheritanceMultiMap;iterator()Ljava/util/Iterator;"))
|
||||||
|
private Iterator<Entity> filterEntitiesOF(ClassInheritanceMultiMap<Entity> classInheritanceMultiMap) {
|
||||||
|
if (Backend.getInstance().canUseInstancing()) {
|
||||||
|
|
||||||
|
ArrayList<Entity> filtered = Lists.newArrayList(classInheritanceMultiMap);
|
||||||
|
filtered.removeIf(entity -> entity instanceof IInstanceRendered && !((IInstanceRendered) entity).shouldRenderNormally());
|
||||||
|
|
||||||
|
return filtered.iterator();
|
||||||
|
}
|
||||||
|
return classInheritanceMultiMap.iterator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
"light.NetworkLightUpdateMixin"
|
"light.NetworkLightUpdateMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue