mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 02:20:57 +00:00
create Linked annotation and link TerraBiome and BiomeBuilder
This commit is contained in:
@@ -20,15 +20,16 @@ public class UserDefinedBiome implements TerraBiome {
|
||||
private final int color;
|
||||
private final Set<String> tags;
|
||||
|
||||
private final Context context = new Context();
|
||||
private final Context context;
|
||||
|
||||
public UserDefinedBiome(ProbabilityCollection<Biome> vanilla, UserDefinedGenerator gen, BiomeTemplate config) {
|
||||
public UserDefinedBiome(ProbabilityCollection<Biome> vanilla, UserDefinedGenerator gen, BiomeTemplate config, Context context) {
|
||||
this.vanilla = vanilla;
|
||||
this.gen = gen;
|
||||
this.id = config.getID();
|
||||
this.config = config;
|
||||
this.color = config.getColor();
|
||||
this.tags = config.getTags();
|
||||
this.context = context;
|
||||
tags.add("BIOME:" + id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.biome;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.seeded.BiomeBuilder;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
@@ -10,6 +10,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class UserDefinedBiomeBuilder implements BiomeBuilder {
|
||||
private final BiomeTemplate template;
|
||||
private final Context context = new Context();
|
||||
|
||||
private final Map<Long, UserDefinedBiome> biomeMap = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -24,7 +25,7 @@ public class UserDefinedBiomeBuilder implements BiomeBuilder {
|
||||
s -> {
|
||||
UserDefinedGenerator generator = new UserDefinedGenerator(template.getNoiseEquation().apply(seed), template.getElevationEquation().apply(seed), template.getCarvingEquation().apply(seed), template.getBiomeNoise().apply(seed), template.getElevationWeight(),
|
||||
template.getBlendDistance(), template.getBlendStep(), template.getBlendWeight());
|
||||
return new UserDefinedBiome(template.getVanilla(), generator, template);
|
||||
return new UserDefinedBiome(template.getVanilla(), generator, template, context);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -34,4 +35,9 @@ public class UserDefinedBiomeBuilder implements BiomeBuilder {
|
||||
public ProbabilityCollection<Biome> getVanillaBiomes() {
|
||||
return template.getVanilla();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.dfsek.terra.api.properties.annotations;
|
||||
|
||||
import com.dfsek.terra.api.properties.PropertyHolder;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Specifies that this property holder shares properties
|
||||
* with the {@link #value()} holder.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
public @interface Linked {
|
||||
Class<? extends PropertyHolder> value();
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.dfsek.terra.api.util.seeded;
|
||||
|
||||
import com.dfsek.terra.api.properties.PropertyHolder;
|
||||
import com.dfsek.terra.api.properties.annotations.Linked;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public interface BiomeBuilder extends SeededBuilder<TerraBiome> {
|
||||
@Linked(TerraBiome.class)
|
||||
public interface BiomeBuilder extends SeededBuilder<TerraBiome>, PropertyHolder {
|
||||
ProbabilityCollection<Biome> getVanillaBiomes();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.dfsek.terra.api.world.biome;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.properties.PropertyHolder;
|
||||
import com.dfsek.terra.api.properties.annotations.Linked;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.seeded.BiomeBuilder;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -10,6 +12,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Represents a custom biome
|
||||
*/
|
||||
@Linked(BiomeBuilder.class)
|
||||
public interface TerraBiome extends PropertyHolder {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user