fixed value not updating for labels

This commit is contained in:
gnembon committed 2020-07-27 04:40:53 -03:00
1 parent df16a3561a
commit a7a5a82c35
1 file changed
+20 -1
@@ -148,7 +148,7 @@ public class ShapesRenderer
RenderedShape<?> existing = shapes.computeIfAbsent(dim, d -> new Long2ObjectOpenHashMap<>()).get(key); RenderedShape<?> existing = shapes.computeIfAbsent(dim, d -> new Long2ObjectOpenHashMap<>()).get(key);
if (existing != null) if (existing != null)
{ // promoting previous shape { // promoting previous shape
existing.expiryTick = rshape.expiryTick; existing.promoteWith(rshape);
} }
else else
{ {
@@ -201,6 +201,11 @@ public class ShapesRenderer
{ {
return false; return false;
} }
public void promoteWith(RenderedShape<?> rshape)
{
expiryTick = rshape.expiryTick;
}
} }
public static class RenderedText extends RenderedShape<ShapeDispatcher.Text> public static class RenderedText extends RenderedShape<ShapeDispatcher.Text>
@@ -290,6 +295,20 @@ public class ShapesRenderer
{ {
return true; return true;
} }
@Override
public void promoteWith(RenderedShape<?> rshape)
{
super.promoteWith(rshape);
try
{
this.shape.value = ((ShapeDispatcher.Text) rshape.shape).value;
}
catch (ClassCastException ignored)
{
CarpetSettings.LOG.error("shape "+rshape.shape.getClass()+" cannot cast to a Label");
}
}
} }
public static class RenderedBox extends RenderedShape<ShapeDispatcher.Box> public static class RenderedBox extends RenderedShape<ShapeDispatcher.Box>