Skip to content

Commit 186824a

Browse files
committed
1 parent f1a313a commit 186824a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/main/java/me/srrapero720/embeddium_extras/config/EmbeddiumExtrasConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
44
import com.electronwill.nightconfig.core.io.WritingMode;
5+
import net.minecraft.resources.ResourceLocation;
56
import net.minecraftforge.common.ForgeConfigSpec;
67
import java.nio.file.Path;
8+
import java.util.Collections;
9+
import java.util.List;
710

811
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
912

@@ -22,6 +25,7 @@ public class EmbeddiumExtrasConfig {
2225

2326
public static ConfigValue<Integer> maxEntityRenderDistanceSquare;
2427
public static ConfigValue<Integer> maxEntityRenderDistanceY;
28+
public static ForgeConfigSpec.ConfigValue<List<? extends String>> entityWhitelist;
2529

2630
public static ConfigValue<Boolean> fog;
2731
public static ConfigValue<Boolean> enableDistanceChecks;
@@ -77,6 +81,10 @@ public class EmbeddiumExtrasConfig {
7781

7882
maxEntityRenderDistanceSquare = b.define("(Entity) Max Horizontal Render Distance [Squared, Default 64^2]", 4096);
7983
maxEntityRenderDistanceY = b.define("(Entity) Max Vertical Render Distance [Raw, Default 32]", 32);
84+
entityWhitelist = b
85+
.comment("List of entities to not cull based on distance.")
86+
.comment("Example: \"minecraft:bat\"")
87+
.defineListAllowEmpty(Collections.singletonList("Entity Whitelist"), Collections::emptyList, (s) -> ResourceLocation.tryParse((String) s) != null);
8088
});
8189

8290
builder.block("True Darkness", b -> {

src/main/java/me/srrapero720/embeddium_extras/mixins/EntityDistance/MaxDistanceEntity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.minecraft.client.renderer.culling.Frustum;
44
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
5+
import net.minecraft.resources.ResourceLocation;
56
import net.minecraft.world.entity.Entity;
67
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
78
import net.minecraft.world.entity.monster.Ghast;
@@ -25,7 +26,7 @@ public <E extends Entity> void shouldDoRender(E entity, Frustum clippingHelper,
2526
if (name.startsWith("com.simibubi.create.content.contraptions")) return;
2627
if (name.startsWith("com.github.alexthe666.iceandfire.entity") && name.contains("dragon")) return;
2728

28-
if (!DistanceUtility.isEntityWithinDistance(
29+
if (!entityWhitelisted(entity.getType().getDefaultLootTable()) && !DistanceUtility.isEntityWithinDistance(
2930
entity,
3031
cameraX,
3132
cameraY,
@@ -36,4 +37,8 @@ public <E extends Entity> void shouldDoRender(E entity, Frustum clippingHelper,
3637
cir.cancel();
3738
}
3839
}
40+
41+
private boolean entityWhitelisted(ResourceLocation s) {
42+
return s != null && EmbeddiumExtrasConfig.entityWhitelist.get().stream().anyMatch(s.toString()::equals);
43+
}
3944
}

0 commit comments

Comments
 (0)