Add config options for portal rendering

This commit is contained in:
Sollace 2024-01-27 04:21:31 +00:00
parent 80500a74c8
commit e385eb5640
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 16 additions and 5 deletions

View file

@ -45,6 +45,16 @@ public class Config extends com.minelittlepony.common.util.settings.Config {
.addComment("Removes butterflies from spawning in your world") .addComment("Removes butterflies from spawning in your world")
.addComment("Turn this ON if you have another mod that adds butterflies."); .addComment("Turn this ON if you have another mod that adds butterflies.");
public final Setting<Boolean> simplifiedPortals = value("compatibility", "simplifiedPortals", false)
.addComment("Disables dynamic portal rendering");
public final Setting<Long> fancyPortalRefreshRate = value("client", "fancyPortalRefreshRate", -1L)
.addComment("Sets the refresh rate of portals when using fancy portal rendering")
.addComment("Set to -1 (default) for unlimited");
public final Setting<Integer> maxPortalRecursion = value("client", "maxPortalRecursion", 2)
.addComment("Sets the maximum depth to reach when rendering portals through portals");
public Config() { public Config() {
super(new HeirarchicalJsonConfigAdapter(new GsonBuilder() super(new HeirarchicalJsonConfigAdapter(new GsonBuilder()
.registerTypeAdapter(Race.class, RegistryTypeAdapter.of(Race.REGISTRY)) .registerTypeAdapter(Race.class, RegistryTypeAdapter.of(Race.REGISTRY))

View file

@ -11,6 +11,7 @@ import org.joml.Matrix4f;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.spell.effect.PortalSpell; import com.minelittlepony.unicopia.ability.magic.spell.effect.PortalSpell;
import com.minelittlepony.unicopia.client.render.RenderLayers; import com.minelittlepony.unicopia.client.render.RenderLayers;
@ -115,11 +116,12 @@ class PortalFrameBuffer implements AutoCloseable {
public void build(PortalSpell spell, Caster<?> caster, EntityReference.EntityValues<Entity> target) { public void build(PortalSpell spell, Caster<?> caster, EntityReference.EntityValues<Entity> target) {
if (framebuffer != null && System.currentTimeMillis() % 1 != 0) { long refreshRate = Unicopia.getConfig().fancyPortalRefreshRate.get();
if (refreshRate > 0 && framebuffer != null && System.currentTimeMillis() % refreshRate != 0) {
return; return;
} }
if (pendingDraw && recursionCount > 2) { if (pendingDraw && recursionCount > Math.max(0, Unicopia.getConfig().maxPortalRecursion.get())) {
innerBuild(spell, caster, target); innerBuild(spell, caster, target);
return; return;
} }

View file

@ -1,5 +1,6 @@
package com.minelittlepony.unicopia.client.render.spell; package com.minelittlepony.unicopia.client.render.spell;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.spell.effect.PortalSpell; import com.minelittlepony.unicopia.ability.magic.spell.effect.PortalSpell;
import com.minelittlepony.unicopia.client.render.RenderLayers; import com.minelittlepony.unicopia.client.render.RenderLayers;
@ -14,8 +15,6 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.RotationAxis; import net.minecraft.util.math.RotationAxis;
public class PortalSpellRenderer extends SpellRenderer<PortalSpell> { public class PortalSpellRenderer extends SpellRenderer<PortalSpell> {
static boolean FANCY_PORTAlS = true;
@Override @Override
public boolean shouldRenderEffectPass(int pass) { public boolean shouldRenderEffectPass(int pass) {
return pass == 0; return pass == 0;
@ -32,7 +31,7 @@ public class PortalSpellRenderer extends SpellRenderer<PortalSpell> {
SphereModel.DISK.render(matrices, buff, light, 0, 2F * strength, 1, 1, 1, 1); SphereModel.DISK.render(matrices, buff, light, 0, 2F * strength, 1, 1, 1, 1);
matrices.pop(); matrices.pop();
if (!FANCY_PORTAlS || !spell.isLinked()) { if (Unicopia.getConfig().simplifiedPortals.get() || !spell.isLinked()) {
matrices.push(); matrices.push();
matrices.translate(0, -0.02, 0); matrices.translate(0, -0.02, 0);
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180)); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180));