megabroke
This commit is contained in:
1 parent
ec66779474
commit
a28f7be625
20 files changed
+2242
-3
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package carpet.logging;
|
||||
|
||||
import carpet.utils.HUDController;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
|
||||
public class HUDLogger extends Logger
|
||||
{
|
||||
public HUDLogger(String logName, String def, String[] options)
|
||||
{
|
||||
super(logName, def, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayer(String playerName)
|
||||
{
|
||||
PlayerEntity player = playerFromName(playerName);
|
||||
if (player != null) HUDController.clear_player(player);
|
||||
super.removePlayer(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPlayerMessage(PlayerEntity player, BaseComponent... messages)
|
||||
{
|
||||
for (BaseComponent m:messages) HUDController.addMessage(player, m);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
package carpet.logging;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Logger
|
||||
{
|
||||
// The set of subscribed and online players.
|
||||
private Map<String, String> subscribedOnlinePlayers;
|
||||
|
||||
// The set of subscribed and offline players.
|
||||
private Map<String,String> subscribedOfflinePlayers;
|
||||
|
||||
// The logName of this log. Gets prepended to logged messages.
|
||||
private String logName;
|
||||
|
||||
private String default_option;
|
||||
|
||||
private String[] options;
|
||||
|
||||
public Logger(String logName, String def, String [] options)
|
||||
{
|
||||
subscribedOnlinePlayers = new HashMap<>();
|
||||
subscribedOfflinePlayers = new HashMap<>();
|
||||
this.logName = logName;
|
||||
this.default_option = def;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public String getDefault()
|
||||
{
|
||||
return default_option;
|
||||
}
|
||||
public String [] getOptions()
|
||||
{
|
||||
if (options == null)
|
||||
{
|
||||
return new String[0];
|
||||
}
|
||||
return options;
|
||||
}
|
||||
public String getLogName()
|
||||
{
|
||||
return logName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes the player with the given logName to the logger.
|
||||
*/
|
||||
public void addPlayer(String playerName, String option)
|
||||
{
|
||||
if (playerFromName(playerName) != null)
|
||||
{
|
||||
subscribedOnlinePlayers.put(playerName, option);
|
||||
}
|
||||
else
|
||||
{
|
||||
subscribedOfflinePlayers.put(playerName, option);
|
||||
}
|
||||
LoggerRegistry.setAccess(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribes the player with the given logName from the logger.
|
||||
*/
|
||||
public void removePlayer(String playerName)
|
||||
{
|
||||
subscribedOnlinePlayers.remove(playerName);
|
||||
subscribedOfflinePlayers.remove(playerName);
|
||||
LoggerRegistry.setAccess(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there are any online subscribers for this log.
|
||||
*/
|
||||
public boolean hasOnlineSubscribers()
|
||||
{
|
||||
return subscribedOnlinePlayers.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* serves messages to players fetching them from the promise
|
||||
* will repeat invocation for players that share the same option
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface lMessage { BaseComponent [] get(String playerOption, PlayerEntity player);}
|
||||
public void log(lMessage messagePromise)
|
||||
{
|
||||
for (Map.Entry<String,String> en : subscribedOnlinePlayers.entrySet())
|
||||
{
|
||||
PlayerEntity player = playerFromName(en.getKey());
|
||||
if (player != null)
|
||||
{
|
||||
BaseComponent [] messages = messagePromise.get(en.getValue(),player);
|
||||
if (messages != null)
|
||||
sendPlayerMessage(player, messages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* guarantees that each message for each option will be evaluated once from the promise
|
||||
* and served the same way to all other players subscribed to the same option
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface lMessageIgnorePlayer { BaseComponent [] get(String playerOption);}
|
||||
public void log(lMessageIgnorePlayer messagePromise)
|
||||
{
|
||||
Map<String, BaseComponent[]> cannedMessages = new HashMap<>();
|
||||
for (Map.Entry<String,String> en : subscribedOnlinePlayers.entrySet())
|
||||
{
|
||||
PlayerEntity player = playerFromName(en.getKey());
|
||||
if (player != null)
|
||||
{
|
||||
String option = en.getValue();
|
||||
if (!cannedMessages.containsKey(option))
|
||||
{
|
||||
cannedMessages.put(option,messagePromise.get(option));
|
||||
}
|
||||
BaseComponent [] messages = cannedMessages.get(option);
|
||||
if (messages != null)
|
||||
sendPlayerMessage(player, messages);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* guarantees that message is evaluated once, so independent from the player and chosen option
|
||||
*/
|
||||
public void log(Supplier<BaseComponent[]> messagePromise)
|
||||
{
|
||||
BaseComponent [] cannedMessages = null;
|
||||
for (Map.Entry<String,String> en : subscribedOnlinePlayers.entrySet())
|
||||
{
|
||||
PlayerEntity player = playerFromName(en.getKey());
|
||||
if (player != null)
|
||||
{
|
||||
if (cannedMessages == null) cannedMessages = messagePromise.get();
|
||||
sendPlayerMessage(player, cannedMessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPlayerMessage(PlayerEntity player, BaseComponent ... messages)
|
||||
{
|
||||
Arrays.stream(messages).forEach(player::sendMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@code PlayerEntity} instance for a player given their UUID. Returns null if they are offline.
|
||||
*/
|
||||
protected PlayerEntity playerFromName(String name)
|
||||
{
|
||||
return CarpetServer.minecraft_server.getPlayerManager().getPlayer(name);
|
||||
}
|
||||
|
||||
// ----- Event Handlers ----- //
|
||||
|
||||
public void onPlayerConnect(PlayerEntity player)
|
||||
{
|
||||
// If the player was subscribed to the log and offline, move them to the set of online subscribers.
|
||||
String playerName = player.getName().getString();
|
||||
if (subscribedOfflinePlayers.containsKey(playerName))
|
||||
{
|
||||
subscribedOnlinePlayers.put(playerName, subscribedOfflinePlayers.get(playerName));
|
||||
subscribedOfflinePlayers.remove(playerName);
|
||||
}
|
||||
LoggerRegistry.setAccess(this);
|
||||
}
|
||||
|
||||
public void onPlayerDisconnect(PlayerEntity player)
|
||||
{
|
||||
// If the player was subscribed to the log, move them to the set of offline subscribers.
|
||||
String playerName = player.getName().getString();
|
||||
if (subscribedOnlinePlayers.containsKey(playerName))
|
||||
{
|
||||
subscribedOfflinePlayers.put(playerName, subscribedOnlinePlayers.get(playerName));
|
||||
subscribedOnlinePlayers.remove(playerName);
|
||||
}
|
||||
LoggerRegistry.setAccess(this);
|
||||
}
|
||||
|
||||
public String getAcceptedOption(String arg)
|
||||
{
|
||||
if (options != null && Arrays.asList(options).contains(arg)) return arg;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package carpet.logging;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class LoggerRegistry
|
||||
{
|
||||
// Map from logger names to loggers.
|
||||
private static Map<String, Logger> loggerRegistry = new HashMap<>();
|
||||
// Map from player names to the set of names of the logs that player is subscribed to.
|
||||
private static Map<String, Map<String, String>> playerSubscriptions = new HashMap<>();
|
||||
//statics to quickly asses if its worth even to call each one
|
||||
public static boolean __tnt;
|
||||
public static boolean __projectiles;
|
||||
public static boolean __fallingBlocks;
|
||||
public static boolean __kills;
|
||||
public static boolean __tps;
|
||||
public static boolean __counter;
|
||||
public static boolean __mobcaps;
|
||||
public static boolean __damage;
|
||||
public static boolean __packets;
|
||||
public static boolean __weather;
|
||||
|
||||
public static void initLoggers()
|
||||
{
|
||||
registerLogger("tnt", new Logger("tnt", "brief", new String[]{"brief", "full"}));
|
||||
registerLogger("projectiles", new Logger("projectiles", "brief", new String[]{"brief", "full"}));
|
||||
registerLogger("fallingBlocks",new Logger("fallingBlocks", "brief", new String[]{"brief", "full"}));
|
||||
registerLogger("kills", new Logger("kills", null, null));
|
||||
registerLogger("damage", new Logger("damage", "all", new String[]{"all","players","me"}));
|
||||
registerLogger("weather", new Logger("weather", null, null));
|
||||
|
||||
registerLogger("tps", new HUDLogger("tps", null, null));
|
||||
registerLogger("packets", new HUDLogger("packets", null, null));
|
||||
registerLogger("counter",new HUDLogger("counter","white", Arrays.stream(EnumDyeColor.values()).map(Object::toString).toArray(String[]::new)));
|
||||
registerLogger("mobcaps", new HUDLogger("mobcaps", "dynamic",new String[]{"dynamic", "overworld", "nether","end"}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the logger with the given name. Returns null if no such logger exists.
|
||||
*/
|
||||
public static Logger getLogger(String name) { return loggerRegistry.get(name); }
|
||||
|
||||
/**
|
||||
* Gets the set of logger names.
|
||||
*/
|
||||
public static Set<String> getLoggerNames() { return loggerRegistry.keySet(); }
|
||||
|
||||
/**
|
||||
* Subscribes the player with name playerName to the log with name logName.
|
||||
*/
|
||||
public static void subscribePlayer(String playerName, String logName, String option)
|
||||
{
|
||||
if (!playerSubscriptions.containsKey(playerName)) playerSubscriptions.put(playerName, new HashMap<>());
|
||||
Logger log = loggerRegistry.get(logName);
|
||||
if (option == null) option = log.getDefault();
|
||||
playerSubscriptions.get(playerName).put(logName,option);
|
||||
log.addPlayer(playerName, option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribes the player with name playerName from the log with name logName.
|
||||
*/
|
||||
public static void unsubscribePlayer(String playerName, String logName)
|
||||
{
|
||||
if (playerSubscriptions.containsKey(playerName))
|
||||
{
|
||||
Map<String,String> subscriptions = playerSubscriptions.get(playerName);
|
||||
subscriptions.remove(logName);
|
||||
loggerRegistry.get(logName).removePlayer(playerName);
|
||||
if (subscriptions.size() == 0) playerSubscriptions.remove(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the player is not subscribed to the log, then subscribe them. Otherwise, unsubscribe them.
|
||||
*/
|
||||
public static boolean togglePlayerSubscription(String playerName, String logName)
|
||||
{
|
||||
if (playerSubscriptions.containsKey(playerName) && playerSubscriptions.get(playerName).containsKey(logName))
|
||||
{
|
||||
unsubscribePlayer(playerName, logName);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
subscribePlayer(playerName, logName, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the set of logs the current player is subscribed to.
|
||||
*/
|
||||
public static Map<String,String> getPlayerSubscriptions(String playerName)
|
||||
{
|
||||
if (playerSubscriptions.containsKey(playerName))
|
||||
{
|
||||
return playerSubscriptions.get(playerName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static void setAccess(Logger logger)
|
||||
{
|
||||
String name = logger.getLogName();
|
||||
boolean value = logger.hasOnlineSubscribers();
|
||||
try
|
||||
{
|
||||
Field f = LoggerRegistry.class.getDeclaredField("__"+name);
|
||||
f.setBoolean(null, value);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
CarpetSettings.LOG.error("Cannot change logger quick access field");
|
||||
}
|
||||
catch (NoSuchFieldException e)
|
||||
{
|
||||
CarpetSettings.LOG.error("Wrong logger name");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called when the server starts. Creates the logs used by Carpet mod.
|
||||
*/
|
||||
private static void registerLogger(String name, Logger logger)
|
||||
{
|
||||
loggerRegistry.put(name, logger);
|
||||
setAccess(logger);
|
||||
}
|
||||
|
||||
public static void playerConnected(EntityPlayer player)
|
||||
{
|
||||
for(Logger log: loggerRegistry.values() )
|
||||
{
|
||||
log.onPlayerConnect(player);
|
||||
}
|
||||
|
||||
}
|
||||
public static void playerDisconnected(EntityPlayer player)
|
||||
{
|
||||
for(Logger log: loggerRegistry.values() )
|
||||
{
|
||||
log.onPlayerDisconnect(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package carpet.logging.logHelpers;
|
||||
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.utils.Messenger;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class DamageReporter
|
||||
{
|
||||
private static ITextComponent[] verifyAndProduceMessage(String option, EntityPlayer player, Entity from, Entity to, Supplier<ITextComponent> messageFuture)
|
||||
{
|
||||
if ("all".equalsIgnoreCase(option)
|
||||
|| ("players".equalsIgnoreCase(option) && (from instanceof EntityPlayer || to instanceof EntityPlayer))
|
||||
|| ("me".equalsIgnoreCase(option) && ( (from == player) || ( to == player) ) ))
|
||||
{
|
||||
return new ITextComponent[]{messageFuture.get()};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean register_damage_attacker(Entity target, EntityLivingBase source, float amount)
|
||||
{
|
||||
if (!LoggerRegistry.__damage) return true;
|
||||
LoggerRegistry.getLogger("damage").log( (option, player)->
|
||||
verifyAndProduceMessage(option, player, source, target, () ->
|
||||
Messenger.c(source.getDisplayName(),
|
||||
"g attacking ", target.getDisplayName(),"g for ",
|
||||
String.format("r %.2f",amount), "g points of damage")
|
||||
)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void register_damage(EntityLivingBase target, DamageSource source, float amount)
|
||||
{
|
||||
if (!LoggerRegistry.__damage) return;
|
||||
if (source.isFireDamage() && (target.isImmuneToFire() ||
|
||||
target.isPotionActive(MobEffects.FIRE_RESISTANCE)))
|
||||
return;
|
||||
LoggerRegistry.getLogger("damage").log( (option, player)->
|
||||
verifyAndProduceMessage(option, player, source.getTrueSource(), target, () ->
|
||||
Messenger.c(target.getDisplayName(),
|
||||
"g receiving ",
|
||||
String.format("r %.2f", amount),
|
||||
String.format("g points of damage from %s", source.getDamageType()))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static void register_final_damage(EntityLivingBase target, DamageSource source, float amount)
|
||||
{
|
||||
if (!LoggerRegistry.__damage) return;
|
||||
LoggerRegistry.getLogger("damage").log( (option, player)->
|
||||
verifyAndProduceMessage(option, player, source.getTrueSource(), target, () ->
|
||||
Messenger.c("g - total received ",
|
||||
String.format("r %.2f", amount),
|
||||
"g points of damage")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static void modify_damage(EntityLivingBase target, DamageSource source, float previous_amount, float final_amount, String component)
|
||||
{
|
||||
if (!LoggerRegistry.__damage)
|
||||
return;
|
||||
if (previous_amount == final_amount)
|
||||
return;
|
||||
if (source.isFireDamage() && (target.isImmuneToFire() ||
|
||||
target.isPotionActive(MobEffects.FIRE_RESISTANCE)))
|
||||
return;
|
||||
LoggerRegistry.getLogger("damage").log( (option, player)->
|
||||
verifyAndProduceMessage(option, player, source.getTrueSource(), target, () ->
|
||||
{
|
||||
if (final_amount == 0.0f)
|
||||
{
|
||||
return Messenger.c("g - reduced to ","r 0.0","g due to: "+component);
|
||||
}
|
||||
else if (previous_amount > final_amount)
|
||||
{
|
||||
float reduction = previous_amount-final_amount;
|
||||
return Messenger.c("g - reduced to ",
|
||||
String.format("l %.2f",final_amount),
|
||||
String.format("g by %.2f (%.1f%% less) due to: %s",reduction,100.0*reduction/previous_amount, component));
|
||||
}
|
||||
else
|
||||
{
|
||||
float increase = final_amount-previous_amount;
|
||||
return Messenger.c("g - increased to ",
|
||||
String.format("r %.2f",final_amount),
|
||||
String.format("g by %.2f (%.1f%% more) due to: %s",increase,100.0*increase/previous_amount, component));
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package carpet.logging.logHelpers;
|
||||
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.utils.Messenger;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class KillLogHelper {
|
||||
|
||||
public static void onSweep(String name, int count)
|
||||
{
|
||||
LoggerRegistry.getLogger("kills").log( () -> new ITextComponent[]{
|
||||
Messenger.c("g "+name+" smacked ","r "+count,"g entities with sweeping")});
|
||||
}
|
||||
|
||||
public static void onNonSweepAttack(String name)
|
||||
{
|
||||
LoggerRegistry.getLogger("kills").log( () -> new ITextComponent[]{
|
||||
Messenger.c("g "+name+" smacked ","r 1","g (no sweeping)")});
|
||||
}
|
||||
|
||||
public static void onDudHit(String name)
|
||||
{
|
||||
LoggerRegistry.getLogger("kills").log( () -> new ITextComponent[]{
|
||||
Messenger.c("g "+name+" dud hot = no one affected")});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package carpet.logging.logHelpers;
|
||||
|
||||
public class PacketCounter
|
||||
{
|
||||
public static long totalOut=0;
|
||||
public static long totalIn=0;
|
||||
public static void reset() {totalIn = 0l; totalOut = 0L; }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package carpet.logging.logHelpers;
|
||||
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.utils.Messenger;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class TNTLogHelper
|
||||
{
|
||||
private double primedX, primedY, primedZ, primedAngle;
|
||||
/**
|
||||
* Runs when the TNT is primed. Expects the position and motion angle of the TNT.
|
||||
*/
|
||||
public void onPrimed(double x, double y, double z, float angle)
|
||||
{
|
||||
primedX = x;
|
||||
primedY = y;
|
||||
primedZ = z;
|
||||
primedAngle = angle;
|
||||
}
|
||||
/**
|
||||
* Runs when the TNT explodes. Expects the position of the TNT.
|
||||
*/
|
||||
public void onExploded(double x, double y, double z)
|
||||
{
|
||||
LoggerRegistry.getLogger("tnt").log( (option) -> {
|
||||
switch (option)
|
||||
{
|
||||
case "brief":
|
||||
return new ITextComponent[]{Messenger.c(
|
||||
"l P ",Messenger.dblt("l",primedX,primedY,primedZ,primedAngle),
|
||||
"r E ",Messenger.dblt("r",x, y, z))};
|
||||
case "full":
|
||||
return new ITextComponent[]{Messenger.c(
|
||||
"l P ",Messenger.dblf("l",primedX,primedY,primedZ,primedAngle),
|
||||
"r E ",Messenger.dblf("r",x, y, z))};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package carpet.logging.logHelpers;
|
||||
|
||||
import carpet.logging.Logger;
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.utils.Messenger;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A generic log helper for logging the trajectory of things like blocks and throwables.
|
||||
*/
|
||||
public class TrajectoryLogHelper
|
||||
{
|
||||
private static final int MAX_TICKS_PER_LINE = 20;
|
||||
|
||||
private boolean doLog;
|
||||
private Logger logger;
|
||||
|
||||
private ArrayList<Vec3d> positions = new ArrayList<>();
|
||||
private ArrayList<Vec3d> motions = new ArrayList<>();
|
||||
|
||||
public TrajectoryLogHelper(String logName)
|
||||
{
|
||||
this.logger = LoggerRegistry.getLogger(logName);
|
||||
this.doLog = this.logger.hasOnlineSubscribers();
|
||||
}
|
||||
|
||||
public void onTick(double x, double y, double z, double motionX, double motionY, double motionZ)
|
||||
{
|
||||
if (!doLog) return;
|
||||
positions.add(new Vec3d(x, y, z));
|
||||
motions.add(new Vec3d(motionX, motionY, motionZ));
|
||||
}
|
||||
|
||||
public void onFinish()
|
||||
{
|
||||
if (!doLog) return;
|
||||
logger.log( (option) -> {
|
||||
List<ITextComponent> comp = new ArrayList<>();
|
||||
switch (option)
|
||||
{
|
||||
case "brief":
|
||||
comp.add(Messenger.s(""));
|
||||
List<String> line = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < positions.size(); i++)
|
||||
{
|
||||
Vec3d pos = positions.get(i);
|
||||
Vec3d mot = motions.get(i);
|
||||
line.add("w x");
|
||||
line.add(String.format("^w Tick: %d\nx: %f\ny: %f\nz: %f\n------------\nmx: %f\nmy: %f\nmz: %f",
|
||||
i, pos.x, pos.y, pos.z, mot.x, mot.y, mot.z));
|
||||
if ((((i+1) % MAX_TICKS_PER_LINE)==0) || i == positions.size()-1)
|
||||
{
|
||||
comp.add(Messenger.c(line.toArray(new Object[0])));
|
||||
line.clear();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "full":
|
||||
comp.add(Messenger.c("w ---------"));
|
||||
for (int i = 0; i < positions.size(); i++)
|
||||
{
|
||||
Vec3d pos = positions.get(i);
|
||||
Vec3d mot = motions.get(i);
|
||||
comp.add(Messenger.c(
|
||||
String.format("w tick: %3d pos",i),Messenger.dblt("w",pos.x, pos.y, pos.z),
|
||||
"w mot",Messenger.dblt("w",mot.x, mot.y, mot.z)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return comp.toArray(new ITextComponent[0]);
|
||||
});
|
||||
doLog = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user