Revert "Log an error and skip shadows instead of crashing when mods set maxSchematicSize too high"

This reverts commit 1dedefd56c.
This commit is contained in:
Anuken
2025-12-01 19:59:19 -05:00
parent 87f7e1f1c2
commit ee8a258447

View File

@@ -59,7 +59,7 @@ public class Schematics implements Loadable{
private ObjectSet<Schematic> errored = new ObjectSet<>(); private ObjectSet<Schematic> errored = new ObjectSet<>();
private ObjectMap<CoreBlock, Seq<Schematic>> loadouts = new ObjectMap<>(); private ObjectMap<CoreBlock, Seq<Schematic>> loadouts = new ObjectMap<>();
private ObjectMap<CoreBlock, Schematic> defaultLoadouts = new ObjectMap<>(); private ObjectMap<CoreBlock, Schematic> defaultLoadouts = new ObjectMap<>();
private @Nullable FrameBuffer shadowBuffer; private FrameBuffer shadowBuffer;
private Texture errorTexture; private Texture errorTexture;
private long lastClearTime; private long lastClearTime;
@@ -99,14 +99,7 @@ public class Schematics implements Loadable{
all.sort(); all.sort();
if(shadowBuffer == null && !headless){ if(shadowBuffer == null && !headless){
Core.app.post(() -> { Core.app.post(() -> shadowBuffer = new FrameBuffer(maxSchematicSize + padding + 8, maxSchematicSize + padding + 8));
try{
shadowBuffer = new FrameBuffer(maxSchematicSize + padding + 8, maxSchematicSize + padding + 8);
}catch(Exception e){
Log.err(Strings.format("Failed to create shadow buffer (@x@): @. This is likely because a mod is setting maxSchematicSize too high. Don't do that.",
maxSchematicSize + padding + 8, maxSchematicSize + padding + 8, Strings.getSimpleMessage(e)));
}
});
} }
} }
@@ -222,7 +215,6 @@ public class Schematics implements Loadable{
Tmp.m2.set(Draw.trans()); Tmp.m2.set(Draw.trans());
FrameBuffer buffer = new FrameBuffer((schematic.width + padding) * resolution, (schematic.height + padding) * resolution); FrameBuffer buffer = new FrameBuffer((schematic.width + padding) * resolution, (schematic.height + padding) * resolution);
if(shadowBuffer != null){
shadowBuffer.begin(Color.clear); shadowBuffer.begin(Color.clear);
Draw.trans().idt(); Draw.trans().idt();
@@ -243,18 +235,15 @@ public class Schematics implements Loadable{
}); });
shadowBuffer.end(); shadowBuffer.end();
}
buffer.begin(Color.clear); buffer.begin(Color.clear);
Draw.proj().setOrtho(0, buffer.getHeight(), buffer.getWidth(), -buffer.getHeight()); Draw.proj().setOrtho(0, buffer.getHeight(), buffer.getWidth(), -buffer.getHeight());
if(shadowBuffer != null){
Tmp.tr1.set(shadowBuffer.getTexture(), 0, 0, schematic.width + padding, schematic.height + padding); Tmp.tr1.set(shadowBuffer.getTexture(), 0, 0, schematic.width + padding, schematic.height + padding);
Draw.color(0f, 0f, 0f, 1f); Draw.color(0f, 0f, 0f, 1f);
Draw.rect(Tmp.tr1, buffer.getWidth()/2f, buffer.getHeight()/2f, buffer.getWidth(), -buffer.getHeight()); Draw.rect(Tmp.tr1, buffer.getWidth()/2f, buffer.getHeight()/2f, buffer.getWidth(), -buffer.getHeight());
Draw.color(); Draw.color();
}
Seq<BuildPlan> plans = schematic.tiles.map(t -> new BuildPlan(t.x, t.y, t.rotation, t.block, t.config)); Seq<BuildPlan> plans = schematic.tiles.map(t -> new BuildPlan(t.x, t.y, t.rotation, t.block, t.config));
@@ -484,6 +473,10 @@ public class Schematics implements Loadable{
if(check && !(st.block instanceof CoreBlock)){ if(check && !(st.block instanceof CoreBlock)){
seq.clear(); seq.clear();
tile.getLinkedTilesAs(st.block, seq); tile.getLinkedTilesAs(st.block, seq);
//remove env blocks, or not?
//if(seq.contains(t -> !t.block().alwaysReplace && !t.synthetic())){
// return;
//}
for(var t : seq){ for(var t : seq){
if(t.block() != Blocks.air){ if(t.block() != Blocks.air){
t.remove(); t.remove();