Merge pull request #213 from X-Green/master

More infomation in TNT logging
This commit is contained in:
gnembon authored and GitHub committed 2020-04-14 09:31:55 -03:00
commit 3c25110b50
2 files changed
+13 -2

No files matched your search

@@ -9,6 +9,8 @@ public class TNTLogHelper
{ {
public boolean initialized; public boolean initialized;
private double primedX, primedY, primedZ; private double primedX, primedY, primedZ;
private static long lastGametime = 0;
private static int tntCount = 0;
private Vec3d primedAngle; private Vec3d primedAngle;
/** /**
* Runs when the TNT is primed. Expects the position and motion angle of the TNT. * Runs when the TNT is primed. Expects the position and motion angle of the TNT.
@@ -24,8 +26,13 @@ public class TNTLogHelper
/** /**
* Runs when the TNT explodes. Expects the position of the TNT. * Runs when the TNT explodes. Expects the position of the TNT.
*/ */
public void onExploded(double x, double y, double z) public void onExploded(double x, double y, double z, long gametime)
{ {
if (!(lastGametime == gametime)){
tntCount = 0;
lastGametime = gametime;
}
tntCount++;
LoggerRegistry.getLogger("tnt").log( (option) -> { LoggerRegistry.getLogger("tnt").log( (option) -> {
switch (option) switch (option)
{ {
@@ -36,6 +43,10 @@ public class TNTLogHelper
"r E ",Messenger.dblt("r",x, y, z))}; "r E ",Messenger.dblt("r",x, y, z))};
case "full": case "full":
return new BaseText[]{Messenger.c( return new BaseText[]{Messenger.c(
"g #" + String.valueOf(tntCount),
"m @" + String.valueOf(gametime),
"g : ",
"g #" + String.valueOf(tntCount) + ": ",
"l P ",Messenger.dblf("l",primedX,primedY,primedZ), "l P ",Messenger.dblf("l",primedX,primedY,primedZ),
"w ",Messenger.dblf("l", primedAngle.x, primedAngle.y, primedAngle.z), "w ",Messenger.dblf("l", primedAngle.x, primedAngle.y, primedAngle.z),
"r E ",Messenger.dblf("r",x, y, z))}; "r E ",Messenger.dblf("r",x, y, z))};
@@ -72,7 +72,7 @@ public abstract class TntEntityMixin extends Entity implements TntEntityInterfac
private void onExplode(CallbackInfo ci) private void onExplode(CallbackInfo ci)
{ {
if (LoggerRegistry.__tnt && logHelper != null) if (LoggerRegistry.__tnt && logHelper != null)
logHelper.onExploded(getX(), getY(), getZ()); logHelper.onExploded(getX(), getY(), getZ(), this.world.getTime());
if (mergedTNT > 1) if (mergedTNT > 1)
for (int i = 0; i < mergedTNT - 1; i++) for (int i = 0; i < mergedTNT - 1; i++)