mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-05 07:16:10 +00:00
@@ -18,9 +18,8 @@ If you would like to test it with a default server config, just run `./gradlew s
|
||||
want a clean installation of the server, re-run the `setupServer` task. This will download a default server config
|
||||
from [here](https://github.com/PolyhedralDev/WorldGenTestServer)
|
||||
and install the server in the `target/server` directory, along with all the needed plugins.
|
||||
|
||||
**Note: You will need to adjust the `NAME` variable `bukkit.yml` of the test server if you are not using the default
|
||||
Terra config.**
|
||||
|
||||
**Note: You will need to adjust the `NAME` variable `bukkit.yml` of the test server if you are not using the default Terra config.**
|
||||
|
||||
## Contributing
|
||||
Contributions are welcome! If you want to see a feature in Terra, please, open an issue, or implement it yourself and
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.dfsek.terra.api.platform.world.generator;
|
||||
|
||||
import com.dfsek.terra.api.platform.Handle;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
|
||||
public interface GeneratorWrapper extends Handle {
|
||||
@Override
|
||||
TerraChunkGenerator getHandle();
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
@@ -24,12 +25,12 @@ public class DummyWorld implements World {
|
||||
|
||||
@Override
|
||||
public int getMaxHeight() {
|
||||
return 155;
|
||||
return 255;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getGenerator() {
|
||||
return () -> (ChunkGenerator) () -> null;
|
||||
return () -> (GeneratorWrapper) () -> null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
@@ -37,16 +37,16 @@ public class TerraWorld {
|
||||
safe = true;
|
||||
}
|
||||
|
||||
public TerraChunkGenerator getGenerator() {
|
||||
return (TerraChunkGenerator) ((ChunkGenerator) world.getGenerator().getHandle()).getHandle();
|
||||
public static boolean isTerraWorld(World w) {
|
||||
return w.getGenerator().getHandle() instanceof GeneratorWrapper;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public static boolean isTerraWorld(World w) {
|
||||
return w.getGenerator().getHandle() instanceof ChunkGenerator;
|
||||
public TerraChunkGenerator getGenerator() {
|
||||
return ((GeneratorWrapper) world.getGenerator().getHandle()).getHandle();
|
||||
}
|
||||
|
||||
public BiomeProvider getBiomeProvider() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.dfsek.terra.bukkit.generator;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.bukkit.population.PopulationManager;
|
||||
@@ -29,7 +30,7 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BukkitChunkGeneratorWrapper extends ChunkGenerator implements com.dfsek.terra.api.platform.world.generator.ChunkGenerator {
|
||||
public class BukkitChunkGeneratorWrapper extends ChunkGenerator implements GeneratorWrapper {
|
||||
|
||||
private static final Map<com.dfsek.terra.api.platform.world.World, PopulationManager> popMap = new HashMap<>();
|
||||
|
||||
|
||||
@@ -3,24 +3,10 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import net.fabricmc.loom.LoomGradleExtension
|
||||
import net.fabricmc.loom.task.RemapJarTask
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "Fabric"
|
||||
url = uri("https://maven.fabricmc.net/")
|
||||
}
|
||||
}
|
||||
// dependencies {
|
||||
// classpath("net.fabricmc:fabric-loom:+")
|
||||
// }
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("fabric-loom").version("0.5.9")
|
||||
`java-library`
|
||||
id("fabric-loom").version("0.6-SNAPSHOT")
|
||||
}
|
||||
//apply(plugin = "fabric-loom")
|
||||
|
||||
configureCommon()
|
||||
|
||||
@@ -31,33 +17,33 @@ tasks.named<ShadowJar>("shadowJar") {
|
||||
|
||||
group = "com.dfsek.terra.fabric"
|
||||
|
||||
dependencies {
|
||||
"shadedApi"(project(":common"))
|
||||
"shadedImplementation"("org.yaml:snakeyaml:1.27")
|
||||
"shadedImplementation"("com.googlecode.json-simple:json-simple:1.1.1")
|
||||
|
||||
"minecraft"("com.mojang:minecraft:1.16.5")
|
||||
"mappings"("net.fabricmc:yarn:1.16.5+build.5:v2")
|
||||
"modImplementation"("net.fabricmc:fabric-loader:0.11.2")
|
||||
|
||||
"modImplementation"("net.fabricmc.fabric-api:fabric-api:0.31.0+1.16")
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("org.json", "com.dfsek.terra.lib.json")
|
||||
relocate("org.yaml", "com.dfsek.terra.lib.yaml")
|
||||
}
|
||||
|
||||
|
||||
configure<LoomGradleExtension> {
|
||||
accessWidener("src/main/resources/terra.accesswidener")
|
||||
}
|
||||
|
||||
tasks.register<RemapJarTask>("remapShadedJar") {
|
||||
dependsOn("shadowJar")
|
||||
setProperty("input", file("build/libs/Terra-fabric-${version}-shaded.jar"))
|
||||
setProperty("addNestedDependencies", false)
|
||||
setProperty("remapAccessWidener", true)
|
||||
val shadowJar = tasks.getByName<ShadowJar>("shadowJar")
|
||||
dependsOn(shadowJar)
|
||||
input.set(shadowJar.archiveFile)
|
||||
archiveFileName.set(shadowJar.archiveFileName.get().replace(Regex("-shaded\\.jar$"), "-shaded-mapped.jar"))
|
||||
addNestedDependencies.set(true)
|
||||
remapAccessWidener.set(true)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"shadedApi"(project(":common"))
|
||||
"shadedImplementation"("org.yaml:snakeyaml:1.27")
|
||||
"shadedImplementation"("com.googlecode.json-simple:json-simple:1.1.1")
|
||||
|
||||
|
||||
// To change the versions see the gradle.properties file
|
||||
"minecraft"("com.mojang:minecraft:1.16.5")
|
||||
"mappings"("net.fabricmc:yarn:1.16.5+build.5:v2")
|
||||
"modImplementation"("net.fabricmc:fabric-loader:0.11.2")
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
"modImplementation"("net.fabricmc.fabric-api:fabric-api:0.31.0+1.16")
|
||||
|
||||
"compileOnly"("net.fabricmc:sponge-mixin:+")
|
||||
"annotationProcessor"("net.fabricmc:sponge-mixin:+")
|
||||
"annotationProcessor"("net.fabricmc:fabric-loom:+")
|
||||
}
|
||||
1
platforms/fabric/gradle.properties
Normal file
1
platforms/fabric/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
org.gradle.jvmargs=-Xmx4G
|
||||
@@ -30,6 +30,7 @@ import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.config.lang.Language;
|
||||
import com.dfsek.terra.config.pack.ConfigPack;
|
||||
import com.dfsek.terra.fabric.inventory.FabricItemHandle;
|
||||
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
|
||||
import com.dfsek.terra.fabric.world.FabricBiome;
|
||||
import com.dfsek.terra.fabric.world.FabricTree;
|
||||
import com.dfsek.terra.fabric.world.FabricWorldHandle;
|
||||
@@ -234,18 +235,15 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
generationSettings.surfaceBuilder(SurfaceBuilder.DEFAULT.withConfig(new TernarySurfaceConfig(Blocks.GRASS_BLOCK.getDefaultState(), Blocks.DIRT.getDefaultState(), Blocks.GRAVEL.getDefaultState()))); // It needs a surfacebuilder, even though we dont use it.
|
||||
generationSettings.feature(GenerationStep.Feature.VEGETAL_DECORATION, POPULATOR_CONFIGURED_FEATURE);
|
||||
|
||||
|
||||
BiomeEffects.Builder effects = new BiomeEffects.Builder()
|
||||
.waterColor(vanilla.getWaterColor())
|
||||
.waterFogColor(vanilla.getWaterFogColor())
|
||||
.fogColor(vanilla.getFogColor())
|
||||
.skyColor(vanilla.getSkyColor())
|
||||
.grassColorModifier(vanilla.getEffects().getGrassColorModifier());
|
||||
if(vanilla.getEffects().getGrassColor().isPresent()) {
|
||||
effects.grassColor(vanilla.getEffects().getGrassColor().get());
|
||||
}
|
||||
if(vanilla.getEffects().getFoliageColor().isPresent()) {
|
||||
effects.foliageColor(vanilla.getEffects().getFoliageColor().get());
|
||||
}
|
||||
.waterColor(vanilla.getEffects().waterColor)
|
||||
.waterFogColor(vanilla.getEffects().waterFogColor)
|
||||
.fogColor(vanilla.getEffects().fogColor)
|
||||
.skyColor(vanilla.getEffects().skyColor)
|
||||
.grassColorModifier(vanilla.getEffects().grassColorModifier);
|
||||
vanilla.getEffects().grassColor.ifPresent(effects::grassColor);
|
||||
vanilla.getEffects().foliageColor.ifPresent(effects::foliageColor);
|
||||
|
||||
return (new Biome.Builder())
|
||||
.precipitation(vanilla.getPrecipitation())
|
||||
@@ -296,8 +294,8 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
}
|
||||
};
|
||||
//noinspection ConstantConditions
|
||||
generatorType.translationKey = (new LiteralText("Terra:" + pack.getTemplate().getID()));
|
||||
GeneratorType.VALUES.add(generatorType);
|
||||
((GeneratorTypeAccessor) generatorType).setTranslationKey(new LiteralText("Terra:" + pack.getTemplate().getID()));
|
||||
GeneratorTypeAccessor.getVALUES().add(generatorType);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.dfsek.terra.api.platform.inventory.item.ItemMeta;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -29,7 +30,7 @@ public class FabricItemMeta implements ItemMeta {
|
||||
|
||||
delegate.getEnchantments().forEach(enchantment -> {
|
||||
CompoundTag eTag = (CompoundTag) enchantment;
|
||||
map.put(FabricAdapter.adapt(net.minecraft.enchantment.Enchantment.byRawId(eTag.getInt("id"))), eTag.getInt("lvl"));
|
||||
map.put(FabricAdapter.adapt(Registry.ENCHANTMENT.get(eTag.getInt("id"))), eTag.getInt("lvl"));
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.dfsek.terra.fabric.mixin;
|
||||
|
||||
import net.minecraft.client.world.GeneratorType;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(GeneratorType.class)
|
||||
public interface GeneratorTypeAccessor {
|
||||
@Accessor
|
||||
static List<GeneratorType> getVALUES() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Mutable
|
||||
@Accessor
|
||||
void setTranslationKey(Text translationKey);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.dfsek.terra.fabric.mixin;
|
||||
|
||||
import com.dfsek.terra.config.pack.ConfigPack;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.SimpleRegistry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.dimension.DimensionOptions;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.gen.GeneratorOptions;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
|
||||
// Mixins commented out until loom fixes multi-project builds.
|
||||
|
||||
//@Mixin(GeneratorOptions.class)
|
||||
public class MixinGeneratorOptions {
|
||||
//@Inject(method = "fromProperties(Lnet/minecraft/util/registry/DynamicRegistryManager;Ljava/util/Properties;)Lnet/minecraft/world/gen/GeneratorOptions;", at = @At("HEAD"), cancellable = true)
|
||||
private static void fromProperties(DynamicRegistryManager dynamicRegistryManager, Properties properties, CallbackInfoReturnable<GeneratorOptions> cir) {
|
||||
if(properties.get("level-type") == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String prop = properties.get("level-type").toString().trim();
|
||||
if(prop.startsWith("Terra")) {
|
||||
String seed = (String) MoreObjects.firstNonNull(properties.get("level-seed"), "");
|
||||
long l = new Random().nextLong();
|
||||
if(!seed.isEmpty()) {
|
||||
try {
|
||||
long m = Long.parseLong(seed);
|
||||
if(m != 0L) {
|
||||
l = m;
|
||||
}
|
||||
} catch(NumberFormatException exception) {
|
||||
l = seed.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
String generate_structures = (String) properties.get("generate-structures");
|
||||
boolean generateStructures = generate_structures == null || Boolean.parseBoolean(generate_structures);
|
||||
Registry<DimensionType> dimensionTypes = dynamicRegistryManager.get(Registry.DIMENSION_TYPE_KEY);
|
||||
Registry<Biome> biomes = dynamicRegistryManager.get(Registry.BIOME_KEY);
|
||||
Registry<ChunkGeneratorSettings> chunkGeneratorSettings = dynamicRegistryManager.get(Registry.NOISE_SETTINGS_WORLDGEN);
|
||||
SimpleRegistry<DimensionOptions> dimensionOptions = DimensionType.createDefaultDimensionOptions(dimensionTypes, biomes, chunkGeneratorSettings, l);
|
||||
|
||||
prop = prop.substring(prop.indexOf(":") + 1);
|
||||
|
||||
ConfigPack pack = TerraFabricPlugin.getInstance().getConfigRegistry().get(prop);
|
||||
|
||||
if(pack == null) throw new IllegalArgumentException("No such pack " + prop);
|
||||
|
||||
cir.setReturnValue(new GeneratorOptions(l, generateStructures, false, GeneratorOptions.method_28608(dimensionTypes, dimensionOptions, new FabricChunkGeneratorWrapper(new TerraBiomeSource(biomes, l, pack), l, pack))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.fabric.world.generator;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.config.pack.ConfigPack;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
||||
@@ -30,7 +32,7 @@ import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.StructuresConfig;
|
||||
import net.minecraft.world.gen.chunk.VerticalBlockSample;
|
||||
|
||||
public class FabricChunkGeneratorWrapper extends ChunkGenerator implements com.dfsek.terra.api.platform.world.generator.ChunkGenerator {
|
||||
public class FabricChunkGeneratorWrapper extends ChunkGenerator implements GeneratorWrapper {
|
||||
private final long seed;
|
||||
private final DefaultChunkGenerator3D delegate;
|
||||
private final TerraBiomeSource biomeSource;
|
||||
@@ -85,10 +87,6 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements com.d
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultChunkGenerator3D getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Codec<? extends ChunkGenerator> getCodec() {
|
||||
@@ -149,4 +147,9 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements com.d
|
||||
|
||||
return new VerticalBlockSample(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraChunkGenerator getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"terra.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.7.4",
|
||||
|
||||
16
platforms/fabric/src/main/resources/terra-refmap.json
Normal file
16
platforms/fabric/src/main/resources/terra-refmap.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"mappings": {
|
||||
"com/dfsek/terra/fabric/mixin/GeneratorTypeAccessor": {
|
||||
"VALUES": "field_25052:Ljava/util/List;",
|
||||
"translationKey": "field_25060:Lnet/minecraft/class_2561;"
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"named:intermediary": {
|
||||
"com/dfsek/terra/fabric/mixin/GeneratorTypeAccessor": {
|
||||
"VALUES": "field_25052:Ljava/util/List;",
|
||||
"translationKey": "field_25060:Lnet/minecraft/class_2561;"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,18 @@ accessWidener v1 named
|
||||
|
||||
extendable method net/minecraft/client/world/GeneratorType <init> (Ljava/lang/String;)V
|
||||
|
||||
accessible field net/minecraft/client/world/GeneratorType translationKey Lnet/minecraft/text/Text;
|
||||
mutable field net/minecraft/client/world/GeneratorType translationKey Lnet/minecraft/text/Text;
|
||||
|
||||
accessible field net/minecraft/client/world/GeneratorType VALUES Ljava/util/List;
|
||||
|
||||
accessible field net/minecraft/server/world/ServerWorld worldProperties Lnet/minecraft/world/level/ServerWorldProperties;
|
||||
|
||||
accessible method net/minecraft/world/MobSpawnerLogic getEntityId ()Lnet/minecraft/util/Identifier;
|
||||
|
||||
accessible field net/minecraft/state/State PROPERTY_MAP_PRINTER Ljava/util/function/Function;
|
||||
|
||||
accessible method net/minecraft/block/entity/LootableContainerBlockEntity setInvStackList (Lnet/minecraft/util/collection/DefaultedList;)V
|
||||
accessible method net/minecraft/block/entity/LootableContainerBlockEntity getInvStackList ()Lnet/minecraft/util/collection/DefaultedList;
|
||||
|
||||
accessible field net/minecraft/world/biome/BiomeEffects fogColor I
|
||||
accessible field net/minecraft/world/biome/BiomeEffects waterColor I
|
||||
accessible field net/minecraft/world/biome/BiomeEffects waterFogColor I
|
||||
accessible field net/minecraft/world/biome/BiomeEffects skyColor I
|
||||
|
||||
accessible field net/minecraft/world/biome/BiomeEffects foliageColor Ljava/util/Optional;
|
||||
accessible field net/minecraft/world/biome/BiomeEffects grassColor Ljava/util/Optional;
|
||||
accessible field net/minecraft/world/biome/BiomeEffects grassColorModifier Lnet/minecraft/world/biome/BiomeEffects$GrassColorModifier;
|
||||
|
||||
16
platforms/fabric/src/main/resources/terra.mixins.json
Normal file
16
platforms/fabric/src/main/resources/terra.mixins.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.dfsek.terra.fabric.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"GeneratorTypeAccessor"
|
||||
],
|
||||
"server": [],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"refmap": "terra-refmap.json"
|
||||
}
|
||||
Reference in New Issue
Block a user