mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-13 11:16:05 +00:00
implement namespaced registries
This commit is contained in:
@@ -62,7 +62,7 @@ public class TerraScriptAddon implements AddonInitializer {
|
||||
}
|
||||
})
|
||||
.toList()
|
||||
.forEach(structureScript -> structureRegistry.register(structureScript.getID(),
|
||||
.forEach(structureScript -> structureRegistry.register(addon.getKey(structureScript.getID()),
|
||||
structureScript)))
|
||||
.close();
|
||||
})
|
||||
|
||||
@@ -66,8 +66,9 @@ public class StructureScript implements Structure {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.id = id;
|
||||
|
||||
functionRegistry.forEach(parser::registerFunction); // Register registry functions.
|
||||
|
||||
//noinspection unchecked
|
||||
functionRegistry.forEach((key, function) -> parser.registerFunction(key.getID(), function)); // Register registry functions.
|
||||
|
||||
parser
|
||||
.registerFunction("block", new BlockFunctionBuilder(platform))
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.entity.Container;
|
||||
import com.dfsek.terra.api.event.events.world.generation.LootPopulateEvent;
|
||||
|
||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
@@ -66,7 +67,7 @@ public class LootFunction implements Function<Void> {
|
||||
String id = data.apply(implementationArguments, variableMap);
|
||||
|
||||
|
||||
registry.get(id)
|
||||
registry.get(RegistryKey.parse(id))
|
||||
.ifPresentOrElse(table -> {
|
||||
Vector3 apply = Vector3.of(FastMath.roundToInt(xz.getX()),
|
||||
y.apply(implementationArguments, variableMap)
|
||||
|
||||
@@ -9,10 +9,13 @@ package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.script.StructureScript;
|
||||
|
||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -68,7 +71,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
|
||||
|
||||
String app = id.apply(implementationArguments, variableMap);
|
||||
return registry.get(app).map(script -> {
|
||||
return registry.tryGet(app).map(script -> {
|
||||
Rotation rotation1;
|
||||
String rotString = rotations.get(arguments.getRandom().nextInt(rotations.size())).apply(implementationArguments, variableMap);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user