Allow markers to use content/displays as textures (#11142)

* Allow markers to use content/displays as textures

* Don't process empty commands

* Allow canvases to be used as marker textures

* Proper Json serialization

---------

Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
Redstonneur1256
2025-12-28 03:37:03 +01:00
committed by GitHub
parent 7d3e3155f7
commit 59c3b18a6f
5 changed files with 118 additions and 41 deletions

View File

@@ -149,8 +149,7 @@ public class CanvasBlock extends Block{
public @Nullable Texture texture;
public byte[] data = new byte[Mathf.ceil(canvasSize * canvasSize * bitsPerPixel / 8f)];
public int blending;
protected boolean updated = false;
public boolean updated = false;
public void setPixel(int pos, int index){
if(pos < canvasSize * canvasSize && pos >= 0 && index >= 0 && index < palette.length){

View File

@@ -89,15 +89,7 @@ public class LogicDisplay extends Block{
//don't even bother processing anything when displays are off.
if(!Vars.renderer.drawDisplays) return;
Draw.draw(Draw.z(), () -> {
if(buffer == null){
buffer = new FrameBuffer(displaySize, displaySize);
//clear the buffer - some OSs leave garbage in it
buffer.begin(Pal.darkerMetal);
buffer.end();
}
});
Draw.draw(Draw.z(), this::ensureBuffer);
processCommands();
Draw.blend(Blending.disabled);
@@ -129,11 +121,20 @@ public class LogicDisplay extends Block{
operations++;
}
public void ensureBuffer() {
if(buffer == null){
buffer = new FrameBuffer(displaySize, displaySize);
//clear the buffer - some OSs leave garbage in it
buffer.begin(Pal.darkerMetal);
buffer.end();
}
}
public void processCommands(){
//don't bother processing commands if displays are off
if(!commands.isEmpty() && buffer != null){
Draw.draw(Draw.z(), () -> {
if(buffer == null) return;
if(buffer == null || commands.isEmpty()) return;
Tmp.m1.set(Draw.proj());
Tmp.m2.set(Draw.trans());