mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 06:11:24 +00:00
use single-parameter Keyed registration
This commit is contained in:
+2
-2
@@ -8,7 +8,6 @@ import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
|||||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||||
import com.dfsek.terra.api.structure.Structure;
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
|
||||||
|
|
||||||
|
|
||||||
public class StructureBlockShortcutAddon implements AddonInitializer {
|
public class StructureBlockShortcutAddon implements AddonInitializer {
|
||||||
@@ -24,7 +23,8 @@ public class StructureBlockShortcutAddon implements AddonInitializer {
|
|||||||
.register(addon, ConfigPackPreLoadEvent.class)
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> event.getPack()
|
.then(event -> event.getPack()
|
||||||
.registerShortcut(Structure.class, "BLOCK",
|
.registerShortcut(Structure.class, "BLOCK",
|
||||||
(configLoader, input) -> new SingletonStructure(configLoader.loadType(BlockState.class, input))))
|
(configLoader, input) -> new SingletonStructure(configLoader.loadType(BlockState.class, input)
|
||||||
|
)))
|
||||||
.failThrough();
|
.failThrough();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-7
@@ -57,12 +57,13 @@ public class SpongeSchematicAddon implements AddonInitializer {
|
|||||||
.register(addon, ConfigPackPreLoadEvent.class)
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
CheckedRegistry<Structure> structureRegistry = event.getPack().getOrCreateRegistry(Structure.class);
|
CheckedRegistry<Structure> structureRegistry = event.getPack().getOrCreateRegistry(Structure.class);
|
||||||
event.getPack().getLoader().open("", ".schem").thenEntries(entries -> {
|
event.getPack()
|
||||||
for(Map.Entry<String, InputStream> entry : entries) {
|
.getLoader()
|
||||||
String id = StringUtil.fileName(entry.getKey());
|
.open("", ".schem")
|
||||||
structureRegistry.register(addon.key(id), convert(entry.getValue(), id));
|
.thenEntries(entries -> entries
|
||||||
}
|
.stream()
|
||||||
}).close();
|
.map(entry -> convert(entry.getValue(), StringUtil.fileName(entry.getKey())))
|
||||||
|
.forEach(structureRegistry::register)).close();
|
||||||
})
|
})
|
||||||
.failThrough();
|
.failThrough();
|
||||||
}
|
}
|
||||||
@@ -96,7 +97,7 @@ public class SpongeSchematicAddon implements AddonInitializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SpongeStructure(states, id);
|
return new SpongeStructure(states, addon.key(id));
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
throw new IllegalArgumentException("Failed to parse Sponge schematic: ", e);
|
throw new IllegalArgumentException("Failed to parse Sponge schematic: ", e);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -47,7 +47,7 @@ public class TerraScriptAddon implements AddonInitializer {
|
|||||||
try {
|
try {
|
||||||
String id = StringUtil.fileName(entry.getKey());
|
String id = StringUtil.fileName(entry.getKey());
|
||||||
return new StructureScript(entry.getValue(),
|
return new StructureScript(entry.getValue(),
|
||||||
id,
|
addon.key(id),
|
||||||
platform,
|
platform,
|
||||||
structureRegistry,
|
structureRegistry,
|
||||||
lootRegistry,
|
lootRegistry,
|
||||||
@@ -57,8 +57,7 @@ public class TerraScriptAddon implements AddonInitializer {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.toList()
|
.toList()
|
||||||
.forEach(structureScript -> structureRegistry.register(addon.key(structureScript.getID()),
|
.forEach(structureRegistry::register))
|
||||||
structureScript)))
|
|
||||||
.close();
|
.close();
|
||||||
})
|
})
|
||||||
.priority(2)
|
.priority(2)
|
||||||
|
|||||||
Reference in New Issue
Block a user