Skip to content

Commit 180606e

Browse files
committed
Remove upgraded structure caching
Performance improvement is minimal with rewritten DFU and it breaks structure generation on 1.21 for some reason
1 parent a6e0785 commit 180606e

File tree

3 files changed

+0
-229
lines changed

3 files changed

+0
-229
lines changed

common/src/main/java/org/embeddedt/modernfix/command/ModernFixCommands.java

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,9 @@
22

33
import com.mojang.brigadier.CommandDispatcher;
44
import net.minecraft.commands.CommandSourceStack;
5-
import net.minecraft.network.chat.Component;
6-
import net.minecraft.resources.ResourceLocation;
7-
import net.minecraft.server.level.ServerLevel;
8-
import net.minecraft.server.packs.resources.Resource;
9-
import net.minecraft.server.packs.resources.ResourceManager;
10-
import org.embeddedt.modernfix.ModernFix;
11-
import org.embeddedt.modernfix.structure.CachingStructureManager;
12-
13-
import java.io.InputStream;
14-
import java.util.Map;
15-
import java.util.regex.Matcher;
16-
import java.util.regex.Pattern;
17-
18-
import static net.minecraft.commands.Commands.literal;
195

206
public class ModernFixCommands {
217
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
22-
dispatcher.register(literal("modernfix")
23-
.then(literal("upgradeStructures")
24-
.requires(source -> source.hasPermission(3))
25-
.executes(context -> {
26-
ServerLevel level = context.getSource().getLevel();
27-
if(level == null) {
28-
context.getSource().sendFailure(Component.literal("Couldn't find server level"));
29-
return 0;
30-
}
31-
32-
ResourceManager manager = level.getServer().resources.resourceManager();
33-
Map<ResourceLocation, Resource> structures = manager.listResources("structures", p -> p.getPath().endsWith(".nbt"));
34-
int upgradedNum = 0;
35-
Pattern pathPattern = Pattern.compile("^structures/(.*)\\.nbt$");
36-
for(Map.Entry<ResourceLocation, Resource> entry : structures.entrySet()) {
37-
upgradedNum++;
38-
ResourceLocation found = entry.getKey();
39-
Matcher matcher = pathPattern.matcher(found.getPath());
40-
if(!matcher.matches())
41-
continue;
42-
ResourceLocation structureLocation = ResourceLocation.fromNamespaceAndPath(found.getNamespace(), matcher.group(1));
43-
try(InputStream resource = entry.getValue().open()) {
44-
CachingStructureManager.readStructureTag(structureLocation, level.getServer().getFixerUpper(), resource);
45-
Component msg = Component.literal("checked " + structureLocation + " (" + upgradedNum + "/" + structures.size() + ")");
46-
context.getSource().sendSuccess(() -> msg, false);
47-
} catch(Throwable e) {
48-
ModernFix.LOGGER.error("Couldn't upgrade structure " + found, e);
49-
context.getSource().sendFailure(Component.literal("error reading " + structureLocation + " (" + upgradedNum + "/" + structures.size() + ")"));
50-
}
51-
}
52-
53-
context.getSource().sendSuccess(() -> Component.literal("All structures upgraded"), false);
548

55-
return 1;
56-
}))
57-
);
589
}
5910
}

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/cache_upgraded_structures/StructureManagerMixin.java

Lines changed: 0 additions & 46 deletions
This file was deleted.

common/src/main/java/org/embeddedt/modernfix/structure/CachingStructureManager.java

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)