Remove Vanilla Key

This commit is contained in:
Zoë
2022-07-11 13:49:55 -07:00
parent b1b91726ef
commit f26cedd613
19 changed files with 226 additions and 343 deletions

View File

@@ -22,6 +22,6 @@ public class BiomeFactory implements ConfigFactory<BiomeTemplate, Biome> {
@Override
public Biome build(BiomeTemplate template, Platform platform) {
return new UserDefinedBiome(template.getVanilla(), template);
return new UserDefinedBiome(template);
}
}

View File

@@ -21,7 +21,6 @@ import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.config.AbstractableTemplate;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.config.meta.Meta;
import com.dfsek.terra.api.world.biome.PlatformBiome;
@SuppressWarnings({ "FieldMayBeFinal", "unused" })
@@ -37,13 +36,11 @@ public class BiomeTemplate implements AbstractableTemplate, ValidatedConfigTempl
@Default
private List<String> extended = Collections.emptyList();
@Value("vanilla")
private @Meta PlatformBiome vanilla;
@Value("color")
@Final
@Default
private @Meta int color = 0;
@Value("tags")
@Default
private @Meta Set<@Meta String> tags = new HashSet<>();
@@ -77,8 +74,4 @@ public class BiomeTemplate implements AbstractableTemplate, ValidatedConfigTempl
public String getID() {
return id;
}
public PlatformBiome getVanilla() {
return vanilla;
}
}

View File

@@ -7,6 +7,8 @@
package com.dfsek.terra.addons.biome;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
import com.dfsek.terra.api.properties.Context;
@@ -18,7 +20,8 @@ import com.dfsek.terra.api.world.biome.PlatformBiome;
* Class representing a config-defined biome
*/
public class UserDefinedBiome implements Biome {
private final PlatformBiome vanilla;
private PlatformBiome platformBiome;
private final String id;
private final BiomeTemplate config;
private final int color;
@@ -26,8 +29,7 @@ public class UserDefinedBiome implements Biome {
private final Context context = new Context();
public UserDefinedBiome(PlatformBiome vanilla, BiomeTemplate config) {
this.vanilla = vanilla;
public UserDefinedBiome(BiomeTemplate config) {
this.id = config.getID();
this.config = config;
this.color = config.getColor();
@@ -41,14 +43,9 @@ public class UserDefinedBiome implements Biome {
return "{BIOME:" + getID() + "}";
}
/**
* Gets the Vanilla biomes to represent the custom biome.
*
* @return Collection of biomes to represent the custom biome.
*/
@Override
public PlatformBiome getPlatformBiome() {
return vanilla;
public @Nullable PlatformBiome getPlatformBiome() {
return platformBiome;
}
@Override
@@ -56,6 +53,15 @@ public class UserDefinedBiome implements Biome {
return color;
}
@Override
public void setPlatformBiome(PlatformBiome biome) {
if(platformBiome != null) {
throw new IllegalStateException("Platform biome already set");
}
this.platformBiome = biome;
}
@Override
public Set<String> getTags() {
return tags;

View File

@@ -8,6 +8,8 @@
package com.dfsek.terra.api.world.biome;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
import com.dfsek.terra.api.properties.PropertyHolder;
@@ -24,7 +26,7 @@ public interface Biome extends PropertyHolder, StringIdentifiable {
*
* @return The platform biome.
*/
PlatformBiome getPlatformBiome();
@Nullable PlatformBiome getPlatformBiome();
/**
* Get the color of this biome.
@@ -39,4 +41,9 @@ public interface Biome extends PropertyHolder, StringIdentifiable {
* @return A {@link Set} of String tags this biome holds.
*/
Set<String> getTags();
/**
* Sets the platform biome this custom biome delegates to.
*/
void setPlatformBiome(PlatformBiome biome);
}