Skip to content

Commit

Permalink
add client config to disable glue rendering
Browse files Browse the repository at this point in the history
closes #44
  • Loading branch information
MelanX committed Aug 4, 2023
1 parent d641980 commit faaaf35
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/main/java/de/melanx/utilitix/UtilitiX.java
@@ -1,7 +1,6 @@
package de.melanx.utilitix;

import de.melanx.utilitix.client.ClientUtilitiX;
import de.melanx.utilitix.config.ArmorStandRotationMapper;
import de.melanx.utilitix.content.BetterMending;
import de.melanx.utilitix.content.shulkerboat.ShulkerBoatRenderer;
import de.melanx.utilitix.content.slime.SlimyCapability;
Expand All @@ -13,7 +12,6 @@
import de.melanx.utilitix.registration.ModEntities;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.raid.Raid;
import net.minecraft.world.level.chunk.LevelChunk;
Expand All @@ -24,7 +22,6 @@
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.moddingx.libx.config.ConfigManager;
import org.moddingx.libx.datagen.DatagenSystem;
import org.moddingx.libx.mod.ModXRegistration;
import org.moddingx.libx.registration.RegistrationBuilder;
Expand All @@ -44,9 +41,6 @@ public UtilitiX() {
instance = this;
network = new UtiliNetwork(this);

ConfigManager.registerValueMapper("utilitix", new ArmorStandRotationMapper());
ConfigManager.registerConfig(new ResourceLocation(this.modid, "common"), UtilitiXConfig.class, false);

DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> ClientUtilitiX::new);

FMLJavaModLoadingContext.get().getModEventBus().addListener(SlimyCapability::registerCapability);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/de/melanx/utilitix/UtilitiXConfig.java
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.ImmutableList;
import de.melanx.utilitix.util.ArmorStandRotation;
import org.moddingx.libx.annotation.config.RegisterConfig;
import org.moddingx.libx.config.Config;
import org.moddingx.libx.config.Group;
import org.moddingx.libx.config.validate.FloatRange;
Expand All @@ -10,6 +11,7 @@

import java.util.List;

@RegisterConfig(value = "common")
public class UtilitiXConfig {

@Group("Config values for the two bells, mob bell and hand bell")
Expand Down
Expand Up @@ -3,10 +3,12 @@
import com.google.gson.JsonObject;
import de.melanx.utilitix.util.ArmorStandRotation;
import net.minecraft.network.FriendlyByteBuf;
import org.moddingx.libx.annotation.config.RegisterMapper;
import org.moddingx.libx.config.gui.ConfigEditor;
import org.moddingx.libx.config.mapper.ValueMapper;
import org.moddingx.libx.config.validator.ValidatorInfo;

@RegisterMapper
public class ArmorStandRotationMapper implements ValueMapper<ArmorStandRotation, JsonObject> {

@Override
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/de/melanx/utilitix/config/ClientConfig.java
@@ -0,0 +1,13 @@
package de.melanx.utilitix.config;

import org.moddingx.libx.annotation.config.RegisterConfig;
import org.moddingx.libx.config.Config;

@RegisterConfig(client = true, value = "client")
public class ClientConfig {

@Config({"On some slower PCs, or in big modpacks, it seems like rendering glue drains a lot of performance.",
"You can disable it here to see if it improves your performance.",
"This will deactivate the glue rendering in the world, so you won't see any glue on any block."})
public static boolean renderGlueOnBlocks = true;
}
Expand Up @@ -2,6 +2,7 @@

import com.mojang.blaze3d.vertex.PoseStack;
import de.melanx.utilitix.Textures;
import de.melanx.utilitix.config.ClientConfig;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
Expand All @@ -23,6 +24,7 @@
public class SlimeRender {

public static void renderWorld(RenderLevelStageEvent event) {
if (!ClientConfig.renderGlueOnBlocks) return;
ClientLevel level = Minecraft.getInstance().level;
if (level != null && event.getStage() == RenderLevelStageEvent.Stage.AFTER_SOLID_BLOCKS) {
Minecraft.getInstance().getProfiler().push("utilitix_glue");
Expand Down

0 comments on commit faaaf35

Please sign in to comment.