added breeding tracking

This commit is contained in:
gnembon committed 2019-07-28 09:01:30 -03:00
1 parent aac4563268
commit e021ca39b2
4 files changed
+158 -62

No files matched your search

@@ -1,5 +1,6 @@
package carpet.logging.logHelpers;
import carpet.helpers.ParticleDisplay;
import carpet.logging.LoggerRegistry;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
@@ -12,64 +13,6 @@ import net.minecraft.util.math.Vec3d;
public class PathfindingVisualizer
{
private static ParticleEffect failedPath;
private static ParticleEffect successfulPath;
private static ParticleEffect lvl1;
private static ParticleEffect lvl2;
private static ParticleEffect lvl3;
static
{
failedPath = parseParticle("angry_villager");
successfulPath = parseParticle("happy_villager");
lvl1 = parseParticle("dust 1 1 0 1");
lvl2 = parseParticle("dust 1 0.5 0 1");
lvl3 = parseParticle("dust 1 0 0 1");
}
private static void drawParticleLine(ServerPlayerEntity player, Vec3d from, Vec3d to, float ratio, boolean successful)
{
ParticleEffect accent = successful ? successfulPath : failedPath;
ParticleEffect color = (ratio < 2)? lvl1 : ((ratio < 4)?lvl2:lvl3);
((ServerWorld)player.world).spawnParticles(
player,
accent,
true,
from.x, from.y, from.z, 5,
0.5, 0.5, 0.5, 0.0);
double lineLengthSq = from.squaredDistanceTo(to);
if (lineLengthSq == 0) return;
Vec3d incvec = to.subtract(from).normalize();// multiply(50/sqrt(lineLengthSq));
int pcount = 0;
for (Vec3d delta = new Vec3d(0.0,0.0,0.0);
delta.lengthSquared()<lineLengthSq;
delta = delta.add(incvec.multiply(player.world.random.nextFloat())))
{
((ServerWorld)player.world).spawnParticles(
player,
color,
true,
delta.x+from.x, delta.y+from.y, delta.z+from.z, 1,
0.0, 0.0, 0.0, 0.0);
}
}
private static ParticleEffect parseParticle(String name)
{
try
{
return ParticleArgumentType.readParameters(new StringReader(name));
}
catch (CommandSyntaxException e)
{
throw new RuntimeException("No such particle: "+name);
}
}
public static void slowPath(Entity entity, Vec3d target, float miliseconds, boolean successful)
{
if (!LoggerRegistry.__pathfinding) return;
@@ -84,7 +27,10 @@ public class PathfindingVisualizer
return null;
if (minDuration < 1)
minDuration = 1;
drawParticleLine((ServerPlayerEntity) player, entity.getPos(), target, miliseconds/minDuration, successful );
String accent = successful ? "happy_villager" : "angry_villager";
String color = (miliseconds/minDuration < 2)? "dust 1 1 0 1" : ((miliseconds/minDuration < 4)?"dust 1 0.5 0 1":"dust 1 0 0 1");
ParticleDisplay.drawParticleLine((ServerPlayerEntity) player, entity.getPos(), target, color, accent, 5, 0.5);
return null;
});
}