Added a gravity logging option for the fall damage handler

This commit is contained in:
Unknown 2019-09-22 18:12:12 +02:00 committed by unknown
parent 98837d28a3
commit c14f2ebfc6
2 changed files with 9 additions and 4 deletions

View file

@ -250,6 +250,7 @@ public class WarpDriveConfig {
public static boolean LOGGING_CHUNK_LOADING = true;
public static boolean LOGGING_ENTITY_FX = false;
public static boolean LOGGING_CLIENT_SYNCHRONIZATION = false;
public static boolean LOGGING_GRAVITY = false;
// Energy
public static String ENERGY_DISPLAY_UNITS = "RF";
@ -906,6 +907,7 @@ public class WarpDriveConfig {
LOGGING_CHUNK_HANDLER = config.get("logging", "enable_chunk_handler_logs", LOGGING_CHUNK_HANDLER, "Detailed chunk data logs to help debug the mod.").getBoolean(false);
LOGGING_CHUNK_LOADING = config.get("logging", "enable_chunk_loading_logs", LOGGING_CHUNK_LOADING, "Chunk loading logs, enable it to report chunk loaders updates").getBoolean(false);
LOGGING_ENTITY_FX = config.get("logging", "enable_entity_fx_logs", LOGGING_ENTITY_FX, "EntityFX logs, enable it to dump entityFX registry updates").getBoolean(false);
LOGGING_GRAVITY = config.get("logging", "enable_gravity_logs", LOGGING_GRAVITY, "Gravity logs, enable it before reporting fall damage and related issues").getBoolean(false);
// Energy handling
ENERGY_DISPLAY_UNITS = config.get("energy", "display_units", ENERGY_DISPLAY_UNITS, "display units for energy (EU, RF, FE, \u0230I)").getString();

View file

@ -291,7 +291,8 @@ public class LivingHandler {
}
if (motionY > -0.65170D) {
event.setCanceled(true); // Don't damage entity
if (WarpDrive.isDev && entityLivingBase instanceof EntityPlayerMP) {
if ( WarpDriveConfig.LOGGING_GRAVITY
&& entityLivingBase instanceof EntityPlayerMP ) {
WarpDrive.logger.warn(String.format("(low speed ) Entity fall damage at motionY %.3f from distance %.3f of %s, isCancelled %s",
motionY, event.getDistance(), entityLivingBase, event.isCanceled()));
}
@ -305,14 +306,15 @@ public class LivingHandler {
// ignore small jumps
if (check <= 0) {
event.setCanceled(true); // Don't damage entity
if (WarpDrive.isDev && entityLivingBase instanceof EntityPlayerMP) {
if ( WarpDriveConfig.LOGGING_GRAVITY
&& entityLivingBase instanceof EntityPlayerMP ) {
WarpDrive.logger.warn(String.format("(short distance) Entity fall damage at motionY %.3f from distance %.3f of %s, isCancelled %s",
motionY, event.getDistance(), entityLivingBase, event.isCanceled()));
}
return;
}
if (WarpDrive.isDev) {
if (WarpDriveConfig.LOGGING_GRAVITY) {
WarpDrive.logger.warn(String.format("Entity fall damage at motionY %.3f from distance %.3f of %s, isCancelled %s",
motionY, event.getDistance(), entityLivingBase, event.isCanceled()));
}
@ -335,7 +337,8 @@ public class LivingHandler {
// adjust distance to 'vanilla' scale and let it fall...
event.setDistance( (float) (-6.582D + 4.148D * Math.exp(1.200D * Math.abs(motionY))) );
if (WarpDrive.isDev && entityLivingBase instanceof EntityPlayerMP) {
if ( WarpDriveConfig.LOGGING_GRAVITY
&& entityLivingBase instanceof EntityPlayerMP ) {
WarpDrive.logger.warn(String.format("(full damage ) Entity fall damage at motionY %.3f from distance %.3f of %s, isCancelled %s",
motionY, event.getDistance(), entityLivingBase, event.isCanceled()));
}