Add debug stacktrace control

This commit is contained in:
Kam committed 2025-07-23 17:24:07 -04:00
1 parent 34dfa2ec59
commit dcabe6a74f
16 files changed
+168 -47

No files matched your search

Vendored Regular → Executable
View File
File mode changed.
@@ -10,6 +10,7 @@ import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.client.resources.SimpleReloadableResourceManager;
import net.minecraft.util.ResourceLocation;
import software.bernie.example.config.ConfigHandler;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -72,7 +73,9 @@ public class ReflectionUtils {
break;
}
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
}
}
@@ -93,7 +96,9 @@ public class ReflectionUtils {
return false;
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
return false;
@@ -1,6 +1,7 @@
package com.eliotlash.mclib.utils.resources;
import net.minecraft.util.ResourceLocation;
import software.bernie.example.config.ConfigHandler;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -40,7 +41,9 @@ public class TextureLocation extends ResourceLocation {
try {
this.unlockField(field);
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
}
@@ -48,7 +51,9 @@ public class TextureLocation extends ResourceLocation {
fields[0].set(this, domain);
fields[1].set(this, path);
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
}
@@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.IResourceManager;
import software.bernie.example.config.ConfigHandler;
import javax.imageio.ImageIO;
import java.awt.*;
@@ -42,7 +43,9 @@ public class TextureProcessor {
w = Math.max(w, child.getWidth(image.getWidth()));
h = Math.max(h, child.getHeight(image.getHeight()));
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
images.add(image);
@@ -18,6 +18,7 @@ import com.eliotlash.molang.functions.AsinDegrees;
import com.eliotlash.molang.functions.Atan2Degrees;
import com.eliotlash.molang.functions.AtanDegrees;
import com.eliotlash.molang.functions.CosDegrees;
import software.bernie.example.config.ConfigHandler;
import com.eliotlash.molang.functions.SinDegrees;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
@@ -232,8 +233,9 @@ public class MolangParser extends MathBuilder implements Serializable {
try {
return this.parseSymbols(symbols);
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
throw new MolangException("Couldn't parse an expression!");
}
}
@@ -7,6 +7,7 @@ import java.io.File;
public class ConfigHandler {
public static Configuration config;
public static boolean enableExamples;
public static boolean debugPrintStacktraces;
public ConfigHandler() {
}
@@ -23,6 +24,7 @@ public class ConfigHandler {
public static void syncConfig() {
config.addCustomCategoryComment("general", "General Settings");
enableExamples = config.getBoolean("enableexamples", "general", false, "Enable Geckolib Examples");
debugPrintStacktraces = config.getBoolean("debugStacktraces", "general", false, "Print stacktraces for debugging");
config.save();
}
}
@@ -5,6 +5,7 @@ import net.minecraft.util.ResourceLocation;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import software.bernie.geckolib3.watchers.ParticleDirWatcher;
import software.bernie.example.config.ConfigHandler;
import java.io.File;
import java.nio.charset.StandardCharsets;
@@ -99,7 +100,9 @@ public class BedrockLibrary {
}
return BedrockScheme.parse(contents);
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
return null;
@@ -121,7 +124,9 @@ public class BedrockLibrary {
try {
return BedrockScheme.parse(IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("assets/" + resLoc.getResourceDomain() + "/" + resLoc.getResourcePath()), StandardCharsets.UTF_8)).factory(true);
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
return null;
@@ -18,6 +18,7 @@ import software.bernie.geckolib3.particles.components.BedrockComponentBase;
import software.bernie.geckolib3.particles.components.GuiModelRenderer;
import software.bernie.geckolib3.particles.components.IComponentParticleInitialize;
import software.bernie.geckolib3.particles.components.IComponentParticleMorphRender;
import software.bernie.example.config.ConfigHandler;
import software.bernie.geckolib3.particles.emitter.BedrockEmitter;
import software.bernie.geckolib3.particles.emitter.BedrockParticle;
@@ -106,7 +107,8 @@ public class BedrockComponentParticleMorph extends BedrockComponentBase implemen
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightnessX, brightnessY);
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
try {
GlStateManager.translate(x, y, z);
if (particle.relativeScaleBillboard) {
GlStateManager.scale(emitter.scale[0], emitter.scale[1], emitter.scale[2]);
@@ -114,8 +116,14 @@ public class BedrockComponentParticleMorph extends BedrockComponentBase implemen
//MorphUtils.render(this.morph.get(), dummy, 0, 0, 0, 0, partialTicks);
RenderHelper.disableStandardItemLighting();
GlStateManager.popMatrix();
RenderHelper.disableStandardItemLighting();
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
}
protected Vector3d calculatePosition(BedrockEmitter emitter, BedrockParticle particle, double px, double py, double pz) {
@@ -18,6 +18,7 @@ import software.bernie.geckolib3.core.util.Color;
import software.bernie.geckolib3.geo.render.built.GeoModel;
import software.bernie.geckolib3.model.AnimatedGeoModel;
import software.bernie.geckolib3.util.GeoUtils;
import software.bernie.example.config.ConfigHandler;
import java.util.Arrays;
import java.util.Map;
@@ -87,7 +88,8 @@ public abstract class GeoArmorRenderer<T extends ItemArmor & IAnimatable> extend
modelProvider.setLivingAnimations(currentArmorItem, this.getUniqueID(this.currentArmorItem), itemEvent);
this.fitToBiped();
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0.01f, 0);
try {
GlStateManager.translate(0, 0.01f, 0);
IBone rightArmBone = this.modelProvider.getBone(this.rightArmBone);
IBone leftArmBone = this.modelProvider.getBone(this.leftArmBone);
if (entityLiving.swingProgress > 0.0F) {
@@ -129,7 +131,13 @@ public abstract class GeoArmorRenderer<T extends ItemArmor & IAnimatable> extend
render(model, currentArmorItem, partialTicks, (float) renderColor.getRed() / 255f,
(float) renderColor.getGreen() / 255f, (float) renderColor.getBlue() / 255f,
(float) renderColor.getAlpha() / 255);
GlStateManager.popMatrix();
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
GlStateManager.scale(-1.0F, -1.0F, 1.0F);
GlStateManager.translate(0.0D, -1.501F, 0.0D);
}
@@ -15,6 +15,7 @@ import software.bernie.geckolib3.core.controller.AnimationController;
import software.bernie.geckolib3.core.util.Color;
import software.bernie.geckolib3.geo.render.built.GeoModel;
import software.bernie.geckolib3.model.AnimatedGeoModel;
import software.bernie.example.config.ConfigHandler;
@SuppressWarnings({"unchecked"})
public abstract class GeoBlockRenderer<T extends TileEntity & IAnimatable> extends TileEntitySpecialRenderer
@@ -57,9 +58,10 @@ public abstract class GeoBlockRenderer<T extends TileEntity & IAnimatable> exten
}
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GlStateManager.translate(0, 0.01f, 0);
GlStateManager.translate(0.5, 0, 0.5);
try {
GlStateManager.translate(x, y, z);
GlStateManager.translate(0, 0.01f, 0);
GlStateManager.translate(0.5, 0, 0.5);
rotateBlock(getFacing(tile));
@@ -67,7 +69,13 @@ public abstract class GeoBlockRenderer<T extends TileEntity & IAnimatable> exten
Color renderColor = getRenderColor((T) tile, partialTicks);
render(model, (T) tile, partialTicks, (float) renderColor.getRed() / 255f, (float) renderColor.getGreen() / 255f,
(float) renderColor.getBlue() / 255f, (float) renderColor.getAlpha() / 255);
GlStateManager.popMatrix();
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
}
@Override
@@ -18,6 +18,7 @@ import net.minecraft.util.ResourceLocation;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.example.config.ConfigHandler;
import software.bernie.geckolib3.core.IAnimatableModel;
import software.bernie.geckolib3.core.controller.AnimationController;
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
@@ -58,7 +59,8 @@ public abstract class GeoEntityRenderer<T extends EntityLivingBase & IAnimatable
if (!(entityObj instanceof EntityLivingBase)) return;
EntityLivingBase entity = (EntityLivingBase) entityObj;
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
try {
GlStateManager.translate(x, y, z);
// TODO: entity.isPassenger() looks redundant here
boolean shouldSit = /* entity.isPassenger() && */ (entity.ridingEntity != null
&& entity.ridingEntity.shouldRiderSit());
@@ -104,7 +106,8 @@ public abstract class GeoEntityRenderer<T extends EntityLivingBase & IAnimatable
}
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0.01f, 0);
try {
GlStateManager.translate(0, 0.01f, 0);
Minecraft.getMinecraft().renderEngine.bindTexture(getEntityTexture(entity));
Color renderColor = getRenderColor((T) entity, partialTicks);
@@ -132,8 +135,20 @@ public abstract class GeoEntityRenderer<T extends EntityLivingBase & IAnimatable
RenderHurtColor.unset();
}
GlStateManager.popMatrix();
GlStateManager.popMatrix();
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
}
public Pair<Float, Float> calculateRotations(EntityLivingBase entity, float partialTicks, boolean shouldSit) {
@@ -17,6 +17,7 @@ import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.util.Color;
import software.bernie.geckolib3.geo.render.built.GeoModel;
import software.bernie.geckolib3.model.AnimatedGeoModel;
import software.bernie.example.config.ConfigHandler;
import javax.vecmath.Matrix4d;
import javax.vecmath.Matrix4f;
@@ -59,24 +60,31 @@ public abstract class GeoItemRenderer<T extends Item & IAnimatable> implements I
@Override
public void renderItem(ItemRenderType var1, ItemStack itemStack, Object... var3) {
GL11.glPushMatrix();
try {
if (var1 == ItemRenderType.INVENTORY) {
GL11.glTranslated(-1, -1, 0);
GL11.glRotatef(90, 0, 1, 0);
if (var1 == ItemRenderType.INVENTORY) {
GL11.glTranslated(-1, -1, 0);
GL11.glRotatef(90, 0, 1, 0);
}
if (var1 != ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslated(0, -0.5, 0);
}
if (var1 == ItemRenderType.ENTITY) {
}
if (var1 != ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslated(0, -0.5, 0);
}
if (var1 == ItemRenderType.ENTITY) {
// Matrix4f matrix4f;
// PositionUtils.setInitialWorldPos();
// GL11.glTranslated(2,4.5,-4);
// Vector3d vec = PositionUtils.getCurrentRenderPos();
// double out=0;
}
this.render((T) itemStack.getItem(), itemStack);
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GL11.glPopMatrix();
}
this.render((T) itemStack.getItem(), itemStack);
GL11.glPopMatrix();
}
public Vector3d getCurrentRenderPos() {
@@ -135,15 +143,22 @@ public abstract class GeoItemRenderer<T extends Item & IAnimatable> implements I
Minecraft.getMinecraft().timer.renderPartialTicks, false, Collections.singletonList(itemStack));
modelProvider.setLivingAnimations(animatable, this.getUniqueID(animatable), itemEvent);
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0.01f, 0);
GlStateManager.translate(0.5, 0.5, 0.5);
try {
GlStateManager.translate(0, 0.01f, 0);
GlStateManager.translate(0.5, 0.5, 0.5);
Minecraft.getMinecraft().renderEngine.bindTexture(getTextureLocation(animatable));
Color renderColor = getRenderColor(animatable, 0f);
GL11.glRotatef(90, 0, 1, 0);
render(model, animatable, 0, (float) renderColor.getRed() / 255f, (float) renderColor.getGreen() / 255f,
(float) renderColor.getBlue() / 255f, (float) renderColor.getAlpha() / 255);
GlStateManager.popMatrix();
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
}
@Override
@@ -16,6 +16,7 @@ import software.bernie.geckolib3.model.AnimatedGeoModel;
import software.bernie.geckolib3.model.provider.GeoModelProvider;
import software.bernie.geckolib3.model.provider.data.EntityModelData;
import software.bernie.geckolib3.util.AnimationUtils;
import software.bernie.example.config.ConfigHandler;
import java.util.Collections;
@@ -41,6 +42,7 @@ public class GeoProjectilesRenderer<T extends Entity & IAnimatable> extends Rend
@Override
public void doRender(Entity entity, double x, double y, double z, float entityYaw, float partialTicks) {
GlStateManager.pushMatrix();
try {
GeoModel model = modelProvider.getModel(modelProvider.getModelLocation((T) entity));
GlStateManager.rotate(
entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks - 90.0F, 0.0F,
@@ -58,6 +60,7 @@ public class GeoProjectilesRenderer<T extends Entity & IAnimatable> extends Rend
((IAnimatableModel<T>) modelProvider).setLivingAnimations((T) entity, this.getUniqueID(entity), predicate);
}
GlStateManager.pushMatrix();
try {
Minecraft.getMinecraft().renderEngine.bindTexture(getTextureLocation(entity));
Color renderColor = getRenderColor((T) entity, partialTicks);
@@ -65,8 +68,20 @@ public class GeoProjectilesRenderer<T extends Entity & IAnimatable> extends Rend
render(model, (T) entity, partialTicks, (float) renderColor.getRed() / 255f,
(float) renderColor.getGreen() / 255f, (float) renderColor.getBlue() / 255f,
(float) renderColor.getAlpha() / 255);
GlStateManager.popMatrix();
GlStateManager.popMatrix();
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
}
@Override
@@ -18,6 +18,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.IAnimatableModel;
import software.bernie.example.config.ConfigHandler;
import software.bernie.geckolib3.core.controller.AnimationController;
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.util.Color;
@@ -69,7 +70,8 @@ public abstract class GeoReplacedEntityRenderer<T extends IAnimatable> extends R
if (!(entityObj instanceof EntityLivingBase)) return;
EntityLivingBase entity = (EntityLivingBase) entityObj;
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
try {
GlStateManager.translate(x, y, z);
// TODO: entity.isPassenger() looks redundant here
boolean shouldSit = /* entity.isPassenger() && */ (entity.ridingEntity != null
@@ -138,7 +140,8 @@ public abstract class GeoReplacedEntityRenderer<T extends IAnimatable> extends R
}
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0.01f, 0);
try {
GlStateManager.translate(0, 0.01f, 0);
Minecraft.getMinecraft().renderEngine.bindTexture(getEntityTexture(entity));
Color renderColor = getRenderColor(entity, partialTicks);
@@ -159,8 +162,20 @@ public abstract class GeoReplacedEntityRenderer<T extends IAnimatable> extends R
this.renderLeash((EntityLiving) entity, x, y, z, entityYaw, partialTicks);
}
}
GlStateManager.popMatrix();
GlStateManager.popMatrix();
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
// super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
@@ -18,6 +18,7 @@ import software.bernie.geckolib3.geo.render.built.GeoVertex;
import software.bernie.geckolib3.model.provider.GeoModelProvider;
import software.bernie.geckolib3.particles.emitter.BedrockEmitter;
import software.bernie.geckolib3.util.MatrixStack;
import software.bernie.example.config.ConfigHandler;
import software.bernie.geckolib3.util.PositionUtils;
import javax.vecmath.Matrix3f;
@@ -88,9 +89,16 @@ public interface IGeoRenderer<T> {
for (GeoCube cube : bone.childCubes) {
MATRIX_STACK.push();
GlStateManager.pushMatrix();
renderCube(builder, cube, red, green, blue, alpha);
GlStateManager.popMatrix();
MATRIX_STACK.pop();
try {
renderCube(builder, cube, red, green, blue, alpha);
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
MATRIX_STACK.pop();
}
}
}
if (!bone.childBonesAreHiddenToo()) {
@@ -17,6 +17,7 @@ import software.bernie.geckolib3.file.GeoModelLoader;
import software.bernie.geckolib3.geo.render.built.GeoModel;
import software.bernie.geckolib3.molang.MolangRegistrar;
import software.bernie.geckolib3.particles.BedrockLibrary;
import software.bernie.example.config.ConfigHandler;
import java.io.File;
import java.lang.reflect.Field;
@@ -80,7 +81,9 @@ public class GeckoLibCache implements IResourceManagerReloadListener {
try {
tempAnimations.put(location, AnimationFileLoader.getInstance().loadAllAnimations(MolangRegistrar.getParser(), location, resourceManager));
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
System.err.println("[GeckoLib] " + "Error loading animation file \"" + location + "\"!" + e);
}
}
@@ -89,7 +92,9 @@ public class GeckoLibCache implements IResourceManagerReloadListener {
try {
tempModels.put(location, GeoModelLoader.getInstance().loadModel(resourceManager, location));
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
System.err.println("[GeckoLib] " + "Error loading model file \"" + location + "\"!" + e);
}
}
@@ -98,7 +103,9 @@ public class GeckoLibCache implements IResourceManagerReloadListener {
try {
BedrockLibrary.instance.storeFactory(location);
} catch (Exception e) {
e.printStackTrace();
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
System.err.println("[GeckoLib] " + "Error loading model file \"" + location + "\"!" + e);
}
}