detecting refreshed shapes
This commit is contained in:
1 parent
46536664c1
commit
6e4b5ebaf6
3 files changed
+147
-39
No files matched your search
@@ -74,6 +74,7 @@ public class ShapeDispatcher
|
||||
protected float r, g, b, a;
|
||||
protected int color;
|
||||
protected int duration = 0;
|
||||
private int key;
|
||||
public ExpiringShape(int duration, int color)
|
||||
{
|
||||
this.r = (float)(color >> 24 & 0xFF) / 255.0F;
|
||||
@@ -82,7 +83,8 @@ public class ShapeDispatcher
|
||||
this.a = (float)(color & 0xFF) / 255.0F;
|
||||
this.color = color;
|
||||
this.duration = duration;
|
||||
};
|
||||
key = 0;
|
||||
}
|
||||
|
||||
public int getExpiry() { return duration; };
|
||||
public CompoundTag toTag()
|
||||
@@ -93,6 +95,18 @@ public class ShapeDispatcher
|
||||
return tag;
|
||||
};
|
||||
public abstract Consumer<ServerPlayerEntity> alternative();
|
||||
public int key()
|
||||
{
|
||||
if (key!=0) return key;
|
||||
key = calcKey();
|
||||
return key;
|
||||
}
|
||||
protected int calcKey()
|
||||
{
|
||||
int hash = 17;
|
||||
hash = 31*hash + color;
|
||||
return hash;
|
||||
};
|
||||
}
|
||||
|
||||
public static class Box extends ExpiringShape
|
||||
@@ -146,6 +160,20 @@ public class ShapeDispatcher
|
||||
return p -> mesh(Collections.singletonList(p), particle, density, x1, y1, z1, x2, y2, z2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calcKey()
|
||||
{
|
||||
int hash = super.calcKey();
|
||||
hash = 31*hash + 1;
|
||||
hash = 31*hash + Float.hashCode(x1);
|
||||
hash = 31*hash + Float.hashCode(y1);
|
||||
hash = 31*hash + Float.hashCode(z1);
|
||||
hash = 31*hash + Float.hashCode(x2);
|
||||
hash = 31*hash + Float.hashCode(y2);
|
||||
hash = 31*hash + Float.hashCode(z2);
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static int mesh(List<ServerPlayerEntity> playerList, ParticleEffect particle, double density,
|
||||
double x1, double y1, double z1, double x2, double y2, double z2 )
|
||||
{
|
||||
@@ -217,6 +245,20 @@ public class ShapeDispatcher
|
||||
double density = Math.max(2.0, Math.sqrt(dx*dx+dy*dy+dz*dz) /50) / (a+0.1);
|
||||
return p -> drawParticleLine(Collections.singletonList(p), particle, pos1, pos2, density);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calcKey()
|
||||
{
|
||||
int hash = super.calcKey();
|
||||
hash = 31*hash + 2;
|
||||
hash = 31*hash + Float.hashCode(x1);
|
||||
hash = 31*hash + Float.hashCode(y1);
|
||||
hash = 31*hash + Float.hashCode(z1);
|
||||
hash = 31*hash + Float.hashCode(x2);
|
||||
hash = 31*hash + Float.hashCode(y2);
|
||||
hash = 31*hash + Float.hashCode(z2);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isStraight(Vec3d from, Vec3d to, double density)
|
||||
|
||||
Reference in new issue
Block a user