Fix cache_upgraded_structures leaking open input streams
This commit is contained in:
parent
b1e91686da
commit
40b04cbded
|
|
@ -14,6 +14,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Mixin(StructureTemplateManager.class)
|
@Mixin(StructureTemplateManager.class)
|
||||||
|
|
@ -29,8 +30,8 @@ public class StructureManagerMixin {
|
||||||
@Overwrite
|
@Overwrite
|
||||||
private Optional<StructureTemplate> loadFromResource(ResourceLocation id) {
|
private Optional<StructureTemplate> loadFromResource(ResourceLocation id) {
|
||||||
ResourceLocation arg = new ResourceLocation(id.getNamespace(), "structures/" + id.getPath() + ".nbt");
|
ResourceLocation arg = new ResourceLocation(id.getNamespace(), "structures/" + id.getPath() + ".nbt");
|
||||||
try {
|
try(InputStream stream = this.resourceManager.open(arg)) {
|
||||||
return Optional.of(CachingStructureManager.readStructure(id, this.fixerUpper, this.resourceManager.open(arg)));
|
return Optional.of(CachingStructureManager.readStructure(id, this.fixerUpper, stream));
|
||||||
} catch(FileNotFoundException e) {
|
} catch(FileNotFoundException e) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user