forked from FiniteReality/embeddium
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
...main/java/me/jellysquid/mods/sodium/mixin/features/chunk_rendering/MixinRenderGlobal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package me.jellysquid.mods.sodium.mixin.features.chunk_rendering; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.entity.EntityPlayerSP; | ||
import net.minecraft.client.multiplayer.WorldClient; | ||
import net.minecraft.client.renderer.RenderGlobal; | ||
import net.minecraft.client.renderer.culling.ICamera; | ||
import net.minecraft.client.renderer.entity.RenderManager; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.util.ClassInheritanceMultiMap; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.chunk.Chunk; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(RenderGlobal.class) | ||
public abstract class MixinRenderGlobal { | ||
@Shadow @Final private RenderManager renderManager; | ||
|
||
@Shadow @Final private Minecraft mc; | ||
|
||
@Shadow private int countEntitiesRendered; | ||
|
||
@Shadow private WorldClient world; | ||
|
||
@Shadow protected abstract boolean isOutlineActive(Entity entityIn, Entity viewer, ICamera camera); | ||
|
||
/** | ||
* @author embeddedt | ||
* @reason reimplement entity render loop because vanilla's relies on the renderInfos list | ||
*/ | ||
@Inject(method = "renderEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/RenderGlobal;renderInfos:Ljava/util/List;", ordinal = 0)) | ||
private void renderEntities(Entity renderViewEntity, ICamera camera, float partialTicks, CallbackInfo ci, | ||
@Local(ordinal = 0) List<Entity> loadedEntityList, | ||
@Local(ordinal = 1) List<Entity> outlineEntityList, | ||
@Local(ordinal = 2) List<Entity> multipassEntityList, | ||
@Local(ordinal = 0) double renderViewX, | ||
@Local(ordinal = 1) double renderViewY, | ||
@Local(ordinal = 2) double renderViewZ) { | ||
int pass = net.minecraftforge.client.MinecraftForgeClient.getRenderPass(); | ||
EntityPlayerSP player = this.mc.player; | ||
BlockPos.MutableBlockPos entityBlockPos = new BlockPos.MutableBlockPos(); | ||
for(Entity entity : loadedEntityList) { | ||
// Skip entities that shouldn't render in this pass | ||
if(!entity.shouldRenderInPass(pass)) { | ||
continue; | ||
} | ||
|
||
// Do regular vanilla checks for visibility | ||
if(!this.renderManager.shouldRender(entity, camera, renderViewX, renderViewY, renderViewZ) && !entity.isRidingOrBeingRiddenBy(player)) { | ||
continue; | ||
} | ||
|
||
// Check if any corners of the bounding box are in a visible subchunk | ||
if(!SodiumWorldRenderer.getInstance().isEntityVisible(entity)) { | ||
continue; | ||
} | ||
|
||
boolean isSleeping = renderViewEntity instanceof EntityLivingBase && ((EntityLivingBase) renderViewEntity).isPlayerSleeping(); | ||
|
||
if ((entity != renderViewEntity || this.mc.gameSettings.thirdPersonView != 0 || isSleeping) | ||
&& (entity.posY < 0.0D || entity.posY >= 256.0D || this.world.isBlockLoaded(entityBlockPos.setPos(entity)))) | ||
{ | ||
++this.countEntitiesRendered; | ||
this.renderManager.renderEntityStatic(entity, partialTicks, false); | ||
|
||
if (this.isOutlineActive(entity, renderViewEntity, camera)) | ||
{ | ||
outlineEntityList.add(entity); | ||
} | ||
|
||
if (this.renderManager.isRenderMultipass(entity)) { | ||
multipassEntityList.add(entity); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters