mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-26 14:00:14 +00:00
6 files changed
+29
-29
No files matched your search
+13
-7
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -66,20 +68,24 @@ public class StructureFunction implements Function<Boolean> {
|
|||||||
|
|
||||||
|
|
||||||
String app = id.apply(implementationArguments, scope);
|
String app = id.apply(implementationArguments, scope);
|
||||||
|
int xValue = FastMath.roundToInt(xz.getX());
|
||||||
|
int yValue = y.apply(implementationArguments, scope).intValue();
|
||||||
|
int zValue = FastMath.roundToInt(xz.getZ());
|
||||||
|
Vector3Int origin = Vector3Int.of(xValue, yValue, zValue);
|
||||||
return registry.getByID(app).map(script -> {
|
return registry.getByID(app).map(script -> {
|
||||||
if(script instanceof StructureScript structureScript) {
|
if(script instanceof StructureScript structureScript) {
|
||||||
return structureScript.generate(arguments.getOrigin(),
|
return structureScript.generate(origin,
|
||||||
arguments.getWorld()
|
arguments.getWorld()
|
||||||
.buffer(FastMath.roundToInt(xz.getX()),
|
.buffer(xValue,
|
||||||
y.apply(implementationArguments, scope).intValue(),
|
yValue,
|
||||||
FastMath.roundToInt(xz.getZ())),
|
zValue),
|
||||||
arguments.getRotation(), arguments.getRecursions() + 1);
|
arguments.getRotation(), arguments.getRecursions() + 1);
|
||||||
}
|
}
|
||||||
return script.generate(arguments.getOrigin(),
|
return script.generate(arguments.getOrigin(),
|
||||||
arguments.getWorld()
|
arguments.getWorld()
|
||||||
.buffer(FastMath.roundToInt(xz.getX()),
|
.buffer(xValue,
|
||||||
y.apply(implementationArguments, scope).intValue(),
|
yValue,
|
||||||
FastMath.roundToInt(xz.getZ())),
|
zValue),
|
||||||
arguments.getRotation());
|
arguments.getRotation());
|
||||||
}).orElseGet(() -> {
|
}).orElseGet(() -> {
|
||||||
LOGGER.error("No such structure {}", app);
|
LOGGER.error("No such structure {}", app);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import ca.solostudios.strata.version.Version;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.config.ConfigPack;
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.event.events.PackEvent;
|
||||||
import com.dfsek.terra.mod.config.VanillaWorldProperties;
|
import com.dfsek.terra.mod.config.VanillaWorldProperties;
|
||||||
|
|
||||||
import com.dfsek.terra.mod.util.MinecraftUtil;
|
import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||||
@@ -53,12 +54,8 @@ public abstract class MinecraftAddon implements BaseAddon {
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
modPlatform.getEventManager()
|
modPlatform.getEventManager()
|
||||||
.getHandler(FunctionalEventHandler.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
.register(this, ConfigurationLoadEvent.class)
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> event.loadTemplate(new VanillaWorldProperties()))
|
||||||
if(event.is(ConfigPack.class)) {
|
|
||||||
event.getLoadedObject(ConfigPack.class).getContext().put(event.load(new VanillaWorldProperties()));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.global();
|
.global();
|
||||||
modPlatform.getEventManager()
|
modPlatform.getEventManager()
|
||||||
.getHandler(FunctionalEventHandler.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ public class VanillaWorldProperties implements ConfigTemplate, Properties {
|
|||||||
@Default
|
@Default
|
||||||
private Boolean respawnAnchorWorks = false;
|
private Boolean respawnAnchorWorks = false;
|
||||||
|
|
||||||
@Value("minecraft.height")
|
@Value("minecraft.height.range")
|
||||||
@Default
|
@Default
|
||||||
private Range height = new ConstantRange(0, 16);
|
private Range height = new ConstantRange(0, 16);
|
||||||
|
|
||||||
|
|||||||
@@ -41,12 +41,18 @@ public class BiomeUtil {
|
|||||||
logger.info("Terra biomes registered.");
|
logger.info("Terra biomes registered.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RegistryKey<net.minecraft.world.biome.Biome> registerKey(Identifier identifier) {
|
||||||
|
return RegistryKey.of(Registry.BIOME_KEY, identifier);
|
||||||
|
}
|
||||||
|
|
||||||
protected static RegistryKey<net.minecraft.world.biome.Biome> registerBiome(Identifier identifier,
|
protected static RegistryKey<net.minecraft.world.biome.Biome> registerBiome(Identifier identifier,
|
||||||
net.minecraft.world.biome.Biome biome) {
|
net.minecraft.world.biome.Biome biome) {
|
||||||
|
RegistryKey key = registerKey(identifier);
|
||||||
|
if(!BuiltinRegistries.BIOME.contains(key)) {
|
||||||
BuiltinRegistries.add(BuiltinRegistries.BIOME,
|
BuiltinRegistries.add(BuiltinRegistries.BIOME,
|
||||||
MinecraftUtil.registerKey(identifier)
|
key.getValue(),
|
||||||
.getValue(),
|
|
||||||
biome);
|
biome);
|
||||||
|
}
|
||||||
return getBiomeKey(identifier);
|
return getBiomeKey(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,11 +69,7 @@ public class BiomeUtil {
|
|||||||
protected static void registerBiome(Biome biome, ConfigPack pack,
|
protected static void registerBiome(Biome biome, ConfigPack pack,
|
||||||
com.dfsek.terra.api.registry.key.RegistryKey id) {
|
com.dfsek.terra.api.registry.key.RegistryKey id) {
|
||||||
VanillaBiomeProperties vanillaBiomeProperties;
|
VanillaBiomeProperties vanillaBiomeProperties;
|
||||||
if (biome.getContext().has(VanillaBiomeProperties.class)) {
|
|
||||||
vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||||
} else {
|
|
||||||
vanillaBiomeProperties = new VanillaBiomeProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(vanillaBiomeProperties);
|
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(vanillaBiomeProperties);
|
||||||
|
|||||||
@@ -18,10 +18,13 @@ import java.util.OptionalLong;
|
|||||||
public class DimensionUtil {
|
public class DimensionUtil {
|
||||||
protected static RegistryKey<DimensionType> registerDimension(Identifier identifier,
|
protected static RegistryKey<DimensionType> registerDimension(Identifier identifier,
|
||||||
DimensionType dimension) {
|
DimensionType dimension) {
|
||||||
|
RegistryKey key = registerKey(identifier);
|
||||||
|
if(!BuiltinRegistries.BIOME.contains(key)) {
|
||||||
BuiltinRegistries.add(BuiltinRegistries.DIMENSION_TYPE,
|
BuiltinRegistries.add(BuiltinRegistries.DIMENSION_TYPE,
|
||||||
registerKey(identifier)
|
key
|
||||||
.getValue(),
|
.getValue(),
|
||||||
dimension);
|
dimension);
|
||||||
|
}
|
||||||
return getDimensionKey(identifier);
|
return getDimensionKey(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,11 +37,7 @@ public class DimensionUtil {
|
|||||||
|
|
||||||
protected static RegistryKey<DimensionType> registerDimension(ConfigPack pack) {
|
protected static RegistryKey<DimensionType> registerDimension(ConfigPack pack) {
|
||||||
VanillaWorldProperties vanillaWorldProperties;
|
VanillaWorldProperties vanillaWorldProperties;
|
||||||
if (pack.getContext().has(VanillaBiomeProperties.class)) {
|
|
||||||
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
|
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
|
||||||
} else {
|
|
||||||
vanillaWorldProperties = new VanillaWorldProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
DimensionType overworldDimensionType = new DimensionType(
|
DimensionType overworldDimensionType = new DimensionType(
|
||||||
vanillaWorldProperties.getFixedTime() == null ? OptionalLong.empty() : OptionalLong.of(vanillaWorldProperties.getFixedTime()),
|
vanillaWorldProperties.getFixedTime() == null ? OptionalLong.empty() : OptionalLong.of(vanillaWorldProperties.getFixedTime()),
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ public final class MinecraftUtil {
|
|||||||
TerraIntProvider.TERRA_RANGE_TYPE_TO_INT_PROVIDER_TYPE.put(ConstantRange.class, CONSTANT);
|
TerraIntProvider.TERRA_RANGE_TYPE_TO_INT_PROVIDER_TYPE.put(ConstantRange.class, CONSTANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RegistryKey<Biome> registerKey(Identifier identifier) {
|
|
||||||
return RegistryKey.of(Registry.BIOME_KEY, identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Biome createBiome(VanillaBiomeProperties vanillaBiomeProperties) {
|
public static Biome createBiome(VanillaBiomeProperties vanillaBiomeProperties) {
|
||||||
|
|
||||||
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();
|
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();
|
||||||
|
|||||||
Reference in new issue
Block a user