Skip to content

Commit

Permalink
Added dimension criteria support
Browse files Browse the repository at this point in the history
  • Loading branch information
Greymerk committed Aug 6, 2014
1 parent 0806b00 commit 3577ea9
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 210 deletions.
2 changes: 1 addition & 1 deletion src/main/java/greymerk/roguelike/Roguelike.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid="Roguelike", name="Roguelike Dungeons", version="1.3.4.1")
@Mod(modid="Roguelike", name="Roguelike Dungeons", version="1.3.4.2")

public class Roguelike {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/greymerk/roguelike/catacomb/Catacomb.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static boolean canSpawnInChunk(int chunkX, int chunkZ, World world){
return false;
}

if(!RogueConfig.getIntList(RogueConfig.DIMENSION).contains((Integer)world.provider.dimensionId)){
if(!RogueConfig.getIntList(RogueConfig.DIMENSIONWL).contains((Integer)world.provider.dimensionId)){
return false;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public CatacombSettingsResolver(){
Arrays.sort(settingsFiles);
for(int i = 0; i < settingsFiles.length; ++i){
File toParse = settingsFiles[i];
System.out.println(toParse.getName());
CatacombSettings toAdd = parseFile(toParse);
settings.put(toAdd.getName(), toAdd);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package greymerk.roguelike.catacomb.settings;

import greymerk.roguelike.config.RogueConfig;
import greymerk.roguelike.worldgen.Coord;

import java.util.ArrayList;
Expand Down Expand Up @@ -74,14 +75,26 @@ public boolean isValid(World world, Coord pos){

Integer dimID = world.getWorldInfo().getVanillaDimension();

List<Integer> dimBL = new ArrayList<Integer>();

if(this.dimensionBlackList != null){
if(this.dimensionBlackList.contains(dimID)) return false;
this.dimensionBlackList.addAll(this.dimensionBlackList);
}

dimBL.addAll(RogueConfig.getIntList(RogueConfig.DIMENSIONBL));

if(dimBL.contains(dimID)) return false;

List<Integer> dimWL = new ArrayList<Integer>();

if(this.dimensionWhiteList != null){
if(!this.dimensionWhiteList.contains(dimID)) return false;
dimWL.addAll(this.dimensionWhiteList);
}

dimWL.addAll(RogueConfig.getIntList(RogueConfig.DIMENSIONWL));

if(!dimWL.isEmpty() && !dimWL.contains(dimID)) return false;

if(this.biomes != null){
BiomeGenBase biome = world.getBiomeGenForCoords(pos.getX(), pos.getZ());
if(!this.biomes.contains(biome.biomeName)) return false;
Expand Down
30 changes: 0 additions & 30 deletions src/main/java/greymerk/roguelike/catacomb/theme/Theme.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package greymerk.roguelike.catacomb.theme;

import net.minecraft.world.biome.BiomeGenBase;

import com.google.gson.JsonObject;

public enum Theme {
Expand Down Expand Up @@ -60,32 +58,4 @@ public static ITheme create(JsonObject json){
return new ThemeBase(primary, secondary);
}
}

public static ITheme getByLevel(BiomeGenBase biome, int level){

boolean hot = biome.temperature >= 0.91F;
boolean cold = biome.temperature <= 0.1F;
boolean wet = biome.rainfall >= 0.8F;
boolean dry = biome.rainfall <= 0.1;

switch(level){
case 0:
if(cold) return getTheme(SPRUCE);
if(hot && dry) return getTheme(SANDSTONE);
if(hot && wet) return getTheme(JUNGLE);
return getTheme(OAK);
case 1:
if(hot && dry) return getTheme(SANDSTONE);
if(hot && wet) return getTheme(JUNGLE);
return getTheme(DARKOAK);
case 2:
if(hot && wet) return getTheme(MOSSY);
return getTheme(CRYPT);
case 3:
if(hot && dry) return getTheme(CRYPT);
return getTheme(MOSSY);
case 4: return getTheme(NETHER);
default: return null;
}
}
}
4 changes: 1 addition & 3 deletions src/main/java/greymerk/roguelike/citadel/CitadelTower.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package greymerk.roguelike.citadel;

import greymerk.roguelike.catacomb.dungeon.DungeonCustomization;
import greymerk.roguelike.catacomb.theme.ITheme;
import greymerk.roguelike.catacomb.theme.Theme;
import greymerk.roguelike.worldgen.BlockWeightedRandom;
Expand Down Expand Up @@ -65,8 +64,7 @@ private Coord getBaseCoord(World world, int x, int y, int z){

public void generate(World world, Random rand, int x, int y, int z){

ITheme theme = DungeonCustomization.getTheme(world.getBiomeGenForCoords(x, z), 0);
if(theme == null) theme = Theme.getByLevel(world.getBiomeGenForCoords(x, z), 0);
ITheme theme = Theme.getTheme(Theme.OAK);


MetaBlock air = new MetaBlock(Blocks.air);
Expand Down
21 changes: 13 additions & 8 deletions src/main/java/greymerk/roguelike/config/RogueConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@

public enum RogueConfig {

DONATURALSPAWN, LEVELRANGE, LEVELMAXROOMS, LEVELSCATTER, SPAWNFREQUENCY, GENEROUS, MOBDROPS, DIMENSION,
PRECIOUSBLOCKS, LOOTING, OVERRIDELOOT;
DONATURALSPAWN, LEVELRANGE, LEVELMAXROOMS, LEVELSCATTER, SPAWNFREQUENCY, GENEROUS, MOBDROPS, DIMENSIONWL, DIMENSIONBL,
PRECIOUSBLOCKS, LOOTING;

public static final String configDirName = "config/roguelike_dungeons";
public static final String configFileName = "roguelike.cfg";

private static ConfigFile instance = null;

static{
init();
}

public static String getName(RogueConfig option){
switch(option){
case DONATURALSPAWN: return "doNaturalSpawn";
Expand All @@ -26,10 +30,10 @@ public static String getName(RogueConfig option){
case LEVELSCATTER: return "levelScatter";
case SPAWNFREQUENCY: return "spawnFrequency";
case GENEROUS: return "generous";
case DIMENSION: return "dimension";
case DIMENSIONWL: return "dimensionWL";
case DIMENSIONBL: return "dimensionBL";
case PRECIOUSBLOCKS: return "preciousBlocks";
case LOOTING: return "looting";
case OVERRIDELOOT: return "overrideLoot";
default: return null;
}
}
Expand All @@ -42,13 +46,14 @@ public static Tuple getDefault(RogueConfig option){
case LEVELSCATTER: return new Tuple(getName(option), 10);
case SPAWNFREQUENCY: return new Tuple(getName(option), 10);
case GENEROUS: return new Tuple(getName(option), true);
case DIMENSION:
case DIMENSIONWL:
List<Integer> ints = new ArrayList<Integer>();
ints.add(0);
return new Tuple(getName(option), ints);
case DIMENSIONBL:
return new Tuple(getName(option), new ArrayList<Integer>());
case PRECIOUSBLOCKS: return new Tuple(getName(option), true);
case LOOTING: return new Tuple(getName(option), 0.085D);
case OVERRIDELOOT: return new Tuple(getName(option), false);
default: return null;
}
}
Expand All @@ -61,10 +66,10 @@ private static void setDefaults(){
if(!instance.ContainsKey(getName(LEVELSCATTER)))setInt(LEVELSCATTER, (Integer)getDefault(LEVELSCATTER).getSecond());
if(!instance.ContainsKey(getName(SPAWNFREQUENCY)))setInt(SPAWNFREQUENCY, (Integer)getDefault(SPAWNFREQUENCY).getSecond());
if(!instance.ContainsKey(getName(GENEROUS))) setBoolean(GENEROUS, (Boolean)getDefault(GENEROUS).getSecond());
if(!instance.ContainsKey(getName(DIMENSION)))setIntList(DIMENSION, (List<Integer>)getDefault(DIMENSION).getSecond());
if(!instance.ContainsKey(getName(DIMENSIONWL)))setIntList(DIMENSIONWL, (List<Integer>)getDefault(DIMENSIONWL).getSecond());
if(!instance.ContainsKey(getName(DIMENSIONBL)))setIntList(DIMENSIONBL, (List<Integer>)getDefault(DIMENSIONBL).getSecond());
if(!instance.ContainsKey(getName(PRECIOUSBLOCKS)))setBoolean(PRECIOUSBLOCKS, (Boolean)getDefault(PRECIOUSBLOCKS).getSecond());
if(!instance.ContainsKey(getName(LOOTING)))setDouble(LOOTING, (Double) getDefault(LOOTING).getSecond());
//if(!instance.ContainsKey(getName(OVERRIDELOOT)))setBoolean(OVERRIDELOOT, (Boolean)getDefault(OVERRIDELOOT).getSecond());
}

public static double getDouble(RogueConfig option){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,20 @@ private ItemStack book(){
ItemStack book = new ItemStack(Items.written_book);

book.setTagInfo("author", new NBTTagString("greymerk"));
book.setTagInfo("title", new NBTTagString("Memo"));
book.setTagInfo("title", new NBTTagString("Dev notes"));

String page1 =
"Dear Eniko,\n\n " +
"Please stop storing the TNT under the floor, it's not very safe." +
" One of these days there's going to be an accident and we'll be" +
" left with a smoking crater in the middle of the base.\n\n" +
"TODO:\n\n " +
"- Witty start chest book\n" +
"- Trap the chests\n" +
"- Nerf the loot\n" +
"- Buff the mobs\n" +
"- Tweet @Eyamaz\n" +
"-greymerk\n";

String page2 =
"Roguelike Dungeons v1.3.4\n" +
"June 29th 2014\n\n" +
"Roguelike Dungeons v1.3.4.2\n" +
"Aug 6th 2014\n\n" +
"Credits\n\n" +
"Author: Greymerk\n\n" +
"Bits: Drainedsoul\n\n" +
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"modid" : "Roguelike",
"name" : "Roguelike Dungeons",
"description" : "Adds randomized dungeons to the world",
"version" : "1.3.4.1",
"version" : "1.3.4.2",
"url" : "dungeons.homelinux.org",
"authorList" : ["Greymerk"],
"mcversion" : "1.7.10"
Expand Down

0 comments on commit 3577ea9

Please sign in to comment.