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
+122 -1

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,10 +73,12 @@ public class ReflectionUtils {
break;
}
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
}
}
@SideOnly(Side.CLIENT)
public static boolean registerResourcePack(IResourcePack pack) {
@@ -93,8 +96,10 @@ public class ReflectionUtils {
return false;
} catch (Exception e) {
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,17 +41,21 @@ public class TextureLocation extends ResourceLocation {
try {
this.unlockField(field);
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
}
try {
fields[0].set(this, domain);
fields[1].set(this, path);
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
}
protected void unlockField(Field field) throws Exception {
field.setAccessible(true);
@@ -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,8 +43,10 @@ public class TextureProcessor {
w = Math.max(w, child.getWidth(image.getWidth()));
h = Math.max(h, child.getHeight(image.getHeight()));
} catch (Exception e) {
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) {
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,8 +100,10 @@ public class BedrockLibrary {
}
return BedrockScheme.parse(contents);
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
}
return null;
}
@@ -121,8 +124,10 @@ 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) {
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,6 +107,7 @@ public class BedrockComponentParticleMorph extends BedrockComponentBase implemen
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightnessX, brightnessY);
GlStateManager.pushMatrix();
try {
GlStateManager.translate(x, y, z);
if (particle.relativeScaleBillboard) {
@@ -115,8 +117,14 @@ public class BedrockComponentParticleMorph extends BedrockComponentBase implemen
//MorphUtils.render(this.morph.get(), dummy, 0, 0, 0, 0, partialTicks);
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) {
if (particle.relativePosition && particle.relativeRotation) {
@@ -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,6 +88,7 @@ public abstract class GeoArmorRenderer<T extends ItemArmor & IAnimatable> extend
modelProvider.setLivingAnimations(currentArmorItem, this.getUniqueID(this.currentArmorItem), itemEvent);
this.fitToBiped();
GlStateManager.pushMatrix();
try {
GlStateManager.translate(0, 0.01f, 0);
IBone rightArmBone = this.modelProvider.getBone(this.rightArmBone);
IBone leftArmBone = this.modelProvider.getBone(this.leftArmBone);
@@ -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);
} 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,6 +58,7 @@ public abstract class GeoBlockRenderer<T extends TileEntity & IAnimatable> exten
}
GlStateManager.pushMatrix();
try {
GlStateManager.translate(x, y, z);
GlStateManager.translate(0, 0.01f, 0);
GlStateManager.translate(0.5, 0, 0.5);
@@ -67,8 +69,14 @@ 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);
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
}
@Override
public AnimatedGeoModel<T> getGeoModelProvider() {
@@ -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,6 +59,7 @@ public abstract class GeoEntityRenderer<T extends EntityLivingBase & IAnimatable
if (!(entityObj instanceof EntityLivingBase)) return;
EntityLivingBase entity = (EntityLivingBase) entityObj;
GlStateManager.pushMatrix();
try {
GlStateManager.translate(x, y, z);
// TODO: entity.isPassenger() looks redundant here
boolean shouldSit = /* entity.isPassenger() && */ (entity.ridingEntity != null
@@ -104,6 +106,7 @@ public abstract class GeoEntityRenderer<T extends EntityLivingBase & IAnimatable
}
GlStateManager.pushMatrix();
try {
GlStateManager.translate(0, 0.01f, 0);
Minecraft.getMinecraft().renderEngine.bindTexture(getEntityTexture(entity));
Color renderColor = getRenderColor((T) entity, partialTicks);
@@ -132,9 +135,21 @@ public abstract class GeoEntityRenderer<T extends EntityLivingBase & IAnimatable
RenderHurtColor.unset();
}
} 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) {
float f = Interpolations.lerpYaw(entity.prevRenderYawOffset, entity.renderYawOffset, partialTicks);
@@ -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,6 +60,7 @@ 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);
@@ -76,8 +78,14 @@ public abstract class GeoItemRenderer<T extends Item & IAnimatable> implements I
// double out=0;
}
this.render((T) itemStack.getItem(), itemStack);
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GL11.glPopMatrix();
}
}
public Vector3d getCurrentRenderPos() {
Entity camera = Minecraft.getMinecraft().renderViewEntity;
@@ -135,6 +143,7 @@ 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();
try {
GlStateManager.translate(0, 0.01f, 0);
GlStateManager.translate(0.5, 0.5, 0.5);
@@ -143,8 +152,14 @@ public abstract class GeoItemRenderer<T extends Item & IAnimatable> implements I
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);
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
}
@Override
public ResourceLocation getTextureLocation(T instance) {
@@ -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,9 +68,21 @@ 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);
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
} catch (Exception e) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
} finally {
GlStateManager.popMatrix();
}
}
@Override
public GeoModelProvider<T> getGeoModelProvider() {
@@ -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,6 +70,7 @@ public abstract class GeoReplacedEntityRenderer<T extends IAnimatable> extends R
if (!(entityObj instanceof EntityLivingBase)) return;
EntityLivingBase entity = (EntityLivingBase) entityObj;
GlStateManager.pushMatrix();
try {
GlStateManager.translate(x, y, z);
// TODO: entity.isPassenger() looks redundant here
@@ -138,6 +140,7 @@ public abstract class GeoReplacedEntityRenderer<T extends IAnimatable> extends R
}
GlStateManager.pushMatrix();
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);
}
}
} 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,11 +89,18 @@ public interface IGeoRenderer<T> {
for (GeoCube cube : bone.childCubes) {
MATRIX_STACK.push();
GlStateManager.pushMatrix();
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()) {
for (GeoBone childBone : bone.childBones) {
renderRecursively(builder, animatable, childBone, red, green, blue, alpha);
@@ -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) {
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) {
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) {
if (ConfigHandler.debugPrintStacktraces) {
e.printStackTrace();
}
System.err.println("[GeckoLib] " + "Error loading model file \"" + location + "\"!" + e);
}
}