You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
4.8 KiB
Java
139 lines
4.8 KiB
Java
package com.zivilon.cinder_loe;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.EnumSet;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import lotr.common.LOTRAchievement;
|
|
import lotr.common.fac.LOTRFaction;
|
|
import lotr.common.world.LOTRWorldProvider;
|
|
import lotr.common.world.LOTRWorldProviderMiddleEarth;
|
|
import lotr.common.world.LOTRWorldProviderUtumno;
|
|
import lotr.common.world.biome.LOTRBiome;
|
|
import net.minecraft.util.StatCollector;
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.world.WorldProvider;
|
|
import net.minecraftforge.common.DimensionManager;
|
|
import net.minecraftforge.common.config.Configuration;
|
|
|
|
import java.util.*;
|
|
|
|
public enum CinderDimension {
|
|
ISLAND("Island", 101, LOTRWorldProviderMiddleEarth.class, false, 500, EnumSet.of(DimensionRegion.REG));
|
|
|
|
public String dimensionName;
|
|
private int defaultID;
|
|
public int dimensionID;
|
|
private Class providerClass;
|
|
private boolean loadSpawn;
|
|
public LOTRBiome[] biomeList = new LOTRBiome[256];
|
|
public Map<Integer, Integer> colorsToBiomeIDs = new HashMap<Integer, Integer>();
|
|
public List<LOTRBiome> majorBiomes = new ArrayList<LOTRBiome>();
|
|
public List<LOTRAchievement.Category> achievementCategories = new ArrayList<LOTRAchievement.Category>();
|
|
public List<LOTRAchievement> allAchievements = new ArrayList<LOTRAchievement>();
|
|
public List<LOTRFaction> factionList = new ArrayList<LOTRFaction>();
|
|
public List<CinderDimension.DimensionRegion> dimensionRegions = new ArrayList<CinderDimension.DimensionRegion>();
|
|
public int spawnCap;
|
|
|
|
private CinderDimension(String s, int i, Class c, boolean flag, int spawns, EnumSet<DimensionRegion> regions) {
|
|
this.dimensionName = s;
|
|
this.defaultID = i;
|
|
this.providerClass = c;
|
|
this.loadSpawn = flag;
|
|
this.spawnCap = spawns;
|
|
this.dimensionRegions.addAll(regions);
|
|
for (DimensionRegion r : this.dimensionRegions) {
|
|
r.setDimension(this);
|
|
}
|
|
}
|
|
public String getUntranslatedDimensionName() {
|
|
return "lotr.dimension." + this.dimensionName;
|
|
}
|
|
|
|
public String getDimensionName() {
|
|
return StatCollector.translateToLocal((String)this.getUntranslatedDimensionName());
|
|
}
|
|
|
|
public static void configureDimensions(Configuration config, String category) {
|
|
for (CinderDimension dim : CinderDimension.values()) {
|
|
dim.dimensionID = config.get(category, "Dimension ID: " + dim.dimensionName, dim.defaultID).getInt();
|
|
}
|
|
}
|
|
|
|
public static void registerDimensions() {
|
|
for (CinderDimension dim : CinderDimension.values()) {
|
|
DimensionManager.registerProviderType((int)dim.dimensionID, (Class)dim.providerClass, (boolean)dim.loadSpawn);
|
|
DimensionManager.registerDimension((int)dim.dimensionID, (int)dim.dimensionID);
|
|
}
|
|
}
|
|
|
|
public static CinderDimension getCurrentDimension(World world) {
|
|
WorldProvider provider;
|
|
if (world != null && (provider = world.provider) instanceof LOTRWorldProvider) {
|
|
return ((LOTRWorldProvider)provider).getLOTRDimension();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static CinderDimension getCurrentDimensionWithFallback(World world) {
|
|
CinderDimension dim = CinderDimension.getCurrentDimension(world);
|
|
if (dim == null) {
|
|
return ISLAND;
|
|
}
|
|
return dim;
|
|
}
|
|
|
|
public static CinderDimension forName(String s) {
|
|
for (CinderDimension dim : CinderDimension.values()) {
|
|
if (!dim.dimensionName.equals(s)) continue;
|
|
return dim;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static enum DimensionRegion {
|
|
REG("island");
|
|
|
|
private String regionName;
|
|
private CinderDimension dimension;
|
|
public List<LOTRFaction> factionList = new ArrayList<LOTRFaction>();
|
|
|
|
private DimensionRegion(String s) {
|
|
this.regionName = s;
|
|
}
|
|
|
|
public void setDimension(CinderDimension dim) {
|
|
this.dimension = dim;
|
|
}
|
|
|
|
public CinderDimension getDimension() {
|
|
return this.dimension;
|
|
}
|
|
|
|
public String codeName() {
|
|
return this.regionName;
|
|
}
|
|
|
|
public String getRegionName() {
|
|
return StatCollector.translateToLocal((String)("lotr.dimension." + this.dimension.dimensionName + "." + this.codeName()));
|
|
}
|
|
|
|
public static DimensionRegion forName(String regionName) {
|
|
for (DimensionRegion r : DimensionRegion.values()) {
|
|
if (!r.codeName().equals(regionName)) continue;
|
|
return r;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static DimensionRegion forID(int ID) {
|
|
for (DimensionRegion r : DimensionRegion.values()) {
|
|
if (r.ordinal() != ID) continue;
|
|
return r;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|